From 1ba53abe926dd2441ac2c866035c3c68e8c9fab6 Mon Sep 17 00:00:00 2001 From: PetteriM1 <26197131+PetteriM1@users.noreply.github.com> Date: Tue, 24 Oct 2023 22:23:31 +0300 Subject: [PATCH] Netherite items can float in lava (#2150) --- src/main/java/cn/nukkit/entity/item/EntityItem.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/cn/nukkit/entity/item/EntityItem.java b/src/main/java/cn/nukkit/entity/item/EntityItem.java index 21ca1ce9236..86d7f5257c4 100644 --- a/src/main/java/cn/nukkit/entity/item/EntityItem.java +++ b/src/main/java/cn/nukkit/entity/item/EntityItem.java @@ -1,6 +1,7 @@ package cn.nukkit.entity.item; import cn.nukkit.Server; +import cn.nukkit.block.Block; import cn.nukkit.block.BlockID; import cn.nukkit.entity.Entity; import cn.nukkit.event.entity.EntityDamageEvent; @@ -39,6 +40,7 @@ public int getNetworkId() { protected Item item; protected int pickupDelay; + protected boolean floatsInLava; @Override public float getWidth() { @@ -109,6 +111,7 @@ protected void initEntity() { int id = this.item.getId(); if (id >= Item.NETHERITE_INGOT && id <= Item.NETHERITE_SCRAP) { this.fireProof = true; // Netherite items are fireproof + this.floatsInLava = true; } this.server.getPluginManager().callEvent(new ItemSpawnEvent(this)); @@ -214,7 +217,8 @@ public boolean onUpdate(int currentTick) { }*/ int bid = level.getBlock(this.getFloorX(), NukkitMath.floorDouble(this.y + 0.53), this.getFloorZ(), false).getId(); - if (bid == BlockID.WATER || bid == BlockID.STILL_WATER) { + if (bid == BlockID.WATER || bid == BlockID.STILL_WATER || + (this.floatsInLava && (bid == Block.LAVA || bid == Block.STILL_LAVA))) { this.motionY = this.getGravity() / 2; } else if (!this.isOnGround()) { this.motionY -= this.getGravity();