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.
This commit is contained in:
RednedEpic 2020-05-23 23:14:29 -05:00
parent 681cbeeae5
commit ebd88c76aa

View file

@ -87,9 +87,12 @@ public class ItemFrameEntity extends Entity {
@Override @Override
public void spawnEntity(GeyserSession session) { public void spawnEntity(GeyserSession session) {
session.getItemFrameCache().put(bedrockPosition, entityId); 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; valid = true;
session.getConnector().getLogger().debug("Spawned item frame at location " + bedrockPosition + " with java id " + entityId);
} }
@Override @Override
@ -170,27 +173,24 @@ public class ItemFrameEntity extends Entity {
* @param session GeyserSession. * @param session GeyserSession.
*/ */
public void updateBlock(GeyserSession session) { public void updateBlock(GeyserSession session) {
// Delay is required, or else loading in frames on chunk load is sketchy at best UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
session.getConnector().getGeneralThreadPool().schedule(() -> { updateBlockPacket.setDataLayer(0);
UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket(); updateBlockPacket.setBlockPosition(bedrockPosition);
updateBlockPacket.setDataLayer(0); updateBlockPacket.setRuntimeId(bedrockRuntimeId);
updateBlockPacket.setBlockPosition(bedrockPosition); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
updateBlockPacket.setRuntimeId(bedrockRuntimeId); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); session.sendUpstreamPacket(updateBlockPacket);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
session.sendUpstreamPacket(updateBlockPacket);
BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket(); BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket();
blockEntityDataPacket.setBlockPosition(bedrockPosition); blockEntityDataPacket.setBlockPosition(bedrockPosition);
if (cachedTag != null) { if (cachedTag != null) {
blockEntityDataPacket.setData(cachedTag); blockEntityDataPacket.setData(cachedTag);
} else { } else {
blockEntityDataPacket.setData(getDefaultTag()); blockEntityDataPacket.setData(getDefaultTag());
} }
session.sendUpstreamPacket(blockEntityDataPacket); session.sendUpstreamPacket(blockEntityDataPacket);
}, 500, TimeUnit.MILLISECONDS);
} }
/** /**