mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 05:47:59 +01:00
Changeling disguises are negated by the spell of revealing if you get within 15 blocks of it
This commit is contained in:
parent
78cfa7d515
commit
1b93928361
1 changed files with 44 additions and 6 deletions
|
@ -36,7 +36,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntitySkull;
|
import net.minecraft.tileentity.TileEntitySkull;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IPlayerHeightPredicate {
|
public class SpellDisguise extends AbstractSpell implements ISuppressable, IFlyingPredicate, IPlayerHeightPredicate {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private String entityId = "";
|
private String entityId = "";
|
||||||
|
@ -47,6 +47,8 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP
|
||||||
@Nullable
|
@Nullable
|
||||||
private NBTTagCompound entityNbt;
|
private NBTTagCompound entityNbt;
|
||||||
|
|
||||||
|
private int suppressionCounter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "disguise";
|
return "disguise";
|
||||||
|
@ -64,7 +66,22 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTint() {
|
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() {
|
public Entity getDisguise() {
|
||||||
|
@ -254,10 +271,26 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean update(ICaster<?> source) {
|
public boolean update(ICaster<?> source) {
|
||||||
checkAndCreateDisguiseEntity(source);
|
|
||||||
|
|
||||||
EntityLivingBase owner = source.getOwner();
|
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) {
|
if (owner == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -354,7 +387,10 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(ICaster<?> source) {
|
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);
|
source.spawnParticles(UParticles.CHANGELING_MAGIC, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,8 +399,8 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP
|
||||||
public void writeToNBT(NBTTagCompound compound) {
|
public void writeToNBT(NBTTagCompound compound) {
|
||||||
super.writeToNBT(compound);
|
super.writeToNBT(compound);
|
||||||
|
|
||||||
|
compound.setInteger("suppressionCounter", suppressionCounter);
|
||||||
compound.setString("entityId", entityId);
|
compound.setString("entityId", entityId);
|
||||||
compound.setBoolean("dead", getDead());
|
|
||||||
|
|
||||||
if (entityNbt != null) {
|
if (entityNbt != null) {
|
||||||
compound.setTag("entity", entityNbt);
|
compound.setTag("entity", entityNbt);
|
||||||
|
@ -377,6 +413,8 @@ public class SpellDisguise extends AbstractSpell implements IFlyingPredicate, IP
|
||||||
public void readFromNBT(NBTTagCompound compound) {
|
public void readFromNBT(NBTTagCompound compound) {
|
||||||
super.readFromNBT(compound);
|
super.readFromNBT(compound);
|
||||||
|
|
||||||
|
suppressionCounter = compound.getInteger("suppressionCounter");
|
||||||
|
|
||||||
String newId = compound.getString("entityId");
|
String newId = compound.getString("entityId");
|
||||||
|
|
||||||
if (!newId.contentEquals(entityId)) {
|
if (!newId.contentEquals(entityId)) {
|
||||||
|
|
Loading…
Reference in a new issue