Skip to content

Commit

Permalink
Add buildup period of 3 seconds for Vengeance Spirits spawned by kill…
Browse files Browse the repository at this point in the history
…ing.

In this period they can not attack or move.
  • Loading branch information
rubensworks committed Mar 26, 2015
1 parent 7d93afe commit 8909776
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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);
Expand Down
29 changes: 27 additions & 2 deletions src/main/java/evilcraft/entity/monster/VengeanceSpirit.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -232,7 +238,7 @@ public void setDead() {

@Override
public boolean isMovementBlocked() {
return isFrozen();
return isFrozen() || getBuildupDuration() > 0;
}

@Override
Expand Down Expand Up @@ -264,7 +270,10 @@ public void onLivingUpdate() {
}
}
}


int buildupDuration = getBuildupDuration();
if(buildupDuration > 0) setBuildupDuration(buildupDuration - 1);

if(isFrozen()) {
this.motionX = 0;
this.motionY = 0;
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/evilcraft/event/LivingDeathEventHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 8909776

Please sign in to comment.