From 7f87d6c3d6a116742f25f1846d747a33afdc63f0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 16 Aug 2013 11:23:24 +0100 Subject: Feature and bugfixes [SEE DESC] Added TNT and Hopper minecarts Fixed piston code failing without an extension set Repeaters are now broken Fixed not being able to place a minecart on an activator rail Added much needed comments on piston code Fixed minor formatting issue --- Tools/ProtoProxy/Connection.cpp | 2 + source/BlockID.cpp | 2 + source/BlockID.h | 2 +- source/Defines.h | 4 +- source/Items/ItemHandler.cpp | 2 + source/Items/ItemMinecart.h | 1 + source/Minecart.cpp | 26 ++++++++++ source/Minecart.h | 33 +++++++++++- source/Piston.cpp | 83 +++++++++++++----------------- source/WorldStorage/NBTChunkSerializer.cpp | 2 + source/WorldStorage/NBTChunkSerializer.h | 2 + source/WorldStorage/WSSAnvil.cpp | 2 + source/WorldStorage/WSSAnvil.h | 2 + 13 files changed, 111 insertions(+), 52 deletions(-) diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index fd7914bb6..4c2b0d4e9 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -212,6 +212,8 @@ enum OBJECT_MINECART = 10, OBJECT_MINECART_STORAGE = 11, OBJECT_MINECART_POWERED = 12, + OBJECT_MINECART_TNT = 13, + OBJECT_MINECART_HOPPER = 14, OBJECT_TNT = 50, OBJECT_ENDERCRYSTAL = 51, OBJECT_ARROW = 60, diff --git a/source/BlockID.cpp b/source/BlockID.cpp index 05506777c..91afeaa35 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -661,6 +661,8 @@ public: g_BlockPistonBreakable[E_BLOCK_MELON_STEM] = true; g_BlockPistonBreakable[E_BLOCK_PUMPKIN] = true; g_BlockPistonBreakable[E_BLOCK_PUMPKIN_STEM] = true; + g_BlockPistonBreakable[E_BLOCK_REDSTONE_REPEATER_OFF] = true; + g_BlockPistonBreakable[E_BLOCK_REDSTONE_REPEATER_ON] = true; g_BlockPistonBreakable[E_BLOCK_REDSTONE_TORCH_OFF] = true; g_BlockPistonBreakable[E_BLOCK_REDSTONE_TORCH_ON] = true; g_BlockPistonBreakable[E_BLOCK_REDSTONE_WIRE] = true; diff --git a/source/BlockID.h b/source/BlockID.h index 571087ab7..eaf234c7b 100644 --- a/source/BlockID.h +++ b/source/BlockID.h @@ -6,7 +6,7 @@ enum ENUM_BLOCK_ID E_BLOCK_AIR = 0, E_BLOCK_STONE = 1, E_BLOCK_GRASS = 2, - E_BLOCK_DIRT = 3, + E_BLOCK_DIRT = 3, E_BLOCK_COBBLESTONE = 4, E_BLOCK_PLANKS = 5, E_BLOCK_SAPLING = 6, diff --git a/source/Defines.h b/source/Defines.h index 94e618eb0..48a7cfb1e 100644 --- a/source/Defines.h +++ b/source/Defines.h @@ -189,9 +189,7 @@ inline bool IsValidBlock(int a_BlockType) { if ( (a_BlockType > -1) && - (a_BlockType <= E_BLOCK_MAX_TYPE_ID) && - (a_BlockType != 34) && // Piston extension - (a_BlockType != 36) // Piston moved block + (a_BlockType <= E_BLOCK_MAX_TYPE_ID) ) { return true; diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp index f3f4ac6e7..a831bb713 100644 --- a/source/Items/ItemHandler.cpp +++ b/source/Items/ItemHandler.cpp @@ -162,6 +162,8 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_MINECART: case E_ITEM_CHEST_MINECART: case E_ITEM_FURNACE_MINECART: + case E_ITEM_MINECART_WITH_TNT: + case E_ITEM_MINECART_WITH_HOPPER: { return new cItemMinecartHandler(a_ItemType); } diff --git a/source/Items/ItemMinecart.h b/source/Items/ItemMinecart.h index 1470104a3..8be3baada 100644 --- a/source/Items/ItemMinecart.h +++ b/source/Items/ItemMinecart.h @@ -43,6 +43,7 @@ public: case E_BLOCK_MINECART_TRACKS: case E_BLOCK_POWERED_RAIL: case E_BLOCK_DETECTOR_RAIL: + case E_BLOCK_ACTIVATOR_RAIL: { // These are allowed break; diff --git a/source/Minecart.cpp b/source/Minecart.cpp index cffa1b6e0..19ea861a1 100644 --- a/source/Minecart.cpp +++ b/source/Minecart.cpp @@ -44,6 +44,8 @@ void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) case mpNone: Type = 10; break; case mpChest: Type = 11; break; case mpFurnace: Type = 12; break; + case mpTNT: Type = 13; break; + case mpHopper: Type = 14; break; default: { ASSERT(!"Unknown payload, cannot spawn on client"); @@ -162,3 +164,27 @@ void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player) +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cMinecartWithTNT: + +cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) : + super(mpTNT, a_X, a_Y, a_Z) +{ +} + +// TODO: Make it activate when passing over activator rail + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cMinecartWithHopper: + +cMinecartWithHopper::cMinecartWithHopper(double a_X, double a_Y, double a_Z) : + super(mpHopper, a_X, a_Y, a_Z) +{ +} + +// TODO: Make it suck up blocks and travel further than any other cart and physics and put and take blocks +// AND AVARYTHING!! \ No newline at end of file diff --git a/source/Minecart.h b/source/Minecart.h index e205a4963..e120af763 100644 --- a/source/Minecart.h +++ b/source/Minecart.h @@ -29,7 +29,9 @@ public: mpNone, // Empty minecart, ridable by player or mobs mpChest, // Minecart-with-chest, can store a grid of 3*8 items mpFurnace, // Minecart-with-furnace, can be powered - // TODO: Other 1.5 features: hopper, tnt, dispenser, spawner + mpTNT, // Minecart-with-TNT, can be blown up with activator rail + mpHopper, // Minecart-with-hopper, can be hopper + // TODO: Spawner minecarts, (and possibly any block in a minecart with NBT editing) } ; // cEntity overrides: @@ -115,3 +117,32 @@ public: + +class cMinecartWithTNT : + public cMinecart +{ + typedef cMinecart super; + +public: + CLASS_PROTODEF(cMinecartWithTNT); + + cMinecartWithTNT(double a_X, double a_Y, double a_Z); +} ; + + + + + +class cMinecartWithHopper : + public cMinecart +{ + typedef cMinecart super; + +public: + CLASS_PROTODEF(cMinecartWithHopper); + + cMinecartWithHopper(double a_X, double a_Y, double a_Z); + + // cEntity overrides: + virtual void OnRightClicked(cPlayer & a_Player) override; +} ; \ No newline at end of file diff --git a/source/Piston.cpp b/source/Piston.cpp index 310fcdfd4..7ffa9febd 100644 --- a/source/Piston.cpp +++ b/source/Piston.cpp @@ -20,7 +20,7 @@ extern bool g_BlockPistonBreakable[]; - +//Replace AddDir (...) with the switch cases that, sets coords in direction of piston face #define AddDir( x, y, z, dir, amount ) \ switch (dir) \ { \ @@ -52,25 +52,26 @@ unsigned short cPiston::FirstPassthroughBlock(int pistonX, int pistonY, int pist pistonmeta &= 7; if (pistonmeta >= 6) { - // Just in case, it shouldn't happen but if it would, it'd case inf loop + // Just in case, it shouldn't happen but if it would, it'd cause inf loop LOGD("cPiston::FirstPassthroughBlock - piston has invalid meta data!\n"); return 9001; } BLOCKTYPE currBlock; - for (ret = 0; ret < 24; ret++) // push up to 24 blocks + NIBBLETYPE currMeta; + for (ret = 0; ret < 24; ret++) //Push up to 24 blocks { - AddDir( pistonX, pistonY, pistonZ, pistonmeta, 1) - currBlock = m_World->GetBlock( pistonX, pistonY, pistonZ ); - if ((currBlock == E_BLOCK_BEDROCK) || (currBlock == E_BLOCK_OBSIDIAN) || (currBlock == E_BLOCK_PISTON_EXTENSION)) + AddDir( pistonX, pistonY, pistonZ, pistonmeta, 1) //Set the coords one further from the piston direction + m_World->GetBlockTypeMeta(pistonX, pistonY, pistonZ, currBlock, currMeta); + if ((currBlock == E_BLOCK_BEDROCK) || (currBlock == E_BLOCK_OBSIDIAN) || (currBlock == E_BLOCK_PISTON_EXTENSION) || ( (currMeta & 0x8) != 0x0 )) { return 9001; } - if (g_BlockPistonBreakable[currBlock]) + if (g_BlockPistonBreakable[currBlock]) //If it's a breakable block (air, torch, etc.) then the line of blocks can be pushed { return ret; } } - return 9001; + return 9001; //There is no space for the blocks to move within 24 spaces, piston can't push } @@ -82,6 +83,7 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz ) BLOCKTYPE pistonBlock; NIBBLETYPE pistonMeta; m_World->GetBlockTypeMeta(pistx, pisty, pistz, pistonBlock, pistonMeta); + char isSticky = (char)(pistonBlock == E_BLOCK_STICKY_PISTON) * 8; if ( (pistonMeta & 0x8) != 0x0 ) { @@ -90,9 +92,9 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz ) } unsigned short dist = FirstPassthroughBlock(pistx, pisty, pistz, pistonMeta); - if (dist > 9000) return; // too many blocks + if (dist > 9000) return; // FirstPassthroughBlock says piston can't push anything, bail out - AddDir(pistx, pisty, pistz, pistonMeta & 7, dist + 1) + AddDir(pistx, pisty, pistz, pistonMeta & 7, dist + 1) //Get the coords of the air / breakable block in the line, dist+1 because of coords BLOCKTYPE currBlock; NIBBLETYPE currMeta; m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currMeta); @@ -101,37 +103,33 @@ void cPiston::ExtendPiston( int pistx, int pisty, int pistz ) cBlockHandler * Handler = BlockHandler(currBlock); if (Handler->DoesDropOnUnsuitable()) { - Handler->DropBlock(m_World, NULL, pistx, pisty, pistz); + Handler->DropBlock(m_World, NULL, pistx, pisty, pistz); //If block is breakable, drop it } } - int oldx = pistx, oldy = pisty, oldz = pistz; + int oldx = pistx, oldy = pisty, oldz = pistz; //Make a second set of coord vars along with the originals NIBBLETYPE currBlockMeta; - for (int i = dist + 1; i > 0; i--) + if (dist != 0) //Check for single block being pushed - for loop doesn't catch it in time and breaks stuffz { - AddDir(pistx, pisty, pistz, pistonMeta & 7, -1) - m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta); - m_World->SetBlock( oldx, oldy, oldz, currBlock, currBlockMeta); - oldx = pistx; - oldy = pisty; - oldz = pistz; + for (int i = dist + 1; i > 1; i--) //Decrement from the dropped breakable block to two further than the piston (one further will be future extension) + { + AddDir(pistx, pisty, pistz, pistonMeta & 7, -1) //Move one set of coords one back from breakable dropped block + m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta); //Get the block + m_World->SetBlock( oldx, oldy, oldz, currBlock, currBlockMeta); //Set the block at the location of the original coords + oldx = pistx; //Shift the selectors down a block and repeat + oldy = pisty; + oldz = pistz; + } } - m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, E_BLOCK_PISTON); - m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); - m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8 ); int extx = pistx; int exty = pisty; int extz = pistz; - AddDir(extx, exty, extz, pistonMeta & 7, 1) - - // TODO: This code needs replacing - // Sleeping here will play the piston animation on the client; however, it will block the entire server - // for the 100 ms, effectively dropping 2 game ticks per piston. This is very bad - // This needs to be handled using delayed scheduled tasks instead - cSleep::MilliSleep(100); - - m_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, isSticky + pistonMeta & 7); + AddDir(pistx, pisty, pistz, pistonMeta & 7, -1) //Move back one block to the piston base + m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, E_BLOCK_PISTON); //Set the base + m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); + m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8 ); + m_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, isSticky + pistonMeta); //Set the arm } @@ -150,9 +148,9 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz ) } m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), E_BLOCK_PISTON); m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); - m_World->FastSetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8)); + m_World->FastSetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8)); //Set the base - AddDir(pistx, pisty, pistz, pistonMeta & 7, 1) + AddDir(pistx, pisty, pistz, pistonMeta & 7, 1) //Move forwards to the extension coord if (m_World->GetBlock(pistx, pisty, pistz) != E_BLOCK_PISTON_EXTENSION) { LOGD("%s: Piston without an extension?", __FUNCTION__); @@ -162,36 +160,27 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz ) if (pistonBlock == E_BLOCK_STICKY_PISTON) { int tempx = pistx, tempy = pisty, tempz = pistz; - AddDir( tempx, tempy, tempz, pistonMeta & 7, 1 ) + AddDir( tempx, tempy, tempz, pistonMeta & 7, 1 ) //Move forward to the block being pulled BLOCKTYPE tempblock; NIBBLETYPE tempmeta; - m_World->GetBlockTypeMeta(tempx, tempy, tempz, tempblock, tempmeta); + m_World->GetBlockTypeMeta(tempx, tempy, tempz, tempblock, tempmeta); //Check for pullable-ness if ( (tempblock == E_BLOCK_OBSIDIAN) || (tempblock == E_BLOCK_BEDROCK) || - (tempblock == E_BLOCK_PISTON_EXTENSION) + (tempblock == E_BLOCK_PISTON_EXTENSION) || + (g_BlockPistonBreakable[tempblock]) || + ((tempmeta & 0x8) != 0x0 ) ) { // These cannot be moved by the sticky piston, bail out return; } - - // TODO: This code needs replacing - // Sleeping here will play the piston animation on the client; however, it will block the entire server - // for the 100 ms, effectively dropping 2 game ticks per piston. This is very bad - // This needs to be handled using delayed scheduled tasks instead - cSleep::MilliSleep(100); m_World->SetBlock(pistx, pisty, pistz, tempblock, tempmeta); m_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0); } else { - // TODO: This code needs replacing - // Sleeping here will play the piston animation on the client; however, it will block the entire server - // for the 100 ms, effectively dropping 2 game ticks per piston. This is very bad - // This needs to be handled using delayed scheduled tasks instead - cSleep::MilliSleep(100); m_World->SetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0); } diff --git a/source/WorldStorage/NBTChunkSerializer.cpp b/source/WorldStorage/NBTChunkSerializer.cpp index da1b9e1c4..fe8630318 100644 --- a/source/WorldStorage/NBTChunkSerializer.cpp +++ b/source/WorldStorage/NBTChunkSerializer.cpp @@ -274,6 +274,8 @@ void cNBTChunkSerializer::AddMinecartEntity(cMinecart * a_Minecart) case cMinecart::mpNone: EntityClass = "MinecartRideable"; break; case cMinecart::mpChest: EntityClass = "MinecartChest"; break; case cMinecart::mpFurnace: EntityClass = "MinecartFurnace"; break; + case cMinecart::mpTNT: EntityClass = "MinecartTNT"; break; + case cMinecart::mpHopper: EntityClass = "MinecartHopper"; break; default: { ASSERT(!"Unhandled minecart payload type"); diff --git a/source/WorldStorage/NBTChunkSerializer.h b/source/WorldStorage/NBTChunkSerializer.h index 1ccd356b0..cd1388f89 100644 --- a/source/WorldStorage/NBTChunkSerializer.h +++ b/source/WorldStorage/NBTChunkSerializer.h @@ -31,6 +31,8 @@ class cFallingBlock; class cMinecart; class cMinecartWithChest; class cMinecartWithFurnace; +class cMinecartWithTNT; +class cMinecartWithHopper; class cMonster; class cPickup; class cItemGrid; diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp index 8f23cc773..3648d4462 100644 --- a/source/WorldStorage/WSSAnvil.cpp +++ b/source/WorldStorage/WSSAnvil.cpp @@ -928,6 +928,8 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a case 0: LoadMinecartRFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Rideable minecart case 1: LoadMinecartCFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Minecart with chest case 2: LoadMinecartFFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Minecart with furnace + case 3: LoadMinecartTFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Minecart with TNT + case 4: LoadMinecartHFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Minecart with Hopper } } else if (strncmp(a_IDTag, "MinecartRideable", a_IDTagLength) == 0) diff --git a/source/WorldStorage/WSSAnvil.h b/source/WorldStorage/WSSAnvil.h index bd2108b30..47fda3f7b 100644 --- a/source/WorldStorage/WSSAnvil.h +++ b/source/WorldStorage/WSSAnvil.h @@ -142,6 +142,8 @@ protected: void LoadMinecartRFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMinecartCFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMinecartFFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadMinecartTFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadMinecartHFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadPickupFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); /// Loads entity common data from the NBT compound; returns true if successful -- cgit v1.2.3 From e64c40115ecb5ed843c7aa036f3b03e3c58ca033 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 16 Aug 2013 13:04:06 +0100 Subject: Compilation and Minecart fixes --- source/Items/ItemMinecart.h | 8 +++++--- source/Minecart.cpp | 12 ++++++------ source/WorldStorage/WSSAnvil.cpp | 42 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/source/Items/ItemMinecart.h b/source/Items/ItemMinecart.h index 8be3baada..df970638e 100644 --- a/source/Items/ItemMinecart.h +++ b/source/Items/ItemMinecart.h @@ -61,9 +61,11 @@ public: cMinecart * Minecart = NULL; switch (m_ItemType) { - case E_ITEM_MINECART: Minecart = new cEmptyMinecart (x, y, z); break; - case E_ITEM_CHEST_MINECART: Minecart = new cMinecartWithChest (x, y, z); break; - case E_ITEM_FURNACE_MINECART: Minecart = new cMinecartWithFurnace(x, y, z); break; + case E_ITEM_MINECART: Minecart = new cEmptyMinecart (x, y, z); break; + case E_ITEM_CHEST_MINECART: Minecart = new cMinecartWithChest (x, y, z); break; + case E_ITEM_FURNACE_MINECART: Minecart = new cMinecartWithFurnace (x, y, z); break; + case E_ITEM_MINECART_WITH_TNT: Minecart = new cMinecartWithTNT (x, y, z); break; + case E_ITEM_MINECART_WITH_HOPPER: Minecart = new cMinecartWithHopper (x, y, z); break; default: { ASSERT(!"Unhandled minecart item"); diff --git a/source/Minecart.cpp b/source/Minecart.cpp index 19ea861a1..07a38692c 100644 --- a/source/Minecart.cpp +++ b/source/Minecart.cpp @@ -39,13 +39,13 @@ bool cMinecart::Initialize(cWorld * a_World) void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) { char Type = 0; - switch (m_Payload) + switch (m_Payload) //Wiki.vg is outdated on this!! { - case mpNone: Type = 10; break; - case mpChest: Type = 11; break; - case mpFurnace: Type = 12; break; - case mpTNT: Type = 13; break; - case mpHopper: Type = 14; break; + case mpNone: Type = 15; break; //? + case mpChest: Type = 10; break; + case mpFurnace: Type = 11; break; //? + case mpTNT: Type = 12; break; //? + case mpHopper: Type = 14; break; //? default: { ASSERT(!"Unknown payload, cannot spawn on client"); diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp index 3648d4462..efa0e9d3e 100644 --- a/source/WorldStorage/WSSAnvil.cpp +++ b/source/WorldStorage/WSSAnvil.cpp @@ -944,6 +944,14 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a { LoadMinecartFFromNBT(a_Entities, a_NBT, a_EntityTagIdx); } + else if (strncmp(a_IDTag, "MinecartTNT", a_IDTagLength) == 0) + { + LoadMinecartTFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + } + else if (strncmp(a_IDTag, "MinecartHopper", a_IDTagLength) == 0) + { + LoadMinecartHFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + } if (strncmp(a_IDTag, "Item", a_IDTagLength) == 0) { LoadPickupFromNBT(a_Entities, a_NBT, a_EntityTagIdx); @@ -1027,6 +1035,40 @@ void cWSSAnvil::LoadMinecartFFromNBT(cEntityList & a_Entities, const cParsedNBT +void cWSSAnvil::LoadMinecartTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) +{ + std::auto_ptr Minecart(new cMinecartWithTNT(0, 0, 0)); + if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx)) + { + return; + } + + //TODO: Everything to do with TNT carts + + a_Entities.push_back(Minecart.release()); +} + + + + + +void cWSSAnvil::LoadMinecartHFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) +{ + std::auto_ptr Minecart(new cMinecartWithHopper(0, 0, 0)); + if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx)) + { + return; + } + + //TODO: Everything to do with hopper carts + + a_Entities.push_back(Minecart.release()); +} + + + + + void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { int ItemTag = a_NBT.FindChildByName(a_TagIdx, "Item"); -- cgit v1.2.3 From 6981e55b6c5057149ba9becaf26cd20d0ccbe475 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 16 Aug 2013 13:12:44 +0100 Subject: Possible entity ID fix? --- source/Minecart.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Minecart.cpp b/source/Minecart.cpp index 07a38692c..8b9c201ad 100644 --- a/source/Minecart.cpp +++ b/source/Minecart.cpp @@ -41,11 +41,11 @@ void cMinecart::SpawnOn(cClientHandle & a_ClientHandle) char Type = 0; switch (m_Payload) //Wiki.vg is outdated on this!! { - case mpNone: Type = 15; break; //? + case mpNone: Type = 9; break; //? case mpChest: Type = 10; break; case mpFurnace: Type = 11; break; //? case mpTNT: Type = 12; break; //? - case mpHopper: Type = 14; break; //? + case mpHopper: Type = 13; break; //? default: { ASSERT(!"Unknown payload, cannot spawn on client"); -- cgit v1.2.3 From a4d927c9e1aa741c5e9125980b410ee5881c0f53 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 16 Aug 2013 13:20:33 +0100 Subject: Another compile fix --- source/Minecart.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/Minecart.h b/source/Minecart.h index e120af763..d78739fc5 100644 --- a/source/Minecart.h +++ b/source/Minecart.h @@ -142,7 +142,4 @@ public: CLASS_PROTODEF(cMinecartWithHopper); cMinecartWithHopper(double a_X, double a_Y, double a_Z); - - // cEntity overrides: - virtual void OnRightClicked(cPlayer & a_Player) override; } ; \ No newline at end of file -- cgit v1.2.3