Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
More cartography parity fixes
Dieser Commit ist enthalten in:
Ursprung
370f3c18ba
Commit
e493415241
@ -357,18 +357,29 @@ public abstract class InventoryTranslator {
|
|||||||
if (inventory instanceof CartographyContainer) {
|
if (inventory instanceof CartographyContainer) {
|
||||||
// TODO add this for more inventories? Only seems to glitch out the cartography table, though.
|
// TODO add this for more inventories? Only seems to glitch out the cartography table, though.
|
||||||
ConsumeStackRequestActionData consumeData = (ConsumeStackRequestActionData) action;
|
ConsumeStackRequestActionData consumeData = (ConsumeStackRequestActionData) action;
|
||||||
|
|
||||||
int sourceSlot = bedrockSlotToJava(consumeData.getSource());
|
int sourceSlot = bedrockSlotToJava(consumeData.getSource());
|
||||||
if (sourceSlot == 0 && inventory.getItem(1).isEmpty()) {
|
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 CARTOGRAPHY_ADDITIONAL could remain empty for Bedrock
|
// Java doesn't allow an item to be renamed; this is why one of the slots could remain empty for Bedrock
|
||||||
// We check this during slot 0 since setting the inventory slots here messes up shouldRejectItemPlace
|
// We check this now since setting the inventory slots here messes up shouldRejectItemPlace
|
||||||
return rejectRequest(request, false);
|
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);
|
GeyserItemStack item = inventory.getItem(sourceSlot);
|
||||||
item.setAmount(item.getAmount() - consumeData.getCount());
|
item.setAmount(item.getAmount() - consumeData.getCount());
|
||||||
if (item.isEmpty()) {
|
if (item.isEmpty()) {
|
||||||
inventory.setItem(sourceSlot, GeyserItemStack.EMPTY, session);
|
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);
|
affectedSlots.add(sourceSlot);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -46,13 +46,13 @@ public class CartographyInventoryTranslator extends AbstractBlockInventoryTransl
|
|||||||
public boolean shouldRejectItemPlace(GeyserSession session, Inventory inventory, ContainerSlotType bedrockSourceContainer,
|
public boolean shouldRejectItemPlace(GeyserSession session, Inventory inventory, ContainerSlotType bedrockSourceContainer,
|
||||||
int javaSourceSlot, ContainerSlotType bedrockDestinationContainer, int javaDestinationSlot) {
|
int javaSourceSlot, ContainerSlotType bedrockDestinationContainer, int javaDestinationSlot) {
|
||||||
if (javaDestinationSlot == 0) {
|
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);
|
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) {
|
} 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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren