Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
Add better destroy support
Dieser Commit ist enthalten in:
Ursprung
d3cb069594
Commit
454fd102d6
@ -465,7 +465,6 @@ public abstract class InventoryTranslator {
|
|||||||
}
|
}
|
||||||
case DESTROY: {
|
case DESTROY: {
|
||||||
// Only called when a creative client wants to destroy an item... I think - Camotoy
|
// Only called when a creative client wants to destroy an item... I think - Camotoy
|
||||||
//TODO there is a Count here we don't use
|
|
||||||
DestroyStackRequestActionData destroyAction = (DestroyStackRequestActionData) action;
|
DestroyStackRequestActionData destroyAction = (DestroyStackRequestActionData) action;
|
||||||
if (!session.getGameMode().equals(GameMode.CREATIVE)) {
|
if (!session.getGameMode().equals(GameMode.CREATIVE)) {
|
||||||
// If this happens, let's throw an error and figure out why.
|
// If this happens, let's throw an error and figure out why.
|
||||||
@ -474,13 +473,23 @@ public abstract class InventoryTranslator {
|
|||||||
if (!isCursor(destroyAction.getSource())) {
|
if (!isCursor(destroyAction.getSource())) {
|
||||||
// Item exists; let's remove it from the inventory
|
// Item exists; let's remove it from the inventory
|
||||||
int javaSlot = bedrockSlotToJava(destroyAction.getSource());
|
int javaSlot = bedrockSlotToJava(destroyAction.getSource());
|
||||||
ClientCreativeInventoryActionPacket destroyItemPacket = new ClientCreativeInventoryActionPacket(
|
GeyserItemStack existingItem = inventory.getItem(javaSlot);
|
||||||
javaSlot,
|
existingItem.setAmount(existingItem.getAmount() - destroyAction.getCount());
|
||||||
new ItemStack(0)
|
ClientCreativeInventoryActionPacket destroyItemPacket;
|
||||||
);
|
if (existingItem.isEmpty()) {
|
||||||
|
destroyItemPacket = new ClientCreativeInventoryActionPacket(
|
||||||
|
javaSlot,
|
||||||
|
new ItemStack(0)
|
||||||
|
);
|
||||||
|
inventory.setItem(javaSlot, GeyserItemStack.EMPTY, session);
|
||||||
|
} else {
|
||||||
|
destroyItemPacket = new ClientCreativeInventoryActionPacket(
|
||||||
|
javaSlot,
|
||||||
|
existingItem.getItemStack()
|
||||||
|
);
|
||||||
|
}
|
||||||
session.sendDownstreamPacket(destroyItemPacket);
|
session.sendDownstreamPacket(destroyItemPacket);
|
||||||
System.out.println(destroyItemPacket);
|
System.out.println(destroyItemPacket);
|
||||||
inventory.setItem(javaSlot, GeyserItemStack.EMPTY, session);
|
|
||||||
affectedSlots.add(javaSlot);
|
affectedSlots.add(javaSlot);
|
||||||
} else {
|
} else {
|
||||||
// Just sync up the item on our end, since the server doesn't care what's in our cursor
|
// Just sync up the item on our end, since the server doesn't care what's in our cursor
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren