1
0

Improved maps

This commit is contained in:
Tiger Wang 2015-06-30 15:50:15 +01:00
parent 9d4d25cdbf
commit 8656e149c8
104 changed files with 946 additions and 938 deletions

View File

@ -62,7 +62,7 @@ enum ENUM_BLOCK_ID // tolua_export
E_BLOCK_TORCH = 50,
E_BLOCK_FIRE = 51,
E_BLOCK_MOB_SPAWNER = 52,
E_BLOCK_WOODEN_STAIRS = 53,
E_BLOCK_OAK_WOOD_STAIRS = 53,
E_BLOCK_CHEST = 54,
E_BLOCK_REDSTONE_WIRE = 55,
E_BLOCK_DIAMOND_ORE = 56,
@ -75,7 +75,7 @@ enum ENUM_BLOCK_ID // tolua_export
E_BLOCK_LIT_FURNACE = 62,
E_BLOCK_BURNING_FURNACE = 62,
E_BLOCK_SIGN_POST = 63,
E_BLOCK_WOODEN_DOOR = 64,
E_BLOCK_OAK_DOOR = 64,
E_BLOCK_LADDER = 65,
E_BLOCK_RAIL = 66,
E_BLOCK_MINECART_TRACKS = 66,
@ -120,7 +120,7 @@ enum ENUM_BLOCK_ID // tolua_export
E_BLOCK_PUMPKIN_STEM = 104,
E_BLOCK_MELON_STEM = 105,
E_BLOCK_VINES = 106,
E_BLOCK_FENCE_GATE = 107,
E_BLOCK_OAK_FENCE_GATE = 107,
E_BLOCK_BRICK_STAIRS = 108,
E_BLOCK_STONE_BRICK_STAIRS = 109,
E_BLOCK_MYCELIUM = 110,
@ -197,8 +197,8 @@ enum ENUM_BLOCK_ID // tolua_export
E_BLOCK_INVERTED_DAYLIGHT_SENSOR = 178,
E_BLOCK_RED_SANDSTONE = 179,
E_BLOCK_RED_SANDSTONE_STAIRS = 180,
E_BLOCK_DOUBLE_NEW_STONE_SLAB= 181,
E_BLOCK_NEW_STONE_SLAB = 182,
E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB = 181,
E_BLOCK_RED_SANDSTONE_SLAB = 182,
E_BLOCK_SPRUCE_FENCE_GATE = 183,
E_BLOCK_BIRCH_FENCE_GATE = 184,
E_BLOCK_JUNGLE_FENCE_GATE = 185,
@ -223,7 +223,9 @@ enum ENUM_BLOCK_ID // tolua_export
// Synonym or ID compatibility
E_BLOCK_YELLOW_FLOWER = E_BLOCK_DANDELION,
E_BLOCK_RED_ROSE = E_BLOCK_FLOWER,
E_BLOCK_LOCKED_CHEST = E_BLOCK_STAINED_GLASS,
E_BLOCK_WOODEN_DOOR = E_BLOCK_OAK_DOOR,
E_BLOCK_FENCE_GATE = E_BLOCK_OAK_FENCE_GATE,
E_BLOCK_WOODEN_STAIRS = E_BLOCK_OAK_WOOD_STAIRS,
};
// tolua_end
@ -612,8 +614,8 @@ enum
E_META_PISTON_EXTENDED = 8,
// E_BLOCK_PLANKS metas:
E_META_PLANKS_APPLE = 0,
E_META_PLANKS_CONIFER = 1,
E_META_PLANKS_OAK = 0,
E_META_PLANKS_SPRUCE = 1,
E_META_PLANKS_BIRCH = 2,
E_META_PLANKS_JUNGLE = 3,
E_META_PLANKS_ACACIA = 4,
@ -814,16 +816,16 @@ enum
E_META_NEWLOG_DARK_OAK_BARK_ONLY = 13,
// E_BLOCK_WOODEN_DOUBLE_SLAB metas:
E_META_WOODEN_DOUBLE_SLAB_APPLE = 0,
E_META_WOODEN_DOUBLE_SLAB_CONIFER = 1,
E_META_WOODEN_DOUBLE_SLAB_OAK = 0,
E_META_WOODEN_DOUBLE_SLAB_SPRUCE = 1,
E_META_WOODEN_DOUBLE_SLAB_BIRCH = 2,
E_META_WOODEN_DOUBLE_SLAB_JUNGLE = 3,
E_META_WOODEN_DOUBLE_SLAB_ACACIA = 4,
E_META_WOODEN_DOUBLE_SLAB_DARK_OAK = 5,
// E_BLOCK_WOODEN_SLAB metas:
E_META_WOODEN_SLAB_APPLE = 0,
E_META_WOODEN_SLAB_CONIFER = 1,
E_META_WOODEN_SLAB_OAK = 0,
E_META_WOODEN_SLAB_SPRUCE = 1,
E_META_WOODEN_SLAB_BIRCH = 2,
E_META_WOODEN_SLAB_JUNGLE = 3,
E_META_WOODEN_SLAB_ACACIA = 4,

View File

@ -88,7 +88,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_END_PORTAL_FRAME ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FARMLAND ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FENCE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FENCE_GATE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_OAK_FENCE_GATE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FIRE ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FLOWER ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_FLOWER_POT ].m_SpreadLightFalloff = 1;
@ -116,7 +116,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_NETHER_PORTAL ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_NETHER_WART ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_NEW_LEAVES ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_NEW_STONE_SLAB ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_RED_SANDSTONE_SLAB ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_PISTON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_PISTON_EXTENSION ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_SpreadLightFalloff = 1;
@ -154,7 +154,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_WALL_BANNER ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WALLSIGN ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_DOOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_OAK_DOOR ].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_SpreadLightFalloff = 1;
a_Info[E_BLOCK_WOODEN_SLAB ].m_SpreadLightFalloff = 1;
@ -205,7 +205,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_END_PORTAL ].m_Transparent = true;
a_Info[E_BLOCK_END_PORTAL_FRAME ].m_Transparent = true;
a_Info[E_BLOCK_FENCE ].m_Transparent = true;
a_Info[E_BLOCK_FENCE_GATE ].m_Transparent = true;
a_Info[E_BLOCK_OAK_FENCE_GATE ].m_Transparent = true;
a_Info[E_BLOCK_FIRE ].m_Transparent = true;
a_Info[E_BLOCK_FLOWER ].m_Transparent = true;
a_Info[E_BLOCK_FLOWER_POT ].m_Transparent = true;
@ -234,7 +234,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_NETHER_PORTAL ].m_Transparent = true;
a_Info[E_BLOCK_NETHER_WART ].m_Transparent = true;
a_Info[E_BLOCK_NEW_LEAVES ].m_Transparent = true;
a_Info[E_BLOCK_NEW_STONE_SLAB ].m_Transparent = true;
a_Info[E_BLOCK_RED_SANDSTONE_SLAB ].m_Transparent = true;
a_Info[E_BLOCK_PISTON ].m_Transparent = true;
a_Info[E_BLOCK_PISTON_EXTENSION ].m_Transparent = true;
a_Info[E_BLOCK_PISTON_MOVED_BLOCK ].m_Transparent = true;
@ -275,7 +275,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_WALLSIGN ].m_Transparent = true;
a_Info[E_BLOCK_WATER ].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_DOOR ].m_Transparent = true;
a_Info[E_BLOCK_OAK_DOOR ].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_Transparent = true;
a_Info[E_BLOCK_WOODEN_SLAB ].m_Transparent = true;
@ -369,7 +369,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_WALLSIGN ].m_PistonBreakable = true;
a_Info[E_BLOCK_WATER ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_BUTTON ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_DOOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_OAK_DOOR ].m_PistonBreakable = true;
a_Info[E_BLOCK_WOODEN_PRESSURE_PLATE].m_PistonBreakable = true;
@ -388,7 +388,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_DIAMOND_ORE ].m_IsSnowable = true;
a_Info[E_BLOCK_DIRT ].m_IsSnowable = true;
a_Info[E_BLOCK_DISPENSER ].m_IsSnowable = true;
a_Info[E_BLOCK_DOUBLE_NEW_STONE_SLAB].m_IsSnowable = true;
a_Info[E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB].m_IsSnowable = true;
a_Info[E_BLOCK_DOUBLE_STONE_SLAB ].m_IsSnowable = true;
a_Info[E_BLOCK_DOUBLE_WOODEN_SLAB ].m_IsSnowable = true;
a_Info[E_BLOCK_DROPPER ].m_IsSnowable = true;
@ -631,7 +631,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_TORCH ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_FIRE ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_MOB_SPAWNER ].m_PlaceSound = "dig.metal";
a_Info[E_BLOCK_WOODEN_STAIRS ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_OAK_WOOD_STAIRS ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_CHEST ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_REDSTONE_WIRE ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_DIAMOND_ORE ].m_PlaceSound = "dig.stone";
@ -641,7 +641,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_FURNACE ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_LIT_FURNACE ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_SIGN_POST ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_WOODEN_DOOR ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_OAK_DOOR ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_LADDER ].m_PlaceSound = "dig.ladder";
a_Info[E_BLOCK_RAIL ].m_PlaceSound = "dig.metal";
a_Info[E_BLOCK_COBBLESTONE_STAIRS ].m_PlaceSound = "dig.stone";
@ -684,7 +684,7 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_PUMPKIN_STEM ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_MELON_STEM ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_VINES ].m_PlaceSound = "dig.grass";
a_Info[E_BLOCK_FENCE_GATE ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_OAK_FENCE_GATE ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_BRICK_STAIRS ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_STONE_BRICK_STAIRS ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_MYCELIUM ].m_PlaceSound = "dig.grass";
@ -755,8 +755,8 @@ void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
a_Info[E_BLOCK_STANDING_BANNER ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_WALL_BANNER ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_RED_SANDSTONE ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_RED_SANDSTONE_STAIRS ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_NEW_STONE_SLAB ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_RED_SANDSTONE_STAIRS].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_RED_SANDSTONE_SLAB ].m_PlaceSound = "dig.stone";
a_Info[E_BLOCK_SPRUCE_FENCE_GATE ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_BIRCH_FENCE_GATE ].m_PlaceSound = "dig.wood";
a_Info[E_BLOCK_JUNGLE_FENCE_GATE ].m_PlaceSound = "dig.wood";

View File

@ -19,20 +19,17 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2));
}
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
cWindow * Window = new cAnvilWindow(a_BlockX, a_BlockY, a_BlockZ);
a_Player->OpenWindow(Window);
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -58,11 +55,16 @@ public:
return true;
}
virtual bool IsUseable() override
{
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 6;
}
} ;

View File

@ -36,7 +36,6 @@ public:
a_Pickups.push_back(cItem(E_ITEM_BED, 1, 0));
}
// Bed specific helper functions
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
@ -77,6 +76,12 @@ public:
a_ChunkInterface.SetBlockMeta(a_BedPosition.x, a_BedPosition.y, a_BedPosition.z, Meta);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 28;
}
} ;

View File

@ -18,7 +18,6 @@ public:
{
}
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -32,7 +31,6 @@ public:
}
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
NIBBLETYPE Meta = a_BlockMeta & 0x7;
@ -45,7 +43,6 @@ public:
a_Pickups.push_back(cItem(E_BLOCK_BIG_FLOWER, 1, Meta));
}
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -78,13 +75,11 @@ public:
}
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR) && (a_RelY < cChunkDef::Height - 1) && ((a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ) == E_BLOCK_AIR) || (a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ) == E_BLOCK_BIG_FLOWER)));
}
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -106,6 +101,12 @@ public:
}
}
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -25,6 +25,12 @@ public:
{
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 6;
}
} ;

View File

@ -16,7 +16,6 @@ public:
{
}
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -50,20 +49,17 @@ public:
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to 0
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
virtual bool IsUseable(void) override
{
return true;
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -76,7 +72,6 @@ public:
return true;
}
inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace)
{
switch (a_BlockFace)
@ -99,7 +94,6 @@ public:
#endif
}
inline static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_Meta)
{
switch (a_Meta & 0x7)
@ -118,7 +112,6 @@ public:
}
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
NIBBLETYPE Meta;
@ -129,6 +122,12 @@ public:
return (a_RelY > 0) && (cBlockInfo::FullyOccupiesVoxel(BlockIsOn));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -16,14 +16,12 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to 0
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@ -64,11 +62,16 @@ public:
return true;
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
a_Chunk.GetWorld()->GrowCactus(a_RelX + a_Chunk.GetPosX() * cChunkDef::Width, a_RelY, a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width, 1);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -43,6 +43,12 @@ public:
{
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 14;
}
} ;

View File

@ -23,7 +23,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -36,17 +35,43 @@ public:
return true;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_BLOCK_CARPET, 1, a_BlockMeta));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return (a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
switch (a_Meta)
{
case E_META_CARPET_WHITE: return 14;
case E_META_CARPET_ORANGE: return 15;
case E_META_CARPET_MAGENTA: return 16;
case E_META_CARPET_LIGHTBLUE: return 17;
case E_META_CARPET_YELLOW: return 18;
case E_META_CARPET_LIGHTGREEN: return 19;
case E_META_CARPET_PINK: return 20;
case E_META_CARPET_GRAY: return 21;
case E_META_CARPET_LIGHTGRAY: return 22;
case E_META_CARPET_CYAN: return 23;
case E_META_CARPET_PURPLE: return 24;
case E_META_CARPET_BLUE: return 25;
case E_META_CARPET_BROWN: return 26;
case E_META_CARPET_GREEN: return 27;
case E_META_CARPET_RED: return 28;
case E_META_CARPET_BLACK: return 29;
default:
{
ASSERT(!"Unhandled meta in carpet handler!");
return 0;
}
}
}
} ;

View File

@ -76,6 +76,12 @@ public:
a_Chunk.SetMeta(a_RelX, a_RelY, a_RelZ, Meta + 1);
}
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 21;
}
} ;

View File

@ -19,7 +19,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -66,7 +65,6 @@ public:
return true;
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
@ -74,7 +72,6 @@ public:
return CanBeAt(a_ChunkInterface, BlockX, a_RelY, BlockZ);
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
cBlockArea Area;
@ -140,7 +137,6 @@ public:
return (NumChestNeighbors < 2);
}
/** Translates player yaw when placing a chest into the chest block metadata. Valid for single chests only */
static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{
@ -168,8 +164,7 @@ public:
}
}
/// If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true.
/** If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true. */
bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta)
{
if (a_Area.GetRelBlockType(a_RelX, 0, a_RelZ) != m_BlockType)
@ -180,11 +175,16 @@ public:
return true;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 13;
}
} ;

View File

@ -15,6 +15,34 @@ public:
: cBlockHandler(a_BlockType)
{
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
switch (a_Meta)
{
case E_META_WOOL_WHITE: return 14;
case E_META_WOOL_ORANGE: return 15;
case E_META_WOOL_MAGENTA: return 16;
case E_META_WOOL_LIGHTBLUE: return 17;
case E_META_WOOL_YELLOW: return 18;
case E_META_WOOL_LIGHTGREEN: return 19;
case E_META_WOOL_PINK: return 20;
case E_META_WOOL_GRAY: return 21;
case E_META_WOOL_LIGHTGRAY: return 22;
case E_META_WOOL_CYAN: return 23;
case E_META_WOOL_PURPLE: return 24;
case E_META_WOOL_BLUE: return 25;
case E_META_WOOL_BROWN: return 26;
case E_META_WOOL_GREEN: return 27;
case E_META_WOOL_RED: return 28;
case E_META_WOOL_BLACK: return 29;
default:
{
ASSERT(!"Unhandled meta in wool handler!");
return 0;
}
}
}
} ;

View File

@ -18,11 +18,16 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
{
a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 3;
}
} ;

View File

@ -16,7 +16,6 @@ public:
{
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
eBlockFace BlockFace = MetaToBlockFace(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
@ -29,7 +28,6 @@ public:
return ((BlockType == E_BLOCK_LOG) && ((BlockMeta & 0x3) == E_META_LOG_JUNGLE));
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
cFastRandom Random;
@ -48,14 +46,12 @@ public:
}
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
int GrowState = a_BlockMeta >> 2;
a_Pickups.Add(E_ITEM_DYE, ((GrowState >= 2) ? 3 : 1), E_META_DYE_BROWN);
}
static eBlockFace MetaToBlockFace(NIBBLETYPE a_Meta)
{
switch (a_Meta & 0x3)
@ -72,7 +68,6 @@ public:
}
}
static NIBBLETYPE BlockFaceToMeta(eBlockFace a_BlockFace)
{
switch (a_BlockFace)
@ -95,6 +90,11 @@ public:
#endif
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 34;
}
} ;

View File

@ -20,6 +20,12 @@ public:
{
a_Pickups.push_back(cItem(E_BLOCK_AIR, 8, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 10;
}
} ;

View File

@ -18,7 +18,6 @@ public:
{
}
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -26,33 +25,28 @@ public:
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
}
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{
UNUSED(a_ChunkInterface);
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to 0
a_Pickups.push_back(cItem(E_ITEM_COMPARATOR, 1, 0));
}
virtual bool IsUseable(void) override
{
return true;
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -65,7 +59,6 @@ public:
return true;
}
inline static Vector3i GetSideCoordinate(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta, bool a_bInverse)
{
if (!a_bInverse)
@ -104,7 +97,6 @@ public:
return Vector3i(a_BlockX, a_BlockY, a_BlockZ);
}
inline static Vector3i GetRearCoordinate(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta)
{
switch (a_Meta)
@ -124,7 +116,6 @@ public:
return Vector3i(a_BlockX, a_BlockY, a_BlockZ);
}
inline static Vector3i GetFrontCoordinate(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta)
{
switch (a_Meta)
@ -143,6 +134,12 @@ public:
return Vector3i(a_BlockX, a_BlockY, a_BlockZ);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 11;
}
} ;

View File

@ -8,7 +8,7 @@
/// Common class that takes care of carrots, potatoes and wheat
/** Common class that takes care of carrots, potatoes and wheat */
class cBlockCropsHandler :
public cBlockHandler
{
@ -18,7 +18,6 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
{
cFastRandom rand;
@ -73,7 +72,6 @@ public:
}
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
NIBBLETYPE Meta = a_Chunk.GetMeta (a_RelX, a_RelY, a_RelZ);
@ -95,11 +93,16 @@ public:
}
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_FARMLAND));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -16,7 +16,6 @@ public:
{
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@ -37,6 +36,12 @@ public:
default: return false;
}
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -9,7 +9,9 @@
/// Handler used for both dirt and grass
/** Handler used for all types of dirt and grass */
class cBlockDirtHandler :
public cBlockHandler
{
@ -19,7 +21,6 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
if (a_BlockMeta == E_META_DIRT_COARSE)
@ -33,7 +34,6 @@ public:
}
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
if (m_BlockType != E_BLOCK_GRASS)
@ -109,6 +109,21 @@ public:
}
} // for i - repeat twice
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
switch (m_BlockType)
{
case E_BLOCK_DIRT: return 10;
case E_BLOCK_GRASS: return 1;
default:
{
ASSERT(!"Unhandled blocktype in dirt handler!");
return 0;
}
}
}
} ;

View File

@ -62,7 +62,7 @@ void cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterfac
case E_BLOCK_JUNGLE_DOOR:
case E_BLOCK_SPRUCE_DOOR:
case E_BLOCK_IRON_DOOR:
case E_BLOCK_WOODEN_DOOR:
case E_BLOCK_OAK_DOOR:
{
ChangeDoor(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
a_Player->GetWorld()->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle());

View File

@ -52,7 +52,6 @@ public:
return true;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
if ((a_BlockMeta & 0x08) != 0) // is top part of door
@ -61,7 +60,7 @@ public:
}
switch (m_BlockType)
{
case E_BLOCK_WOODEN_DOOR:
case E_BLOCK_OAK_DOOR:
{
a_Pickups.Add(E_ITEM_WOODEN_DOOR);
break;
@ -104,19 +103,16 @@ public:
}
}
virtual bool IsUseable(void) override
{
return true;
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return ((a_RelY > 0) && CanBeOn(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ), a_Chunk.GetMeta(a_RelX, a_RelY - 1, a_RelZ)));
}
/** Returns true if door can be placed on the specified block type. */
static bool CanBeOn(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
@ -140,7 +136,6 @@ public:
}
}
static bool CanReplaceBlock(BLOCKTYPE a_BlockType)
{
switch (a_BlockType)
@ -160,7 +155,6 @@ public:
return false;
}
/** Converts the player's yaw to placed door's blockmeta */
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{
@ -189,7 +183,6 @@ public:
}
}
/** Returns a vector pointing one block in the direction the door is facing (where the outside is). */
inline static Vector3i GetRelativeDirectionToOutside(NIBBLETYPE a_BlockMeta)
{
@ -202,7 +195,6 @@ public:
}
}
/** Returns true if the specified blocktype is any kind of door */
inline static bool IsDoorBlockType(BLOCKTYPE a_Block)
{
@ -214,7 +206,7 @@ public:
case E_BLOCK_IRON_DOOR:
case E_BLOCK_JUNGLE_DOOR:
case E_BLOCK_SPRUCE_DOOR:
case E_BLOCK_WOODEN_DOOR:
case E_BLOCK_OAK_DOOR:
{
return true;
}
@ -225,7 +217,6 @@ public:
}
}
/** Returns true iff the door at the specified coords is open.
The coords may point to either the top part or the bottom part of the door. */
static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
@ -234,7 +225,6 @@ public:
return ((Meta & 0x04) != 0);
}
/** Returns the complete meta composed from the both parts of the door as (TopMeta << 4) | BottomMeta
The coords may point to either part of the door.
The returned value has bit 3 (0x08) set iff the coords point to the top part of the door.
@ -267,7 +257,6 @@ public:
}
}
/** Sets the door to the specified state. If the door is already in that state, does nothing. */
static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open)
{
@ -301,12 +290,31 @@ public:
}
}
/** Changes the door at the specified coords from open to close or vice versa */
static void ChangeDoor(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
SetOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, !IsOpen(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
switch (m_BlockType)
{
case E_BLOCK_OAK_DOOR: return 13;
case E_BLOCK_SPRUCE_DOOR: return 34;
case E_BLOCK_BIRCH_DOOR: return 2;
case E_BLOCK_JUNGLE_DOOR: return 10;
case E_BLOCK_DARK_OAK_DOOR: return 26;
case E_BLOCK_ACACIA_DOOR: return 15;
case E_BLOCK_IRON_DOOR: return 6;
default:
{
ASSERT(!"Unhandled blocktype in door handler!");
return 0;
}
}
}
} ;

View File

@ -21,7 +21,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -49,6 +48,12 @@ public:
// Not Facing Up or Down; No change.
return a_Meta;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 11;
}
} ;

View File

@ -18,18 +18,22 @@ public:
{
}
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
cWindow * Window = new cEnchantingWindow(a_BlockX, a_BlockY, a_BlockZ);
a_Player->OpenWindow(Window);
}
virtual bool IsUseable(void) override
{
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 29;
}
};

View File

@ -16,13 +16,11 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.Add(m_BlockType, 1, 0); // Reset meta to zero
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -35,7 +33,6 @@ public:
return true;
}
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
NIBBLETYPE OldMetaData = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -55,20 +52,17 @@ public:
a_Player->GetWorld()->BroadcastSoundParticleEffect(1003, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle());
}
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
}
virtual bool IsUseable(void) override
{
return true;
}
/// Converts the player's yaw to placed gate's blockmeta
/** Converts the player's yaw to placed gate's blockmeta */
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{
ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
@ -95,6 +89,25 @@ public:
return 0x3;
}
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
switch (m_BlockType)
{
case E_BLOCK_OAK_FENCE_GATE: return 13;
case E_BLOCK_SPRUCE_FENCE_GATE: return 34;
case E_BLOCK_BIRCH_FENCE_GATE: return 2;
case E_BLOCK_JUNGLE_FENCE_GATE: return 10;
case E_BLOCK_DARK_OAK_FENCE_GATE: return 26;
case E_BLOCK_ACACIA_FENCE_GATE: return 15;
default:
{
ASSERT(!"Unhandled blocktype in fence gate handler!");
return 0;
}
}
}
} ;

View File

@ -17,7 +17,7 @@ public:
{
}
/// Portal boundary and direction variables
/** Portal boundary and direction variables */
// 2014_03_30 _X: What are these used for? Why do we need extra variables?
int XZP, XZM;
NIBBLETYPE Dir;
@ -102,7 +102,7 @@ public:
return true;
}
/// Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE)
/** Finds entire frame in any direction with the coordinates of a base block and fills hole with nether portal (START HERE) */
void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface)
{
int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks
@ -193,7 +193,7 @@ public:
return (FoundFrameXP && FoundFrameXM);
}
/// Evaluates if coords are a portal going ZP / ZM; returns true if so, and writes boundaries to variable
/** Evaluates if coords are a portal going ZP / ZM; returns true if so, and writes boundaries to variable */
bool FindPortalSliceZ(int X, int Y, int Z1, int Z2, int MaxY, cChunkInterface & a_ChunkInterface)
{
Dir = 2;
@ -236,6 +236,12 @@ public:
{
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 15;
}
};

View File

@ -16,18 +16,22 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to zero
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -21,6 +21,12 @@ public:
{
a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -19,19 +19,16 @@ public:
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// No pickups
}
virtual bool DoesIgnoreBuildCollision(void) override
{
return true;
}
virtual void Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
{
switch (m_BlockType)
@ -49,6 +46,17 @@ public:
}
super::Check(a_ChunkInterface, a_PluginInterface, a_RelX, a_RelY, a_RelZ, a_Chunk);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
if (IsBlockWater(m_BlockType))
{
return 12;
}
ASSERT(!"Unhandled blocktype in fluid/water handler!");
return 0;
}
} ;
@ -66,8 +74,7 @@ public:
{
}
/// Called to tick the block
/** Called to tick the block */
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
if (a_Chunk.GetWorld()->ShouldLavaSpawnFire())
@ -80,8 +87,7 @@ public:
}
}
/// Tries to start a fire near the lava at given coords. Returns true if fire started.
/** Tries to start a fire near the lava at given coords. Returns true if fire started. */
static bool TryStartFireNear(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
{
// Pick a block next to this lava block:
@ -132,6 +138,12 @@ public:
} // for i - CrossCoords[]
return false;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 4;
}
} ;

View File

@ -18,13 +18,11 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_BLOCK_FURNACE, 1, 0));
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -39,6 +37,12 @@ public:
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 11;
}
} ;

View File

@ -19,6 +19,12 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -16,13 +16,19 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to 0
cFastRandom Random;
// Add more than one dust
a_Pickups.push_back(cItem(E_ITEM_GLOWSTONE_DUST, (char)(2 + Random.NextInt(3)), 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 2;
}
} ;

View File

@ -28,6 +28,12 @@ public:
a_Pickups.Add(E_BLOCK_GRAVEL, 1, 0);
}
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 11;
}
} ;

View File

@ -215,7 +215,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_DIAMOND_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_DIRT: return new cBlockDirtHandler (a_BlockType);
case E_BLOCK_DISPENSER: return new cBlockDropSpenserHandler (a_BlockType);
case E_BLOCK_DOUBLE_NEW_STONE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType);
@ -223,7 +223,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_ENCHANTMENT_TABLE: return new cBlockEnchantmentTableHandler(a_BlockType);
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler (a_BlockType);
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_OAK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
@ -266,7 +266,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_NETHER_QUARTZ_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_NEW_LEAVES: return new cBlockLeavesHandler (a_BlockType);
case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_NEW_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
case E_BLOCK_RED_SANDSTONE_SLAB: return new cBlockSlabHandler (a_BlockType);
case E_BLOCK_NOTE_BLOCK: return new cBlockEntityHandler (a_BlockType);
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler;
@ -320,10 +320,10 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType);
case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType);
case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType);
case E_BLOCK_WOODEN_DOOR: return new cBlockDoorHandler (a_BlockType);
case E_BLOCK_OAK_DOOR: return new cBlockDoorHandler (a_BlockType);
case E_BLOCK_WOODEN_PRESSURE_PLATE: return new cBlockPressurePlateHandler (a_BlockType);
case E_BLOCK_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
case E_BLOCK_WOODEN_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_OAK_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_WOOL: return new cBlockClothHandler (a_BlockType);
case E_BLOCK_WORKBENCH: return new cBlockWorkbenchHandler (a_BlockType);
case E_BLOCK_YELLOW_FLOWER: return new cBlockFlowerHandler (a_BlockType);
@ -574,3 +574,13 @@ void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterf
ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta)
{
// Zero for transparent
return 0;
}

View File

@ -127,6 +127,9 @@ public:
and wakes up all simulators on the block. */
virtual void Check(cChunkInterface & ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk);
/** Returns the base colour ID of the block, as will be represented on a map, as per documentation: http://minecraft.gamepedia.com/Map_item_format */
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta);
/// <summary>Rotates a given block meta counter-clockwise. Default: no change</summary>
/// <returns>Block meta following rotation</returns>
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) { return a_Meta; }

View File

@ -16,7 +16,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -40,7 +39,6 @@ public:
return true;
}
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag. Lowest three bits are position. 0x08 == 1000
@ -54,6 +52,12 @@ public:
// Not Facing Up or Down; No change.
return a_Meta;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 11;
}
} ;

View File

@ -17,13 +17,11 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// No pickups
}
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
if (a_Player->IsGameModeCreative() || (a_BlockY <= 0))
@ -44,4 +42,10 @@ public:
// This is called later than the real destroying of this ice block
}
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 5;
}
} ;

View File

@ -19,7 +19,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -42,13 +41,11 @@ public:
return true;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.Add(m_BlockType, 1, 0); // Reset meta
}
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
{
switch (a_Direction)
@ -70,7 +67,6 @@ public:
#endif
}
static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData)
{
switch (a_MetaData)
@ -83,7 +79,6 @@ public:
}
}
/** Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure */
static eBlockFace FindSuitableBlockFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
@ -98,7 +93,6 @@ public:
return BLOCK_FACE_BOTTOM;
}
static bool LadderCanBePlacedAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
{
if ((a_BlockFace == BLOCK_FACE_BOTTOM) || (a_BlockFace == BLOCK_FACE_TOP))
@ -111,7 +105,6 @@ public:
return cBlockInfo::IsSolid(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
// TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
@ -120,6 +113,12 @@ public:
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
return LadderCanBePlacedAt(a_ChunkInterface, BlockX, a_RelY, BlockZ, BlockFace);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -35,7 +35,6 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
cFastRandom rand;
@ -74,7 +73,6 @@ public:
}
}
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_WhichNeighbor) override
{
// Unset 0x8 bit so this block gets checked for decay:
@ -85,7 +83,6 @@ public:
}
}
virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
@ -128,6 +125,12 @@ public:
DropBlock(a_ChunkInterface, a_WorldInterface, a_PluginInterface, nullptr, BlockX, a_RelY, BlockZ);
a_ChunkInterface.DigBlock(a_WorldInterface, BlockX, a_RelY, BlockZ);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -27,20 +27,17 @@ public:
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect("random.click", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, (Meta & 0x08) ? 0.6f : 0.5f);
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to 0
a_Pickups.push_back(cItem(E_BLOCK_LEVER, 1, 0));
}
virtual bool IsUseable(void) override
{
return true;
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -53,7 +50,6 @@ public:
return true;
}
inline static NIBBLETYPE LeverDirectionToMetaData(eBlockFace a_Dir)
{
// Determine lever direction:
@ -73,7 +69,6 @@ public:
#endif
}
inline static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_Meta)
{
switch (a_Meta & 0x7)
@ -94,7 +89,6 @@ public:
}
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
@ -128,7 +122,6 @@ public:
return false;
}
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
switch (a_Meta)
@ -143,7 +136,6 @@ public:
}
}
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
switch (a_Meta)
@ -157,6 +149,12 @@ public:
default: return super::MetaRotateCW(a_Meta); // Wall Rotation
}
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -17,6 +17,12 @@ public:
super(a_BlockType)
{
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
};

View File

@ -16,12 +16,17 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
cFastRandom Random;
a_Pickups.push_back(cItem(E_ITEM_MELON_SLICE, (char)(3 + Random.NextInt(5)), 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 19;
}
} ;

View File

@ -17,13 +17,11 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// The drop spawn is in the OnDestroyedByPlayer method
}
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
if (a_Player->IsGameModeCreative())
@ -63,6 +61,12 @@ public:
a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -16,17 +16,14 @@ public:
{
}
// TODO: Add Mushroom Spread
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to 0
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@ -50,6 +47,12 @@ public:
}
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -22,6 +22,12 @@ public:
{
a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 24;
}
} ;

View File

@ -18,7 +18,6 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
{
cFastRandom rand;
@ -34,7 +33,6 @@ public:
}
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
@ -44,10 +42,15 @@ public:
}
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
// Needs to be placed on top of a Soulsand block:
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_SOULSAND));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 35;
}
} ;

View File

@ -82,6 +82,12 @@ public:
static void ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
static void RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 11;
}
private:
/// Returns true if the piston (specified by blocktype) is a sticky piston

View File

@ -15,7 +15,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -27,6 +26,24 @@ public:
a_BlockMeta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage);
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
switch (a_Meta)
{
case E_META_PLANKS_BIRCH: return 2;
case E_META_PLANKS_JUNGLE: return 10;
case E_META_PLANKS_OAK: return 13;
case E_META_PLANKS_ACACIA: return 15;
case E_META_PLANKS_DARK_OAK: return 26;
case E_META_PLANKS_SPRUCE: return 34;
default:
{
ASSERT(!"Unhandled meta in planks handler!");
return 0;
}
}
}
} ;

View File

@ -33,7 +33,6 @@ public:
return true;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// No pickups
@ -64,21 +63,20 @@ public:
{
case 0x1:
{
static const struct
static const std::array<Vector3i, 4> PortalCheck
{
int x, y, z;
} PortalCheck[] =
{
{ 0, 1, 0},
{ 0, -1, 0},
{ 1, 0, 0},
{-1, 0, 0},
} ;
{
{ 0, 1, 0 },
{ 0, -1, 0 },
{ 1, 0, 0 },
{ -1, 0, 0 },
}
};
for (size_t i = 0; i < ARRAYCOUNT(PortalCheck); i++)
for (const auto & Direction : PortalCheck)
{
BLOCKTYPE Block;
a_Chunk.UnboundedRelGetBlockType(a_RelX + PortalCheck[i].x, a_RelY + PortalCheck[i].y, a_RelZ + PortalCheck[i].z, Block);
a_Chunk.UnboundedRelGetBlockType(a_RelX + Direction.x, a_RelY + Direction.y, a_RelZ + Direction.z, Block);
if ((Block != E_BLOCK_NETHER_PORTAL) && (Block != E_BLOCK_OBSIDIAN))
{
@ -89,21 +87,20 @@ public:
}
case 0x2:
{
static const struct
static const std::array<Vector3i, 4> PortalCheck
{
int x, y, z;
} PortalCheck[] =
{
{ 0, 1, 0},
{ 0, -1, 0},
{ 0, 0, -1},
{ 0, 0, 1},
} ;
{
{ 0, 1, 0 },
{ 0, -1, 0 },
{ 0, 0, -1 },
{ 0, 0, 1 },
}
};
for (size_t i = 0; i < ARRAYCOUNT(PortalCheck); i++)
for (const auto & Direction : PortalCheck)
{
BLOCKTYPE Block;
a_Chunk.UnboundedRelGetBlockType(a_RelX + PortalCheck[i].x, a_RelY + PortalCheck[i].y, a_RelZ + PortalCheck[i].z, Block);
a_Chunk.UnboundedRelGetBlockType(a_RelX + Direction.x, a_RelY + Direction.y, a_RelZ + Direction.z, Block);
if ((Block != E_BLOCK_NETHER_PORTAL) && (Block != E_BLOCK_OBSIDIAN))
{
@ -115,6 +112,12 @@ public:
}
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 24;
}
} ;

View File

@ -30,6 +30,23 @@ public:
return (cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
switch (m_BlockType)
{
case E_BLOCK_STONE_PRESSURE_PLATE: return 11;
case E_BLOCK_WOODEN_PRESSURE_PLATE: return 13;
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: return 6;
case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return 30;
default:
{
ASSERT(!"Unhandled blocktype in pressure plate handler!");
return 0;
}
}
}
} ;

View File

@ -16,7 +16,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -56,6 +55,11 @@ public:
}
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 15;
}
} ;

View File

@ -15,7 +15,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -36,7 +35,6 @@ public:
return true;
}
inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace, NIBBLETYPE a_QuartzMeta)
{
switch (a_BlockFace)
@ -70,4 +68,10 @@ public:
return 0;
#endif
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 8;
}
} ;

View File

@ -41,7 +41,6 @@ public:
return true;
}
virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
{
super::OnPlaced(a_ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
@ -57,7 +56,6 @@ public:
OnNeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ - 1, BLOCK_FACE_NONE);
}
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
super::OnDestroyed(a_ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ);
@ -73,7 +71,6 @@ public:
OnNeighborChanged(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ - 1, BLOCK_FACE_NONE);
}
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_WhichNeighbor) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -83,13 +80,11 @@ public:
}
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
super::ConvertToPickups(a_Pickups, 0);
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@ -258,13 +253,11 @@ public:
return Meta;
}
inline bool CanThisRailCurve(void)
{
return m_BlockType == E_BLOCK_RAIL;
}
bool IsUnstable(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
if (!IsBlockRail(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY, a_BlockZ)))
@ -397,7 +390,6 @@ public:
return false;
}
bool IsNotConnected(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, char a_Pure = 0)
{
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, false);
@ -495,7 +487,6 @@ public:
return true;
}
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag when a_Meta is in the range 0x00--0x05 and 0x0A--0x0F.
@ -532,7 +523,6 @@ public:
return a_Meta;
}
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
@ -568,7 +558,6 @@ public:
return a_Meta;
}
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
@ -599,7 +588,6 @@ public:
return a_Meta;
}
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
// Bit 0x08 is a flag for value in the range 0x00--0x05 and specifies direction for values withint 0x006--0x09.
@ -629,6 +617,12 @@ public:
// To avoid a compiler warning;
return a_Meta;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -18,8 +18,6 @@ public:
{
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@ -46,12 +44,17 @@ public:
return false;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to zero
a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, 1, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -20,6 +20,12 @@ public:
{
a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 15;
}
};

View File

@ -18,7 +18,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -31,34 +30,28 @@ public:
return true;
}
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, ((a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
}
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{
UNUSED(a_ChunkInterface);
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to zero
a_Pickups.push_back(cItem(E_ITEM_REDSTONE_REPEATER, 1, 0));
}
virtual bool IsUseable(void) override
{
return true;
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@ -85,7 +78,6 @@ public:
return false;
}
inline static NIBBLETYPE RepeaterRotationToMetaData(double a_Rotation)
{
a_Rotation += 90 + 45; // So its not aligned with axis
@ -111,6 +103,12 @@ public:
return 0x0;
}
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 11;
}
} ;

View File

@ -17,12 +17,17 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Always drop the ON torch, meta 0
a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_TORCH_ON, 1, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -15,6 +15,12 @@ public:
: cBlockHandler(a_BlockType)
{
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 2;
}
};

View File

@ -18,20 +18,17 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Only the first 2 bits contain the display information and the 4th bit is for the growth indicator, but, we use 0x07 for forward compatibility
a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ));
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
@ -174,6 +171,12 @@ private:
return LargeTree;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -20,13 +20,11 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@ -38,7 +36,6 @@ public:
return ((Type == E_BLOCK_SIGN_POST) || (Type == E_BLOCK_WALLSIGN) || cBlockInfo::IsSolid(Type));
}
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
@ -52,19 +49,16 @@ public:
return ((char)a_Rotation) % 16;
}
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
return (a_Meta + 4) & 0x0f;
}
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
return (a_Meta + 12) & 0x0f;
}
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
// Mirrors signs over the XY plane (North-South Mirroring)
@ -74,7 +68,6 @@ public:
return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta);
}
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
// Mirrors signs over the YZ plane (East-West Mirroring)
@ -83,6 +76,12 @@ public:
// These values are equated to angles on a circle; 0x10 = 360 degrees.
return 0x10 - a_Meta;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 13;
}
} ;

View File

@ -11,7 +11,6 @@
#include "BlockHandler.h"
#include "../Items/ItemHandler.h"
#include "Root.h"
#include "ChunkInterface.h"
#include "../Entities/Player.h"
@ -26,13 +25,11 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta & 0x7));
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -88,14 +85,12 @@ public:
return true;
}
/// Returns true if the specified blocktype is one of the slabs handled by this handler
/** Returns true if the specified blocktype is one of the slabs handled by this handler */
static bool IsAnySlabType(BLOCKTYPE a_BlockType)
{
return ((a_BlockType == E_BLOCK_WOODEN_SLAB) || (a_BlockType == E_BLOCK_STONE_SLAB) || (a_BlockType == E_BLOCK_NEW_STONE_SLAB));
return ((a_BlockType == E_BLOCK_WOODEN_SLAB) || (a_BlockType == E_BLOCK_STONE_SLAB) || (a_BlockType == E_BLOCK_RED_SANDSTONE_SLAB));
}
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{
if ((a_BlockFace == BLOCK_FACE_NONE) || (a_Player->GetEquippedItem().m_ItemType != static_cast<short>(m_BlockType)))
@ -103,30 +98,82 @@ public:
return;
}
// Sends the slab back to the client. It's to refuse a doubleslab placement.
// Sends the slab back to the client. It's to refuse a doubleslab placement. */
a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
}
/// Converts the single-slab blocktype to its equivalent double-slab blocktype
/** Converts the single-slab blocktype to its equivalent double-slab blocktype */
static BLOCKTYPE GetDoubleSlabType(BLOCKTYPE a_SingleSlabBlockType)
{
switch (a_SingleSlabBlockType)
{
case E_BLOCK_STONE_SLAB: return E_BLOCK_DOUBLE_STONE_SLAB;
case E_BLOCK_STONE_SLAB: return E_BLOCK_DOUBLE_STONE_SLAB;
case E_BLOCK_WOODEN_SLAB: return E_BLOCK_DOUBLE_WOODEN_SLAB;
case E_BLOCK_NEW_STONE_SLAB: return E_BLOCK_DOUBLE_NEW_STONE_SLAB;
case E_BLOCK_RED_SANDSTONE_SLAB: return E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB;
}
ASSERT(!"Unhandled slab type!");
return E_BLOCK_AIR;
}
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
{
// Toggle the 4th bit - up / down:
return (a_Meta ^ 0x08);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
a_Meta &= 0x7;
switch (m_BlockType)
{
case E_BLOCK_STONE_SLAB:
{
switch (a_Meta)
{
case E_META_STONE_SLAB_SANDSTONE: return 2;
case E_META_STONE_SLAB_PLANKS: return 13;
case E_META_STONE_SLAB_STONE_BRICK:
case E_META_STONE_SLAB_STONE:
case E_META_STONE_SLAB_COBBLESTONE: return 11;
case E_META_STONE_SLAB_BRICK: return 28;
case E_META_STONE_SLAB_NETHER_BRICK: return 35;
case E_META_STONE_SLAB_QUARTZ: return 8;
default:
{
ASSERT(!"Unhandled meta in slab handler!");
return 0;
}
}
}
case E_BLOCK_WOODEN_SLAB:
{
switch (a_Meta)
{
case E_META_WOODEN_SLAB_BIRCH: return 2;
case E_META_WOODEN_SLAB_JUNGLE: return 10;
case E_META_WOODEN_SLAB_OAK: return 13;
case E_META_WOODEN_SLAB_ACACIA: return 15;
case E_META_WOODEN_SLAB_DARK_OAK: return 26;
case E_META_WOODEN_SLAB_SPRUCE: return 34;
default:
{
ASSERT(!"Unhandled meta in slab handler!");
return 0;
}
}
}
case E_BLOCK_RED_SANDSTONE_SLAB:
{
return 10;
}
default:
{
ASSERT(!"Unhandled blocktype in slab handler!");
return 0;
}
}
}
} ;
@ -142,7 +189,6 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
BLOCKTYPE Block = GetSingleSlabType(m_BlockType);
@ -153,13 +199,19 @@ public:
{
switch (a_BlockType)
{
case E_BLOCK_DOUBLE_STONE_SLAB: return E_BLOCK_STONE_SLAB;
case E_BLOCK_DOUBLE_STONE_SLAB: return E_BLOCK_STONE_SLAB;
case E_BLOCK_DOUBLE_WOODEN_SLAB: return E_BLOCK_WOODEN_SLAB;
case E_BLOCK_DOUBLE_NEW_STONE_SLAB: return E_BLOCK_NEW_STONE_SLAB;
case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB: return E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB;
}
ASSERT(!"Unhandled double slab type!");
return a_BlockType;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
// For doule slabs, the meta values are the same. Only the meaning of the 4th bit changes, but that's ignored in the below handler
return BlockHandler(GetSingleSlabType(m_BlockType))->GetMapBaseColourID(a_Meta);
}
} ;

View File

@ -16,7 +16,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -42,7 +41,6 @@ public:
return true;
}
virtual bool DoesIgnoreBuildCollision(cPlayer * a_Player, NIBBLETYPE a_Meta) override
{
if ((a_Player->GetEquippedItem().m_ItemType == E_BLOCK_SNOW) && (a_Meta < 7))
@ -58,13 +56,11 @@ public:
return false;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_ITEM_SNOWBALL, 1, 0));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY > 0)
@ -82,11 +78,16 @@ public:
return false;
}
virtual bool DoesDropOnUnsuitable(void) override
{
return false;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 14;
}
} ;

View File

@ -17,7 +17,6 @@ public:
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -54,14 +53,12 @@ public:
return true;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to zero
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 90 + 45; // So its not aligned with axis
@ -92,6 +89,32 @@ public:
// Toggle bit 3:
return (a_Meta & 0x0b) | ((~a_Meta) & 0x04);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
switch (m_BlockType)
{
case E_BLOCK_SANDSTONE_STAIRS:
case E_BLOCK_BIRCH_WOOD_STAIRS: return 2;
case E_BLOCK_QUARTZ_STAIRS: return 8;
case E_BLOCK_JUNGLE_WOOD_STAIRS:
case E_BLOCK_RED_SANDSTONE_STAIRS: return 10;
case E_BLOCK_COBBLESTONE_STAIRS:
case E_BLOCK_STONE_BRICK_STAIRS: return 11;
case E_BLOCK_OAK_WOOD_STAIRS: return 13;
case E_BLOCK_ACACIA_WOOD_STAIRS: return 15;
case E_BLOCK_DARK_OAK_WOOD_STAIRS: return 26;
case E_BLOCK_BRICK_STAIRS: return 28;
case E_BLOCK_NETHER_BRICK_STAIRS: return 35;
case E_BLOCK_SPRUCE_WOOD_STAIRS: return 34;
default:
{
ASSERT(!"Unhandled blocktype in stairs handler!");
return 0;
}
}
}
} ;

View File

@ -17,14 +17,12 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
short ItemType = (m_BlockType == E_BLOCK_MELON_STEM) ? E_ITEM_MELON_SEEDS : E_ITEM_PUMPKIN_SEEDS;
a_Pickups.push_back(cItem(ItemType, 1, 0));
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
@ -42,11 +40,16 @@ public:
}
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_FARMLAND));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -25,6 +25,12 @@ public:
}
a_Pickups.push_back(cItem(E_BLOCK_STONE, 1, a_BlockMeta));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 11;
}
};

View File

@ -16,13 +16,11 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_ITEM_SUGARCANE, 1, 0));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@ -73,11 +71,16 @@ public:
return false;
}
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
a_Chunk.GetWorld()->GrowSugarcane(a_RelX + a_Chunk.GetPosX() * cChunkDef::Width, a_RelY, a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width, 1);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -20,6 +20,12 @@ public:
{
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 4;
}
};

View File

@ -18,13 +18,11 @@ public:
{
}
virtual bool DoesIgnoreBuildCollision(void) override
{
return true;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Drop seeds, sometimes
@ -35,7 +33,6 @@ public:
}
}
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop) override
{
if (a_CanDrop && (a_Digger != nullptr) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
@ -70,7 +67,6 @@ public:
super::DropBlock(a_ChunkInterface, a_WorldInterface, a_BlockPluginInterface, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_CanDrop);
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
if (a_RelY <= 0)
@ -81,6 +77,12 @@ public:
BLOCKTYPE BelowBlock = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
return IsBlockTypeOfDirt(BelowBlock);
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -17,7 +17,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -48,7 +47,6 @@ public:
return true;
}
inline static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
{
switch (a_Direction)
@ -68,7 +66,6 @@ public:
return 0x0;
}
inline static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData)
{
switch (a_MetaData)
@ -88,7 +85,6 @@ public:
return BLOCK_FACE_TOP;
}
static bool CanBePlacedOn(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, eBlockFace a_BlockFace)
{
switch (a_BlockType)
@ -119,7 +115,7 @@ public:
// Toches can be placed on the top of these slabs only if the occupy the top half of the voxel
return ((a_BlockFace == BLOCK_FACE_YP) && ((a_BlockMeta & 0x08) == 0x08));
}
case E_BLOCK_WOODEN_STAIRS:
case E_BLOCK_OAK_WOOD_STAIRS:
case E_BLOCK_COBBLESTONE_STAIRS:
case E_BLOCK_BRICK_STAIRS:
case E_BLOCK_STONE_BRICK_STAIRS:
@ -147,7 +143,6 @@ public:
}
}
/** Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure */
static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
@ -172,7 +167,6 @@ public:
return BLOCK_FACE_NONE;
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
eBlockFace Face = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
@ -188,12 +182,17 @@ public:
return CanBePlacedOn(BlockInQuestion, BlockInQuestionMeta, Face);
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Always drop meta = 0
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
} ;

View File

@ -66,7 +66,6 @@ public:
return true;
}
inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_BlockFace)
{
switch (a_BlockFace)
@ -89,7 +88,6 @@ public:
#endif
}
inline static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_Meta)
{
switch (a_Meta & 0x3)
@ -106,7 +104,6 @@ public:
}
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
NIBBLETYPE Meta;
@ -118,6 +115,21 @@ public:
return ((a_RelY > 0) && cBlockInfo::IsSolid(BlockIsOn));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
switch (m_BlockType)
{
case E_BLOCK_TRAPDOOR: return 13;
case E_BLOCK_IRON_TRAPDOOR: return 6;
default:
{
ASSERT(!"Unhandled blocktype in trapdoor handler!");
return 0;
}
}
}
};

View File

@ -20,6 +20,12 @@ public:
{
a_Pickups.push_back(cItem(E_ITEM_STRING, 1, 0));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
};

View File

@ -16,7 +16,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -30,7 +29,6 @@ public:
return true;
}
inline static NIBBLETYPE DirectionToMetadata(eBlockFace a_Direction)
{
switch (a_Direction)
@ -53,7 +51,6 @@ public:
#endif
}
inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta)
{
switch (a_Meta & 0x03)
@ -66,7 +63,6 @@ public:
}
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to zero
@ -84,6 +80,12 @@ public:
return ((a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 0;
}
};

View File

@ -15,7 +15,6 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
@ -39,14 +38,12 @@ public:
return true;
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to zero
a_Pickups.push_back(cItem(E_BLOCK_VINES, 1, 0));
}
static NIBBLETYPE DirectionToMetaData(char a_BlockFace)
{
switch (a_BlockFace)
@ -59,7 +56,6 @@ public:
}
}
static char MetaDataToDirection(NIBBLETYPE a_MetaData)
{
switch (a_MetaData)
@ -72,8 +68,7 @@ public:
}
}
/// Returns true if the specified block type is good for vines to attach to
/** Returns true if the specified block type is good for vines to attach to */
static bool IsBlockAttachable(BLOCKTYPE a_BlockType)
{
switch (a_BlockType)
@ -93,8 +88,7 @@ public:
}
}
/// Returns the meta that has the maximum allowable sides of the vine, given the surroundings
/** Returns the meta that has the maximum allowable sides of the vine, given the surroundings */
NIBBLETYPE GetMaxMeta(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
{
static const struct
@ -124,7 +118,6 @@ public:
return res;
}
void Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
{
NIBBLETYPE CurMeta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
@ -164,19 +157,16 @@ public:
}
}
virtual bool DoesIgnoreBuildCollision(void) override
{
return true;
}
virtual bool DoesDropOnUnsuitable(void) override
{
return false;
}
virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
{
UNUSED(a_ChunkInterface);
@ -200,32 +190,34 @@ public:
}
}
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
return ((a_Meta >> 1) | (a_Meta << 3)) & 0x0f; // Rotate bits to the right
}
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
{
return ((a_Meta << 1) | (a_Meta >> 3)) & 0x0f; // Rotate bits to the left
}
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
{
// Bits 2 and 4 stay, bits 1 and 3 swap
return (NIBBLETYPE)((a_Meta & 0x0a) | ((a_Meta & 0x01) << 2) | ((a_Meta & 0x04) >> 2));
}
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
// Bits 1 and 3 stay, bits 2 and 4 swap
return (NIBBLETYPE)((a_Meta & 0x05) | ((a_Meta & 0x02) << 2) | ((a_Meta & 0x08) >> 2));
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 7;
}
} ;

View File

@ -20,13 +20,11 @@ public:
{
}
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX;
@ -37,7 +35,6 @@ public:
return ((Type == E_BLOCK_WALLSIGN) || (Type == E_BLOCK_SIGN_POST) || cBlockInfo::IsSolid(Type));
}
static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ)
{
switch (a_BlockMeta)
@ -50,7 +47,6 @@ public:
}
}
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
{
switch (a_Direction)
@ -68,6 +64,12 @@ public:
}
return 0x2;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 13;
}
} ;

View File

@ -18,18 +18,22 @@ public:
{
}
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
cWindow * Window = new cCraftingWindow(a_BlockX, a_BlockY, a_BlockZ);
a_Player->OpenWindow(Window);
}
virtual bool IsUseable(void) override
{
return true;
}
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
{
UNUSED(a_Meta);
return 13;
}
} ;

View File

@ -2403,27 +2403,9 @@ void cClientHandle::SendInventorySlot(char a_WindowID, short a_SlotNum, const cI
void cClientHandle::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale)
void cClientHandle::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY)
{
m_Protocol->SendMapColumn(a_ID, a_X, a_Y, a_Colors, a_Length, m_Scale);
}
void cClientHandle::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale)
{
m_Protocol->SendMapDecorators(a_ID, a_Decorators, m_Scale);
}
void cClientHandle::SendMapInfo(int a_ID, unsigned int a_Scale)
{
m_Protocol->SendMapInfo(a_ID, a_Scale);
m_Protocol->SendMapData(a_Map, a_DataStartX, a_DataStartY);
}

View File

@ -178,9 +178,7 @@ public: // tolua_export
void SendHealth (void);
void SendHideTitle (void);
void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item);
void SendMapColumn (int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale);
void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale);
void SendMapInfo (int a_ID, unsigned int a_Scale);
void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY);
void SendPaintingSpawn (const cPainting & a_Painting);
void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount);
void SendParticleEffect (const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data);

View File

@ -205,6 +205,7 @@ void cPlayer::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
if (m_ClientHandle->IsDestroyed())
{
// This should not happen, because destroying a client will remove it from the world, but just in case
ASSERT(!"Player ticked whilst in the process of destruction!");
m_ClientHandle = nullptr;
return;
}
@ -215,6 +216,10 @@ void cPlayer::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
return;
}
}
else
{
ASSERT(!"Player ticked whilst in the process of destruction!");
}
m_Stats.AddValue(statMinutesPlayed, 1);

View File

@ -143,6 +143,7 @@ typedef unsigned short UInt16;
typedef unsigned char UInt8;
typedef unsigned char Byte;
typedef Byte ColourID;
// If you get an error about specialization check the size of integral types
@ -245,6 +246,7 @@ template class SizeChecker<UInt8, 1>;
// STL stuff:
#include <array>
#include <chrono>
#include <vector>
#include <list>

View File

@ -580,21 +580,9 @@ bool cInventory::AddToBar(cItem & a_Item, const int a_Offset, const int a_Size,
void cInventory::UpdateItems(void)
{
const cItem & Slot = GetEquippedItem();
if (Slot.IsEmpty())
if (!Slot.IsEmpty())
{
return;
}
switch (Slot.m_ItemType)
{
case E_ITEM_MAP:
{
ItemHandler(Slot.m_ItemType)->OnUpdate(m_Owner.GetWorld(), &m_Owner, Slot);
break;
}
default: break;
ItemHandler(Slot.m_ItemType)->OnUpdate(m_Owner.GetWorld(), &m_Owner, Slot);
}
}

View File

@ -49,7 +49,7 @@ public:
BLOCKTYPE BlockType;
switch (m_ItemType)
{
case E_ITEM_WOODEN_DOOR: BlockType = E_BLOCK_WOODEN_DOOR; break;
case E_ITEM_WOODEN_DOOR: BlockType = E_BLOCK_OAK_DOOR; break;
case E_ITEM_IRON_DOOR: BlockType = E_BLOCK_IRON_DOOR; break;
case E_ITEM_SPRUCE_DOOR: BlockType = E_BLOCK_SPRUCE_DOOR; break;
case E_ITEM_BIRCH_DOOR: BlockType = E_BLOCK_BIRCH_DOOR; break;

View File

@ -43,8 +43,8 @@ public:
const int RegionWidth = cChunkDef::Width * 8;
int CenterX = (int)(floor(a_Player->GetPosX() / (float) RegionWidth) * RegionWidth);
int CenterZ = (int)(floor(a_Player->GetPosZ() / (float) RegionWidth) * RegionWidth);
int CenterX = FloorC(a_Player->GetPosX() / RegionWidth) * RegionWidth + (RegionWidth / 2);
int CenterZ = FloorC(a_Player->GetPosZ() / RegionWidth) * RegionWidth + (RegionWidth / 2);
cMap * NewMap = a_World->GetMapManager().CreateMap(CenterX, CenterZ, DEFAULT_SCALE);

View File

@ -587,6 +587,7 @@ char cItemHandler::GetMaxStackSize(void)
case E_ITEM_DYE: return 64;
case E_ITEM_EGG: return 16;
case E_ITEM_EMERALD: return 64;
case E_ITEM_EMPTY_MAP: return 64;
case E_ITEM_ENDER_PEARL: return 16;
case E_ITEM_EYE_OF_ENDER: return 64;
case E_ITEM_FEATHER: return 64;
@ -732,7 +733,7 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
case E_BLOCK_DEAD_BUSH:
case E_BLOCK_DIAMOND_BLOCK:
case E_BLOCK_DIAMOND_ORE:
case E_BLOCK_DOUBLE_NEW_STONE_SLAB:
case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB:
case E_BLOCK_DOUBLE_STONE_SLAB:
case E_BLOCK_EMERALD_ORE:
case E_BLOCK_ENCHANTMENT_TABLE:
@ -752,7 +753,7 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
case E_BLOCK_NETHER_BRICK_STAIRS:
case E_BLOCK_NETHER_BRICK_FENCE:
case E_BLOCK_NETHERRACK:
case E_BLOCK_NEW_STONE_SLAB:
case E_BLOCK_RED_SANDSTONE_SLAB:
case E_BLOCK_OBSIDIAN:
case E_BLOCK_PACKED_ICE:
case E_BLOCK_PRISMARINE_BLOCK:

View File

@ -88,7 +88,7 @@ public:
UNUSED(a_BlockFace);
}
/** Called every tick while the item is on the player's inventory (Used by maps) - For now, called only for equipped items */
/** Called every tick while the item is on the player's inventory (used by maps, for example) - For now, called only for equipped items */
virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item)
{
UNUSED(a_World);

View File

@ -37,7 +37,6 @@ public:
}
Map->UpdateRadius(*a_Player, DEFAULT_RADIUS);
Map->UpdateClient(a_Player);
}
} ;

View File

@ -65,7 +65,7 @@ public:
case E_BLOCK_COBBLESTONE:
case E_BLOCK_COBBLESTONE_STAIRS:
case E_BLOCK_COBBLESTONE_WALL:
case E_BLOCK_DOUBLE_NEW_STONE_SLAB:
case E_BLOCK_DOUBLE_RED_SANDSTONE_SLAB:
case E_BLOCK_DOUBLE_STONE_SLAB:
case E_BLOCK_ENCHANTMENT_TABLE:
case E_BLOCK_END_STONE:
@ -76,7 +76,7 @@ public:
case E_BLOCK_NETHER_BRICK:
case E_BLOCK_NETHER_BRICK_STAIRS:
case E_BLOCK_NETHERRACK:
case E_BLOCK_NEW_STONE_SLAB:
case E_BLOCK_RED_SANDSTONE_SLAB:
case E_BLOCK_PRISMARINE_BLOCK:
case E_BLOCK_RED_SANDSTONE:
case E_BLOCK_RED_SANDSTONE_STAIRS:

View File

@ -61,7 +61,7 @@ public:
switch (a_BlockType)
{
case E_BLOCK_NEW_STONE_SLAB:
case E_BLOCK_RED_SANDSTONE_SLAB:
case E_BLOCK_WOODEN_SLAB:
case E_BLOCK_STONE_SLAB:
{

View File

@ -5,108 +5,11 @@
#include "Map.h"
#include "ClientHandle.h"
#include "World.h"
#include "Chunk.h"
#include "Entities/Player.h"
#include "FastRandom.h"
cMapDecorator::cMapDecorator(cMap * a_Map, eType a_Type, int a_X, int a_Z, int a_Rot)
: m_Map(a_Map)
, m_Type(a_Type)
, m_PixelX(a_X)
, m_PixelZ(a_Z)
, m_Rot(a_Rot)
, m_Player(nullptr)
{
}
cMapDecorator::cMapDecorator(cMap * a_Map, cPlayer * a_Player)
: m_Map(a_Map)
, m_Type(E_TYPE_PLAYER)
, m_Player(a_Player)
{
Update();
}
void cMapDecorator::Update(void)
{
if (m_Player != nullptr)
{
ASSERT(m_Map != nullptr);
unsigned int PixelWidth = m_Map->GetPixelWidth();
int InsideWidth = (m_Map->GetWidth() / 2) - 1;
int InsideHeight = (m_Map->GetHeight() / 2) - 1;
int PixelX = (int) (m_Player->GetPosX() - m_Map->GetCenterX()) / PixelWidth;
int PixelZ = (int) (m_Player->GetPosZ() - m_Map->GetCenterZ()) / PixelWidth;
// Center of pixel
m_PixelX = (2 * PixelX) + 1;
m_PixelZ = (2 * PixelZ) + 1;
if ((PixelX > -InsideWidth) && (PixelX <= InsideWidth) && (PixelZ > -InsideHeight) && (PixelZ <= InsideHeight))
{
double Yaw = m_Player->GetYaw();
if (m_Map->GetDimension() == dimNether)
{
cFastRandom Random;
// TODO 2014-02-19 xdot: Refine
m_Rot = Random.NextInt(16);
}
else
{
m_Rot = (int) (Yaw * 16) / 360;
}
m_Type = E_TYPE_PLAYER;
}
else
{
if ((abs(PixelX) > 320.0) || (abs(PixelZ) > 320.0))
{
// TODO 2014-02-18 xdot: Remove decorator
}
m_Rot = 0;
m_Type = E_TYPE_PLAYER_OUTSIDE;
// Move to border
if (PixelX <= -InsideWidth)
{
m_PixelX = (2 * -InsideWidth) + 1;
}
if (PixelZ <= -InsideHeight)
{
m_PixelZ = (2 * -InsideHeight) + 1;
}
if (PixelX > InsideWidth)
{
m_PixelX = (2 * InsideWidth) + 1;
}
if (PixelZ > InsideHeight)
{
m_PixelZ = (2 * InsideHeight) + 1;
}
}
}
}
#include "Blocks/BlockHandler.h"
@ -148,6 +51,20 @@ cMap::cMap(unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld * a_World, un
void cMap::Tick()
{
for (const auto & Client : m_ClientsInCurrentTick)
{
Client->SendMapData(*this, 0, 0);
}
m_ClientsInCurrentTick.clear();
m_Decorators.clear();
}
void cMap::UpdateRadius(int a_PixelX, int a_PixelZ, unsigned int a_Radius)
{
int PixelRadius = a_Radius / GetPixelWidth();
@ -219,13 +136,11 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
virtual bool Item(cChunk * a_Chunk) override
{
if (a_Chunk == nullptr)
if (!a_Chunk->IsValid())
{
return false;
}
unsigned int CallbackPixelWidth = m_Map->GetPixelWidth();
if (m_Map->GetDimension() == dimNether)
{
// TODO 2014-02-22 xdot: Nether maps
@ -233,84 +148,33 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
return false;
}
typedef std::map<ColorID, unsigned int> ColorCountMap;
ColorCountMap ColorCounts;
static const std::array<unsigned char, 4> BrightnessID = { { 3, 0, 1, 2 } }; // Darkest to lightest
BLOCKTYPE TargetBlock;
NIBBLETYPE TargetMeta;
// Count surface blocks
for (unsigned int X = m_RelX; X < m_RelX + CallbackPixelWidth; ++X)
auto Height = a_Chunk->GetHeight(m_RelX, m_RelZ);
auto ChunkHeight = cChunkDef::Height;
a_Chunk->GetBlockTypeMeta(m_RelX, Height, m_RelZ, TargetBlock, TargetMeta);
auto ColourID = BlockHandler(TargetBlock)->GetMapBaseColourID(TargetMeta);
if (IsBlockWater(TargetBlock))
{
for (unsigned int Z = m_RelZ; Z < m_RelZ + CallbackPixelWidth; ++Z)
ChunkHeight /= 4;
while (((--Height) != -1) && IsBlockWater(a_Chunk->GetBlock(m_RelX, Height, m_RelZ)))
{
// unsigned int WaterDepth = 0;
BLOCKTYPE TargetBlock = E_BLOCK_AIR;
NIBBLETYPE TargetMeta = 0;
int Height = a_Chunk->GetHeight(X, Z);
while (Height > 0)
{
a_Chunk->GetBlockTypeMeta(X, Height, Z, TargetBlock, TargetMeta);
// TODO 2014-02-22 xdot: Check if block color is transparent
if (TargetBlock == E_BLOCK_AIR)
{
--Height;
continue;
}
// TODO 2014-02-22 xdot: Check if block is liquid
/*
else if (false)
{
--Height;
++WaterDepth;
continue;
}
*/
break;
}
// TODO 2014-02-22 xdot: Query block color
ColorID Color = E_BASE_COLOR_BROWN;
// Debug - Temporary
switch (TargetBlock)
{
case E_BLOCK_GRASS:
{
Color = E_BASE_COLOR_LIGHT_GREEN; break;
}
case E_BLOCK_STATIONARY_WATER:
case E_BLOCK_WATER:
{
Color = E_BASE_COLOR_BLUE; break;
}
}
++ColorCounts[Color];
continue;
}
}
else if (ColourID == 0)
{
while (((--Height) != -1) && ((ColourID = BlockHandler(a_Chunk->GetBlock(m_RelX, Height, m_RelZ))->GetMapBaseColourID(a_Chunk->GetMeta(m_RelX, Height, m_RelZ))) == 0))
{
continue;
}
}
// Find dominant color
ColorID PixelColor = E_BASE_COLOR_TRANSPARENT;
unsigned int MaxCount = 0;
for (ColorCountMap::iterator it = ColorCounts.begin(); it != ColorCounts.end(); ++it)
{
if (it->second > MaxCount)
{
PixelColor = it->first;
MaxCount = it->second;
}
}
// TODO 2014-02-22 xdot: Adjust brightness
unsigned int dColor = 1;
m_PixelData = PixelColor + dColor;
// Multiply base color ID by 4 and add brightness ID
m_PixelData = ColourID * 4 + BrightnessID[Clamp<size_t>(static_cast<size_t>(Height / (ChunkHeight / BrightnessID.size())), 0, BrightnessID.size() - 1)];
return false;
}
@ -332,162 +196,11 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
void cMap::UpdateDecorators(void)
{
for (cMapDecoratorList::iterator it = m_Decorators.begin(); it != m_Decorators.end(); ++it)
{
it->Update();
}
}
void cMap::AddPlayer(cPlayer * a_Player, Int64 a_WorldAge)
{
cClientHandle * Handle = a_Player->GetClientHandle();
if (Handle == nullptr)
{
return;
}
cMapClient MapClient;
MapClient.m_LastUpdate = a_WorldAge;
MapClient.m_SendInfo = true;
MapClient.m_Handle = Handle;
MapClient.m_DataUpdate = 0;
MapClient.m_NextDecoratorUpdate = 0;
m_Clients.push_back(MapClient);
cMapDecorator PlayerDecorator(this, a_Player);
m_Decorators.push_back(PlayerDecorator);
}
void cMap::RemoveInactiveClients(Int64 a_WorldAge)
{
for (cMapClientList::iterator it = m_Clients.begin(); it != m_Clients.end();)
{
if (it->m_LastUpdate < a_WorldAge)
{
// Remove associated decorators
for (cMapDecoratorList::iterator it2 = m_Decorators.begin(); it2 != m_Decorators.end();)
{
if (it2->GetPlayer()->GetClientHandle() == it->m_Handle)
{
// Erase decorator
cMapDecoratorList::iterator temp = it2;
++it2;
m_Decorators.erase(temp);
}
else
{
++it2;
}
}
// Erase client
cMapClientList::iterator temp = it;
++it;
m_Clients.erase(temp);
}
else
{
++it;
}
}
}
void cMap::StreamNext(cMapClient & a_Client)
{
cClientHandle * Handle = a_Client.m_Handle;
if (a_Client.m_SendInfo)
{
Handle->SendMapInfo(m_ID, m_Scale);
a_Client.m_SendInfo = false;
return;
}
++a_Client.m_NextDecoratorUpdate;
if (a_Client.m_NextDecoratorUpdate >= 4)
{
// TODO 2014-02-19 xdot
// This is dangerous as the player object may have been destroyed before the decorator is erased from the list
UpdateDecorators();
Handle->SendMapDecorators(m_ID, m_Decorators, m_Scale);
a_Client.m_NextDecoratorUpdate = 0;
}
else
{
++a_Client.m_DataUpdate;
unsigned int Y = (a_Client.m_DataUpdate * 11) % m_Width;
const Byte * Colors = &m_Data[Y * m_Height];
Handle->SendMapColumn(m_ID, Y, 0, Colors, m_Height, m_Scale);
}
}
void cMap::UpdateClient(cPlayer * a_Player)
{
ASSERT(a_Player != nullptr);
cClientHandle * Handle = a_Player->GetClientHandle();
if (Handle == nullptr)
{
return;
}
Int64 WorldAge = a_Player->GetWorld()->GetWorldAge();
RemoveInactiveClients(WorldAge - 5);
// Linear search for client state
for (cMapClientList::iterator it = m_Clients.begin(); it != m_Clients.end(); ++it)
{
if (it->m_Handle == Handle)
{
it->m_LastUpdate = WorldAge;
StreamNext(*it);
return;
}
}
// New player, construct a new client state
AddPlayer(a_Player, WorldAge);
}
void cMap::EraseData(void)
{
m_Data.assign(m_Width * m_Height, 0);
m_Decorators.emplace_back(CreateDecorator(a_Player));
m_ClientsInCurrentTick.push_back(a_Player->GetClientHandle());
}
@ -532,30 +245,11 @@ void cMap::SetPosition(int a_CenterX, int a_CenterZ)
void cMap::SetScale(unsigned int a_Scale)
{
if (m_Scale == a_Scale)
{
return;
}
m_Scale = a_Scale;
for (cMapClientList::iterator it = m_Clients.begin(); it != m_Clients.end(); ++it)
{
it->m_SendInfo = true;
}
}
bool cMap::SetPixel(unsigned int a_X, unsigned int a_Z, cMap::ColorID a_Data)
{
if ((a_X < m_Width) && (a_Z < m_Height))
{
m_Data[a_Z + (a_X * m_Height)] = a_Data;
m_Data[a_Z * m_Width + a_X] = a_Data;
return true;
}
@ -573,7 +267,7 @@ cMap::ColorID cMap::GetPixel(unsigned int a_X, unsigned int a_Z)
{
if ((a_X < m_Width) && (a_Z < m_Height))
{
return m_Data[a_Z + (a_X * m_Height)];
return m_Data[a_Z * m_Width + a_X];
}
else
{
@ -585,24 +279,6 @@ cMap::ColorID cMap::GetPixel(unsigned int a_X, unsigned int a_Z)
void cMap::SendTo(cClientHandle & a_Client)
{
a_Client.SendMapInfo(m_ID, m_Scale);
for (unsigned int i = 0; i < m_Width; ++i)
{
const Byte * Colors = &m_Data[i * m_Height];
a_Client.SendMapColumn(m_ID, i, 0, Colors, m_Height, m_Scale);
}
a_Client.SendMapDecorators(m_ID, m_Decorators, m_Scale);
}
unsigned int cMap::GetNumPixels(void) const
{
return m_Width * m_Height;
@ -612,9 +288,66 @@ unsigned int cMap::GetNumPixels(void) const
size_t cMap::GetNumDecorators(void) const
const cMapDecorator cMap::CreateDecorator(const cEntity * a_TrackedEntity)
{
return m_Decorators.size();
int InsideWidth = (GetWidth() / 2) - 1;
int InsideHeight = (GetHeight() / 2) - 1;
// Center of pixel
int PixelX = (int)(a_TrackedEntity->GetPosX() - GetCenterX()) / GetPixelWidth();
int PixelZ = (int)(a_TrackedEntity->GetPosZ() - GetCenterZ()) / GetPixelWidth();
cMapDecorator::eType Type;
int Rot;
if ((PixelX > -InsideWidth) && (PixelX <= InsideWidth) && (PixelZ > -InsideHeight) && (PixelZ <= InsideHeight))
{
double Yaw = a_TrackedEntity->GetYaw();
if (GetDimension() == dimNether)
{
cFastRandom Random;
// TODO 2014-02-19 xdot: Refine
Rot = Random.NextInt(16);
}
else
{
Rot = CeilC(((Yaw - 11.25) * 16) / 360);
}
Type = cMapDecorator::eType::E_TYPE_PLAYER;
}
else
{
if ((PixelX > 320.0) || (PixelZ > 320.0))
{
;
}
Rot = 0;
Type = cMapDecorator::eType::E_TYPE_PLAYER_OUTSIDE;
// Move to border
if (PixelX <= -InsideWidth)
{
PixelX = -InsideWidth;
}
if (PixelZ <= -InsideHeight)
{
PixelZ = -InsideHeight;
}
if (PixelX > InsideWidth)
{
PixelX = InsideWidth;
}
if (PixelZ > InsideHeight)
{
PixelZ = InsideHeight;
}
}
return {Type, (unsigned)(2 * PixelX + 1), (unsigned)(2 * PixelZ + 1), Rot};
}

View File

@ -22,6 +22,7 @@
class cClientHandle;
class cWorld;
class cPlayer;
class cItemFrame;
class cMap;
@ -35,11 +36,11 @@ A map decorator represents an object drawn on the map that can move freely.
Excluding manually placed decorators,
decorators are automatically managed (allocated and freed) by their parent cMap instance.
*/
class cMapDecorator
struct cMapDecorator
{
public:
enum eType
enum class eType
{
E_TYPE_PLAYER = 0x00,
E_TYPE_ITEM_FRAME = 0x01,
@ -48,45 +49,34 @@ public:
E_TYPE_PLAYER_OUTSIDE = 0x06
};
cMapDecorator(eType a_Type, unsigned int a_X, unsigned int a_Z, int a_Rot) :
m_Type(a_Type),
m_PixelX(a_X),
m_PixelZ(a_Z),
m_Rot(a_Rot)
{
}
public:
/** Constructs a map decorator fixed at the specified pixel coordinates. (DEBUG) */
cMapDecorator(cMap * a_Map, eType a_Type, int a_X, int a_Z, int a_Rot);
/** Constructs a map decorator that tracks a player. */
cMapDecorator(cMap * a_Map, cPlayer * a_Player);
/** Updates the decorator. */
void Update(void);
unsigned int GetPixelX(void) const { return m_PixelX; }
unsigned int GetPixelZ(void) const { return m_PixelZ; }
unsigned int GetRot(void) const { return m_Rot; }
int GetRot(void) const { return m_Rot; }
eType GetType(void) const { return m_Type; }
cPlayer * GetPlayer(void) { return m_Player; }
protected:
cMap * m_Map;
private:
eType m_Type;
unsigned int m_PixelX;
unsigned int m_PixelZ;
unsigned int m_Rot;
cPlayer * m_Player;
int m_Rot;
};
typedef std::list<cMapDecorator> cMapDecoratorList;
@ -102,6 +92,7 @@ public:
{
E_BASE_COLOR_TRANSPARENT = 0, /* Air */
E_BASE_COLOR_LIGHT_GREEN = 4, /* Grass */
E_BASE_COLOR_LIGHT_BLUE = 5,
E_BASE_COLOR_LIGHT_BROWN = 8, /* Sand */
E_BASE_COLOR_GRAY_1 = 12, /* Cloth */
E_BASE_COLOR_RED = 16, /* TNT */
@ -121,9 +112,8 @@ public:
// tolua_end
typedef std::vector<ColorID> cColorList;
public:
typedef std::vector<cClientHandle *> cMapClientList;
typedef std::vector<cMapDecorator> cMapDecoratorList;
/** Construct an empty map. */
cMap(unsigned int a_ID, cWorld * a_World);
@ -131,8 +121,9 @@ public:
/** Construct an empty map at the specified coordinates. */
cMap(unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld * a_World, unsigned int a_Scale = 3);
/** Send this map to the specified client. WARNING: Slow */
void SendTo(cClientHandle & a_Client);
/** Sends a map update to all registered clients
Clears the list holding registered clients and decorators */
void Tick();
/** Update a circular region with the specified radius and center (in pixels). */
void UpdateRadius(int a_PixelX, int a_PixelZ, unsigned int a_Radius);
@ -145,14 +136,11 @@ public:
// tolua_begin
/** Erase pixel data */
void EraseData(void);
void Resize(unsigned int a_Width, unsigned int a_Height);
void SetPosition(int a_CenterX, int a_CenterZ);
void SetScale(unsigned int a_Scale);
void SetScale(unsigned int a_Scale) { m_Scale = a_Scale; }
bool SetPixel(unsigned int a_X, unsigned int a_Z, ColorID a_Data);
@ -180,7 +168,9 @@ public:
// tolua_end
size_t GetNumDecorators(void) const;
const cMapDecorator CreateDecorator(const cEntity * a_TrackedEntity);
const cMapDecoratorList GetDecorators(void) const { return m_Decorators; }
const cColorList & GetData(void) const { return m_Data; }
@ -195,48 +185,11 @@ public:
}
protected:
/** Encapsulates the state of a map client.
In order to enhance performace, maps are streamed column-by-column to each client.
This structure stores the state of the stream.
*/
struct cMapClient
{
cClientHandle * m_Handle;
/** Whether the map scale was modified and needs to be resent. */
bool m_SendInfo;
/** Ticks since last decorator update. */
unsigned int m_NextDecoratorUpdate;
/** Number of pixel data updates. */
Int64 m_DataUpdate;
Int64 m_LastUpdate;
};
typedef std::list<cMapClient> cMapClientList;
private:
/** Update the associated decorators. */
void UpdateDecorators(void);
/** Update the specified pixel. */
bool UpdatePixel(unsigned int a_X, unsigned int a_Z);
/** Add a new map client. */
void AddPlayer(cPlayer * a_Player, Int64 a_WorldAge);
/** Remove inactive or invalid clients. */
void RemoveInactiveClients(Int64 a_WorldAge);
/** Send next update packet to the specified client. */
void StreamNext(cMapClient & a_Client);
unsigned int m_ID;
unsigned int m_Width;
@ -253,9 +206,9 @@ private:
cWorld * m_World;
cMapDecoratorList m_Decorators;
cMapClientList m_ClientsInCurrentTick;
cMapClientList m_Clients;
cMapDecoratorList m_Decorators;
AString m_Name;

View File

@ -42,18 +42,13 @@ bool cMapManager::DoWithMap(UInt32 a_ID, cMapCallback & a_Callback)
bool cMapManager::ForEachMap(cMapCallback & a_Callback)
void cMapManager::TickMaps()
{
cCSLock Lock(m_CS);
for (cMapList::iterator itr = m_MapData.begin(); itr != m_MapData.end(); ++itr)
for (auto & Map : m_MapData)
{
cMap * Map = &(*itr);
if (a_Callback.Item(Map))
{
return false;
}
} // for itr - m_MapData[]
return true;
Map.Tick();
}
}
@ -97,15 +92,6 @@ cMap * cMapManager::CreateMap(int a_CenterX, int a_CenterY, unsigned int a_Scale
size_t cMapManager::GetNumMaps(void) const
{
return m_MapData.size();
}
void cMapManager::LoadMapData(void)
{
cCSLock Lock(m_CS);

View File

@ -43,11 +43,8 @@ public:
Callback return value is ignored. */
bool DoWithMap(UInt32 a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp
/** Calls the callback for each map.
Returns true if all maps processed, false if the callback aborted by returning true. */
bool ForEachMap(cMapCallback & a_Callback);
size_t GetNumMaps(void) const; // tolua_export
/** Ticks each registered map */
void TickMaps(void);
/** Loads the map data from the disk */
void LoadMapData(void);

View File

@ -159,7 +159,7 @@ bool cPath::IsSolid(const Vector3i & a_Location)
m_Chunk->GetBlockTypeMeta(RelX, a_Location.y, RelZ, BlockType, BlockMeta);
if (
(BlockType == E_BLOCK_FENCE) ||
(BlockType == E_BLOCK_FENCE_GATE) ||
(BlockType == E_BLOCK_OAK_FENCE_GATE) ||
(BlockType == E_BLOCK_NETHER_BRICK_FENCE) ||
((BlockType >= E_BLOCK_SPRUCE_FENCE_GATE) && (BlockType <= E_BLOCK_ACACIA_FENCE))
)

View File

@ -99,9 +99,7 @@ public:
virtual void SendKeepAlive (int a_PingID) = 0;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) = 0;
virtual void SendLoginSuccess (void) = 0;
virtual void SendMapColumn (int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) = 0;
virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) = 0;
virtual void SendMapInfo (int a_ID, unsigned int a_Scale) = 0;
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) = 0;
virtual void SendPaintingSpawn (const cPainting & a_Painting) = 0;
virtual void SendPickupSpawn (const cPickup & a_Pickup) = 0;
virtual void SendPlayerAbilities (void) = 0;

View File

@ -723,64 +723,55 @@ void cProtocol172::SendPaintingSpawn(const cPainting & a_Painting)
void cProtocol172::SendMapColumn(int a_MapID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale)
void cProtocol172::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY)
{
ASSERT(m_State == 3); // In game mode?
ASSERT(a_Length + 3 <= USHRT_MAX);
ASSERT((a_X >= 0) && (a_X < 256));
ASSERT((a_Y >= 0) && (a_Y < 256));
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
Pkt.WriteBEUInt16(static_cast<UInt16>(3 + a_Length));
Pkt.WriteBEUInt8(0);
Pkt.WriteBEUInt8(static_cast<Byte>(a_X));
Pkt.WriteBEUInt8(static_cast<Byte>(a_Y));
Pkt.WriteBuf(reinterpret_cast<const char *>(a_Colors), a_Length);
}
void cProtocol172::SendMapDecorators(int a_MapID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale)
{
ASSERT(m_State == 3); // In game mode?
ASSERT(1 + 3 * a_Decorators.size() < USHRT_MAX);
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
Pkt.WriteBEUInt16(static_cast<UInt16>(1 + (3 * a_Decorators.size())));
Pkt.WriteBEUInt8(1);
for (cMapDecoratorList::const_iterator it = a_Decorators.begin(); it != a_Decorators.end(); ++it)
{
ASSERT(it->GetPixelX() < 256);
ASSERT(it->GetPixelZ() < 256);
Pkt.WriteBEUInt8(static_cast<Byte>((it->GetType() << 4) | static_cast<Byte>(it->GetRot() & 0xf)));
Pkt.WriteBEUInt8(static_cast<Byte>(it->GetPixelX()));
Pkt.WriteBEUInt8(static_cast<Byte>(it->GetPixelZ()));
ASSERT(a_Map.GetScale() < 256);
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetID()));
Pkt.WriteBEUInt16(2);
Pkt.WriteBEUInt8(2);
Pkt.WriteBEUInt8(static_cast<Byte>(a_Map.GetScale()));
}
}
{
ASSERT(a_Map.GetData().size() + 3 <= USHRT_MAX);
ASSERT((a_DataStartX >= 0) && (a_DataStartX < 256));
ASSERT((a_DataStartY >= 0) && (a_DataStartY < 256));
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetID()));
Pkt.WriteBEUInt16(static_cast<UInt16>(3 + a_Map.GetData().size()));
Pkt.WriteBEUInt8(0);
Pkt.WriteBEUInt8(static_cast<Byte>(a_DataStartX));
Pkt.WriteBEUInt8(static_cast<Byte>(a_DataStartX));
Pkt.WriteBuf(reinterpret_cast<const char *>(a_Map.GetData().data()), a_Map.GetData().size());
}
void cProtocol172::SendMapInfo(int a_MapID, unsigned int a_Scale)
{
ASSERT(m_State == 3); // In game mode?
ASSERT(a_Scale < 256);
{
ASSERT(1 + 3 * a_Map.GetDecorators().size() < USHRT_MAX);
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
Pkt.WriteBEUInt16(2);
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetID()));
Pkt.WriteBEUInt16(static_cast<UInt16>(1 + (3 * a_Map.GetDecorators().size())));
Pkt.WriteBEUInt8(2);
Pkt.WriteBEUInt8(static_cast<Byte>(a_Scale));
Pkt.WriteBEUInt8(1);
for (const auto & Decorator : a_Map.GetDecorators())
{
ASSERT(Decorator.GetPixelX() < 256);
ASSERT(Decorator.GetPixelZ() < 256);
Pkt.WriteBEUInt8(static_cast<Byte>((Decorator.GetRot() << 4) | static_cast<int>(Decorator.GetType())));
Pkt.WriteBEUInt8(static_cast<Byte>(Decorator.GetPixelX()));
Pkt.WriteBEUInt8(static_cast<Byte>(Decorator.GetPixelZ()));
}
}
}

View File

@ -101,9 +101,7 @@ public:
virtual void SendKeepAlive (int a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendLoginSuccess (void) override;
virtual void SendMapColumn (int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) override;
virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) override;
virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override;
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) override;
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;

View File

@ -715,60 +715,31 @@ void cProtocol180::SendPaintingSpawn(const cPainting & a_Painting)
void cProtocol180::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale)
void cProtocol180::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(a_ID);
Pkt.WriteBEUInt8(m_Scale);
Pkt.WriteVarInt32(a_Map.GetID());
Pkt.WriteBEUInt8(a_Map.GetScale());
Pkt.WriteVarInt32(0);
Pkt.WriteBEUInt8(1);
Pkt.WriteBEUInt8(a_Length);
Pkt.WriteBEUInt8(a_X);
Pkt.WriteBEUInt8(a_Y);
Pkt.WriteVarInt32(a_Length);
for (unsigned int i = 0; i < a_Length; ++i)
Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetDecorators().size()));
for (const auto Decorator : a_Map.GetDecorators())
{
Pkt.WriteBEUInt8(a_Colors[i]);
}
}
void cProtocol180::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(a_ID);
Pkt.WriteBEUInt8(m_Scale);
Pkt.WriteVarInt32(static_cast<UInt32>(a_Decorators.size()));
for (cMapDecoratorList::const_iterator it = a_Decorators.begin(); it != a_Decorators.end(); ++it)
{
Pkt.WriteBEUInt8((it->GetType() << 4) | (it->GetRot() & 0xf));
Pkt.WriteBEUInt8(it->GetPixelX());
Pkt.WriteBEUInt8(it->GetPixelZ());
Pkt.WriteBEUInt8(static_cast<Byte>((static_cast<int>(Decorator.GetType()) << 4) | (Decorator.GetRot() & 0xF)));
Pkt.WriteBEUInt8(Decorator.GetPixelX());
Pkt.WriteBEUInt8(Decorator.GetPixelZ());
}
Pkt.WriteBEUInt8(0);
}
void cProtocol180::SendMapInfo(int a_ID, unsigned int a_Scale)
{
UNUSED(a_ID);
UNUSED(a_Scale);
// This packet was removed in 1.8
Pkt.WriteBEUInt8(128);
Pkt.WriteBEUInt8(128);
Pkt.WriteBEUInt8(a_DataStartX);
Pkt.WriteBEUInt8(a_DataStartY);
Pkt.WriteVarInt32(static_cast<UInt32>(a_Map.GetData().size()));
for (auto itr = a_Map.GetData().cbegin(); itr != a_Map.GetData().cend(); ++itr)
{
Pkt.WriteBEUInt8(*itr);
}
}

View File

@ -96,9 +96,7 @@ public:
virtual void SendKeepAlive (int a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendLoginSuccess (void) override;
virtual void SendMapColumn (int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) override;
virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) override;
virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override;
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendPlayerAbilities (void) override;

View File

@ -470,30 +470,10 @@ void cProtocolRecognizer::SendLoginSuccess(void)
void cProtocolRecognizer::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale)
void cProtocolRecognizer::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendMapColumn(a_ID, a_X, a_Y, a_Colors, a_Length, m_Scale);
}
void cProtocolRecognizer::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendMapDecorators(a_ID, a_Decorators, m_Scale);
}
void cProtocolRecognizer::SendMapInfo(int a_ID, unsigned int a_Scale)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendMapInfo(a_ID, a_Scale);
m_Protocol->SendMapData(a_Map, a_DataStartX, a_DataStartY);
}

View File

@ -84,9 +84,7 @@ public:
virtual void SendKeepAlive (int a_PingID) override;
virtual void SendLogin (const cPlayer & a_Player, const cWorld & a_World) override;
virtual void SendLoginSuccess (void) override;
virtual void SendMapColumn (int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) override;
virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) override;
virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override;
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) override;
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override;

View File

@ -168,7 +168,7 @@ bool cFireSimulator::IsFuel(BLOCKTYPE a_BlockType)
case E_BLOCK_PLANKS:
case E_BLOCK_DOUBLE_WOODEN_SLAB:
case E_BLOCK_WOODEN_SLAB:
case E_BLOCK_WOODEN_STAIRS:
case E_BLOCK_OAK_WOOD_STAIRS:
case E_BLOCK_SPRUCE_WOOD_STAIRS:
case E_BLOCK_BIRCH_WOOD_STAIRS:
case E_BLOCK_JUNGLE_WOOD_STAIRS:
@ -184,7 +184,7 @@ bool cFireSimulator::IsFuel(BLOCKTYPE a_BlockType)
case E_BLOCK_JUNGLE_FENCE:
case E_BLOCK_DARK_OAK_FENCE:
case E_BLOCK_ACACIA_FENCE:
case E_BLOCK_FENCE_GATE:
case E_BLOCK_OAK_FENCE_GATE:
case E_BLOCK_SPRUCE_FENCE_GATE:
case E_BLOCK_BIRCH_FENCE_GATE:
case E_BLOCK_JUNGLE_FENCE_GATE:

Some files were not shown because too many files have changed in this diff Show More