From 1920233090cc285cdd8bdf2236aa707b835e3575 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 1 Nov 2024 14:02:45 +0000 Subject: [PATCH] Fixed horseshoes shot from dispensers not using their correct speed for the item fired --- .../unicopia/item/HorseShoeItem.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/minelittlepony/unicopia/item/HorseShoeItem.java b/src/main/java/com/minelittlepony/unicopia/item/HorseShoeItem.java index 98e44a06..cbb71890 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/HorseShoeItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/HorseShoeItem.java @@ -16,6 +16,7 @@ import net.minecraft.component.type.AttributeModifierSlot; import net.minecraft.component.type.AttributeModifiersComponent; import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.tooltip.TooltipType; @@ -92,6 +93,20 @@ public class HorseShoeItem extends HeavyProjectileItem { return projectile; } + @Override + public void initializeProjectile(ProjectileEntity entity, double x, double y, double z, float power, float uncertainty) { + float degradation = 0; + if (entity instanceof PhysicsBodyProjectileEntity p) { + ItemStack stack = p.getStack(); + degradation = (stack.getDamage() / (float)stack.getMaxDamage()); + } + + float speed = Math.max(0.2F, ((baseProjectileSpeed + 0.1F) / 1.5F) * (1 - (0.6F * degradation))); + float inaccuracy = projectileInnacuracy + degradation * 30; + entity.setVelocity(x, y, z, speed, inaccuracy); + } + + @Override public SoundEvent getThrowSound(ItemStack stack) { return USounds.Vanilla.ITEM_TRIDENT_THROW.value();