diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/EntityPackets.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/EntityPackets.java index 2b61e8b00..90f90d364 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/EntityPackets.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/EntityPackets.java @@ -157,9 +157,11 @@ public class EntityPackets { Item stack = wrapper.get(Type.ITEM, 0); if (stack != null) { - if (Material.getMaterial(stack.getId()).name().endsWith("SWORD")) { - entityTracker.getValidBlocking().add(entityID); - return; + if(Material.getMaterial(stack.getId()) != null) { + if (Material.getMaterial(stack.getId()).name().endsWith("SWORD")) { + entityTracker.getValidBlocking().add(entityID); + return; + } } } entityTracker.getValidBlocking().remove(entityID); diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index 28165d8f8..be0a7f53b 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -226,8 +226,8 @@ public class WorldPackets { public void handle(PacketWrapper wrapper) throws Exception { EntityTracker tracker = wrapper.user().get(EntityTracker.class); Long last = tracker.getLastPlaceBlock(); - if(last != -1){ - if((wrapper.user().getReceivedPackets() - last) < 5) { + if (last != -1) { + if ((wrapper.user().getReceivedPackets() - last) < 5) { wrapper.cancel(); } tracker.setLastPlaceBlock(-1L); @@ -248,17 +248,18 @@ public class WorldPackets { Item item = Item.getItem(Protocol1_9TO1_8.getHandItem(wrapper.user())); // Blocking patch if (item != null) { - if (Material.getMaterial(item.getId()).name().endsWith("SWORD")) { - if (hand == 0) { - EntityTracker tracker = wrapper.user().get(EntityTracker.class); - if (!tracker.isBlocking()) { - tracker.setBlocking(true); - Item shield = new Item((short) 442, (byte) 1, (short) 0, null); - tracker.setSecondHand(shield); + if (Material.getMaterial(item.getId()) != null) { + if (Material.getMaterial(item.getId()).name().endsWith("SWORD")) { + if (hand == 0) { + EntityTracker tracker = wrapper.user().get(EntityTracker.class); + if (!tracker.isBlocking()) { + tracker.setBlocking(true); + Item shield = new Item((short) 442, (byte) 1, (short) 0, null); + tracker.setSecondHand(shield); + } + wrapper.cancel(); } - wrapper.cancel(); } - } } wrapper.write(Type.ITEM, item);