Added Sentry explosion delay
This commit is contained in:
parent
aa2853ecf4
commit
b960bd7051
|
@ -20,7 +20,7 @@ public class SentryRenderer extends RenderLiving<EntitySentry>
|
|||
public SentryRenderer(RenderManager renderManager)
|
||||
{
|
||||
super(renderManager, new ModelSlime(0), 0.3F);
|
||||
this.addLayer(new SentryLayer());
|
||||
this.addLayer(new SentryLayer((ModelSlime) this.getMainModel()));
|
||||
}
|
||||
|
||||
protected void preRenderCallback(EntitySentry entityliving, float f)
|
||||
|
@ -31,7 +31,7 @@ public class SentryRenderer extends RenderLiving<EntitySentry>
|
|||
|
||||
protected ResourceLocation getEntityTexture(EntitySentry entity)
|
||||
{
|
||||
return entity.getAttackTarget() == null ? TEXTURE : TEXTURE_LIT;
|
||||
return !entity.isAwake() ? TEXTURE : TEXTURE_LIT;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
package com.legacy.aether.client.renders.entities.layer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelSlime;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.legacy.aether.server.entities.hostile.EntitySentry;
|
||||
|
||||
public class SentryLayer implements LayerRenderer<EntitySentry>
|
||||
|
@ -14,30 +15,56 @@ public class SentryLayer implements LayerRenderer<EntitySentry>
|
|||
|
||||
private static final ResourceLocation TEXTURE_EYE = new ResourceLocation("aether_legacy", "textures/entities/sentry/eye.png");
|
||||
|
||||
@Override
|
||||
public void doRenderLayer(EntitySentry sentry, float p_177141_2_, float p_177141_3_, float p_177141_4_, float p_177141_5_, float p_177141_6_, float p_177141_7_, float p_177141_8_)
|
||||
{
|
||||
if (sentry.getAttackTarget() != null)
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderManager().renderEngine.bindTexture(TEXTURE_EYE);
|
||||
float f1 = 1.0F;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||
char j = 61680;
|
||||
int k = j % 65536;
|
||||
int l = j / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);
|
||||
}
|
||||
private final ModelSlime model;
|
||||
|
||||
public SentryLayer(ModelSlime model)
|
||||
{
|
||||
super();
|
||||
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRenderLayer(EntitySentry sentry, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
|
||||
{
|
||||
RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
|
||||
|
||||
if (sentry.isAwake())
|
||||
{
|
||||
renderManager.renderEngine.bindTexture(TEXTURE_EYE);
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
|
||||
|
||||
if (sentry.isInvisible())
|
||||
{
|
||||
GlStateManager.depthMask(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.depthMask(true);
|
||||
}
|
||||
|
||||
int i = 61680;
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.model.render(sentry, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
||||
i = sentry.getBrightnessForRender(partialTicks);
|
||||
j = i % 65536;
|
||||
k = i / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCombineTextures()
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.pathfinding.PathNavigateGround;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
|
@ -28,6 +31,10 @@ import com.legacy.aether.server.blocks.util.EnumStoneType;
|
|||
public class EntitySentry extends EntityLiving implements IMob
|
||||
{
|
||||
|
||||
public static final DataParameter<Boolean> SENTRY_AWAKE = EntityDataManager.<Boolean>createKey(EntitySentry.class, DataSerializers.BOOLEAN);
|
||||
|
||||
public float timeSpotted;
|
||||
|
||||
public float squishAmount;
|
||||
public float squishFactor;
|
||||
public float prevSquishFactor;
|
||||
|
@ -39,23 +46,18 @@ public class EntitySentry extends EntityLiving implements IMob
|
|||
|
||||
this.moveHelper = new EntitySentry.SlimeMoveHelper(this);
|
||||
|
||||
this.setSize(1);
|
||||
this.setSize(1.0F, 1.0F);
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10.0F);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3F);
|
||||
this.setHealth(this.getMaxHealth());
|
||||
}
|
||||
|
||||
public EntitySentry(World world, double x, double y, double z)
|
||||
{
|
||||
this(world);
|
||||
this.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
protected void setSize(int size)
|
||||
{
|
||||
this.setSize(size, size);
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(size);
|
||||
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue((double)(0.2F + 0.1F * (float)size));
|
||||
this.setHealth(this.getMaxHealth());
|
||||
this.experienceValue = size;
|
||||
this.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,6 +71,14 @@ public class EntitySentry extends EntityLiving implements IMob
|
|||
this.targetTasks.addTask(3, new EntityAIFindEntityNearest(this, EntityIronGolem.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit()
|
||||
{
|
||||
super.entityInit();
|
||||
|
||||
this.dataManager.register(SENTRY_AWAKE, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
|
@ -96,6 +106,25 @@ public class EntitySentry extends EntityLiving implements IMob
|
|||
this.isDead = true;
|
||||
}
|
||||
|
||||
EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, 8D);
|
||||
|
||||
if (entityplayer != null)
|
||||
{
|
||||
if (!this.isAwake())
|
||||
{
|
||||
if (this.timeSpotted >= 24)
|
||||
{
|
||||
this.setAwake(true);
|
||||
}
|
||||
|
||||
++this.timeSpotted;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setAwake(false);
|
||||
}
|
||||
|
||||
this.squishFactor += (this.squishAmount - this.squishFactor) * 0.5F;
|
||||
this.prevSquishFactor = this.squishFactor;
|
||||
super.onUpdate();
|
||||
|
@ -149,7 +178,7 @@ public class EntitySentry extends EntityLiving implements IMob
|
|||
|
||||
protected void explode(EntityLivingBase entity)
|
||||
{
|
||||
if (this.canEntityBeSeen(entity) && entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1.0F))
|
||||
if (this.isAwake() && this.canEntityBeSeen(entity) && entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1.0F))
|
||||
{
|
||||
entity.addVelocity(0.5D, 0.5D, 0.5D);
|
||||
|
||||
|
@ -161,6 +190,16 @@ public class EntitySentry extends EntityLiving implements IMob
|
|||
}
|
||||
}
|
||||
|
||||
public void setAwake(boolean isAwake)
|
||||
{
|
||||
this.dataManager.set(SENTRY_AWAKE, isAwake);
|
||||
}
|
||||
|
||||
public boolean isAwake()
|
||||
{
|
||||
return this.dataManager.get(SENTRY_AWAKE);
|
||||
}
|
||||
|
||||
public float getEyeHeight()
|
||||
{
|
||||
return 0.625F * this.height;
|
||||
|
@ -187,8 +226,11 @@ public class EntitySentry extends EntityLiving implements IMob
|
|||
@Override
|
||||
protected void jump()
|
||||
{
|
||||
this.motionY = 0.41999998688697815D;
|
||||
this.isAirBorne = true;
|
||||
if (this.isAwake())
|
||||
{
|
||||
this.motionY = 0.41999998688697815D;
|
||||
this.isAirBorne = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -219,6 +261,12 @@ public class EntitySentry extends EntityLiving implements IMob
|
|||
public boolean shouldExecute()
|
||||
{
|
||||
EntityLivingBase entitylivingbase = this.slime.getAttackTarget();
|
||||
|
||||
if (!this.slime.isAwake())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return entitylivingbase == null ? false : (!entitylivingbase.isEntityAlive() ? false : !(entitylivingbase instanceof EntityPlayer) || !((EntityPlayer)entitylivingbase).capabilities.disableDamage);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue