diff options
37 files changed, 832 insertions, 214 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f5777b67e..82bbe9e0d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -487,9 +487,9 @@ g_APIDesc = ]], Functions = { - Sort = { Notes = "void" }, - IsInside = { Notes = "bool" }, - IsInside = { Notes = "bool" }, + Sort = { Return = "" }, + IsInside = { Return = "bool" }, + IsInside = { Return = "bool" }, }, Variables = { @@ -688,14 +688,14 @@ g_APIDesc = ]], Functions = { - SetName = { Notes = "void" }, - GetName = { Notes = "String" }, - SetColor = { Notes = "void" }, - GetColor = { Notes = "String" }, - AddCommand = { Notes = "void" }, - HasCommand = { Notes = "bool" }, - AddPermission = { Notes = "void" }, - InheritFrom = { Notes = "void" }, + SetName = { Return = "" }, + GetName = { Return = "string" }, + SetColor = { Return = "" }, + GetColor = { Return = "string" }, + AddCommand = { Return = "" }, + HasCommand = { Return = "bool" }, + AddPermission = { Return = "" }, + InheritFrom = { Return = "" }, }, Constants = { @@ -709,16 +709,16 @@ g_APIDesc = Functions = { constructor = { Return = "{{cIniFile|cIniFile}}" }, - CaseSensitive = { Notes = "void" }, - CaseInsensitive = { Notes = "void" }, - Path = { Notes = "void" }, - Path = { Notes = "String" }, - SetPath = { Notes = "void" }, - ReadFile = { Notes = "bool" }, - WriteFile = { Notes = "bool" }, - Erase = { Notes = "void" }, - Clear = { Notes = "void" }, - Reset = { Notes = "void" }, + CaseSensitive = { Return = "" }, + CaseInsensitive = { Return = "" }, + Path = { Return = "" }, + Path = { Return = "string" }, + SetPath = { Return = "" }, + ReadFile = { Return = "bool" }, + WriteFile = { Return = "bool" }, + Erase = { Return = "" }, + Clear = { Return = "" }, + Reset = { Return = "" }, FindKey = { Notes = "long i" }, FindValue = { Notes = "long i" }, NumKeys = { Notes = "unsigned i" }, @@ -743,29 +743,29 @@ g_APIDesc = GetValueSetI = { Notes = "i" }, GetValueSetB = { Notes = "bo" }, GetValueSetF = { Notes = "doub" }, - SetValue = { Notes = "bool" }, - SetValue = { Notes = "bool" }, - SetValueI = { Notes = "bool" }, - SetValueB = { Notes = "bool" }, - SetValueF = { Notes = "bool" }, - DeleteValueByID = { Notes = "bool" }, - DeleteValue = { Notes = "bool" }, - DeleteKey = { Notes = "bool" }, + SetValue = { Return = "bool" }, + SetValue = { Return = "bool" }, + SetValueI = { Return = "bool" }, + SetValueB = { Return = "bool" }, + SetValueF = { Return = "bool" }, + DeleteValueByID = { Return = "bool" }, + DeleteValue = { Return = "bool" }, + DeleteKey = { Return = "bool" }, NumHeaderComments = { Notes = "unsigned int" }, - HeaderComment = { Notes = "void" }, + HeaderComment = { Return = "" }, HeaderComment = { Notes = "Stri" }, - DeleteHeaderComment = { Notes = "bool" }, - DeleteHeaderComments = { Notes = "void" }, + DeleteHeaderComment = { Return = "bool" }, + DeleteHeaderComments = { Return = "" }, NumKeyComments = { Notes = "unsigned i" }, NumKeyComments = { Notes = "unsigned i" }, - KeyComment = { Notes = "bool" }, - KeyComment = { Notes = "bool" }, + KeyComment = { Return = "bool" }, + KeyComment = { Return = "bool" }, KeyComment = { Notes = "Stri" }, KeyComment = { Notes = "Stri" }, - DeleteKeyComment = { Notes = "bool" }, - DeleteKeyComment = { Notes = "bool" }, - DeleteKeyComments = { Notes = "bool" }, - DeleteKeyComments = { Notes = "bool" }, + DeleteKeyComment = { Return = "bool" }, + DeleteKeyComment = { Return = "bool" }, + DeleteKeyComments = { Return = "bool" }, + DeleteKeyComments = { Return = "bool" }, }, Constants = { @@ -1042,12 +1042,12 @@ a_Player:OpenWindow(Window); ]], Functions = { - TeleportToEntity = { Notes = "void" }, - TeleportTo = { Notes = "void" }, - Heal = { Notes = "void" }, - TakeDamage = { Notes = "void" }, - KilledBy = { Notes = "void" }, - GetHealth = { Notes = "int" }, + TeleportToEntity = { Return = "" }, + TeleportTo = { Return = "" }, + Heal = { Return = "" }, + TakeDamage = { Return = "" }, + KilledBy = { Return = "" }, + GetHealth = { Return = "number" }, }, Constants = { @@ -1063,7 +1063,7 @@ a_Player:OpenWindow(Window); { cPickup = { Notes = "[[cPickup}}" }, GetItem = { Notes = "{{cItem|cItem}}" }, - CollectedBy = { Notes = "bool" }, + CollectedBy = { Return = "bool" }, }, Constants = { @@ -1077,40 +1077,35 @@ a_Player:OpenWindow(Window); ]], Functions = { - GetEyeHeight = { Notes = "double" }, - GetEyePosition = { Notes = "{{Vector3d|Vector3d}}" }, - GetFlying = { Notes = "bool" }, - GetStance = { Notes = "double" }, - GetInventory = { Notes = "{{cInventory|cInventory}}" }, - TeleportTo = { Notes = "void" }, - GetGameMode = { Notes = "{{eGameMode|eGameMode}}" }, - GetIP = { Notes = "String" }, - GetLastBlockActionTime = { Notes = "float" }, - GetLastBlockActionCnt = { Notes = "int" }, - SetLastBlockActionCnt = { Notes = "void" }, - SetLastBlockActionTime = { Notes = "void" }, - SetGameMode = { Notes = "void" }, - MoveTo = { Notes = "void" }, - GetClientHandle = { Notes = "{{cClientHandle|cClientHandle}}" }, - SendMessage = { Notes = "void" }, - GetName = { Notes = "String" }, - SetName = { Notes = "void" }, - AddToGroup = { Notes = "void" }, - CanUseCommand = { Notes = "bool" }, - HasPermission = { Notes = "bool" }, - IsInGroup = { Notes = "bool" }, - GetColor = { Notes = "String" }, - TossItem = { Notes = "void" }, - Heal = { Notes = "void" }, - TakeDamage = { Notes = "void" }, - KilledBy = { Notes = "void" }, - Respawn = { Notes = "void" }, - SetVisible = { Notes = "void" }, - IsVisible = { Notes = "bool" }, - MoveToWorld = { Notes = "bool" }, - LoadPermissionsFromDisk = { Notes = "void" }, - GetGroups = { Notes = "list<{{cGroup|cGroup}}>" }, - GetResolvedPermissions = { Notes = "String" }, + GetEyeHeight = { Return = "number" }, + GetEyePosition = { Return = "{{Vector3d|EyePositionVector}}" }, + GetFlying = { Return = "bool" }, + GetStance = { Return = "number" }, + GetInventory = { Return = "{{cInventory|Inventory}}" }, + GetGameMode = { Return = "{{eGameMode|GameMode}}", Notes = "Returns the player's gamemode. The player may have their gamemode unassigned, in which case they inherit the gamemode from the current {{cWorld|world}}.<br /> <b>NOTE:</b> Instead of comparing the value returned by this function to the gmXXX constants, use the IsGameModeXXX() functions. These functions handle the gamemode inheritance automatically."}, + GetIP = { Return = "string" }, + SetGameMode = { Return = "" }, + MoveTo = { Return = "" }, + GetClientHandle = { Return = "{{cClientHandle|ClientHandle}}" }, + SendMessage = { Return = "" }, + GetName = { Return = "String" }, + SetName = { Return = "" }, + AddToGroup = { Return = "" }, + CanUseCommand = { Return = "bool" }, + HasPermission = { Return = "bool" }, + IsInGroup = { Return = "bool" }, + GetColor = { Return = "string" }, + TossItem = { Return = "" }, + Heal = { Return = "" }, + TakeDamage = { Return = "" }, + KilledBy = { Return = "" }, + Respawn = { Return = "" }, + SetVisible = { Return = "" }, + IsVisible = { Return = "bool" }, + MoveToWorld = { Return = "bool" }, + LoadPermissionsFromDisk = { Return = "" }, + GetGroups = { Return = "list<{{cGroup|cGroup}}>" }, + GetResolvedPermissions = { Return = "string" }, }, Constants = { @@ -1124,11 +1119,11 @@ a_Player:OpenWindow(Window); ]], Functions = { - GetName = { Notes = "String" }, - SetName = { Notes = "void" }, + GetName = { Return = "string" }, + SetName = { Return = "" }, GetVersion = { Notes = "int" }, - SetVersion = { Notes = "void" }, - GetFileName = { Notes = "String" }, + SetVersion = { Return = "" }, + GetFileName = { Return = "string" }, CreateWebPlugin = { Notes = "{{cWebPlugin|cWebPlugin}}" }, }, Constants = diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index e985c2ff6..c4776949e 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -15,7 +15,14 @@ -#ifdef _DEBUG +/// When defined, the following macro causes a sleep after each parsed packet (DEBUG-mode only) +// #define SLEEP_AFTER_PACKET + + + + + +#if defined(_DEBUG) && defined(SLEEP_AFTER_PACKET) #define DebugSleep Sleep #else #define DebugSleep(X) @@ -182,6 +189,7 @@ enum PACKET_BLOCK_CHANGE = 0x35, PACKET_BLOCK_ACTION = 0x36, PACKET_MAP_CHUNK_BULK = 0x38, + PACKET_EXPLOSION = 0x3c, PACKET_SOUND_EFFECT = 0x3d, PACKET_NAMED_SOUND_EFFECT = 0x3e, PACKET_CHANGE_GAME_STATE = 0x46, @@ -299,7 +307,7 @@ void cConnection::Run(void) Log("Cannot connect to server; aborting"); return; } - + while (true) { fd_set ReadFDs; @@ -694,6 +702,7 @@ bool cConnection::DecodeServersPackets(const char * a_Data, int a_Size) case PACKET_ENTITY_STATUS: HANDLE_SERVER_READ(HandleServerEntityStatus); break; case PACKET_ENTITY_TELEPORT: HANDLE_SERVER_READ(HandleServerEntityTeleport); break; case PACKET_ENTITY_VELOCITY: HANDLE_SERVER_READ(HandleServerEntityVelocity); break; + case PACKET_EXPLOSION: HANDLE_SERVER_READ(HandleServerExplosion); break; case PACKET_INCREMENT_STATISTIC: HANDLE_SERVER_READ(HandleServerIncrementStatistic); break; case PACKET_KEEPALIVE: HANDLE_SERVER_READ(HandleServerKeepAlive); break; case PACKET_KICK: HANDLE_SERVER_READ(HandleServerKick); break; @@ -1586,6 +1595,49 @@ bool cConnection::HandleServerEntityVelocity(void) +bool cConnection::HandleServerExplosion(void) +{ + HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosX); + HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosY); + HANDLE_SERVER_PACKET_READ(ReadBEDouble, double, PosZ); + HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, Force); + HANDLE_SERVER_PACKET_READ(ReadBEInt, int, NumRecords); + struct sCoords + { + int x, y, z; + + sCoords(int a_X, int a_Y, int a_Z) : x(a_X), y(a_Y), z(a_Z) {} + } ; + std::vector<sCoords> Records; + Records.reserve(NumRecords); + int PosXI = (int)PosX, PosYI = (int)PosY, PosZI = (int)PosZ; + for (int i = 0; i < NumRecords; i++) + { + HANDLE_SERVER_PACKET_READ(ReadChar, char, rx); + HANDLE_SERVER_PACKET_READ(ReadChar, char, ry); + HANDLE_SERVER_PACKET_READ(ReadChar, char, rz); + Records.push_back(sCoords(PosXI + rx, PosYI + ry, PosZI + rz)); + } + HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, PlayerMotionX); + HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, PlayerMotionY); + HANDLE_SERVER_PACKET_READ(ReadBEFloat, float, PlayerMotionZ); + Log("Received a PACKET_EXPLOSION from the server:"); + Log(" Pos = {%.02f, %.02f, %.02f}", PosX, PosY, PosZ); + Log(" Force = %.02f", Force); + Log(" NumRecords = %d", NumRecords); + for (int i = 0; i < NumRecords; i++) + { + Log(" Records[%d] = {%d, %d, %d}", i, Records[i].x, Records[i].y, Records[i].z); + } + Log(" Player motion = <%.02f, %.02f, %.02f>", PlayerMotionX, PlayerMotionY, PlayerMotionZ); + COPY_TO_CLIENT(); + return true; +} + + + + + bool cConnection::HandleServerIncrementStatistic(void) { // 0xc8 diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h index c30a28727..6093408d6 100644 --- a/Tools/ProtoProxy/Connection.h +++ b/Tools/ProtoProxy/Connection.h @@ -158,6 +158,7 @@ protected: bool HandleServerEntityStatus(void); bool HandleServerEntityTeleport(void); bool HandleServerEntityVelocity(void); + bool HandleServerExplosion(void); bool HandleServerIncrementStatistic(void); bool HandleServerKeepAlive(void); bool HandleServerKick(void); diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 423e3e2b0..ace82b010 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -964,6 +964,14 @@ > </File> <File + RelativePath="..\source\Mobs\EnderDragon.cpp" + > + </File> + <File + RelativePath="..\source\Mobs\EnderDragon.h" + > + </File> + <File RelativePath="..\source\Mobs\Enderman.cpp" > </File> @@ -980,11 +988,35 @@ > </File> <File - RelativePath="..\source\Mobs\Magmacube.cpp" + RelativePath="..\source\Mobs\Giant.cpp" + > + </File> + <File + RelativePath="..\source\Mobs\Giant.h" + > + </File> + <File + RelativePath="..\source\Mobs\Horse.cpp" > </File> <File - RelativePath="..\source\Mobs\Magmacube.h" + 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 @@ -1060,6 +1092,14 @@ > </File> <File + RelativePath="..\source\Mobs\SnowGolem.cpp" + > + </File> + <File + RelativePath="..\source\Mobs\SnowGolem.h" + > + </File> + <File RelativePath="..\source\Mobs\Spider.cpp" > </File> @@ -1092,6 +1132,14 @@ > </File> <File + RelativePath="..\source\Mobs\Wither.cpp" + > + </File> + <File + RelativePath="..\source\Mobs\Wither.h" + > + </File> + <File RelativePath="..\source\Mobs\Wolf.h" > </File> @@ -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> @@ -2028,6 +2076,14 @@ > </File> <File + RelativePath="..\source\Blocks\BlockComparator.cpp" + > + </File> + <File + RelativePath="..\source\Blocks\BlockComparator.h" + > + </File> + <File RelativePath="..\source\blocks\BlockCrops.h" > </File> @@ -2284,6 +2340,10 @@ > </File> <File + RelativePath="..\source\Items\ItemComparator.h" + > + </File> + <File RelativePath="..\source\items\ItemDoor.h" > </File> diff --git a/source/BlockID.cpp b/source/BlockID.cpp index c3bd3c750..ecdbc0c34 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -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; diff --git a/source/BlockID.h b/source/BlockID.h index 7971b4f84..c2bf8dbdf 100644 --- a/source/BlockID.h +++ b/source/BlockID.h @@ -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, } ; diff --git a/source/Blocks/BlockComparator.cpp b/source/Blocks/BlockComparator.cpp new file mode 100644 index 000000000..e6fa64e2c --- /dev/null +++ b/source/Blocks/BlockComparator.cpp @@ -0,0 +1,64 @@ + +#include "Globals.h" +#include "BlockComparator.h" +#include "../Item.h" +#include "../World.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->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta); +} + + + + + +void cBlockComparatorHandler::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); +} + + + + +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; +} + + + + diff --git a/source/Blocks/BlockComparator.h b/source/Blocks/BlockComparator.h new file mode 100644 index 000000000..208727107 --- /dev/null +++ b/source/Blocks/BlockComparator.h @@ -0,0 +1,57 @@ + +#pragma once + +#include "BlockHandler.h" +#include "../World.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 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; + + + 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"; + } +} ; + + + + diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index e1cfebb56..b06171119 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -13,6 +13,7 @@ #include "BlockChest.h" #include "BlockCloth.h" #include "BlockCobWeb.h" +#include "BlockComparator.h" #include "BlockCrops.h" #include "BlockDeadBush.h" #include "BlockDirt.h" @@ -110,6 +111,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); @@ -124,7 +126,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); @@ -136,6 +138,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); @@ -153,7 +156,7 @@ 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_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); @@ -355,15 +358,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); - */ - - a_World->SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ); + 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 (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); } } diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp index dc3c7796e..d465c75bd 100644 --- a/source/Entities/Entity.cpp +++ b/source/Entities/Entity.cpp @@ -549,12 +549,11 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width); int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width); BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ ); - BLOCKTYPE BlockBelow = NextChunk->GetBlock( RelBlockX, BlockY - 1, RelBlockZ ); + BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR; if (!g_BlockIsSolid[BlockIn]) // Making sure we are not inside a solid block { if (m_bOnGround) // check if it's still on the ground { - BLOCKTYPE BlockBelow = NextChunk->GetBlock( RelBlockX, BlockY - 1, RelBlockZ ); if (!g_BlockIsSolid[BlockBelow]) // Check if block below is air or water. { m_bOnGround = false; @@ -613,7 +612,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk) { fallspeed = m_Gravity * a_Dt / 3; // Fall 3x slower in water. } - else if ((IsBlockRail(BlockBelow)) && (IsMinecart())) // Rails aren't solid, except for Minecarts + else if (IsBlockRail(BlockBelow) && IsMinecart()) // Rails aren't solid, except for Minecarts { fallspeed = 0; m_bOnGround = true; diff --git a/source/Entities/Pickup.cpp b/source/Entities/Pickup.cpp index db7be8b04..075f93449 100644 --- a/source/Entities/Pickup.cpp +++ b/source/Entities/Pickup.cpp @@ -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 ) diff --git a/source/Entities/Pickup.h b/source/Entities/Pickup.h index af6eaf3bb..488f91fb2 100644 --- a/source/Entities/Pickup.h +++ b/source/Entities/Pickup.h @@ -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_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); // tolua_export cItem & GetItem(void) {return m_Item; } // tolua_export const cItem & GetItem(void) const {return m_Item; } diff --git a/source/Items/ItemComparator.h b/source/Items/ItemComparator.h new file mode 100644 index 000000000..53dbd020d --- /dev/null +++ b/source/Items/ItemComparator.h @@ -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; + } +} ; + + + + diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp index 3c2fa1e79..9d38e6f3a 100644 --- a/source/Items/ItemHandler.cpp +++ b/source/Items/ItemHandler.cpp @@ -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" @@ -92,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(); diff --git a/source/Mobs/EnderDragon.cpp b/source/Mobs/EnderDragon.cpp new file mode 100644 index 000000000..64f2bedfa --- /dev/null +++ b/source/Mobs/EnderDragon.cpp @@ -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; +} + + + + diff --git a/source/Mobs/EnderDragon.h b/source/Mobs/EnderDragon.h new file mode 100644 index 000000000..77177edfe --- /dev/null +++ b/source/Mobs/EnderDragon.h @@ -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; +} ; + + + + diff --git a/source/Mobs/Giant.cpp b/source/Mobs/Giant.cpp new file mode 100644 index 000000000..a02758a43 --- /dev/null +++ b/source/Mobs/Giant.cpp @@ -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); +} + + + + diff --git a/source/Mobs/Giant.h b/source/Mobs/Giant.h new file mode 100644 index 000000000..356dd4352 --- /dev/null +++ b/source/Mobs/Giant.h @@ -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; +} ; + + + + diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp new file mode 100644 index 000000000..05ac73c15 --- /dev/null +++ b/source/Mobs/Horse.cpp @@ -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); +} + + + + diff --git a/source/Mobs/Horse.h b/source/Mobs/Horse.h new file mode 100644 index 000000000..83e64308e --- /dev/null +++ b/source/Mobs/Horse.h @@ -0,0 +1,25 @@ + +#pragma once + +#include "PassiveMonster.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; +} ; + + + + diff --git a/source/Mobs/IronGolem.cpp b/source/Mobs/IronGolem.cpp new file mode 100644 index 000000000..42d312c23 --- /dev/null +++ b/source/Mobs/IronGolem.cpp @@ -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); +} + + + + diff --git a/source/Mobs/IronGolem.h b/source/Mobs/IronGolem.h new file mode 100644 index 000000000..d49ff4cab --- /dev/null +++ b/source/Mobs/IronGolem.h @@ -0,0 +1,25 @@ + +#pragma once + +#include "PassiveAggressiveMonster.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; +} ; + + + + diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp index 0b9b57e3c..c72b4831b 100644 --- a/source/Mobs/Magmacube.cpp +++ b/source/Mobs/Magmacube.cpp @@ -7,8 +7,8 @@ -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); } diff --git a/source/Mobs/Magmacube.h b/source/Mobs/Magmacube.h index e4df4f33d..80a1d0701 100644 --- a/source/Mobs/Magmacube.h +++ b/source/Mobs/Magmacube.h @@ -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; } ; diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index 484e32c65..b2676f5b1 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -26,34 +26,36 @@ public: /// This identifies individual monster type, as well as their network type-ID enum eType { + mtBat = E_META_SPAWN_EGG_BAT, + 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, - 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, + mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON, 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, + 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, - 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, + 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 diff --git a/source/Mobs/SnowGolem.cpp b/source/Mobs/SnowGolem.cpp new file mode 100644 index 000000000..51125542d --- /dev/null +++ b/source/Mobs/SnowGolem.cpp @@ -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); +} + + + + diff --git a/source/Mobs/SnowGolem.h b/source/Mobs/SnowGolem.h new file mode 100644 index 000000000..d1344adfd --- /dev/null +++ b/source/Mobs/SnowGolem.h @@ -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; +} ; + + + + diff --git a/source/Mobs/Wither.cpp b/source/Mobs/Wither.cpp new file mode 100644 index 000000000..8b77284c8 --- /dev/null +++ b/source/Mobs/Wither.cpp @@ -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); +} + + + + diff --git a/source/Mobs/Wither.h b/source/Mobs/Wither.h new file mode 100644 index 000000000..56effc6bb --- /dev/null +++ b/source/Mobs/Wither.h @@ -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; +} ; + + + + diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp index 09b44816f..1e31a72d9 100644 --- a/source/Mobs/Zombiepigman.cpp +++ b/source/Mobs/Zombiepigman.cpp @@ -8,8 +8,8 @@ -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); diff --git a/source/Mobs/Zombiepigman.h b/source/Mobs/Zombiepigman.h index fe8c6d047..67991d56a 100644 --- a/source/Mobs/Zombiepigman.h +++ b/source/Mobs/Zombiepigman.h @@ -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; } ; diff --git a/source/Protocol/Protocol125.cpp b/source/Protocol/Protocol125.cpp index 54bd28c9f..050132917 100644 --- a/source/Protocol/Protocol125.cpp +++ b/source/Protocol/Protocol125.cpp @@ -436,15 +436,18 @@ void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc WriteDouble (a_BlockZ); WriteFloat (a_Radius); WriteInt (a_BlocksAffected.size()); + int BlockX = (int)a_BlockX; + int BlockY = (int)a_BlockY; + int BlockZ = (int)a_BlockZ; for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr) { - WriteByte ((Byte)(itr->x - a_BlockX)); - WriteByte ((Byte)(itr->y - a_BlockY)); - WriteByte ((Byte)(itr->z - a_BlockZ)); + WriteByte((Byte)(itr->x - BlockX)); + WriteByte((Byte)(itr->y - BlockY)); + WriteByte((Byte)(itr->z - BlockZ)); } - WriteFloat ((float)a_PlayerMotion.x); - WriteFloat ((float)a_PlayerMotion.y); - WriteFloat ((float)a_PlayerMotion.z); + WriteFloat((float)a_PlayerMotion.x); + WriteFloat((float)a_PlayerMotion.y); + WriteFloat((float)a_PlayerMotion.z); Flush(); } diff --git a/source/Protocol/Protocol16x.cpp b/source/Protocol/Protocol16x.cpp index be5b45f19..0eac7b081 100644 --- a/source/Protocol/Protocol16x.cpp +++ b/source/Protocol/Protocol16x.cpp @@ -7,6 +7,8 @@ Implements the 1.6.x protocol classes: - release 1.6.1 protocol (#73) - cProtocol162 - release 1.6.2 protocol (#74) + - release 1.6.3 protocol (#77) - no relevant changes + - release 1.6.4 protocol (#78) - no relevant changes (others may be added later in the future for the 1.6 release series) */ diff --git a/source/Protocol/Protocol16x.h b/source/Protocol/Protocol16x.h index 077c7958b..2447f90a7 100644 --- a/source/Protocol/Protocol16x.h +++ b/source/Protocol/Protocol16x.h @@ -7,6 +7,8 @@ Declares the 1.6.x protocol classes: - release 1.6.1 protocol (#73) - cProtocol162 - release 1.6.2 protocol (#74) + - release 1.6.3 protocol (#77) - no relevant changes + - release 1.6.4 protocol (#78) - no relevant changes (others may be added later in the future for the 1.6 release series) */ diff --git a/source/Protocol/ProtocolRecognizer.cpp b/source/Protocol/ProtocolRecognizer.cpp index 853018329..fe99b22e1 100644 --- a/source/Protocol/ProtocolRecognizer.cpp +++ b/source/Protocol/ProtocolRecognizer.cpp @@ -55,6 +55,8 @@ AString cProtocolRecognizer::GetVersionTextFromInt(int a_ProtocolVersion) case PROTO_VERSION_1_5_2: return "1.5.2"; case PROTO_VERSION_1_6_1: return "1.6.1"; case PROTO_VERSION_1_6_2: return "1.6.2"; + case PROTO_VERSION_1_6_3: return "1.6.3"; + case PROTO_VERSION_1_6_4: return "1.6.4"; } ASSERT(!"Unknown protocol version"); return Printf("Unknown protocol (%d)", a_ProtocolVersion); @@ -707,6 +709,8 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void) return true; } case PROTO_VERSION_1_6_2: + case PROTO_VERSION_1_6_3: + case PROTO_VERSION_1_6_4: { m_Protocol = new cProtocol162(m_Client); return true; @@ -746,6 +750,8 @@ void cProtocolRecognizer::HandleServerPing(void) case PROTO_VERSION_1_5_2: case PROTO_VERSION_1_6_1: case PROTO_VERSION_1_6_2: + case PROTO_VERSION_1_6_3: + case PROTO_VERSION_1_6_4: { // The server list ping now has 1 more byte of "magic". Mojang just loves to complicate stuff. // http://wiki.vg/wiki/index.php?title=Protocol&oldid=3101#Server_List_Ping_.280xFE.29 diff --git a/source/Protocol/ProtocolRecognizer.h b/source/Protocol/ProtocolRecognizer.h index 2178d5e61..c53288230 100644 --- a/source/Protocol/ProtocolRecognizer.h +++ b/source/Protocol/ProtocolRecognizer.h @@ -18,8 +18,8 @@ // Adjust these if a new protocol is added or an old one is removed: -#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2" -#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49, 51, 60, 61, 73, 74" +#define MCS_CLIENT_VERSIONS "1.2.4, 1.2.5, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5, 1.5.1, 1.5.2, 1.6.1, 1.6.2, 1.6.3, 1.6.4" +#define MCS_PROTOCOL_VERSIONS "29, 39, 47, 49, 51, 60, 61, 73, 74, 77, 78" @@ -42,6 +42,8 @@ public: PROTO_VERSION_1_5_2 = 61, PROTO_VERSION_1_6_1 = 73, PROTO_VERSION_1_6_2 = 74, + PROTO_VERSION_1_6_3 = 77, + PROTO_VERSION_1_6_4 = 78, PROTO_VERSION_NEXT, PROTO_VERSION_LATEST = PROTO_VERSION_NEXT - 1, ///< Automatically assigned to the last protocol version, this serves as the default for PrimaryServerVersion diff --git a/source/World.cpp b/source/World.cpp index 7be83168c..96a4731d7 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -35,7 +35,11 @@ #include "Mobs/Cow.h" #include "Mobs/Creeper.h" #include "Mobs/Enderman.h" +#include "Mobs/EnderDragon.h" #include "Mobs/Ghast.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" @@ -44,10 +48,12 @@ #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" @@ -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: { |