Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

  • Author

I allready have that, "setSize(30,3)".

The hitbar is still very small.

But the hitbar isn't large enough.

  • Author

I have looked in EntityZombie and EntityDragon (of minecraft) and there block size is used.

Can it be a problem with max lenght or something?

 

  • Author

I have tested it's hitbar with arrows.

The hitbar for arrows is different than the hitbar for normal attacks.

Really strange, isn't it?

  • Author

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?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.