aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/ItemEntity.cpp
diff options
context:
space:
mode:
authordaoge <3523206925@qq.com>2026-03-03 03:04:10 +0800
committerGitHub <noreply@github.com>2026-03-03 03:04:10 +0800
commitb3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch)
tree267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/ItemEntity.cpp
parent84c31a2331f7a0ec85b9d438992e244f60e5020f (diff)
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/ItemEntity.cpp')
-rw-r--r--Minecraft.World/ItemEntity.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/Minecraft.World/ItemEntity.cpp b/Minecraft.World/ItemEntity.cpp
index eb7684a6..e6bdffa5 100644
--- a/Minecraft.World/ItemEntity.cpp
+++ b/Minecraft.World/ItemEntity.cpp
@@ -94,7 +94,7 @@ void ItemEntity::tick()
xd = (random->nextFloat() - random->nextFloat()) * 0.2f;
zd = (random->nextFloat() - random->nextFloat()) * 0.2f;
MemSect(31);
- level->playSound(shared_from_this(), eSoundType_RANDOM_FIZZ, 0.4f, 2.0f + random->nextFloat() * 0.4f);
+ playSound(eSoundType_RANDOM_FIZZ, 0.4f, 2.0f + random->nextFloat() * 0.4f);
MemSect(0);
}
@@ -184,13 +184,15 @@ void ItemEntity::burn(int dmg)
}
-bool ItemEntity::hurt(DamageSource *source, int damage)
+bool ItemEntity::hurt(DamageSource *source, float damage)
{
// 4J - added next line: found whilst debugging an issue with item entities getting into a bad state when being created by a cactus, since entities insides cactuses get hurt
// and therefore depending on the timing of things they could get removed from the client when they weren't supposed to be. Are there really any cases were we would want
// an itemEntity to be locally hurt?
- if (level->isClientSide ) return false;
+ if (level->isClientSide ) return false;
+ if (isInvulnerable()) return false;
+ if (getItem() != NULL && getItem()->id == Item::netherStar_Id && source->isExplosion()) return false;
markHurt();
health -= damage;
if (health <= 0)
@@ -254,7 +256,7 @@ void ItemEntity::playerTouch(shared_ptr<Player> player)
if (item->id == Item::blazeRod_Id)
player->awardStat(GenericStats::blazeRod(), GenericStats::param_blazeRod());
- level->playSound(shared_from_this(), eSoundType_RANDOM_POP, 0.2f, ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f);
+ playSound(eSoundType_RANDOM_POP, 0.2f, ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f);
player->take(shared_from_this(), orgCount);
// System.out.println(item.count + ", " + orgCount);
if (item->count <= 0) remove();
@@ -267,6 +269,13 @@ wstring ItemEntity::getAName()
//return I18n.get("item." + item.getDescriptionId());
}
+void ItemEntity::changeDimension(int i)
+{
+ Entity::changeDimension(i);
+
+ if (!level->isClientSide) mergeWithNeighbours();
+}
+
shared_ptr<ItemInstance> ItemEntity::getItem()
{
shared_ptr<ItemInstance> result = getEntityData()->getItemInstance(DATA_ITEM);
@@ -278,7 +287,7 @@ shared_ptr<ItemInstance> ItemEntity::getItem()
app.DebugPrintf("Item entity %d has no item?!\n", entityId);
//level.getLogger().severe("Item entity " + entityId + " has no item?!");
}
- return shared_ptr<ItemInstance>(new ItemInstance(Tile::rock));
+ return shared_ptr<ItemInstance>(new ItemInstance(Tile::stone));
}
return result;