Skip to content

Instantly share code, notes, and snippets.

@BlockAfterBlock
Created April 11, 2011 22:16
Show Gist options
  • Select an option

  • Save BlockAfterBlock/914491 to your computer and use it in GitHub Desktop.

Select an option

Save BlockAfterBlock/914491 to your computer and use it in GitHub Desktop.
package net.minecraft.src;
import java.util.List;
public class LMHBarbarian extends EntityMobs
{
public LMHBarbarian(World world)
{
super(world);
angerLevel = 0;
attackStrength = 7; //3.5 Hearts per hit
health = 30; //15 Hearts
texture = "/LMH/Barbarian.png";
//Note: Texture from wimpzilla
}
//Drops//////////////////////////
protected void dropFewItems()
{
int i = rand.nextInt(2);
for(int j = 0; j < i; j++)
{
dropItem(Item.porkCooked.shiftedIndex, 1);
}
i = rand.nextInt(3);
for(int k = 0; k < i; k++)
{
dropItem(Item.bone.shiftedIndex, 1);
}
i = rand.nextInt(2);
for (int r = 0; r < i; r++)
{
dropItem(mod_LotsMoreHumans.LMHBattleAxe.shiftedIndex, 1);
}
}
//Item Held////////////////////////
public ItemStack getHeldItem()
{
return defaultHeldItem;
}
private static final ItemStack defaultHeldItem;
static
{
defaultHeldItem = new ItemStack(mod_LotsMoreHumans.LMHBattleAxe, 1);
}
//Sound//////////////////////////
/*
protected String getLivingSound()
{
return "mob.skeleton";
}
protected String getHurtSound()
{
return "mob.skeletonhurt";
}
protected String getDeathSound()
{
return "mob.skeletonhurt";
}*/
//Spawning/////////////////////////
public boolean getCanSpawnHere()
{
/*
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
int spawnBlock = worldObj.getBlockId(i, j - 1, k);
*/
int rarity = 12;
if(rand.nextInt(rarity)== 0){
return worldObj.checkIfAABBIsClear(boundingBox) && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && !worldObj.getIsAnyLiquid(boundingBox);
// && (spawnBlock == Block.cobblestone.blockID || spawnBlock == Block.grass.blockID);
} else
return false;
}
public int getMaxSpawnedInChunk()
{
return 3;
}
//Anger/////////////////////////////
private void becomeAngryAt(Entity entity)
{
playerToAttack = entity;
angerLevel = 400 + rand.nextInt(400);
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
nbttagcompound.setShort("Anger", (short)angerLevel);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
angerLevel = nbttagcompound.getShort("Anger");
}
protected Entity findPlayerToAttack()
{
if(angerLevel == 0)
{
return null;
} else
{
return super.findPlayerToAttack();
}
}
public boolean attackEntityFrom(Entity entity, int i)
{
if(entity instanceof EntityPlayer)
{
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(32D, 32D, 32D));
for(int j = 0; j < list.size(); j++)
{
Entity entity1 = (Entity)list.get(j);
if(entity1 instanceof LMHBarbarian)
{
LMHBarbarian lmhbarbarian = (LMHBarbarian)entity1;
lmhbarbarian.becomeAngryAt(entity);
}
}
becomeAngryAt(entity);
}
return super.attackEntityFrom(entity, i);
}
private int angerLevel;
//Attacking/////////////////////////
/*protected Entity findPlayerToAttack()
{
EntityLiving entityliving = getClosestTarget(this, targetDistance);
if(entityliving != null && canEntityBeSeen(entityliving))
{
return entityliving;
} else
{
return null;
}
}*/
public EntityLiving getClosestTarget(Entity entity, double d)
{
double d1 = -1D;
EntityLiving entityliving = null;
for(int i = 0; i < worldObj.loadedEntityList.size(); i++)
{
Entity entity1 = (Entity)worldObj.loadedEntityList.get(i);
if(entity1 instanceof LMHIndian || entity1 instanceof LMHChiefIndian || (entity1 instanceof EntityAnimals) && !(entity1 instanceof EntityWolf)) //|| entity1 instanceof LMHFemaleIndian
// if(!(entity1 instanceof EntityLiving) || (entity1 instanceof EntityCreature) && !(entity1 instanceof h_samurai) || (entity1 instanceof EntityPlayer) || entity1 == entity || entity1 == this)
{
continue;
}
double d2 = entity1.getDistanceSq(entity.posX, entity.posY, entity.posZ);
if((d < 0.0D || d2 < d * d) && (d1 == -1D || d2 < d1) && ((EntityLiving)entity1).canEntityBeSeen(entity))
{
d1 = d2;
entityliving = (EntityLiving)entity1;
}
}
return entityliving;
}
protected void attackEntity(Entity entity, float f)
{
if(attackTime <= 0 && f < 2.0F && entity.boundingBox.maxY > boundingBox.minY && entity.boundingBox.minY < boundingBox.maxY)
{
attackTime = 20;
entity.attackEntityFrom(this, attackStrength);
}
}
//Follow////////////////////////////
/*public void onUpdate()
{
super.onUpdate();
for(int i = 0; i < worldObj.loadedEntityList.size(); i++)
{
Entity entity1 = (Entity)worldObj.loadedEntityList.get(i);
if(!(entity1 instanceof LMHFemaleBarbarian))
{
continue;
}
double d2 = entity1.getDistance(posX, posY, posZ);
LMHFemaleBarbarian lmhfemalebarbarian = (LMHFemaleBarbarian)entity1;
if((d2 < 16) && lmhfemalebarbarian.canEntityBeSeen(this) && lmhfemalebarbarian.playerToAttack == null)
{
lmhfemalebarbarian.playerToAttack = this;
}
}
}*/
public double targetDistance;
protected int attackStrength;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment