mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Added hydrophobic projectiles
This commit is contained in:
parent
5f93eb6ac6
commit
9426fedd22
2 changed files with 23 additions and 0 deletions
|
@ -31,6 +31,9 @@ public class EntityProjectile extends EntitySnowball implements IMagicals, ICast
|
||||||
private static final DataParameter<Float> DAMAGE = EntityDataManager
|
private static final DataParameter<Float> DAMAGE = EntityDataManager
|
||||||
.createKey(EntityProjectile.class, DataSerializers.FLOAT);
|
.createKey(EntityProjectile.class, DataSerializers.FLOAT);
|
||||||
|
|
||||||
|
private static final DataParameter<Boolean> HYDROPHOBIC = EntityDataManager
|
||||||
|
.createKey(EntityProjectile.class, DataSerializers.BOOLEAN);
|
||||||
|
|
||||||
private static final DataParameter<NBTTagCompound> EFFECT = EntityDataManager
|
private static final DataParameter<NBTTagCompound> EFFECT = EntityDataManager
|
||||||
.createKey(EntitySpell.class, DataSerializers.COMPOUND_TAG);
|
.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(ITEM, ItemStack.EMPTY);
|
||||||
getDataManager().register(DAMAGE, (float)0);
|
getDataManager().register(DAMAGE, (float)0);
|
||||||
getDataManager().register(EFFECT, new NBTTagCompound());
|
getDataManager().register(EFFECT, new NBTTagCompound());
|
||||||
|
getDataManager().register(HYDROPHOBIC, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
|
@ -118,6 +122,14 @@ public class EntityProjectile extends EntitySnowball implements IMagicals, ICast
|
||||||
return getDataManager().get(DAMAGE);
|
return getDataManager().get(DAMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHydrophobic() {
|
||||||
|
getDataManager().set(HYDROPHOBIC, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getHydrophobic() {
|
||||||
|
return getDataManager().get(HYDROPHOBIC);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readEntityFromNBT(NBTTagCompound compound) {
|
public void readEntityFromNBT(NBTTagCompound compound) {
|
||||||
super.readEntityFromNBT(compound);
|
super.readEntityFromNBT(compound);
|
||||||
|
@ -150,6 +162,16 @@ public class EntityProjectile extends EntitySnowball implements IMagicals, ICast
|
||||||
getEffect().render(this);
|
getEffect().render(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getHydrophobic()) {
|
||||||
|
if (world.getBlockState(getPosition()).getMaterial().isLiquid()) {
|
||||||
|
motionY *= -1;
|
||||||
|
|
||||||
|
if (!hasNoGravity()) {
|
||||||
|
motionY += 0.16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,6 +28,7 @@ public interface ITossedEffect extends IMagicEffect, ITossable<ICaster<?>> {
|
||||||
projectile.setThrowDamage(getThrowDamage(caster));
|
projectile.setThrowDamage(getThrowDamage(caster));
|
||||||
projectile.setOwner(caster.getOwner());
|
projectile.setOwner(caster.getOwner());
|
||||||
projectile.setEffect(this);
|
projectile.setEffect(this);
|
||||||
|
projectile.setHydrophobic();
|
||||||
projectile.shoot(entity, entity.rotationPitch, entity.rotationYaw, 0, 1.5F, 1);
|
projectile.shoot(entity, entity.rotationPitch, entity.rotationYaw, 0, 1.5F, 1);
|
||||||
|
|
||||||
world.spawnEntity(projectile);
|
world.spawnEntity(projectile);
|
||||||
|
|
Loading…
Reference in a new issue