diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-07 21:56:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 09:56:03 +0700 |
| commit | a9be52c41a02d207233199e98898fe7483d7e817 (patch) | |
| tree | 71dfaec3a86b05e9ca409b97d8eb9d7f993bfdd0 /Minecraft.World/ItemFrame.cpp | |
| parent | 1be5faaea781402e7de06b263eeca4c688b7712c (diff) | |
Project modernization (#630)
* 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
Diffstat (limited to 'Minecraft.World/ItemFrame.cpp')
| -rw-r--r-- | Minecraft.World/ItemFrame.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Minecraft.World/ItemFrame.cpp b/Minecraft.World/ItemFrame.cpp index 0d52b421..f5988b9f 100644 --- a/Minecraft.World/ItemFrame.cpp +++ b/Minecraft.World/ItemFrame.cpp @@ -37,8 +37,8 @@ ItemFrame::ItemFrame(Level *level, int xTile, int yTile, int zTile, int dir) : H void ItemFrame::defineSynchedData() { - getEntityData()->defineNULL(DATA_ITEM, NULL); - getEntityData()->define(DATA_ROTATION, (byte) 0); + getEntityData()->defineNULL(DATA_ITEM, nullptr); + getEntityData()->define(DATA_ROTATION, static_cast<byte>(0)); } bool ItemFrame::shouldRenderAtSqrDistance(double distance) @@ -52,7 +52,7 @@ void ItemFrame::dropItem(shared_ptr<Entity> causedBy) { shared_ptr<ItemInstance> item = getItem(); - if (causedBy != NULL && causedBy->instanceof(eTYPE_PLAYER)) + if (causedBy != nullptr && causedBy->instanceof(eTYPE_PLAYER)) { if (dynamic_pointer_cast<Player>(causedBy)->abilities.instabuild) { @@ -61,8 +61,8 @@ void ItemFrame::dropItem(shared_ptr<Entity> causedBy) } } - spawnAtLocation( shared_ptr<ItemInstance>(new ItemInstance(Item::frame) ), 0); - if ( (item != NULL) && (random->nextFloat() < dropChance) ) + spawnAtLocation(std::make_shared<ItemInstance>(Item::frame), 0); + if ( (item != nullptr) && (random->nextFloat() < dropChance) ) { item = item->copy(); removeFramedMap(item); @@ -72,7 +72,7 @@ void ItemFrame::dropItem(shared_ptr<Entity> causedBy) void ItemFrame::removeFramedMap(shared_ptr<ItemInstance> item) { - if (item == NULL) return; + if (item == nullptr) return; if (item->id == Item::map_Id) { shared_ptr<MapItemSavedData> mapItemSavedData = Item::map->getSavedData(item, level); @@ -89,7 +89,7 @@ shared_ptr<ItemInstance> ItemFrame::getItem() void ItemFrame::setItem(shared_ptr<ItemInstance> item) { - if(item != NULL) + if(item != nullptr) { item = item->copy(); item->count = 1; @@ -107,15 +107,15 @@ int ItemFrame::getRotation() void ItemFrame::setRotation(int rotation) { - getEntityData()->set(DATA_ROTATION, (byte) (rotation % 4)); + getEntityData()->set(DATA_ROTATION, static_cast<byte>(rotation % 4)); } void ItemFrame::addAdditonalSaveData(CompoundTag *tag) { - if (getItem() != NULL) + if (getItem() != nullptr) { tag->putCompound(L"Item", getItem()->save(new CompoundTag())); - tag->putByte(L"ItemRotation", (byte) getRotation()); + tag->putByte(L"ItemRotation", static_cast<byte>(getRotation())); tag->putFloat(L"ItemDropChance", dropChance); } HangingEntity::addAdditonalSaveData(tag); @@ -124,7 +124,7 @@ void ItemFrame::addAdditonalSaveData(CompoundTag *tag) void ItemFrame::readAdditionalSaveData(CompoundTag *tag) { CompoundTag *itemTag = tag->getCompound(L"Item"); - if (itemTag != NULL && !itemTag->isEmpty()) + if (itemTag != nullptr && !itemTag->isEmpty()) { setItem(ItemInstance::fromTag(itemTag)); setRotation(tag->getByte(L"ItemRotation")); @@ -141,11 +141,11 @@ bool ItemFrame::interact(shared_ptr<Player> player) return false; } - if (getItem() == NULL) + if (getItem() == nullptr) { shared_ptr<ItemInstance> item = player->getCarriedItem(); - if (item != NULL) + if (item != nullptr) { if (!level->isClientSide)//isClientSide) { |
