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/BlockEntities/DropSpenserEntity.cpp | 2 +- source/BlockEntities/JukeboxEntity.cpp | 6 +++--- source/ChunkMap.cpp | 2 +- source/ClientHandle.cpp | 4 ++-- source/Entities/Pickup.cpp | 5 +++-- source/Mobs/Horse.cpp | 8 ++++---- source/Mobs/Monster.cpp | 7 ++++++- source/Protocol/Protocol17x.cpp | 6 +++--- source/World.cpp | 3 +-- 9 files changed, 24 insertions(+), 19 deletions(-) (limited to 'source') diff --git a/source/BlockEntities/DropSpenserEntity.cpp b/source/BlockEntities/DropSpenserEntity.cpp index 25def9999..823ed598f 100644 --- a/source/BlockEntities/DropSpenserEntity.cpp +++ b/source/BlockEntities/DropSpenserEntity.cpp @@ -96,7 +96,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk) case E_META_DROPSPENSER_FACING_ZM: SmokeDir = 1; break; case E_META_DROPSPENSER_FACING_ZP: SmokeDir = 7; break; } - m_World->BroadcastSoundParticleEffect(2000, m_PosX * 8, m_PosY * 8, m_PosZ * 8, SmokeDir); + m_World->BroadcastSoundParticleEffect(2000, m_PosX, m_PosY, m_PosZ, SmokeDir); m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f); // Update the UI window, if open: diff --git a/source/BlockEntities/JukeboxEntity.cpp b/source/BlockEntities/JukeboxEntity.cpp index d4bbae2b0..1288719f6 100644 --- a/source/BlockEntities/JukeboxEntity.cpp +++ b/source/BlockEntities/JukeboxEntity.cpp @@ -57,7 +57,7 @@ void cJukeboxEntity::UsedBy(cPlayer * a_Player) void cJukeboxEntity::PlayRecord( void ) { - m_World->BroadcastSoundParticleEffect(1005, m_PosX * 8, m_PosY * 8, m_PosZ * 8, m_Record); + m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, m_Record); } @@ -68,8 +68,8 @@ void cJukeboxEntity::EjectRecord( void ) { cItems Drops; Drops.push_back(cItem(m_Record, 1, 0)); - m_World->SpawnItemPickups(Drops, m_PosX + 0.5, m_PosY + 1, m_PosZ + 0.5, 5); - m_World->BroadcastSoundParticleEffect(1005, m_PosX * 8, m_PosY * 8, m_PosZ * 8, 0); + m_World->SpawnItemPickups(Drops, m_PosX + 0.5, m_PosY + 1, m_PosZ + 0.5, 8); + m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, 0); } diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp index d9de24cff..73a16dbb4 100644 --- a/source/ChunkMap.cpp +++ b/source/ChunkMap.cpp @@ -613,7 +613,7 @@ void cChunkMap::BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_S cCSLock Lock(m_CSLayers); int ChunkX, ChunkZ; - cChunkDef::BlockToChunk(a_SrcX / 8, a_SrcZ / 8, ChunkX, ChunkZ); + cChunkDef::BlockToChunk(a_SrcX, a_SrcZ, ChunkX, ChunkZ); cChunkPtr Chunk = GetChunkNoGen(ChunkX, 0, ChunkZ); if (Chunk == NULL) { diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 3548b4035..f8fd4a8b7 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -729,7 +729,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo if (a_OldBlock == E_BLOCK_AIR) { - LOGD("Digged air? wtf?"); + LOGD("Dug air - what the function?"); return; } @@ -738,7 +738,7 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo // The ItemHandler is also responsible for spawning the pickups BlockHandler(a_OldBlock)->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); - World->BroadcastSoundParticleEffect(2001, a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, a_OldBlock, this); + World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this); World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta); diff --git a/source/Entities/Pickup.cpp b/source/Entities/Pickup.cpp index 5bd61effc..f8aae9703 100644 --- a/source/Entities/Pickup.cpp +++ b/source/Entities/Pickup.cpp @@ -31,8 +31,9 @@ cPickup::cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_It , m_bCollected( false ) , m_bIsPlayerCreated( IsPlayerCreated ) { - m_MaxHealth = 5; - m_Health = 5; + SetGravity(-10.5f); + SetMaxHealth(5); + SetHealth(5); SetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ); } 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); diff --git a/source/Protocol/Protocol17x.cpp b/source/Protocol/Protocol17x.cpp index a962d238b..d580be23b 100644 --- a/source/Protocol/Protocol17x.cpp +++ b/source/Protocol/Protocol17x.cpp @@ -491,7 +491,7 @@ void cProtocol172::SendPlayerAbilities(void) void cProtocol172::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation) { cPacketizer Pkt(*this, 0x0b); // Animation packet - Pkt.WriteInt(a_Player.GetUniqueID()); + Pkt.WriteVarInt(a_Player.GetUniqueID()); Pkt.WriteChar(a_Animation); } @@ -616,8 +616,8 @@ void cProtocol172::SendSoundParticleEffect(int a_EffectID, int a_SrcX, int a_Src { cPacketizer Pkt(*this, 0x28); // Effect packet Pkt.WriteInt(a_EffectID); - Pkt.WriteByte(a_SrcX); - Pkt.WriteInt(a_SrcY); + Pkt.WriteInt(a_SrcX); + Pkt.WriteByte(a_SrcY); Pkt.WriteInt(a_SrcZ); Pkt.WriteInt(a_Data); Pkt.WriteBool(false); diff --git a/source/World.cpp b/source/World.cpp index a86468c32..0f9df8a62 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -1512,7 +1512,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) { float SpeedX = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); - float SpeedY = 1; + float SpeedY = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); float SpeedZ = (float)(a_FlyAwaySpeed * (r1.randInt(1000) - 500)); cPickup * Pickup = new cPickup( @@ -2571,7 +2571,6 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp } // Because it's logical that ALL mob spawns need spawn effects, not just spawners - // TODO: Not working - wiki.vg outdated? BroadcastSoundParticleEffect(2004, (int)a_PosX, (int)a_PosY, (int)a_PosZ, 0); return SpawnMobFinalize(Monster); -- cgit v1.2.3