Jump to content

How to increase Mob Health and Max Health over 1024?


IPECTER

Recommended Posts

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

    }

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 

 

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.