1
0

Merge pull request #2 from tigerw/bugfixes

Bugfixes
This commit is contained in:
Tiger Wang 2013-09-24 02:31:57 -07:00
commit 21b23ff1e7
44 changed files with 924 additions and 250 deletions

View File

@ -963,6 +963,14 @@
RelativePath="..\source\Mobs\Creeper.h"
>
</File>
<File
RelativePath="..\source\Mobs\EnderDragon.cpp"
>
</File>
<File
RelativePath="..\source\Mobs\EnderDragon.h"
>
</File>
<File
RelativePath="..\source\Mobs\Enderman.cpp"
>
@ -980,11 +988,35 @@
>
</File>
<File
RelativePath="..\source\Mobs\Magmacube.cpp"
RelativePath="..\source\Mobs\Giant.cpp"
>
</File>
<File
RelativePath="..\source\Mobs\Magmacube.h"
RelativePath="..\source\Mobs\Giant.h"
>
</File>
<File
RelativePath="..\source\Mobs\Horse.cpp"
>
</File>
<File
RelativePath="..\source\Mobs\Horse.h"
>
</File>
<File
RelativePath="..\source\Mobs\IronGolem.cpp"
>
</File>
<File
RelativePath="..\source\Mobs\IronGolem.h"
>
</File>
<File
RelativePath="..\source\Mobs\MagmaCube.cpp"
>
</File>
<File
RelativePath="..\source\Mobs\MagmaCube.h"
>
</File>
<File
@ -1059,6 +1091,14 @@
RelativePath="..\source\Mobs\Slime.h"
>
</File>
<File
RelativePath="..\source\Mobs\SnowGolem.cpp"
>
</File>
<File
RelativePath="..\source\Mobs\SnowGolem.h"
>
</File>
<File
RelativePath="..\source\Mobs\Spider.cpp"
>
@ -1091,6 +1131,14 @@
RelativePath="..\source\Mobs\Witch.h"
>
</File>
<File
RelativePath="..\source\Mobs\Wither.cpp"
>
</File>
<File
RelativePath="..\source\Mobs\Wither.h"
>
</File>
<File
RelativePath="..\source\Mobs\Wolf.h"
>
@ -1104,11 +1152,11 @@
>
</File>
<File
RelativePath="..\source\Mobs\Zombiepigman.cpp"
RelativePath="..\source\Mobs\ZombiePigman.cpp"
>
</File>
<File
RelativePath="..\source\Mobs\Zombiepigman.h"
RelativePath="..\source\Mobs\ZombiePigman.h"
>
</File>
</Filter>
@ -2003,6 +2051,14 @@
RelativePath="..\source\Blocks\BlockBrewingStand.h"
>
</File>
<File
RelativePath="..\source\Blocks\BlockButton.cpp"
>
</File>
<File
RelativePath="..\source\Blocks\BlockButton.h"
>
</File>
<File
RelativePath="..\source\blocks\BlockCactus.h"
>
@ -2027,6 +2083,14 @@
RelativePath="..\source\Blocks\BlockCobWeb.h"
>
</File>
<File
RelativePath="..\source\Blocks\BlockComparator.cpp"
>
</File>
<File
RelativePath="..\source\Blocks\BlockComparator.h"
>
</File>
<File
RelativePath="..\source\blocks\BlockCrops.h"
>
@ -2159,6 +2223,10 @@
RelativePath="..\source\blocks\BlockPiston.h"
>
</File>
<File
RelativePath="..\source\blocks\BlockPlanks.h"
>
</File>
<File
RelativePath="..\source\Blocks\BlockPumpkin.h"
>
@ -2279,6 +2347,10 @@
RelativePath="..\source\items\ItemCloth.h"
>
</File>
<File
RelativePath="..\source\Items\ItemComparator.h"
>
</File>
<File
RelativePath="..\source\items\ItemDoor.h"
>
@ -2351,10 +2423,6 @@
RelativePath="..\source\items\ItemSign.h"
>
</File>
<File
RelativePath="..\source\items\ItemSlab.h"
>
</File>
<File
RelativePath="..\source\Items\ItemSpawnEgg.h"
>
@ -2371,10 +2439,6 @@
RelativePath="..\source\Items\ItemThrowable.h"
>
</File>
<File
RelativePath="..\source\items\ItemWood.h"
>
</File>
</Filter>
<Filter
Name="Protocol"

View File

@ -630,11 +630,13 @@ public:
// TODO: Any other transparent blocks?
// One hit break blocks
g_BlockOneHitDig[E_BLOCK_ACTIVE_COMPARATOR] = true;
g_BlockOneHitDig[E_BLOCK_BROWN_MUSHROOM] = true;
g_BlockOneHitDig[E_BLOCK_CARROTS] = true;
g_BlockOneHitDig[E_BLOCK_CROPS] = true;
g_BlockOneHitDig[E_BLOCK_FIRE] = true;
g_BlockOneHitDig[E_BLOCK_FLOWER_POT] = true;
g_BlockOneHitDig[E_BLOCK_INACTIVE_COMPARATOR] = true;
g_BlockOneHitDig[E_BLOCK_LOCKED_CHEST] = true;
g_BlockOneHitDig[E_BLOCK_MELON_STEM] = true;
g_BlockOneHitDig[E_BLOCK_POTATOES] = true;
@ -655,6 +657,7 @@ public:
g_BlockOneHitDig[E_BLOCK_YELLOW_FLOWER] = true;
// Blocks that breaks when pushed by piston
g_BlockPistonBreakable[E_BLOCK_ACTIVE_COMPARATOR] = true;
g_BlockPistonBreakable[E_BLOCK_AIR] = true;
g_BlockPistonBreakable[E_BLOCK_BED] = true;
g_BlockPistonBreakable[E_BLOCK_BROWN_MUSHROOM] = true;
@ -662,6 +665,7 @@ public:
g_BlockPistonBreakable[E_BLOCK_CROPS] = true;
g_BlockPistonBreakable[E_BLOCK_DEAD_BUSH] = true;
g_BlockPistonBreakable[E_BLOCK_FIRE] = true;
g_BlockPistonBreakable[E_BLOCK_INACTIVE_COMPARATOR] = true;
g_BlockPistonBreakable[E_BLOCK_IRON_DOOR] = true;
g_BlockPistonBreakable[E_BLOCK_JACK_O_LANTERN] = true;
g_BlockPistonBreakable[E_BLOCK_LADDER] = true;
@ -694,6 +698,7 @@ public:
// Blocks that can be snowed over:
g_BlockIsSnowable[E_BLOCK_ACTIVE_COMPARATOR] = false;
g_BlockIsSnowable[E_BLOCK_AIR] = false;
g_BlockIsSnowable[E_BLOCK_BROWN_MUSHROOM] = false;
g_BlockIsSnowable[E_BLOCK_CACTUS] = false;
@ -702,6 +707,7 @@ public:
g_BlockIsSnowable[E_BLOCK_FIRE] = false;
g_BlockIsSnowable[E_BLOCK_GLASS] = false;
g_BlockIsSnowable[E_BLOCK_ICE] = false;
g_BlockIsSnowable[E_BLOCK_INACTIVE_COMPARATOR] = false;
g_BlockIsSnowable[E_BLOCK_LAVA] = false;
g_BlockIsSnowable[E_BLOCK_LILY_PAD] = false;
g_BlockIsSnowable[E_BLOCK_LOCKED_CHEST] = false;

View File

@ -323,17 +323,17 @@ enum ENUM_ITEM_ID
E_ITEM_BOOK_AND_QUILL = 386,
E_ITEM_WRITTEN_BOOK = 387,
E_ITEM_EMERALD = 388,
// TODO: missing an item: item frame
E_ITEM_ITEM_FRAME = 389,
E_ITEM_FLOWER_POT = 390,
E_ITEM_CARROT = 391,
E_ITEM_POTATO = 392,
E_ITEM_BAKED_POTATO = 393,
E_ITEM_POISONOUS_POTATO = 394,
// TODO: missing an item: empty map
E_ITEM_EMPTY_MAP = 395,
E_ITEM_GOLDEN_CARROT = 396,
E_ITEM_HEAD = 397,
E_ITEM_CARROT_ON_STICK = 398,
// TODO: missing an item: nether star
E_ITEM_NETHER_STAR = 399,
E_ITEM_PUMPKIN_PIE = 400,
E_ITEM_FIREWORK_ROCKET = 401,
E_ITEM_FIREWORK_STAR = 402,
@ -607,35 +607,60 @@ enum
// E_ITEM_SPAWN_EGG metas:
// See also cMonster::eType, since monster type and spawn egg meta are the same
E_META_SPAWN_EGG_CREEPER = 50,
E_META_SPAWN_EGG_SKELETON = 51,
E_META_SPAWN_EGG_SPIDER = 52,
E_META_SPAWN_EGG_ZOMBIE = 54,
E_META_SPAWN_EGG_GIANT = 53,
E_META_SPAWN_EGG_SLIME = 55,
E_META_SPAWN_EGG_GHAST = 56,
E_META_SPAWN_EGG_ZOMBIE_PIGMAN = 57,
E_META_SPAWN_EGG_ENDERMAN = 58,
E_META_SPAWN_EGG_CAVE_SPIDER = 59,
E_META_SPAWN_EGG_SILVERFISH = 60,
E_META_SPAWN_EGG_BLAZE = 61,
E_META_SPAWN_EGG_MAGMA_CUBE = 62,
E_META_SPAWN_EGG_ENDER_DRAGON = 63,
E_META_SPAWN_EGG_WITHER = 64,
E_META_SPAWN_EGG_BAT = 65,
E_META_SPAWN_EGG_WITCH = 66,
E_META_SPAWN_EGG_PIG = 90,
E_META_SPAWN_EGG_SHEEP = 91,
E_META_SPAWN_EGG_COW = 92,
E_META_SPAWN_EGG_CHICKEN = 93,
E_META_SPAWN_EGG_SQUID = 94,
E_META_SPAWN_EGG_WOLF = 95,
E_META_SPAWN_EGG_MOOSHROOM = 96,
E_META_SPAWN_EGG_SNOW_GOLEM = 97,
E_META_SPAWN_EGG_OCELOT = 98,
E_META_SPAWN_EGG_IRON_GOLEM = 99,
E_META_SPAWN_EGG_HORSE = 100,
E_META_SPAWN_EGG_VILLAGER = 120,
E_META_SPAWN_EGG_PICKUP = 1,
E_META_SPAWN_EGG_EXPERIENCE_ORB = 2,
E_META_SPAWN_EGG_LEASH_KNOT = 8,
E_META_SPAWN_EGG_PAINTING = 9,
E_META_SPAWN_EGG_ARROW = 10,
E_META_SPAWN_EGG_SNOWBALL = 11,
E_META_SPAWN_EGG_FIREBALL = 12,
E_META_SPAWN_EGG_SMALL_FIREBALL = 13,
E_META_SPAWN_EGG_ENDER_PEARL = 14,
E_META_SPAWN_EGG_EYE_OF_ENDER = 15,
E_META_SPAWN_EGG_SPLASH_POTION = 16,
E_META_SPAWN_EGG_EXP_BOTTLE = 17,
E_META_SPAWN_EGG_ITEM_FRAME = 18,
E_META_SPAWN_EGG_WITHER_SKULL = 19,
E_META_SPAWN_EGG_PRIMED_TNT = 20,
E_META_SPAWN_EGG_FALLING_BLOCK = 21,
E_META_SPAWN_EGG_FIREWORK = 22,
E_META_SPAWN_EGG_BOAT = 41,
E_META_SPAWN_EGG_MINECART = 42,
E_META_SPAWN_EGG_MINECART_CHEST = 43,
E_META_SPAWN_EGG_MINECART_FURNACE = 44,
E_META_SPAWN_EGG_MINECART_TNT = 45,
E_META_SPAWN_EGG_MINECART_HOPPER = 46,
E_META_SPAWN_EGG_MINECART_SPAWNER = 47,
E_META_SPAWN_EGG_CREEPER = 50,
E_META_SPAWN_EGG_SKELETON = 51,
E_META_SPAWN_EGG_SPIDER = 52,
E_META_SPAWN_EGG_GIANT = 53,
E_META_SPAWN_EGG_ZOMBIE = 54,
E_META_SPAWN_EGG_SLIME = 55,
E_META_SPAWN_EGG_GHAST = 56,
E_META_SPAWN_EGG_ZOMBIE_PIGMAN = 57,
E_META_SPAWN_EGG_ENDERMAN = 58,
E_META_SPAWN_EGG_CAVE_SPIDER = 59,
E_META_SPAWN_EGG_SILVERFISH = 60,
E_META_SPAWN_EGG_BLAZE = 61,
E_META_SPAWN_EGG_MAGMA_CUBE = 62,
E_META_SPAWN_EGG_ENDER_DRAGON = 63,
E_META_SPAWN_EGG_WITHER = 64,
E_META_SPAWN_EGG_BAT = 65,
E_META_SPAWN_EGG_WITCH = 66,
E_META_SPAWN_EGG_PIG = 90,
E_META_SPAWN_EGG_SHEEP = 91,
E_META_SPAWN_EGG_COW = 92,
E_META_SPAWN_EGG_CHICKEN = 93,
E_META_SPAWN_EGG_SQUID = 94,
E_META_SPAWN_EGG_WOLF = 95,
E_META_SPAWN_EGG_MOOSHROOM = 96,
E_META_SPAWN_EGG_SNOW_GOLEM = 97,
E_META_SPAWN_EGG_OCELOT = 98,
E_META_SPAWN_EGG_IRON_GOLEM = 99,
E_META_SPAWN_EGG_HORSE = 100,
E_META_SPAWN_EGG_VILLAGER = 120,
E_META_SPAWN_EGG_ENDER_CRYSTAL = 200,
} ;

View File

@ -0,0 +1,39 @@
#include "Globals.h"
#include "BlockButton.h"
cBlockButtonHandler::cBlockButtonHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
{
}
void cBlockButtonHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
// Flip the ON bit on/off. Using XOR bitwise operation to turn it on/off.
NIBBLETYPE Meta = ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f);
a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
if (Meta & 0x08)
{
a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
}
else
{
a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.5f);
}
// Queue a button reset (unpress), with a GetBlock to prevent duplication of buttons (press, break, wait for reset)
a_World->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ), ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f), m_BlockType == E_BLOCK_STONE_BUTTON ? 20 : 25);
}

View File

@ -0,0 +1,69 @@
#pragma once
#include "BlockHandler.h"
class cBlockButtonHandler :
public cBlockHandler
{
public:
cBlockButtonHandler(BLOCKTYPE a_BlockType);
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to 0
a_Pickups.push_back(cItem(m_BlockType == E_BLOCK_WOODEN_BUTTON ? E_BLOCK_WOODEN_BUTTON : E_BLOCK_STONE_BUTTON, 1, 0));
}
virtual bool IsUseable(void) override
{
return true;
}
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
a_BlockType = m_BlockType;
a_BlockMeta = BlockFaceToMetaData(a_BlockFace);
return true;
}
virtual const char * GetStepSound(void) override
{
return m_BlockType == E_BLOCK_WOODEN_BUTTON ? "step.wood" : "step.stone";
}
inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace)
{
switch (a_BlockFace)
{
case BLOCK_FACE_ZP: { return 0x4; }
case BLOCK_FACE_ZM: { return 0x3; }
case BLOCK_FACE_XP: { return 0x2; }
case BLOCK_FACE_XM: { return 0x1; }
default:
{
ASSERT(!"Unhandled block face!");
return 0x0; // No idea, give a special meta (button in centre of block)
}
}
}
} ;

View File

@ -0,0 +1,53 @@
#include "Globals.h"
#include "BlockComparator.h"
#include "../Simulator/RedstoneSimulator.h"
#include "../Entities/Player.h"
cBlockComparatorHandler::cBlockComparatorHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
{
}
void cBlockComparatorHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
{
// Nothing needed yet
}
void cBlockComparatorHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
}
bool cBlockComparatorHandler::GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
)
{
a_BlockType = m_BlockType;
a_BlockMeta = cRedstoneSimulator::RepeaterRotationToMetaData(a_Player->GetRotation());
return true;
}

View File

@ -0,0 +1,55 @@
#pragma once
#include "BlockHandler.h"
class cBlockComparatorHandler :
public cBlockHandler
{
public:
cBlockComparatorHandler(BLOCKTYPE a_BlockType);
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
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(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(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override;
virtual const char * GetStepSound(void) override
{
return "step.wood";
}
} ;

View File

@ -7,12 +7,14 @@
#include "../PluginManager.h"
#include "BlockBed.h"
#include "BlockBrewingStand.h"
#include "BlockButton.h"
#include "BlockCactus.h"
#include "BlockCarpet.h"
#include "BlockCauldron.h"
#include "BlockChest.h"
#include "BlockCloth.h"
#include "BlockCobWeb.h"
#include "BlockComparator.h"
#include "BlockCrops.h"
#include "BlockDeadBush.h"
#include "BlockDirt.h"
@ -41,6 +43,7 @@
#include "BlockNote.h"
#include "BlockOre.h"
#include "BlockPiston.h"
#include "BlockPlanks.h"
#include "BlockPumpkin.h"
#include "BlockRail.h"
#include "BlockRedstone.h"
@ -109,6 +112,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_ACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType);
case E_BLOCK_COBBLESTONE: return new cBlockStoneHandler (a_BlockType);
case E_BLOCK_COBBLESTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_COBWEB: return new cBlockCobWebHandler (a_BlockType);
@ -123,7 +127,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType);
case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler;
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler ( );
case E_BLOCK_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);
@ -135,6 +139,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType);
case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType);
case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
case E_BLOCK_INACTIVE_COMPARATOR: return new cBlockComparatorHandler (a_BlockType);
case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType);
case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_JUKEBOX: return new cBlockEntityHandler (a_BlockType);
@ -152,8 +157,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);
case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType);
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ();
case E_BLOCK_PLANKS: return new cBlockWoodHandler (a_BlockType);
case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler ( );
case E_BLOCK_PLANKS: return new cBlockPlanksHandler (a_BlockType);
case E_BLOCK_PUMPKIN: return new cBlockPumpkinHandler (a_BlockType);
case E_BLOCK_JACK_O_LANTERN: return new cBlockPumpkinHandler (a_BlockType);
case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType);
@ -181,6 +186,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_STICKY_PISTON: return new cBlockPistonHandler (a_BlockType);
case E_BLOCK_STONE: return new cBlockStoneHandler (a_BlockType);
case E_BLOCK_STONE_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_STONE_BUTTON: return new cBlockButtonHandler (a_BlockType);
case E_BLOCK_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
case E_BLOCK_SUGARCANE: return new cBlockSugarcaneHandler (a_BlockType);
case E_BLOCK_TALL_GRASS: return new cBlockTallGrassHandler (a_BlockType);
@ -188,6 +194,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType);
case E_BLOCK_WALLSIGN: return new cBlockSignHandler (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_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
case E_BLOCK_WOODEN_STAIRS: return new cBlockStairsHandler (a_BlockType);
@ -354,15 +361,20 @@ void cBlockHandler::DropBlock(cWorld * a_World, cEntity * a_Digger, int a_BlockX
if (!Pickups.empty())
{
// Add random offset to the spawn position:
// Commented out until bug with pickups not spawning properly is fixed, see World.cpp
/*
int MicroX = (int)(a_BlockX * 32) + (r1.randInt(16) + r1.randInt(16) - 16);
int MicroY = (int)(a_BlockY * 32) + (r1.randInt(16) + r1.randInt(16) - 16);
int MicroZ = (int)(a_BlockZ * 32) + (r1.randInt(16) + r1.randInt(16) - 16);
*/
MTRand r1;
a_World->SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
// 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 (this causes pickups to spawn inside blocks most times, it's a little buggy)
//MicroX += (int)(r1.randInt(16) + r1.randInt(16) - 16);
//MicroY += (int)(r1.randInt(16) + r1.randInt(16) - 16);
//MicroZ += (int)(r1.randInt(16) + r1.randInt(16) - 16);
a_World->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ);
}
}

View File

@ -1,8 +1,6 @@
#include "Globals.h"
#include "BlockLever.h"
#include "../Item.h"
#include "../World.h"
#include "../Entities/Player.h"
#include "../Simulator/RedstoneSimulator.h"
@ -23,7 +21,8 @@ void cBlockLeverHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX,
{
// Flip the ON bit on/off. Using XOR bitwise operation to turn it on/off.
NIBBLETYPE Meta = ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08) & 0x0f);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta);
a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
if (Meta & 0x08)
{
a_World->BroadcastSoundEffect("random.click", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
@ -37,12 +36,3 @@ void cBlockLeverHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX,
void cBlockLeverHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NONE, 8, 8, 8);
}

View File

@ -1,7 +1,6 @@
#pragma once
#include "BlockHandler.h"
#include "../World.h"
#include "../Simulator/RedstoneSimulator.h"
@ -14,7 +13,6 @@ class cBlockLeverHandler :
public:
cBlockLeverHandler(BLOCKTYPE a_BlockType);
virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;

View File

@ -0,0 +1,41 @@
#pragma once
#include "BlockHandler.h"
class cBlockPlanksHandler : public cBlockHandler
{
public:
cBlockPlanksHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
{
}
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
a_BlockType = m_BlockType;
NIBBLETYPE Meta = a_Player->GetEquippedItem().m_ItemDamage;
a_BlockMeta = Meta;
return true;
}
virtual const char * GetStepSound(void) override
{
return "step.wood";
}
} ;

View File

@ -1,9 +1,8 @@
#include "Globals.h"
#include "BlockRedstoneRepeater.h"
#include "../Item.h"
#include "../World.h"
#include "../Simulator/RedstoneSimulator.h"
#include "../Entities/Player.h"
@ -29,16 +28,22 @@ void cBlockRedstoneRepeaterHandler::OnDestroyed(cWorld *a_World, int a_BlockX, i
void cBlockRedstoneRepeaterHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
}
void cBlockRedstoneRepeaterHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
bool cBlockRedstoneRepeaterHandler::GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
)
{
OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_NONE, 8, 8, 8);
a_BlockType = m_BlockType;
a_BlockMeta = cRedstoneSimulator::RepeaterRotationToMetaData(a_Player->GetRotation());
return true;
}

View File

@ -2,7 +2,6 @@
#pragma once
#include "BlockHandler.h"
#include "../World.h"
@ -15,7 +14,6 @@ public:
cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType);
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
@ -36,6 +34,15 @@ public:
{
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
}
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override;
virtual const char * GetStepSound(void) override
{

View File

@ -15,8 +15,28 @@ public:
: cBlockHandler(a_BlockType)
{
}
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
a_BlockType = m_BlockType;
NIBBLETYPE Meta = a_World->GetBlockMeta(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
if ((Meta < 7) && (Meta != 0)) // Is height at maximum (7) or at mininum (0)? Don't do anything if so
{
Meta++;
}
a_BlockMeta = Meta;
return true;
}
virtual bool DoesIgnoreBuildCollision(void) override
{
return true;

View File

@ -53,7 +53,6 @@ public:
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 90 + 45; // So its not aligned with axis
NIBBLETYPE result = 0x0;
if (a_Rotation > 360)
{
a_Rotation -= 360;

View File

@ -15,6 +15,51 @@ public:
{
}
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
a_BlockType = m_BlockType;
NIBBLETYPE Meta = a_Player->GetEquippedItem().m_ItemDamage;
a_BlockMeta = BlockFaceToMetaData(a_BlockFace, Meta);
return true;
}
inline static NIBBLETYPE BlockFaceToMetaData(char a_BlockFace, NIBBLETYPE a_WoodMeta)
{
switch (a_BlockFace)
{
case BLOCK_FACE_YM:
case BLOCK_FACE_YP:
{
return a_WoodMeta; // Top or bottom, just return original
}
case BLOCK_FACE_ZP:
case BLOCK_FACE_ZM:
{
return a_WoodMeta | 0x8; // North or south
}
case BLOCK_FACE_XP:
case BLOCK_FACE_XM:
{
return a_WoodMeta | 0x4; // East or west
}
default:
{
ASSERT(!"Unhandled block face!");
return a_WoodMeta | 0xC; // No idea, give a special meta (all sides bark)
}
}
}
virtual const char * GetStepSound(void) override
{

View File

@ -1917,7 +1917,7 @@ void cClientHandle::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleTypeType is specific to Minecarts
void cClientHandle::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType) // VehicleSubType is specific to Minecarts
{
m_Protocol->SendSpawnVehicle(a_Vehicle, a_VehicleType, a_VehicleSubType);
}

View File

@ -10,7 +10,6 @@
#pragma once
#include "Entity.h"
#include "../Item.h"

View File

@ -10,7 +10,6 @@
#pragma once
#include "Entity.h"
#include "../Item.h"

View File

@ -24,8 +24,8 @@
cPickup::cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */)
: cEntity(etPickup, (((double)(a_MicroPosX)) / 32) + 0.1 /*Accomodate player vomiting*/, ((double)(a_MicroPosY)) / 32, ((double)(a_MicroPosZ)) / 32, 0.2, 0.2)
cPickup::cPickup(double a_X, double a_Y, double a_Z, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */)
: cEntity(etPickup, a_X, a_Y, a_Z, 0.2, 0.2)
, m_Timer( 0.f )
, m_Item(a_Item)
, m_bCollected( false )

View File

@ -24,7 +24,7 @@ class cPickup :
public:
CLASS_PROTODEF(cPickup);
cPickup(int a_MicroPosX, int a_MicroPosY, int a_MicroPosZ, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); // tolua_export
cPickup(double a_MicroPosX, double a_MicroPosY, double a_MicroPosZ, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); // tolua_export
cItem & GetItem(void) {return m_Item; } // tolua_export
const cItem & GetItem(void) const {return m_Item; }

View File

@ -0,0 +1,40 @@
#pragma once
#include "ItemHandler.h"
#include "../Simulator/RedstoneSimulator.h"
class cItemComparatorHandler :
public cItemHandler
{
public:
cItemComparatorHandler(int a_ItemType) :
cItemHandler(a_ItemType)
{
}
virtual bool IsPlaceable(void) override
{
return true;
}
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
int a_CursorX, int a_CursorY, int a_CursorZ,
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
a_BlockType = E_BLOCK_INACTIVE_COMPARATOR;
a_BlockMeta = cRedstoneSimulator::RepeaterRotationToMetaData(a_Player->GetRotation());
return true;
}
} ;

View File

@ -14,6 +14,7 @@
#include "ItemBucket.h"
#include "ItemCauldron.h"
#include "ItemCloth.h"
#include "ItemComparator.h"
#include "ItemDoor.h"
#include "ItemDye.h"
#include "ItemFlowerPot.h"
@ -31,11 +32,9 @@
#include "ItemShears.h"
#include "ItemShovel.h"
#include "ItemSign.h"
#include "ItemSlab.h"
#include "ItemSpawnEgg.h"
#include "ItemSugarcane.h"
#include "ItemSword.h"
#include "ItemWood.h"
#include "../Blocks/BlockHandler.h"
@ -94,6 +93,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_BOW: return new cItemBowHandler;
case E_ITEM_BREWING_STAND: return new cItemBrewingStandHandler(a_ItemType);
case E_ITEM_CAULDRON: return new cItemCauldronHandler(a_ItemType);
case E_ITEM_COMPARATOR: return new cItemComparatorHandler(a_ItemType);
case E_ITEM_DYE: return new cItemDyeHandler(a_ItemType);
case E_ITEM_EGG: return new cItemEggHandler();
case E_ITEM_ENDER_PEARL: return new cItemEnderPearlHandler();
@ -143,18 +143,6 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
return new cItemSwordHandler(a_ItemType);
}
case E_BLOCK_STONE_SLAB:
case E_BLOCK_WOODEN_SLAB:
{
return new cItemSlabHandler(a_ItemType);
}
case E_BLOCK_LOG:
case E_BLOCK_PLANKS:
{
return new cItemWoodHandler(a_ItemType);
}
case E_ITEM_BUCKET:
case E_ITEM_WATER_BUCKET:
case E_ITEM_LAVA_BUCKET:

View File

@ -1,52 +0,0 @@
#pragma once
#include "ItemHandler.h"
#include "../World.h"
class cItemSlabHandler : public cItemHandler
{
public:
cItemSlabHandler(int a_ItemType)
: cItemHandler(a_ItemType)
{
}
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
{
BLOCKTYPE Block;
NIBBLETYPE Meta;
a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, Block, Meta);
if (
((a_Dir == 0) || (a_Dir == 1)) // Only when clicking on top or on bottom of the block
&& ((Block == E_BLOCK_WOODEN_SLAB) || (Block == E_BLOCK_STONE_SLAB)) // It is a slab
&& (Block == a_Item.m_ItemType) // Same slab
&& ((Meta & 0x7) == (a_Item.m_ItemDamage & 0x7))) // Same Texture
{
if (a_Player->GetGameMode() == eGameMode_Creative)
{
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, Block - 1, Meta); // Block - 1 simple hack to save one if statement
return true;
}
else
{
if (a_Player->GetInventory().RemoveOneEquippedItem())
{
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, Block - 1, Meta); // Block - 1 simple hack to save one if statement
return true;
}
}
}
return false;
}
} ;

View File

@ -1,22 +0,0 @@
#pragma once
#include "ItemHandler.h"
class cItemWoodHandler :
public cItemHandler
{
public:
cItemWoodHandler(int a_ItemType)
: cItemHandler(a_ItemType)
{
}
} ;

View File

@ -0,0 +1,27 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "EnderDragon.h"
cEnderDragon::cEnderDragon(void) :
// TODO: Vanilla source says this, but is it right? Dragons fly, they don't stand
super("EnderDragon", 63, "mob.enderdragon.hit", "mob.enderdragon.end", 16.0, 8.0)
{
}
void cEnderDragon::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
return;
}

25
source/Mobs/EnderDragon.h Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#include "AggressiveMonster.h"
class cEnderDragon :
public cAggressiveMonster
{
typedef cAggressiveMonster super;
public:
cEnderDragon(void);
CLASS_PROTODEF(cEnderDragon);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;

27
source/Mobs/Giant.cpp Normal file
View File

@ -0,0 +1,27 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Giant.h"
cGiant::cGiant(void) :
// TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
super("Giant", 53, "mob.zombie.hurt", "mob.zombie.death", 2.0, 13.5)
{
}
void cGiant::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 10, 50, E_ITEM_ROTTEN_FLESH);
}

25
source/Mobs/Giant.h Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#include "AggressiveMonster.h"
class cGiant :
public cAggressiveMonster
{
typedef cAggressiveMonster super;
public:
cGiant(void);
CLASS_PROTODEF(cGiant);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;

26
source/Mobs/Horse.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Horse.h"
cHorse::cHorse(void) :
super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6)
{
}
void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 0, 2, E_ITEM_LEATHER);
}

25
source/Mobs/Horse.h Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#include "AggressiveMonster.h"
class cHorse :
public cPassiveMonster
{
typedef cPassiveMonster super;
public:
cHorse(void);
CLASS_PROTODEF(cHorse);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;

26
source/Mobs/IronGolem.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "IronGolem.h"
cIronGolem::cIronGolem(void) :
super("IronGolem", 99, "mob.IronGolem.hit", "mob.IronGolem.death", 1.4, 2.9)
{
}
void cIronGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 0, 5, E_ITEM_IRON);
}

25
source/Mobs/IronGolem.h Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#include "AggressiveMonster.h"
class cIronGolem :
public cPassiveAggressiveMonster
{
typedef cPassiveAggressiveMonster super;
public:
cIronGolem(void);
CLASS_PROTODEF(cIronGolem);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;

View File

@ -1,14 +1,14 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Magmacube.h"
#include "MagmaCube.h"
cMagmacube::cMagmacube(int a_Size) :
super("Magmacube", 62, "mob.magmacube.big", "mob.magmacube.big", 0.6 * a_Size, 0.6 * a_Size),
cMagmaCube::cMagmaCube(int a_Size) :
super("MagmaCube", 62, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size),
m_Size(a_Size)
{
}
@ -17,7 +17,7 @@ cMagmacube::cMagmacube(int a_Size) :
void cMagmacube::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cMagmaCube::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_MAGMA_CREAM);
}

View File

@ -7,22 +7,22 @@
class cMagmacube :
class cMagmaCube :
public cAggressiveMonster
{
typedef cAggressiveMonster super;
public:
/// Creates a magmacube of the specified size; size is 1 .. 3, with 1 being the smallest
cMagmacube(int a_Size);
/// Creates a MagmaCube of the specified size; size is 1 .. 3, with 1 being the smallest
cMagmaCube(int a_Size);
CLASS_PROTODEF(cMagmacube);
CLASS_PROTODEF(cMagmaCube);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
protected:
/// Size of the magmacube, 1 .. 3, with 1 being the smallest
/// Size of the MagmaCube, 1 .. 3, with 1 being the smallest
int m_Size;
} ;

View File

@ -26,34 +26,36 @@ public:
/// This identifies individual monster type, as well as their network type-ID
enum eType
{
mtCreeper = E_META_SPAWN_EGG_CREEPER,
mtSkeleton = E_META_SPAWN_EGG_SKELETON,
mtSpider = E_META_SPAWN_EGG_SPIDER,
mtGiant = E_META_SPAWN_EGG_GIANT,
mtZombie = E_META_SPAWN_EGG_ZOMBIE,
mtSlime = E_META_SPAWN_EGG_SLIME,
mtGhast = E_META_SPAWN_EGG_GHAST,
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
mtEnderman = E_META_SPAWN_EGG_ENDERMAN,
mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER,
mtSilverfish = E_META_SPAWN_EGG_SILVERFISH,
mtBlaze = E_META_SPAWN_EGG_BLAZE,
mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE,
mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON,
mtWither = E_META_SPAWN_EGG_WITHER,
mtBat = E_META_SPAWN_EGG_BAT,
mtWitch = E_META_SPAWN_EGG_WITCH,
mtBlaze = E_META_SPAWN_EGG_BLAZE,
mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER,
mtChicken = E_META_SPAWN_EGG_CHICKEN,
mtCow = E_META_SPAWN_EGG_COW,
mtCreeper = E_META_SPAWN_EGG_CREEPER,
mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON,
mtEnderman = E_META_SPAWN_EGG_ENDERMAN,
mtGhast = E_META_SPAWN_EGG_GHAST,
mtGiant = E_META_SPAWN_EGG_GIANT,
mtHorse = E_META_SPAWN_EGG_HORSE,
mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM,
mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE,
mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM,
mtOcelot = E_META_SPAWN_EGG_OCELOT,
mtPig = E_META_SPAWN_EGG_PIG,
mtSheep = E_META_SPAWN_EGG_SHEEP,
mtCow = E_META_SPAWN_EGG_COW,
mtChicken = E_META_SPAWN_EGG_CHICKEN,
mtSquid = E_META_SPAWN_EGG_SQUID,
mtWolf = E_META_SPAWN_EGG_WOLF,
mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM,
mtSilverfish = E_META_SPAWN_EGG_SILVERFISH,
mtSkeleton = E_META_SPAWN_EGG_SKELETON,
mtSlime = E_META_SPAWN_EGG_SLIME,
mtSnowGolem = E_META_SPAWN_EGG_SNOW_GOLEM,
mtOcelot = E_META_SPAWN_EGG_OCELOT,
mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM,
mtSpider = E_META_SPAWN_EGG_SPIDER,
mtSquid = E_META_SPAWN_EGG_SQUID,
mtVillager = E_META_SPAWN_EGG_VILLAGER,
mtWitch = E_META_SPAWN_EGG_WITCH,
mtWither = E_META_SPAWN_EGG_WITHER,
mtWolf = E_META_SPAWN_EGG_WOLF,
mtZombie = E_META_SPAWN_EGG_ZOMBIE,
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
} ;
// tolua_end
@ -110,7 +112,7 @@ public:
void SetSightDistance(float sd);
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight(bool a_BurnsInDaylight) { a_BurnsInDaylight = a_BurnsInDaylight; }
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality;

26
source/Mobs/SnowGolem.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "SnowGolem.h"
cSnowGolem::cSnowGolem(void) :
super("SnowGolem", 97, "", "", 0.4, 1.8)
{
}
void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 0, 5, E_ITEM_SNOWBALL);
}

25
source/Mobs/SnowGolem.h Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#include "AggressiveMonster.h"
class cSnowGolem :
public cAggressiveMonster
{
typedef cAggressiveMonster super;
public:
cSnowGolem(void);
CLASS_PROTODEF(cSnowGolem);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;

26
source/Mobs/Wither.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Wither.h"
cWither::cWither(void) :
super("Wither", 64, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0)
{
}
void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 1, 1, E_ITEM_NETHER_STAR);
}

25
source/Mobs/Wither.h Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#include "AggressiveMonster.h"
class cWither :
public cAggressiveMonster
{
typedef cAggressiveMonster super;
public:
cWither(void);
CLASS_PROTODEF(cWither);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
} ;

View File

@ -1,15 +1,15 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Zombiepigman.h"
#include "ZombiePigman.h"
#include "../World.h"
cZombiepigman::cZombiepigman(void) :
super("Zombiepigman", 57, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8)
cZombiePigman::cZombiePigman(void) :
super("ZombiePigman", 57, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8)
{
}
@ -17,23 +17,7 @@ cZombiepigman::cZombiepigman(void) :
void cZombiepigman::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
// TODO Same as noticed in cSkeleton AND Do they really burn by sun?? :D In the neather is no sun :D
if ((GetWorld()->GetTimeOfDay() < (12000 + 1000)) && !IsOnFire())
{
// Burn for 10 ticks, then decide again
StartBurning(10);
}
}
void cZombiepigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_ROTTEN_FLESH);
AddRandomDropItem(a_Drops, 0, 1, E_ITEM_GOLD_NUGGET);
@ -45,7 +29,7 @@ void cZombiepigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cZombiepigman::KilledBy(cEntity * a_Killer)
void cZombiePigman::KilledBy(cEntity * a_Killer)
{
super::KilledBy(a_Killer);

View File

@ -7,17 +7,16 @@
class cZombiepigman :
class cZombiePigman :
public cPassiveAggressiveMonster
{
typedef cPassiveAggressiveMonster super;
public:
cZombiepigman(void);
cZombiePigman(void);
CLASS_PROTODEF(cZombiepigman);
CLASS_PROTODEF(cZombiePigman);
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void KilledBy(cEntity * a_Killer) override;
} ;

View File

@ -21,7 +21,7 @@ extern bool g_BlockPistonBreakable[];
/// Number of ticks that the piston extending / retracting waits before setting the block
const int PISTON_TICK_DELAY = 10;
const int PISTON_TICK_DELAY = 20;

View File

@ -35,8 +35,12 @@
#include "Mobs/Cow.h"
#include "Mobs/Creeper.h"
#include "Mobs/Enderman.h"
#include "Mobs/EnderDragon.h"
#include "Mobs/Ghast.h"
#include "Mobs/Magmacube.h"
#include "Mobs/Giant.h"
#include "Mobs/Horse.h"
#include "Mobs/IronGolem.h"
#include "Mobs/MagmaCube.h"
#include "Mobs/Mooshroom.h"
#include "Mobs/Ocelot.h"
#include "Mobs/Pig.h"
@ -44,13 +48,15 @@
#include "Mobs/Silverfish.h"
#include "Mobs/Skeleton.h"
#include "Mobs/Slime.h"
#include "Mobs/SnowGolem.h"
#include "Mobs/Spider.h"
#include "Mobs/Squid.h"
#include "Mobs/Villager.h"
#include "Mobs/Witch.h"
#include "Mobs/Wither.h"
#include "Mobs/Wolf.h"
#include "Mobs/Zombie.h"
#include "Mobs/Zombiepigman.h"
#include "Mobs/ZombiePigman.h"
#include "OSSupport/MakeDir.h"
#include "MersenneTwister.h"
@ -1516,14 +1522,9 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500));
float SpeedY = 1;
float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500));
// Pickup doesn't spawn on client without a mid block position. Perhaps the doubles are causing issues?
int MicroX = (int)(floor(a_BlockX) * 32) + 16;
int MicroY = (int)(floor(a_BlockY) * 32) + 16;
int MicroZ = (int)(floor(a_BlockZ) * 32) + 16;
cPickup * Pickup = new cPickup(
MicroX, MicroY, MicroZ,
a_BlockX, a_BlockY, a_BlockZ,
*itr, SpeedX, SpeedY, SpeedZ
);
Pickup->Initialize(this);
@ -1536,16 +1537,10 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ)
{
MTRand r1;
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
{
// Pickup doesn't spawn on client without a mid block position. Perhaps the doubles are causing issues?
int MicroX = (int)(floor(a_BlockX) * 32) + 16;
int MicroY = (int)(floor(a_BlockY) * 32) + 16;
int MicroZ = (int)(floor(a_BlockZ) * 32) + 16;
cPickup * Pickup = new cPickup(
MicroX, MicroY, MicroZ,
a_BlockX, a_BlockY, a_BlockZ,
*itr, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ
);
Pickup->Initialize(this);
@ -2588,8 +2583,12 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp
case cMonster::mtCow: Monster = new cCow(); break;
case cMonster::mtCreeper: Monster = new cCreeper(); break;
case cMonster::mtEnderman: Monster = new cEnderman(); break;
case cMonster::mtEnderDragon: Monster = new cEnderDragon(); break;
case cMonster::mtGhast: Monster = new cGhast(); break;
case cMonster::mtMagmaCube: Monster = new cMagmacube(Size); break;
case cMonster::mtGiant: Monster = new cGiant(); break;
case cMonster::mtHorse: Monster = new cHorse(); break;
case cMonster::mtIronGolem: Monster = new cIronGolem(); break;
case cMonster::mtMagmaCube: Monster = new cMagmaCube(Size); break;
case cMonster::mtMooshroom: Monster = new cMooshroom(); break;
case cMonster::mtOcelot: Monster = new cOcelot(); break;
case cMonster::mtPig: Monster = new cPig(); break;
@ -2597,13 +2596,15 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp
case cMonster::mtSilverfish: Monster = new cSilverfish(); break;
case cMonster::mtSkeleton: Monster = new cSkeleton(); break;
case cMonster::mtSlime: Monster = new cSlime(Size); break;
case cMonster::mtSnowGolem: Monster = new cSnowGolem(); break;
case cMonster::mtSpider: Monster = new cSpider(); break;
case cMonster::mtSquid: Monster = new cSquid(); break;
case cMonster::mtVillager: Monster = new cVillager(); break;
case cMonster::mtWitch: Monster = new cWitch(); break;
case cMonster::mtWither: Monster = new cWither(); break;
case cMonster::mtWolf: Monster = new cWolf(); break;
case cMonster::mtZombie: Monster = new cZombie(); break;
case cMonster::mtZombiePigman: Monster = new cZombiepigman(); break;
case cMonster::mtZombiePigman: Monster = new cZombiePigman(); break;
default:
{