diff --git a/src/main/java/com/minelittlepony/unicopia/entity/EntityProjectile.java b/src/main/java/com/minelittlepony/unicopia/entity/EntityProjectile.java index 5c9b6d5c..f48f7ec7 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/EntityProjectile.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/EntityProjectile.java @@ -31,6 +31,9 @@ public class EntityProjectile extends EntitySnowball implements IMagicals, ICast private static final DataParameter DAMAGE = EntityDataManager .createKey(EntityProjectile.class, DataSerializers.FLOAT); + private static final DataParameter HYDROPHOBIC = EntityDataManager + .createKey(EntityProjectile.class, DataSerializers.BOOLEAN); + private static final DataParameter EFFECT = EntityDataManager .createKey(EntitySpell.class, DataSerializers.COMPOUND_TAG); @@ -53,6 +56,7 @@ public class EntityProjectile extends EntitySnowball implements IMagicals, ICast getDataManager().register(ITEM, ItemStack.EMPTY); getDataManager().register(DAMAGE, (float)0); getDataManager().register(EFFECT, new NBTTagCompound()); + getDataManager().register(HYDROPHOBIC, false); } public ItemStack getItem() { @@ -118,6 +122,14 @@ public class EntityProjectile extends EntitySnowball implements IMagicals, ICast return getDataManager().get(DAMAGE); } + public void setHydrophobic() { + getDataManager().set(HYDROPHOBIC, true); + } + + public boolean getHydrophobic() { + return getDataManager().get(HYDROPHOBIC); + } + @Override public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); @@ -150,6 +162,16 @@ public class EntityProjectile extends EntitySnowball implements IMagicals, ICast getEffect().render(this); } } + + if (getHydrophobic()) { + if (world.getBlockState(getPosition()).getMaterial().isLiquid()) { + motionY *= -1; + + if (!hasNoGravity()) { + motionY += 0.16; + } + } + } } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/spell/ITossedEffect.java b/src/main/java/com/minelittlepony/unicopia/spell/ITossedEffect.java index 9a9100ef..6e5ad0da 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/ITossedEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/ITossedEffect.java @@ -28,6 +28,7 @@ public interface ITossedEffect extends IMagicEffect, ITossable> { projectile.setThrowDamage(getThrowDamage(caster)); projectile.setOwner(caster.getOwner()); projectile.setEffect(this); + projectile.setHydrophobic(); projectile.shoot(entity, entity.rotationPitch, entity.rotationYaw, 0, 1.5F, 1); world.spawnEntity(projectile);