More cartography parity fixes

This commit is contained in:
Camotoy 2021-03-10 14:43:54 -05:00
parent 370f3c18ba
commit e493415241
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 22 additions and 11 deletions

View file

@ -357,18 +357,29 @@ public abstract class InventoryTranslator {
if (inventory instanceof CartographyContainer) {
// TODO add this for more inventories? Only seems to glitch out the cartography table, though.
ConsumeStackRequestActionData consumeData = (ConsumeStackRequestActionData) action;
int sourceSlot = bedrockSlotToJava(consumeData.getSource());
if (sourceSlot == 0 && inventory.getItem(1).isEmpty()) {
// Java doesn't allow an item to be renamed; this is why CARTOGRAPHY_ADDITIONAL could remain empty for Bedrock
// We check this during slot 0 since setting the inventory slots here messes up shouldRejectItemPlace
if ((sourceSlot == 0 && inventory.getItem(1).isEmpty()) || (sourceSlot == 1 && inventory.getItem(0).isEmpty())) {
// Java doesn't allow an item to be renamed; this is why one of the slots could remain empty for Bedrock
// We check this now since setting the inventory slots here messes up shouldRejectItemPlace
return rejectRequest(request, false);
}
if (sourceSlot == 1) {
// Decrease the item count, but only after both slots are checked.
// Otherwise, the slot 1 check will fail
GeyserItemStack item = inventory.getItem(sourceSlot);
item.setAmount(item.getAmount() - consumeData.getCount());
if (item.isEmpty()) {
inventory.setItem(sourceSlot, GeyserItemStack.EMPTY, session);
}
GeyserItemStack itemZero = inventory.getItem(0);
itemZero.setAmount(itemZero.getAmount() - consumeData.getCount());
if (itemZero.isEmpty()) {
inventory.setItem(0, GeyserItemStack.EMPTY, session);
}
}
affectedSlots.add(sourceSlot);
}
break;

View file

@ -46,13 +46,13 @@ public class CartographyInventoryTranslator extends AbstractBlockInventoryTransl
public boolean shouldRejectItemPlace(GeyserSession session, Inventory inventory, ContainerSlotType bedrockSourceContainer,
int javaSourceSlot, ContainerSlotType bedrockDestinationContainer, int javaDestinationSlot) {
if (javaDestinationSlot == 0) {
// Bedrock Edition can use paper in slot 0
// Bedrock Edition can use paper or an empty map in slot 0
GeyserItemStack itemStack = javaSourceSlot == -1 ? session.getPlayerInventory().getCursor() : inventory.getItem(javaSourceSlot);
return itemStack.getItemEntry().getJavaIdentifier().equals("minecraft:paper");
return itemStack.getItemEntry().getJavaIdentifier().equals("minecraft:paper") || itemStack.getItemEntry().getJavaIdentifier().equals("minecraft:map");
} else if (javaDestinationSlot == 1) {
// Bedrock Edition can use a compass to create locator maps in the ADDITIONAL slot
// Bedrock Edition can use a compass to create locator maps, or use a filled map, in the ADDITIONAL slot
GeyserItemStack itemStack = javaSourceSlot == -1 ? session.getPlayerInventory().getCursor() : inventory.getItem(javaSourceSlot);
return itemStack.getItemEntry().getJavaIdentifier().equals("minecraft:compass");
return itemStack.getItemEntry().getJavaIdentifier().equals("minecraft:compass") || itemStack.getItemEntry().getJavaIdentifier().equals("minecraft:filled_map");
}
return false;
}