Jump to content

[1.7.10]Turning off auto health regeneration - please no console commands!


Frontsalat
 Share

Recommended Posts

The title says it already...I've come so far to find this inside the EntityPlayerSP...

 

 

   public void setPlayerSPHealth(float p_71150_1_)
    {
        float f1 = this.getHealth() - p_71150_1_;

        if (f1 <= 0.0F)
        {
            this.setHealth(p_71150_1_);

            if (f1 < 0.0F)
            {
                this.hurtResistantTime = this.maxHurtResistantTime / 2;
            }
        }
        else
        {
            this.lastDamage = f1;
            this.setHealth(this.getHealth());
            this.hurtResistantTime = this.maxHurtResistantTime;
            this.damageEntity(DamageSource.generic, f1);
            this.hurtTime = this.maxHurtTime = 10;
        }
    }

 

 

I'm just unsure how to manipulate it so health will not automatically regenerate.

 

A much better solution would be to turn off auto health regen without editing base files. Is this possible via player.capabilities? Or any Forge event for this?

Link to comment
Share on other sites

Looks like the code to determine whether or not the player should heal is in FoodStats/onUpdate

        if (p_75118_1_.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.foodLevel >= 18 && p_75118_1_.shouldHeal())
        {
            ++this.foodTimer;

            if (this.foodTimer >= 80)
            {
                p_75118_1_.heal(1.0F);
                this.addExhaustion(3.0F);
                this.foodTimer = 0;
            }
        }

 

That's called from EntityPlayer/onUpdate, the foodTimer field is private, however you could use ASM/Reflection to get access to the field, then on the PlayerTickEvent.Pre just keep it at 0

Link to comment
Share on other sites

I'd disagree with changing the game rule as that would affect every single player. If that is your goal then go for it, however if there's going to be conditions to this, like the player has to have some certain potion effect or be in a certain area, you don't want to use the gamerule but rather what I suggested.

Link to comment
Share on other sites

I agree that the original question isn't quite clear on what is to be achieved. It does sound like they mean just one of the players and not all players, so yeah changing the game rules is probably not the way to go.

 

Like 61352151511 said, the best way is to record the foodTimer value at the time the effect starts and then in the player tick event use reflection to keep the foodTimer set to that amount.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

It's ok, the Mod I'm creating is supposed to be played like that...no auto health regen...to be honest I think turning off auto health should've been an option in Minceraft to beginn with.

 

Btw., are you the Jabelar from the tutorial website? If so, I'd like to point out my gratitude to all your tutorial efforts... :)

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

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Got this Issue here. Tried a few things but nothing really helpd.     [08Dec2022 10:35:03.461] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException 3668[08Dec2022 10:35:03.461] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39) 3669[08Dec2022 10:35:03.461] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) 3670[08Dec2022 10:35:03.461] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) 3671[08Dec2022 10:35:03.461] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) 3672[08Dec2022 10:35:03.461] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) 3673[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:49) 3674[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:46) 3675[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.server.ServerMain.main(ServerMain.java:43) 3676[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.reflect.InvocationTargetException 3677[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 3678[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 3679[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 3680[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: at java.lang.reflect.Method.invoke(Method.java:498) 3681[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:37) 3682[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) 3683[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: ... 7 more 3684[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered 3685[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:392) 3686[08Dec2022 10:35:03.462] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:250) 3687[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at org.spongepowered.asm.service.modlauncher.MixinTransformationHandler.processClass(MixinTransformationHandler.java:131) 3688[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at org.spongepowered.asm.launch.MixinLaunchPluginLegacy.processClass(MixinLaunchPluginLegacy.java:131) 3689[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:154) 3690[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85) 3691[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) 3692[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:265) 3693[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) 3694[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) 3695[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at java.lang.ClassLoader.loadClass(ClassLoader.java:351) 3696[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at net.minecraft.block.Blocks.<clinit>(Blocks.java:30) 3697[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at net.minecraft.world.gen.surfacebuilders.SurfaceBuilder.<clinit>(SurfaceBuilder.java:12) 3698[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilders.<clinit>(SourceFile:11) 3699[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at net.minecraft.util.registry.WorldGenRegistries.func_243674_g(WorldGenRegistries.java:33) 3700[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at net.minecraft.util.registry.WorldGenRegistries.func_243668_a(WorldGenRegistries.java:89) 3701[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) 3702[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at net.minecraft.util.registry.WorldGenRegistries.<clinit>(WorldGenRegistries.java:88) 3703[08Dec2022 10:35:03.463] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at net.minecraft.util.registry.Registry.<clinit>(Registry.java:464) 3704[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at net.minecraft.util.registry.Bootstrap.func_151354_b(Bootstrap.java:38) 3705[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: at net.minecraft.server.Main.main(Main.java:92) 3706[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: ... 13 more 3707[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: Caused by: org.spongepowered.asm.mixin.injection.throwables.InjectionError: Critical injection failure: Redirector pehkui$tickCramming$getBoundingBox(Lnet/minecraft/entity/LivingEntity;)Lnet/minecraft/util/math/AxisAlignedBB; in pehkui.mixins.json:LivingEntityMixin failed injection check, (0/1) succeeded. Scanned 1 target(s). Using refmap Pehkui-refmap.json 3708[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: at org.spongepowered.asm.mixin.injection.struct.InjectionInfo.postInject(InjectionInfo.java:468) 3709[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: at org.spongepowered.asm.mixin.transformer.MixinTargetContext.applyInjections(MixinTargetContext.java:1362) 3710[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyInjections(MixinApplicatorStandard.java:1051) 3711[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:400) 3712[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:325) 3713[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: at org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:383) 3714[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:365) 3715[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363) 3716[08Dec2022 10:35:03.464] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:668]: ... 33 more 3717       Modlist: https://pastebin.com/pMMqiLeq
    • The error does not really identify a mod. But it could be flywheel since that modifies the code in this area, or it could be a conflict with optifine? Check you have the latest version of flywheel and try without optifine.
    • Issue with jeed, check you have the latest version then contact the mod author.
    • I'm looking to disable this auto-jumping that happens in certain mobs (e.g. fish) so that they don't jump out of the water when they are swimming in 1 block deep water.  
    • I have items that use a reference to potions to get mob effects and a machine to make them. I can't simply use a potion as an input for the recipe since the player doesn't directly interact with potions but potion items. I can get the registry location for the potion easily enough.  How do I get a reference to the actual potion item to set an an input for the recipe?
  • Topics

×
×
  • Create New...

Important Information

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