From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: Modernize project codebase (#906) * Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR --- Minecraft.Client/TrackedEntity.cpp | 144 ++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'Minecraft.Client/TrackedEntity.cpp') diff --git a/Minecraft.Client/TrackedEntity.cpp b/Minecraft.Client/TrackedEntity.cpp index 0a5a02bf..3aa33248 100644 --- a/Minecraft.Client/TrackedEntity.cpp +++ b/Minecraft.Client/TrackedEntity.cpp @@ -63,10 +63,10 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl updatePlayers(tracker, players); } - if (lastRidingEntity != e->riding || (e->riding != NULL && tickCount % (SharedConstants::TICKS_PER_SECOND * 3) == 0)) + if (lastRidingEntity != e->riding || (e->riding != nullptr && tickCount % (SharedConstants::TICKS_PER_SECOND * 3) == 0)) { lastRidingEntity = e->riding; - broadcast(shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, e, e->riding))); + broadcast(std::make_shared(SetEntityLinkPacket::RIDING, e, e->riding)); } // Moving forward special case for item frames @@ -75,7 +75,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl shared_ptr frame = dynamic_pointer_cast (e); shared_ptr item = frame->getItem(); - if (item != NULL && item->getItem()->id == Item::map_Id && !e->removed) + if (item != nullptr && item->getItem()->id == Item::map_Id && !e->removed) { shared_ptr data = Item::map->getSavedData(item, e->level); for (auto& it : *players) @@ -86,7 +86,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (!player->removed && player->connection && player->connection->countDelayedPackets() <= 5) { shared_ptr packet = Item::map->getUpdatePacket(item, e->level, player); - if (packet != NULL) player->connection->send(packet); + if (packet != nullptr) player->connection->send(packet); } } } @@ -94,7 +94,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl shared_ptr entityData = e->getEntityData(); if (entityData->isDirty()) { - broadcastAndSend( shared_ptr( new SetEntityDataPacket(e->entityId, entityData, false) ) ); + broadcastAndSend(std::make_shared(e->entityId, entityData, false)); } } else if (tickCount % updateInterval == 0 || e->hasImpulse || e->getEntityData()->isDirty()) @@ -107,7 +107,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl int yRota = yRotn - yRotp; int xRota = xRotn - xRotp; - if(e->riding == NULL) + if(e->riding == nullptr) { teleportDelay++; @@ -152,7 +152,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ) { teleportDelay = 0; - packet = shared_ptr( new TeleportEntityPacket(e->entityId, xn, yn, zn, (byte) yRotn, (byte) xRotn) ); + packet = std::make_shared(e->entityId, xn, yn, zn, static_cast(yRotn), static_cast(xRotn)); // printf("%d: New teleport rot %d\n",e->entityId,yRotn); yRotp = yRotn; xRotp = xRotn; @@ -179,12 +179,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl yRotn = yRotp + yRota; } // 5 bits each for x & z, and 6 for y - packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, (char) xa, (char) ya, (char) za, (char) yRota, 0 ) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), 0); c0a++; } else { - packet = shared_ptr( new MoveEntityPacket::PosRot(e->entityId, (char) xa, (char) ya, (char) za, (char) yRota, (char) xRota) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), static_cast(yRota), static_cast(xRota)); // printf("%d: New posrot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); c0b++; } @@ -197,7 +197,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ( ya >= -16 ) && ( ya <= 15 ) ) { // 4 bits each for x & z, and 5 for y - packet = shared_ptr( new MoveEntityPacketSmall::Pos(e->entityId, (char) xa, (char) ya, (char) za) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)); c1a++; } @@ -206,12 +206,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl ( ya >= -32 ) && ( ya <= 31 ) ) { // use the packet with small packet with rotation if we can - 5 bits each for x & z, and 6 for y - still a byte less than the alternative - packet = shared_ptr( new MoveEntityPacketSmall::PosRot(e->entityId, (char) xa, (char) ya, (char) za, 0, 0 )); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za), 0, 0); c1b++; } else { - packet = shared_ptr( new MoveEntityPacket::Pos(e->entityId, (char) xa, (char) ya, (char) za) ); + packet = std::make_shared(e->entityId, static_cast(xa), static_cast(ya), static_cast(za)); c1c++; } } @@ -231,13 +231,13 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl yRota = 15; yRotn = yRotp + yRota; } - packet = shared_ptr( new MoveEntityPacketSmall::Rot(e->entityId, (char) yRota, 0) ); + packet = std::make_shared(e->entityId, static_cast(yRota), 0); c2a++; } else { // printf("%d: New rot %d + %d = %d\n",e->entityId,yRotp,yRota,yRotn); - packet = shared_ptr( new MoveEntityPacket::Rot(e->entityId, (char) yRota, (char) xRota) ); + packet = std::make_shared(e->entityId, static_cast(yRota), static_cast(xRota)); c2b++; } } @@ -259,12 +259,12 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl xap = e->xd; yap = e->yd; zap = e->zd; - broadcast( shared_ptr( new SetEntityMotionPacket(e->entityId, xap, yap, zap) ) ); + broadcast(std::make_shared(e->entityId, xap, yap, zap)); } } - if (packet != NULL) + if (packet != nullptr) { broadcast(packet); } @@ -291,7 +291,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (rot) { // 4J: Changed this to use deltas - broadcast( shared_ptr( new MoveEntityPacket::Rot(e->entityId, (byte) yRota, (byte) xRota)) ); + broadcast(std::make_shared(e->entityId, static_cast(yRota), static_cast(xRota))); yRotp = yRotn; xRotp = xRotn; } @@ -308,7 +308,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl int yHeadRot = Mth::floor(e->getYHeadRot() * 256 / 360); if (abs(yHeadRot - yHeadRotp) >= TOLERANCE_LEVEL) { - broadcast(shared_ptr( new RotateHeadPacket(e->entityId, (byte) yHeadRot))); + broadcast(std::make_shared(e->entityId, static_cast(yHeadRot))); yHeadRotp = yHeadRot; } @@ -320,7 +320,7 @@ void TrackedEntity::tick(EntityTracker *tracker, vector > *pl if (e->hurtMarked) { // broadcast(new AnimatePacket(e, AnimatePacket.HURT)); - broadcastAndSend( shared_ptr( new SetEntityMotionPacket(e) ) ); + broadcastAndSend(std::make_shared(e)); e->hurtMarked = false; } @@ -331,18 +331,18 @@ void TrackedEntity::sendDirtyEntityData() shared_ptr entityData = e->getEntityData(); if (entityData->isDirty()) { - broadcastAndSend( shared_ptr( new SetEntityDataPacket(e->entityId, entityData, false)) ); + broadcastAndSend(std::make_shared(e->entityId, entityData, false)); } if ( e->instanceof(eTYPE_LIVINGENTITY) ) { shared_ptr living = dynamic_pointer_cast(e); - ServersideAttributeMap *attributeMap = (ServersideAttributeMap *) living->getAttributes(); + ServersideAttributeMap *attributeMap = static_cast(living->getAttributes()); unordered_set *attributes = attributeMap->getDirtyAttributes(); if (!attributes->empty()) { - broadcastAndSend(shared_ptr( new UpdateAttributesPacket(e->entityId, attributes)) ); + broadcastAndSend(std::make_shared(e->entityId, attributes)); } attributes->clear(); @@ -368,7 +368,7 @@ void TrackedEntity::broadcast(shared_ptr packet) if( sentTo.size() ) { INetworkPlayer *thisPlayer =player->connection->getNetworkPlayer(); - if( thisPlayer == NULL ) + if( thisPlayer == nullptr ) { dontSend = true; } @@ -377,7 +377,7 @@ void TrackedEntity::broadcast(shared_ptr packet) for(auto& player2 : sentTo) { INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { dontSend = true; } @@ -410,7 +410,7 @@ void TrackedEntity::broadcastAndSend(shared_ptr packet) vector< shared_ptr > sentTo; broadcast(packet); shared_ptr sp = e->instanceof(eTYPE_SERVERPLAYER) ? dynamic_pointer_cast(e) : nullptr; - if (sp != NULL && sp->connection) + if (sp != nullptr && sp->connection) { sp->connection->send(packet); } @@ -477,7 +477,7 @@ TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shar if( ep->dimension != sp->dimension ) continue; INetworkPlayer * otherPlayer = ep->connection->getNetworkPlayer(); - if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) ) + if( otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer) ) { // 4J Stu - We call update players when the entity has moved more than a certain amount at the start of it's tick // Before this call we set xpu, ypu and zpu to the entities new position, but xp,yp and zp are the old position until later in the tick. @@ -499,7 +499,7 @@ TrackedEntity::eVisibility TrackedEntity::isVisible(EntityTracker *tracker, shar // 4J-JEV: ADDED! An entities mount has to be visible before the entity visible, // this is to ensure that the mount is already in the client's game when the rider is added. - if (canBeSeenBy && bVisible && e->riding != NULL) + if (canBeSeenBy && bVisible && e->riding != nullptr) { return tracker->getTracker(e->riding)->isVisible(tracker, sp, true); } @@ -530,43 +530,43 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr plr = dynamic_pointer_cast(e); app.DebugPrintf( "TrackedEntity:: Player '%ls' is now visible to player '%ls', %s.\n", plr->name.c_str(), sp->name.c_str(), - (e->riding==NULL?"not riding minecart":"in minecart") + (e->riding==nullptr?"not riding minecart":"in minecart") ); } - bool isAddMobPacket = dynamic_pointer_cast(packet) != NULL; + bool isAddMobPacket = dynamic_pointer_cast(packet) != nullptr; // 4J Stu brought forward to fix when Item Frames if (!e->getEntityData()->isEmpty() && !isAddMobPacket) { - sp->connection->send(shared_ptr( new SetEntityDataPacket(e->entityId, e->getEntityData(), true))); + sp->connection->send(std::make_shared(e->entityId, e->getEntityData(), true)); } if ( e->instanceof(eTYPE_LIVINGENTITY) ) { shared_ptr living = dynamic_pointer_cast(e); - ServersideAttributeMap *attributeMap = (ServersideAttributeMap *) living->getAttributes(); + ServersideAttributeMap *attributeMap = static_cast(living->getAttributes()); unordered_set *attributes = attributeMap->getSyncableAttributes(); if (!attributes->empty()) { - sp->connection->send(shared_ptr( new UpdateAttributesPacket(e->entityId, attributes)) ); + sp->connection->send(std::make_shared(e->entityId, attributes)); } delete attributes; } if (trackDelta && !isAddMobPacket) { - sp->connection->send( shared_ptr( new SetEntityMotionPacket(e->entityId, e->xd, e->yd, e->zd) ) ); + sp->connection->send(std::make_shared(e->entityId, e->xd, e->yd, e->zd)); } - if (e->riding != NULL) + if (e->riding != nullptr) { - sp->connection->send(shared_ptr(new SetEntityLinkPacket(SetEntityLinkPacket::RIDING, e, e->riding))); + sp->connection->send(std::make_shared(SetEntityLinkPacket::RIDING, e, e->riding)); } - if ( e->instanceof(eTYPE_MOB) && dynamic_pointer_cast(e)->getLeashHolder() != NULL) + if ( e->instanceof(eTYPE_MOB) && dynamic_pointer_cast(e)->getLeashHolder() != nullptr) { - sp->connection->send( shared_ptr( new SetEntityLinkPacket(SetEntityLinkPacket::LEASH, e, dynamic_pointer_cast(e)->getLeashHolder())) ); + sp->connection->send(std::make_shared(SetEntityLinkPacket::LEASH, e, dynamic_pointer_cast(e)->getLeashHolder())); } if ( e->instanceof(eTYPE_LIVINGENTITY) ) @@ -574,7 +574,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr item = dynamic_pointer_cast(e)->getCarried(i); - if(item != NULL) sp->connection->send( shared_ptr( new SetEquippedItemPacket(e->entityId, i, item) ) ); + if(item != nullptr) sp->connection->send(std::make_shared(e->entityId, i, item)); } } @@ -583,7 +583,7 @@ void TrackedEntity::updatePlayer(EntityTracker *tracker, shared_ptr spe = dynamic_pointer_cast(e); if (spe->isSleeping()) { - sp->connection->send( shared_ptr( new EntityActionAtPositionPacket(e, EntityActionAtPositionPacket::START_SLEEP, Mth::floor(e->x), Mth::floor(e->y), Mth::floor(e->z)) ) ); + sp->connection->send(std::make_shared(e, EntityActionAtPositionPacket::START_SLEEP, Mth::floor(e->x), Mth::floor(e->y), Mth::floor(e->z))); } } @@ -636,15 +636,15 @@ shared_ptr TrackedEntity::getAddEntityPacket() } // 4J-PB - replacing with a switch, rather than tons of ifs - if (dynamic_pointer_cast(e) != NULL) + if (dynamic_pointer_cast(e) != nullptr) { yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); - return shared_ptr( new AddMobPacket(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp) ); + return std::make_shared(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp); } if (e->instanceof(eTYPE_ITEMENTITY)) { - shared_ptr packet = shared_ptr( new AddEntityPacket(e, AddEntityPacket::ITEM, 1, yRotp, xRotp, xp, yp, zp) ); + shared_ptr packet = std::make_shared(e, AddEntityPacket::ITEM, 1, yRotp, xRotp, xp, yp, zp); return packet; } else if (e->instanceof(eTYPE_SERVERPLAYER)) @@ -653,61 +653,61 @@ shared_ptr TrackedEntity::getAddEntityPacket() PlayerUID xuid = INVALID_XUID; PlayerUID OnlineXuid = INVALID_XUID; - if( player != NULL ) + if( player != nullptr ) { xuid = player->getXuid(); OnlineXuid = player->getOnlineXuid(); } // 4J Added yHeadRotp param to fix #102563 - TU12: Content: Gameplay: When one of the Players is idle for a few minutes his head turns 180 degrees. - return shared_ptr( new AddPlayerPacket( player, xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp, yHeadRotp ) ); + return std::make_shared(player, xuid, OnlineXuid, xp, yp, zp, yRotp, xRotp, yHeadRotp); } else if (e->instanceof(eTYPE_MINECART)) { shared_ptr minecart = dynamic_pointer_cast(e); - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::MINECART, minecart->getType(), yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::MINECART, minecart->getType(), yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_BOAT)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ENDERDRAGON)) { yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); - return shared_ptr( new AddMobPacket(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp ) ); + return std::make_shared(dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp); } else if (e->instanceof(eTYPE_FISHINGHOOK)) { shared_ptr owner = dynamic_pointer_cast(e)->owner; - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FISH_HOOK, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::FISH_HOOK, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ARROW)) { shared_ptr owner = (dynamic_pointer_cast(e))->owner; - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::ARROW, owner != NULL ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::ARROW, owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_SNOWBALL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNPOTION)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp)); + return std::make_shared(e, AddEntityPacket::THROWN_POTION, ((dynamic_pointer_cast(e))->getPotionValue()), yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNEXPBOTTLE)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::THROWN_EXPBOTTLE, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNENDERPEARL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::THROWN_ENDERPEARL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_EYEOFENDERSIGNAL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FIREWORKS_ROCKET)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FIREWORKS, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::FIREWORKS, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FIREBALL)) { @@ -728,39 +728,39 @@ shared_ptr TrackedEntity::getAddEntityPacket() shared_ptr fb = dynamic_pointer_cast(e); shared_ptr aep = nullptr; - if (fb->owner != NULL) + if (fb->owner != nullptr) { - aep = shared_ptr( new AddEntityPacket(e, type, fb->owner->entityId, yRotp, xRotp, xp, yp, zp) ); + aep = std::make_shared(e, type, fb->owner->entityId, yRotp, xRotp, xp, yp, zp); } else { - aep = shared_ptr( new AddEntityPacket(e, type, 0, yRotp, xRotp, xp, yp, zp) ); + aep = std::make_shared(e, type, 0, yRotp, xRotp, xp, yp, zp); } - aep->xa = (int) (fb->xPower * 8000); - aep->ya = (int) (fb->yPower * 8000); - aep->za = (int) (fb->zPower * 8000); + aep->xa = static_cast(fb->xPower * 8000); + aep->ya = static_cast(fb->yPower * 8000); + aep->za = static_cast(fb->zPower * 8000); return aep; } else if (e->instanceof(eTYPE_THROWNEGG)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_PRIMEDTNT)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ENDER_CRYSTAL)) { - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FALLINGTILE)) { shared_ptr ft = dynamic_pointer_cast(e); - return shared_ptr( new AddEntityPacket(e, AddEntityPacket::FALLING, ft->tile | (ft->data << 16), yRotp, xRotp, xp, yp, zp) ); + return std::make_shared(e, AddEntityPacket::FALLING, ft->tile | (ft->data << 16), yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_PAINTING)) { - return shared_ptr( new AddPaintingPacket(dynamic_pointer_cast(e)) ); + return std::make_shared(dynamic_pointer_cast(e)); } else if (e->instanceof(eTYPE_ITEM_FRAME)) { @@ -774,7 +774,7 @@ shared_ptr TrackedEntity::getAddEntityPacket() app.DebugPrintf("eTYPE_ITEM_FRAME xyz %d,%d,%d\n",ix,iy,iz); } - shared_ptr packet = shared_ptr(new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp)); + shared_ptr packet = std::make_shared(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp); packet->x = Mth::floor(frame->xTile * 32.0f); packet->y = Mth::floor(frame->yTile * 32.0f); packet->z = Mth::floor(frame->zTile * 32.0f); @@ -783,15 +783,15 @@ shared_ptr TrackedEntity::getAddEntityPacket() else if (e->instanceof(eTYPE_LEASHFENCEKNOT)) { shared_ptr knot = dynamic_pointer_cast(e); - shared_ptr packet = shared_ptr(new AddEntityPacket(e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp) ); - packet->x = Mth::floor((float)knot->xTile * 32); - packet->y = Mth::floor((float)knot->yTile * 32); - packet->z = Mth::floor((float)knot->zTile * 32); + shared_ptr packet = std::make_shared(e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp); + packet->x = Mth::floor(static_cast(knot->xTile) * 32); + packet->y = Mth::floor(static_cast(knot->yTile) * 32); + packet->z = Mth::floor(static_cast(knot->zTile) * 32); return packet; } else if (e->instanceof(eTYPE_EXPERIENCEORB)) { - return shared_ptr( new AddExperienceOrbPacket(dynamic_pointer_cast(e)) ); + return std::make_shared(dynamic_pointer_cast(e)); } else { -- cgit v1.2.3