From 1b93928361dbb574ea4bb17358f99ae8e10936ef Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 13 Feb 2019 22:47:44 +0200 Subject: [PATCH] Changeling disguises are negated by the spell of revealing if you get within 15 blocks of it --- .../unicopia/spell/SpellDisguise.java | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellDisguise.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellDisguise.java index e5b0a0e4..610a84c8 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellDisguise.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellDisguise.java @@ -36,7 +36,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.math.MathHelper; -public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IPlayerHeightPredicate { +public class SpellDisguise extends AbstractSpell implements ISuppressable, IFlyingPredicate, IPlayerHeightPredicate { @Nonnull private String entityId = ""; @@ -47,6 +47,8 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP @Nullable private NBTTagCompound entityNbt; + private int suppressionCounter; + @Override public String getName() { return "disguise"; @@ -64,7 +66,22 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP @Override public int getTint() { - return 0; + return 0x19E48E; + } + + @Override + public boolean isVulnerable(ICaster otherSource, IMagicEffect other) { + return suppressionCounter <= otherSource.getCurrentLevel(); + } + + @Override + public void onSuppressed(ICaster otherSource) { + suppressionCounter = 100; + } + + @Override + public boolean getSuppressed() { + return suppressionCounter > 0; } public Entity getDisguise() { @@ -254,10 +271,26 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP @SuppressWarnings("unchecked") @Override public boolean update(ICaster source) { - checkAndCreateDisguiseEntity(source); - EntityLivingBase owner = source.getOwner(); + if (getSuppressed()) { + suppressionCounter--; + + owner.setInvisible(false); + if (source instanceof IPlayer) { + ((IPlayer)source).setInvisible(false); + } + + if (entity != null) { + entity.setInvisible(true); + entity.posY = Integer.MIN_VALUE; + } + + return true; + } + + checkAndCreateDisguiseEntity(source); + if (owner == null) { return true; } @@ -354,7 +387,10 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP @Override public void render(ICaster source) { - if (source.getWorld().rand.nextInt(30) == 0) { + if (getSuppressed()) { + source.spawnParticles(UParticles.UNICORN_MAGIC, 5); + source.spawnParticles(UParticles.CHANGELING_MAGIC, 5); + } else if (source.getWorld().rand.nextInt(30) == 0) { source.spawnParticles(UParticles.CHANGELING_MAGIC, 2); } } @@ -363,8 +399,8 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); + compound.setInteger("suppressionCounter", suppressionCounter); compound.setString("entityId", entityId); - compound.setBoolean("dead", getDead()); if (entityNbt != null) { compound.setTag("entity", entityNbt); @@ -377,6 +413,8 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); + suppressionCounter = compound.getInteger("suppressionCounter"); + String newId = compound.getString("entityId"); if (!newId.contentEquals(entityId)) {