13
0
geforkt von Mirrors/Paper

SPIGOT-6189: Persistent data disappears when calling setFacingDirection on an item frame

By: DerFrZocker <derrieple@gmail.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2021-05-15 10:11:38 +10:00
Ursprung b19314a834
Commit 6afb9da7cb
3 geänderte Dateien mit 29 neuen und 31 gelöschten Zeilen

Datei anzeigen

@ -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());
}
}

Datei anzeigen

@ -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

Datei anzeigen

@ -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;