Posted April 14, 20205 yr Hey so, the MAX_HEALTH has a max value of 1024 and I'm wondering if there is a way to change that
April 14, 20205 yr Author 1 hour ago, diesieben07 said: You can set RangedAttribute#maximumValue using reflection. thanks
April 16, 20205 yr Author On 4/14/2020 at 7:42 PM, diesieben07 said: You can set RangedAttribute#maximumValue using reflection. Hey, so I have tried this now and set the maximum health to 2000. When I sysout getHealth() now it outputs this, the mob is also one hit. Do you know why?
April 16, 20205 yr Author 17 minutes ago, diesieben07 said: Show your code. try { ReflectionUtil.setFieldValue(SharedMonsterAttributes.MAX_HEALTH.getClass().getDeclaredField("maximumValue"), SharedMonsterAttributes.MAX_HEALTH, 100000); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(robotHealth); //robotHealth = 2000
April 16, 20205 yr Author 4 minutes ago, diesieben07 said: That is not how you handle exceptions, ever. You need to use ObfuscationReflectionHelper and provide it with SRG names. Provide more context. Just a code snippet without surroundings is not helpful. How else should I handle them?
April 16, 20205 yr Author 1 minute ago, diesieben07 said: Do you expect them to ever happen? If so: Decide how to continue. Can you continue on normally, maybe by doing an alternative action? Can you continue on normally with the action having failed? If you can't: re-throw the exception to signify that something fatal has continued and your code cannot carry on. If you don't expect them to happen: Throw an exception signifying that something terrible has happened (your expectations of the exceptions not happening has failed). "Just log and carry on blindly" is almost never the answer. Okay. Either way, here's my full code of the function. Apparently the field isn't found even though it should be the correct field @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); ObfuscationReflectionHelper.setPrivateValue(IAttribute.class, SharedMonsterAttributes.MAX_HEALTH, 1000, "field_111118_b"); this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(robotHealth); this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE) .setBaseValue(this.attackDamage); }
April 16, 20205 yr Author 23 minutes ago, diesieben07 said: IAttribute is an interface and thus does not have fields. Oh yea, oops. Did it like this now and it still doesn't work. @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); ObfuscationReflectionHelper.setPrivateValue(RangedAttribute.class, (RangedAttribute) SharedMonsterAttributes.MAX_HEALTH, 1000, "field_111118_b"); this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(robotHealth); this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE) .setBaseValue(this.attackDamage); }
April 16, 20205 yr Author 2 minutes ago, diesieben07 said: Define "doesn't work". It does the same thing as before. The health is outputted as "1.4E-45" and the mob is one hit
April 16, 20205 yr Author 13 minutes ago, diesieben07 said: Where does robotHealth come from in your code above? public float robotHealth = 2000; @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); ObfuscationReflectionHelper.setPrivateValue(RangedAttribute.class, (RangedAttribute) SharedMonsterAttributes.MAX_HEALTH, 1000, "field_111118_b"); this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(robotHealth); this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE) .setBaseValue(this.attackDamage); }
April 16, 20205 yr 21 minutes ago, RobinCirex said: ObfuscationReflectionHelper.setPrivateValue(RangedAttribute.class, (RangedAttribute) SharedMonsterAttributes.MAX_HEALTH, 1000, "field_111118_b"); You do know you are setting it to 1,000 right? 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.
April 16, 20205 yr Author 1 minute ago, Animefan8888 said: You do know you are setting it to 1,000 right? oh, yea, that was a typo, but when setting it higher it still doesnt work
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.