mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix item durability 'resetting' on 1.16.210 (#2042)
This commit is contained in:
parent
2f058e05bd
commit
d41d8b0ebf
1 changed files with 17 additions and 2 deletions
|
@ -32,6 +32,8 @@ import com.github.steveice10.mc.protocol.data.game.recipe.Recipe;
|
|||
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.StackRequestSlotInfoData;
|
||||
|
@ -40,7 +42,10 @@ import com.nukkitx.protocol.bedrock.packet.ItemStackResponsePacket;
|
|||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.inventory.*;
|
||||
import org.geysermc.connector.inventory.CartographyContainer;
|
||||
import org.geysermc.connector.inventory.GeyserItemStack;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.inventory.PlayerInventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.inventory.click.Click;
|
||||
import org.geysermc.connector.network.translators.inventory.click.ClickPlan;
|
||||
|
@ -854,7 +859,17 @@ public abstract class InventoryTranslator {
|
|||
public static ItemStackResponsePacket.ItemEntry makeItemEntry(int bedrockSlot, GeyserItemStack itemStack) {
|
||||
ItemStackResponsePacket.ItemEntry itemEntry;
|
||||
if (!itemStack.isEmpty()) {
|
||||
itemEntry = new ItemStackResponsePacket.ItemEntry((byte) bedrockSlot, (byte) bedrockSlot, (byte) itemStack.getAmount(), itemStack.getNetId(), "", 0);
|
||||
// As of 1.16.210: Bedrock needs confirmation on what the current item durability is.
|
||||
// If 0 is sent, then Bedrock thinks the item is not damaged
|
||||
int durability = 0;
|
||||
if (itemStack.getNbt() != null) {
|
||||
Tag damage = itemStack.getNbt().get("Damage");
|
||||
if (damage instanceof IntTag) {
|
||||
durability = ((IntTag) damage).getValue();
|
||||
}
|
||||
}
|
||||
|
||||
itemEntry = new ItemStackResponsePacket.ItemEntry((byte) bedrockSlot, (byte) bedrockSlot, (byte) itemStack.getAmount(), itemStack.getNetId(), "", durability);
|
||||
} else {
|
||||
itemEntry = new ItemStackResponsePacket.ItemEntry((byte) bedrockSlot, (byte) bedrockSlot, (byte) 0, 0, "", 0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue