Jump to content

Overriding Minecraft's Health System Question


TheXFactor117

Recommended Posts

I was just curious as to if this would be possible first and for most, along with how it would effect certain aspects of the game and even mod compatibility (because I assume it might break a lot of things potentially). It's not something I am 100% wanting to implement, but I have just been toying around the idea and was wondering the feasibility behind it.

 

To explain a bit better, I was thinking about removing the health system in place in favor of my own, which would essentially increase the amount of health everyone house to "points" instead of hearts. For instance, 10 hearts would be equivalent to say 2000 points of health in my new system. To do so, I figured I would just use a formula to convert hearts to points. With that being said, damage would also have to be changed too.

 

All in all, if what I am envisioning is possible, how would that affect mod compatibility? Is there a way I could run through every entity registered and change the values of health/damage of their entities? And what about changes authors might do during a LivingHurtEvent for example that modifies damage? I'm just curious as to what I would be dealing with if I did decide to go for it.

Developer of Levels and Lost Eclipse

Link to comment
Share on other sites

Overriding Minecrafts health system would be rather interesting and you would probably run into some hard, but fun bugs. I would start by creating the capability that stores the new health value. Then I would use the LivingHurtEvent and LivingHealEvent to calculate damage and healing and I would change the health of the entities vanilla only if a config setting is on, because you can end up with some rounding errors for the health conversion, and then I would only actually update it client side.

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.

Link to comment
Share on other sites

I know how I would go about doing it, I guess I was just looking for some answers on what would happen compatibility wise (but I guess since no one has really done it, no one really knows). If no one posts here with any issues that might arise, I'm definitely going to try and overwrite the health system for one of my mods. If it works out and is successful, I might actually make it a standalone mod for people interested in changing things up. But I'm not going to get too far of myself, I'm sure there will be a lot of work involved to get it running properly.

Developer of Levels and Lost Eclipse

Link to comment
Share on other sites

I know how I would go about doing it, I guess I was just looking for some answers on what would happen compatibility wise (but I guess since no one has really done it, no one really knows). If no one posts here with any issues that might arise, I'm definitely going to try and overwrite the health system for one of my mods. If it works out and is successful, I might actually make it a standalone mod for people interested in changing things up. But I'm not going to get too far of myself, I'm sure there will be a lot of work involved to get it running properly.

I could see a not so much compatibility error with Tinkers Construct and other mods that effect the health, unless you rely slightly on the vanilla implementation of health.

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.

Link to comment
Share on other sites

Yes, but I think through events and capabilities you can re-work the health system. It would just rely on the specific events getting called last.

 

However, compatibility issues will likely arise with mods that change max health as well (and possibly those that alter the HUD Gui). I'm working on implementing it right now, and will test how everything works with other mods. Right now, I don't know of a way to fix any issues with other mods changing max health.

Developer of Levels and Lost Eclipse

Link to comment
Share on other sites

Yes, but I think through events and capabilities you can re-work the health system. It would just rely on the specific events getting called last.

 

However, compatibility issues will likely arise with mods that change max health as well (and possibly those that alter the HUD Gui). I'm working on implementing it right now, and will test how everything works with other mods. Right now, I don't know of a way to fix any issues with other mods changing max health.

 

Capabilities are the wrong way to modify the health system. Vanilla has the attribute system, which allows modification of various attributes(Max health, movement speed, attack damage, etc) of any mob. Using events and attributes will work much better than using  capabilities and events. Using both attributes is more compatible as all the health related methods and most damage related methods use them, so they will work properly without any extra work. The few edge cases(Such as directly causing damage with

EntityLivingBase#attackEntityFrom()

) can be handled by events.

 

Link to comment
Share on other sites

So you know how to do it? How? The player in Terraria has 100 starting health, it can be increased with Life Crystals (increases max by 20 HP) up to 400 HP. I want to use this type of health instead of the vanilla so that I can deal small amounts of damage, like 5 HP, and not take one-fourth of the player's health (one of the weakest mobs in Terraria, the Green Slime, deals 5 damage, but it would be OP in Minecraft)!

 

Health is a float, not an int. You can deal 0.0625 damage(1/16th of a heart) if you want, or any other amount that can be expressed by a float.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
  • Topics

×
×
  • Create New...

Important Information

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