Skip to content

Instantly share code, notes, and snippets.

@BlockAfterBlock
Created May 18, 2011 00:26
Show Gist options
  • Select an option

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

Select an option

Save BlockAfterBlock/977764 to your computer and use it in GitHub Desktop.
package net.minecraft.src;
import java.util.List;
public class LMHEntityBase extends EntityMob
{
public LMHEntityBase(World world)
{
super(world);
attackStrength = 2; //1 Heart per Hit
health = 20; //10 Hearts
//MaxSpawned = 3;
}
//Item Held
public ItemStack getHeldItem(){return defaultHeldItem;}
//Sound
//protected String getHurtSound(){return "mob.skeletonhurt";}
//Spawning
public boolean getCanSpawnHere()
{
int rarity = 4;
if(rand.nextInt(rarity)== 0){
return worldObj.checkIfAABBIsClear(boundingBox) && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && !worldObj.getIsAnyLiquid(boundingBox);
} else
return false;
}
if(this instanceof LMHNative1 || this instanceof LMHNative2 || this instanceof LMHBarbarian || this instanceof LMHFemaleBarbarian || this instanceof LMHFemaleNative)
//if(MaxSpawned == 3)
{
public int getMaxSpawnedInChunk(){return 3;}
}
if(this instanceof LMHChiefNative || this instanceof LMHSandBandit || this instanceof LMHHunter)
{
public int getMaxSpawnedInChunk(){return 1;}
}
//Attacking
protected Entity findPlayerToAttack()
{
return null;
}
protected void attackEntity(Entity entity, float f)
{
if(this instanceof LMHNative1)
{
if(f < 10F)
{
double d = entity.posX - posX;
double d1 = entity.posZ - posZ;
if(attackTime == 0)
{
EntityArrow entityarrow = new EntityArrow(worldObj, this);
entityarrow.posY += 1.3999999761581421D;
double d2 = entity.posY - 0.20000000298023224D - entityarrow.posY;
float f1 = MathHelper.sqrt_double(d * d + d1 * d1) * 0.2F;
worldObj.playSoundAtEntity(this, "random.bow", 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 0.8F));
worldObj.entityJoinedWorld(entityarrow);
entityarrow.setArrowHeading(d, d2 + (double)f1, d1, 0.6F, 12F);
attackTime = 40;
}
rotationYaw = (float)((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F;
hasAttacked = true;
}
}
if(this instanceof LMHNative2)
{
if(f < 10F)
{
double d = entity.posX - posX;
double d1 = entity.posZ - posZ;
if(attackTime == 0)
{
LMHEntitySpear lmhentityspear = new LMHEntitySpear(worldObj, this);
lmhentityspear.posY += 1.3999999761581421D;
double d2 = entity.posY - 0.20000000298023224D - lmhentityspear.posY;
float f1 = MathHelper.sqrt_double(d * d + d1 * d1) * 0.2F;
worldObj.entityJoinedWorld(lmhentityspear);
lmhentityspear.setSpearHeading(d, d2 + (double)f1, d1, 0.6F, 12F);
attackTime = 90;
}
rotationYaw = (float)((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F;
hasAttacked = true;
}
}
}
public int ticktimer = 1200;
public boolean mobTrigger = true;
public void noSelfHarm()
{
if (playerToAttack == this)
{
playerToAttack = null;
}
}
//Arm Swing
/*public void onLivingUpdate()
{
super.onLivingUpdate();
if (swingArm) {
swingTick++;
if (swingTick == 8) {
swingTick = 0;
swingArm = false;
}
} else
{
swingTick = 0;
}
swingProgress = (float) swingTick / 8F;
}
public boolean swingArm = false;
public int swingTick = 0;*/
//Make Mobs Target This
public void makeMobsTargetThis()
{
if(this instanceof LMHNative1)
{
List targets = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(32, 32, 32));
for (int j = 0; j < targets.size(); j++)
{
Entity ent = (Entity) targets.get(j);
if (ent instanceof LMHBarbarian && canEntityBeSeen(ent))
{
LMHBarbarian lmhbarbarian = (LMHBarbarian)ent;
lmhbarbarian.playerToAttack = this;
} else if (ent instanceof LMHFemaleBarbarian && canEntityBeSeen(ent))
{
LMHFemaleBarbarian lmhfemalebarbarian = (LMHFemaleBarbarian)ent;
lmhfemalebarbarian.playerToAttack = this;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment