diff --git a/src/main/java/com/minelittlepony/unicopia/item/ProjectileItem.java b/src/main/java/com/minelittlepony/unicopia/item/ProjectileItem.java index dad86673..767d098c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ProjectileItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ProjectileItem.java @@ -45,7 +45,7 @@ abstract class ProjectileItem extends Item { player.incrementStat(Stats.USED.getOrCreateStat(this)); - if (!player.getAbilities().creativeMode) { + if (!player.isCreative()) { stack.decrement(1); } @@ -56,6 +56,7 @@ abstract class ProjectileItem extends Item { MagicProjectileEntity projectile = player == null ? new MagicProjectileEntity(world) : new MagicProjectileEntity(world, player); projectile.setItem(stack); projectile.setThrowDamage(getProjectileDamage(stack)); + projectile.setMaxAge(-1); if (player != null) { projectile.setVelocity(player, player.getPitch(), player.getYaw(), 0, 1.5F, 1); } diff --git a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java index cff6faf8..09fbff79 100644 --- a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java @@ -39,6 +39,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; import net.minecraft.network.packet.Packet; import net.minecraft.network.listener.ClientPlayPacketListener; import net.minecraft.particle.ItemStackParticleEffect; @@ -71,6 +72,8 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster homingTarget = new EntityReference<>(); private EntityReference owner; + private int maxAge = 90; + public MagicProjectileEntity(EntityType type, World world) { super(type, world); } @@ -125,7 +128,6 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster getMasterReference() { if (owner == null) { @@ -188,12 +190,14 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster 90) { - discard(); - } + if (maxAge > 0 && !getWorld().isClient() && homingTarget.getOrEmpty(asWorld()).isEmpty() && (getVelocity().length() < 0.1 || age > maxAge)) { + discard(); } super.tick(); @@ -263,6 +267,9 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster { compound.put("effect", Spell.writeNbt(effect)); });