diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java index b597f268f1..34d22e34a9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java @@ -1,9 +1,12 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.core.EnumDirection; +import net.minecraft.server.level.PlayerChunkMap; +import net.minecraft.server.level.WorldServer; import net.minecraft.world.entity.decoration.EntityHanging; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.entity.EntityType; import org.bukkit.entity.Hanging; @@ -71,4 +74,19 @@ public class CraftHanging extends CraftEntity implements Hanging { public EntityType getType() { return EntityType.UNKNOWN; } + + protected void update() { + if (!getHandle().isAlive()) { + return; + } + + WorldServer world = ((CraftWorld) getWorld()).getHandle(); + PlayerChunkMap.EntityTracker entityTracker = world.getChunkProvider().playerChunkMap.trackedEntities.get(getEntityId()); + + if (entityTracker == null) { + return; + } + + entityTracker.broadcast(getHandle().P()); + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 86bb26cd1d..4238641ebb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -1,17 +1,15 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.core.BlockPosition; import net.minecraft.core.EnumDirection; -import net.minecraft.server.level.WorldServer; +import net.minecraft.network.syncher.DataWatcher; import net.minecraft.world.entity.decoration.EntityHanging; import net.minecraft.world.entity.decoration.EntityItemFrame; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Blocks; import org.apache.commons.lang.Validate; import org.bukkit.Rotation; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.EntityType; @@ -39,20 +37,17 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { return true; } - private void update() { - EntityItemFrame old = this.getHandle(); + @Override + protected void update() { + super.update(); - WorldServer world = ((CraftWorld) getWorld()).getHandle(); - BlockPosition position = old.getBlockPosition(); - EnumDirection direction = old.getDirection(); - ItemStack item = old.getItem() != null ? old.getItem().cloneItemStack() : null; + // mark dirty, so that the client gets updated with item and rotation + for (DataWatcher.Item dataItem : getHandle().getDataWatcher().c()) { + getHandle().getDataWatcher().markDirty(dataItem.a()); + } - old.die(); - - EntityItemFrame frame = new EntityItemFrame(world, position, direction); - frame.setItem(item); - world.addEntity(frame); - this.entity = frame; + // update redstone + getHandle().getWorld().updateAdjacentComparators(getHandle().blockPosition, Blocks.AIR); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 30f4053ac3..72f38fe6bc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -1,14 +1,11 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.level.WorldServer; -import net.minecraft.world.entity.EntityTypes; import net.minecraft.world.entity.decoration.EntityPainting; import net.minecraft.world.entity.decoration.Paintings; import org.bukkit.Art; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftArt; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.entity.EntityType; import org.bukkit.entity.Painting; @@ -55,18 +52,6 @@ public class CraftPainting extends CraftHanging implements Painting { return false; } - private void update() { - WorldServer world = ((CraftWorld) getWorld()).getHandle(); - EntityPainting painting = EntityTypes.PAINTING.a(world); - painting.blockPosition = getHandle().blockPosition; - painting.art = getHandle().art; - painting.setDirection(getHandle().getDirection()); - getHandle().die(); - getHandle().velocityChanged = true; // because this occurs when the painting is broken, so it might be important - world.addEntity(painting); - this.entity = painting; - } - @Override public EntityPainting getHandle() { return (EntityPainting) entity;