#How can I change private variables of an entity from an external class?

3 messages · Page 1 of 1 (latest)

fleet iris
#

I am calling the setCustomCritical method of MachineArrowEntity from other class below, but the customCritical variable is always set to false. It seems to be changing to the result I defined initially. Is there a way to set it to true?

MachineArrowEntity machineArrowEntity = new MachineArrowEntity(world, shooter, weaponStack, projectileStack);
machineArrowEntity.setCustomCritical(true);
public class MachineArrowEntity
    extends PersistentProjectileEntity {
    private int duration = 200;
    private boolean customCritical;

public void setCustomCritical(boolean value) {
    this.customCritical = value;
    }
}
elfin kestrel
#

Have you considered that the client and server have different instances of the entity? You'll probably need to sync the value using a data tracker

fleet iris