From 24cd6a9a3bf5776c6406456669ac10dd473b9656 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 27 Jan 2021 18:03:57 +0200 Subject: [PATCH] Fixed particle effect and added a sound effect when apples rot --- .../unicopia/item/AppleItem.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java index ea9aa0f2..96381cd9 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java @@ -13,6 +13,7 @@ import net.minecraft.entity.ItemEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleTypes; +import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.math.MathHelper; @@ -28,7 +29,7 @@ public class AppleItem extends Item implements ItemImpl.TickableItem { public ActionResult onGroundTick(IItemEntity item) { ItemEntity entity = item.get().getMaster(); - if (!entity.removed && item.getPickupDelay() == 0 && item.getAge() > 200230 && entity.world.random.nextInt(200) < 10) { + if (!entity.removed && item.getPickupDelay() == 0 && item.getAge() > 2030 && entity.world.random.nextInt(150) < 10) { if (!entity.world.isClient) { entity.remove(); @@ -45,16 +46,17 @@ public class AppleItem extends Item implements ItemImpl.TickableItem { copy.getStack().decrement(1); entity.world.spawnEntity(copy); - } else { - float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.hoverHeight) * 0.1F + 0.1F; - - for (int i = 0; i < 3; i++) { - entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(), - entity.world.random.nextGaussian() - 0.5F, - entity.world.random.nextGaussian() - 0.5F, - entity.world.random.nextGaussian() - 0.5F); - } } + + float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.hoverHeight) * 0.1F + 0.1F; + + for (int i = 0; i < 3; i++) { + entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(), + entity.world.random.nextGaussian() - 0.5F, + entity.world.random.nextGaussian() - 0.5F, + entity.world.random.nextGaussian() - 0.5F); + } + entity.playSound(SoundEvents.ENTITY_ZOMBIE_DESTROY_EGG, 0.5F, 1.5F); } return ActionResult.PASS;