From 71abbb2f56c15634cca8615343d9699d0c50724d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 10 Nov 2013 20:48:12 +0000 Subject: Bundled fixes [SEE DESC] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed pickups spawning in an incorrect position from a JukeBox * Pickups make a popping sound in Prtcl1.7 * Arrows make a *what sort of sound does an arrow make anyway‽* when hitting a block, and a popping sound when fired * Mobs again have metadata * Fixed Prtcl1.7 not using valid JSON to kick a client * Minecarts and arrows again have metadata --- source/Mobs/Monster.cpp | 56 +++++++++++++++++++++++-------------------------- source/Mobs/Monster.h | 7 ++----- 2 files changed, 28 insertions(+), 35 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 9d2be1e29..33960ea46 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -622,37 +622,41 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily) -cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType, int a_Size) +cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) { - cFastRandom Random; - cMonster * toReturn = NULL; + cFastRandom RandomDerps; - // unspecified size get rand[1,3] for Monsters that need size + // Create the mob entity switch (a_MobType) { case mtMagmaCube: - case mtSlime: + case mtSlime: toReturn = new cSlime (RandomDerps.NextInt(2) + 1); break; // Size parameter + case mtSheep: toReturn = new cSheep (RandomDerps.NextInt(15)); break; // Colour parameter + case mtSkeleton: toReturn = new cSkeleton ((bool)(RandomDerps.NextInt(1))); break; // TODO: Actual detection of spawning in Nether + case mtZombie: toReturn = new cZombie (false); break; // TODO: Infected zombie parameter + case mtVillager: { - if (a_Size == -1) - { - a_Size = Random.NextInt(2, a_MobType) + 1; - } - if ((a_Size <= 0) || (a_Size >= 4)) - { - ASSERT(!"Random for size was supposed to pick in [1..3] and picked outside"); - a_Size = 1; - } + int VilType = RandomDerps.NextInt(6); + if (VilType == 6) { VilType = 0; } // Give farmers a better chance of spawning + + toReturn = new cVillager(cVillager::eVillagerType(VilType)); // Type (blacksmith, butcher, etc.) parameter + break; + } + case mtHorse: + { + // Horses take a type (species), a colour, and a style (dots, stripes, etc.) + int HseType = RandomDerps.NextInt(7); + int HseColor = RandomDerps.NextInt(6); + int HseStyle = RandomDerps.NextInt(6); + int HseTameTimes = RandomDerps.NextInt(6) + 1; + + if ((HseType == 5) || (HseType == 6) || (HseType == 7)) { HseType = 0; } // Increase chances of normal horse (zero) + + toReturn = new cHorse(HseType, HseColor, HseStyle, HseTameTimes); break; } - default: break; - } // switch (a_MobType) - // Create the mob entity - switch (a_MobType) - { - case mtMagmaCube: toReturn = new cMagmaCube(a_Size); break; - case mtSlime: toReturn = new cSlime(a_Size); break; case mtBat: toReturn = new cBat(); break; case mtBlaze: toReturn = new cBlaze(); break; case mtCaveSpider: toReturn = new cCavespider(); break; @@ -661,26 +665,18 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType, int a_Size) case mtCreeper: toReturn = new cCreeper(); break; case mtEnderman: toReturn = new cEnderman(); break; case mtGhast: toReturn = new cGhast(); break; - // TODO: - // case cMonster::mtHorse: toReturn = new cHorse(); break; case mtMooshroom: toReturn = new cMooshroom(); break; case mtOcelot: toReturn = new cOcelot(); break; case mtPig: toReturn = new cPig(); break; - // TODO: Implement sheep color - case mtSheep: toReturn = new cSheep(0); break; case mtSilverfish: toReturn = new cSilverfish(); break; - // TODO: Implement wither skeleton geration - case mtSkeleton: toReturn = new cSkeleton(false); break; case mtSpider: toReturn = new cSpider(); break; case mtSquid: toReturn = new cSquid(); break; - case mtVillager: toReturn = new cVillager(cVillager::vtFarmer); break; case mtWitch: toReturn = new cWitch(); break; case mtWolf: toReturn = new cWolf(); break; - case mtZombie: toReturn = new cZombie(false); break; case mtZombiePigman: toReturn = new cZombiePigman(); break; default: { - ASSERT(!"Unhandled Mob type"); + ASSERT(!"Unhandled mob type whilst trying to spawn mob!"); } } return toReturn; diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index a0002bf4f..29a705d11 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -153,12 +153,9 @@ public: /** Creates a new object of the specified mob. a_MobType is the type of the mob to be created - a_Size is the size (for mobs with size) - if a_Size is let to -1 for entities that need size, size will be random - asserts and returns null if mob type is not specified - asserts if invalid size for mobs that need size + Asserts and returns null if mob type is not specified */ - static cMonster * NewMonsterFromType(eType a_MobType, int a_Size = -1); + static cMonster * NewMonsterFromType(eType a_MobType); protected: -- cgit v1.2.3 From f713780db31e22345a1faf048ab948b1b4e03200 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 10 Nov 2013 22:20:25 +0000 Subject: Bundled fixes [SEE DESC] * Fixed compiler warning in Monster.cpp * Future proofed particle effects * Improved pickups, made less jittery --- source/Mobs/Horse.cpp | 8 ++++---- source/Mobs/Monster.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp index d18887ea4..bb9a4e3f6 100644 --- a/source/Mobs/Horse.cpp +++ b/source/Mobs/Horse.cpp @@ -55,10 +55,10 @@ void cHorse::Tick(float a_Dt, cChunk & a_Chunk) { if (m_World->GetTickRandomNumber(50) == 25) { - m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 0); - m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 2); - m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 6); - m_World->BroadcastSoundParticleEffect(2000, (int)(floor(GetPosX()) * 8), (int)(floor(GetPosY()) * 8), (int)(floor(GetPosZ()) * 8), 8); + m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 0); + m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 2); + m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 6); + m_World->BroadcastSoundParticleEffect(2000, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ(), 8); m_Attachee->Detach(); m_bIsRearing = true; diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 33960ea46..167a07486 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -633,8 +633,13 @@ cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType) case mtMagmaCube: case mtSlime: toReturn = new cSlime (RandomDerps.NextInt(2) + 1); break; // Size parameter case mtSheep: toReturn = new cSheep (RandomDerps.NextInt(15)); break; // Colour parameter - case mtSkeleton: toReturn = new cSkeleton ((bool)(RandomDerps.NextInt(1))); break; // TODO: Actual detection of spawning in Nether case mtZombie: toReturn = new cZombie (false); break; // TODO: Infected zombie parameter + case mtSkeleton: + { + // TODO: Actual detection of spawning in Nether + toReturn = new cSkeleton(RandomDerps.NextInt(1) == 0 ? false : true); + break; + } case mtVillager: { int VilType = RandomDerps.NextInt(6); -- cgit v1.2.3