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:
Ursprung
b19314a834
Commit
6afb9da7cb
@ -1,9 +1,12 @@
|
|||||||
package org.bukkit.craftbukkit.entity;
|
package org.bukkit.craftbukkit.entity;
|
||||||
|
|
||||||
import net.minecraft.core.EnumDirection;
|
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 net.minecraft.world.entity.decoration.EntityHanging;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Hanging;
|
import org.bukkit.entity.Hanging;
|
||||||
@ -71,4 +74,19 @@ public class CraftHanging extends CraftEntity implements Hanging {
|
|||||||
public EntityType getType() {
|
public EntityType getType() {
|
||||||
return EntityType.UNKNOWN;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package org.bukkit.craftbukkit.entity;
|
package org.bukkit.craftbukkit.entity;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import net.minecraft.core.BlockPosition;
|
|
||||||
import net.minecraft.core.EnumDirection;
|
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.EntityHanging;
|
||||||
import net.minecraft.world.entity.decoration.EntityItemFrame;
|
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.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Rotation;
|
import org.bukkit.Rotation;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -39,20 +37,17 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
@Override
|
||||||
EntityItemFrame old = this.getHandle();
|
protected void update() {
|
||||||
|
super.update();
|
||||||
|
|
||||||
WorldServer world = ((CraftWorld) getWorld()).getHandle();
|
// mark dirty, so that the client gets updated with item and rotation
|
||||||
BlockPosition position = old.getBlockPosition();
|
for (DataWatcher.Item<?> dataItem : getHandle().getDataWatcher().c()) {
|
||||||
EnumDirection direction = old.getDirection();
|
getHandle().getDataWatcher().markDirty(dataItem.a());
|
||||||
ItemStack item = old.getItem() != null ? old.getItem().cloneItemStack() : null;
|
}
|
||||||
|
|
||||||
old.die();
|
// update redstone
|
||||||
|
getHandle().getWorld().updateAdjacentComparators(getHandle().blockPosition, Blocks.AIR);
|
||||||
EntityItemFrame frame = new EntityItemFrame(world, position, direction);
|
|
||||||
frame.setItem(item);
|
|
||||||
world.addEntity(frame);
|
|
||||||
this.entity = frame;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package org.bukkit.craftbukkit.entity;
|
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.EntityPainting;
|
||||||
import net.minecraft.world.entity.decoration.Paintings;
|
import net.minecraft.world.entity.decoration.Paintings;
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.craftbukkit.CraftArt;
|
import org.bukkit.craftbukkit.CraftArt;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Painting;
|
import org.bukkit.entity.Painting;
|
||||||
|
|
||||||
@ -55,18 +52,6 @@ public class CraftPainting extends CraftHanging implements Painting {
|
|||||||
return false;
|
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
|
@Override
|
||||||
public EntityPainting getHandle() {
|
public EntityPainting getHandle() {
|
||||||
return (EntityPainting) entity;
|
return (EntityPainting) entity;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren