New config to disable eating while at max hp
parent
43026a9f60
commit
3262546727
|
@ -52,6 +52,8 @@ public class ModConfig {
|
||||||
"Clouds height modifier, goes from 0.0, meaning the default 108 blocks height, to 1.0, meaning a 324 blocks height.");
|
"Clouds height modifier, goes from 0.0, meaning the default 108 blocks height, to 1.0, meaning a 324 blocks height.");
|
||||||
public static final Option<Boolean> ENABLE_COAL_AND_REDSTONE_BLOCKS_RECIPE = make("Enable Coal and Redstone Blocks Recipe", false,
|
public static final Option<Boolean> ENABLE_COAL_AND_REDSTONE_BLOCKS_RECIPE = make("Enable Coal and Redstone Blocks Recipe", false,
|
||||||
"Allows crafting coal and redstone as blocks for better storage");
|
"Allows crafting coal and redstone as blocks for better storage");
|
||||||
|
public static final Option<Boolean> DISABLE_EATING_WHEN_MAX_HP = make("Disable eating when at max HP", false,
|
||||||
|
"Makes it so players can no longer eat if they're at max HP so they don't accidently waste food");
|
||||||
|
|
||||||
public static final Option<Boolean> FIX_BOW_MODEL = make("Fix bow model", true,
|
public static final Option<Boolean> FIX_BOW_MODEL = make("Fix bow model", true,
|
||||||
"Makes the box model held by players and skeletons bigger and facing forward");
|
"Makes the box model held by players and skeletons bigger and facing forward");
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package xyz.pixelatedw.finalbeta.mixin;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.Player;
|
||||||
|
import net.minecraft.item.ItemInstance;
|
||||||
|
import net.minecraft.item.food.FoodItem;
|
||||||
|
import net.minecraft.level.Level;
|
||||||
|
import xyz.pixelatedw.finalbeta.ModConfig;
|
||||||
|
|
||||||
|
@Mixin(FoodItem.class)
|
||||||
|
public class FoodItemMixin {
|
||||||
|
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void use(ItemInstance stack, Level level, Player player, CallbackInfoReturnable<ItemInstance> cir) {
|
||||||
|
if (ModConfig.DISABLE_EATING_WHEN_MAX_HP.get() && player.health >= 20) {
|
||||||
|
cir.setReturnValue(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,7 +44,8 @@
|
||||||
"SlimeMixin",
|
"SlimeMixin",
|
||||||
"DimensionMixin",
|
"DimensionMixin",
|
||||||
"TranslationStorageMixin",
|
"TranslationStorageMixin",
|
||||||
"RecipeRegistryAccessor"
|
"RecipeRegistryAccessor",
|
||||||
|
"FoodItemMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": -1
|
"defaultRequire": -1
|
||||||
|
|
Loading…
Reference in New Issue