Skip to content

Commit

Permalink
add hungerless
Browse files Browse the repository at this point in the history
Signed-off-by: unilock <[email protected]>
  • Loading branch information
unilock committed Oct 30, 2024
1 parent e602652 commit 17e25e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/cc/unilock/legacyfixes/LegacyFixesConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class LegacyFixesConfig {
public static boolean bedSpawnFix = true;
public static boolean chatLinebreakFix = false;
public static boolean doubleDoors = true;
public static boolean hungerless = false;
public static boolean jumpClimbing = true;
public static boolean keepXP = false;
public static boolean mc5694Fix = true;
Expand All @@ -25,6 +26,7 @@ public static void synchronizeConfiguration(File configFile) {
bedSpawnFix = configuration.getBoolean("bedSpawnFix", Configuration.CATEGORY_GENERAL, bedSpawnFix, "Allows beds to set a player's spawn point during the day (as in 1.15+)");
chatLinebreakFix = configuration.getBoolean("chatLinebreakFix", Configuration.CATEGORY_GENERAL, chatLinebreakFix, "Fixes line breaks in chat not rendering properly, but breaks certain formatting in fixed chat messages");
doubleDoors = configuration.getBoolean("doubleDoors", Configuration.CATEGORY_GENERAL, doubleDoors, "Makes double doors open simultaneously");
hungerless = configuration.getBoolean("hungerless", Configuration.CATEGORY_GENERAL, hungerless, "Makes the hunger system always act as if the difficulty is set to Peaceful");
jumpClimbing = configuration.getBoolean("jumpClimbing", Configuration.CATEGORY_GENERAL, jumpClimbing, "Allows climbing ladders by jumping (incompat with slideClimbing)");
keepXP = configuration.getBoolean("keepXP", Configuration.CATEGORY_GENERAL, keepXP, "Players keep their experience level / points on death");
mc5694Fix = configuration.getBoolean("mc5694Fix", Configuration.CATEGORY_GENERAL, mc5694Fix, "Try to fix MC-5694 (\"High efficiency tools / fast mining destroys some blocks client-side only\")");
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/cc/unilock/legacyfixes/mixin/FoodStatsMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cc.unilock.legacyfixes.mixin;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.util.FoodStats;
import net.minecraft.world.EnumDifficulty;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(FoodStats.class)
public class FoodStatsMixin {
@ModifyExpressionValue(method = "Lnet/minecraft/util/FoodStats;onUpdate(Lnet/minecraft/entity/player/EntityPlayer;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;difficultySetting:Lnet/minecraft/world/EnumDifficulty;", opcode = Opcodes.GETFIELD))
private EnumDifficulty legacyfixes$difficultySetting(EnumDifficulty original) {
return LegacyFixesConfig.hungerless ? EnumDifficulty.PEACEFUL : original;
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.legacyfixes.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"BlockFarmlandMixin",
"EntityLivingBaseMixin",
"EntityPlayerMixin",
"FoodStatsMixin",
"ItemInWorldManagerMixin",
"accessor.EntityPlayerAccessor"
],
Expand Down

0 comments on commit 17e25e1

Please sign in to comment.