diff --git a/src/main/java/evilcraft/client/render/entity/RenderVengeanceSpirit.java b/src/main/java/evilcraft/client/render/entity/RenderVengeanceSpirit.java index 52ff4f6846..79d56679bc 100644 --- a/src/main/java/evilcraft/client/render/entity/RenderVengeanceSpirit.java +++ b/src/main/java/evilcraft/client/render/entity/RenderVengeanceSpirit.java @@ -1,17 +1,15 @@ package evilcraft.client.render.entity; +import evilcraft.core.config.extendedconfig.ExtendedConfig; +import evilcraft.core.config.extendedconfig.MobConfig; +import evilcraft.entity.monster.VengeanceSpirit; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import evilcraft.core.config.extendedconfig.ExtendedConfig; -import evilcraft.core.config.extendedconfig.MobConfig; -import evilcraft.entity.monster.VengeanceSpirit; - /** * Renderer for a vengeance spirit * @@ -41,6 +39,8 @@ public void doRender(Entity entity, double x, double y, double z, float yaw, flo } else { GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR); } + float c = Math.min(1F - (float) (spirit.getBuildupDuration()) / 30, 0.65F); + GL11.glColor3f(c, c, c); //GL14.glBlendColor(0, 0, 0, 0); //GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_CONSTANT_COLOR); //GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_DST_COLOR); diff --git a/src/main/java/evilcraft/entity/monster/VengeanceSpirit.java b/src/main/java/evilcraft/entity/monster/VengeanceSpirit.java index d81d333ff7..a4e5f1ba7e 100644 --- a/src/main/java/evilcraft/entity/monster/VengeanceSpirit.java +++ b/src/main/java/evilcraft/entity/monster/VengeanceSpirit.java @@ -77,6 +77,7 @@ public class VengeanceSpirit extends EntityMob implements IConfigurable { private static final int WATCHERID_VENGEANCEPLAYERS = 24; private static final int WATCHERID_ISSWARM = 25; private static final int WATCHERID_SWARMTIER = 26; + private static final int WATCHERID_BUILDUP = 27; /** * The NBT key used to store the inner entity name. @@ -147,6 +148,7 @@ public void entityInit() { this.dataWatcher.addObject(WATCHERID_VENGEANCEPLAYERS, new String()); this.dataWatcher.addObject(WATCHERID_ISSWARM, 0); this.dataWatcher.addObject(WATCHERID_SWARMTIER, rand.nextInt(SWARM_TIERS)); + this.dataWatcher.addObject(WATCHERID_BUILDUP, 0); } @Override @@ -158,6 +160,7 @@ public void writeEntityToNBT(NBTTagCompound tag) { tag.setInteger("frozenDuration", getFrozenDuration()); tag.setBoolean("isSwarm", isSwarm()); tag.setInteger("swarmTier", getSwarmTier()); + tag.setInteger("buildupDuration", getBuildupDuration()); } @Override @@ -170,6 +173,7 @@ public void readEntityFromNBT(NBTTagCompound tag) { setFrozenDuration(tag.getInteger("frozenDuration")); setIsSwarm(tag.getBoolean("isSwarm")); setSwarmTier(tag.getInteger("swarmTier")); + setBuildupDuration(tag.getInteger("buildupDuration")); } @Override @@ -198,6 +202,8 @@ public boolean isEntityInvulnerable() { @Override public boolean attackEntityAsMob(Entity entity) { + if(getBuildupDuration() > 0) return false; // Don't attack anything when still building up. + this.setDead(); this.worldObj.removeEntity(this); if(entity instanceof EntityPlayer) { @@ -232,7 +238,7 @@ public void setDead() { @Override public boolean isMovementBlocked() { - return isFrozen(); + return isFrozen() || getBuildupDuration() > 0; } @Override @@ -264,7 +270,10 @@ public void onLivingUpdate() { } } } - + + int buildupDuration = getBuildupDuration(); + if(buildupDuration > 0) setBuildupDuration(buildupDuration - 1); + if(isFrozen()) { this.motionX = 0; this.motionY = 0; @@ -453,6 +462,22 @@ public void setRemainingLife(int remainingLife) { this.dataWatcher.updateObject(WATCHERID_REMAININGLIFE, remainingLife); } + /** + * Get the remaining life. + * @return The remaining life. + */ + public int getBuildupDuration() { + return dataWatcher.getWatchableObjectInt(WATCHERID_BUILDUP); + } + + /** + * Set the remaining buildup time. + * @param buildupDuration The remaining life. + */ + public void setBuildupDuration(int buildupDuration) { + this.dataWatcher.updateObject(WATCHERID_BUILDUP, buildupDuration); + } + /** * Get the frozen duration. * @return The frozen duration. diff --git a/src/main/java/evilcraft/event/LivingDeathEventHook.java b/src/main/java/evilcraft/event/LivingDeathEventHook.java index b4e704d458..6a3413018e 100644 --- a/src/main/java/evilcraft/event/LivingDeathEventHook.java +++ b/src/main/java/evilcraft/event/LivingDeathEventHook.java @@ -11,6 +11,7 @@ import evilcraft.client.particle.EntityBloodSplashFX; import evilcraft.core.PlayerExtendedInventoryIterator; import evilcraft.core.algorithm.Location; +import evilcraft.core.helper.MinecraftHelpers; import evilcraft.core.world.FakeWorld; import evilcraft.entity.monster.VengeanceSpirit; import evilcraft.entity.monster.VengeanceSpiritConfig; @@ -111,6 +112,7 @@ private void vengeanceEvent(LivingDeathEvent event) { world.spawnEntityInWorld(spirit); if(directToPlayer) { EntityPlayer player = (EntityPlayer) event.source.getSourceOfDamage(); + spirit.setBuildupDuration(3 * MinecraftHelpers.SECOND_IN_TICKS); spirit.setGlobalVengeance(true); spirit.setTarget(player); }