2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
4.8 KiB
Java

package com.zivilon.cinder_loe.entity;
import com.zivilon.cinder_loe.CinderLoE;
import com.zivilon.cinder_loe.util.Utilities;
import com.zivilon.cinder_loe.entity.Nex;
import com.zivilon.cinder_loe.entity.ai.LoEPreciseAttackOnCollide;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import lotr.common.entity.npc.LOTREntityMan;
import lotr.common.fac.LOTRFaction;
import java.util.List;
public abstract class NexMiniboss extends LOTREntityMan {
public String entity_name = "UNDEFINED";
public boolean bound = true;
public NexMiniboss(World world) {
super(world);
setSize(0.6F, 1.8F);
((EntityLiving) this).tasks.addTask(2, (EntityAIBase) new LoEPreciseAttackOnCollide(this, 1.3D, 1.0D, 40, false));
((EntityLiving) this).tasks.addTask(8, (EntityAIBase) new EntityAIWatchClosest((EntityLiving) this, Nex.class, 8.0F, 0.02F));
addTargetTasks(true);
setupEquipment();
}
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200.0D);
getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.225D);
getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0D);
getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(100.0D);
}
@Override
public LOTRFaction getFaction() {
return LOTRFaction.UTUMNO;
}
@Override
protected boolean canDespawn() {
return false;
}
@Override
public String getNPCName() {
return entity_name;
}
@Override
public String getNPCFormattedName(String npcName, String entityName) {
return entity_name;
}
@Override
protected void dropFewItems(boolean flag, int i) {
}
@Override
public boolean getCanSpawnHere() {
return false;
}
@Override
public String getSpeechBank(EntityPlayer entityplayer) {
return "nex/undefined";
}
@Override
public void setupNPCName() {
}
@Override
public ItemStack getPickedResult(MovingObjectPosition target) {
return null;
}
@Override
public void onDeath(DamageSource source) {
List<Nex> entityList = this.worldObj.getEntitiesWithinAABB(Nex.class, this.boundingBox.expand(100, 10, 100));
for (Nex nex : entityList) {
nex.next_phase();
return;
}
}
public void unbind() {
System.out.println("Unbinding " + this.getClass().getSimpleName());
int x = MathHelper.floor_double(this.posX);
int y = MathHelper.floor_double(this.posY);
int z = MathHelper.floor_double(this.posZ);
Block blockAtFeet = this.worldObj.getBlock(x, y, z);
Block blockAtHead = this.worldObj.getBlock(x, y + 1, z);
if (blockAtFeet == CinderLoE.iceCage) {
this.worldObj.setBlock(x, y, z, Blocks.air);
}
if (blockAtHead == CinderLoE.iceCage) {
this.worldObj.setBlock(x, y, z, Blocks.air);
}
bound = false;
}
@Override
public void onUpdate() {
super.onUpdate();
checkInsideIceCage();
}
public void checkInsideIceCage() {
int x = MathHelper.floor_double(this.posX);
int y = MathHelper.floor_double(this.posY);
int z = MathHelper.floor_double(this.posZ);
Block blockAtFeet = this.worldObj.getBlock(x, y, z);
Block blockAtHead = this.worldObj.getBlock(x, y + 1, z);
if (blockAtFeet == CinderLoE.iceCage || blockAtHead == CinderLoE.iceCage) {
onBoundUpdate(x, y, z);
Utilities.setInvulnerable((Entity)this, true);
// System.out.println("Nex Miniboss vulnerable: " + this.isEntityInvulnerable());
} else {
onUnboundUpdate();
Utilities.setInvulnerable((Entity)this, false);
// System.out.println("Nex Miniboss vulnerable: " + this.isEntityInvulnerable());
}
}
public abstract void onBoundUpdate(int x, int y, int z);
public abstract void onUnboundUpdate();
public abstract void setupEquipment();
}