From ebd88c76aad8a200dfee3c498a77b90b1762afa8 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sat, 23 May 2020 23:14:29 -0500 Subject: [PATCH] Don't delay item frame interactions Causes interacting (moving) an item in an item frame to delay by about half a second. This delay is still present on chunk load where this delay is absolutely needed in order to the item frame to show up. --- .../connector/entity/ItemFrameEntity.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/entity/ItemFrameEntity.java b/connector/src/main/java/org/geysermc/connector/entity/ItemFrameEntity.java index f100704f1..5954e77eb 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/ItemFrameEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/ItemFrameEntity.java @@ -87,9 +87,12 @@ public class ItemFrameEntity extends Entity { @Override public void spawnEntity(GeyserSession session) { session.getItemFrameCache().put(bedrockPosition, entityId); - updateBlock(session); + // Delay is required, or else loading in frames on chunk load is sketchy at best + session.getConnector().getGeneralThreadPool().schedule(() -> { + updateBlock(session); + session.getConnector().getLogger().debug("Spawned item frame at location " + bedrockPosition + " with java id " + entityId); + }, 500, TimeUnit.MILLISECONDS); valid = true; - session.getConnector().getLogger().debug("Spawned item frame at location " + bedrockPosition + " with java id " + entityId); } @Override @@ -170,27 +173,24 @@ public class ItemFrameEntity extends Entity { * @param session GeyserSession. */ public void updateBlock(GeyserSession session) { - // Delay is required, or else loading in frames on chunk load is sketchy at best - session.getConnector().getGeneralThreadPool().schedule(() -> { - UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket(); - updateBlockPacket.setDataLayer(0); - updateBlockPacket.setBlockPosition(bedrockPosition); - updateBlockPacket.setRuntimeId(bedrockRuntimeId); - updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); - updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); - updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); - session.sendUpstreamPacket(updateBlockPacket); + UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket(); + updateBlockPacket.setDataLayer(0); + updateBlockPacket.setBlockPosition(bedrockPosition); + updateBlockPacket.setRuntimeId(bedrockRuntimeId); + updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); + updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); + updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); + session.sendUpstreamPacket(updateBlockPacket); - BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket(); - blockEntityDataPacket.setBlockPosition(bedrockPosition); - if (cachedTag != null) { - blockEntityDataPacket.setData(cachedTag); - } else { - blockEntityDataPacket.setData(getDefaultTag()); - } + BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket(); + blockEntityDataPacket.setBlockPosition(bedrockPosition); + if (cachedTag != null) { + blockEntityDataPacket.setData(cachedTag); + } else { + blockEntityDataPacket.setData(getDefaultTag()); + } - session.sendUpstreamPacket(blockEntityDataPacket); - }, 500, TimeUnit.MILLISECONDS); + session.sendUpstreamPacket(blockEntityDataPacket); } /**