forked from GeyserMC/Geyser
Bump OpenNBT lib to 1.4-SNAPSHOT
This fixes the NPE when sending an ItemStack with a null NBT tag. This also fixes some item movement bugs on pure vanilla servers.
This commit is contained in:
parent
1a9aa4255f
commit
3d61b3ce28
4 changed files with 4 additions and 11 deletions
|
@ -79,7 +79,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.steveice10</groupId>
|
<groupId>com.github.steveice10</groupId>
|
||||||
<artifactId>opennbt</artifactId>
|
<artifactId>opennbt</artifactId>
|
||||||
<version>1.3-SNAPSHOT</version>
|
<version>1.4-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -182,7 +182,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
||||||
} else {
|
} else {
|
||||||
javaItem = TranslatorsInit.getItemTranslator().translateToJava(action.getToItem());
|
javaItem = TranslatorsInit.getItemTranslator().translateToJava(action.getToItem());
|
||||||
}
|
}
|
||||||
ClientCreativeInventoryActionPacket creativePacket = new ClientCreativeInventoryActionPacket(javaSlot, InventoryUtils.fixStack(javaItem));
|
ClientCreativeInventoryActionPacket creativePacket = new ClientCreativeInventoryActionPacket(javaSlot, javaItem);
|
||||||
session.getDownstream().getSession().send(creativePacket);
|
session.getDownstream().getSession().send(creativePacket);
|
||||||
inventory.setItem(javaSlot, javaItem);
|
inventory.setItem(javaSlot, javaItem);
|
||||||
break;
|
break;
|
||||||
|
@ -195,7 +195,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
||||||
if (action.getSource().getType() == InventorySource.Type.WORLD_INTERACTION
|
if (action.getSource().getType() == InventorySource.Type.WORLD_INTERACTION
|
||||||
&& action.getSource().getFlag() == InventorySource.Flag.DROP_ITEM) {
|
&& action.getSource().getFlag() == InventorySource.Flag.DROP_ITEM) {
|
||||||
javaItem = TranslatorsInit.getItemTranslator().translateToJava(action.getToItem());
|
javaItem = TranslatorsInit.getItemTranslator().translateToJava(action.getToItem());
|
||||||
ClientCreativeInventoryActionPacket creativeDropPacket = new ClientCreativeInventoryActionPacket(-1, InventoryUtils.fixStack(javaItem));
|
ClientCreativeInventoryActionPacket creativeDropPacket = new ClientCreativeInventoryActionPacket(-1, javaItem);
|
||||||
session.getDownstream().getSession().send(creativeDropPacket);
|
session.getDownstream().getSession().send(creativeDropPacket);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ClickPlan {
|
||||||
refresh = true;
|
refresh = true;
|
||||||
|
|
||||||
ClientWindowActionPacket clickPacket = new ClientWindowActionPacket(inventory.getId(),
|
ClientWindowActionPacket clickPacket = new ClientWindowActionPacket(inventory.getId(),
|
||||||
actionId, action.slot, !planIter.hasNext() && refresh ? InventoryUtils.REFRESH_ITEM : InventoryUtils.fixStack(clickedItem),
|
actionId, action.slot, !planIter.hasNext() && refresh ? InventoryUtils.REFRESH_ITEM : clickedItem,
|
||||||
WindowAction.CLICK_ITEM, action.click.actionParam);
|
WindowAction.CLICK_ITEM, action.click.actionParam);
|
||||||
|
|
||||||
if (translator.getSlotType(action.slot) == SlotType.OUTPUT) {
|
if (translator.getSlotType(action.slot) == SlotType.OUTPUT) {
|
||||||
|
|
|
@ -87,13 +87,6 @@ public class InventoryUtils {
|
||||||
session.getUpstream().sendPacket(cursorPacket);
|
session.getUpstream().sendPacket(cursorPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
//NPE if compound tag is null
|
|
||||||
public static ItemStack fixStack(ItemStack stack) {
|
|
||||||
if (stack == null || stack.getId() == 0)
|
|
||||||
return null;
|
|
||||||
return new ItemStack(stack.getId(), stack.getAmount(), stack.getNbt() == null ? new CompoundTag("") : stack.getNbt());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canStack(ItemStack item1, ItemStack item2) {
|
public static boolean canStack(ItemStack item1, ItemStack item2) {
|
||||||
if (item1 == null || item2 == null)
|
if (item1 == null || item2 == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue