mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 08:18:00 +01:00
Fixed horseshoes shot from dispensers not using their correct speed for the item fired
This commit is contained in:
parent
653fc0bcf7
commit
1920233090
1 changed files with 15 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue