Skip to content

Commit

Permalink
Always allow eating heating/cooling consumables
Browse files Browse the repository at this point in the history
  • Loading branch information
Adubbz committed Jan 2, 2024
1 parent 9d23fd3 commit 6836eb7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.4 2024-01-02T10:32:54.7659436 Tags for minecraft:item mod id toughasnails
// 1.20.4 2024-01-02T11:01:06.4961003 Tags for minecraft:item mod id toughasnails
f05342856fe99891fa5e94bbe8db82a4f75ac41e data/toughasnails/tags/items/cooling_armor.json
35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/toughasnails/tags/items/cooling_consumed_items.json
7c304628a9c17ca3ba6cd13e199fcf73ad9c974f data/toughasnails/tags/items/cooling_held_items.json
Expand Down
26 changes: 26 additions & 0 deletions common/src/main/java/toughasnails/mixin/MixinItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright 2023, the Glitchfiend Team.
* All rights reserved.
******************************************************************************/
package toughasnails.mixin;

import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import toughasnails.init.ModTags;

@Mixin(Item.class)
public class MixinItem
{
@Redirect(method="use", at=@At(value = "INVOKE", target="Lnet/minecraft/world/entity/player/Player;canEat(Z)Z"))
public boolean onUse(Player player, boolean canAlwaysEat, Level level, Player player2, InteractionHand hand)
{
ItemStack stack = player.getItemInHand(hand);
return stack.is(ModTags.Items.HEATING_CONSUMED_ITEMS) || stack.is(ModTags.Items.COOLING_CONSUMED_ITEMS) || player.canEat(canAlwaysEat);
}
}
1 change: 1 addition & 0 deletions common/src/main/resources/toughasnails.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"refmap": "toughasnails.refmap.json",
"mixins": [
"MixinItem",
"MixinPlayer",
"MixinServerLevel",
"MixinServerPlayer"
Expand Down

0 comments on commit 6836eb7

Please sign in to comment.