Permalink
Browse files

Predators can now superjump and duck in caves. Also now taller.

  • Loading branch information...
Ri5ux committed Dec 19, 2018
1 parent 8ecf067 commit cf3735a3c1674365ca8bed843afffeb2840fde5c
@@ -612,6 +612,17 @@ public void render(Object obj)
float swingProgressPrev = swingProgressPrev(obj);
float mandibleProgress = (idleProgress(obj) + (swingProgress(obj) * 75F)) * 2F;

if (base instanceof EntitySpeciesYautja)
{
EntitySpeciesYautja y = (EntitySpeciesYautja) base;

if (Math.abs(base.motionY) > 0.1F)
{
swingProgress = 0F;
swingProgressPrev = 0F;
}
}

this.lMandibleUpper.rotateAngleY = (float) ((float) Math.sin(Math.toRadians(mandibleProgress)) * 0.075F - Math.toRadians(15F));
this.lMandibleUpper.rotateAngleZ = (float) ((float) Math.sin(Math.toRadians(mandibleProgress)) * 0.075F + Math.toRadians(5F));
this.lMandibleLower1.rotateAngleY = (float) Math.sin(Math.toRadians(mandibleProgress)) * 0.075F;
@@ -627,22 +638,24 @@ public void render(Object obj)
this.lThigh.rotateAngleX = MathHelper.sin(swingProgress * 1F + (float) Math.PI) * 0.75F * swingProgressPrev - 0.2F;
this.rArmUpper.rotateAngleX = MathHelper.cos(swingProgress * 0.75F) * 0.6F * swingProgressPrev;
this.lArmUpper.rotateAngleX = MathHelper.sin(swingProgress * 0.75F) * 0.6F * swingProgressPrev;

this.rShin.rotateAngleX = this.rThigh.rotateAngleX * 0.75F + 0.35F;
this.lShin.rotateAngleX = this.lThigh.rotateAngleX * 0.75F + 0.35F;
this.lArmLower.rotateAngleX = this.rThigh.rotateAngleX * 1.75F;
this.rArmLower.rotateAngleX = this.lThigh.rotateAngleX * 1.75F;

if (base instanceof EntitySpeciesYautja)
{
EntitySpeciesYautja yautja = (EntitySpeciesYautja) base;
EntitySpeciesYautja y = (EntitySpeciesYautja) base;

this.biomaskMouth.isHidden = false;
this.lMandibleLower1.isHidden = true;
this.rMandibleLower1.isHidden = true;
this.lMandibleUpper.isHidden = true;
this.rMandibleUpper.isHidden = true;
this.nose.isHidden = true;

if (!yautja.isWearingMask())
if (!y.isWearingMask())
{
this.biomaskMouth.isHidden = true;
this.lMandibleLower1.isHidden = false;
@@ -651,6 +664,12 @@ public void render(Object obj)
this.rMandibleUpper.isHidden = false;
this.nose.isHidden = false;
}

if (Math.abs(base.motionY) > 0.1F)
{
this.rArmUpper.rotateAngleX = -2.5F;
this.lArmUpper.rotateAngleX = -2F;
}
}

OpenGL.pushMatrix();
@@ -0,0 +1,86 @@
package org.avp.entities.ai;

import java.util.Random;

import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.math.MathHelper;

public class EntityAISuperjump extends EntityAIBase
{
private Random random;
/** The entity that is leaping. */
EntityLiving leaper;
/** The entity that the leaper is leaping towards. */
EntityLivingBase leapTarget;
/** The entity's motionY after leaping. */
float leapMotionY;

public EntityAISuperjump(EntityLiving leapingEntity, float leapMotionYIn)
{
this.leaper = leapingEntity;
this.leapMotionY = leapMotionYIn;
this.setMutexBits(5);
this.random = new Random();
}

/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
this.leapTarget = this.leaper.getAttackTarget();

if (this.leapTarget == null)
{
return false;
}
else
{
double distance = this.leaper.getDistanceSq(this.leapTarget);

if (distance >= 30.0D && distance <= 500.0D)
{
if (!this.leaper.onGround)
{
return false;
}
else
{
return this.leaper.getRNG().nextInt(5) == 0;
}
}
else
{
return false;
}
}
}

/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean shouldContinueExecuting()
{
return !this.leaper.onGround;
}

/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
double distX = this.leapTarget.posX - this.leaper.posX;
double distZ = this.leapTarget.posZ - this.leaper.posZ;
float distance = MathHelper.sqrt(distX * distX + distZ * distZ);

if ((double)distance >= 1.0E-4D)
{
this.leaper.motionX += distX / (double)distance + this.leaper.motionX;
this.leaper.motionZ += distZ / (double)distance + this.leaper.motionZ;
}

this.leaper.motionY = (double)this.leapMotionY + (0.3F / (1 + random.nextInt(2)));
}
}
@@ -5,6 +5,7 @@
import org.avp.api.parasitoidic.IHost;
import org.avp.client.Sounds;
import org.avp.entities.ai.EntityAICustomAttackOnCollide;
import org.avp.entities.ai.EntityAISuperjump;
import org.avp.item.ItemDisc;
import org.avp.item.ItemFirearm;
import org.avp.item.ItemPlasmaCannon;
@@ -13,18 +14,22 @@

import com.google.common.base.Predicate;

import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILeapAtTarget;
import net.minecraft.entity.ai.EntityAIMoveTowardsTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.MobEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
@@ -36,25 +41,30 @@
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.DamageSource;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;

public abstract class EntitySpeciesYautja extends EntityMob implements IHost, Predicate<EntityLivingBase>
{
private static final DataParameter<Boolean> WEARING_MASK = EntityDataManager.createKey(EntitySpeciesYautja.class, DataSerializers.BOOLEAN);
private static final DataParameter<Boolean> DUCKING = EntityDataManager.createKey(EntitySpeciesYautja.class, DataSerializers.BOOLEAN);

public EntitySpeciesYautja(World world)
{
super(world);
this.experienceValue = 250;
this.setSize(1.0F, 2.5F);

this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAICustomAttackOnCollide(this, EntityLivingBase.class, 1D, true));
this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityMob.class, 16F));
this.tasks.addTask(2, new EntityAIWander(this, 0.8D));
this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.6F));
this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<EntityLivingBase>(this, EntityLivingBase.class, 0, false, false, this));
// this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(0, new EntityAICustomAttackOnCollide(this, EntityLivingBase.class, 0.9D, true));
this.tasks.addTask(1, new EntityAIWander(this, 0.6D));
this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityLivingBase.class, 16F));
this.targetTasks.addTask(0, new EntityAISuperjump(this, 1.0F));
this.targetTasks.addTask(1, new EntityAIMoveTowardsTarget(this, 0.9D, 48));
this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityLivingBase>(this, EntityLivingBase.class, 0, false, false, this));
this.jumpMovementFactor = 0.1F;
}

@Override
@@ -65,19 +75,68 @@ protected void applyEntityAttributes()
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.6D);
this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6.0D);
this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.75D);
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(48D);
}

@Override
protected void entityInit()
{
super.entityInit();
this.getDataManager().register(WEARING_MASK, this.rand.nextBoolean());
this.getDataManager().register(DUCKING, false);
}

@Override
public void onUpdate()
{
super.onUpdate();

if (this.world.getWorldTime() % 10 == 0)
{
BlockPos aboveHead = this.getPosition().add(0, 3, 0);
this.setDucking(this.world.getBlockState(aboveHead).getBlock() != Blocks.AIR);
System.out.println(this.isDucking());

if (this.isDucking())
{
this.setSize(1.0F, 1.75F);
}
else
{
this.setSize(1.0F, 2.5F);
}
}
}

@Override
public int getMaxFallHeight()
{
return 20;
}

@Override
public void fall(float distance, float damageMultiplier)
{
int intensity = MathHelper.ceil((distance - 3.0F) * damageMultiplier);

if (intensity > 0)
{
this.playSound(this.getFallSound(intensity), 1.0F, 1.0F);

if (this.world.getWorldTime() % 4 == 0)
this.playSound(this.getDeathSound(), 1.0F, 1.0F);

int x = MathHelper.floor(this.posX);
int y = MathHelper.floor(this.posY - 0.20000000298023224D);
int z = MathHelper.floor(this.posZ);
IBlockState state = this.world.getBlockState(new BlockPos(x, y, z));

if (state.getMaterial() != Material.AIR)
{
SoundType soundtype = state.getBlock().getSoundType(state, world, new BlockPos(x, y, z), this);
this.playSound(soundtype.getFallSound(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
}
}
}

@Override
@@ -224,6 +283,11 @@ public boolean isWearingMask()
return this.getDataManager().get(WEARING_MASK);
}

public boolean isDucking()
{
return this.getDataManager().get(DUCKING);
}

public void setWearingMask(boolean wearingMask)
{
if (!this.world.isRemote)
@@ -232,6 +296,14 @@ public void setWearingMask(boolean wearingMask)
}
}

public void setDucking(boolean ducking)
{
if (!this.world.isRemote)
{
this.getDataManager().set(DUCKING, ducking);
}
}

@Override
public boolean canParasiteAttach()
{
@@ -23,6 +23,7 @@ protected void applyEntityAttributes()
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5199999761581421D);
this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(10.0D);
this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(10.0D);
this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(48D);
}

@Override

0 comments on commit cf3735a

Please sign in to comment.