summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-10-23 08:40:39 +0200
committerMattes D <github@xoft.cz>2014-10-23 08:40:39 +0200
commitf8c54f4243049abbcafff1e96f994f742ea9f50d (patch)
tree67fe10bfea90cbb21952039bd795666682d43ad5
parentCompile fix? (diff)
parentMerge pull request #1559 from mc-server/nullptr (diff)
downloadcuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.gz
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.bz2
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.lz
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.xz
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.tar.zst
cuberite-f8c54f4243049abbcafff1e96f994f742ea9f50d.zip
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/APIDump/Classes/Projectiles.lua65
m---------MCServer/Plugins/Core0
-rw-r--r--MCServer/Plugins/InfoDump.lua6
m---------MCServer/Plugins/ProtectionAreas0
-rw-r--r--MCServer/webadmin/template.lua2
-rw-r--r--src/Bindings/AllToLua.pkg14
-rw-r--r--src/Bindings/CMakeLists.txt208
-rw-r--r--src/Bindings/LuaState.cpp55
-rw-r--r--src/BlockEntities/DispenserEntity.cpp7
-rw-r--r--src/BlockEntities/FlowerPotEntity.cpp10
-rw-r--r--src/BlockEntities/FurnaceEntity.cpp36
-rw-r--r--src/BlockEntities/FurnaceEntity.h2
-rw-r--r--src/BlockEntities/HopperEntity.cpp66
-rw-r--r--src/BlockEntities/JukeboxEntity.cpp6
-rw-r--r--src/BlockEntities/SignEntity.cpp8
-rw-r--r--src/Blocks/BlockDeadBush.h24
-rw-r--r--src/Blocks/BlockTallGrass.h52
-rw-r--r--src/Blocks/BlockVine.h20
-rw-r--r--src/ChunkDef.h64
-rw-r--r--src/Defines.h38
-rw-r--r--src/Entities/ArrowEntity.h45
-rw-r--r--src/Entities/ExpBottleEntity.h17
-rw-r--r--src/Entities/FireChargeEntity.h15
-rw-r--r--src/Entities/FireworkEntity.cpp13
-rw-r--r--src/Entities/FireworkEntity.h32
-rw-r--r--src/Entities/GhastFireballEntity.h15
-rw-r--r--src/Entities/HangingEntity.cpp30
-rw-r--r--src/Entities/HangingEntity.h29
-rw-r--r--src/Entities/ItemFrame.cpp16
-rw-r--r--src/Entities/ItemFrame.h17
-rw-r--r--src/Entities/Painting.h13
-rw-r--r--src/Entities/Pickup.h10
-rw-r--r--src/Entities/ProjectileEntity.h20
-rw-r--r--src/Entities/SplashPotionEntity.h18
-rw-r--r--src/Entities/ThrownEggEntity.cpp21
-rw-r--r--src/Entities/ThrownEggEntity.h34
-rw-r--r--src/Entities/ThrownEnderPearlEntity.cpp22
-rw-r--r--src/Entities/ThrownEnderPearlEntity.h34
-rw-r--r--src/Entities/ThrownSnowballEntity.cpp25
-rw-r--r--src/Entities/ThrownSnowballEntity.h34
-rw-r--r--src/Entities/WitherSkullEntity.h12
-rw-r--r--src/Generating/ComposableGenerator.cpp6
-rw-r--r--src/Items/ItemHandler.cpp2
-rw-r--r--src/Items/ItemShears.h35
-rw-r--r--src/Mobs/Monster.h60
-rw-r--r--src/OSSupport/IsThread.h12
-rw-r--r--src/Protocol/Protocol17x.cpp2
-rw-r--r--src/Protocol/Protocol18x.cpp2
-rw-r--r--src/UI/SlotArea.cpp2
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp24
-rw-r--r--src/WorldStorage/WSSAnvil.cpp45
51 files changed, 819 insertions, 526 deletions
diff --git a/MCServer/Plugins/APIDump/Classes/Projectiles.lua b/MCServer/Plugins/APIDump/Classes/Projectiles.lua
index 08c981e5d..aef6a048c 100644
--- a/MCServer/Plugins/APIDump/Classes/Projectiles.lua
+++ b/MCServer/Plugins/APIDump/Classes/Projectiles.lua
@@ -35,12 +35,49 @@ return
Inherits = "cProjectileEntity",
}, -- cArrowEntity
+ cExpBottleEntity =
+ {
+ Desc = [[
+ Represents a thrown ExpBottle. A subclass of the {{cProjectileEntity}}.
+ ]],
+ Functions =
+ {
+ },
+ Inherits = "cProjectileEntity",
+ }, -- cExpBottleEntity
+
cFireChargeEntity =
{
- Desc = "",
+ Desc = [[
+ Represents a fire charge that has been shot by a Blaze or a {{cDispenserEntity|Dispenser}}. A subclass
+ of the {{cProjectileEntity}}.
+ ]],
Functions = {},
Inherits = "cProjectileEntity",
}, -- cFireChargeEntity
+
+ cFireworkEntity =
+ {
+ Desc = [[
+ Represents a firework rocket.
+ ]],
+ Functions =
+ {
+ GetItem = { Params = "", Return = "{{cItem}}", Notes = "Returns the item that has been used to create the firework rocket. The item's m_FireworkItem member contains all the firework-related data." },
+ GetTicksToExplosion = { Params = "", Return = "number", Notes = "Returns the number of ticks left until the firework explodes." },
+ SetItem = { Params = "{{cItem}}", Return = "", Notes = "Sets a new item to be used for the firework." },
+ SetTicksToExplosion = { Params = "NumTicks", Return = "", Notes = "Sets the number of ticks left until the firework explodes." },
+ },
+
+ Inherits = "cProjectileEntity",
+ }, -- cFireworkEntity
+
+ cFloater =
+ {
+ Desc = "",
+ Functions = {},
+ Inherits = "cProjectileEntity",
+ }, -- cFloater
cGhastFireballEntity =
{
@@ -64,14 +101,14 @@ return
pkArrow = { Notes = "The projectile is an {{cArrowEntity|arrow}}" },
pkEgg = { Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}" },
pkEnderPearl = { Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}" },
- pkExpBottle = { Notes = "The projectile is a thrown exp bottle (NYI)" },
+ pkExpBottle = { Notes = "The projectile is a {{cExpBottleEntity|thrown exp bottle}}" },
pkFireCharge = { Notes = "The projectile is a {{cFireChargeEntity|fire charge}}" },
- pkFirework = { Notes = "The projectile is a (flying) firework (NYI)" },
- pkFishingFloat = { Notes = "The projectile is a fishing float (NYI)" },
+ pkFirework = { Notes = "The projectile is a (flying) {{cFireworkEntity|firework}}" },
+ pkFishingFloat = { Notes = "The projectile is a {{cFloater|fishing float}}" },
pkGhastFireball = { Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}" },
pkSnowball = { Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}" },
- pkSplashPotion = { Notes = "The projectile is a thrown splash potion (NYI)" },
- pkWitherSkull = { Notes = "The projectile is a wither skull (NYI)" },
+ pkSplashPotion = { Notes = "The projectile is a {{cSplashPotionEntity|thrown splash potion}}" },
+ pkWitherSkull = { Notes = "The projectile is a {{cWitherSkullEntity|wither skull}}" },
},
ConstantGroups =
{
@@ -84,6 +121,13 @@ return
Inherits = "cEntity",
}, -- cProjectileEntity
+ cSplashPotionEntity =
+ {
+ Desc = "",
+ Functions = {},
+ Inherits = "cProjectileEntity",
+ }, -- cSplashPotionEntity
+
cThrownEggEntity =
{
Desc = "",
@@ -97,13 +141,20 @@ return
Functions = {},
Inherits = "cProjectileEntity",
}, -- cThrownEnderPearlEntity
-
+
cThrownSnowballEntity =
{
Desc = "",
Functions = {},
Inherits = "cProjectileEntity",
}, -- cThrownSnowballEntity
+
+ cWitherSkullEntity =
+ {
+ Desc = "",
+ Functions = {},
+ Inherits = "cProjectileEntity",
+ }, -- cWitherSkullEntity
}
diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core
-Subproject f8c2531fbef9bfd0b6f024d4d3319384a70a083
+Subproject 4702471943511f641458c7e8e89b430a723f43e
diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua
index bc9bab767..de1d1f451 100644
--- a/MCServer/Plugins/InfoDump.lua
+++ b/MCServer/Plugins/InfoDump.lua
@@ -625,7 +625,11 @@ local function LoadPluginInfo(a_FolderName)
-- This is Lua-5.1-specific and won't work in Lua 5.2!
local Sandbox = {}
setfenv(cfg, Sandbox)
- cfg()
+ local isSuccess, errMsg = pcall(cfg)
+ if not(isSuccess) then
+ return nil, "Cannot load Info.lua: " .. (errMsg or "<unknown error>")
+ end
+
if (Sandbox.g_PluginInfo == nil) then
return nil, "Info.lua doesn't contain the g_PluginInfo declaration"
end
diff --git a/MCServer/Plugins/ProtectionAreas b/MCServer/Plugins/ProtectionAreas
-Subproject 7765048fa740b8f119db72a4ccc546504f86b2a
+Subproject 624580e5b522ba2799dfe5b5902b4002b1a8da3
diff --git a/MCServer/webadmin/template.lua b/MCServer/webadmin/template.lua
index 84a50b055..05ca224b1 100644
--- a/MCServer/webadmin/template.lua
+++ b/MCServer/webadmin/template.lua
@@ -33,7 +33,7 @@ function GetDefaultPage()
local AllPlugins = PM:GetAllPlugins()
for key,value in pairs(AllPlugins) do
if( value ~= nil and value ~= false ) then
- Content = Content .. "<li>" .. key .. " V." .. value:GetVersion() .. "</li>"
+ Content = Content .. "<li>" .. key .. " (version " .. value:GetVersion() .. ")</li>"
end
end
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 73de98e22..1bff26b0e 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -33,15 +33,27 @@ $cfile "../StringUtils.h"
$cfile "../Defines.h"
$cfile "../ChatColor.h"
$cfile "../ClientHandle.h"
+$cfile "../Entities/ArrowEntity.h"
$cfile "../Entities/Entity.h"
+$cfile "../Entities/EntityEffect.h"
+$cfile "../Entities/ExpBottleEntity.h"
+$cfile "../Entities/FireChargeEntity.h"
+$cfile "../Entities/FireworkEntity.h"
$cfile "../Entities/Floater.h"
+$cfile "../Entities/GhastFireballEntity.h"
+$cfile "../Entities/HangingEntity.h"
+$cfile "../Entities/ItemFrame.h"
$cfile "../Entities/Pawn.h"
$cfile "../Entities/Player.h"
$cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h"
+$cfile "../Entities/SplashPotionEntity.h"
+$cfile "../Entities/ThrownEggEntity.h"
+$cfile "../Entities/ThrownEnderPearlEntity.h"
+$cfile "../Entities/ThrownSnowballEntity.h"
$cfile "../Entities/TNTEntity.h"
-$cfile "../Entities/EntityEffect.h"
+$cfile "../Entities/WitherSkullEntity.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
index 5c56231c6..d47579cd6 100644
--- a/src/Bindings/CMakeLists.txt
+++ b/src/Bindings/CMakeLists.txt
@@ -5,131 +5,133 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
include_directories (".")
SET (SRCS
- Bindings.cpp
- DeprecatedBindings.cpp
- LuaChunkStay.cpp
- LuaState.cpp
- LuaWindow.cpp
- ManualBindings.cpp
- ManualBindings_RankManager.cpp
- Plugin.cpp
- PluginLua.cpp
- PluginManager.cpp
- WebPlugin.cpp
+ Bindings.cpp
+ DeprecatedBindings.cpp
+ LuaChunkStay.cpp
+ LuaState.cpp
+ LuaWindow.cpp
+ ManualBindings.cpp
+ ManualBindings_RankManager.cpp
+ Plugin.cpp
+ PluginLua.cpp
+ PluginManager.cpp
+ WebPlugin.cpp
)
SET (HDRS
- Bindings.h
- DeprecatedBindings.h
- LuaChunkStay.h
- LuaFunctions.h
- LuaState.h
- LuaWindow.h
- ManualBindings.h
- Plugin.h
- PluginLua.h
- PluginManager.h
- WebPlugin.h
- tolua++.h
+ Bindings.h
+ DeprecatedBindings.h
+ LuaChunkStay.h
+ LuaFunctions.h
+ LuaState.h
+ LuaWindow.h
+ ManualBindings.h
+ Plugin.h
+ PluginLua.h
+ PluginManager.h
+ WebPlugin.h
+ tolua++.h
)
# List all the files that are generated as part of the Bindings build process
set (BINDING_OUTPUTS
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
)
set(BINDING_DEPENDENCIES
- tolua
- ../Bindings/virtual_method_hooks.lua
- ../Bindings/AllToLua.pkg
- ../Bindings/LuaFunctions.h
- ../Bindings/LuaWindow.h
- ../Bindings/Plugin.h
- ../Bindings/PluginLua.h
- ../Bindings/PluginManager.h
- ../Bindings/WebPlugin.h
- ../BiomeDef.h
- ../BlockArea.h
+ tolua
+ ../Bindings/virtual_method_hooks.lua
+ ../Bindings/AllToLua.pkg
+ ../Bindings/LuaFunctions.h
+ ../Bindings/LuaWindow.h
+ ../Bindings/Plugin.h
+ ../Bindings/PluginLua.h
+ ../Bindings/PluginManager.h
+ ../Bindings/WebPlugin.h
+ ../BiomeDef.h
+ ../BlockArea.h
../BlockEntities/BeaconEntity.h
- ../BlockEntities/BlockEntity.h
- ../BlockEntities/BlockEntityWithItems.h
- ../BlockEntities/ChestEntity.h
- ../BlockEntities/DispenserEntity.h
- ../BlockEntities/DropSpenserEntity.h
- ../BlockEntities/DropperEntity.h
- ../BlockEntities/FurnaceEntity.h
- ../BlockEntities/HopperEntity.h
- ../BlockEntities/JukeboxEntity.h
- ../BlockEntities/NoteEntity.h
- ../BlockEntities/SignEntity.h
- ../BlockEntities/MobHeadEntity.h
- ../BlockEntities/FlowerPotEntity.h
- ../BlockID.h
- ../BoundingBox.h
- ../ChatColor.h
- ../ChunkDef.h
- ../ClientHandle.h
- ../CraftingRecipes.h
- ../Cuboid.h
- ../Defines.h
- ../Enchantments.h
- ../Entities/EntityEffect.h
- ../Entities/Entity.h
- ../Entities/Floater.h
- ../Entities/Pawn.h
- ../Entities/Painting.h
- ../Entities/Pickup.h
- ../Entities/Player.h
- ../Entities/ProjectileEntity.h
- ../Entities/ArrowEntity.h
- ../Entities/ThrownEggEntity.h
- ../Entities/ThrownEnderPearlEntity.h
- ../Entities/ExpBottleEntity.h
- ../Entities/ThrownSnowballEntity.h
- ../Entities/FireChargeEntity.h
- ../Entities/FireworkEntity.h
- ../Entities/GhastFireballEntity.h
- ../Entities/TNTEntity.h
- ../Entities/ExpOrb.h
- ../Entities/HangingEntity.h
- ../Entities/ItemFrame.h
- ../Generating/ChunkDesc.h
- ../Inventory.h
- ../Item.h
- ../ItemGrid.h
- ../Mobs/Monster.h
- ../OSSupport/File.h
- ../Root.h
- ../Server.h
- ../StringUtils.h
- ../Tracer.h
- ../UI/Window.h
- ../Vector3.h
- ../WebAdmin.h
- ../World.h
+ ../BlockEntities/BlockEntity.h
+ ../BlockEntities/BlockEntityWithItems.h
+ ../BlockEntities/ChestEntity.h
+ ../BlockEntities/DispenserEntity.h
+ ../BlockEntities/DropSpenserEntity.h
+ ../BlockEntities/DropperEntity.h
+ ../BlockEntities/FurnaceEntity.h
+ ../BlockEntities/HopperEntity.h
+ ../BlockEntities/JukeboxEntity.h
+ ../BlockEntities/NoteEntity.h
+ ../BlockEntities/SignEntity.h
+ ../BlockEntities/MobHeadEntity.h
+ ../BlockEntities/FlowerPotEntity.h
+ ../BlockID.h
+ ../BoundingBox.h
+ ../ChatColor.h
+ ../ChunkDef.h
+ ../ClientHandle.h
+ ../CraftingRecipes.h
+ ../Cuboid.h
+ ../Defines.h
+ ../Enchantments.h
+ ../Entities/ArrowEntity.h
+ ../Entities/Entity.h
+ ../Entities/EntityEffect.h
+ ../Entities/ExpBottleEntity.h
+ ../Entities/FireChargeEntity.h
+ ../Entities/FireworkEntity.h
+ ../Entities/Floater.h
+ ../Entities/GhastFireballEntity.h
+ ../Entities/HangingEntity.h
+ ../Entities/ItemFrame.h
+ ../Entities/Pawn.h
+ ../Entities/Player.h
+ ../Entities/Painting.h
+ ../Entities/Pickup.h
+ ../Entities/ProjectileEntity.h
+ ../Entities/SplashPotionEntity.h
+ ../Entities/ThrownEggEntity.h
+ ../Entities/ThrownEnderPearlEntity.h
+ ../Entities/ThrownSnowballEntity.h
+ ../Entities/TNTEntity.h
+ ../Entities/WitherSkullEntity.h
+ ../Generating/ChunkDesc.h
+ ../Inventory.h
+ ../Item.h
+ ../ItemGrid.h
+ ../Mobs/Monster.h
+ ../OSSupport/File.h
+ ../Root.h
+ ../Server.h
+ ../StringUtils.h
+ ../Tracer.h
+ ../UI/Window.h
+ ../Vector3.h
+ ../WebAdmin.h
+ ../World.h
)
if (NOT MSVC)
- ADD_CUSTOM_COMMAND(
- # add any new generated bindings here
- OUTPUT ${BINDING_OUTPUTS}
+ ADD_CUSTOM_COMMAND(
+ # add any new generated bindings here
+ OUTPUT ${BINDING_OUTPUTS}
- # Regenerate bindings:
- COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ # Regenerate bindings:
+ COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- # add any new generation dependencies here
- DEPENDS ${BINDING_DEPENDENCIES}
- )
+ # add any new generation dependencies here
+ DEPENDS ${BINDING_DEPENDENCIES}
+ )
endif ()
+
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if(NOT MSVC)
- add_library(Bindings ${SRCS} ${HDRS})
+ add_library(Bindings ${SRCS} ${HDRS})
- target_link_libraries(Bindings lua sqlite tolualib polarssl)
+ target_link_libraries(Bindings lua sqlite tolualib polarssl)
endif()
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 3b4ce3376..2f5d173fd 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -562,16 +562,57 @@ void cLuaState::Push(cEntity * a_Entity)
{
lua_pushnil(m_LuaState);
}
- else if (a_Entity->IsMob())
- {
- // Don't push specific mob types, as those are not exported in the API:
- tolua_pushusertype(m_LuaState, a_Entity, "cMonster");
- }
else
{
- // Push the specific class type:
- tolua_pushusertype(m_LuaState, a_Entity, a_Entity->GetClass());
+ switch (a_Entity->GetEntityType())
+ {
+ case cEntity::etMonster:
+ {
+ // Don't push specific mob types, as those are not exported in the API:
+ tolua_pushusertype(m_LuaState, a_Entity, "cMonster");
+ break;
+ }
+ case cEntity::etPlayer:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, "cPlayer");
+ break;
+ }
+ case cEntity::etPickup:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, "cPickup");
+ break;
+ }
+ case cEntity::etTNT:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, "cTNTEntity");
+ break;
+ }
+ case cEntity::etProjectile:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, a_Entity->GetClass());
+ break;
+ }
+ case cEntity::etFloater:
+ {
+ tolua_pushusertype(m_LuaState, a_Entity, "cFloater");
+ break;
+ }
+
+ case cEntity::etEntity:
+ case cEntity::etEnderCrystal:
+ case cEntity::etFallingBlock:
+ case cEntity::etMinecart:
+ case cEntity::etBoat:
+ case cEntity::etExpOrb:
+ case cEntity::etItemFrame:
+ case cEntity::etPainting:
+ {
+ // Push the generic entity class type:
+ tolua_pushusertype(m_LuaState, a_Entity, "cEntity");
+ }
+ } // switch (EntityType)
}
+
m_NumCurrentFunctionArgs += 1;
}
diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp
index 82c234a14..42a0476b6 100644
--- a/src/BlockEntities/DispenserEntity.cpp
+++ b/src/BlockEntities/DispenserEntity.cpp
@@ -105,7 +105,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
{
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
- if (m_World->SpawnMob(MobX, DispY, MobZ, (eMonsterType)m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0)
+ if (m_World->SpawnMob(MobX, DispY, MobZ, static_cast<eMonsterType>(m_Contents.GetSlot(a_SlotNum).m_ItemDamage)) >= 0)
{
m_Contents.ChangeSlotCount(a_SlotNum, -1);
}
@@ -190,7 +190,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
void cDispenserEntity::SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_ShootVector)
{
- m_World->CreateProjectile((double)a_BlockX + 0.5, (double)a_BlockY + 0.5, (double)a_BlockZ + 0.5, a_Kind, nullptr, nullptr, &a_ShootVector);
+ m_World->CreateProjectile(static_cast<double>(a_BlockX + 0.5), static_cast<double>(a_BlockY + 0.5), static_cast<double>(a_BlockZ + 0.5), a_Kind, nullptr, nullptr, &a_ShootVector);
}
@@ -275,6 +275,3 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum
m_Contents.AddItem(EmptyBucket);
return true;
}
-
-
-
diff --git a/src/BlockEntities/FlowerPotEntity.cpp b/src/BlockEntities/FlowerPotEntity.cpp
index 9db3b268b..64b7edd02 100644
--- a/src/BlockEntities/FlowerPotEntity.cpp
+++ b/src/BlockEntities/FlowerPotEntity.cpp
@@ -28,7 +28,7 @@ void cFlowerPotEntity::UsedBy(cPlayer * a_Player)
{
return;
}
-
+
cItem SelectedItem = a_Player->GetInventory().GetEquippedItem();
if (IsFlower(SelectedItem.m_ItemType, SelectedItem.m_ItemDamage))
{
@@ -63,7 +63,7 @@ void cFlowerPotEntity::Destroy(void)
cItems Pickups;
Pickups.Add(m_Item);
m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5);
-
+
m_Item.Empty();
}
}
@@ -88,7 +88,7 @@ bool cFlowerPotEntity::IsFlower(short m_ItemType, short m_ItemData)
}
case E_BLOCK_TALL_GRASS:
{
- return (m_ItemData == (short) 2);
+ return (m_ItemData == static_cast<short>(2));
}
default:
{
@@ -96,7 +96,3 @@ bool cFlowerPotEntity::IsFlower(short m_ItemType, short m_ItemData)
}
}
}
-
-
-
-
diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp
index 85f68b00b..d2ec2bd1e 100644
--- a/src/BlockEntities/FurnaceEntity.cpp
+++ b/src/BlockEntities/FurnaceEntity.cpp
@@ -115,16 +115,16 @@ bool cFurnaceEntity::Tick(float a_Dt, cChunk & a_Chunk)
FinishOne();
}
}
-
+
m_TimeBurned++;
if (m_TimeBurned >= m_FuelBurnTime)
{
// The current fuel has been exhausted, use another one, if possible
BurnNewFuel();
}
-
+
UpdateProgressBars();
-
+
return true;
}
@@ -185,7 +185,7 @@ void cFurnaceEntity::BurnNewFuel(void)
SetIsCooking(false);
return;
}
-
+
// Is the input and output ready for cooking?
if (!CanCookInputToOutput())
{
@@ -217,12 +217,12 @@ void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
{
return;
}
-
+
ASSERT(a_ItemGrid == &m_Contents);
switch (a_SlotNum)
{
- case fsInput: UpdateInput(); break;
- case fsFuel: UpdateFuel(); break;
+ case fsInput: UpdateInput(); break;
+ case fsFuel: UpdateFuel(); break;
case fsOutput: UpdateOutput(); break;
default: ASSERT(!"Invalid furnace slot update!"); break;
}
@@ -241,7 +241,7 @@ void cFurnaceEntity::UpdateInput(void)
m_TimeCooked = 0;
}
m_LastInput = m_Contents.GetSlot(fsInput);
-
+
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
m_CurrentRecipe = FR->GetRecipeFrom(m_Contents.GetSlot(fsInput));
if (!CanCookInputToOutput())
@@ -254,7 +254,7 @@ void cFurnaceEntity::UpdateInput(void)
{
m_NeedCookTime = m_CurrentRecipe->CookTime;
SetIsCooking(true);
-
+
// Start burning new fuel if there's no flame now:
if (GetFuelBurnTimeLeft() <= 0)
{
@@ -274,7 +274,7 @@ void cFurnaceEntity::UpdateFuel(void)
// The current fuel is still burning, don't modify anything:
return;
}
-
+
// The current fuel is spent, try to burn some more:
BurnNewFuel();
}
@@ -292,7 +292,7 @@ void cFurnaceEntity::UpdateOutput(void)
SetIsCooking(false);
return;
}
-
+
// No need to burn new fuel, the Tick() function will take care of that
// Can cook, start cooking if not already underway:
@@ -311,7 +311,7 @@ bool cFurnaceEntity::CanCookInputToOutput(void) const
// This input cannot be cooked
return false;
}
-
+
const cItem & Slot = m_Contents.GetSlot(fsOutput);
if (Slot.IsEmpty())
{
@@ -324,13 +324,13 @@ bool cFurnaceEntity::CanCookInputToOutput(void) const
// The output slot is blocked with something that cannot be stacked with the recipe's output
return false;
}
-
+
if (Slot.IsFullStack())
{
// Cannot add any more items to the output slot
return false;
}
-
+
return true;
}
@@ -345,11 +345,11 @@ void cFurnaceEntity::UpdateProgressBars(bool a_ForceUpdate)
{
return;
}
-
+
int CurFuel = (m_FuelBurnTime > 0) ? 200 - (200 * m_TimeBurned / m_FuelBurnTime) : 0;
BroadcastProgress(PROGRESSBAR_FUEL, static_cast<short>(CurFuel));
- int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0;
+ int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0;
BroadcastProgress(PROGRESSBAR_SMELTING_CONFIRM, 200); // Post 1.8, Mojang requires a random packet with an ID of three and value of 200. Wat. Wat. Wat.
BroadcastProgress(PROGRESSBAR_SMELTING, static_cast<short>(CurCook));
}
@@ -373,7 +373,3 @@ void cFurnaceEntity::SetIsCooking(bool a_IsCooking)
m_World->FastSetBlock(m_PosX, m_PosY, m_PosZ, E_BLOCK_LIT_FURNACE, m_BlockMeta);
}
}
-
-
-
-
diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h
index 8e48810ba..71c2fe127 100644
--- a/src/BlockEntities/FurnaceEntity.h
+++ b/src/BlockEntities/FurnaceEntity.h
@@ -133,7 +133,7 @@ protected:
int m_FuelBurnTime;
/** Amount of ticks that the current fuel has been burning */
- int m_TimeBurned;
+ int m_TimeBurned;
/** Sends the specified progressbar value to all clients of the window */
void BroadcastProgress(short a_ProgressbarID, short a_Value);
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index 5ed25ce99..fe3fb85c4 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -58,7 +58,7 @@ bool cHopperEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
-
+
bool res = false;
res = MoveItemsIn (a_Chunk, CurrentTick) || res;
res = MovePickupsIn(a_Chunk, CurrentTick) || res;
@@ -74,7 +74,7 @@ void cHopperEntity::SendTo(cClientHandle & a_Client)
{
// The hopper entity doesn't need anything sent to the client when it's created / gets in the viewdistance
// All the actual handling is in the cWindow UI code that gets called when the hopper is rclked
-
+
UNUSED(a_Client);
}
@@ -91,7 +91,7 @@ void cHopperEntity::UsedBy(cPlayer * a_Player)
OpenNewWindow();
Window = GetWindow();
}
-
+
// Open the window for the player:
if (Window != nullptr)
{
@@ -138,7 +138,7 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
// Too early after the previous transfer
return false;
}
-
+
// Try moving an item in:
bool res = false;
switch (a_Chunk.GetBlock(m_RelX, m_PosY + 1, m_RelZ))
@@ -161,17 +161,17 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
case E_BLOCK_DROPPER:
case E_BLOCK_HOPPER:
{
- res = MoveItemsFromGrid(*(cBlockEntityWithItems *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ));
+ res = MoveItemsFromGrid(*static_cast<cBlockEntityWithItems *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ)));
break;
}
}
-
+
// If the item has been moved, reset the last tick:
if (res)
{
m_LastMoveItemsInTick = a_CurrentTick;
}
-
+
return res;
}
@@ -205,12 +205,12 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
}
Vector3f EntityPos = a_Entity->GetPosition();
- Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
+ Vector3f BlockPos(m_Pos.x + 0.5f, static_cast<float>(m_Pos.y) + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
double Distance = (EntityPos - BlockPos).Length();
if (Distance < 0.5)
{
- if (TrySuckPickupIn((cPickup *)a_Entity))
+ if (TrySuckPickupIn(static_cast<cPickup *>(a_Entity)))
{
return false;
}
@@ -238,9 +238,9 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
m_bFoundPickupsAbove = true;
int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;
-
+
Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
-
+
if (Item.IsEmpty())
{
a_Pickup->Destroy(); // Kill pickup if all items were added
@@ -280,7 +280,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
// Too early after the previous transfer
return false;
}
-
+
// Get the coords of the block where to output items:
int OutX, OutY, OutZ;
NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
@@ -294,7 +294,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
// Cannot output below the zero-th block level
return false;
}
-
+
// Convert coords to relative:
int OutRelX = OutX - a_Chunk.GetPosX() * cChunkDef::Width;
int OutRelZ = OutZ - a_Chunk.GetPosZ() * cChunkDef::Width;
@@ -304,7 +304,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
// The destination chunk has been unloaded, don't tick
return false;
}
-
+
// Call proper moving function, based on the blocktype present at the coords:
bool res = false;
switch (DestChunk->GetBlock(OutRelX, OutY, OutRelZ))
@@ -327,7 +327,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
case E_BLOCK_DROPPER:
case E_BLOCK_HOPPER:
{
- cBlockEntityWithItems * BlockEntity = (cBlockEntityWithItems *)DestChunk->GetBlockEntity(OutX, OutY, OutZ);
+ cBlockEntityWithItems * BlockEntity = static_cast<cBlockEntityWithItems *>(DestChunk->GetBlockEntity(OutX, OutY, OutZ));
if (BlockEntity == nullptr)
{
LOGWARNING("%s: A block entity was not found where expected at {%d, %d, %d}", __FUNCTION__, OutX, OutY, OutZ);
@@ -337,13 +337,13 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
break;
}
}
-
+
// If the item has been moved, reset the last tick:
if (res)
{
m_LastMoveItemsOutTick = a_CurrentTick;
}
-
+
return res;
}
@@ -354,7 +354,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
/// Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
{
- cChestEntity * MainChest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
+ cChestEntity * MainChest = static_cast<cChestEntity *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ));
if (MainChest == nullptr)
{
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
@@ -365,7 +365,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
// Moved the item from the chest directly above the hopper
return true;
}
-
+
// Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there:
static const struct
{
@@ -395,7 +395,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
continue;
}
- cChestEntity * SideChest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
+ cChestEntity * SideChest = static_cast<cChestEntity *>(Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z));
if (SideChest == nullptr)
{
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
@@ -409,7 +409,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
}
return false;
}
-
+
// The chest was single and nothing could be moved
return false;
}
@@ -421,13 +421,13 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
/// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
{
- cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
+ cFurnaceEntity * Furnace = static_cast<cFurnaceEntity *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ));
if (Furnace == nullptr)
{
LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
return false;
}
-
+
// Try move from the output slot:
if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsOutput, true))
{
@@ -435,7 +435,7 @@ bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
Furnace->SetOutputSlot(NewOutput.AddCount(-1));
return true;
}
-
+
// No output moved, check if we can move an empty bucket out of the fuel slot:
if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET)
{
@@ -445,7 +445,7 @@ bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
return true;
}
}
-
+
// Nothing can be moved
return false;
}
@@ -458,7 +458,7 @@ bool cHopperEntity::MoveItemsFromGrid(cBlockEntityWithItems & a_Entity)
{
cItemGrid & Grid = a_Entity.GetContents();
int NumSlots = Grid.GetNumSlots();
-
+
// First try adding items of types already in the hopper:
for (int i = 0; i < NumSlots; i++)
{
@@ -519,7 +519,7 @@ bool cHopperEntity::MoveItemsFromSlot(cBlockEntityWithItems & a_Entity, int a_Sl
// Plugin disagrees with the move
continue;
}
-
+
m_Contents.ChangeSlotCount(i, 1);
return true;
}
@@ -535,7 +535,7 @@ bool cHopperEntity::MoveItemsFromSlot(cBlockEntityWithItems & a_Entity, int a_Sl
bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ)
{
// Try the chest directly connected to the hopper:
- cChestEntity * ConnectedChest = (cChestEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
+ cChestEntity * ConnectedChest = static_cast<cChestEntity *>(a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ));
if (ConnectedChest == nullptr)
{
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, a_BlockX, a_BlockY, a_BlockZ);
@@ -578,7 +578,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
continue;
}
- cChestEntity * Chest = (cChestEntity *)Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z);
+ cChestEntity * Chest = static_cast<cChestEntity *>(Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z));
if (Chest == nullptr)
{
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d} (%d, %d)", __FUNCTION__, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z, x, z);
@@ -590,7 +590,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
}
return false;
}
-
+
// The chest was single and nothing could be moved
return false;
}
@@ -602,7 +602,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
/// Moves items to the furnace at the specified coords. Returns true if contents have changed
bool cHopperEntity::MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_HopperMeta)
{
- cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
+ cFurnaceEntity * Furnace = static_cast<cFurnaceEntity *>(a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ));
if (a_HopperMeta == E_META_HOPPER_FACING_YM)
{
// Feed the input slot of the furnace
@@ -684,7 +684,3 @@ bool cHopperEntity::MoveItemsToSlot(cBlockEntityWithItems & a_Entity, int a_DstS
return false;
}
}
-
-
-
-
diff --git a/src/BlockEntities/JukeboxEntity.cpp b/src/BlockEntities/JukeboxEntity.cpp
index bb9b335e0..473526855 100644
--- a/src/BlockEntities/JukeboxEntity.cpp
+++ b/src/BlockEntities/JukeboxEntity.cpp
@@ -79,7 +79,7 @@ bool cJukeboxEntity::EjectRecord(void)
}
cItems Drops;
- Drops.push_back(cItem(m_Record, 1, 0));
+ Drops.push_back(cItem(static_cast<short>(m_Record), 1, 0));
m_Record = 0;
m_World->SpawnItemPickups(Drops, m_PosX + 0.5, m_PosY + 1, m_PosZ + 0.5, 8);
m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, 0);
@@ -113,7 +113,3 @@ void cJukeboxEntity::SetRecord(int a_Record)
{
m_Record = a_Record;
}
-
-
-
-
diff --git a/src/BlockEntities/SignEntity.cpp b/src/BlockEntities/SignEntity.cpp
index d048d0218..9a2695b3f 100644
--- a/src/BlockEntities/SignEntity.cpp
+++ b/src/BlockEntities/SignEntity.cpp
@@ -45,7 +45,7 @@ void cSignEntity::SetLines(const AString & a_Line1, const AString & a_Line2, con
void cSignEntity::SetLine(int a_Index, const AString & a_Line)
{
- if ((a_Index < 0) || (a_Index >= (int)ARRAYCOUNT(m_Line)))
+ if ((a_Index < 0) || (a_Index >= static_cast<int>(ARRAYCOUNT(m_Line))))
{
LOGWARNING("%s: setting a non-existent line %d (value \"%s\"", __FUNCTION__, a_Index, a_Line.c_str());
return;
@@ -59,7 +59,7 @@ void cSignEntity::SetLine(int a_Index, const AString & a_Line)
AString cSignEntity::GetLine(int a_Index) const
{
- if ((a_Index < 0) || (a_Index >= (int)ARRAYCOUNT(m_Line)))
+ if ((a_Index < 0) || (a_Index >= static_cast<int>(ARRAYCOUNT(m_Line))))
{
LOGWARNING("%s: requesting a non-existent line %d", __FUNCTION__, a_Index);
return "";
@@ -75,7 +75,3 @@ void cSignEntity::SendTo(cClientHandle & a_Client)
{
a_Client.SendUpdateSign(m_PosX, m_PosY, m_PosZ, m_Line[0], m_Line[1], m_Line[2], m_Line[3]);
}
-
-
-
-
diff --git a/src/Blocks/BlockDeadBush.h b/src/Blocks/BlockDeadBush.h
index 5b687c710..09df16893 100644
--- a/src/Blocks/BlockDeadBush.h
+++ b/src/Blocks/BlockDeadBush.h
@@ -17,15 +17,25 @@ public:
}
- virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
- {
- // Don't drop anything
- }
-
-
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_SAND);
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+
+ BLOCKTYPE BelowBlock = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
+ switch (BelowBlock)
+ {
+ case E_BLOCK_CLAY:
+ case E_BLOCK_HARDENED_CLAY:
+ case E_BLOCK_STAINED_CLAY:
+ case E_BLOCK_SAND:
+ {
+ return true;
+ }
+ default: return false;
+ }
}
} ;
diff --git a/src/Blocks/BlockTallGrass.h b/src/Blocks/BlockTallGrass.h
index f520414a7..8e821b899 100644
--- a/src/Blocks/BlockTallGrass.h
+++ b/src/Blocks/BlockTallGrass.h
@@ -2,6 +2,7 @@
#pragma once
#include "BlockHandler.h"
+#include "ChunkInterface.h"
@@ -10,6 +11,7 @@
class cBlockTallGrassHandler :
public cBlockHandler
{
+ typedef cBlockHandler super;
public:
cBlockTallGrassHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
@@ -26,32 +28,58 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Drop seeds, sometimes
- MTRand r1;
- if (r1.randInt(10) == 5)
+ cFastRandom Random;
+ if (Random.NextInt(8) == 0)
{
a_Pickups.push_back(cItem(E_ITEM_SEEDS, 1, 0));
}
}
- virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ 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);
-
- if ((!a_Player->IsGameModeCreative()) && (a_Player->GetEquippedItem().m_ItemType == E_ITEM_SHEARS))
+ if (a_CanDrop && (a_Digger != NULL) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
{
- cItems Pickups;
- Pickups.Add(E_BLOCK_TALL_GRASS, 1, Meta);
- a_WorldInterface.SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
-
- a_Player->UseEquippedItem();
+ NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ cItems Drops;
+ Drops.Add(m_BlockType, 1, Meta);
+
+ // Allow plugins to modify the pickups:
+ a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Drops);
+
+ // Spawn the pickups:
+ if (!Drops.empty())
+ {
+ MTRand r1;
+
+ // Mid-block position first
+ double MicroX, MicroY, MicroZ;
+ MicroX = a_BlockX + 0.5;
+ MicroY = a_BlockY + 0.5;
+ MicroZ = a_BlockZ + 0.5;
+
+ // Add random offset second
+ MicroX += r1.rand(1) - 0.5;
+ MicroZ += r1.rand(1) - 0.5;
+
+ a_WorldInterface.SpawnItemPickups(Drops, MicroX, MicroY, MicroZ);
+ }
+ return;
}
+
+ 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
{
- return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
+ if (a_RelY <= 0)
+ {
+ return false;
+ }
+
+ BLOCKTYPE BelowBlock = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
+ return IsBlockTypeOfDirt(BelowBlock);
}
} ;
diff --git a/src/Blocks/BlockVine.h b/src/Blocks/BlockVine.h
index 04021bc47..00d7a69b8 100644
--- a/src/Blocks/BlockVine.h
+++ b/src/Blocks/BlockVine.h
@@ -23,10 +23,6 @@ public:
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
- UNUSED(a_Player);
- UNUSED(a_CursorX);
- UNUSED(a_CursorY);
- UNUSED(a_CursorZ);
// TODO: Disallow placement where the vine doesn't attach to something properly
BLOCKTYPE BlockType = 0;
NIBBLETYPE BlockMeta;
@@ -80,7 +76,21 @@ public:
/// Returns true if the specified block type is good for vines to attach to
static bool IsBlockAttachable(BLOCKTYPE a_BlockType)
{
- return ((a_BlockType == E_BLOCK_LEAVES) || (a_BlockType == E_BLOCK_NEW_LEAVES) || cBlockInfo::IsSolid(a_BlockType));
+ switch (a_BlockType)
+ {
+ case E_BLOCK_GLASS:
+ case E_BLOCK_STAINED_GLASS:
+ case E_BLOCK_CHEST:
+ case E_BLOCK_TRAPPED_CHEST:
+ {
+ // You can't attach a vine to this solid blocks.
+ return false;
+ }
+ default:
+ {
+ return cBlockInfo::IsSolid(a_BlockType);
+ }
+ }
}
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index f4ed66c4b..260aace58 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -66,7 +66,7 @@ public:
/// The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column
typedef HEIGHTTYPE HeightMap[Width * Width];
-
+
/** The type used for any biomemap operations and storage inside MCServer,
using MCServer biomes (need not correspond to client representation!)
idx = x + Width * z // Need to verify this with the protocol spec, currently unknown!
@@ -95,8 +95,8 @@ public:
a_X = a_X - a_ChunkX * Width;
a_Z = a_Z - a_ChunkZ * Width;
}
-
-
+
+
/// Converts absolute block coords to chunk coords:
inline static void BlockToChunk(int a_X, int a_Z, int & a_ChunkX, int & a_ChunkZ)
{
@@ -165,15 +165,15 @@ public:
ASSERT((a_Z >= 0) && (a_Z < Width));
a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)] = a_Type;
}
-
-
+
+
inline static void SetBlock(BLOCKTYPE * a_BlockTypes, int a_Index, BLOCKTYPE a_Type)
{
ASSERT((a_Index >= 0) && (a_Index <= NumBlocks));
a_BlockTypes[a_Index] = a_Type;
}
-
-
+
+
inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_X, int a_Y, int a_Z)
{
ASSERT((a_X >= 0) && (a_X < Width));
@@ -181,39 +181,39 @@ public:
ASSERT((a_Z >= 0) && (a_Z < Width));
return a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)];
}
-
-
+
+
inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_Idx)
{
ASSERT((a_Idx >= 0) && (a_Idx < NumBlocks));
return a_BlockTypes[a_Idx];
}
-
-
+
+
inline static int GetHeight(const HeightMap & a_HeightMap, int a_X, int a_Z)
{
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width));
return a_HeightMap[a_X + Width * a_Z];
}
-
-
+
+
inline static void SetHeight(HeightMap & a_HeightMap, int a_X, int a_Z, unsigned char a_Height)
{
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width));
a_HeightMap[a_X + Width * a_Z] = a_Height;
}
-
-
+
+
inline static EMCSBiome GetBiome(const BiomeMap & a_BiomeMap, int a_X, int a_Z)
{
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width));
return a_BiomeMap[a_X + Width * a_Z];
}
-
-
+
+
inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
{
ASSERT((a_X >= 0) && (a_X < Width));
@@ -226,11 +226,11 @@ public:
{
if ((a_BlockIdx > -1) && (a_BlockIdx < NumBlocks))
{
- if ((size_t)(a_BlockIdx / 2) >= a_Buffer.size())
+ if (static_cast<size_t>(a_BlockIdx / 2) >= a_Buffer.size())
{
return (a_IsSkyLightNibble ? 0xff : 0);
}
- return (a_Buffer[(size_t)(a_BlockIdx / 2)] >> ((a_BlockIdx & 1) * 4)) & 0x0f;
+ return (a_Buffer[static_cast<size_t>(a_BlockIdx / 2)] >> ((a_BlockIdx & 1) * 4)) & 0x0f;
}
ASSERT(!"cChunkDef::GetNibble(): index out of chunk range!");
return 0;
@@ -241,7 +241,7 @@ public:
{
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{
- size_t Index = (size_t)MakeIndexNoCheck(x, y, z);
+ size_t Index = static_cast<size_t>(MakeIndexNoCheck(x, y, z));
if ((Index / 2) >= a_Buffer.size())
{
return (a_IsSkyLightNibble ? 0xff : 0);
@@ -258,7 +258,7 @@ public:
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{
int Index = MakeIndexNoCheck(x, y, z);
- return (a_Buffer[(size_t)(Index / 2)] >> ((Index & 1) * 4)) & 0x0f;
+ return (a_Buffer[static_cast<size_t>(Index / 2)] >> ((Index & 1) * 4)) & 0x0f;
}
ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!");
return 0;
@@ -272,11 +272,11 @@ public:
ASSERT(!"cChunkDef::SetNibble(): index out of range!");
return;
}
- if ((size_t)(a_BlockIdx / 2) >= a_Buffer.size())
+ if (static_cast<size_t>(a_BlockIdx / 2) >= a_Buffer.size())
{
- a_Buffer.resize((size_t)((a_BlockIdx / 2) + 1));
+ a_Buffer.resize(static_cast<size_t>((a_BlockIdx / 2) + 1));
}
- a_Buffer[(size_t)(a_BlockIdx / 2)] = PackNibble(a_Buffer, (size_t)a_BlockIdx, a_Nibble);
+ a_Buffer[static_cast<size_t>(a_BlockIdx / 2)] = PackNibble(a_Buffer, static_cast<size_t>(a_BlockIdx), a_Nibble);
}
@@ -292,7 +292,7 @@ public:
return;
}
- size_t Index = (size_t)MakeIndexNoCheck(x, y, z);
+ size_t Index = static_cast<size_t>(MakeIndexNoCheck(x, y, z));
if ((Index / 2) >= a_Buffer.size())
{
a_Buffer.resize(((Index / 2) + 1));
@@ -336,7 +336,7 @@ public:
/// Called for clients that are in Chunk1 and not in Chunk2,
virtual void Removed(cClientHandle * a_Client) = 0;
-
+
/// Called for clients that are in Chunk2 and not in Chunk1.
virtual void Added(cClientHandle * a_Client) = 0;
} ;
@@ -373,9 +373,9 @@ class cChunkCoords
public:
int m_ChunkX;
int m_ChunkZ;
-
+
cChunkCoords(int a_ChunkX, int a_ChunkZ) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ) {}
-
+
bool operator == (const cChunkCoords & a_Other) const
{
return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ));
@@ -432,12 +432,12 @@ public:
int y;
int z;
X Data;
-
+
cCoordWithData(int a_X, int a_Y, int a_Z) :
x(a_X), y(a_Y), z(a_Z), Data()
{
}
-
+
cCoordWithData(int a_X, int a_Y, int a_Z, const X & a_Data) :
x(a_X), y(a_Y), z(a_Z), Data(a_Data)
{
@@ -478,7 +478,3 @@ public:
typedef cCoordWithDoubleData <BLOCKTYPE, bool> cCoordWithBlockAndBool;
typedef std::vector<cCoordWithBlockAndBool> cCoordWithBlockAndBoolVector;
-
-
-
-
diff --git a/src/Defines.h b/src/Defines.h
index d32b7f9c3..c2f46c241 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -39,7 +39,7 @@ enum eBlockFace
BLOCK_FACE_YP = 1, // Interacting with the Y+ face of the block
BLOCK_FACE_ZM = 2, // Interacting with the Z- face of the block
BLOCK_FACE_ZP = 3, // Interacting with the Z+ face of the block
-
+
// Synonyms using the (deprecated) world directions:
BLOCK_FACE_BOTTOM = BLOCK_FACE_YM, // Interacting with the bottom face of the block
BLOCK_FACE_TOP = BLOCK_FACE_YP, // Interacting with the top face of the block
@@ -101,7 +101,7 @@ enum eClickAction
caDblClick,
// Add new actions here
caUnknown = 255,
-
+
// Keep this list in sync with ClickActionToString() function below!
} ;
@@ -116,14 +116,14 @@ enum eGameMode
eGameMode_Creative = 1,
eGameMode_Adventure = 2,
eGameMode_Spectator = 3,
-
+
// Easier-to-use synonyms:
gmNotSet = eGameMode_NotSet,
gmSurvival = eGameMode_Survival,
gmCreative = eGameMode_Creative,
gmAdventure = eGameMode_Adventure,
gmSpectator = eGameMode_Spectator,
-
+
// These two are used to check GameMode for validity when converting from integers.
gmMax, // Gets automatically assigned
gmMin = 0,
@@ -138,7 +138,7 @@ enum eWeather
eWeather_Sunny = 0,
eWeather_Rain = 1,
eWeather_ThunderStorm = 2,
-
+
// Easier-to-use synonyms:
wSunny = eWeather_Sunny,
wRain = eWeather_Rain,
@@ -218,7 +218,7 @@ inline const char * ClickActionToString(eClickAction a_ClickAction)
case caLeftPaintEnd: return "caLeftPaintEnd";
case caRightPaintEnd: return "caRightPaintEnd";
case caDblClick: return "caDblClick";
-
+
case caUnknown: return "caUnknown";
}
ASSERT(!"Unknown click action");
@@ -472,7 +472,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
{
int Y = a_BlockY;
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
- a_BlockY = Clamp<unsigned char>((unsigned char)Y, 0, 255);
+ a_BlockY = Clamp<unsigned char>(static_cast<unsigned char>(Y), 0, 255);
}
@@ -556,7 +556,7 @@ enum eMessageType
mtPrivateMessage, // Player to player messaging identifier
mtJoin, // A player has joined the server
mtLeave, // A player has left the server
-
+
// Common aliases:
mtFail = mtFailure,
mtError = mtFailure,
@@ -626,9 +626,9 @@ namespace ItemCategory
|| (a_ItemID == E_ITEM_GOLD_HOE)
|| (a_ItemID == E_ITEM_DIAMOND_HOE);
}
-
-
-
+
+
+
inline bool IsShovel(short a_ItemID)
{
return (a_ItemID == E_ITEM_WOODEN_SHOVEL)
@@ -648,9 +648,9 @@ namespace ItemCategory
|| IsHoe ( a_ItemID)
|| IsShovel ( a_ItemID);
}
-
-
-
+
+
+
inline bool IsHelmet(short a_ItemType)
{
return (
@@ -700,9 +700,9 @@ namespace ItemCategory
(a_ItemType == E_ITEM_DIAMOND_BOOTS)
);
}
-
-
-
+
+
+
inline bool IsArmor(short a_ItemType)
{
return (
@@ -715,7 +715,3 @@ namespace ItemCategory
}
// tolua_end
-
-
-
-
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 1e4d8eebb..436ec0293 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -1,6 +1,11 @@
-//
-// ArrowEntity.h
-//
+
+// ArrowEntity.h
+
+// Declares the cArrowEntity representing the arrow that has been shot by the player or by a skeleton
+
+
+
+
#pragma once
@@ -19,7 +24,7 @@ class cArrowEntity :
typedef cProjectileEntity super;
public:
- /// Determines when the arrow can be picked up (depending on player gamemode). Corresponds to the MCA file "pickup" field
+ /** Determines when the arrow can be picked up (depending on player gamemode). Corresponds to the MCA file "pickup" field */
enum ePickupState
{
psNoPickup = 0,
@@ -31,33 +36,33 @@ public:
CLASS_PROTODEF(cArrowEntity)
- /// Creates a new arrow with psNoPickup state and default damage modifier coeff
+ /** Creates a new arrow with psNoPickup state and default damage modifier coeff */
cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
- /// Creates a new arrow as shot by a player, initializes it from the player object
+ /** Creates a new arrow as shot by a player, initializes it from the player object */
cArrowEntity(cPlayer & a_Player, double a_Force);
// tolua_begin
- /// Returns whether the arrow can be picked up by players
+ /** Returns whether the arrow can be picked up by players */
ePickupState GetPickupState(void) const { return m_PickupState; }
- /// Sets a new pickup state
+ /** Sets a new pickup state */
void SetPickupState(ePickupState a_PickupState) { m_PickupState = a_PickupState; }
- /// Returns the damage modifier coeff.
+ /** Returns the damage modifier coeff. */
double GetDamageCoeff(void) const { return m_DamageCoeff; }
- /// Sets the damage modifier coeff
+ /** Sets the damage modifier coeff */
void SetDamageCoeff(double a_DamageCoeff) { m_DamageCoeff = a_DamageCoeff; }
- /// Returns true if the specified player can pick the arrow up
+ /** Returns true if the specified player can pick the arrow up */
bool CanPickup(const cPlayer & a_Player) const;
- /// Returns true if the arrow is set as critical
+ /** Returns true if the arrow is set as critical */
bool IsCritical(void) const { return m_IsCritical; }
- /// Sets the IsCritical flag
+ /** Sets the IsCritical flag */
void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; }
/** Gets the block arrow is in */
@@ -70,28 +75,28 @@ public:
protected:
- /// Determines when the arrow can be picked up by players
+ /** Determines when the arrow can be picked up by players */
ePickupState m_PickupState;
- /// The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow
+ /** The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow */
double m_DamageCoeff;
- /// If true, the arrow deals more damage
+ /** If true, the arrow deals more damage */
bool m_IsCritical;
- /// Timer for pickup collection animation or five minute timeout
+ /** Timer for pickup collection animation or five minute timeout */
float m_Timer;
- /// Timer for client arrow position confirmation via TeleportEntity
+ /** Timer for client arrow position confirmation via TeleportEntity */
float m_HitGroundTimer;
// Whether the arrow has already been teleported into the proper position in the ground.
bool m_HasTeleported;
- /// If true, the arrow is in the process of being collected - don't go to anyone else
+ /** If true, the arrow is in the process of being collected - don't go to anyone else */
bool m_bIsCollected;
- /// Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air
+ /** Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air */
Vector3i m_HitBlockPos;
// cProjectileEntity overrides:
diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h
index d36110f97..715b9947e 100644
--- a/src/Entities/ExpBottleEntity.h
+++ b/src/Entities/ExpBottleEntity.h
@@ -1,6 +1,11 @@
-//
-// ExpBottleEntity.h
-//
+
+// ExpBottleEntity.h
+
+// Declares the cExpBottleEntity class representing the thrown exp bottle
+
+
+
+
#pragma once
@@ -33,6 +38,10 @@ protected:
/** Breaks the bottle, fires its particle effects and sounds
@param a_HitPos The position where the bottle will break */
- void Break(const Vector3d &a_HitPos);
+ void Break(const Vector3d & a_HitPos);
}; // tolua_export
+
+
+
+
diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h
index 5df55bec4..eb08f5324 100644
--- a/src/Entities/FireChargeEntity.h
+++ b/src/Entities/FireChargeEntity.h
@@ -1,6 +1,11 @@
-//
-// FireChargeEntity.h
-//
+
+// FireChargeEntity.h
+
+// Declares the cFireChargeEntity representing the fire charge shot by the blaze
+
+
+
+
#pragma once
@@ -34,3 +39,7 @@ protected:
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/FireworkEntity.cpp b/src/Entities/FireworkEntity.cpp
index 403a53c84..68d02640a 100644
--- a/src/Entities/FireworkEntity.cpp
+++ b/src/Entities/FireworkEntity.cpp
@@ -10,7 +10,7 @@
cFireworkEntity::cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item) :
super(pkFirework, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
- m_ExplodeTimer(0),
+ m_TicksToExplosion(a_Item.m_FireworkItem.m_FlightTimeInTicks),
m_FireworkItem(a_Item)
{
}
@@ -27,7 +27,9 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((PosY < 0) || (PosY >= cChunkDef::Height))
{
- goto setspeed;
+ AddSpeedY(1);
+ AddPosition(GetSpeed() * (a_Dt / 1000));
+ return;
}
if (m_IsInGround)
@@ -50,7 +52,6 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
}
}
-setspeed:
AddSpeedY(1);
AddPosition(GetSpeed() * (a_Dt / 1000));
}
@@ -63,11 +64,13 @@ void cFireworkEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (m_ExplodeTimer == m_FireworkItem.m_FireworkItem.m_FlightTimeInTicks)
+ if (m_TicksToExplosion <= 0)
{
+ // TODO: Notify the plugins
m_World->BroadcastEntityStatus(*this, esFireworkExploding);
Destroy();
+ return;
}
- m_ExplodeTimer++;
+ m_TicksToExplosion -= 1;
}
diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h
index 20f18b6dc..300ec571e 100644
--- a/src/Entities/FireworkEntity.h
+++ b/src/Entities/FireworkEntity.h
@@ -1,6 +1,11 @@
-//
-// FireworkEntity.h
-//
+
+// FireworkEntity.h
+
+// Declares the cFireworkEntity class representing the flying firework rocket
+
+
+
+
#pragma once
@@ -24,7 +29,22 @@ public:
CLASS_PROTODEF(cFireworkEntity)
cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item);
+
+ // tolua_begin
+
+ /** Returns the item used to create the rocket (has all the firework effects on it) */
const cItem & GetItem(void) const { return m_FireworkItem; }
+
+ /** Sets the item that is used to create the rocket (has all the firework effects on it) */
+ void SetItem(const cItem & a_Item) { m_FireworkItem = a_Item; }
+
+ /** Returns the number of ticks left until the firework explosion. */
+ int GetTicksToExplosion(void) const { return m_TicksToExplosion; }
+
+ /** Sets the number of ticks left until the firework explosion. */
+ void SetTicksToExplosion(int a_TicksToExplosion) { m_TicksToExplosion = a_TicksToExplosion; }
+
+ // tolua_end
protected:
@@ -34,7 +54,11 @@ protected:
private:
- int m_ExplodeTimer;
+ int m_TicksToExplosion;
cItem m_FireworkItem;
}; // tolua_export
+
+
+
+
diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h
index 3ed72d9ef..bbce89d31 100644
--- a/src/Entities/GhastFireballEntity.h
+++ b/src/Entities/GhastFireballEntity.h
@@ -1,6 +1,11 @@
-//
-// GhastFireballEntity.h
-//
+
+// GhastFireballEntity.h
+
+// Declares the cGhastFireballEntity class representing the ghast fireball in flight.
+
+
+
+
#pragma once
@@ -36,3 +41,7 @@ protected:
// TODO: Deflecting the fireballs by arrow- or sword- hits
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp
index 3276bc4a0..a6b9c40c8 100644
--- a/src/Entities/HangingEntity.cpp
+++ b/src/Entities/HangingEntity.cpp
@@ -9,9 +9,9 @@
-cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
- : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8)
- , m_BlockFace(a_BlockFace)
+cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_Facing, double a_X, double a_Y, double a_Z) :
+ cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8),
+ m_Facing(a_Facing)
{
SetMaxHealth(1);
SetHealth(1);
@@ -21,15 +21,23 @@ cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace,
-void cHangingEntity::SetDirection(eBlockFace a_BlockFace)
+void cHangingEntity::SetFacing(eBlockFace a_Facing)
{
- if ((a_BlockFace < 2) || (a_BlockFace > 5))
+ // Y-based faces are not allowed:
+ switch (a_Facing)
{
- ASSERT(!"Tried to set a bad direction!");
- return;
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
+ {
+ LOGWARNING("%s: Invalid facing: %d. Ignoring.", __FUNCTION__, a_Facing);
+ ASSERT(!"Tried to set a bad facing!");
+ return;
+ }
+ default: break;
}
- m_BlockFace = a_BlockFace;
+ m_Facing = a_Facing;
}
@@ -41,7 +49,7 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
int Dir = 0;
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
- switch (m_BlockFace)
+ switch (m_Facing)
{
case BLOCK_FACE_ZP: Dir = 0; break;
case BLOCK_FACE_ZM: Dir = 2; break;
@@ -49,8 +57,8 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
case BLOCK_FACE_XP: Dir = 3; break;
default:
{
- LOGINFO("Invalid face (%d) in a cHangingEntity at {%d, %d, %d}, adjusting to BLOCK_FACE_XP.",
- m_BlockFace, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ()
+ LOGINFO("Invalid facing (%d) in a cHangingEntity at {%d, %d, %d}, adjusting to BLOCK_FACE_XP.",
+ m_Facing, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ()
);
Dir = 3;
}
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index 1cc0034e1..67146a20b 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -11,36 +11,41 @@
class cHangingEntity :
public cEntity
{
- // tolua_end
typedef cEntity super;
public:
+ // tolua_end
+
CLASS_PROTODEF(cHangingEntity)
cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
- /** Returns the orientation from the hanging entity */
- eBlockFace GetDirection() const { return m_BlockFace; } // tolua_export
+ // tolua_begin
+
+ /** Returns the direction in which the entity is facing. */
+ eBlockFace GetFacing() const { return m_Facing; }
- /** Set the orientation from the hanging entity */
- void SetDirection(eBlockFace a_BlockFace); // tolua_export
+ /** Set the direction in which the entity is facing. */
+ void SetFacing(eBlockFace a_Facing);
- /** Returns the X coord. */
- int GetTileX() const { return POSX_TOINT; } // tolua_export
+ /** Returns the X coord of the block in which the entity resides. */
+ int GetBlockX() const { return POSX_TOINT; }
- /** Returns the Y coord. */
- int GetTileY() const { return POSY_TOINT; } // tolua_export
+ /** Returns the Y coord of the block in which the entity resides. */
+ int GetBlockY() const { return POSY_TOINT; }
- /** Returns the Z coord. */
- int GetTileZ() const { return POSZ_TOINT; } // tolua_export
+ /** Returns the Z coord of the block in which the entity resides. */
+ int GetBlockZ() const { return POSZ_TOINT; }
+
+ // tolua_end
private:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}
- eBlockFace m_BlockFace;
+ eBlockFace m_Facing;
}; // tolua_export
diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp
index b7aac52d0..dfffcd3ed 100644
--- a/src/Entities/ItemFrame.cpp
+++ b/src/Entities/ItemFrame.cpp
@@ -9,10 +9,10 @@
-cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
- : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z)
- , m_Item(E_BLOCK_AIR)
- , m_Rotation(0)
+cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z) :
+ cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z),
+ m_Item(E_BLOCK_AIR),
+ m_ItemRotation(0)
{
}
@@ -27,10 +27,10 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player)
if (!m_Item.IsEmpty())
{
// Item not empty, rotate, clipping values to zero to three inclusive
- m_Rotation++;
- if (m_Rotation >= 8)
+ m_ItemRotation++;
+ if (m_ItemRotation >= 8)
{
- m_Rotation = 0;
+ m_ItemRotation = 0;
}
}
else if (!a_Player.GetEquippedItem().IsEmpty())
@@ -72,7 +72,7 @@ void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
SetHealth(GetMaxHealth());
m_Item.Empty();
- m_Rotation = 0;
+ m_ItemRotation = 0;
SetInvulnerableTicks(0);
GetWorld()->BroadcastEntityMetadata(*this);
}
diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h
index a63b78b70..ced8c37af 100644
--- a/src/Entities/ItemFrame.h
+++ b/src/Entities/ItemFrame.h
@@ -11,26 +11,31 @@
class cItemFrame :
public cHangingEntity
{
- // tolua_end
typedef cHangingEntity super;
public:
+ // tolua_end
+
CLASS_PROTODEF(cItemFrame)
cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
+ // tolua_begin
+
/** Returns the item in the frame */
- const cItem & GetItem(void) { return m_Item; } // tolua_export
+ const cItem & GetItem(void) { return m_Item; }
/** Set the item in the frame */
- void SetItem(cItem & a_Item) { m_Item = a_Item; } // tolua_export
+ void SetItem(cItem & a_Item) { m_Item = a_Item; }
/** Returns the rotation from the item in the frame */
- Byte GetRotation(void) const { return m_Rotation; } // tolua_export
+ Byte GetItemRotation(void) const { return m_ItemRotation; }
/** Set the rotation from the item in the frame */
- void SetRotation(Byte a_Rotation) { m_Rotation = a_Rotation; } // tolua_export
+ void SetItemRotation(Byte a_ItemRotation) { m_ItemRotation = a_ItemRotation; }
+
+ // tolua_end
private:
@@ -39,7 +44,7 @@ private:
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
cItem m_Item;
- Byte m_Rotation;
+ Byte m_ItemRotation;
}; // tolua_export
diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h
index 9877c95c5..078270b42 100644
--- a/src/Entities/Painting.h
+++ b/src/Entities/Painting.h
@@ -11,15 +11,22 @@
class cPainting :
public cEntity
{
- // tolua_end
typedef cEntity super;
public:
+
+ // tolua_end
+
CLASS_PROTODEF(cPainting)
cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z);
- const AString & GetName(void) const { return m_Name; } // tolua_export
- int GetDirection(void) const { return m_Direction; } // tolua_export
+
+ // tolua_begin
+
+ const AString & GetName(void) const { return m_Name; }
+ int GetDirection(void) const { return m_Direction; }
+
+ // tolua_end
private:
diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h
index b3cbeee0b..d1176a7cf 100644
--- a/src/Entities/Pickup.h
+++ b/src/Entities/Pickup.h
@@ -19,7 +19,7 @@ class cPickup :
public cEntity
{
typedef cEntity super;
-
+
public:
// tolua_end
@@ -37,10 +37,10 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
/** Returns the number of ticks that this entity has existed */
- int GetAge(void) const { return (int)(m_Timer / 50); } // tolua_export
+ int GetAge(void) const { return static_cast<int>(m_Timer / 50); } // tolua_export
/** Set the number of ticks that this entity has existed */
- void SetAge(int a_Age) { m_Timer = (float)(a_Age * 50); } // tolua_export
+ void SetAge(int a_Age) { m_Timer = static_cast<float>(a_Age * 50); } // tolua_export
/** Returns true if the pickup has already been collected */
bool IsCollected(void) const { return m_bCollected; } // tolua_export
@@ -59,7 +59,3 @@ private:
bool m_bIsPlayerCreated;
}; // tolua_export
-
-
-
-
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index 3861f9ecc..2a98e31c7 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -1,7 +1,7 @@
// ProjectileEntity.h
-// Declares the cProjectileEntity class representing the common base class for projectiles, as well as individual projectile types
+// Declares the cProjectileEntity class representing the common base class for projectiles
@@ -23,7 +23,7 @@ class cProjectileEntity :
typedef cEntity super;
public:
- /// The kind of the projectile. The numbers correspond to the network type ID used for spawning via the 0x17 packet.
+ /** The kind of the projectile. The numbers correspond to the network type ID used for spawning them in the protocol. */
enum eKind
{
pkArrow = 60,
@@ -48,22 +48,22 @@ public:
static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = nullptr);
- /// Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given
+ /** Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given */
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace);
- /// Called by the physics blocktracer when the entity hits another entity
+ /** Called by the physics blocktracer when the entity hits another entity */
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
UNUSED(a_EntityHit);
UNUSED(a_HitPos);
}
- /// Called by Chunk when the projectile is eligible for player collection
+ /** Called by Chunk when the projectile is eligible for player collection */
virtual void CollectedBy(cPlayer & a_Dest);
// tolua_begin
- /// Returns the kind of the projectile (fast class identification)
+ /** Returns the kind of the projectile (fast class identification) */
eKind GetProjectileKind(void) const { return m_ProjectileKind; }
/** Returns the unique ID of the entity who created this projectile
@@ -76,15 +76,15 @@ public:
*/
AString GetCreatorName(void) const { return m_CreatorData.m_Name; }
- /// Returns the string that is used as the entity type (class name) in MCA files
+ /** Returns the string that is used as the entity type (class name) in MCA files */
AString GetMCAClassName(void) const;
- /// Returns true if the projectile has hit the ground and is stuck there
+ /** Returns true if the projectile has hit the ground and is stuck there */
bool IsInGround(void) const { return m_IsInGround; }
// tolua_end
- /// Sets the internal InGround flag. To be used by MCA loader only!
+ /** Sets the internal InGround flag. To be used by MCA loader only! */
void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; }
protected:
@@ -114,7 +114,7 @@ protected:
*/
CreatorData m_CreatorData;
- /// True if the projectile has hit the ground and is stuck there
+ /** True if the projectile has hit the ground and is stuck there */
bool m_IsInGround;
// cEntity overrides:
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index 4afc5f204..9302d8292 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -1,6 +1,11 @@
-//
-// SplashPotionEntity.h
-//
+
+// SplashPotionEntity.h
+
+// Declares the cSplashPotionEntity class representing a splash potion that has been thrown
+
+
+
+
#pragma once
@@ -32,6 +37,7 @@ public:
const cItem & a_Item
);
+ // tolua_begin
cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
int GetPotionColor(void) const { return m_PotionColor; }
@@ -39,6 +45,8 @@ public:
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
+
+ // tolua_end
protected:
@@ -77,3 +85,7 @@ private:
/** Time in ticks to wait for the hit animation to begin before destroying */
int m_DestroyTimer;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp
index 5ae85bee8..24c946a9c 100644
--- a/src/Entities/ThrownEggEntity.cpp
+++ b/src/Entities/ThrownEggEntity.cpp
@@ -44,6 +44,27 @@ void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
+void cThrownEggEntity::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+}
+
+
+
+
+
void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
{
if (m_World->GetTickRandomNumber(7) == 1)
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index a0b7d5340..6ffedf5b5 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -1,6 +1,11 @@
-//
-// ThrownEggEntity.h
-//
+
+// ThrownEggEntity.h
+
+// Declares the cThrownEggEntity class representing a regular thrown egg
+
+
+
+
#pragma once
@@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick (float a_Dt, cChunk & a_Chunk) override
- {
- if (m_DestroyTimer > 0)
- {
- m_DestroyTimer--;
- if (m_DestroyTimer == 0)
- {
- Destroy();
- return;
- }
- }
- else
- {
- super::Tick(a_Dt, a_Chunk);
- }
- }
+ virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
// Randomly decides whether to spawn a chicken where the egg lands.
void TrySpawnChicken(const Vector3d & a_HitPos);
@@ -56,3 +46,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index c7407e6ae..8f1b62934 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -1,3 +1,4 @@
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "ThrownEnderPearlEntity.h"
@@ -45,6 +46,27 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
+void cThrownEnderPearlEntity::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+}
+
+
+
+
+
void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
{
if (m_CreatorData.m_Name.empty())
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index 436450013..475ebde87 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -1,6 +1,11 @@
-//
-// ThrownEnderPearlEntity.h
-//
+
+// ThrownEnderPearlEntity.h
+
+// Declares the cThrownEnderPeralEntity class representing an ender pearl being thrown
+
+
+
+
#pragma once
@@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick (float a_Dt, cChunk & a_Chunk) override
- {
- if (m_DestroyTimer > 0)
- {
- m_DestroyTimer--;
- if (m_DestroyTimer == 0)
- {
- Destroy();
- return;
- }
- }
- else
- {
- super::Tick(a_Dt, a_Chunk);
- }
- }
+ virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
/** Teleports the creator where the ender pearl lands */
void TeleportCreator(const Vector3d & a_HitPos);
@@ -56,3 +46,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp
index 496397100..88e39d22e 100644
--- a/src/Entities/ThrownSnowballEntity.cpp
+++ b/src/Entities/ThrownSnowballEntity.cpp
@@ -43,3 +43,28 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
m_DestroyTimer = 5;
}
+
+
+
+
+
+void cThrownSnowballEntity::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+}
+
+
+
+
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index 8d195ced1..f806996cc 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -1,6 +1,11 @@
-//
-// ThrownSnowballEntity.h
-//
+
+// ThrownSnowballEntity.h
+
+// Declares the cThrownSnowballEntity representing a snowball that has been thrown
+
+
+
+
#pragma once
@@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick (float a_Dt, cChunk & a_Chunk) override
- {
- if (m_DestroyTimer > 0)
- {
- m_DestroyTimer--;
- if (m_DestroyTimer == 0)
- {
- Destroy();
- return;
- }
- }
- else
- {
- super::Tick(a_Dt, a_Chunk);
- }
- }
+ virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
private:
@@ -53,3 +43,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
index c59acd807..43a520388 100644
--- a/src/Entities/WitherSkullEntity.h
+++ b/src/Entities/WitherSkullEntity.h
@@ -1,8 +1,12 @@
-// WitherSkullEntity.h
+// WitherSkullEntity.h
// Declares the cWitherSkullEntity class representing the entity used by both blue and black wither skulls
+
+
+
+
#pragma once
#include "ProjectileEntity.h"
@@ -30,6 +34,10 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
} ; // tolua_export
+
+
+
+
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index 625dffa84..9a52588d5 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -119,9 +119,9 @@ cTerrainCompositionGenPtr cTerrainCompositionGen::CreateCompositionGen(cIniFile
cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) :
super(a_ChunkGenerator),
- m_BiomeGen(nullptr),
- m_HeightGen(nullptr),
- m_CompositionGen(nullptr)
+ m_BiomeGen(),
+ m_HeightGen(),
+ m_CompositionGen()
{
}
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index d1588e9d8..9272a723d 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -572,6 +572,8 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
case E_BLOCK_COBBLESTONE:
case E_BLOCK_COBBLESTONE_STAIRS:
case E_BLOCK_COBBLESTONE_WALL:
+ case E_BLOCK_COBWEB:
+ case E_BLOCK_DEAD_BUSH:
case E_BLOCK_DIAMOND_BLOCK:
case E_BLOCK_DIAMOND_ORE:
case E_BLOCK_DOUBLE_NEW_STONE_SLAB:
diff --git a/src/Items/ItemShears.h b/src/Items/ItemShears.h
index fa2794df2..73343f629 100644
--- a/src/Items/ItemShears.h
+++ b/src/Items/ItemShears.h
@@ -28,21 +28,25 @@ public:
virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
{
- BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ BLOCKTYPE Block;
+ NIBBLETYPE BlockMeta;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, BlockMeta);
+
if ((Block == E_BLOCK_LEAVES) || (Block == E_BLOCK_NEW_LEAVES))
{
- NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ cItems Drops;
cBlockHandler * Handler = cBlockInfo::GetHandler(Block);
- cItems Drops;
- Handler->ConvertToPickups(Drops, Meta);
- Drops.push_back(cItem(Block, 1, Meta & 3));
+ Handler->ConvertToPickups(Drops, BlockMeta);
+ Drops.Add(Block, 1, BlockMeta & 3);
a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
a_Player->UseEquippedItem();
return true;
}
+
return false;
}
@@ -53,12 +57,10 @@ public:
{
case E_BLOCK_COBWEB:
case E_BLOCK_VINES:
- case E_BLOCK_LEAVES:
- case E_BLOCK_NEW_LEAVES:
{
return true;
}
- } // switch (a_BlockType)
+ }
return super::CanHarvestBlock(a_BlockType);
}
@@ -71,12 +73,21 @@ public:
virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
- super::OnBlockDestroyed(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ);
+ BLOCKTYPE Block;
+ NIBBLETYPE BlockMeta;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, BlockMeta);
- BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- if ((Block == E_BLOCK_TRIPWIRE) || (Block == E_BLOCK_VINES))
+ super::OnBlockDestroyed(a_World, a_Player, a_Item, a_BlockX, a_BlockY, a_BlockZ);
+ switch (Block)
{
- a_Player->UseEquippedItem();
+ case E_BLOCK_COBWEB:
+ case E_BLOCK_DEAD_BUSH:
+ case E_BLOCK_TRIPWIRE:
+ case E_BLOCK_VINES:
+ case E_BLOCK_WOOL:
+ {
+ a_Player->UseEquippedItem();
+ }
}
}
} ;
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 9fd67d67c..f5ae2cb4d 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -35,12 +35,12 @@ public:
mfNoSpawn,
mfUnhandled, // Nothing. Be sure this is the last and the others are in order
} ;
-
+
// tolua_end
-
+
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
enum MPersonality{PASSIVE, AGGRESSIVE, COWARDLY} m_EMPersonality;
-
+
/** Creates the mob object.
If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig()
a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22))
@@ -49,47 +49,47 @@ public:
cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
CLASS_PROTODEF(cMonster)
-
+
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
-
+
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
virtual bool ReachedDestination(void);
-
+
// tolua_begin
eMonsterType GetMobType(void) const {return m_MobType; }
eFamily GetMobFamily(void) const;
// tolua_end
-
+
virtual void CheckEventSeePlayer(void);
virtual void EventSeePlayer(cEntity * a_Player);
-
+
/// Reads the monster configuration for the specified monster name and assigns it to this object.
void GetMonsterConfig(const AString & a_Name);
-
+
/** Returns whether this mob is undead (skeleton, zombie, etc.) */
virtual bool IsUndead(void);
-
+
virtual void EventLosePlayer(void);
virtual void CheckEventLostPlayer(void);
-
+
virtual void InStateIdle (float a_Dt);
virtual void InStateChasing (float a_Dt);
virtual void InStateEscaping(float a_Dt);
-
- int GetAttackRate() { return (int)m_AttackRate; }
+
+ int GetAttackRate() { return static_cast<int>(m_AttackRate); }
void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; }
void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; }
void SetAttackDamage(int a_AttackDamage) { m_AttackDamage = a_AttackDamage; }
void SetSightDistance(int a_SightDistance) { m_SightDistance = a_SightDistance; }
-
+
float GetDropChanceWeapon() { return m_DropChanceWeapon; }
float GetDropChanceHelmet() { return m_DropChanceHelmet; }
float GetDropChanceChestplate() { return m_DropChanceChestplate; }
@@ -102,7 +102,7 @@ public:
void SetDropChanceLeggings(float a_DropChanceLeggings) { m_DropChanceLeggings = a_DropChanceLeggings; }
void SetDropChanceBoots(float a_DropChanceBoots) { m_DropChanceBoots = a_DropChanceBoots; }
void SetCanPickUpLoot(bool a_CanPickUpLoot) { m_CanPickUpLoot = a_CanPickUpLoot; }
-
+
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
@@ -113,7 +113,7 @@ public:
virtual bool IsBaby (void) const { return false; }
virtual bool IsTame (void) const { return false; }
virtual bool IsSitting (void) const { return false; }
-
+
// tolua_begin
/** Returns true if the monster has a custom name. */
@@ -135,10 +135,10 @@ public:
/// Translates MobType enum to a string, empty string if unknown
static AString MobTypeToString(eMonsterType a_MobType);
-
+
/// Translates MobType string to the enum, mtInvalidType if not recognized
static eMonsterType StringToMobType(const AString & a_MobTypeName);
-
+
/// Returns the mob family based on the type
static eFamily FamilyFromType(eMonsterType a_MobType);
@@ -146,7 +146,7 @@ public:
static int GetSpawnDelay(cMonster::eFamily a_MobFamily);
// tolua_end
-
+
/** Creates a new object of the specified mob.
a_MobType is the type of the mob to be created
Asserts and returns null if mob type is not specified
@@ -154,7 +154,7 @@ public:
static cMonster * NewMonsterFromType(eMonsterType a_MobType);
protected:
-
+
/* ======= PATHFINDING ======= */
/** A pointer to the entity this mobile is aiming to reach */
@@ -168,7 +168,7 @@ protected:
/** Stores if mobile is currently moving towards the ultimate, final destination */
bool m_bMovingToDestination;
-
+
/** Finds the first non-air block position (not the highest, as cWorld::GetHeight does)
If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1
If current Y is solid, goes up to find first nonsolid block, and returns that */
@@ -227,14 +227,14 @@ protected:
int m_AttackRange;
float m_AttackInterval;
int m_SightDistance;
-
+
float m_DropChanceWeapon;
float m_DropChanceHelmet;
float m_DropChanceChestplate;
float m_DropChanceLeggings;
float m_DropChanceBoots;
bool m_CanPickUpLoot;
-
+
void HandleDaylightBurning(cChunk & a_Chunk);
bool m_BurnsInDaylight;
@@ -242,22 +242,18 @@ protected:
/** 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);
-
+
/** Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops*/
void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0);
-
+
/** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/
void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel);
-
+
/** Adds armor that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/
void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel);
-
+
/** Adds weapon that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/
void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel);
-
-
-} ; // tolua_export
-
-
+} ; // tolua_export
diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h
index ba6a48898..6aadaf447 100644
--- a/src/OSSupport/IsThread.h
+++ b/src/OSSupport/IsThread.h
@@ -31,17 +31,17 @@ protected:
/// The overriden Execute() method should check this value periodically and terminate if this is true
volatile bool m_ShouldTerminate;
-
+
public:
cIsThread(const AString & a_ThreadName);
virtual ~cIsThread();
-
+
/// Starts the thread; returns without waiting for the actual start
bool Start(void);
-
+
/// Signals the thread to terminate and waits until it's finished
void Stop(void);
-
+
/// Waits for the thread to finish. Doesn't signalize the ShouldTerminate flag
bool Wait(void);
@@ -58,7 +58,3 @@ protected:
#endif // CISTHREAD_H_INCLUDED
-
-
-
-
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 3baf684e9..f33d37b30 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -2803,7 +2803,7 @@ void cProtocol172::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity)
WriteByte(0xA2);
WriteItem(Frame.GetItem());
WriteByte(0x3);
- WriteByte(Frame.GetRotation() / 2);
+ WriteByte(Frame.GetItemRotation() / 2);
break;
}
default: break;
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index 0ca9927db..8445e8f26 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -3109,7 +3109,7 @@ void cProtocol180::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity)
WriteByte(0xA8);
WriteItem(Frame.GetItem());
WriteByte(0x09);
- WriteByte(Frame.GetRotation());
+ WriteByte(Frame.GetItemRotation());
break;
}
default: break;
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index f5c409e6c..79004167d 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -2321,7 +2321,7 @@ cItem * cSlotAreaTemporary::GetPlayerSlots(cPlayer & a_Player)
if (itr == m_Items.end())
{
return nullptr;
- }
+ }
return itr->second.data();
}
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index c4862bdb4..d85a5c329 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -685,21 +685,21 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
void cNBTChunkSerializer::AddHangingEntity(cHangingEntity * a_Hanging)
{
- m_Writer.AddByte("Direction", (unsigned char)a_Hanging->GetDirection());
- m_Writer.AddInt("TileX", a_Hanging->GetTileX());
- m_Writer.AddInt("TileY", a_Hanging->GetTileY());
- m_Writer.AddInt("TileZ", a_Hanging->GetTileZ());
- switch (a_Hanging->GetDirection())
+ m_Writer.AddInt("TileX", a_Hanging->GetBlockX());
+ m_Writer.AddInt("TileY", a_Hanging->GetBlockY());
+ m_Writer.AddInt("TileZ", a_Hanging->GetBlockZ());
+ switch (a_Hanging->GetFacing())
{
- case BLOCK_FACE_YM: m_Writer.AddByte("Dir", (unsigned char)2); break;
- case BLOCK_FACE_YP: m_Writer.AddByte("Dir", (unsigned char)1); break;
- case BLOCK_FACE_ZM: m_Writer.AddByte("Dir", (unsigned char)0); break;
- case BLOCK_FACE_ZP: m_Writer.AddByte("Dir", (unsigned char)3); break;
+ case BLOCK_FACE_XM: m_Writer.AddByte("Facing", 1); break;
+ case BLOCK_FACE_XP: m_Writer.AddByte("Facing", 3); break;
+ case BLOCK_FACE_ZM: m_Writer.AddByte("Facing", 2); break;
+ case BLOCK_FACE_ZP: m_Writer.AddByte("Facing", 0); break;
- case BLOCK_FACE_XM:
- case BLOCK_FACE_XP:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
case BLOCK_FACE_NONE:
{
+ // These directions are invalid, but they may have been previously loaded, so keep them.
break;
}
}
@@ -740,7 +740,7 @@ void cNBTChunkSerializer::AddItemFrameEntity(cItemFrame * a_ItemFrame)
AddBasicEntity(a_ItemFrame, "ItemFrame");
AddHangingEntity(a_ItemFrame);
AddItem(a_ItemFrame->GetItem(), -1, "Item");
- m_Writer.AddByte("ItemRotation", (unsigned char)a_ItemFrame->GetRotation());
+ m_Writer.AddByte("ItemRotation", (unsigned char)a_ItemFrame->GetItemRotation());
m_Writer.AddFloat("ItemDropChance", 1.0F);
m_Writer.EndCompound();
}
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index d0483ab70..af7551ee4 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1660,30 +1660,41 @@ void cWSSAnvil::LoadExpOrbFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadHangingFromNBT(cHangingEntity & a_Hanging, const cParsedNBT & a_NBT, int a_TagIdx)
{
- int Direction = a_NBT.FindChildByName(a_TagIdx, "Direction");
- if (Direction > 0)
+ // "Facing" tag is the prime source of the Facing; if not available, translate from older "Direction" or "Dir"
+ int Facing = a_NBT.FindChildByName(a_TagIdx, "Facing");
+ if (Facing > 0)
{
- Direction = (int)a_NBT.GetByte(Direction);
- if ((Direction < 2) || (Direction > 5))
+ Facing = (int)a_NBT.GetByte(Facing);
+ if ((Facing >= 2) && (Facing <= 5))
{
- a_Hanging.SetDirection(BLOCK_FACE_NORTH);
- }
- else
- {
- a_Hanging.SetDirection(static_cast<eBlockFace>(Direction));
+ a_Hanging.SetFacing(static_cast<eBlockFace>(Facing));
}
}
else
{
- Direction = a_NBT.FindChildByName(a_TagIdx, "Dir");
- if (Direction > 0)
+ Facing = a_NBT.FindChildByName(a_TagIdx, "Direction");
+ if (Facing > 0)
+ {
+ switch ((int)a_NBT.GetByte(Facing))
+ {
+ case 0: a_Hanging.SetFacing(BLOCK_FACE_ZM); break;
+ case 1: a_Hanging.SetFacing(BLOCK_FACE_XM); break;
+ case 2: a_Hanging.SetFacing(BLOCK_FACE_ZP); break;
+ case 3: a_Hanging.SetFacing(BLOCK_FACE_XP); break;
+ }
+ }
+ else
{
- switch ((int)a_NBT.GetByte(Direction))
+ Facing = a_NBT.FindChildByName(a_TagIdx, "Dir"); // Has values 0 and 2 swapped
+ if (Facing > 0)
{
- case 0: a_Hanging.SetDirection(BLOCK_FACE_NORTH); break;
- case 1: a_Hanging.SetDirection(BLOCK_FACE_TOP); break;
- case 2: a_Hanging.SetDirection(BLOCK_FACE_BOTTOM); break;
- case 3: a_Hanging.SetDirection(BLOCK_FACE_SOUTH); break;
+ switch ((int)a_NBT.GetByte(Facing))
+ {
+ case 0: a_Hanging.SetFacing(BLOCK_FACE_ZP); break;
+ case 1: a_Hanging.SetFacing(BLOCK_FACE_XM); break;
+ case 2: a_Hanging.SetFacing(BLOCK_FACE_ZM); break;
+ case 3: a_Hanging.SetFacing(BLOCK_FACE_XP); break;
+ }
}
}
}
@@ -1732,7 +1743,7 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT
int Rotation = a_NBT.FindChildByName(a_TagIdx, "ItemRotation");
if (Rotation > 0)
{
- ItemFrame->SetRotation((Byte)a_NBT.GetByte(Rotation));
+ ItemFrame->SetItemRotation((Byte)a_NBT.GetByte(Rotation));
}
a_Entities.push_back(ItemFrame.release());