From 7698de7226f581573f45356f7b9b04620e0fc377 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 1 Nov 2024 14:01:04 +0000 Subject: [PATCH] Fixed crash when throwing a horseshoe, muffin, or rock at an entity. Closes #511 --- .../unicopia/projectile/PhysicsBodyProjectileEntity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/projectile/PhysicsBodyProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/projectile/PhysicsBodyProjectileEntity.java index 38ef6e5e..183720b7 100644 --- a/src/main/java/com/minelittlepony/unicopia/projectile/PhysicsBodyProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/projectile/PhysicsBodyProjectileEntity.java @@ -163,9 +163,11 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl } else { ItemStack stack = asItemStack(); if (stack.isIn(UTags.Items.HORSE_SHOES)) { - stack.damage(1 + random.nextInt(10), (ServerWorld)getWorld(), null, i -> { - playSound(USounds.Vanilla.ENTITY_ITEM_BREAK, 1, 1); - }); + if (getWorld() instanceof ServerWorld sw) { + stack.damage(1 + random.nextInt(10), sw, null, i -> { + playSound(USounds.Vanilla.ENTITY_ITEM_BREAK, 1, 1); + }); + } if (!stack.isEmpty()) { dropStack(stack); }