Jump to content

[1.10] CustomEntity transform automaticaly into pig? o.O


terraya

Recommended Posts

Hello@All,

 

im trying to play around a bit with my TestEntity.

 

 

somehow , i addet a attribute or something that makes my Entity.class take the model of a pig O.o

 

becouse when i try to spawn it, it spawns a pig ... xD

 

public class EntityModelTest extends EntityMob{

public EntityModelTest(World worldIn) {
	super(worldIn);
}


protected void applyEntityAttributes()
{
  super.applyEntityAttributes();
  this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10.0D);
  this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3F);
  this.tasks.addTask(0, new EntityAISwimming(this));
  this.tasks.addTask(1, new EntityAITempt(this, 1.0D, Items.APPLE, false));
  this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
  this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
  this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
  this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  this.tasks.addTask(8, new EntityAILookIdle(this));
  this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
 }

 @Override
 public void readEntityFromNBT(NBTTagCompound nbt)
 {
  super.readEntityFromNBT(nbt);
 }

 @Override
 public void writeEntityToNBT(NBTTagCompound nbt)
 {
  super.writeEntityToNBT(nbt);
 }

 @Override
 public boolean attackEntityAsMob(Entity entity){
  super.attackEntityAsMob(entity);
  return entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1);
 }

 public boolean attackEntityFrom(DamageSource ds, float damage)
 {
  if(ds.getEntity() != null && ds.getEntity() instanceof EntityPlayer)
  {
  return super.attackEntityFrom(ds, this.getMaxHealth());
  }

  return super.attackEntityFrom(ds, damage);
 }

protected boolean isAIEnabled()
{
return true;
}

  public boolean onUpdate(EntityLivingBase mob)
  {
    if ((getAttackTarget() != null) && 
      ((getAttackTarget() instanceof EntityPlayer))) {
      tryAbility(mob, getAttackTarget());
    }
    return onUpdate(mob);
  }

  private long nextAbilityUse = 0L;
  
  private void tryAbility(EntityLivingBase mob, EntityLivingBase target)
  {
    if ((target == null) || (target.getRidingEntity() != null) || (!mob.canEntityBeSeen(target))) {
      return;
    }
    long time = System.currentTimeMillis();
    if ((time > this.nextAbilityUse) && 
      (mob.getDistanceToEntity(target) > 3.0F) && 
      (target.worldObj.canBlockSeeSky(new BlockPos(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ)))))
    {
      this.nextAbilityUse = (time + 15000L);
      mob.worldObj.addWeatherEffect(new EntityLightningBolt(mob.worldObj, target.posX, target.posY - 1.0D, target.posZ, false));
    }
  }

    protected boolean canDropLoot()
    {
        return false;
    }

}

 

IT IS NOT the "Handler" or the "render" etc ...

 

it has to be in this class bcuz "before" it worked pretty well , now it just doent work becouse i add something weird O.o

Link to comment
Share on other sites

Can you show us the log? I'd like to see what commend you used and what the game thought of it.

 

You should also try running in the debugger and setting some breakpoints.

 

And, just for good measure, show us where you register this entity.

 

I am suspicious of the pig result. It is the default for a spawner block because pig=0 in some entity or mob list. That suggests that there's a zero in your code (or command) that the game is translating into pig.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Can you show us the log? I'd like to see what commend you used and what the game thought of it.

 

You should also try running in the debugger and setting some breakpoints.

 

And, just for good measure, show us where you register this entity.

 

I am suspicious of the pig result. It is the default for a spawner block because pig=0 in some entity or mob list. That suggests that there's a zero in your code (or command) that the game is translating into pig.

 

as i said, "it is not in the registry" becouse the pig came out after changing the entityclass itself ^^

 

well , im gonna search a bit more and tell you what it is :)

Link to comment
Share on other sites

I haven't messed with it and don't know, but I'm going to spout something at random.

 

No, you do not need a spawn egg for spawners to work.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Please show where you register the entity and how you spawn it.

 

as written above, its not the register.

 

well the error are my attribute tasks:

 

	  this.tasks.addTask(0, new EntityAISwimming(this));
  this.tasks.addTask(1, new EntityAITempt(this, 1.0D, Items.APPLE, false));
  this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
  this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
  this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
  this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  this.tasks.addTask(8, new EntityAILookIdle(this));
  this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));

 

one of them makes my entity to an pig X)

Link to comment
Share on other sites

Please show where you register the entity and how you spawn it.

 

as written above, its not the register.

 

well the error are my attribute tasks:

 

	  this.tasks.addTask(0, new EntityAISwimming(this));
  this.tasks.addTask(1, new EntityAITempt(this, 1.0D, Items.APPLE, false));
  this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
  this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
  this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
  this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  this.tasks.addTask(8, new EntityAILookIdle(this));
  this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));

 

one of them makes my entity to an pig X)

Then remove the ones you added to make sure. If so remove them one by one, if that doesn't work try removing multiple to see which ones are causing it then come back and tell us which ones are causing the problem.

 

What makes you think that?

as i said, "it is not in the registry" becouse the pig came out after changing the entityclass itself ^^

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

as written above, its not the register.

 

Well then, that's your problem. Your entity can't work unless it is registered. Register your entity, then rerun your mod, and then show us the log that two of us have asked for.

 

Oh, and while you're rerunning the mod, set some breakpoints so you can step through the spawning code in the debugger. If you see where the entity is determined, then you will know what went zero that shouldn't have.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Please show where you register the entity and how you spawn it.

 

as written above, its not the register.

 

well the error are my attribute tasks:

 

	  this.tasks.addTask(0, new EntityAISwimming(this));
  this.tasks.addTask(1, new EntityAITempt(this, 1.0D, Items.APPLE, false));
  this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
  this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
  this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
  this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  this.tasks.addTask(8, new EntityAILookIdle(this));
  this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));

 

one of them makes my entity to an pig X)

Then remove the ones you added to make sure. If so remove them one by one, if that doesn't work try removing multiple to see which ones are causing it then come back and tell us which ones are causing the problem.

 

What makes you think that?

as i said, "it is not in the registry" becouse the pig came out after changing the entityclass itself ^^

 

yep did that , and worked out perfectly!

 

thanks

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.