summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------MCServer/Plugins/Core0
m---------MCServer/Plugins/MagicCarpet0
m---------MCServer/Plugins/TransAPI0
-rw-r--r--MCServer/crafting.txt38
-rw-r--r--Tools/QtBiomeVisualiser/MainWindow.cpp8
m---------lib/jsoncpp0
-rw-r--r--src/BlockEntities/DropSpenserEntity.cpp4
-rw-r--r--src/BlockID.h26
-rw-r--r--src/BlockInfo.cpp26
-rw-r--r--src/Blocks/BlockAnvil.h10
-rw-r--r--src/Blocks/BlockBed.h7
-rw-r--r--src/Blocks/BlockBigFlower.h11
-rw-r--r--src/Blocks/BlockBrewingStand.h6
-rw-r--r--src/Blocks/BlockButton.h13
-rw-r--r--src/Blocks/BlockCactus.h9
-rw-r--r--src/Blocks/BlockCake.h6
-rw-r--r--src/Blocks/BlockCarpet.h31
-rw-r--r--src/Blocks/BlockCauldron.h6
-rw-r--r--src/Blocks/BlockChest.h14
-rw-r--r--src/Blocks/BlockCloth.h28
-rw-r--r--src/Blocks/BlockCobWeb.h7
-rw-r--r--src/Blocks/BlockCocoaPod.h10
-rw-r--r--src/Blocks/BlockCommandBlock.h6
-rw-r--r--src/Blocks/BlockComparator.h15
-rw-r--r--src/Blocks/BlockCrops.h11
-rw-r--r--src/Blocks/BlockDeadBush.h7
-rw-r--r--src/Blocks/BlockDirt.h21
-rw-r--r--src/Blocks/BlockDoor.cpp2
-rw-r--r--src/Blocks/BlockDoor.h40
-rw-r--r--src/Blocks/BlockDropSpenser.h7
-rw-r--r--src/Blocks/BlockEnchantmentTable.h8
-rw-r--r--src/Blocks/BlockFenceGate.h27
-rw-r--r--src/Blocks/BlockFire.h12
-rw-r--r--src/Blocks/BlockFlower.h8
-rw-r--r--src/Blocks/BlockFlowerPot.h6
-rw-r--r--src/Blocks/BlockFluid.h26
-rw-r--r--src/Blocks/BlockFurnace.h8
-rw-r--r--src/Blocks/BlockGlass.h6
-rw-r--r--src/Blocks/BlockGlowstone.h10
-rw-r--r--src/Blocks/BlockGravel.h6
-rw-r--r--src/Blocks/BlockHandler.cpp20
-rw-r--r--src/Blocks/BlockHandler.h3
-rw-r--r--src/Blocks/BlockHopper.h8
-rw-r--r--src/Blocks/BlockIce.h8
-rw-r--r--src/Blocks/BlockLadder.h13
-rw-r--r--src/Blocks/BlockLeaves.h9
-rw-r--r--src/Blocks/BlockLever.h14
-rw-r--r--src/Blocks/BlockLilypad.h6
-rw-r--r--src/Blocks/BlockMelon.h7
-rw-r--r--src/Blocks/BlockMobHead.h8
-rw-r--r--src/Blocks/BlockMushroom.h9
-rw-r--r--src/Blocks/BlockMycelium.h6
-rw-r--r--src/Blocks/BlockNetherWart.h9
-rw-r--r--src/Blocks/BlockPiston.h6
-rw-r--r--src/Blocks/BlockPlanks.h19
-rw-r--r--src/Blocks/BlockPortal.h49
-rw-r--r--src/Blocks/BlockPressurePlate.h17
-rw-r--r--src/Blocks/BlockPumpkin.h6
-rw-r--r--src/Blocks/BlockQuartz.h8
-rw-r--r--src/Blocks/BlockRail.h20
-rw-r--r--src/Blocks/BlockRedstone.h9
-rw-r--r--src/Blocks/BlockRedstoneLamp.h6
-rw-r--r--src/Blocks/BlockRedstoneRepeater.h14
-rw-r--r--src/Blocks/BlockRedstoneTorch.h7
-rw-r--r--src/Blocks/BlockSand.h6
-rw-r--r--src/Blocks/BlockSapling.h155
-rw-r--r--src/Blocks/BlockSignPost.h17
-rw-r--r--src/Blocks/BlockSlab.h84
-rw-r--r--src/Blocks/BlockSnow.h11
-rw-r--r--src/Blocks/BlockStairs.h29
-rw-r--r--src/Blocks/BlockStems.h9
-rw-r--r--src/Blocks/BlockStone.h6
-rw-r--r--src/Blocks/BlockSugarcane.h9
-rw-r--r--src/Blocks/BlockTNT.h6
-rw-r--r--src/Blocks/BlockTallGrass.h10
-rw-r--r--src/Blocks/BlockTorch.h29
-rw-r--r--src/Blocks/BlockTrapdoor.h18
-rw-r--r--src/Blocks/BlockTripwire.h6
-rw-r--r--src/Blocks/BlockTripwireHook.h10
-rw-r--r--src/Blocks/BlockVine.h24
-rw-r--r--src/Blocks/BlockWallSign.h10
-rw-r--r--src/Blocks/BlockWorkbench.h8
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/ClientHandle.cpp22
-rw-r--r--src/ClientHandle.h4
-rw-r--r--src/Color.cpp76
-rw-r--r--src/Color.h58
-rw-r--r--src/CraftingRecipes.cpp196
-rw-r--r--src/CraftingRecipes.h3
-rw-r--r--src/Entities/Player.cpp26
-rw-r--r--src/FurnaceRecipe.cpp6
-rw-r--r--src/Generating/BioGen.cpp4
-rw-r--r--src/Generating/FinishGen.cpp8
-rw-r--r--src/Generating/Trees.cpp94
-rw-r--r--src/Generating/Trees.h6
-rw-r--r--src/Globals.h2
-rw-r--r--src/Inventory.cpp16
-rw-r--r--src/Item.cpp19
-rw-r--r--src/Item.h11
-rw-r--r--src/Items/ItemDoor.h2
-rw-r--r--src/Items/ItemEmptyMap.h4
-rw-r--r--src/Items/ItemHandler.cpp5
-rw-r--r--src/Items/ItemHandler.h2
-rw-r--r--src/Items/ItemMap.h1
-rw-r--r--src/Items/ItemPickaxe.h4
-rw-r--r--src/Items/ItemRedstoneDust.h2
-rw-r--r--src/Map.cpp451
-rw-r--r--src/Map.h97
-rw-r--r--src/MapManager.cpp22
-rw-r--r--src/MapManager.h7
-rw-r--r--src/Mobs/Monster.cpp1
-rw-r--r--src/Mobs/Monster.h8
-rw-r--r--src/Mobs/Path.cpp2
-rw-r--r--src/Protocol/Protocol.h4
-rw-r--r--src/Protocol/Protocol17x.cpp93
-rw-r--r--src/Protocol/Protocol17x.h4
-rw-r--r--src/Protocol/Protocol18x.cpp136
-rw-r--r--src/Protocol/Protocol18x.h4
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp24
-rw-r--r--src/Protocol/ProtocolRecognizer.h4
-rw-r--r--src/Simulator/FireSimulator.cpp4
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp6
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.h10
-rw-r--r--src/World.cpp21
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp33
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp207
-rw-r--r--tests/LoadablePieces/Stubs.cpp9
127 files changed, 1870 insertions, 1063 deletions
diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core
-Subproject 5171b43807ff699a6b239ad4969520730b3748a
+Subproject cbf3280a6a3cbf9468742dbbdaca9ff6f0a7743
diff --git a/MCServer/Plugins/MagicCarpet b/MCServer/Plugins/MagicCarpet
-Subproject 493f2dfa6d39f134e37c4c614cf8d6ffd10c825
+Subproject 94da343b62f0498a5843247f36d6ee00cbeb8f2
diff --git a/MCServer/Plugins/TransAPI b/MCServer/Plugins/TransAPI
-Subproject 6527b80a77b3b7f5fac0ef214c1b59ad83e39b2
+Subproject be15597bf3d976310a59e3aa8661cce413441c1
diff --git a/MCServer/crafting.txt b/MCServer/crafting.txt
index b08a82f2f..8adc00fa2 100644
--- a/MCServer/crafting.txt
+++ b/MCServer/crafting.txt
@@ -552,6 +552,44 @@ GlisteringMelon = MelonSlice, 2:2 | GoldNugget, 1:1, 1:2, 1:3, 2:1, 2:3, 3:1
GoldNugget, 9 = GoldIngot, *
EnchantmentTable = Obsidian, 1:3, 2:3, 3:3, 2:2 | Diamond, 1:2, 3:2 | Book, 2:1
+#******************************************************#
+# Dyed Armor
+# Do not modify
+LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, *
+LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, *
+LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherHelmet = LeatherHelmet^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+
+LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, *
+LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, *
+LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherChestplate = LeatherChestplate^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+
+LeatherPants = LeatherPants^-1, * | Dye^-1, *
+LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, *
+LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherPants = LeatherPants^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+
+LeatherBoots = LeatherBoots^-1, * | Dye^-1, *
+LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, *
+LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
+LeatherBoots = LeatherBoots^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, * | Dye^-1, *
#******************************************************#
# Fireworks & Co.
diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp
index c6ea8656e..8d5b768d8 100644
--- a/Tools/QtBiomeVisualiser/MainWindow.cpp
+++ b/Tools/QtBiomeVisualiser/MainWindow.cpp
@@ -87,7 +87,7 @@ void MainWindow::newGenerator()
// Set the chunk source:
cIniFilePtr iniFile = m_GeneratorSetup->getIniFile();
- m_BiomeView->setChunkSource(std::shared_ptr<BioGenSource>(new BioGenSource(iniFile)));
+ m_BiomeView->setChunkSource(std::make_shared<BioGenSource>(iniFile));
m_BiomeView->redraw();
}
@@ -108,7 +108,7 @@ void MainWindow::openGenerator()
openGeneratorSetup(worldIni.toStdString());
// Set the chunk source:
- m_BiomeView->setChunkSource(std::shared_ptr<BioGenSource>(new BioGenSource(m_GeneratorSetup->getIniFile())));
+ m_BiomeView->setChunkSource(std::make_shared<BioGenSource>(m_GeneratorSetup->getIniFile()));
m_BiomeView->redraw();
}
@@ -129,7 +129,7 @@ void MainWindow::openWorld()
closeGeneratorSetup();
// Set the chunk source:
- m_BiomeView->setChunkSource(std::shared_ptr<AnvilSource>(new AnvilSource(regionFolder)));
+ m_BiomeView->setChunkSource(std::make_shared<AnvilSource>(regionFolder));
m_BiomeView->redraw();
}
@@ -150,7 +150,7 @@ void MainWindow::openVanillaWorld()
closeGeneratorSetup();
// Set the chunk source:
- m_BiomeView->setChunkSource(std::shared_ptr<AnvilSource>(new AnvilSource(action->data().toString())));
+ m_BiomeView->setChunkSource(std::make_shared<AnvilSource>(action->data().toString()));
m_BiomeView->redraw();
}
diff --git a/lib/jsoncpp b/lib/jsoncpp
-Subproject 5256551b0307d3e85f453faf1b1822b1d859f94
+Subproject 81cf237917b6873decd27e15b7fe8473003a276
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp
index 039f5d360..3a93e85a1 100644
--- a/src/BlockEntities/DropSpenserEntity.cpp
+++ b/src/BlockEntities/DropSpenserEntity.cpp
@@ -75,7 +75,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
if (SlotsCnt == 0)
{
// Nothing in the dropspenser, play the click sound
- m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.2f);
+ m_World->BroadcastSoundEffect("random.click", static_cast<double>(m_PosX), static_cast<double>(m_PosY), static_cast<double>(m_PosZ), 1.0f, 1.2f);
return;
}
@@ -97,7 +97,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
case E_META_DROPSPENSER_FACING_ZP: SmokeDir = 7; break;
}
m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir);
- m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
+ m_World->BroadcastSoundEffect("random.click", static_cast<double>(m_PosX), static_cast<double>(m_PosY), static_cast<double>(m_PosZ), 1.0f, 1.0f);
}
diff --git a/src/BlockID.h b/src/BlockID.h
index 41ccf90b5..5de57a33c 100644
--- a/src/BlockID.h
+++ b/src/BlockID.h
@@ -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,
diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp
index c0ae5e945..70ca38362 100644
--- a/src/BlockInfo.cpp
+++ b/src/BlockInfo.cpp
@@ -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";
diff --git a/src/Blocks/BlockAnvil.h b/src/Blocks/BlockAnvil.h
index 154394550..a2a7c0cf4 100644
--- a/src/Blocks/BlockAnvil.h
+++ b/src/Blocks/BlockAnvil.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockBed.h b/src/Blocks/BlockBed.h
index 905c0ea76..43ed9beb3 100644
--- a/src/Blocks/BlockBed.h
+++ b/src/Blocks/BlockBed.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockBigFlower.h b/src/Blocks/BlockBigFlower.h
index 6c5cc6b68..b1aec7385 100644
--- a/src/Blocks/BlockBigFlower.h
+++ b/src/Blocks/BlockBigFlower.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockBrewingStand.h b/src/Blocks/BlockBrewingStand.h
index 57642bcb6..f68f9d8af 100644
--- a/src/Blocks/BlockBrewingStand.h
+++ b/src/Blocks/BlockBrewingStand.h
@@ -25,6 +25,12 @@ public:
{
return true;
}
+
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ {
+ UNUSED(a_Meta);
+ return 6;
+ }
} ;
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index 3558729bb..c24945ea8 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -15,7 +15,6 @@ public:
: cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>(a_BlockType)
{
}
-
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
{
@@ -49,7 +48,6 @@ public:
});
}
-
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
@@ -57,13 +55,11 @@ public:
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;
+ }
} ;
diff --git a/src/Blocks/BlockCactus.h b/src/Blocks/BlockCactus.h
index 910966c43..cb6cecc7b 100644
--- a/src/Blocks/BlockCactus.h
+++ b/src/Blocks/BlockCactus.h
@@ -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)
@@ -63,12 +61,17 @@ 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;
+ }
} ;
diff --git a/src/Blocks/BlockCake.h b/src/Blocks/BlockCake.h
index 3a754ce18..eeba666dc 100644
--- a/src/Blocks/BlockCake.h
+++ b/src/Blocks/BlockCake.h
@@ -43,6 +43,12 @@ public:
{
return true;
}
+
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ {
+ UNUSED(a_Meta);
+ return 14;
+ }
} ;
diff --git a/src/Blocks/BlockCarpet.h b/src/Blocks/BlockCarpet.h
index 4b287c664..19be882d0 100644
--- a/src/Blocks/BlockCarpet.h
+++ b/src/Blocks/BlockCarpet.h
@@ -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,
@@ -35,18 +34,44 @@ public:
a_BlockMeta = a_Player->GetEquippedItem().m_ItemDamage & 0x0f;
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;
+ }
+ }
+ }
} ;
diff --git a/src/Blocks/BlockCauldron.h b/src/Blocks/BlockCauldron.h
index e0f86f4cb..fa1dc3d7b 100644
--- a/src/Blocks/BlockCauldron.h
+++ b/src/Blocks/BlockCauldron.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockChest.h b/src/Blocks/BlockChest.h
index 01fec7f8b..df87ca4c7 100644
--- a/src/Blocks/BlockChest.h
+++ b/src/Blocks/BlockChest.h
@@ -18,7 +18,6 @@ public:
: cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{
}
-
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
@@ -65,7 +64,6 @@ public:
a_BlockMeta = PlayerYawToMetaData(yaw);
return true;
}
-
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
@@ -73,7 +71,6 @@ public:
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
return CanBeAt(a_ChunkInterface, BlockX, a_RelY, BlockZ);
}
-
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
{
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockCloth.h b/src/Blocks/BlockCloth.h
index 525176725..a46cfafb2 100644
--- a/src/Blocks/BlockCloth.h
+++ b/src/Blocks/BlockCloth.h
@@ -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;
+ }
+ }
+ }
} ;
diff --git a/src/Blocks/BlockCobWeb.h b/src/Blocks/BlockCobWeb.h
index 982bfaa30..e7dd70af4 100644
--- a/src/Blocks/BlockCobWeb.h
+++ b/src/Blocks/BlockCobWeb.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockCocoaPod.h b/src/Blocks/BlockCocoaPod.h
index 4d16d2552..d061fbdd5 100644
--- a/src/Blocks/BlockCocoaPod.h
+++ b/src/Blocks/BlockCocoaPod.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockCommandBlock.h b/src/Blocks/BlockCommandBlock.h
index b66def201..d1b81185f 100644
--- a/src/Blocks/BlockCommandBlock.h
+++ b/src/Blocks/BlockCommandBlock.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h
index 3babeddad..3a69f2186 100644
--- a/src/Blocks/BlockComparator.h
+++ b/src/Blocks/BlockComparator.h
@@ -17,7 +17,6 @@ public:
: cMetaRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true>(a_BlockType)
{
}
-
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
{
@@ -26,32 +25,27 @@ 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,
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockCrops.h b/src/Blocks/BlockCrops.h
index 53e996683..e510d5f8d 100644
--- a/src/Blocks/BlockCrops.h
+++ b/src/Blocks/BlockCrops.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockDeadBush.h b/src/Blocks/BlockDeadBush.h
index 09df16893..b86e3557e 100644
--- a/src/Blocks/BlockDeadBush.h
+++ b/src/Blocks/BlockDeadBush.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h
index 3d671d218..d93bdd22d 100644
--- a/src/Blocks/BlockDirt.h
+++ b/src/Blocks/BlockDirt.h
@@ -9,7 +9,9 @@
-/// Handler used for both dirt and grass
+
+
+/** Handler used for all types of dirt and grass */
class cBlockDirtHandler :
public cBlockHandler
{
@@ -18,7 +20,6 @@ public:
: cBlockHandler(a_BlockType)
{
}
-
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
@@ -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;
+ }
+ }
+ }
} ;
diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp
index a4e375cf0..3997441ab 100644
--- a/src/Blocks/BlockDoor.cpp
+++ b/src/Blocks/BlockDoor.cpp
@@ -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());
diff --git a/src/Blocks/BlockDoor.h b/src/Blocks/BlockDoor.h
index 4773e6f0a..ca2719a8b 100644
--- a/src/Blocks/BlockDoor.h
+++ b/src/Blocks/BlockDoor.h
@@ -52,12 +52,15 @@ public:
return true;
}
-
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
+ if ((a_BlockMeta & 0x08) != 0) // is top part of door
+ {
+ return;
+ }
switch (m_BlockType)
{
- case E_BLOCK_WOODEN_DOOR:
+ case E_BLOCK_OAK_DOOR:
{
a_Pickups.Add(E_ITEM_WOODEN_DOOR);
break;
@@ -100,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)
{
@@ -136,7 +136,6 @@ public:
}
}
-
static bool CanReplaceBlock(BLOCKTYPE a_BlockType)
{
switch (a_BlockType)
@@ -156,7 +155,6 @@ public:
return false;
}
-
/** Converts the player's yaw to placed door's blockmeta */
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
{
@@ -185,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)
{
@@ -198,7 +195,6 @@ public:
}
}
-
/** Returns true if the specified blocktype is any kind of door */
inline static bool IsDoorBlockType(BLOCKTYPE a_Block)
{
@@ -210,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;
}
@@ -221,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)
@@ -230,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.
@@ -263,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)
{
@@ -297,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;
+ }
+ }
+ }
} ;
diff --git a/src/Blocks/BlockDropSpenser.h b/src/Blocks/BlockDropSpenser.h
index ba96c716a..c572d5d34 100644
--- a/src/Blocks/BlockDropSpenser.h
+++ b/src/Blocks/BlockDropSpenser.h
@@ -20,7 +20,6 @@ public:
cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
{
}
-
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockEnchantmentTable.h b/src/Blocks/BlockEnchantmentTable.h
index 40001f356..85951984f 100644
--- a/src/Blocks/BlockEnchantmentTable.h
+++ b/src/Blocks/BlockEnchantmentTable.h
@@ -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;
+ }
};
diff --git a/src/Blocks/BlockFenceGate.h b/src/Blocks/BlockFenceGate.h
index b5c1323bd..81e93fa50 100644
--- a/src/Blocks/BlockFenceGate.h
+++ b/src/Blocks/BlockFenceGate.h
@@ -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;
+ }
+ }
+ }
} ;
diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h
index 3f75455da..d1c8c17c9 100644
--- a/src/Blocks/BlockFire.h
+++ b/src/Blocks/BlockFire.h
@@ -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;
+ }
};
diff --git a/src/Blocks/BlockFlower.h b/src/Blocks/BlockFlower.h
index 3eb8a0baa..45f39f2be 100644
--- a/src/Blocks/BlockFlower.h
+++ b/src/Blocks/BlockFlower.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockFlowerPot.h b/src/Blocks/BlockFlowerPot.h
index fc75ef638..cafe476d9 100644
--- a/src/Blocks/BlockFlowerPot.h
+++ b/src/Blocks/BlockFlowerPot.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockFluid.h b/src/Blocks/BlockFluid.h
index 58b3ce042..56a2ad3c2 100644
--- a/src/Blocks/BlockFluid.h
+++ b/src/Blocks/BlockFluid.h
@@ -18,20 +18,17 @@ 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;
+ }
} ;
diff --git a/src/Blocks/BlockFurnace.h b/src/Blocks/BlockFurnace.h
index 2c7310ac9..a543a26f4 100644
--- a/src/Blocks/BlockFurnace.h
+++ b/src/Blocks/BlockFurnace.h
@@ -18,12 +18,10 @@ 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,
@@ -39,6 +37,12 @@ public:
return true;
}
+
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ {
+ UNUSED(a_Meta);
+ return 11;
+ }
} ;
diff --git a/src/Blocks/BlockGlass.h b/src/Blocks/BlockGlass.h
index f6958bbb6..5b797be31 100644
--- a/src/Blocks/BlockGlass.h
+++ b/src/Blocks/BlockGlass.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockGlowstone.h b/src/Blocks/BlockGlowstone.h
index d1353e29a..2781a7206 100644
--- a/src/Blocks/BlockGlowstone.h
+++ b/src/Blocks/BlockGlowstone.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockGravel.h b/src/Blocks/BlockGravel.h
index d076306fb..eb101efe9 100644
--- a/src/Blocks/BlockGravel.h
+++ b/src/Blocks/BlockGravel.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp
index 412fc3aeb..ae5274d02 100644
--- a/src/Blocks/BlockHandler.cpp
+++ b/src/Blocks/BlockHandler.cpp
@@ -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;
+}
+
+
+
+
diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h
index 1b357c3f1..4a484dfad 100644
--- a/src/Blocks/BlockHandler.h
+++ b/src/Blocks/BlockHandler.h
@@ -126,6 +126,9 @@ public:
By default drops if position no more suitable (CanBeAt(), DoesDropOnUnsuitable(), Drop()),
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>
diff --git a/src/Blocks/BlockHopper.h b/src/Blocks/BlockHopper.h
index 06e2b0e9f..22f800f28 100644
--- a/src/Blocks/BlockHopper.h
+++ b/src/Blocks/BlockHopper.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockIce.h b/src/Blocks/BlockIce.h
index 47a84e5a7..337c92022 100644
--- a/src/Blocks/BlockIce.h
+++ b/src/Blocks/BlockIce.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockLadder.h b/src/Blocks/BlockLadder.h
index d727f8f8e..5a1a099b7 100644
--- a/src/Blocks/BlockLadder.h
+++ b/src/Blocks/BlockLadder.h
@@ -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)
{
@@ -97,7 +92,6 @@ public:
}
return BLOCK_FACE_BOTTOM;
}
-
static bool LadderCanBePlacedAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
{
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index 2368eab7b..06c41369d 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index 8d676b56f..840a61e60 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockLilypad.h b/src/Blocks/BlockLilypad.h
index 53277caa5..b2fb69309 100644
--- a/src/Blocks/BlockLilypad.h
+++ b/src/Blocks/BlockLilypad.h
@@ -17,6 +17,12 @@ public:
super(a_BlockType)
{
}
+
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ {
+ UNUSED(a_Meta);
+ return 7;
+ }
};
diff --git a/src/Blocks/BlockMelon.h b/src/Blocks/BlockMelon.h
index 22cdb4d29..e97df723d 100644
--- a/src/Blocks/BlockMelon.h
+++ b/src/Blocks/BlockMelon.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockMobHead.h b/src/Blocks/BlockMobHead.h
index cb8143749..639b83a03 100644
--- a/src/Blocks/BlockMobHead.h
+++ b/src/Blocks/BlockMobHead.h
@@ -16,13 +16,11 @@ public:
cBlockEntityHandler(a_BlockType)
{
}
-
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
{
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockMushroom.h b/src/Blocks/BlockMushroom.h
index 7c06fcc74..65b68b097 100644
--- a/src/Blocks/BlockMushroom.h
+++ b/src/Blocks/BlockMushroom.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockMycelium.h b/src/Blocks/BlockMycelium.h
index 628e87181..1c365caa8 100644
--- a/src/Blocks/BlockMycelium.h
+++ b/src/Blocks/BlockMycelium.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockNetherWart.h b/src/Blocks/BlockNetherWart.h
index 812cf906f..424730796 100644
--- a/src/Blocks/BlockNetherWart.h
+++ b/src/Blocks/BlockNetherWart.h
@@ -17,7 +17,6 @@ public:
: cBlockHandler(a_BlockType)
{
}
-
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override
{
@@ -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);
@@ -43,11 +41,16 @@ public:
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_NETHER_WART, ++Meta);
}
}
-
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;
+ }
} ;
diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h
index 5933d4885..f915f0a8d 100644
--- a/src/Blocks/BlockPiston.h
+++ b/src/Blocks/BlockPiston.h
@@ -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
diff --git a/src/Blocks/BlockPlanks.h b/src/Blocks/BlockPlanks.h
index 3c243ebdc..e913db5f6 100644
--- a/src/Blocks/BlockPlanks.h
+++ b/src/Blocks/BlockPlanks.h
@@ -14,7 +14,6 @@ public:
: cBlockHandler(a_BlockType)
{
}
-
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
@@ -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;
+ }
+ }
+ }
} ;
diff --git a/src/Blocks/BlockPortal.h b/src/Blocks/BlockPortal.h
index 581a29447..c18acbdb5 100644
--- a/src/Blocks/BlockPortal.h
+++ b/src/Blocks/BlockPortal.h
@@ -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
- {
- int x, y, z;
- } PortalCheck[] =
+ static const std::array<Vector3i, 4> 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
- {
- int x, y, z;
- } PortalCheck[] =
+ static const std::array<Vector3i, 4> 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;
+ }
} ;
diff --git a/src/Blocks/BlockPressurePlate.h b/src/Blocks/BlockPressurePlate.h
index bd2f283a2..5829b5190 100644
--- a/src/Blocks/BlockPressurePlate.h
+++ b/src/Blocks/BlockPressurePlate.h
@@ -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;
+ }
+ }
+ }
} ;
diff --git a/src/Blocks/BlockPumpkin.h b/src/Blocks/BlockPumpkin.h
index af00fbe8e..133a486ac 100644
--- a/src/Blocks/BlockPumpkin.h
+++ b/src/Blocks/BlockPumpkin.h
@@ -15,7 +15,6 @@ public:
super(a_BlockType)
{
}
-
virtual bool GetPlacementBlockTypeMeta(
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
@@ -56,6 +55,11 @@ public:
}
}
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ {
+ UNUSED(a_Meta);
+ return 15;
+ }
} ;
diff --git a/src/Blocks/BlockQuartz.h b/src/Blocks/BlockQuartz.h
index b936a7e4a..878a12b25 100644
--- a/src/Blocks/BlockQuartz.h
+++ b/src/Blocks/BlockQuartz.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h
index 7fb910e8c..b603bb1a7 100644
--- a/src/Blocks/BlockRail.h
+++ b/src/Blocks/BlockRail.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockRedstone.h b/src/Blocks/BlockRedstone.h
index 2785eb479..ec661b1f0 100644
--- a/src/Blocks/BlockRedstone.h
+++ b/src/Blocks/BlockRedstone.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockRedstoneLamp.h b/src/Blocks/BlockRedstoneLamp.h
index 69a2b27c2..8545d5ca6 100644
--- a/src/Blocks/BlockRedstoneLamp.h
+++ b/src/Blocks/BlockRedstoneLamp.h
@@ -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;
+ }
};
diff --git a/src/Blocks/BlockRedstoneRepeater.h b/src/Blocks/BlockRedstoneRepeater.h
index e8262dc40..09d0df167 100644
--- a/src/Blocks/BlockRedstoneRepeater.h
+++ b/src/Blocks/BlockRedstoneRepeater.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockRedstoneTorch.h b/src/Blocks/BlockRedstoneTorch.h
index 8416a415c..21d005052 100644
--- a/src/Blocks/BlockRedstoneTorch.h
+++ b/src/Blocks/BlockRedstoneTorch.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockSand.h b/src/Blocks/BlockSand.h
index 48beab138..30d5ae59d 100644
--- a/src/Blocks/BlockSand.h
+++ b/src/Blocks/BlockSand.h
@@ -15,6 +15,12 @@ public:
: cBlockHandler(a_BlockType)
{
}
+
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ {
+ UNUSED(a_Meta);
+ return 2;
+ }
};
diff --git a/src/Blocks/BlockSapling.h b/src/Blocks/BlockSapling.h
index bec79c6f3..1770cc4aa 100644
--- a/src/Blocks/BlockSapling.h
+++ b/src/Blocks/BlockSapling.h
@@ -3,6 +3,7 @@
#include "BlockHandler.h"
#include "../World.h"
+#include "../FastRandom.h"
@@ -16,35 +17,165 @@ public:
: cBlockHandler(a_BlockType)
{
}
-
-
+
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);
-
- if ((Meta & 0x08) != 0)
+ NIBBLETYPE Light = std::max(a_Chunk.GetBlockLight(a_RelX, a_RelY, a_RelZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelX, a_RelY, a_RelZ)));
+
+ // Only grow if we have the right amount of light
+ if (Light > 8)
{
- int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
- int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
- a_Chunk.GetWorld()->GrowTree(BlockX, a_RelY, BlockZ);
+ cFastRandom random;
+ // Only grow if we are in the right growth stage and have the right amount of space around them.
+ if (((Meta & 0x08) != 0) && (random.NextInt(99) < 45) && CanGrowAt(a_Chunk, a_RelX, a_RelY, a_RelZ, Meta))
+ {
+ int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
+ int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
+ a_Chunk.GetWorld()->GrowTree(BlockX, a_RelY, BlockZ);
+ }
+ // Only move to the next growth stage if we haven't gone there yet
+ else if (((Meta & 0x08) == 0) && (random.NextInt(99) < 45))
+ {
+ a_Chunk.SetMeta(a_RelX, a_RelY, a_RelZ, Meta | 0x08);
+ }
}
- else
+ }
+
+ bool CanGrowAt(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
+ {
+ a_Meta = a_Meta & 0x07;
+ int CheckHeight = 0;
+ bool LargeTree = false;
+
+ // Get the height to check against
+ switch (a_Meta)
+ {
+ case E_META_SAPLING_APPLE:
+ {
+ CheckHeight = 5;
+ break;
+ }
+ case E_META_SAPLING_CONIFER:
+ {
+ CheckHeight = 7;
+ if (IsLargeTree(a_Chunk, a_RelX, a_RelY, a_RelZ, a_Meta))
+ {
+ CheckHeight = 16;
+ LargeTree = true;
+ }
+ break;
+ }
+ case E_META_SAPLING_BIRCH:
+ {
+ CheckHeight = 6;
+ break;
+ }
+ case E_META_SAPLING_JUNGLE:
+ {
+ CheckHeight = 7;
+ if (IsLargeTree(a_Chunk, a_RelX, a_RelY, a_RelZ, a_Meta))
+ {
+ CheckHeight = 13;
+ LargeTree = true;
+ }
+ break;
+ }
+ // Dark Oaks only grow in a 2x2 area
+ case E_META_SAPLING_DARK_OAK:
+ {
+ if (!IsLargeTree(a_Chunk, a_RelX, a_RelY, a_RelZ, a_Meta))
+ {
+ return false;
+ }
+ CheckHeight = 7;
+ LargeTree = true;
+ break;
+ }
+ }
+ // We should always get a valid CheckHeight
+ ASSERT(CheckHeight != 0);
+
+ // Don't grow a tree if we don't have enough space left above it in the chunk
+ if ((a_RelY + CheckHeight) > cChunkDef::Height)
+ {
+ return false;
+ }
+ bool CanGrow = true;
+
+ // Validate the neighbor blocks. They cannot be solid.
+ BLOCKTYPE check = E_BLOCK_AIR;
+ a_Chunk.UnboundedRelGetBlockType(a_RelX - 1, a_RelY, a_RelZ, check);
+ CanGrow = CanGrow && cBlockInfo::IsTransparent(check);
+
+ a_Chunk.UnboundedRelGetBlockType(a_RelX + 1, a_RelY, a_RelZ, check);
+ CanGrow = CanGrow && cBlockInfo::IsTransparent(check);
+
+ a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ - 1, check);
+ CanGrow = CanGrow && cBlockInfo::IsTransparent(check);
+
+ a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ + 1, check);
+ CanGrow = CanGrow && cBlockInfo::IsTransparent(check);
+
+
+
+ while (CheckHeight && CanGrow)
{
- a_Chunk.SetMeta(a_RelX, a_RelY, a_RelZ, Meta | 0x08);
+ check = a_Chunk.GetBlock(a_RelX, a_RelY + CheckHeight, a_RelZ);
+ CanGrow = CanGrow && ((check == E_BLOCK_AIR) || (check == E_BLOCK_LEAVES));
+
+ // We have to check above the neighboring saplings as well
+ if (LargeTree)
+ {
+ a_Chunk.UnboundedRelGetBlockType(a_RelX + 1, a_RelY + CheckHeight, a_RelZ, check);
+ CanGrow = CanGrow && ((check == E_BLOCK_AIR) || (check == E_BLOCK_LEAVES));
+
+ a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY + CheckHeight, a_RelZ + 1, check);
+ CanGrow = CanGrow && ((check == E_BLOCK_AIR) || (check == E_BLOCK_LEAVES));
+
+ a_Chunk.UnboundedRelGetBlockType(a_RelX + 1, a_RelY + CheckHeight, a_RelZ + 1, check);
+ CanGrow = CanGrow && ((check == E_BLOCK_AIR) || (check == E_BLOCK_LEAVES));
+ }
+
+ --CheckHeight;
}
+
+ return CanGrow;
+ }
+
+private:
+ bool IsLargeTree(cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
+ {
+ BLOCKTYPE type;
+ NIBBLETYPE meta;
+ bool LargeTree = true;
+ a_Chunk.UnboundedRelGetBlock(a_RelX + 1, a_RelY, a_RelZ, type, meta);
+ LargeTree = LargeTree && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+
+ a_Chunk.UnboundedRelGetBlock(a_RelX + 1, a_RelY, a_RelZ + 1, type, meta);
+ LargeTree = LargeTree && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+
+ a_Chunk.UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ + 1, type, meta);
+ LargeTree = LargeTree && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+
+ return LargeTree;
+ }
+
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ {
+ UNUSED(a_Meta);
+ return 7;
}
} ;
diff --git a/src/Blocks/BlockSignPost.h b/src/Blocks/BlockSignPost.h
index 99c000633..5ae285bf0 100644
--- a/src/Blocks/BlockSignPost.h
+++ b/src/Blocks/BlockSignPost.h
@@ -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,36 +49,38 @@ 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)
// There are 16 meta values which correspond to different directions.
// These values are equated to angles on a circle; 0x08 = 180 degrees.
- return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta);
+ return (a_Meta < 0x08) ? (0x08 - a_Meta) : (0x18 - a_Meta);
}
-
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
{
// Mirrors signs over the YZ plane (East-West Mirroring)
// There are 16 meta values which correspond to different directions.
// These values are equated to angles on a circle; 0x10 = 360 degrees.
- return 0x10 - a_Meta;
+ return 0x0f - a_Meta;
+ }
+
+ virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
+ {
+ UNUSED(a_Meta);
+ return 13;
}
} ;
diff --git a/src/Blocks/BlockSlab.h b/src/Blocks/BlockSlab.h
index 58e85013e..19b25595d 100644
--- a/src/Blocks/BlockSlab.h
+++ b/src/Blocks/BlockSlab.h
@@ -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,
@@ -87,15 +84,13 @@ 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);
+ }
} ;
diff --git a/src/Blocks/BlockSnow.h b/src/Blocks/BlockSnow.h
index 7b6094c9f..3fab0b8ef 100644
--- a/src/Blocks/BlockSnow.h
+++ b/src/Blocks/BlockSnow.h
@@ -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))
@@ -57,14 +55,12 @@ 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;
+ }
} ;
diff --git a/src/Blocks/BlockStairs.h b/src/Blocks/BlockStairs.h
index 7ef69d2ec..8a23fd064 100644
--- a/src/Blocks/BlockStairs.h
+++ b/src/Blocks/BlockStairs.h
@@ -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;
+ }
+ }
+ }
} ;
diff --git a/src/Blocks/BlockStems.h b/src/Blocks/BlockStems.h
index 860c7dd45..13b7a599f 100644
--- a/src/Blocks/BlockStems.h
+++ b/src/Blocks/BlockStems.h
@@ -17,13 +17,11 @@ 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
{
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockStone.h b/src/Blocks/BlockStone.h
index 69cc8301b..34eccb9aa 100644
--- a/src/Blocks/BlockStone.h
+++ b/src/Blocks/BlockStone.h
@@ -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;
+ }
};
diff --git a/src/Blocks/BlockSugarcane.h b/src/Blocks/BlockSugarcane.h
index c832ff218..632dc8baa 100644
--- a/src/Blocks/BlockSugarcane.h
+++ b/src/Blocks/BlockSugarcane.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockTNT.h b/src/Blocks/BlockTNT.h
index 3a573ae67..a49b8bbfe 100644
--- a/src/Blocks/BlockTNT.h
+++ b/src/Blocks/BlockTNT.h
@@ -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;
+ }
};
diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h
index 4134a01f8..746c67617 100644
--- a/src/Blocks/BlockTallGrass.h
+++ b/src/Blocks/BlockTallGrass.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockTorch.h b/src/Blocks/BlockTorch.h
index 36d2fec67..db66259e9 100644
--- a/src/Blocks/BlockTorch.h
+++ b/src/Blocks/BlockTorch.h
@@ -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,
@@ -47,7 +46,6 @@ public:
a_BlockMeta = DirectionToMetaData(a_BlockFace);
return true;
}
-
inline static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
{
@@ -67,7 +65,6 @@ public:
};
return 0x0;
}
-
inline static eBlockFace MetaDataToDirection(NIBBLETYPE 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,6 +115,22 @@ 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_OAK_WOOD_STAIRS:
+ case E_BLOCK_COBBLESTONE_STAIRS:
+ case E_BLOCK_BRICK_STAIRS:
+ case E_BLOCK_STONE_BRICK_STAIRS:
+ case E_BLOCK_NETHER_BRICK_STAIRS:
+ case E_BLOCK_SANDSTONE_STAIRS:
+ case E_BLOCK_SPRUCE_WOOD_STAIRS:
+ case E_BLOCK_BIRCH_WOOD_STAIRS:
+ case E_BLOCK_JUNGLE_WOOD_STAIRS:
+ case E_BLOCK_QUARTZ_STAIRS:
+ case E_BLOCK_ACACIA_WOOD_STAIRS:
+ case E_BLOCK_DARK_OAK_WOOD_STAIRS:
+ case E_BLOCK_RED_SANDSTONE_STAIRS:
+ {
+ return (a_BlockFace == BLOCK_FACE_TOP) && (a_BlockMeta & E_BLOCK_STAIRS_UPSIDE_DOWN);
+ }
default:
{
if (cBlockInfo::FullyOccupiesVoxel(a_BlockType))
@@ -131,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)
{
@@ -156,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));
@@ -172,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;
+ }
} ;
diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h
index a1d2dff6f..13783c16f 100644
--- a/src/Blocks/BlockTrapdoor.h
+++ b/src/Blocks/BlockTrapdoor.h
@@ -65,7 +65,6 @@ public:
}
return true;
}
-
inline static NIBBLETYPE BlockFaceToMetaData(eBlockFace 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;
+ }
+ }
+ }
};
diff --git a/src/Blocks/BlockTripwire.h b/src/Blocks/BlockTripwire.h
index d03f37537..19a9c4384 100644
--- a/src/Blocks/BlockTripwire.h
+++ b/src/Blocks/BlockTripwire.h
@@ -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;
+ }
};
diff --git a/src/Blocks/BlockTripwireHook.h b/src/Blocks/BlockTripwireHook.h
index 39892af5a..6eab3434e 100644
--- a/src/Blocks/BlockTripwireHook.h
+++ b/src/Blocks/BlockTripwireHook.h
@@ -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;
+ }
};
diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h
index 3d06a8223..cc354c374 100644
--- a/src/Blocks/BlockVine.h
+++ b/src/Blocks/BlockVine.h
@@ -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,18 +157,15 @@ 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
{
@@ -199,33 +189,35 @@ 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;
+ }
+
} ;
diff --git a/src/Blocks/BlockWallSign.h b/src/Blocks/BlockWallSign.h
index 9b90b78bf..b69944609 100644
--- a/src/Blocks/BlockWallSign.h
+++ b/src/Blocks/BlockWallSign.h
@@ -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;
+ }
} ;
diff --git a/src/Blocks/BlockWorkbench.h b/src/Blocks/BlockWorkbench.h
index e40e15606..ed78f224d 100644
--- a/src/Blocks/BlockWorkbench.h
+++ b/src/Blocks/BlockWorkbench.h
@@ -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;
+ }
} ;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6c8fe7d0c..d941b7d4c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -28,6 +28,7 @@ SET (SRCS
ChunkSender.cpp
ChunkStay.cpp
ClientHandle.cpp
+ Color.cpp
CommandOutput.cpp
CompositeChat.cpp
CraftingRecipes.cpp
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 6ca43da6f..566b814b9 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -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);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 302de5a77..7401537b9 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -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);
diff --git a/src/Color.cpp b/src/Color.cpp
new file mode 100644
index 000000000..f2180e2d9
--- /dev/null
+++ b/src/Color.cpp
@@ -0,0 +1,76 @@
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Color.h"
+
+
+
+
+
+#define COLOR_RED_BITS 0x00FF0000
+#define COLOR_GREEN_BITS 0x0000FF00
+#define COLOR_BLUE_BITS 0x000000FF
+#define COLOR_RED_OFFSET 16
+#define COLOR_GREEN_OFFSET 8
+
+
+
+
+
+void cColor::SetColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue)
+{
+ m_Color = (static_cast<unsigned int>(a_Red) << COLOR_RED_OFFSET) + (static_cast<unsigned int>(a_Green) << COLOR_GREEN_OFFSET) + (static_cast<unsigned int>(a_Blue));
+}
+
+
+
+
+
+void cColor::SetRed(unsigned char a_Red)
+{
+ m_Color = (static_cast<unsigned int>(a_Red) << COLOR_RED_OFFSET) + ((COLOR_GREEN_BITS | COLOR_BLUE_BITS) & m_Color);
+}
+
+
+
+
+
+void cColor::SetGreen(unsigned char a_Green)
+{
+ m_Color = (static_cast<unsigned int>(a_Green) << COLOR_GREEN_OFFSET) + ((COLOR_RED_BITS | COLOR_BLUE_BITS) & m_Color);
+}
+
+
+
+
+
+void cColor::SetBlue(unsigned char a_Blue)
+{
+ m_Color = static_cast<unsigned int>(a_Blue) + ((COLOR_RED_BITS | COLOR_GREEN_BITS) & m_Color);
+}
+
+
+
+
+
+unsigned char cColor::GetRed() const
+{
+ return (m_Color & COLOR_RED_BITS) >> COLOR_RED_OFFSET;
+}
+
+
+
+
+
+unsigned char cColor::GetGreen() const
+{
+ return (m_Color & COLOR_GREEN_BITS) >> COLOR_GREEN_OFFSET;
+}
+
+
+
+
+
+unsigned char cColor::GetBlue() const
+{
+ return m_Color & COLOR_BLUE_BITS;
+}
diff --git a/src/Color.h b/src/Color.h
new file mode 100644
index 000000000..a90e8372b
--- /dev/null
+++ b/src/Color.h
@@ -0,0 +1,58 @@
+
+// Color.h
+
+// Declares a class to handle item color related code
+
+
+
+
+
+#pragma once
+
+ // tolua_begin
+
+class cColor
+{
+public:
+
+ enum
+ {
+ COLOR_MIN = 0,
+ COLOR_MAX = 255,
+ COLOR_LIMIT = 256,
+ COLOR_NONE = 0xFFFFFFFF,
+ };
+ cColor() { m_Color = COLOR_NONE;}
+ cColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue) { SetColor(a_Red, a_Green, a_Blue); }
+
+ /// Returns whether the color is a valid color
+ bool IsValid() const { return m_Color != COLOR_NONE; }
+
+ /// Changes the color
+ void SetColor(unsigned char a_Red, unsigned char a_Green, unsigned char a_Blue);
+
+ /// Alters the red value of the color
+ void SetRed(unsigned char a_Red);
+
+ /// Alters the green value of the color
+ void SetGreen(unsigned char a_Red);
+
+ /// Alters the blue value of the color
+ void SetBlue(unsigned char a_Red);
+
+ /// Returns the red value of the color
+ unsigned char GetRed() const;
+
+ /// Returns the green value of the color
+ unsigned char GetGreen() const;
+
+ /// Returns the blue value of the color
+ unsigned char GetBlue() const;
+
+ /// Resets the color
+ void Clear() { m_Color = COLOR_NONE; }
+ // tolua_end
+
+ unsigned int m_Color;
+
+};
diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp
index c6a407d4b..d3a28292a 100644
--- a/src/CraftingRecipes.cpp
+++ b/src/CraftingRecipes.cpp
@@ -385,7 +385,7 @@ void cCraftingRecipes::AddRecipeLine(int a_LineNum, const AString & a_RecipeLine
return;
}
- std::unique_ptr<cCraftingRecipes::cRecipe> Recipe(new cCraftingRecipes::cRecipe);
+ std::unique_ptr<cCraftingRecipes::cRecipe> Recipe = cpp14::make_unique<cCraftingRecipes::cRecipe>();
// Parse the result:
AStringVector ResultSplit = StringSplit(Sides[0], ",");
@@ -766,7 +766,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
} // for y, for x
// The recipe has matched. Create a copy of the recipe and set its coords to match the crafting grid:
- std::unique_ptr<cRecipe> Recipe(new cRecipe);
+ std::unique_ptr<cRecipe> Recipe = cpp14::make_unique<cRecipe>();
Recipe->m_Result = a_Recipe->m_Result;
Recipe->m_Width = a_Recipe->m_Width;
Recipe->m_Height = a_Recipe->m_Height;
@@ -787,6 +787,9 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
// We use Recipe instead of a_Recipe because we want the wildcard ingredients' slot numbers as well, which was just added previously
HandleFireworks(a_CraftingGrid, Recipe.get(), a_GridStride, a_OffsetX, a_OffsetY);
+ // Handle Dyed Leather
+ HandleDyedLeather(a_CraftingGrid, Recipe.get(), a_GridStride, a_GridWidth, a_GridHeight);
+
return Recipe.release();
}
@@ -874,3 +877,192 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe
+
+void cCraftingRecipes::HandleDyedLeather(const cItem * a_CraftingGrid, cCraftingRecipes::cRecipe * a_Recipe, int a_GridStride, int a_GridWidth, int a_GridHeight)
+{
+ short result_type = a_Recipe->m_Result.m_ItemType;
+ if ((result_type == E_ITEM_LEATHER_CAP) || (result_type == E_ITEM_LEATHER_TUNIC) || (result_type == E_ITEM_LEATHER_PANTS) || (result_type == E_ITEM_LEATHER_BOOTS))
+ {
+ bool found = false;
+ cItem temp;
+
+ float red = 0;
+ float green = 0;
+ float blue = 0;
+ float dye_count = 0;
+
+ for (int x = 0; x < a_GridWidth; ++x)
+ {
+ for (int y = 0; y < a_GridHeight; ++y)
+ {
+ int GridIdx = x + a_GridStride * y;
+ if ((a_CraftingGrid[GridIdx].m_ItemType == result_type) && (found == false))
+ {
+ found = true;
+ temp = a_CraftingGrid[GridIdx].CopyOne();
+ // The original color of the item affects the result
+ if (temp.m_ItemColor.IsValid())
+ {
+ red += temp.m_ItemColor.GetRed();
+ green += temp.m_ItemColor.GetGreen();
+ blue += temp.m_ItemColor.GetBlue();
+ ++dye_count;
+ }
+ }
+ else if (a_CraftingGrid[GridIdx].m_ItemType == E_ITEM_DYE)
+ {
+ switch (a_CraftingGrid[GridIdx].m_ItemDamage)
+ {
+ case E_META_DYE_BLACK:
+ {
+ red += 23;
+ green += 23;
+ blue += 23;
+ break;
+ }
+ case E_META_DYE_RED:
+ {
+ red += 142;
+ green += 47;
+ blue += 47;
+ break;
+ }
+ case E_META_DYE_GREEN:
+ {
+ red += 95;
+ green += 118;
+ blue += 47;
+ break;
+ }
+ case E_META_DYE_BROWN:
+ {
+ red += 95;
+ green += 71;
+ blue += 47;
+ break;
+ }
+ case E_META_DYE_BLUE:
+ {
+ red += 47;
+ green += 71;
+ blue += 165;
+ break;
+ }
+ case E_META_DYE_PURPLE:
+ {
+ red += 118;
+ green += 59;
+ blue += 165;
+ break;
+ }
+ case E_META_DYE_CYAN:
+ {
+ red += 71;
+ green += 118;
+ blue += 142;
+ break;
+ }
+ case E_META_DYE_LIGHTGRAY:
+ {
+ red += 142;
+ green += 142;
+ blue += 142;
+ break;
+ }
+ case E_META_DYE_GRAY:
+ {
+ red += 71;
+ green += 71;
+ blue += 71;
+ break;
+ }
+ case E_META_DYE_PINK:
+ {
+ red += 225;
+ green += 118;
+ blue += 153;
+ break;
+ }
+ case E_META_DYE_LIGHTGREEN:
+ {
+ red += 118;
+ green += 190;
+ blue += 23;
+ break;
+ }
+ case E_META_DYE_YELLOW:
+ {
+ red += 213;
+ green += 213;
+ blue += 47;
+ break;
+ }
+ case E_META_DYE_LIGHTBLUE:
+ {
+ red += 95;
+ green += 142;
+ blue += 201;
+ break;
+ }
+ case E_META_DYE_MAGENTA:
+ {
+ red += 165;
+ green += 71;
+ blue += 201;
+ break;
+ }
+ case E_META_DYE_ORANGE:
+ {
+ red += 201;
+ green += 118;
+ blue += 47;
+ break;
+ }
+ case E_META_DYE_WHITE:
+ {
+ red += 237;
+ green += 237;
+ blue += 237;
+ break;
+ }
+ }
+ ++dye_count;
+ }
+ else if (a_CraftingGrid[GridIdx].m_ItemType != E_ITEM_EMPTY)
+ {
+ return;
+ }
+ }
+ }
+
+ if (!found)
+ {
+ return;
+ }
+
+ // Calculate the rgb values
+ double maximum = static_cast<double>(std::max({red, green, blue}));
+
+ double average_red = red / dye_count;
+ double average_green = green / dye_count;
+ double average_blue = blue / dye_count;
+ double average_max = maximum / dye_count;
+
+ double max_average = std::max({average_red, average_green, average_blue});
+
+ double gain_factor = average_max / max_average;
+
+
+ unsigned char result_red = static_cast<unsigned char>(average_red * gain_factor);
+ unsigned char result_green = static_cast<unsigned char>(average_green * gain_factor);
+ unsigned char result_blue = static_cast<unsigned char>(average_blue * gain_factor);
+
+ // Set the results values
+ a_Recipe->m_Result = temp;
+ a_Recipe->m_Result.m_ItemColor.SetColor(result_red, result_green, result_blue);
+ }
+}
+
+
+
+
diff --git a/src/CraftingRecipes.h b/src/CraftingRecipes.h
index 44444d42e..778dd495a 100644
--- a/src/CraftingRecipes.h
+++ b/src/CraftingRecipes.h
@@ -168,6 +168,9 @@ protected:
/** Searches for anything firework related, and does the data setting if appropriate */
void HandleFireworks(const cItem * a_CraftingGrid, cCraftingRecipes::cRecipe * a_Recipe, int a_GridStride, int a_OffsetX, int a_OffsetY);
+
+ /// Searches for anything dye related for leather, calculates the appropriate color value, and sets the resulting value.
+ void HandleDyedLeather(const cItem * a_CraftingGrid, cCraftingRecipes::cRecipe * a_Recipe, int a_GridStride, int a_GridWidth, int a_GridHeight);
} ;
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 97e2eca3a..3a9360d1e 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -16,6 +16,7 @@
#include "../Items/ItemHandler.h"
#include "../Vector3.h"
#include "../FastRandom.h"
+#include <cmath>
#include "../WorldStorage/StatSerializer.h"
#include "../CompositeChat.h"
@@ -205,6 +206,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 +217,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);
@@ -2178,20 +2184,18 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
return;
}
- // Process exhaustion every two ticks as that is how frequently m_LastPos is updated
- // Otherwise, we apply exhaustion for a 'movement' every tick, one of which is an already processed value
- if (GetWorld()->GetWorldAge() % 2 != 0)
- {
- return;
- }
-
// Calculate the distance travelled, update the last pos:
- Vector3d Movement(GetPosition() - m_LastPos);
- Movement.y = 0; // Only take XZ movement into account
+ double SpeedX = m_Speed.x;
+ double SpeedZ = m_Speed.z;
+ double BaseExhaustion(sqrt((SpeedX * SpeedX) + (SpeedZ * SpeedZ)));
// Apply the exhaustion based on distance travelled:
- double BaseExhaustion = Movement.Length();
- if (IsSprinting())
+ if (IsFlying() || IsClimbing())
+ {
+ // Apply no exhaustion when flying or climbing.
+ BaseExhaustion = 0;
+ }
+ else if (IsSprinting())
{
// 0.1 pt per meter sprinted
BaseExhaustion = BaseExhaustion * 0.1;
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp
index e3be6b230..a0c8560f1 100644
--- a/src/FurnaceRecipe.cpp
+++ b/src/FurnaceRecipe.cpp
@@ -115,7 +115,7 @@ void cFurnaceRecipe::AddFuelFromLine(const AString & a_Line, unsigned int a_Line
Line.erase(Line.begin()); // Remove the beginning "!"
Line.erase(std::remove_if(Line.begin(), Line.end(), isspace), Line.end());
- std::unique_ptr<cItem> Item(new cItem);
+ std::unique_ptr<cItem> Item = cpp14::make_unique<cItem>();
int BurnTime;
const AStringVector & Sides = StringSplit(Line, "=");
@@ -157,8 +157,8 @@ void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, unsigned int a_Li
Line.erase(std::remove_if(Line.begin(), Line.end(), isspace), Line.end());
int CookTime = 200;
- std::unique_ptr<cItem> InputItem(new cItem());
- std::unique_ptr<cItem> OutputItem(new cItem());
+ std::unique_ptr<cItem> InputItem = cpp14::make_unique<cItem>();
+ std::unique_ptr<cItem> OutputItem = cpp14::make_unique<cItem>();
const AStringVector & Sides = StringSplit(Line, "=");
if (Sides.size() != 2)
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index f0d2af4f3..ff8827511 100644
--- a/src/Generating/BioGen.cpp
+++ b/src/Generating/BioGen.cpp
@@ -641,8 +641,8 @@ void cBioGenMultiStepMap::BuildTemperatureHumidityMaps(int a_ChunkX, int a_Chunk
// Re-map into integral values in [0 .. 255] range:
for (size_t idx = 0; idx < ARRAYCOUNT(a_TemperatureMap); idx++)
{
- a_TemperatureMap[idx] = std::max(0, std::min(255, static_cast<int>(128 + TemperatureMap[idx] * 128)));
- a_HumidityMap[idx] = std::max(0, std::min(255, static_cast<int>(128 + HumidityMap[idx] * 128)));
+ a_TemperatureMap[idx] = Clamp(static_cast<int>(128 + TemperatureMap[idx] * 128), 0, 255);
+ a_HumidityMap[idx] = Clamp(static_cast<int>(128 + HumidityMap[idx] * 128), 0, 255);
}
}
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index 59af0fd63..513c2bd49 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -322,6 +322,7 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
if (
(a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) ||
((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_GRASS) && (a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_DIRT))
+
)
{
continue;
@@ -337,7 +338,7 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
{
a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, 2);
}
- else
+ else if (!IsBiomeVeryCold(a_ChunkDesc.GetBiome(x, z)))
{
// If double long grass we have to choose what type we should use:
if (a_ChunkDesc.GetBlockType(x, y + 1, z) == E_BLOCK_AIR)
@@ -347,6 +348,11 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
a_ChunkDesc.SetBlockTypeMeta(x, y + 1, z, E_BLOCK_BIG_FLOWER, 8);
}
}
+ else
+ {
+ NIBBLETYPE meta = (m_Noise.IntNoise2DInt(xx * 50, zz * 50) / 7 % 2) + 1;
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_TALL_GRASS, meta);
+ }
}
}
}
diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp
index c8bbab12f..5da8fc44a 100644
--- a/src/Generating/Trees.cpp
+++ b/src/Generating/Trees.cpp
@@ -6,6 +6,7 @@
#include "Globals.h"
#include "Trees.h"
#include "../BlockID.h"
+#include "../World.h"
@@ -200,7 +201,8 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No
}
else
{
- GetJungleTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
+ bool IsLarge = a_Noise.IntNoise3DInt(a_BlockX + 32 * a_Seq, a_BlockY + 32 * a_Seq, a_BlockZ) < 0x60000000;
+ GetJungleTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks, IsLarge);
}
return;
}
@@ -920,9 +922,9 @@ void GetAppleBushImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Nois
-void GetJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks)
+void GetJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks, bool a_Large)
{
- if (a_Noise.IntNoise3DInt(a_BlockX + 32 * a_Seq, a_BlockY + 32 * a_Seq, a_BlockZ) < 0x60000000)
+ if (!a_Large)
{
GetSmallJungleTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
}
@@ -1041,3 +1043,89 @@ void GetSmallJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise &
+
+bool GetLargeTreeAdjustment(cWorld & a_World, int & a_X, int & a_Y, int & a_Z, NIBBLETYPE a_Meta)
+{
+ bool IsLarge = true;
+ a_Meta = a_Meta & 0x07;
+
+ // Check to see if we are the northwest corner
+ for (int x = 0; x < 2; ++x)
+ {
+ for (int z = 0; z < 2; ++z)
+ {
+ NIBBLETYPE meta;
+ BLOCKTYPE type;
+ a_World.GetBlockTypeMeta(a_X + x, a_Y, a_Z + z, type, meta);
+ IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+ }
+ }
+
+ if (IsLarge)
+ {
+ return true;
+ }
+
+ IsLarge = true;
+ // Check to see if we are the southwest corner
+ for (int x = 0; x < 2; ++x)
+ {
+ for (int z = 0; z > -2; --z)
+ {
+ NIBBLETYPE meta;
+ BLOCKTYPE type;
+ a_World.GetBlockTypeMeta(a_X + x, a_Y, a_Z + z, type, meta);
+ IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+ }
+ }
+
+ if (IsLarge)
+ {
+ --a_Z;
+ return true;
+ }
+
+ IsLarge = true;
+ // Check to see if we are the southeast corner
+ for (int x = 0; x > -2; --x)
+ {
+ for (int z = 0; z > -2; --z)
+ {
+ NIBBLETYPE meta;
+ BLOCKTYPE type;
+ a_World.GetBlockTypeMeta(a_X + x, a_Y, a_Z + z, type, meta);
+ IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+ }
+ }
+
+ if (IsLarge)
+ {
+ --a_Z;
+ --a_X;
+ return true;
+ }
+
+ IsLarge = true;
+ // Check to see if we are the northeast corner
+ for (int x = 0; x > -2; --x)
+ {
+ for (int z = 0; z < 2; ++z)
+ {
+ NIBBLETYPE meta;
+ BLOCKTYPE type;
+ a_World.GetBlockTypeMeta(a_X + x, a_Y, a_Z + z, type, meta);
+ IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+ }
+ }
+
+ if (IsLarge)
+ {
+ --a_X;
+ }
+
+ return IsLarge;
+}
+
+
+
+
diff --git a/src/Generating/Trees.h b/src/Generating/Trees.h
index a2c8274f5..092d71182 100644
--- a/src/Generating/Trees.h
+++ b/src/Generating/Trees.h
@@ -20,6 +20,8 @@ logs can overwrite others(leaves), but others shouldn't overwrite logs. This is
#include "../ChunkDef.h"
#include "../Noise/Noise.h"
+class cWorld;
+
@@ -96,7 +98,7 @@ void GetSwampTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Nois
void GetAppleBushImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
/// Generates an image of a random jungle tree
-void GetJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
+void GetJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks, bool a_Large);
/// Generates an image of a large jungle tree (2x2 trunk)
void GetLargeJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
@@ -104,7 +106,7 @@ void GetLargeJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise &
/// Generates an image of a small jungle tree (1x1 trunk)
void GetSmallJungleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks);
-
+bool GetLargeTreeAdjustment(cWorld & a_World, int & a_X, int & a_Y, int & a_Z, NIBBLETYPE a_Meta);
diff --git a/src/Globals.h b/src/Globals.h
index f0e370d2c..28cd6d163 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -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>
diff --git a/src/Inventory.cpp b/src/Inventory.cpp
index 6b3c8e62f..455a4bbe5 100644
--- a/src/Inventory.cpp
+++ b/src/Inventory.cpp
@@ -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())
- {
- return;
- }
-
- switch (Slot.m_ItemType)
+ if (!Slot.IsEmpty())
{
- 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);
}
}
diff --git a/src/Item.cpp b/src/Item.cpp
index 36c444328..7bd344ae8 100644
--- a/src/Item.cpp
+++ b/src/Item.cpp
@@ -142,6 +142,13 @@ void cItem::GetJson(Json::Value & a_OutValue) const
a_OutValue["Lore"] = m_Lore;
}
+ if (m_ItemColor.IsValid())
+ {
+ a_OutValue["Color_Red"] = m_ItemColor.GetRed();
+ a_OutValue["Color_Green"] = m_ItemColor.GetGreen();
+ a_OutValue["Color_Blue"] = m_ItemColor.GetBlue();
+ }
+
if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR))
{
a_OutValue["Flicker"] = m_FireworkItem.m_HasFlicker;
@@ -172,6 +179,18 @@ void cItem::FromJson(const Json::Value & a_Value)
m_CustomName = a_Value.get("Name", "").asString();
m_Lore = a_Value.get("Lore", "").asString();
+ int red = a_Value.get("Color_Red", -1).asInt();
+ int green = a_Value.get("Color_Green", -1).asInt();
+ int blue = a_Value.get("Color_Blue", -1).asInt();
+ if ((red > -1) && (red < static_cast<int>(cColor::COLOR_LIMIT)) && (green > -1) && (green < static_cast<int>(cColor::COLOR_LIMIT)) && (blue > -1) && (blue < static_cast<int>(cColor::COLOR_LIMIT)))
+ {
+ m_ItemColor.SetColor(static_cast<unsigned char>(red), static_cast<unsigned char>(green), static_cast<unsigned char>(blue));
+ }
+ else if ((red != -1) || (blue != -1) || (green != -1))
+ {
+ LOGWARNING("Item with invalid red, green, and blue values read in from json file.");
+ }
+
if ((m_ItemType == E_ITEM_FIREWORK_ROCKET) || (m_ItemType == E_ITEM_FIREWORK_STAR))
{
m_FireworkItem.m_HasFlicker = a_Value.get("Flicker", false).asBool();
diff --git a/src/Item.h b/src/Item.h
index 056b5eb8a..8f47c4177 100644
--- a/src/Item.h
+++ b/src/Item.h
@@ -12,6 +12,7 @@
#include "Defines.h"
#include "Enchantments.h"
#include "WorldStorage/FireworksSerializer.h"
+#include "Color.h"
@@ -19,6 +20,7 @@
// fwd:
class cItemHandler;
+class cColor;
namespace Json
{
@@ -41,7 +43,8 @@ public:
m_CustomName(""),
m_Lore(""),
m_RepairCost(0),
- m_FireworkItem()
+ m_FireworkItem(),
+ m_ItemColor()
{
}
@@ -62,7 +65,8 @@ public:
m_CustomName (a_CustomName),
m_Lore (a_Lore),
m_RepairCost (0),
- m_FireworkItem()
+ m_FireworkItem(),
+ m_ItemColor()
{
if (!IsValidItem(m_ItemType))
{
@@ -105,6 +109,7 @@ public:
m_Lore = "";
m_RepairCost = 0;
m_FireworkItem.EmptyData();
+ m_ItemColor.Clear();
}
@@ -114,6 +119,7 @@ public:
m_ItemCount = 0;
m_ItemDamage = 0;
m_RepairCost = 0;
+ m_ItemColor.Clear();
}
@@ -206,6 +212,7 @@ public:
int m_RepairCost;
cFireworkItem m_FireworkItem;
+ cColor m_ItemColor;
};
// tolua_end
diff --git a/src/Items/ItemDoor.h b/src/Items/ItemDoor.h
index e92c567fb..a74997b7d 100644
--- a/src/Items/ItemDoor.h
+++ b/src/Items/ItemDoor.h
@@ -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;
diff --git a/src/Items/ItemEmptyMap.h b/src/Items/ItemEmptyMap.h
index fba8c0a2c..98352bd2d 100644
--- a/src/Items/ItemEmptyMap.h
+++ b/src/Items/ItemEmptyMap.h
@@ -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);
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index a1fa67152..aa5f6109b 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -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:
diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h
index 684b55788..be2e2fade 100644
--- a/src/Items/ItemHandler.h
+++ b/src/Items/ItemHandler.h
@@ -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);
diff --git a/src/Items/ItemMap.h b/src/Items/ItemMap.h
index 2dbbb3dc0..a96183f41 100644
--- a/src/Items/ItemMap.h
+++ b/src/Items/ItemMap.h
@@ -37,7 +37,6 @@ public:
}
Map->UpdateRadius(*a_Player, DEFAULT_RADIUS);
-
Map->UpdateClient(a_Player);
}
} ;
diff --git a/src/Items/ItemPickaxe.h b/src/Items/ItemPickaxe.h
index b5dc179f8..1d5abddb6 100644
--- a/src/Items/ItemPickaxe.h
+++ b/src/Items/ItemPickaxe.h
@@ -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:
diff --git a/src/Items/ItemRedstoneDust.h b/src/Items/ItemRedstoneDust.h
index 6d5fb521f..87f351654 100644
--- a/src/Items/ItemRedstoneDust.h
+++ b/src/Items/ItemRedstoneDust.h
@@ -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:
{
diff --git a/src/Map.cpp b/src/Map.cpp
index 48d7fb0ca..d55642a5a 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -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;
+
+ 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);
- // Count surface blocks
- for (unsigned int X = m_RelX; X < m_RelX + CallbackPixelWidth; ++X)
+ 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;
}
}
-
- // Find dominant color
- ColorID PixelColor = E_BASE_COLOR_TRANSPARENT;
-
- unsigned int MaxCount = 0;
-
- for (ColorCountMap::iterator it = ColorCounts.begin(); it != ColorCounts.end(); ++it)
+ else if (ColourID == 0)
{
- if (it->second > MaxCount)
+ while (((--Height) != -1) && ((ColourID = BlockHandler(a_Chunk->GetBlock(m_RelX, Height, m_RelZ))->GetMapBaseColourID(a_Chunk->GetMeta(m_RelX, Height, m_RelZ))) == 0))
{
- PixelColor = it->first;
- MaxCount = it->second;
+ continue;
}
}
- // 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,36 +279,75 @@ cMap::ColorID cMap::GetPixel(unsigned int a_X, unsigned int a_Z)
-void cMap::SendTo(cClientHandle & a_Client)
+unsigned int cMap::GetNumPixels(void) const
{
- a_Client.SendMapInfo(m_ID, m_Scale);
+ return m_Width * m_Height;
+}
- 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);
-}
+const cMapDecorator cMap::CreateDecorator(const cEntity * a_TrackedEntity)
+{
+ 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();
-unsigned int cMap::GetNumPixels(void) const
-{
- return m_Width * m_Height;
-}
+ 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;
+ }
+ }
-size_t cMap::GetNumDecorators(void) const
-{
- return m_Decorators.size();
+ return {Type, (unsigned)(2 * PixelX + 1), (unsigned)(2 * PixelZ + 1), Rot};
}
diff --git a/src/Map.h b/src/Map.h
index a764eda50..b1976133e 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -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;
diff --git a/src/MapManager.cpp b/src/MapManager.cpp
index 41b0d9e34..2729e67dd 100644
--- a/src/MapManager.cpp
+++ b/src/MapManager.cpp
@@ -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);
diff --git a/src/MapManager.h b/src/MapManager.h
index cacc6d816..6730e515e 100644
--- a/src/MapManager.h
+++ b/src/MapManager.h
@@ -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);
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index cb4edb951..4befe307d 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -101,6 +101,7 @@ cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const A
, m_TicksSinceLastDamaged(100)
, m_BurnsInDaylight(false)
, m_RelativeWalkSpeed(1)
+ , m_Age(1)
{
if (!a_ConfigName.empty())
{
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 1076c9544..2832a1570 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -112,10 +112,14 @@ public:
void SetRelativeWalkSpeed(double a_WalkSpeed) { m_RelativeWalkSpeed = a_WalkSpeed; } // tolua_export
// Overridables to handle ageable mobs
- virtual bool IsBaby (void) const { return false; }
virtual bool IsTame (void) const { return false; }
virtual bool IsSitting (void) const { return false; }
+ bool IsBaby (void) const { return m_Age < 0; }
+ char GetAge (void) const { return m_Age; }
+ void SetAge(char a_Age) { m_Age = a_Age; }
+
+
// tolua_begin
/** Returns true if the monster has a custom name. */
@@ -270,6 +274,8 @@ protected:
bool m_BurnsInDaylight;
double m_RelativeWalkSpeed;
+ char m_Age;
+
/** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp
index e987381f7..d6de8de00 100644
--- a/src/Mobs/Path.cpp
+++ b/src/Mobs/Path.cpp
@@ -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))
)
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 1a19249bf..9e80f7bd5 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -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;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 53bb01790..098c62a90 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -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);
-}
+ {
+ 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()));
-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(0);
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_DataStartX));
+ Pkt.WriteBEUInt8(static_cast<Byte>(a_DataStartX));
- 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()));
+ Pkt.WriteBuf(reinterpret_cast<const char *>(a_Map.GetData().data()), a_Map.GetData().size());
}
-}
-
+ {
+ ASSERT(1 + 3 * a_Map.GetDecorators().size() < USHRT_MAX);
+ 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(1);
-void cProtocol172::SendMapInfo(int a_MapID, unsigned int a_Scale)
-{
- ASSERT(m_State == 3); // In game mode?
- ASSERT(a_Scale < 256);
-
- cPacketizer Pkt(*this, 0x34);
- Pkt.WriteVarInt32(static_cast<UInt32>(a_MapID));
- Pkt.WriteBEUInt16(2);
-
- Pkt.WriteBEUInt8(2);
- Pkt.WriteBEUInt8(static_cast<Byte>(a_Scale));
+ 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()));
+ }
+ }
}
@@ -2646,6 +2637,10 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
a_Item.m_Lore = Lore;
}
+ else if ((NBT.GetType(displaytag) == TAG_Int) && (NBT.GetName(displaytag) == "color"))
+ {
+ a_Item.m_ItemColor.m_Color = static_cast<unsigned int>(NBT.GetInt(displaytag));
+ }
}
}
else if ((TagName == "Fireworks") || (TagName == "Explosion"))
@@ -2732,7 +2727,7 @@ void cProtocol172::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
a_Pkt.WriteBEInt8(a_Item.m_ItemCount);
a_Pkt.WriteBEInt16(a_Item.m_ItemDamage);
- if (a_Item.m_Enchantments.IsEmpty() && a_Item.IsBothNameAndLoreEmpty() && (a_Item.m_ItemType != E_ITEM_FIREWORK_ROCKET) && (a_Item.m_ItemType != E_ITEM_FIREWORK_STAR))
+ if (a_Item.m_Enchantments.IsEmpty() && a_Item.IsBothNameAndLoreEmpty() && (a_Item.m_ItemType != E_ITEM_FIREWORK_ROCKET) && (a_Item.m_ItemType != E_ITEM_FIREWORK_STAR) && !a_Item.m_ItemColor.IsValid())
{
a_Pkt.WriteBEInt16(-1);
return;
@@ -2749,9 +2744,15 @@ void cProtocol172::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName);
}
- if (!a_Item.IsBothNameAndLoreEmpty())
+ if (!a_Item.IsBothNameAndLoreEmpty() || a_Item.m_ItemColor.IsValid())
{
Writer.BeginCompound("display");
+
+ if (a_Item.m_ItemColor.IsValid())
+ {
+ Writer.AddInt("color", static_cast<int>(a_Item.m_ItemColor.m_Color));
+ }
+
if (!a_Item.IsCustomNameEmpty())
{
Writer.AddString("Name", a_Item.m_CustomName.c_str());
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index b07fa9ed9..c5625dd62 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -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;
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index 63fa91b01..f4f32dfdb 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -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]);
+ Pkt.WriteBEUInt8(static_cast<Byte>((static_cast<int>(Decorator.GetType()) << 4) | (Decorator.GetRot() & 0xF)));
+ Pkt.WriteBEUInt8(Decorator.GetPixelX());
+ Pkt.WriteBEUInt8(Decorator.GetPixelZ());
}
-}
-
-
-
-
-
-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(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((it->GetType() << 4) | (it->GetRot() & 0xf));
- Pkt.WriteBEUInt8(it->GetPixelX());
- Pkt.WriteBEUInt8(it->GetPixelZ());
+ Pkt.WriteBEUInt8(*itr);
}
-
- 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
}
@@ -2898,6 +2869,10 @@ void cProtocol180::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
a_Item.m_Lore = Lore;
}
+ else if ((NBT.GetType(displaytag) == TAG_Int) && (NBT.GetName(displaytag) == "color"))
+ {
+ a_Item.m_ItemColor.m_Color = static_cast<unsigned int>(NBT.GetInt(displaytag));
+ }
}
}
else if ((TagName == "Fireworks") || (TagName == "Explosion"))
@@ -3047,12 +3022,13 @@ void cProtocol180::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
a_Pkt.WriteBEInt8(a_Item.m_ItemCount);
a_Pkt.WriteBEInt16(a_Item.m_ItemDamage);
- if (a_Item.m_Enchantments.IsEmpty() && a_Item.IsBothNameAndLoreEmpty() && (a_Item.m_ItemType != E_ITEM_FIREWORK_ROCKET) && (a_Item.m_ItemType != E_ITEM_FIREWORK_STAR))
+ if (a_Item.m_Enchantments.IsEmpty() && a_Item.IsBothNameAndLoreEmpty() && (a_Item.m_ItemType != E_ITEM_FIREWORK_ROCKET) && (a_Item.m_ItemType != E_ITEM_FIREWORK_STAR) && !a_Item.m_ItemColor.IsValid())
{
a_Pkt.WriteBEInt8(0);
return;
}
+
// Send the enchantments and custom names:
cFastNBTWriter Writer;
if (a_Item.m_RepairCost != 0)
@@ -3064,9 +3040,14 @@ void cProtocol180::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
const char * TagName = (a_Item.m_ItemType == E_ITEM_BOOK) ? "StoredEnchantments" : "ench";
EnchantmentSerializer::WriteToNBTCompound(a_Item.m_Enchantments, Writer, TagName);
}
- if (!a_Item.IsBothNameAndLoreEmpty())
+ if (!a_Item.IsBothNameAndLoreEmpty() || a_Item.m_ItemColor.IsValid())
{
Writer.BeginCompound("display");
+ if (a_Item.m_ItemColor.IsValid())
+ {
+ Writer.AddInt("color", static_cast<int>(a_Item.m_ItemColor.m_Color));
+ }
+
if (!a_Item.IsCustomNameEmpty())
{
Writer.AddString("Name", a_Item.m_CustomName.c_str());
@@ -3354,7 +3335,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Bat.IsHanging() ? 1 : 0);
break;
} // case mtBat
-
+
case mtCreeper:
{
auto & Creeper = reinterpret_cast<const cCreeper &>(a_Mob);
@@ -3364,7 +3345,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Creeper.IsCharged() ? 1 : 0);
break;
} // case mtCreeper
-
+
case mtEnderman:
{
auto & Enderman = reinterpret_cast<const cEnderman &>(a_Mob);
@@ -3376,7 +3357,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Enderman.IsScreaming() ? 1 : 0);
break;
} // case mtEnderman
-
+
case mtGhast:
{
auto & Ghast = reinterpret_cast<const cGhast &>(a_Mob);
@@ -3384,7 +3365,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Ghast.IsCharging());
break;
} // case mtGhast
-
+
case mtHorse:
{
auto & Horse = reinterpret_cast<const cHorse &>(a_Mob);
@@ -3401,10 +3382,6 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
{
Flags |= 0x08;
}
- if (Horse.IsBaby())
- {
- Flags |= 0x10;
- }
if (Horse.IsEating())
{
Flags |= 0x20;
@@ -3428,6 +3405,9 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEInt32(Appearance);
a_Pkt.WriteBEUInt8(0x56); // Int at index 22
a_Pkt.WriteBEInt32(Horse.GetHorseArmour());
+
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Horse.GetAge());
break;
} // case mtHorse
@@ -3439,17 +3419,38 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
break;
} // case mtMagmaCube
+ case mtOcelot:
+ {
+ auto & Ocelot = reinterpret_cast<const cOcelot &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Ocelot.GetAge());
+ break;
+ } // case mtOcelot
+
case mtPig:
{
auto & Pig = reinterpret_cast<const cPig &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Pig.GetAge());
a_Pkt.WriteBEUInt8(0x10);
a_Pkt.WriteBEUInt8(Pig.IsSaddled() ? 1 : 0);
break;
} // case mtPig
-
+
+ case mtRabbit:
+ {
+ auto & Rabbit = reinterpret_cast<const cRabbit &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Rabbit.GetAge());
+ break;
+ } // case mtRabbit
+
case mtSheep:
{
auto & Sheep = reinterpret_cast<const cSheep &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Sheep.GetAge());
+
a_Pkt.WriteBEUInt8(0x10);
Byte SheepMetadata = 0;
SheepMetadata = Sheep.GetFurColor();
@@ -3460,7 +3461,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(SheepMetadata);
break;
} // case mtSheep
-
+
case mtSkeleton:
{
auto & Skeleton = reinterpret_cast<const cSkeleton &>(a_Mob);
@@ -3468,7 +3469,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Skeleton.IsWither() ? 1 : 0);
break;
} // case mtSkeleton
-
+
case mtSlime:
{
auto & Slime = reinterpret_cast<const cSlime &>(a_Mob);
@@ -3482,9 +3483,11 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
auto & Villager = reinterpret_cast<const cVillager &>(a_Mob);
a_Pkt.WriteBEUInt8(0x50);
a_Pkt.WriteBEInt32(Villager.GetVilType());
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Villager.GetAge());
break;
} // case mtVillager
-
+
case mtWitch:
{
auto & Witch = reinterpret_cast<const cWitch &>(a_Mob);
@@ -3502,7 +3505,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth()));
break;
} // case mtWither
-
+
case mtWolf:
{
auto & Wolf = reinterpret_cast<const cWolf &>(a_Mob);
@@ -3528,20 +3531,31 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Wolf.IsBegging() ? 1 : 0);
a_Pkt.WriteBEUInt8(0x14);
a_Pkt.WriteBEUInt8(Wolf.GetCollarColor());
+
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(Wolf.GetAge());
break;
} // case mtWolf
-
+
case mtZombie:
{
auto & Zombie = reinterpret_cast<const cZombie &>(a_Mob);
a_Pkt.WriteBEUInt8(0x0c);
- a_Pkt.WriteBEUInt8(Zombie.IsBaby() ? 1 : 0);
+ a_Pkt.WriteBEInt8(Zombie.IsBaby() ? 1 : -1);
a_Pkt.WriteBEUInt8(0x0d);
a_Pkt.WriteBEUInt8(Zombie.IsVillagerZombie() ? 1 : 0);
a_Pkt.WriteBEUInt8(0x0e);
a_Pkt.WriteBEUInt8(Zombie.IsConverting() ? 1 : 0);
break;
} // case mtZombie
+
+ case mtZombiePigman:
+ {
+ auto & ZombiePigman = reinterpret_cast<const cZombiePigman &>(a_Mob);
+ a_Pkt.WriteBEUInt8(0x0c);
+ a_Pkt.WriteBEInt8(ZombiePigman.IsBaby() ? 1 : -1);
+ break;
+ } // case mtZombiePigman
} // switch (a_Mob.GetType())
}
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index 36ed251fe..99774d242 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -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;
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index c89c745a4..574875831 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -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);
}
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 29eddcbc9..491645cff 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -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;
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 0ee33a3bc..e447437d4 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -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:
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 7d9cc93b2..ba921a57e 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -220,7 +220,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(std::chrono::milliseconds a_Dt
case E_BLOCK_DARK_OAK_DOOR:
case E_BLOCK_JUNGLE_DOOR:
case E_BLOCK_SPRUCE_DOOR:
- case E_BLOCK_WOODEN_DOOR:
+ case E_BLOCK_OAK_DOOR:
case E_BLOCK_IRON_DOOR:
{
HandleDoor(dataitr->first.x, dataitr->first.y, dataitr->first.z);
@@ -229,7 +229,7 @@ void cIncrementalRedstoneSimulator::SimulateChunk(std::chrono::milliseconds a_Dt
case E_BLOCK_ACACIA_FENCE_GATE:
case E_BLOCK_BIRCH_FENCE_GATE:
case E_BLOCK_DARK_OAK_FENCE_GATE:
- case E_BLOCK_FENCE_GATE:
+ case E_BLOCK_OAK_FENCE_GATE:
case E_BLOCK_JUNGLE_FENCE_GATE:
case E_BLOCK_SPRUCE_FENCE_GATE:
{
@@ -961,7 +961,7 @@ void cIncrementalRedstoneSimulator::HandleDoor(int a_RelBlockX, int a_RelBlockY,
int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
- typedef GetHandlerCompileTime<E_BLOCK_WOODEN_DOOR>::type DoorHandler;
+ typedef GetHandlerCompileTime<E_BLOCK_OAK_DOOR>::type DoorHandler;
if (AreCoordsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ))
{
diff --git a/src/Simulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator.h
index e4250c0b9..394250800 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.h
+++ b/src/Simulator/IncrementalRedstoneSimulator.h
@@ -272,7 +272,7 @@ private:
case E_BLOCK_DARK_OAK_FENCE_GATE:
case E_BLOCK_DISPENSER:
case E_BLOCK_DROPPER:
- case E_BLOCK_FENCE_GATE:
+ case E_BLOCK_OAK_FENCE_GATE:
case E_BLOCK_HOPPER:
case E_BLOCK_INACTIVE_COMPARATOR:
case E_BLOCK_IRON_DOOR:
@@ -292,7 +292,7 @@ private:
case E_BLOCK_STICKY_PISTON:
case E_BLOCK_TNT:
case E_BLOCK_TRAPDOOR:
- case E_BLOCK_WOODEN_DOOR:
+ case E_BLOCK_OAK_DOOR:
{
return true;
}
@@ -348,7 +348,7 @@ private:
case E_BLOCK_DETECTOR_RAIL:
case E_BLOCK_DISPENSER:
case E_BLOCK_DROPPER:
- case E_BLOCK_FENCE_GATE:
+ case E_BLOCK_OAK_FENCE_GATE:
case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE:
case E_BLOCK_HOPPER:
case E_BLOCK_INACTIVE_COMPARATOR:
@@ -378,7 +378,7 @@ private:
case E_BLOCK_TRIPWIRE_HOOK:
case E_BLOCK_TRIPWIRE:
case E_BLOCK_WOODEN_BUTTON:
- case E_BLOCK_WOODEN_DOOR:
+ case E_BLOCK_OAK_DOOR:
case E_BLOCK_WOODEN_PRESSURE_PLATE:
case E_BLOCK_PISTON:
{
@@ -395,7 +395,7 @@ private:
case E_BLOCK_ACACIA_FENCE_GATE:
case E_BLOCK_BIRCH_FENCE_GATE:
case E_BLOCK_DARK_OAK_FENCE_GATE:
- case E_BLOCK_FENCE_GATE:
+ case E_BLOCK_OAK_FENCE_GATE:
case E_BLOCK_JUNGLE_FENCE_GATE:
case E_BLOCK_SPRUCE_FENCE_GATE:
case E_BLOCK_IRON_TRAPDOOR:
diff --git a/src/World.cpp b/src/World.cpp
index 83a8b6c10..dec335253 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -838,6 +838,7 @@ void cWorld::Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_La
AddQueuedPlayers();
m_ChunkMap->Tick(a_Dt);
+ m_MapManager.TickMaps();
TickClients(static_cast<float>(a_Dt.count()));
TickQueuedBlocks();
@@ -855,7 +856,7 @@ void cWorld::Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_La
SaveAllChunks();
}
- if (m_WorldAge - m_LastUnload > std::chrono::minutes(5)) // Unload every 10 seconds
+ if (m_WorldAge - m_LastUnload > std::chrono::seconds(10)) // Unload every 10 seconds
{
UnloadUnusedChunks();
}
@@ -1393,9 +1394,23 @@ void cWorld::GrowTreeFromSapling(int a_X, int a_Y, int a_Z, NIBBLETYPE a_Sapling
case E_META_SAPLING_APPLE: GetAppleTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
case E_META_SAPLING_BIRCH: GetBirchTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
case E_META_SAPLING_CONIFER: GetConiferTreeImage(a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
- case E_META_SAPLING_JUNGLE: GetJungleTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
case E_META_SAPLING_ACACIA: GetAcaciaTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
- case E_META_SAPLING_DARK_OAK: GetDarkoakTreeImage(a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other); break;
+ case E_META_SAPLING_JUNGLE:
+ {
+ bool IsLarge = GetLargeTreeAdjustment(*this, a_X, a_Y, a_Z, a_SaplingMeta);
+ GetJungleTreeImage (a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other, IsLarge);
+ break;
+ }
+ case E_META_SAPLING_DARK_OAK:
+ {
+ if (!GetLargeTreeAdjustment(*this, a_X, a_Y, a_Z, a_SaplingMeta))
+ {
+ return;
+ }
+
+ GetDarkoakTreeImage(a_X, a_Y, a_Z, Noise, WorldAge, Logs, Other);
+ break;
+ }
}
Other.insert(Other.begin(), Logs.begin(), Logs.end());
Logs.clear();
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 10231ae3b..234c60d62 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -554,6 +554,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
m_Writer.AddInt ("Style", Horse.GetHorseStyle());
m_Writer.AddInt ("ArmorType", Horse.GetHorseArmour());
m_Writer.AddByte("Saddle", Horse.IsSaddled());
+ m_Writer.AddByte("Age", Horse.GetAge());
break;
}
case mtMagmaCube:
@@ -565,6 +566,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
{
m_Writer.AddByte("Sheared", ((const cSheep *)a_Monster)->IsSheared());
m_Writer.AddByte("Color", ((const cSheep *)a_Monster)->GetFurColor());
+ m_Writer.AddByte("Age", ((const cSheep *)a_Monster)->GetAge());
break;
}
case mtSlime:
@@ -580,6 +582,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
case mtVillager:
{
m_Writer.AddInt("Profession", ((const cVillager *)a_Monster)->GetVilType());
+ m_Writer.AddByte("Age", ((const cVillager *)a_Monster)->GetAge());
break;
}
case mtWither:
@@ -601,13 +604,37 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
m_Writer.AddByte("Sitting", Wolf.IsSitting() ? 1 : 0);
m_Writer.AddByte("Angry", Wolf.IsAngry() ? 1 : 0);
m_Writer.AddByte("CollarColor", (unsigned char)Wolf.GetCollarColor());
+ m_Writer.AddByte("Age", Wolf.GetAge());
break;
}
case mtZombie:
{
m_Writer.AddByte("IsVillager", (((const cZombie *)a_Monster)->IsVillagerZombie() ? 1 : 0));
- m_Writer.AddByte("IsBaby", (((const cZombie *)a_Monster)->IsBaby() ? 1 : 0));
m_Writer.AddByte("IsConverting", (((const cZombie *)a_Monster)->IsConverting() ? 1 : 0));
+ m_Writer.AddByte("Age", (((const cZombie *)a_Monster)->GetAge()));
+ break;
+ }
+ case mtZombiePigman:
+ {
+ m_Writer.AddByte("Age", (((const cZombiePigman *)a_Monster)->GetAge()));
+ break;
+ }
+ case mtOcelot:
+ {
+ const cOcelot & Ocelot = *((cOcelot *)a_Monster);
+ m_Writer.AddByte("Age", Ocelot.GetAge());
+ break;
+ }
+ case mtPig:
+ {
+ const cPig & Pig = *((cPig *)a_Monster);
+ m_Writer.AddByte("Age", Pig.GetAge());
+ break;
+ }
+ case mtRabbit:
+ {
+ const cRabbit & Rabbit = *((cRabbit *)a_Monster);
+ m_Writer.AddByte("Age", Rabbit.GetAge());
break;
}
case mtInvalidType:
@@ -621,15 +648,11 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
case mtGuardian:
case mtIronGolem:
case mtMooshroom:
- case mtOcelot:
- case mtPig:
- case mtRabbit:
case mtSilverfish:
case mtSnowGolem:
case mtSpider:
case mtSquid:
case mtWitch:
- case mtZombiePigman:
{
// Other mobs have no special tags.
break;
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 4912d20f6..62918f44e 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -859,7 +859,7 @@ cBlockEntity * cWSSAnvil::LoadBeaconFromNBT(const cParsedNBT & a_NBT, int a_TagI
return nullptr;
}
- std::unique_ptr<cBeaconEntity> Beacon(new cBeaconEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cBeaconEntity> Beacon = cpp14::make_unique<cBeaconEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Levels");
if (CurrentLine >= 0)
@@ -909,7 +909,7 @@ cBlockEntity * cWSSAnvil::LoadChestFromNBT(const cParsedNBT & a_NBT, int a_TagId
{
return nullptr; // Make it an empty chest - the chunk loader will provide an empty cChestEntity for this
}
- std::unique_ptr<cChestEntity> Chest(new cChestEntity(a_BlockX, a_BlockY, a_BlockZ, m_World, a_ChestBlockType));
+ std::unique_ptr<cChestEntity> Chest = cpp14::make_unique<cChestEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World, a_ChestBlockType);
LoadItemGridFromNBT(Chest->GetContents(), a_NBT, Items);
return Chest.release();
}
@@ -926,7 +926,7 @@ cBlockEntity * cWSSAnvil::LoadCommandBlockFromNBT(const cParsedNBT & a_NBT, int
return nullptr;
}
- std::unique_ptr<cCommandBlockEntity> CmdBlock(new cCommandBlockEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cCommandBlockEntity> CmdBlock = cpp14::make_unique<cCommandBlockEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
int currentLine = a_NBT.FindChildByName(a_TagIdx, "Command");
if (currentLine >= 0)
@@ -968,7 +968,7 @@ cBlockEntity * cWSSAnvil::LoadDispenserFromNBT(const cParsedNBT & a_NBT, int a_T
{
return nullptr; // Make it an empty dispenser - the chunk loader will provide an empty cDispenserEntity for this
}
- std::unique_ptr<cDispenserEntity> Dispenser(new cDispenserEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cDispenserEntity> Dispenser = cpp14::make_unique<cDispenserEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
LoadItemGridFromNBT(Dispenser->GetContents(), a_NBT, Items);
return Dispenser.release();
}
@@ -990,7 +990,7 @@ cBlockEntity * cWSSAnvil::LoadDropperFromNBT(const cParsedNBT & a_NBT, int a_Tag
{
return nullptr; // Make it an empty dropper - the chunk loader will provide an empty cDropperEntity for this
}
- std::unique_ptr<cDropperEntity> Dropper(new cDropperEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cDropperEntity> Dropper = cpp14::make_unique<cDropperEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
LoadItemGridFromNBT(Dropper->GetContents(), a_NBT, Items);
return Dropper.release();
}
@@ -1007,7 +1007,7 @@ cBlockEntity * cWSSAnvil::LoadFlowerPotFromNBT(const cParsedNBT & a_NBT, int a_T
return nullptr;
}
- std::unique_ptr<cFlowerPotEntity> FlowerPot(new cFlowerPotEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cFlowerPotEntity> FlowerPot = cpp14::make_unique<cFlowerPotEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
cItem Item;
int currentLine = a_NBT.FindChildByName(a_TagIdx, "Item");
@@ -1051,7 +1051,7 @@ cBlockEntity * cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_Tag
return nullptr; // Make it an empty furnace - the chunk loader will provide an empty cFurnaceEntity for this
}
- std::unique_ptr<cFurnaceEntity> Furnace(new cFurnaceEntity(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, m_World));
+ std::unique_ptr<cFurnaceEntity> Furnace = cpp14::make_unique<cFurnaceEntity>(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, m_World);
Furnace->SetLoading(true);
// Load slots:
@@ -1104,7 +1104,7 @@ cBlockEntity * cWSSAnvil::LoadMobSpawnerFromNBT(const cParsedNBT & a_NBT, int a_
return nullptr;
}
- std::unique_ptr<cMobSpawnerEntity> MobSpawner(new cMobSpawnerEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cMobSpawnerEntity> MobSpawner = cpp14::make_unique<cMobSpawnerEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
// Load entity (MCServer worlds):
int Type = a_NBT.FindChildByName(a_TagIdx, "Entity");
@@ -1157,7 +1157,7 @@ cBlockEntity * cWSSAnvil::LoadHopperFromNBT(const cParsedNBT & a_NBT, int a_TagI
{
return nullptr; // Make it an empty hopper - the chunk loader will provide an empty cHopperEntity for this
}
- std::unique_ptr<cHopperEntity> Hopper(new cHopperEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cHopperEntity> Hopper = cpp14::make_unique<cHopperEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
LoadItemGridFromNBT(Hopper->GetContents(), a_NBT, Items);
return Hopper.release();
}
@@ -1174,7 +1174,7 @@ cBlockEntity * cWSSAnvil::LoadJukeboxFromNBT(const cParsedNBT & a_NBT, int a_Tag
return nullptr;
}
- std::unique_ptr<cJukeboxEntity> Jukebox(new cJukeboxEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cJukeboxEntity> Jukebox = cpp14::make_unique<cJukeboxEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
int Record = a_NBT.FindChildByName(a_TagIdx, "Record");
if (Record >= 0)
{
@@ -1195,7 +1195,7 @@ cBlockEntity * cWSSAnvil::LoadMobHeadFromNBT(const cParsedNBT & a_NBT, int a_Tag
return nullptr;
}
- std::unique_ptr<cMobHeadEntity> MobHead(new cMobHeadEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cMobHeadEntity> MobHead = cpp14::make_unique<cMobHeadEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
int currentLine = a_NBT.FindChildByName(a_TagIdx, "SkullType");
if (currentLine >= 0)
@@ -1230,7 +1230,7 @@ cBlockEntity * cWSSAnvil::LoadNoteBlockFromNBT(const cParsedNBT & a_NBT, int a_T
return nullptr;
}
- std::unique_ptr<cNoteEntity> NoteBlock(new cNoteEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cNoteEntity> NoteBlock = cpp14::make_unique<cNoteEntity>(a_BlockX, a_BlockY, a_BlockZ, m_World);
int note = a_NBT.FindChildByName(a_TagIdx, "note");
if (note >= 0)
{
@@ -1251,7 +1251,7 @@ cBlockEntity * cWSSAnvil::LoadSignFromNBT(const cParsedNBT & a_NBT, int a_TagIdx
return nullptr;
}
- std::unique_ptr<cSignEntity> Sign(new cSignEntity(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, m_World));
+ std::unique_ptr<cSignEntity> Sign = cpp14::make_unique<cSignEntity>(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, m_World);
int currentLine = a_NBT.FindChildByName(a_TagIdx, "Text1");
if (currentLine >= 0)
@@ -1516,7 +1516,7 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cBoat> Boat(new cBoat(0, 0, 0));
+ std::unique_ptr<cBoat> Boat = cpp14::make_unique<cBoat>(0, 0, 0);
if (!LoadEntityBaseFromNBT(*Boat.get(), a_NBT, a_TagIdx))
{
return;
@@ -1530,7 +1530,7 @@ void cWSSAnvil::LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
void cWSSAnvil::LoadEnderCrystalFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cEnderCrystal> EnderCrystal(new cEnderCrystal(0, 0, 0));
+ std::unique_ptr<cEnderCrystal> EnderCrystal = cpp14::make_unique<cEnderCrystal>(0, 0, 0);
if (!LoadEntityBaseFromNBT(*EnderCrystal.get(), a_NBT, a_TagIdx))
{
return;
@@ -1555,7 +1555,7 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
int Type = a_NBT.GetInt(TypeIdx);
NIBBLETYPE Meta = (NIBBLETYPE)a_NBT.GetByte(MetaIdx);
- std::unique_ptr<cFallingBlock> FallingBlock(new cFallingBlock(Vector3i(0, 0, 0), Type, Meta));
+ std::unique_ptr<cFallingBlock> FallingBlock = cpp14::make_unique<cFallingBlock>(Vector3i(0, 0, 0), Type, Meta);
if (!LoadEntityBaseFromNBT(*FallingBlock.get(), a_NBT, a_TagIdx))
{
return;
@@ -1569,7 +1569,7 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
void cWSSAnvil::LoadMinecartRFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cRideableMinecart> Minecart(new cRideableMinecart(0, 0, 0, cItem(), 1)); // TODO: Load the block and the height
+ std::unique_ptr<cRideableMinecart> Minecart = cpp14::make_unique<cRideableMinecart>(0, 0, 0, cItem(), 1); // TODO: Load the block and the height
if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
{
return;
@@ -1588,7 +1588,7 @@ void cWSSAnvil::LoadMinecartCFromNBT(cEntityList & a_Entities, const cParsedNBT
{
return; // Make it an empty chest - the chunk loader will provide an empty cChestEntity for this
}
- std::unique_ptr<cMinecartWithChest> Minecart(new cMinecartWithChest(0, 0, 0));
+ std::unique_ptr<cMinecartWithChest> Minecart = cpp14::make_unique<cMinecartWithChest>(0, 0, 0);
if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
{
return;
@@ -1615,7 +1615,7 @@ void cWSSAnvil::LoadMinecartCFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadMinecartFFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cMinecartWithFurnace> Minecart(new cMinecartWithFurnace(0, 0, 0));
+ std::unique_ptr<cMinecartWithFurnace> Minecart = cpp14::make_unique<cMinecartWithFurnace>(0, 0, 0);
if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
{
return;
@@ -1632,7 +1632,7 @@ void cWSSAnvil::LoadMinecartFFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadMinecartTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cMinecartWithTNT> Minecart(new cMinecartWithTNT(0, 0, 0));
+ std::unique_ptr<cMinecartWithTNT> Minecart = cpp14::make_unique<cMinecartWithTNT>(0, 0, 0);
if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
{
return;
@@ -1649,7 +1649,7 @@ void cWSSAnvil::LoadMinecartTFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadMinecartHFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cMinecartWithHopper> Minecart(new cMinecartWithHopper(0, 0, 0));
+ std::unique_ptr<cMinecartWithHopper> Minecart = cpp14::make_unique<cMinecartWithHopper>(0, 0, 0);
if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
{
return;
@@ -1678,7 +1678,7 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a
return;
}
- std::unique_ptr<cPickup> Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false
+ std::unique_ptr<cPickup> Pickup = cpp14::make_unique<cPickup>(0, 0, 0, Item, false); // Pickup delay doesn't matter, just say false
if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx))
{
return;
@@ -1700,7 +1700,7 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cTNTEntity> TNT(new cTNTEntity(0.0, 0.0, 0.0, 0));
+ std::unique_ptr<cTNTEntity> TNT = cpp14::make_unique<cTNTEntity>(0.0, 0.0, 0.0, 0);
if (!LoadEntityBaseFromNBT(*TNT.get(), a_NBT, a_TagIdx))
{
return;
@@ -1722,7 +1722,7 @@ void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadExpOrbFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cExpOrb> ExpOrb(new cExpOrb(0.0, 0.0, 0.0, 0));
+ std::unique_ptr<cExpOrb> ExpOrb = cpp14::make_unique<cExpOrb>(0.0, 0.0, 0.0, 0);
if (!LoadEntityBaseFromNBT(*ExpOrb.get(), a_NBT, a_TagIdx))
{
return;
@@ -1791,7 +1791,7 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT
return;
}
- std::unique_ptr<cItemFrame> ItemFrame(new cItemFrame(BLOCK_FACE_NONE, 0.0, 0.0, 0.0));
+ std::unique_ptr<cItemFrame> ItemFrame = cpp14::make_unique<cItemFrame>(BLOCK_FACE_NONE, 0.0, 0.0, 0.0);
if (!LoadEntityBaseFromNBT(*ItemFrame.get(), a_NBT, a_TagIdx))
{
return;
@@ -1823,7 +1823,7 @@ void cWSSAnvil::LoadPaintingFromNBT(cEntityList & a_Entities, const cParsedNBT &
return;
}
- std::unique_ptr<cPainting> Painting(new cPainting(a_NBT.GetString(MotiveTag), BLOCK_FACE_NONE, 0.0, 0.0, 0.0));
+ std::unique_ptr<cPainting> Painting = cpp14::make_unique<cPainting>(a_NBT.GetString(MotiveTag), BLOCK_FACE_NONE, 0.0, 0.0, 0.0);
if (!LoadEntityBaseFromNBT(*Painting.get(), a_NBT, a_TagIdx))
{
return;
@@ -1839,7 +1839,7 @@ void cWSSAnvil::LoadPaintingFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cArrowEntity> Arrow(new cArrowEntity(nullptr, 0, 0, 0, Vector3d(0, 0, 0)));
+ std::unique_ptr<cArrowEntity> Arrow = cpp14::make_unique<cArrowEntity>(nullptr, 0, 0, 0, Vector3d(0, 0, 0));
if (!LoadProjectileBaseFromNBT(*Arrow.get(), a_NBT, a_TagIdx))
{
return;
@@ -1909,7 +1909,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cSplashPotionEntity> SplashPotion(new cSplashPotionEntity(nullptr, 0, 0, 0, Vector3d(0, 0, 0), cItem()));
+ std::unique_ptr<cSplashPotionEntity> SplashPotion = cpp14::make_unique<cSplashPotionEntity>(nullptr, 0, 0, 0, Vector3d(0, 0, 0), cItem());
if (!LoadProjectileBaseFromNBT(*SplashPotion.get(), a_NBT, a_TagIdx))
{
return;
@@ -1933,7 +1933,7 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN
void cWSSAnvil::LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cThrownSnowballEntity> Snowball(new cThrownSnowballEntity(nullptr, 0, 0, 0, Vector3d(0, 0, 0)));
+ std::unique_ptr<cThrownSnowballEntity> Snowball = cpp14::make_unique<cThrownSnowballEntity>(nullptr, 0, 0, 0, Vector3d(0, 0, 0));
if (!LoadProjectileBaseFromNBT(*Snowball.get(), a_NBT, a_TagIdx))
{
return;
@@ -1949,7 +1949,7 @@ void cWSSAnvil::LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadEggFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cThrownEggEntity> Egg(new cThrownEggEntity(nullptr, 0, 0, 0, Vector3d(0, 0, 0)));
+ std::unique_ptr<cThrownEggEntity> Egg = cpp14::make_unique<cThrownEggEntity>(nullptr, 0, 0, 0, Vector3d(0, 0, 0));
if (!LoadProjectileBaseFromNBT(*Egg.get(), a_NBT, a_TagIdx))
{
return;
@@ -1965,7 +1965,7 @@ void cWSSAnvil::LoadEggFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadFireballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cGhastFireballEntity> Fireball(new cGhastFireballEntity(nullptr, 0, 0, 0, Vector3d(0, 0, 0)));
+ std::unique_ptr<cGhastFireballEntity> Fireball = cpp14::make_unique<cGhastFireballEntity>(nullptr, 0, 0, 0, Vector3d(0, 0, 0));
if (!LoadProjectileBaseFromNBT(*Fireball.get(), a_NBT, a_TagIdx))
{
return;
@@ -1981,7 +1981,7 @@ void cWSSAnvil::LoadFireballFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadFireChargeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cFireChargeEntity> FireCharge(new cFireChargeEntity(nullptr, 0, 0, 0, Vector3d(0, 0, 0)));
+ std::unique_ptr<cFireChargeEntity> FireCharge = cpp14::make_unique<cFireChargeEntity>(nullptr, 0, 0, 0, Vector3d(0, 0, 0));
if (!LoadProjectileBaseFromNBT(*FireCharge.get(), a_NBT, a_TagIdx))
{
return;
@@ -1997,7 +1997,7 @@ void cWSSAnvil::LoadFireChargeFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadThrownEnderpearlFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cThrownEnderPearlEntity> Enderpearl(new cThrownEnderPearlEntity(nullptr, 0, 0, 0, Vector3d(0, 0, 0)));
+ std::unique_ptr<cThrownEnderPearlEntity> Enderpearl = cpp14::make_unique<cThrownEnderPearlEntity>(nullptr, 0, 0, 0, Vector3d(0, 0, 0));
if (!LoadProjectileBaseFromNBT(*Enderpearl.get(), a_NBT, a_TagIdx))
{
return;
@@ -2013,7 +2013,7 @@ void cWSSAnvil::LoadThrownEnderpearlFromNBT(cEntityList & a_Entities, const cPar
void cWSSAnvil::LoadBatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cBat> Monster(new cBat());
+ std::unique_ptr<cBat> Monster = cpp14::make_unique<cBat>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2033,7 +2033,7 @@ void cWSSAnvil::LoadBatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadBlazeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cBlaze> Monster(new cBlaze());
+ std::unique_ptr<cBlaze> Monster = cpp14::make_unique<cBlaze>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2053,7 +2053,7 @@ void cWSSAnvil::LoadBlazeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadCaveSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cCaveSpider> Monster(new cCaveSpider());
+ std::unique_ptr<cCaveSpider> Monster = cpp14::make_unique<cCaveSpider>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2073,7 +2073,7 @@ void cWSSAnvil::LoadCaveSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadChickenFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cChicken> Monster(new cChicken());
+ std::unique_ptr<cChicken> Monster = cpp14::make_unique<cChicken>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2093,7 +2093,7 @@ void cWSSAnvil::LoadChickenFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadCowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cCow> Monster(new cCow());
+ std::unique_ptr<cCow> Monster = cpp14::make_unique<cCow>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2113,7 +2113,7 @@ void cWSSAnvil::LoadCowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadCreeperFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cCreeper> Monster(new cCreeper());
+ std::unique_ptr<cCreeper> Monster = cpp14::make_unique<cCreeper>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2133,7 +2133,7 @@ void cWSSAnvil::LoadCreeperFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadEnderDragonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cEnderDragon> Monster(new cEnderDragon());
+ std::unique_ptr<cEnderDragon> Monster = cpp14::make_unique<cEnderDragon>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2153,7 +2153,7 @@ void cWSSAnvil::LoadEnderDragonFromNBT(cEntityList & a_Entities, const cParsedNB
void cWSSAnvil::LoadEndermanFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cEnderman> Monster(new cEnderman());
+ std::unique_ptr<cEnderman> Monster = cpp14::make_unique<cEnderman>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2173,7 +2173,7 @@ void cWSSAnvil::LoadEndermanFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadGhastFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cGhast> Monster(new cGhast());
+ std::unique_ptr<cGhast> Monster = cpp14::make_unique<cGhast>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2193,7 +2193,7 @@ void cWSSAnvil::LoadGhastFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadGiantFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cGiant> Monster(new cGiant());
+ std::unique_ptr<cGiant> Monster = cpp14::make_unique<cGiant>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2213,7 +2213,7 @@ void cWSSAnvil::LoadGiantFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadGuardianFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cGuardian> Monster(new cGuardian());
+ std::unique_ptr<cGuardian> Monster = cpp14::make_unique<cGuardian>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2245,7 +2245,7 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int Color = a_NBT.GetInt(ColorIdx);
int Style = a_NBT.GetInt(StyleIdx);
- std::unique_ptr<cHorse> Monster(new cHorse(Type, Color, Style, 1));
+ std::unique_ptr<cHorse> Monster = cpp14::make_unique<cHorse>(Type, Color, Style, 1);
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
@@ -2256,7 +2256,14 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
{
return;
}
-
+
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (AgeableIdx > 0)
+ {
+ Byte Age = a_NBT.GetByte(AgeableIdx);
+ Monster->SetAge(Age);
+ }
+
a_Entities.push_back(Monster.release());
}
@@ -2266,7 +2273,7 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadIronGolemFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cIronGolem> Monster(new cIronGolem());
+ std::unique_ptr<cIronGolem> Monster = cpp14::make_unique<cIronGolem>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2295,7 +2302,7 @@ void cWSSAnvil::LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT
int Size = a_NBT.GetInt(SizeIdx);
- std::unique_ptr<cMagmaCube> Monster(new cMagmaCube(Size));
+ std::unique_ptr<cMagmaCube> Monster = cpp14::make_unique<cMagmaCube>(Size);
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2315,7 +2322,7 @@ void cWSSAnvil::LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadMooshroomFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cMooshroom> Monster(new cMooshroom());
+ std::unique_ptr<cMooshroom> Monster = cpp14::make_unique<cMooshroom>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2335,7 +2342,7 @@ void cWSSAnvil::LoadMooshroomFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cOcelot> Monster(new cOcelot());
+ std::unique_ptr<cOcelot> Monster = cpp14::make_unique<cOcelot>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2346,6 +2353,13 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a
return;
}
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (AgeableIdx > 0)
+ {
+ Byte Age = a_NBT.GetByte(AgeableIdx);
+ Monster->SetAge(Age);
+ }
+
a_Entities.push_back(Monster.release());
}
@@ -2355,7 +2369,7 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cPig> Monster(new cPig());
+ std::unique_ptr<cPig> Monster = cpp14::make_unique<cPig>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2365,7 +2379,14 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
{
return;
}
-
+
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (AgeableIdx > 0)
+ {
+ Byte Age = a_NBT.GetByte(AgeableIdx);
+ Monster->SetAge(Age);
+ }
+
a_Entities.push_back(Monster.release());
}
@@ -2375,7 +2396,7 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cRabbit> Monster(new cRabbit());
+ std::unique_ptr<cRabbit> Monster = cpp14::make_unique<cRabbit>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2385,7 +2406,14 @@ void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{
return;
}
-
+
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (AgeableIdx > 0)
+ {
+ Byte Age = a_NBT.GetByte(AgeableIdx);
+ Monster->SetAge(Age);
+ }
+
a_Entities.push_back(Monster.release());
}
@@ -2402,7 +2430,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
Color = (int)a_NBT.GetByte(ColorIdx);
}
- std::unique_ptr<cSheep> Monster(new cSheep(Color));
+ std::unique_ptr<cSheep> Monster = cpp14::make_unique<cSheep>(Color);
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2418,7 +2446,14 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
{
Monster->SetSheared(a_NBT.GetByte(ShearedIdx) != 0);
}
-
+
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (AgeableIdx > 0)
+ {
+ Byte Age = a_NBT.GetByte(AgeableIdx);
+ Monster->SetAge(Age);
+ }
+
a_Entities.push_back(Monster.release());
}
@@ -2428,7 +2463,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadSilverfishFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cSilverfish> Monster(new cSilverfish());
+ std::unique_ptr<cSilverfish> Monster = cpp14::make_unique<cSilverfish>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2456,7 +2491,7 @@ void cWSSAnvil::LoadSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT &
bool Type = ((a_NBT.GetByte(TypeIdx) == 1) ? true : false);
- std::unique_ptr<cSkeleton> Monster(new cSkeleton(Type));
+ std::unique_ptr<cSkeleton> Monster = cpp14::make_unique<cSkeleton>(Type);
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2485,7 +2520,7 @@ void cWSSAnvil::LoadSlimeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int Size = a_NBT.GetInt(SizeIdx);
- std::unique_ptr<cSlime> Monster(new cSlime(Size));
+ std::unique_ptr<cSlime> Monster = cpp14::make_unique<cSlime>(Size);
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2505,7 +2540,7 @@ void cWSSAnvil::LoadSlimeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadSnowGolemFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cSnowGolem> Monster(new cSnowGolem());
+ std::unique_ptr<cSnowGolem> Monster = cpp14::make_unique<cSnowGolem>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2525,7 +2560,7 @@ void cWSSAnvil::LoadSnowGolemFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cSpider> Monster(new cSpider());
+ std::unique_ptr<cSpider> Monster = cpp14::make_unique<cSpider>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2545,7 +2580,7 @@ void cWSSAnvil::LoadSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadSquidFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cSquid> Monster(new cSquid());
+ std::unique_ptr<cSquid> Monster = cpp14::make_unique<cSquid>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2573,7 +2608,7 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT &
int Type = a_NBT.GetInt(TypeIdx);
- std::unique_ptr<cVillager> Monster(new cVillager(cVillager::eVillagerType(Type)));
+ std::unique_ptr<cVillager> Monster = cpp14::make_unique<cVillager>(cVillager::eVillagerType(Type));
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2583,7 +2618,15 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT &
{
return;
}
-
+
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (AgeableIdx > 0)
+ {
+ Byte Age = a_NBT.GetByte(AgeableIdx);
+ Monster->SetAge(Age);
+ }
+
+
a_Entities.push_back(Monster.release());
}
@@ -2593,7 +2636,7 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadWitchFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cWitch> Monster(new cWitch());
+ std::unique_ptr<cWitch> Monster = cpp14::make_unique<cWitch>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2613,7 +2656,7 @@ void cWSSAnvil::LoadWitchFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cWither> Monster(new cWither());
+ std::unique_ptr<cWither> Monster = cpp14::make_unique<cWither>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2639,7 +2682,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cWolf> Monster(new cWolf());
+ std::unique_ptr<cWolf> Monster = cpp14::make_unique<cWolf>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2683,6 +2726,14 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
}
}
}
+
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (AgeableIdx > 0)
+ {
+ Byte Age = a_NBT.GetByte(AgeableIdx);
+ Monster->SetAge(Age);
+ }
+
a_Entities.push_back(Monster.release());
}
@@ -2700,7 +2751,7 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a
bool IsVillagerZombie = ((a_NBT.GetByte(IsVillagerIdx) == 1) ? true : false);
- std::unique_ptr<cZombie> Monster(new cZombie(IsVillagerZombie));
+ std::unique_ptr<cZombie> Monster = cpp14::make_unique<cZombie>(IsVillagerZombie);
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2710,7 +2761,14 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{
return;
}
-
+
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (AgeableIdx > 0)
+ {
+ Byte Age = a_NBT.GetByte(AgeableIdx);
+ Monster->SetAge(Age);
+ }
+
a_Entities.push_back(Monster.release());
}
@@ -2720,7 +2778,7 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::unique_ptr<cZombiePigman> Monster(new cZombiePigman());
+ std::unique_ptr<cZombiePigman> Monster = cpp14::make_unique<cZombiePigman>();
if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
{
return;
@@ -2730,7 +2788,14 @@ void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT
{
return;
}
-
+
+ int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (AgeableIdx > 0)
+ {
+ Byte Age = a_NBT.GetByte(AgeableIdx);
+ Monster->SetAge(Age);
+ }
+
a_Entities.push_back(Monster.release());
}
diff --git a/tests/LoadablePieces/Stubs.cpp b/tests/LoadablePieces/Stubs.cpp
index 3f4623850..26ee06769 100644
--- a/tests/LoadablePieces/Stubs.cpp
+++ b/tests/LoadablePieces/Stubs.cpp
@@ -237,6 +237,15 @@ void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterf
+ColourID cBlockHandler::GetMapBaseColourID(NIBBLETYPE a_Meta)
+{
+ return 0;
+}
+
+
+
+
+
cBlockEntity * cBlockEntity::CreateByBlockType(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
{
return nullptr;