Skip to content

Commit

Permalink
Fix NPE in PlayerAction when BlockPosition is null
Browse files Browse the repository at this point in the history
  • Loading branch information
bundabrg committed Feb 17, 2021
1 parent 1676a76 commit 6d557c6
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ public PlayerActionHandlerHandler_v390ee_to_v408be(BedrockTranslator translator)
public boolean fromUpstream(PlayerActionPacket packet) {
super.fromUpstream(packet);

InventoryTransactionHandler_v390ee_to_v408be ith = (InventoryTransactionHandler_v390ee_to_v408be) getTranslator().getHandlers().get(InventoryTransactionPacket.class);

// If ith has a penderItemUse with the same location as this we will handle it ourself
InventoryTransactionHandler_v390ee_to_v408be.PendingUseItem pending = ith.getPendingUseItems().stream()
.filter(i -> i.getFirstPacket().getBlockPosition().equals(packet.getBlockPosition()))
.findFirst()
.orElse(null);

if (pending != null) {
pending.setActionPacket(packet);
return true;
if (packet.getBlockPosition() != null) {
InventoryTransactionHandler_v390ee_to_v408be ith = (InventoryTransactionHandler_v390ee_to_v408be) getTranslator().getHandlers().get(InventoryTransactionPacket.class);

// If ith has a pendingItemUse with the same location as this we will handle it ourself
InventoryTransactionHandler_v390ee_to_v408be.PendingUseItem pending = ith.getPendingUseItems().stream()
.filter(i -> i.getFirstPacket().getBlockPosition().equals(packet.getBlockPosition()))
.findFirst()
.orElse(null);

if (pending != null) {
pending.setActionPacket(packet);
return true;
}
}

return false;
Expand Down

0 comments on commit 6d557c6

Please sign in to comment.