More comments

This commit is contained in:
Camotoy 2020-12-28 13:16:17 -05:00
parent 3ba396e625
commit a5c020e7ee
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F

View file

@ -72,7 +72,6 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
LecternContainer lecternContainer = (LecternContainer) inventory; LecternContainer lecternContainer = (LecternContainer) inventory;
lecternContainer.setCurrentBedrockPage(value / 2); lecternContainer.setCurrentBedrockPage(value / 2);
lecternContainer.setBlockEntityTag(lecternContainer.getBlockEntityTag().toBuilder().putInt("page", lecternContainer.getCurrentBedrockPage()).build()); lecternContainer.setBlockEntityTag(lecternContainer.getBlockEntityTag().toBuilder().putInt("page", lecternContainer.getCurrentBedrockPage()).build());
System.out.println(lecternContainer.getBlockEntityTag());
BlockEntityUtils.updateBlockEntity(session, lecternContainer.getBlockEntityTag(), lecternContainer.getPosition()); BlockEntityUtils.updateBlockEntity(session, lecternContainer.getBlockEntityTag(), lecternContainer.getPosition());
} }
} }
@ -100,7 +99,7 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
if (tag != null) { if (tag != null) {
// Position has to be the last interacted position... right? // Position has to be the last interacted position... right?
Vector3i position = session.getLastInteractionPosition(); Vector3i position = session.getLastInteractionPosition();
// shouldRefresh means that we should boot out the // shouldRefresh means that we should boot out the client on our side because their lectern GUI isn't updated yet
boolean shouldRefresh = !session.getConnector().getWorldManager().shouldExpectLecternHandled() && !session.getLecternCache().contains(position); boolean shouldRefresh = !session.getConnector().getWorldManager().shouldExpectLecternHandled() && !session.getLecternCache().contains(position);
int pagesSize = ((ListTag) tag.get("pages")).size(); int pagesSize = ((ListTag) tag.get("pages")).size();
ItemData itemData = geyserItemStack.getItemData(session); ItemData itemData = geyserItemStack.getItemData(session);
@ -116,7 +115,6 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
// Even with serverside access to lecterns, we don't easily know which lectern this is, so we need to rebuild // Even with serverside access to lecterns, we don't easily know which lectern this is, so we need to rebuild
// the block entity tag // the block entity tag
lecternContainer.setBlockEntityTag(blockEntityTag); lecternContainer.setBlockEntityTag(blockEntityTag);
System.out.println(blockEntityTag);
lecternContainer.setPosition(position); lecternContainer.setPosition(position);
if (shouldRefresh) { if (shouldRefresh) {
// Update the lectern because it's not updated client-side // Update the lectern because it's not updated client-side
@ -148,6 +146,7 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
builder.putByte("hasBook", (byte) 1); builder.putByte("hasBook", (byte) 1);
builder.putInt("totalPages", totalPages); builder.putInt("totalPages", totalPages);
} else { } else {
// Not usually needed, but helps with kicking out Bedrock players from reading the UI
builder.putByte("hasBook", (byte) 0); builder.putByte("hasBook", (byte) 0);
} }
return builder; return builder;