-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #583
- Loading branch information
Showing
5 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/mod/acgaming/universaltweaks/tweaks/items/eating/mixin/UTSmartEatMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package mod.acgaming.universaltweaks.tweaks.items.eating.mixin; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemFood; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import mod.acgaming.universaltweaks.config.UTConfigTweaks; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(ItemFood.class) | ||
public abstract class UTSmartEatMixin | ||
{ | ||
@Shadow | ||
public boolean alwaysEdible; | ||
|
||
@Shadow | ||
public abstract int getHealAmount(ItemStack stack); | ||
|
||
@Redirect(method = "onItemRightClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;canEat(Z)Z")) | ||
public boolean utSmartEat(EntityPlayer player, boolean ignoreHunger, @Local ItemStack itemstack) | ||
{ | ||
if (!UTConfigTweaks.ITEMS.utSmartEatToggle || this.alwaysEdible) return player.canEat(true); | ||
return player.canEat(false) && this.getHealAmount(itemstack) <= (20 - player.getFoodStats().getFoodLevel()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters