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
1 changed files with 21 additions and 21 deletions

View File

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