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

 

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

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.