9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-19 15:09:15 +00:00

添加家具刷新方法

This commit is contained in:
XiaoMoMi
2025-12-18 23:30:56 +08:00
parent 433dc2e25e
commit 7cb77bed76
2 changed files with 15 additions and 2 deletions

View File

@@ -144,7 +144,7 @@ public class BukkitFurniture extends Furniture {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected void refresh() { public void refresh() {
ItemDisplay itemDisplay = this.metaEntity.get(); ItemDisplay itemDisplay = this.metaEntity.get();
if (itemDisplay == null) return; if (itemDisplay == null) return;
Object removePacket = FastNMS.INSTANCE.constructor$ClientboundRemoveEntitiesPacket(MiscUtils.init(new IntArrayList(), l -> l.add(itemDisplay.getEntityId()))); Object removePacket = FastNMS.INSTANCE.constructor$ClientboundRemoveEntitiesPacket(MiscUtils.init(new IntArrayList(), l -> l.add(itemDisplay.getEntityId())));
@@ -156,6 +156,17 @@ public class BukkitFurniture extends Furniture {
} }
} }
@Override
public void refresh(net.momirealms.craftengine.core.entity.player.Player player) {
ItemDisplay itemDisplay = this.metaEntity.get();
if (itemDisplay == null) return;
Object removePacket = FastNMS.INSTANCE.constructor$ClientboundRemoveEntitiesPacket(MiscUtils.init(new IntArrayList(), l -> l.add(itemDisplay.getEntityId())));
Object addPacket = FastNMS.INSTANCE.constructor$ClientboundAddEntityPacket(itemDisplay.getEntityId(), itemDisplay.getUniqueId(),
itemDisplay.getX(), itemDisplay.getY(), itemDisplay.getZ(), itemDisplay.getPitch(), itemDisplay.getYaw(), MEntityTypes.ITEM_DISPLAY, 0, CoreReflections.instance$Vec3$Zero, 0);
player.sendPacket(removePacket, false);
player.sendPacket(addPacket, false);
}
@Override @Override
public void destroy() { public void destroy() {
Optional.ofNullable(this.metaEntity.get()).ifPresent(Entity::remove); Optional.ofNullable(this.metaEntity.get()).ifPresent(Entity::remove);

View File

@@ -79,7 +79,9 @@ public abstract class Furniture implements Cullable {
public abstract CompletableFuture<Boolean> moveTo(WorldPosition position, boolean force); public abstract CompletableFuture<Boolean> moveTo(WorldPosition position, boolean force);
protected abstract void refresh(); public abstract void refresh();
public abstract void refresh(Player player);
protected void clearColliders() { protected void clearColliders() {
if (this.colliders != null) { if (this.colliders != null) {