Skip to content

Commit

Permalink
Netherite items can float in lava
Browse files Browse the repository at this point in the history
(cherry picked from commit 1ba53ab)
  • Loading branch information
PetteriM1 authored and wode490390 committed May 25, 2024
1 parent 1a10ec6 commit 7262c28
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/cn/nukkit/entity/item/EntityItem.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -39,6 +40,7 @@ public int getNetworkId() {
protected Item item;

protected int pickupDelay;
protected boolean floatsInLava;

@Override
public float getWidth() {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7262c28

Please sign in to comment.