Fixed crash when throwing a horseshoe, muffin, or rock at an entity. Closes #511

This commit is contained in:
Sollace 2024-11-01 14:01:04 +00:00
parent 8ef56c4890
commit 7698de7226
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -163,9 +163,11 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
} else { } else {
ItemStack stack = asItemStack(); ItemStack stack = asItemStack();
if (stack.isIn(UTags.Items.HORSE_SHOES)) { if (stack.isIn(UTags.Items.HORSE_SHOES)) {
stack.damage(1 + random.nextInt(10), (ServerWorld)getWorld(), null, i -> { if (getWorld() instanceof ServerWorld sw) {
stack.damage(1 + random.nextInt(10), sw, null, i -> {
playSound(USounds.Vanilla.ENTITY_ITEM_BREAK, 1, 1); playSound(USounds.Vanilla.ENTITY_ITEM_BREAK, 1, 1);
}); });
}
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
dropStack(stack); dropStack(stack);
} }