February 16, 20223 yr Author 11 hours ago, Luis_ST said: this is an example where i replace the AttributeValue Note: this code requires this AT (version 1.18.1) hmm... It's weird... Everything is perfect. But Mob's maxhealth doesn't go up above 1024. public X100health() { MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void on(FMLCommonSetupEvent e) { e.enqueueWork(() -> { replaceAttributeValue((RangedAttribute) Attributes.MAX_HEALTH, 131072); System.out.println("Hello!!!"); }); } protected static void replaceAttributeValue(RangedAttribute attribute, double maxValue) { attribute.maxValue = maxValue; } @SubscribeEvent public void onMobSpawn(LivingSpawnEvent.SpecialSpawn e) { if (e.getEntity() instanceof Mob) { Mob mob = (Mob) e.getEntity(); mob.getAttribute(Attributes.MAX_HEALTH).setBaseValue(mob.getAttribute(Attributes.MAX_HEALTH).getBaseValue() * 100); mob.setHealth(mob.getHealth() * 100); } }
February 16, 20223 yr Author 51 minutes ago, diesieben07 said: Do not use setBaseValue. Add an attribute modifier in EntityJoinWorldEvent. I have told you this three times now. okay.. addTransientModifier() ? ...... @SubscribeEvent public void onMobSpawn(EntityJoinWorldEvent e) { if (e.getEntity() instanceof Mob) { Mob mob = (Mob) e.getEntity(); mob.getAttribute(Attributes.MAX_HEALTH).addTransientModifier("What should I put in here?"); mob.setHealth(mob.getHealth() * 100); } } What should I put in here?What should I put in here?What should I put in here?What should I put in here?What should I put in here?
February 16, 20223 yr Author 13 hours ago, diesieben07 said: Yes. You need to create a new AttributeModifier. Look at vanilla for examples, e.g. LivingEntity.SPEED_MODIFIER_SPRINTING. okay Ill try it thx Edited February 17, 20223 yr by IPECTER
February 17, 20223 yr Author 14 hours ago, diesieben07 said: Yes. You need to create a new AttributeModifier. Look at vanilla for examples, e.g. LivingEntity.SPEED_MODIFIER_SPRINTING. private static final AttributeModifier x100MaxHealth = new AttributeModifier(LivingEntity.MAX_HEALTH, "x100 Max Health", 100, AttributeModifier.Operation.MULTIPLY_BASE); @SubscribeEvent public void onMobSpawn(EntityJoinWorldEvent e) { if (e.getEntity() instanceof Mob) { Mob mob = (Mob) e.getEntity(); mob.getAttribute(Attributes.MAX_HEALTH).addTransientModifier(x100MaxHealth); mob.setHealth(mob.getHealth() * 100); } } hmm... too hard.. LivingEntity.MAX_HEALTH doesn't exist. I don't know what t put in. Is there any other way to make the maximum max health/healath of all mobs 100 times other than this Event method?
February 17, 20223 yr 2 hours ago, IPECTER said: LivingEntity.MAX_HEALTH doesn't exist. the field exists but it's private 2 hours ago, IPECTER said: Is there any other way to make the maximum max health/healath of all mobs 100 times other than this Event method? this is the best way to do this
February 17, 20223 yr Author 3 hours ago, Luis_ST said: the field exists but it's private ..so, I cant use MAX_HEALTH AND HEALTH? 3 hours ago, Luis_ST said: this is the best way to do this hmm.....
February 18, 20223 yr Author 18 hours ago, diesieben07 said: If only I told you 20 times before and you already used it: new AttributeModifier(Attributes.MAX_HEALTH, "x100 Max Health", 100, AttributeModifier.Operation.MULTIPLY_BASE); error... Cannot resolve constructor 'AttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute, java.lang.String, int, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation)'
February 18, 20223 yr take a look at the constructor, since you need to pass in the correct parameters
February 18, 20223 yr Author 18 minutes ago, Luis_ST said: 올바른 매개변수를 전달해야 하므로 생성자를 살펴보세요. public X100health() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup); MinecraftForge.EVENT_BUS.register(EntityJoinWorld.class); } protected static void replaceAttributeValue(RangedAttribute attribute, double maxValue) { attribute.maxValue = maxValue; } private void commonSetup(FMLCommonSetupEvent e) { e.enqueueWork(() -> { replaceAttributeValue((RangedAttribute) Attributes.MAX_HEALTH, 131072); }); } success!!!! thx everyone for help
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.