3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-09-17 00:33:47 +02:00
Dieser Commit ist enthalten in:
AJ Ferguson 2019-11-30 17:22:14 -09:00
Ursprung db0e506e3b
Commit ba0b898da9
2 geänderte Dateien mit 29 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -131,22 +131,18 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
InventoryAction anvilResult = null; InventoryAction anvilResult = null;
InventoryAction anvilInput = null; InventoryAction anvilInput = null;
for (InventoryAction action : packet.getActions()) { for (InventoryAction action : packet.getActions()) {
if (action.getSource().getContainerId() == ContainerId.ANVIL_RESULT) { if (action.getSource().getContainerId() == ContainerId.ANVIL_MATERIAL) {
//useless packet
return;
} else if (action.getSource().getContainerId() == ContainerId.ANVIL_RESULT) {
anvilResult = action; anvilResult = action;
} else if (action.getSource().getContainerId() == ContainerId.CONTAINER_INPUT) { } else if (translator.bedrockSlotToJava(action) == 0) {
anvilInput = action; anvilInput = action;
} }
} }
ItemData itemName = null; ItemData itemName = null;
if (anvilResult != null) { if (anvilResult != null) {
itemName = anvilResult.getFromItem(); itemName = anvilResult.getFromItem();
actions = new ArrayList<>(2);
for (InventoryAction action : packet.getActions()) { //packet sent by client when grabbing anvil output needs useless actions stripped
if (!(action.getSource().getContainerId() == ContainerId.CONTAINER_INPUT ||
action.getSource().getContainerId() == ContainerId.ANVIL_MATERIAL)) {
actions.add(action);
}
}
} else if (anvilInput != null) { } else if (anvilInput != null) {
itemName = anvilInput.getToItem(); itemName = anvilInput.getToItem();
} }
@ -161,6 +157,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename); ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename);
session.getDownstream().getSession().send(renameItemPacket); session.getDownstream().getSession().send(renameItemPacket);
} }
if (anvilResult != null) {
//client will send another packet to grab anvil output
//this packet was only used to send rename packet
return;
}
} }
if (actions.size() == 2) { if (actions.size() == 2) {
@ -494,7 +495,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
ItemStack clickedItem = inventory.getItem(action.slot); ItemStack clickedItem = inventory.getItem(action.slot);
short actionId = (short) inventory.getTransactionId().getAndIncrement(); short actionId = (short) inventory.getTransactionId().getAndIncrement();
boolean craftingOutput = (inventory.getId() == 0 || inventory.getWindowType() == WindowType.CRAFTING) && action.slot == 0; boolean craftingOutput = (inventory.getId() == 0 || inventory.getWindowType() == WindowType.CRAFTING) && action.slot == 0;
if (craftingOutput) if (craftingOutput || translator.isOutputSlot(action.slot))
refresh = true; refresh = true;
ClientWindowActionPacket clickPacket = new ClientWindowActionPacket(inventory.getId(), ClientWindowActionPacket clickPacket = new ClientWindowActionPacket(inventory.getId(),
actionId, action.slot, !planIter.hasNext() && refresh ? refreshItem : fixStack(clickedItem), actionId, action.slot, !planIter.hasNext() && refresh ? refreshItem : fixStack(clickedItem),

Datei anzeigen

@ -28,6 +28,14 @@ package org.geysermc.connector.network.translators.inventory;
import com.nukkitx.protocol.bedrock.data.ContainerId; import com.nukkitx.protocol.bedrock.data.ContainerId;
import com.nukkitx.protocol.bedrock.data.ContainerType; import com.nukkitx.protocol.bedrock.data.ContainerType;
import com.nukkitx.protocol.bedrock.data.InventoryAction; import com.nukkitx.protocol.bedrock.data.InventoryAction;
import com.nukkitx.protocol.bedrock.data.ItemData;
import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket;
import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.TranslatorsInit;
import java.util.Arrays;
public class AnvilInventoryTranslator extends BlockInventoryTranslator { public class AnvilInventoryTranslator extends BlockInventoryTranslator {
public AnvilInventoryTranslator() { public AnvilInventoryTranslator() {
@ -45,12 +53,18 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
return slotnum + this.size + 27; return slotnum + this.size + 27;
} }
} else { } else {
if (action.getSource().getContainerId() == ContainerId.ANVIL_RESULT) { if (action.getSource().getContainerId() == ContainerId.CURSOR) {
return 2; switch (slotnum) {
} else { case 1:
return slotnum; return 0;
case 2:
return 1;
case 50:
return 2;
}
} }
} }
return slotnum;
} }
@Override @Override