Jump to content

Recommended Posts

Posted

I'm using a static boolean that says to the model class when the entity shot, this because into the model class I can set "aimedBow" only when the entity is shooting. Now when I setted "not static" the variable "isShooting" the model class cant recognizes the value even if changed.... also using the "get" function:

 

Entity.class

private static boolean isShooting = false;

protected void updateAITasks()
{
super.updateAITasks();

if (this.getHeldItem() != null && !this.isSitting())
{
if (this.getAttackTarget() != null) {
this.isShooting = true;
} else {
this.isShooting = false;
}
}
}

protected boolean getShooting()
{
return this.isShooting;
}

 

Model.class

public void setLivingAnimations(EntityLivingBase p_78086_1_, float p_78086_2_, float p_78086_3_, float p_78086_4_)
{
this.aimedBow = (((EntityWizard)p_78086_1_).getShooting());
super.setLivingAnimations(p_78086_1_, p_78086_2_, p_78086_3_, p_78086_4_);
}

 

Render.class

public class RenderWizard extends RenderBiped {

private static final ResourceLocation relaxWizardTexture = new ResourceLocation("mymod:textures/families/wizard.png");
private static final ResourceLocation tamedWizardTexture = new ResourceLocation("mymod:textures/families/wizard_tamed.png");

public RenderWizard(ModelBiped wizard, float par2) {
super(wizard, par2);

}

protected ResourceLocation getEntityTexture(EntityWizard p_110775_1_)
{
//return p_110775_1_.isTamed() ? tamedWizardTexture : (p_110775_1_.isAngry() ? tamedWizardTexture : relaxWizardTexture);
return p_110775_1_.isTamed() ? relaxWizardTexture : relaxWizardTexture;
}

protected ResourceLocation getEntityTexture(Entity entity) {
return this.getEntityTexture((EntityWizard)entity);
}

protected ResourceLocation getEntityTexture(EntityLiving entity) {
return this.getEntityTexture((EntityWizard)entity);
}

}

 

If the variable "isShooting" is "not static" the model.class get "isShooting" always = false even if changed ...

If the variable "isShooting" is "static" ALL entities instance are "aimedBow" synchronized ...

 

Posted

It's always false because you only set its value on the server side (or possibly getAttackTarget is always null on the client).

 

Anyway, you don't want to use static as you already discovered; instead, you need to send a packet to the client with the current state of the 'isShooting' field for the given entity.

 

Alternatively, you can store the boolean value in DataWatcher instead, which will handle the packet bit for you.

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.