Jump to content

[1.8] tiny hitbar


knokko

Recommended Posts

I am having a problem with my dragon.

It is a very large model with a lenght of 30 blocks, but it has the hitbar of a "tiny" player.

And the attack reach of the dragon is as large as it's body, so the player can't hit it before the dragon hits the player.

Is there a way to give it a larger hitbar?

Link to comment
Share on other sites

Here is the superclass:

public abstract class Dragon extends EntityFlying implements IMob{

protected EntityLivingBase target;

public Dragon(World worldIn) {
	super(worldIn);
	setSize(30, 3);
	isImmuneToFire = true;
}

public void onUpdate(){
	super.onUpdate();
	if(target == null){
		target = worldObj.getClosestPlayerToEntity(this, getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue());
	}
	if(target != null){
		followTarget();
		shootingUpdate();
		faceEntity(target, 30, 30);
	}
	attackEntities();
}

public abstract void shootingUpdate();

public void attackEntities(){
	AxisAlignedBB aabb = getEntityBoundingBox();
	List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, aabb);
	int times = 0;
	while(times < list.size()){
		Entity entity = (Entity) list.get(times);
		if(!(entity instanceof EntityItem)){
			entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float) getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue());
		}
		++times;
	}
}

public void followTarget(){
	Line line = new Line(new Position(this), new Position(target));
	double speed = getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
	motionX = ExtraUtils.divineAccurate(line.distanceXT, line.distance) * speed;
	motionY = ExtraUtils.divineAccurate(line.distanceYT, line.distance) * speed;
	motionZ = ExtraUtils.divineAccurate(line.distanceZT, line.distance) * speed;
}

public void setAttackTarget(EntityLivingBase entity){
	target = entity;
}

public void setRevengeTarget(EntityLivingBase entity){
	target = entity;
}

public EntityLivingBase getAttackTarget(){
	return target;
}

public EntityLivingBase getAITarget(){
	return target;
}

public void applyEntityAttributes(){
	super.applyEntityAttributes();
	getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
}

public AxisAlignedBB getCollisionBox(Entity in){
	return getEntityBoundingBox();
}

public AxisAlignedBB getBoundingBox(){
	return getEntityBoundingBox();
}
}

 

Here is the 'real' class:

public class FireDragon extends Dragon{

public int cooldown;
public int fireTimer;
public boolean shootCooldown;

public FireDragon(World worldIn) {
	super(worldIn);
	setSize(30,3);
}

@Override
public void shootingUpdate() {
	if(!worldObj.isRemote){
		if(cooldown <= 0){
			if(fireTimer < 5 && shootCooldown){
				EntityLargeFireball fire = new EntityLargeFireball(worldObj, this, 1, 1, 1);
				fire.explosionPower = 2;
				worldObj.spawnEntityInWorld(fire);
				++fireTimer;
				shootCooldown = false;
			}
			else if(fireTimer >= 5){
				cooldown = 100;
				fireTimer = 0;
			}
			else {
				shootCooldown = true;
			}
		}
		else {
			--cooldown;
		}
	}
}

@Override
public void applyEntityAttributes(){
	super.applyEntityAttributes();
	getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10);
	getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3);
	getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(64);
	getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(400);
}

}

 

Any ideas what can go wrong?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.