Added jukeboxes (patch contributed by Luksor)
git-svn-id: http://mc-server.googlecode.com/svn/trunk@994 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
e30bec4fd6
commit
3f9e876d70
@ -962,6 +962,14 @@
|
|||||||
RelativePath="..\source\FurnaceEntity.h"
|
RelativePath="..\source\FurnaceEntity.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\source\JukeboxEntity.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\source\JukeboxEntity.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\source\Ladder.h"
|
RelativePath="..\source\Ladder.h"
|
||||||
>
|
>
|
||||||
|
@ -107,6 +107,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
|||||||
case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
|
case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
|
||||||
case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType);
|
case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType);
|
||||||
case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType);
|
case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType);
|
||||||
|
case E_BLOCK_JUKEBOX: return new cBlockEntityHandler (a_BlockType);
|
||||||
case E_BLOCK_JUNGLE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
case E_BLOCK_JUNGLE_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
||||||
case E_BLOCK_LADDER: return new cBlockLadderHandler (a_BlockType);
|
case E_BLOCK_LADDER: return new cBlockLadderHandler (a_BlockType);
|
||||||
case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType);
|
case E_BLOCK_LAPIS_ORE: return new cBlockOreHandler (a_BlockType);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "FurnaceEntity.h"
|
#include "FurnaceEntity.h"
|
||||||
#include "SignEntity.h"
|
#include "SignEntity.h"
|
||||||
#include "NoteEntity.h"
|
#include "NoteEntity.h"
|
||||||
|
#include "JukeboxEntity.h"
|
||||||
#include "Torch.h"
|
#include "Torch.h"
|
||||||
#include "Ladder.h"
|
#include "Ladder.h"
|
||||||
#include "Pickup.h"
|
#include "Pickup.h"
|
||||||
@ -809,6 +810,15 @@ void cChunk::CreateBlockEntities(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case E_BLOCK_JUKEBOX:
|
||||||
|
{
|
||||||
|
if (!HasBlockEntityAt(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width))
|
||||||
|
{
|
||||||
|
m_BlockEntities.push_back(new cJukeboxEntity(x + m_PosX * Width, y + m_PosY * Height, z + m_PosZ * Width, m_World) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
} // switch (BlockType)
|
} // switch (BlockType)
|
||||||
} // for y
|
} // for y
|
||||||
} // for z
|
} // for z
|
||||||
@ -934,6 +944,11 @@ void cChunk::SetBlock( int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType
|
|||||||
AddBlockEntity(new cNoteEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
AddBlockEntity(new cNoteEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case E_BLOCK_JUKEBOX:
|
||||||
|
{
|
||||||
|
AddBlockEntity(new cJukeboxEntity(WorldPos.x, WorldPos.y, WorldPos.z, m_World));
|
||||||
|
break;
|
||||||
|
}
|
||||||
} // switch (a_BlockType)
|
} // switch (a_BlockType)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1757,6 +1772,22 @@ void cChunk::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunk::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
|
||||||
|
{
|
||||||
|
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||||
|
{
|
||||||
|
if (*itr == a_Exclude)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
(*itr)->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
|
||||||
|
} // for itr - LoadedByClient[]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
|
void cChunk::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
|
||||||
{
|
{
|
||||||
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
|
||||||
|
@ -197,7 +197,8 @@ public:
|
|||||||
void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
|
void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
|
void BroadcastThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
|
void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
|
||||||
void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL);
|
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
|
||||||
|
void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
|
void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
|
||||||
void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
|
void BroadcastChunkData (cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
|
||||||
|
|
||||||
|
@ -466,6 +466,25 @@ void cChunkMap::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, in
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cChunkMap::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
|
||||||
|
{
|
||||||
|
cCSLock Lock(m_CSLayers);
|
||||||
|
int ChunkX, ChunkZ;
|
||||||
|
|
||||||
|
cChunkDef::BlockToChunk(a_SrcX / 8, a_SrcY / 8, a_SrcZ / 8, ChunkX, ChunkZ);
|
||||||
|
cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ);
|
||||||
|
if (Chunk == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// It's perfectly legal to broadcast packets even to invalid chunks!
|
||||||
|
Chunk->BroadcastSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data, a_Exclude);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunkMap::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
|
void cChunkMap::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSLayers);
|
cCSLock Lock(m_CSLayers);
|
||||||
|
@ -78,6 +78,8 @@ public:
|
|||||||
|
|
||||||
void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
|
void BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
|
||||||
|
|
||||||
|
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
|
||||||
|
|
||||||
void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL);
|
void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL);
|
||||||
|
|
||||||
void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
|
void BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
|
||||||
|
@ -1485,6 +1485,15 @@ void cClientHandle::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cClientHandle::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
|
||||||
|
{
|
||||||
|
m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cClientHandle::SendBlockBreakAnim(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage)
|
void cClientHandle::SendBlockBreakAnim(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage)
|
||||||
{
|
{
|
||||||
m_Protocol->SendBlockBreakAnim(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage);
|
m_Protocol->SendBlockBreakAnim(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage);
|
||||||
|
@ -105,6 +105,7 @@ public:
|
|||||||
void SendPlayerSpawn (const cPlayer & a_Player);
|
void SendPlayerSpawn (const cPlayer & a_Player);
|
||||||
void SendRespawn (void);
|
void SendRespawn (void);
|
||||||
void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8
|
void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch); // a_Src coords are Block * 8
|
||||||
|
void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data);
|
||||||
void SendBlockBreakAnim (int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage);
|
void SendBlockBreakAnim (int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage);
|
||||||
void SendSpawnMob (const cMonster & a_Mob);
|
void SendSpawnMob (const cMonster & a_Mob);
|
||||||
void SendTeleportEntity (const cEntity & a_Entity);
|
void SendTeleportEntity (const cEntity & a_Entity);
|
||||||
|
123
source/JukeboxEntity.cpp
Normal file
123
source/JukeboxEntity.cpp
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
|
||||||
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
|
|
||||||
|
#include "JukeboxEntity.h"
|
||||||
|
#include "World.h"
|
||||||
|
#include <json/json.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cJukeboxEntity::cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
|
||||||
|
: cBlockEntity(E_BLOCK_JUKEBOX, a_BlockX, a_BlockY, a_BlockZ, a_World)
|
||||||
|
, m_Record( 0 )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cJukeboxEntity::~cJukeboxEntity()
|
||||||
|
{
|
||||||
|
if (m_Record >= 2256 && m_Record <= 2266)
|
||||||
|
{
|
||||||
|
EjectRecord();
|
||||||
|
m_Record = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cJukeboxEntity::UsedBy( cPlayer * a_Player )
|
||||||
|
{
|
||||||
|
if (m_Record == 0)
|
||||||
|
{
|
||||||
|
const cItem & HeldItem = a_Player->GetEquippedItem();
|
||||||
|
if (HeldItem.m_ItemType >= 2256 && HeldItem.m_ItemType <= 2266)
|
||||||
|
{
|
||||||
|
m_Record = HeldItem.m_ItemType;
|
||||||
|
a_Player->UseEquippedItem();
|
||||||
|
PlayRecord();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_Record >= 2256 && m_Record <= 2266)
|
||||||
|
{
|
||||||
|
EjectRecord();
|
||||||
|
m_Record = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cJukeboxEntity::PlayRecord( void )
|
||||||
|
{
|
||||||
|
m_World->BroadcastSoundParticleEffect(1005, m_PosX * 8, m_PosY * 8, m_PosZ * 8, m_Record);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cJukeboxEntity::EjectRecord( void )
|
||||||
|
{
|
||||||
|
cItems Drops;
|
||||||
|
Drops.push_back(cItem(m_Record, 1, 0));
|
||||||
|
m_World->SpawnItemPickups(Drops, m_PosX, m_PosY+1, m_PosZ);
|
||||||
|
m_World->BroadcastSoundParticleEffect(1005, m_PosX * 8, m_PosY * 8, m_PosZ * 8, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int cJukeboxEntity::GetRecord( void )
|
||||||
|
{
|
||||||
|
return m_Record;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cJukeboxEntity::SetRecord( int a_Record )
|
||||||
|
{
|
||||||
|
m_Record = a_Record;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cJukeboxEntity::LoadFromJson( const Json::Value & a_Value )
|
||||||
|
{
|
||||||
|
m_PosX = a_Value.get("x", 0).asInt();
|
||||||
|
m_PosY = a_Value.get("y", 0).asInt();
|
||||||
|
m_PosZ = a_Value.get("z", 0).asInt();
|
||||||
|
|
||||||
|
m_Record = a_Value.get("Record", 0).asInt();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cJukeboxEntity::SaveToJson( Json::Value & a_Value )
|
||||||
|
{
|
||||||
|
a_Value["x"] = m_PosX;
|
||||||
|
a_Value["y"] = m_PosY;
|
||||||
|
a_Value["z"] = m_PosZ;
|
||||||
|
|
||||||
|
a_Value["Record"] = m_Record;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
43
source/JukeboxEntity.h
Normal file
43
source/JukeboxEntity.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BlockEntity.h"
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Json
|
||||||
|
{
|
||||||
|
class Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cJukeboxEntity :
|
||||||
|
public cBlockEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cJukeboxEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
|
||||||
|
virtual ~cJukeboxEntity();
|
||||||
|
|
||||||
|
bool LoadFromJson( const Json::Value& a_Value );
|
||||||
|
virtual void SaveToJson( Json::Value& a_Value ) override;
|
||||||
|
|
||||||
|
int GetRecord( void );
|
||||||
|
void SetRecord( int a_Record );
|
||||||
|
void PlayRecord( void );
|
||||||
|
void EjectRecord( void );
|
||||||
|
virtual void UsedBy( cPlayer * a_Player ) override;
|
||||||
|
virtual void SendTo(cClientHandle & a_Client) override { };
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_Record;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -72,7 +72,8 @@ public:
|
|||||||
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
|
virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0;
|
||||||
virtual void SendRespawn (void) = 0;
|
virtual void SendRespawn (void) = 0;
|
||||||
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8
|
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) = 0; // a_Src coords are Block * 8
|
||||||
virtual void SendBlockBreakAnim (int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage) = 0;
|
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) = 0;
|
||||||
|
virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) = 0;
|
||||||
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
|
virtual void SendSpawnMob (const cMonster & a_Mob) = 0;
|
||||||
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
|
virtual void SendTeleportEntity (const cEntity & a_Entity) = 0;
|
||||||
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
|
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
|
||||||
|
@ -69,7 +69,8 @@ enum
|
|||||||
PACKET_BLOCK_CHANGE = 0x35,
|
PACKET_BLOCK_CHANGE = 0x35,
|
||||||
PACKET_BLOCK_ACTION = 0x36,
|
PACKET_BLOCK_ACTION = 0x36,
|
||||||
PACKET_EXPLOSION = 0x3C,
|
PACKET_EXPLOSION = 0x3C,
|
||||||
PACKET_SOUND_EFFECT = 0x3D,
|
PACKET_SOUND_EFFECT = 0x3e,
|
||||||
|
PACKET_SOUND_PARTICLE_EFFECT = 0x3d,
|
||||||
PACKET_CHANGE_GAME_STATE = 0x46,
|
PACKET_CHANGE_GAME_STATE = 0x46,
|
||||||
PACKET_THUNDERBOLT = 0x47,
|
PACKET_THUNDERBOLT = 0x47,
|
||||||
PACKET_WINDOW_OPEN = 0x64,
|
PACKET_WINDOW_OPEN = 0x64,
|
||||||
@ -592,6 +593,15 @@ void cProtocol125::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol125::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
|
||||||
|
{
|
||||||
|
// Not implemented in this protocol version
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol125::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
|
void cProtocol125::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
|
||||||
{
|
{
|
||||||
// Not supported in this protocol version
|
// Not supported in this protocol version
|
||||||
|
@ -56,7 +56,8 @@ public:
|
|||||||
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
|
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
|
||||||
virtual void SendRespawn (void) override;
|
virtual void SendRespawn (void) override;
|
||||||
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
|
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
|
||||||
virtual void SendBlockBreakAnim (int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage) override;
|
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
|
||||||
|
virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override;
|
||||||
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
||||||
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
||||||
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||||
|
@ -64,7 +64,8 @@ enum
|
|||||||
PACKET_BLOCK_CHANGE = 0x35,
|
PACKET_BLOCK_CHANGE = 0x35,
|
||||||
PACKET_BLOCK_ACTION = 0x36,
|
PACKET_BLOCK_ACTION = 0x36,
|
||||||
PACKET_BLOCK_BREAK_ANIM = 0x37,
|
PACKET_BLOCK_BREAK_ANIM = 0x37,
|
||||||
PACKET_SOUND_EFFECT = 0x3e
|
PACKET_SOUND_EFFECT = 0x3e,
|
||||||
|
PACKET_SOUND_PARTICLE_EFFECT = 0x3d
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
@ -378,6 +379,22 @@ void cProtocol132::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol132::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
|
||||||
|
{
|
||||||
|
cCSLock Lock(m_CSPacket);
|
||||||
|
WriteByte(PACKET_SOUND_PARTICLE_EFFECT);
|
||||||
|
WriteInt (a_EffectID);
|
||||||
|
WriteInt (a_SrcX / 8);
|
||||||
|
WriteByte(a_SrcY / 8);
|
||||||
|
WriteInt (a_SrcZ / 8);
|
||||||
|
WriteInt (a_Data);
|
||||||
|
Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol132::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
|
void cProtocol132::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSPacket);
|
cCSLock Lock(m_CSPacket);
|
||||||
|
@ -39,7 +39,8 @@ public:
|
|||||||
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
|
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
|
||||||
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
|
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
|
||||||
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
|
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8
|
||||||
virtual void SendBlockBreakAnim (int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage) override;
|
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
|
||||||
|
virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override;
|
||||||
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
||||||
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
|
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
|
||||||
virtual void SendWholeInventory (const cWindow & a_Window) override;
|
virtual void SendWholeInventory (const cWindow & a_Window) override;
|
||||||
|
@ -356,7 +356,9 @@ void cProtocolRecognizer::SendRespawn(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) {
|
|
||||||
|
void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
|
||||||
|
{
|
||||||
ASSERT(m_Protocol != NULL);
|
ASSERT(m_Protocol != NULL);
|
||||||
m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
|
m_Protocol->SendSoundEffect(a_SoundName, a_SrcX, a_SrcY, a_SrcZ, a_Volume, a_Pitch);
|
||||||
}
|
}
|
||||||
@ -365,6 +367,16 @@ void cProtocolRecognizer::SendSoundEffect(const AString & a_SoundName, int a_Src
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocolRecognizer::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
|
||||||
|
{
|
||||||
|
ASSERT(m_Protocol != NULL);
|
||||||
|
m_Protocol->SendSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocolRecognizer::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
|
void cProtocolRecognizer::SendBlockBreakAnim(int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage)
|
||||||
{
|
{
|
||||||
ASSERT(m_Protocol != NULL);
|
ASSERT(m_Protocol != NULL);
|
||||||
|
@ -67,7 +67,8 @@ public:
|
|||||||
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
|
virtual void SendPlayerSpawn (const cPlayer & a_Player) override;
|
||||||
virtual void SendRespawn (void) override;
|
virtual void SendRespawn (void) override;
|
||||||
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override;
|
virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override;
|
||||||
virtual void SendBlockBreakAnim (int a_entityID, int a_BlockX, int a_BlockY, int a_BlockZ, char stage) override;
|
virtual void SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
|
||||||
|
virtual void SendBlockBreakAnim (int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage) override;
|
||||||
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
||||||
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
virtual void SendTeleportEntity (const cEntity & a_Entity) override;
|
||||||
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||||
|
@ -1475,9 +1475,18 @@ void cWorld::BroadcastSoundEffect(const AString & a_SoundName, int a_SrcX, int a
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWorld::BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude )
|
void cWorld::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude)
|
||||||
{
|
{
|
||||||
m_ChunkMap->BroadcastBlockBreakAnimation(a_entityID, a_blockX, a_blockY, a_blockZ, a_stage, a_Exclude);
|
m_ChunkMap->BroadcastSoundParticleEffect(a_EffectID, a_SrcX, a_SrcY, a_SrcZ, a_Data, a_Exclude);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cWorld::BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude )
|
||||||
|
{
|
||||||
|
m_ChunkMap->BroadcastBlockBreakAnimation(a_EntityID, a_BlockX, a_BlockY, a_BlockZ, a_Stage, a_Exclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,8 @@ public:
|
|||||||
void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
|
void BroadcastChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL);
|
void BroadcastPlayerListItem (const cPlayer & a_Player, bool a_IsOnline, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
|
void BroadcastSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL); // a_Src coords are Block * 8
|
||||||
void BroadcastBlockBreakAnimation(int a_entityID, int a_blockX, int a_blockY, int a_blockZ, char a_stage, const cClientHandle * a_Exclude = NULL);
|
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL);
|
||||||
|
void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL);
|
||||||
void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
|
void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ );
|
||||||
|
|
||||||
/// If there is a block entity at the specified coods, sends it to all clients except a_Exclude
|
/// If there is a block entity at the specified coods, sends it to all clients except a_Exclude
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "../FurnaceEntity.h"
|
#include "../FurnaceEntity.h"
|
||||||
#include "../SignEntity.h"
|
#include "../SignEntity.h"
|
||||||
#include "../NoteEntity.h"
|
#include "../NoteEntity.h"
|
||||||
|
#include "../JukeboxEntity.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../StringCompression.h"
|
#include "../StringCompression.h"
|
||||||
#include "../Entity.h"
|
#include "../Entity.h"
|
||||||
@ -156,6 +157,13 @@ protected:
|
|||||||
m_Writer.EndCompound();
|
m_Writer.EndCompound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddJukeboxEntity(cJukeboxEntity * a_Jukebox)
|
||||||
|
{
|
||||||
|
m_Writer.BeginCompound("");
|
||||||
|
AddBasicTileEntity(a_Jukebox, "RecordPlayer");
|
||||||
|
m_Writer.AddInt("Record", a_Jukebox->GetRecord());
|
||||||
|
m_Writer.EndCompound();
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool LightIsValid(bool a_IsLightValid) override
|
virtual bool LightIsValid(bool a_IsLightValid) override
|
||||||
{
|
{
|
||||||
@ -194,6 +202,7 @@ protected:
|
|||||||
case E_BLOCK_SIGN_POST:
|
case E_BLOCK_SIGN_POST:
|
||||||
case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
|
case E_BLOCK_WALLSIGN: AddSignEntity ((cSignEntity *) a_Entity); break;
|
||||||
case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
|
case E_BLOCK_NOTE_BLOCK: AddNoteEntity ((cNoteEntity *) a_Entity); break;
|
||||||
|
case E_BLOCK_JUKEBOX: AddJukeboxEntity((cJukeboxEntity *)a_Entity); break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ASSERT(!"Unhandled block entity saved into Anvil");
|
ASSERT(!"Unhandled block entity saved into Anvil");
|
||||||
@ -662,6 +671,10 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
|
|||||||
{
|
{
|
||||||
LoadNoteFromNBT(a_BlockEntities, a_NBT, Child);
|
LoadNoteFromNBT(a_BlockEntities, a_NBT, Child);
|
||||||
}
|
}
|
||||||
|
else if (strncmp(a_NBT.GetData(sID), "RecordPlayer", a_NBT.GetDataLength(sID)) == 0)
|
||||||
|
{
|
||||||
|
LoadJukeboxFromNBT(a_BlockEntities, a_NBT, Child);
|
||||||
|
}
|
||||||
// TODO: Other block entities
|
// TODO: Other block entities
|
||||||
} // for Child - tag children
|
} // for Child - tag children
|
||||||
}
|
}
|
||||||
@ -844,6 +857,27 @@ void cWSSAnvil::LoadNoteFromNBT(cBlockEntityList & a_BlockEntities, const cParse
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cWSSAnvil::LoadJukeboxFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||||
|
{
|
||||||
|
ASSERT(a_NBT.GetType(a_TagIdx) == TAG_Compound);
|
||||||
|
int x, y, z;
|
||||||
|
if (!GetBlockEntityNBTPos(a_NBT, a_TagIdx, x, y, z))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::auto_ptr<cJukeboxEntity> Jukebox(new cJukeboxEntity(x, y, z, m_World));
|
||||||
|
int Record = a_NBT.FindChildByName(a_TagIdx, "Record");
|
||||||
|
if (Record >= 0)
|
||||||
|
{
|
||||||
|
Jukebox->SetRecord(a_NBT.GetInt(Record));
|
||||||
|
}
|
||||||
|
a_BlockEntities.push_back(Jukebox.release());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cWSSAnvil::GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int & a_X, int & a_Y, int & a_Z)
|
bool cWSSAnvil::GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int & a_X, int & a_Y, int & a_Z)
|
||||||
{
|
{
|
||||||
int x = a_NBT.FindChildByName(a_TagIdx, "x");
|
int x = a_NBT.FindChildByName(a_TagIdx, "x");
|
||||||
|
@ -112,6 +112,7 @@ protected:
|
|||||||
void LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
void LoadFurnaceFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||||
void LoadSignFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
void LoadSignFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||||
void LoadNoteFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
void LoadNoteFromNBT (cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||||
|
void LoadJukeboxFromNBT(cBlockEntityList & a_BlockEntities, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||||
|
|
||||||
/// Helper function for extracting the X, Y, and Z int subtags of a NBT compound; returns true if successful
|
/// Helper function for extracting the X, Y, and Z int subtags of a NBT compound; returns true if successful
|
||||||
bool GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int & a_X, int & a_Y, int & a_Z);
|
bool GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int & a_X, int & a_Y, int & a_Z);
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "../SignEntity.h"
|
#include "../SignEntity.h"
|
||||||
#include "../FurnaceEntity.h"
|
#include "../FurnaceEntity.h"
|
||||||
#include "../NoteEntity.h"
|
#include "../NoteEntity.h"
|
||||||
|
#include "../JukeboxEntity.h"
|
||||||
#include "../BlockID.h"
|
#include "../BlockID.h"
|
||||||
|
|
||||||
|
|
||||||
@ -75,6 +76,7 @@ void cJsonChunkSerializer::BlockEntity(cBlockEntity * a_BlockEntity)
|
|||||||
case E_BLOCK_SIGN_POST: SaveInto = "Signs"; break;
|
case E_BLOCK_SIGN_POST: SaveInto = "Signs"; break;
|
||||||
case E_BLOCK_WALLSIGN: SaveInto = "Signs"; break;
|
case E_BLOCK_WALLSIGN: SaveInto = "Signs"; break;
|
||||||
case E_BLOCK_NOTE_BLOCK: SaveInto = "Notes"; break;
|
case E_BLOCK_NOTE_BLOCK: SaveInto = "Notes"; break;
|
||||||
|
case E_BLOCK_JUKEBOX: SaveInto = "Jukeboxes"; break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -338,6 +340,26 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
|
|||||||
}
|
}
|
||||||
} // for itr - AllNotes[]
|
} // for itr - AllNotes[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load jukeboxes
|
||||||
|
Json::Value AllJukeboxes = a_Value.get("Jukeboxes", Json::nullValue);
|
||||||
|
if( !AllJukeboxes.empty() )
|
||||||
|
{
|
||||||
|
for( Json::Value::iterator itr = AllJukeboxes.begin(); itr != AllJukeboxes.end(); ++itr )
|
||||||
|
{
|
||||||
|
Json::Value & Jukebox = *itr;
|
||||||
|
cJukeboxEntity * JukeboxEntity = new cJukeboxEntity(0, 0, 0, a_World);
|
||||||
|
if ( !JukeboxEntity->LoadFromJson( Jukebox ) )
|
||||||
|
{
|
||||||
|
LOGERROR("ERROR READING JUKEBOX FROM JSON!" );
|
||||||
|
delete JukeboxEntity;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
a_BlockEntities.push_back( JukeboxEntity );
|
||||||
|
}
|
||||||
|
} // for itr - AllJukeboxes[]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user