-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
warming food compat with farmers delight
- Loading branch information
1 parent
c44145c
commit 5722263
Showing
8 changed files
with
211 additions
and
1 deletion.
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
34 changes: 34 additions & 0 deletions
34
src/main/java/com/github/thedeathlycow/frostiful/item/FoodHelper.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,34 @@ | ||
package com.github.thedeathlycow.frostiful.item; | ||
|
||
import net.minecraft.item.FoodComponent; | ||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class FoodHelper { | ||
|
||
@Contract("_->new") | ||
@NotNull | ||
public static FoodComponent copyFoodComponent(@NotNull FoodComponent other) { | ||
var builder = new FoodComponent.Builder(); | ||
builder.hunger(other.getHunger()); | ||
builder.saturationModifier(other.getSaturationModifier()); | ||
other.getStatusEffects().forEach(effectAndChance -> { | ||
builder.statusEffect(effectAndChance.getFirst(), effectAndChance.getSecond()); | ||
}); | ||
if (other.isAlwaysEdible()) { | ||
builder.alwaysEdible(); | ||
} | ||
if (other.isMeat()) { | ||
builder.meat(); | ||
} | ||
if (other.isSnack()) { | ||
builder.snack(); | ||
} | ||
|
||
return builder.build(); | ||
} | ||
|
||
private FoodHelper() { | ||
|
||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/com/github/thedeathlycow/frostiful/mixins/food/compat/WarmFoodMixin.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,67 @@ | ||
package com.github.thedeathlycow.frostiful.mixins.food.compat; | ||
|
||
import com.github.thedeathlycow.frostiful.entity.effect.FStatusEffects; | ||
import com.github.thedeathlycow.frostiful.tag.FItemTags; | ||
import com.github.thedeathlycow.frostiful.util.TextStyles; | ||
import net.minecraft.client.item.TooltipContext; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.effect.StatusEffectInstance; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
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.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(Item.class) | ||
public abstract class WarmFoodMixin { | ||
|
||
@Shadow public abstract boolean isFood(); | ||
|
||
@Inject( | ||
method = "finishUsing", | ||
at = @At("HEAD") | ||
) | ||
private void addWarmthToWarmFoods( | ||
ItemStack stack, | ||
World world, | ||
LivingEntity user, | ||
CallbackInfoReturnable<ItemStack> cir | ||
) { | ||
if (this.isWarmingFood(stack)) { | ||
user.addStatusEffect(new StatusEffectInstance(FStatusEffects.WARMTH, 30 * 20)); | ||
} | ||
} | ||
|
||
@Inject( | ||
method = "appendTooltip", | ||
at = @At("TAIL") | ||
) | ||
private void addToolTip( | ||
ItemStack stack, | ||
@Nullable World world, | ||
List<Text> tooltip, | ||
TooltipContext context, | ||
CallbackInfo ci | ||
) { | ||
if (this.isWarmingFood(stack)) { | ||
tooltip.add(Text.translatable("item.frostiful.warming.tooltip") | ||
.setStyle(TextStyles.WARMING_TOOLTIP)); | ||
} | ||
} | ||
|
||
private boolean isWarmingFood(ItemStack stack) { | ||
return this.isFood() && stack.isIn(FItemTags.WARM_FOODS); | ||
} | ||
|
||
|
||
|
||
|
||
} |
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
97 changes: 97 additions & 0 deletions
97
src/main/resources/data/frostiful/tags/items/warm_foods.json
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,97 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
{ | ||
"id": "farmersdelight:hot_cocoa", | ||
"required": false | ||
}, | ||
{ | ||
"id": "frozenup:mug_of_truffle_hot_chocolate", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:green_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:yellow_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:black_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:rose_hip_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:dandelion_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:purulent_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:coffee", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:long_green_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:long_yellow_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:long_black_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:long_dandelion_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:long_coffee", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:strong_green_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:strong_yellow_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:strong_black_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:strong_purulent_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:strong_rose_hip_tea", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:strong_coffee", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:tea_curry", | ||
"required": false | ||
}, | ||
{ | ||
"id": "farmersrespite:blazing_chili", | ||
"required": false | ||
}, | ||
{ | ||
"id": "festive_delight:christmas_tea", | ||
"required": false | ||
} | ||
] | ||
} |
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