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

  • 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);
        }

    }

 

  • 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?

  • 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 by IPECTER

  • 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?

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

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

  • 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)'

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

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.