mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
Add Coffee Machine JEI category
Create a recipe type replacement for CoffeeIngredient
This commit is contained in:
parent
2f50f5ecfc
commit
971fdd652f
25 changed files with 607 additions and 82 deletions
|
@ -0,0 +1,10 @@
|
|||
// 1.20.4 2024-03-05T21:12:08.3849935 Coffee Ingredient Recipes
|
||||
68a4a8ca4b24d8cc042c0a384069196f708a4dd9 data/actuallyadditions/recipes/coffee_ingredient/blaze_powder.json
|
||||
f18e6b3fee9f1610c0366feabc0dd3ffe2455224 data/actuallyadditions/recipes/coffee_ingredient/fermented_spider_eye.json
|
||||
5402f0078e820175f117c4c3b63907f29daa6209 data/actuallyadditions/recipes/coffee_ingredient/ghast_tear.json
|
||||
58f7831e3e547732cb9b0605334d21f45730b566 data/actuallyadditions/recipes/coffee_ingredient/golden_carrot.json
|
||||
708f899155df8a114e30f15e7e5940f75fb2a9e9 data/actuallyadditions/recipes/coffee_ingredient/magma_cream.json
|
||||
113a26d8cd82641cf612e39e4bf026f769e4597b data/actuallyadditions/recipes/coffee_ingredient/milk_bucket.json
|
||||
60fa6da54a062d5bbd2f25c09f00f833ea8ff2bf data/actuallyadditions/recipes/coffee_ingredient/milk_tagged.json
|
||||
228b27e7fb0ea183b8c34561ceb6b7b6a48fc0fe data/actuallyadditions/recipes/coffee_ingredient/pufferfish.json
|
||||
1f74a319b1677a66f1fc83ccc6c284dc51db88ef data/actuallyadditions/recipes/coffee_ingredient/sugar.json
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"type": "actuallyadditions:coffee_ingredient",
|
||||
"effects": [
|
||||
{
|
||||
"amplifier": 0,
|
||||
"duration": 15,
|
||||
"effect": "minecraft:strength"
|
||||
}
|
||||
],
|
||||
"ingredient": {
|
||||
"item": "minecraft:blaze_powder"
|
||||
},
|
||||
"maxAmplifier": 4
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"type": "actuallyadditions:coffee_ingredient",
|
||||
"effects": [
|
||||
{
|
||||
"amplifier": 0,
|
||||
"duration": 25,
|
||||
"effect": "minecraft:invisibility"
|
||||
}
|
||||
],
|
||||
"ingredient": {
|
||||
"item": "minecraft:fermented_spider_eye"
|
||||
},
|
||||
"maxAmplifier": 2
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"type": "actuallyadditions:coffee_ingredient",
|
||||
"effects": [
|
||||
{
|
||||
"amplifier": 0,
|
||||
"duration": 5,
|
||||
"effect": "minecraft:regeneration"
|
||||
}
|
||||
],
|
||||
"ingredient": {
|
||||
"item": "minecraft:ghast_tear"
|
||||
},
|
||||
"maxAmplifier": 3
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"type": "actuallyadditions:coffee_ingredient",
|
||||
"effects": [
|
||||
{
|
||||
"amplifier": 0,
|
||||
"duration": 30,
|
||||
"effect": "minecraft:night_vision"
|
||||
}
|
||||
],
|
||||
"ingredient": {
|
||||
"item": "minecraft:golden_carrot"
|
||||
},
|
||||
"maxAmplifier": 2
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"type": "actuallyadditions:coffee_ingredient",
|
||||
"effects": [
|
||||
{
|
||||
"amplifier": 0,
|
||||
"duration": 20,
|
||||
"effect": "minecraft:fire_resistance"
|
||||
}
|
||||
],
|
||||
"ingredient": {
|
||||
"item": "minecraft:magma_cream"
|
||||
},
|
||||
"maxAmplifier": 2
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"type": "actuallyadditions:coffee_ingredient",
|
||||
"extraText": "jei.actuallyadditions.coffee.extra.milk",
|
||||
"ingredient": {
|
||||
"item": "minecraft:milk_bucket"
|
||||
},
|
||||
"maxAmplifier": 0
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"neoforge:conditions": [
|
||||
{
|
||||
"type": "neoforge:not",
|
||||
"value": {
|
||||
"type": "neoforge:tag_empty",
|
||||
"tag": "forge:milk"
|
||||
}
|
||||
}
|
||||
],
|
||||
"type": "actuallyadditions:coffee_ingredient",
|
||||
"extraText": "jei.actuallyadditions.coffee.extra.milk",
|
||||
"ingredient": {
|
||||
"tag": "forge:milk"
|
||||
},
|
||||
"maxAmplifier": 0
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"type": "actuallyadditions:coffee_ingredient",
|
||||
"effects": [
|
||||
{
|
||||
"amplifier": 0,
|
||||
"duration": 10,
|
||||
"effect": "minecraft:water_breathing"
|
||||
}
|
||||
],
|
||||
"ingredient": {
|
||||
"item": "minecraft:pufferfish"
|
||||
},
|
||||
"maxAmplifier": 2
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"type": "actuallyadditions:coffee_ingredient",
|
||||
"effects": [
|
||||
{
|
||||
"amplifier": 0,
|
||||
"duration": 30,
|
||||
"effect": "minecraft:speed"
|
||||
}
|
||||
],
|
||||
"ingredient": {
|
||||
"item": "minecraft:sugar"
|
||||
},
|
||||
"maxAmplifier": 4
|
||||
}
|
|
@ -21,6 +21,7 @@ import de.ellpeck.actuallyadditions.api.lens.LensConversion;
|
|||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.WeightedOre;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.ColorChangeRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
|
||||
|
@ -66,7 +67,7 @@ public final class ActuallyAdditionsAPI {
|
|||
* Farmer behaviors are sorted when first accessed, this will not be done until after loading, but do not add behaviors at runtime.
|
||||
*/
|
||||
public static final List<IFarmerBehavior> FARMER_BEHAVIORS = new ArrayList<>();
|
||||
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<>();
|
||||
public static final List<RecipeHolder<CoffeeIngredientRecipe>> COFFEE_MACHINE_INGREDIENTS = new ArrayList<>();
|
||||
// public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<>();
|
||||
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<>();
|
||||
//This is added to automatically, you don't need to add anything to this list
|
||||
|
@ -241,7 +242,7 @@ public final class ActuallyAdditionsAPI {
|
|||
* @param ingredient The ingredient to add
|
||||
*/
|
||||
public static void addCoffeeMachineIngredient(CoffeeIngredient ingredient) {
|
||||
COFFEE_MACHINE_INGREDIENTS.add(ingredient);
|
||||
// COFFEE_MACHINE_INGREDIENTS.add(ingredient);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.api.internal;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -25,8 +26,11 @@ import java.util.List;
|
|||
*/
|
||||
public interface IMethodHandler {
|
||||
|
||||
@Deprecated
|
||||
boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient);
|
||||
|
||||
boolean addRecipeEffectToStack(ItemStack stack, CoffeeIngredientRecipe ingredient);
|
||||
|
||||
MobEffectInstance getSameEffectFromStack(ItemStack stack, MobEffectInstance effect);
|
||||
|
||||
void addEffectProperties(ItemStack stack, MobEffectInstance effect, boolean addDur, boolean addAmp);
|
||||
|
|
|
@ -57,6 +57,7 @@ public class ActuallyAdditionsData {
|
|||
generator.addProvider(true, new FuelRecipeGenerator(packOutput));
|
||||
generator.addProvider(true, new MiscMachineRecipeGenerator(packOutput));
|
||||
generator.addProvider(true, new MiningLensGenerator(packOutput));
|
||||
generator.addProvider(true, new CoffeeIngredientGenerator(packOutput));
|
||||
|
||||
generator.addProvider(true, new SoundsGenerator(packOutput, helper));
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package de.ellpeck.actuallyadditions.data;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.recipes.RecipeOutput;
|
||||
import net.minecraft.data.recipes.RecipeProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.neoforged.neoforge.common.conditions.NotCondition;
|
||||
import net.neoforged.neoforge.common.conditions.TagEmptyCondition;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CoffeeIngredientGenerator extends RecipeProvider {
|
||||
public CoffeeIngredientGenerator(PackOutput packOutput) {
|
||||
super(packOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Coffee Ingredient " + super.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildRecipes(@Nonnull RecipeOutput recipeOutput) {
|
||||
buildIngredient(recipeOutput, Items.MILK_BUCKET, 0, "jei." + ActuallyAdditions.MODID + ".coffee.extra.milk");
|
||||
|
||||
//Pam's puts milk in a tag, so we'll use that
|
||||
TagKey<Item> milkTag = ItemTags.create(new ResourceLocation("forge", "milk"));
|
||||
RecipeOutput tagOutput = recipeOutput.withConditions(new NotCondition(new TagEmptyCondition(milkTag.location())));
|
||||
buildIngredient(tagOutput, new ResourceLocation(ActuallyAdditions.MODID, "coffee_ingredient/milk_tagged"),
|
||||
Ingredient.of(milkTag), 0, "jei." + ActuallyAdditions.MODID + ".coffee.extra.milk");
|
||||
|
||||
buildIngredient(recipeOutput, Items.SUGAR, 4, new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 30, 0));
|
||||
buildIngredient(recipeOutput, Items.MAGMA_CREAM, 2, new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 20, 0));
|
||||
buildIngredient(recipeOutput, Items.PUFFERFISH, 2, new MobEffectInstance(MobEffects.WATER_BREATHING, 10, 0));
|
||||
buildIngredient(recipeOutput, Items.GOLDEN_CARROT, 2, new MobEffectInstance(MobEffects.NIGHT_VISION, 30, 0));
|
||||
buildIngredient(recipeOutput, Items.GHAST_TEAR, 3, new MobEffectInstance(MobEffects.REGENERATION, 5, 0));
|
||||
buildIngredient(recipeOutput, Items.BLAZE_POWDER, 4, new MobEffectInstance(MobEffects.DAMAGE_BOOST, 15, 0));
|
||||
buildIngredient(recipeOutput, Items.FERMENTED_SPIDER_EYE, 2, new MobEffectInstance(MobEffects.INVISIBILITY, 25, 0));
|
||||
}
|
||||
|
||||
private void buildIngredient(RecipeOutput recipeOutput, ItemLike ingredient, int maxAmplifier, MobEffectInstance... effects) {
|
||||
buildIngredient(recipeOutput, ingredient, maxAmplifier, "", effects);
|
||||
}
|
||||
|
||||
private void buildIngredient(RecipeOutput recipeOutput, ItemLike ingredient, int maxAmplifier, String extraText, MobEffectInstance... effects) {
|
||||
ResourceLocation id = new ResourceLocation(ActuallyAdditions.MODID, "coffee_ingredient/" + getItemName(ingredient));
|
||||
NonNullList<CoffeeIngredientRecipe.EffectInstance> instances = NonNullList.create();
|
||||
for (MobEffectInstance effect : effects) {
|
||||
instances.add(new CoffeeIngredientRecipe.EffectInstance(effect));
|
||||
}
|
||||
CoffeeIngredientRecipe recipe = new CoffeeIngredientRecipe(Ingredient.of(ingredient), instances, maxAmplifier, extraText);
|
||||
recipeOutput.accept(id, recipe, null);
|
||||
}
|
||||
|
||||
private void buildIngredient(RecipeOutput recipeOutput, ResourceLocation id, Ingredient ingredient, int maxAmplifier, MobEffectInstance... effects) {
|
||||
buildIngredient(recipeOutput, id, ingredient, maxAmplifier, "", effects);
|
||||
}
|
||||
|
||||
private void buildIngredient(RecipeOutput recipeOutput, ResourceLocation id, Ingredient ingredient, int maxAmplifier, String extraText, MobEffectInstance... effects) {
|
||||
NonNullList<CoffeeIngredientRecipe.EffectInstance> instances = NonNullList.create();
|
||||
for (MobEffectInstance effect : effects) {
|
||||
instances.add(new CoffeeIngredientRecipe.EffectInstance(effect));
|
||||
}
|
||||
CoffeeIngredientRecipe recipe = new CoffeeIngredientRecipe(ingredient, instances, maxAmplifier, extraText);
|
||||
recipeOutput.accept(id, recipe, null);
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ public class ActuallyRecipes {
|
|||
public static final Supplier<RecipeSerializer<?>> FERMENTING_RECIPE = SERIALIZERS.register(FermentingRecipe.NAME, FermentingRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> COLOR_CHANGE_RECIPE = SERIALIZERS.register(ColorChangeRecipe.NAME, ColorChangeRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> MINING_LENS_RECIPE = SERIALIZERS.register(MiningLensRecipe.NAME, MiningLensRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> COFFEE_INGREDIENT_RECIPE = SERIALIZERS.register(CoffeeIngredientRecipe.NAME, CoffeeIngredientRecipe.Serializer::new);
|
||||
|
||||
|
||||
|
||||
|
@ -45,6 +46,7 @@ public class ActuallyRecipes {
|
|||
public static final Supplier<RecipeType<FermentingRecipe>> FERMENTING = RECIPE_TYPES.register("fermenting", () -> new RecipeType<>() {});
|
||||
public static final Supplier<RecipeType<ColorChangeRecipe>> COLOR_CHANGE = RECIPE_TYPES.register("color_change", () -> new RecipeType<>() {});
|
||||
public static final Supplier<RecipeType<MiningLensRecipe>> MINING_LENS = RECIPE_TYPES.register("mining_lens", () -> new RecipeType<>() {});
|
||||
public static final Supplier<RecipeType<CoffeeIngredientRecipe>> COFFEE_INGREDIENT = RECIPE_TYPES.register("coffee_ingredient", () -> new RecipeType<>() {});
|
||||
}
|
||||
public static class Ingredients {
|
||||
public static final DeferredRegister<IngredientType<?>> INGREDIENTS = DeferredRegister.create(NeoForgeRegistries.Keys.INGREDIENT_TYPES, ActuallyAdditions.MODID);
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
package de.ellpeck.actuallyadditions.mod.crafting;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CoffeeIngredientRecipe implements Recipe<Container> {
|
||||
public static final String NAME = "coffee_ingredient";
|
||||
|
||||
protected final Ingredient ingredient;
|
||||
protected final NonNullList<EffectInstance> instances; //Just a record used to populate the effects list
|
||||
protected final List<MobEffectInstance> effects;
|
||||
protected final int maxAmplifier;
|
||||
protected final String extraText;
|
||||
|
||||
public CoffeeIngredientRecipe(Ingredient ingredient, NonNullList<EffectInstance> effectInstances, int maxAmplifier, String extraText) {
|
||||
this.ingredient = ingredient;
|
||||
this.maxAmplifier = maxAmplifier;
|
||||
|
||||
this.instances = effectInstances;
|
||||
List<MobEffectInstance> instances = new ArrayList<>();
|
||||
for (EffectInstance instance : effectInstances) {
|
||||
MobEffect effect = BuiltInRegistries.MOB_EFFECT.get(instance.effect());
|
||||
if (effect == null) break;
|
||||
instances.add(new MobEffectInstance(effect, instance.duration, instance.amplifier));
|
||||
}
|
||||
this.effects = instances;
|
||||
this.extraText = extraText;
|
||||
}
|
||||
|
||||
public Ingredient getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
public List<MobEffectInstance> getEffects() {
|
||||
return effects;
|
||||
}
|
||||
|
||||
public int getMaxAmplifier() {
|
||||
return maxAmplifier;
|
||||
}
|
||||
|
||||
public String getExtraText() {
|
||||
return extraText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Container container, Level level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean matches(ItemStack itemStack) {
|
||||
return ingredient.test(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(Container container, RegistryAccess registryAccess) {
|
||||
return getResultItem(registryAccess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraftInDimensions(int pWidth, int pHeight) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResultItem(RegistryAccess registryAccess) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpecial() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return ActuallyRecipes.COFFEE_INGREDIENT_RECIPE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType<?> getType() {
|
||||
return ActuallyRecipes.Types.COFFEE_INGREDIENT.get();
|
||||
}
|
||||
|
||||
public boolean effect(ItemStack stack) {
|
||||
return ActuallyAdditionsAPI.methodHandler.addRecipeEffectToStack(stack, this);
|
||||
}
|
||||
|
||||
public static Optional<RecipeHolder<CoffeeIngredientRecipe>> getIngredientForStack(ItemStack ingredient) {
|
||||
return ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS.stream().filter(recipe -> recipe.value().matches(ingredient)).findFirst();
|
||||
}
|
||||
|
||||
public record EffectInstance(ResourceLocation effect, int duration, int amplifier) { //Simplified record for the effect instance
|
||||
public static final EffectInstance EMPTY = new EffectInstance(new ResourceLocation("darkness"), 0, 0);
|
||||
public static final Codec<EffectInstance> CODEC = RecordCodecBuilder.create(
|
||||
instance -> instance.group(
|
||||
ResourceLocation.CODEC.fieldOf("effect").forGetter(effect -> effect.effect),
|
||||
Codec.INT.fieldOf("duration").forGetter(effect -> effect.duration),
|
||||
Codec.INT.fieldOf("amplifier").forGetter(effect -> effect.amplifier)
|
||||
)
|
||||
.apply(instance, EffectInstance::new)
|
||||
);
|
||||
|
||||
public EffectInstance(MobEffectInstance effect) {
|
||||
this(BuiltInRegistries.MOB_EFFECT.getKey(effect.getEffect()), effect.getDuration(), effect.getAmplifier());
|
||||
}
|
||||
|
||||
public static EffectInstance fromNetwork(FriendlyByteBuf pBuffer) {
|
||||
ResourceLocation effect = pBuffer.readResourceLocation();
|
||||
int duration = pBuffer.readVarInt();
|
||||
int amplifier = pBuffer.readVarInt();
|
||||
return new EffectInstance(effect, duration, amplifier);
|
||||
}
|
||||
|
||||
public void toNetwork(FriendlyByteBuf pBuffer) {
|
||||
pBuffer.writeResourceLocation(effect);
|
||||
pBuffer.writeVarInt(duration);
|
||||
pBuffer.writeVarInt(amplifier);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Serializer implements RecipeSerializer<CoffeeIngredientRecipe> {
|
||||
private static final Codec<CoffeeIngredientRecipe> CODEC = RecordCodecBuilder.create(
|
||||
instance -> instance.group(
|
||||
Ingredient.CODEC_NONEMPTY.fieldOf("ingredient").forGetter(recipe -> recipe.ingredient),
|
||||
EffectInstance.CODEC
|
||||
.listOf()
|
||||
.optionalFieldOf("effects", new ArrayList<>())
|
||||
.flatXmap(
|
||||
list -> {
|
||||
for (EffectInstance effect : list) {
|
||||
if (!BuiltInRegistries.MOB_EFFECT.containsKey(effect.effect)) {
|
||||
return DataResult.error(() -> "Unknown effect: %s".formatted(effect.effect));
|
||||
}
|
||||
}
|
||||
return DataResult.success(NonNullList.of(EffectInstance.EMPTY, list.toArray(EffectInstance[]::new)));
|
||||
},
|
||||
DataResult::success
|
||||
)
|
||||
.forGetter(recipe -> recipe.instances),
|
||||
Codec.INT.fieldOf("maxAmplifier").forGetter(recipe -> recipe.maxAmplifier),
|
||||
Codec.STRING.optionalFieldOf("extraText", "").forGetter(recipe -> recipe.extraText)
|
||||
)
|
||||
.apply(instance, CoffeeIngredientRecipe::new)
|
||||
);
|
||||
|
||||
@Override
|
||||
public Codec<CoffeeIngredientRecipe> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CoffeeIngredientRecipe fromNetwork(@Nonnull FriendlyByteBuf pBuffer) {
|
||||
Ingredient ingredient = Ingredient.fromNetwork(pBuffer);
|
||||
int i = pBuffer.readVarInt();
|
||||
NonNullList<EffectInstance> list = NonNullList.withSize(i, EffectInstance.EMPTY);
|
||||
for (int j = 0; j < list.size(); ++j) {
|
||||
list.set(j, EffectInstance.fromNetwork(pBuffer));
|
||||
}
|
||||
int maxAmplifier = pBuffer.readInt();
|
||||
String extraText = pBuffer.readUtf(32767);
|
||||
return new CoffeeIngredientRecipe(ingredient, list, maxAmplifier, extraText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(@Nonnull FriendlyByteBuf pBuffer, CoffeeIngredientRecipe pRecipe) {
|
||||
pRecipe.ingredient.toNetwork(pBuffer);
|
||||
pBuffer.writeVarInt(pRecipe.instances.size());
|
||||
for (EffectInstance effect : pRecipe.instances) {
|
||||
effect.toNetwork(pBuffer);
|
||||
}
|
||||
pBuffer.writeInt(pRecipe.maxAmplifier);
|
||||
pBuffer.writeUtf(pRecipe.extraText);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -85,7 +85,7 @@ public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
|||
if (!this.moveItemStackTo(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT + 1, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (ItemCoffee.getIngredientFromStack(newStack) != null) {
|
||||
} else if (ItemCoffee.getIngredientRecipeFromStack(newStack) != null) {
|
||||
if (!this.moveItemStackTo(newStack, 3, 11, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class ActuallyItems {
|
|||
|
||||
// MISC ITEMS
|
||||
public static final DeferredItem<ItemBase> CANOLA = ITEMS.register("canola", () -> new ItemBase());
|
||||
public static final DeferredItem<ItemBase> COFFEE_CUP = ITEMS.register("coffee_cup", () -> new ItemBase());
|
||||
public static final DeferredItem<ItemCoffee> COFFEE_CUP = ITEMS.register("coffee_cup", () -> new ItemCoffee());
|
||||
public static final DeferredItem<ItemBase> PAPER_CONE = ITEMS.register("paper_cone", () -> new ItemBase());
|
||||
public static final DeferredItem<ItemBase> DOUGH = ITEMS.register("dough", () -> new ItemBase());
|
||||
public static final DeferredItem<ItemBase> RING = ITEMS.register("ring", () -> new ItemBase());
|
||||
|
|
|
@ -13,110 +13,104 @@ package de.ellpeck.actuallyadditions.mod.items;
|
|||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.UseAnim;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.fml.ModList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemCoffee extends ItemFoodBase {
|
||||
public class ItemCoffee extends ItemBase {
|
||||
private static final FoodProperties FOOD = new FoodProperties.Builder().nutrition(8).saturationMod(5.0F).alwaysEat().build();
|
||||
|
||||
public ItemCoffee() {
|
||||
super(8, 5.0F, false); //, name);
|
||||
//this.setMaxDamage(3);
|
||||
//this.setAlwaysEdible();
|
||||
//this.setMaxStackSize(1);
|
||||
//this.setNoRepair();
|
||||
super(ActuallyItems.defaultProps().food(FOOD).durability(3));
|
||||
}
|
||||
|
||||
public static void initIngredients() {
|
||||
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(Ingredient.of(Items.MILK_BUCKET)));
|
||||
//Pam's Soy Milk (For Jemx because he's lactose intolerant. YER HAPPY NAO!?)
|
||||
if (ModList.get().isLoaded("harvestcraft")) {
|
||||
Item item = ItemUtil.getItemFromName("harvestcraft:soymilkitem");
|
||||
if (item != null) {
|
||||
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(Ingredient.of(item)));
|
||||
}
|
||||
}
|
||||
|
||||
//ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.SUGAR), 4, new PotionEffect(MobEffects.SPEED, 30, 0)));
|
||||
//ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.MAGMA_CREAM), 2, new PotionEffect(MobEffects.FIRE_RESISTANCE, 20, 0)));
|
||||
//ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(new ItemStack(Items.FISH, 1, 3)), 2, new PotionEffect(MobEffects.WATER_BREATHING, 10, 0)));
|
||||
//ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.GOLDEN_CARROT), 2, new PotionEffect(MobEffects.NIGHT_VISION, 30, 0)));
|
||||
//ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.GHAST_TEAR), 3, new PotionEffect(MobEffects.REGENERATION, 5, 0)));
|
||||
//ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.BLAZE_POWDER), 4, new PotionEffect(MobEffects.STRENGTH, 15, 0)));
|
||||
//ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.FERMENTED_SPIDER_EYE), 2, new PotionEffect(MobEffects.INVISIBILITY, 25, 0)));
|
||||
// ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(Ingredient.of(Items.MILK_BUCKET)));
|
||||
// //Pam's Soy Milk (For Jemx because he's lactose intolerant. YER HAPPY NAO!?)
|
||||
// if (ModList.get().isLoaded("harvestcraft")) {
|
||||
// Item item = ItemUtil.getItemFromName("harvestcraft:soymilkitem");
|
||||
// if (item != null) {
|
||||
// ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(Ingredient.of(item)));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.SUGAR), 4, new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 30, 0)));
|
||||
// ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.MAGMA_CREAM), 2, new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 20, 0)));
|
||||
// ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.PUFFERFISH), 2, new MobEffectInstance(MobEffects.WATER_BREATHING, 10, 0)));
|
||||
// ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.GOLDEN_CARROT), 2, new MobEffectInstance(MobEffects.NIGHT_VISION, 30, 0)));
|
||||
// ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.GHAST_TEAR), 3, new MobEffectInstance(MobEffects.REGENERATION, 5, 0)));
|
||||
// ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.BLAZE_POWDER), 4, new MobEffectInstance(MobEffects.DAMAGE_BOOST, 15, 0)));
|
||||
// ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.of(Items.FERMENTED_SPIDER_EYE), 2, new MobEffectInstance(MobEffects.INVISIBILITY, 25, 0)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CoffeeIngredient getIngredientFromStack(ItemStack stack) {
|
||||
for (CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS) {
|
||||
if (ingredient.getInput().test(stack)) {
|
||||
return ingredient;
|
||||
public static RecipeHolder<CoffeeIngredientRecipe> getIngredientRecipeFromStack(ItemStack stack) {
|
||||
for (RecipeHolder<CoffeeIngredientRecipe> recipeHolder : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS) {
|
||||
if (recipeHolder.value().getIngredient().test(stack)) {
|
||||
return recipeHolder;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void applyPotionEffectsFromStack(ItemStack stack, LivingEntity player) {/*
|
||||
PotionEffect[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack);
|
||||
public static void applyPotionEffectsFromStack(ItemStack stack, LivingEntity player) {
|
||||
MobEffectInstance[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack);
|
||||
if (effects != null && effects.length > 0) {
|
||||
for (PotionEffect effect : effects) {
|
||||
player.addPotionEffect(new PotionEffect(effect.getPotion(), effect.getDuration() * 20, effect.getAmplifier()));
|
||||
for (MobEffectInstance effect : effects) {
|
||||
player.addEffect(new MobEffectInstance(effect.getEffect(), effect.getDuration() * 20, effect.getAmplifier()));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//@Override
|
||||
public ItemStack onItemUseFinish(ItemStack stack, Level world, LivingEntity player) {
|
||||
@Override
|
||||
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity livingEntity) {
|
||||
ItemStack theStack = stack.copy();
|
||||
super.finishUsingItem(stack, world, player);
|
||||
applyPotionEffectsFromStack(stack, player);
|
||||
//theStack.setItemDamage(theStack.getItemDamage() + 1);
|
||||
//if (theStack.getMaxDamage() - theStack.getItemDamage() < 0) {
|
||||
// return new ItemStack(ActuallyItems.COFFEE_CUP.get());
|
||||
//} else {
|
||||
// return theStack;
|
||||
//}
|
||||
return ItemStack.EMPTY;
|
||||
super.finishUsingItem(stack, level, livingEntity);
|
||||
applyPotionEffectsFromStack(stack, livingEntity);
|
||||
theStack.setDamageValue(theStack.getDamageValue() + 1);
|
||||
if (theStack.getMaxDamage() - theStack.getDamageValue() < 0) {
|
||||
return new ItemStack(ActuallyItems.COFFEE_CUP.get());
|
||||
} else {
|
||||
return theStack;
|
||||
}
|
||||
}
|
||||
|
||||
//@Override
|
||||
//public EnumAction getItemUseAction(ItemStack stack) {
|
||||
// return EnumAction.DRINK;
|
||||
//}
|
||||
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public CompoundTag getShareTag(ItemStack stack) {
|
||||
// return super.getShareTag(stack);
|
||||
// }
|
||||
@Override
|
||||
public UseAnim getUseAnimation(ItemStack pStack) {
|
||||
return UseAnim.DRINK;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Level playerIn, List<Component> tooltip, TooltipFlag advanced) {
|
||||
//PotionEffect[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack);
|
||||
//if (effects != null) {
|
||||
// for (PotionEffect effect : effects) {
|
||||
// tooltip.add(StringUtil.localize(effect.getEffectName()) + " " + (effect.getAmplifier() + 1) + ", " + StringUtils.formatTickDuration(effect.getDuration() * 20));
|
||||
// }
|
||||
//} else {
|
||||
// tooltip.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".coffeeCup.noEffect"));
|
||||
//}
|
||||
MobEffectInstance[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack);
|
||||
if (effects != null) {
|
||||
for (MobEffectInstance effect : effects) {
|
||||
tooltip.add(Component.translatable(effect.getDescriptionId())
|
||||
.append(" " + (effect.getAmplifier() + 1) + ", " + StringUtil.formatTickDuration(effect.getDuration(), 20))
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
} else {
|
||||
tooltip.add(Component.translatable("tooltip." + ActuallyAdditions.MODID + ".coffeeCup.noEffect").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,7 +151,7 @@ public class ItemCoffee extends ItemFoodBase {
|
|||
|
||||
@Override
|
||||
public String getExtraText() {
|
||||
return I18n.get("container.nei." + ActuallyAdditions.MODID + ".coffee.extra.milk");
|
||||
return I18n.get("jei." + ActuallyAdditions.MODID + ".coffee.extra.milk");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,12 @@ package de.ellpeck.actuallyadditions.mod.jei;
|
|||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.fermenting.FermentingCategory;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.laser.LaserRecipeCategory;
|
||||
|
@ -45,6 +47,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin {
|
|||
public static final RecipeType<FermentingRecipe> FERMENTING = RecipeType.create(ActuallyAdditions.MODID, "fermenting", FermentingRecipe.class);
|
||||
public static final RecipeType<LaserRecipe> LASER = RecipeType.create(ActuallyAdditions.MODID, "laser", LaserRecipe.class);
|
||||
public static final RecipeType<EmpowererRecipe> EMPOWERER = RecipeType.create(ActuallyAdditions.MODID, "empowerer", EmpowererRecipe.class);
|
||||
public static final RecipeType<CoffeeIngredientRecipe> COFFEE_MACHINE = RecipeType.create(ActuallyAdditions.MODID, "coffee_machine", CoffeeIngredientRecipe.class);
|
||||
|
||||
@Override
|
||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||
|
@ -53,8 +56,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin {
|
|||
registry.addRecipeCategories(new FermentingCategory(helpers.getGuiHelper()));
|
||||
registry.addRecipeCategories(new LaserRecipeCategory(helpers.getGuiHelper()));
|
||||
registry.addRecipeCategories(new EmpowererRecipeCategory(helpers.getGuiHelper()));
|
||||
|
||||
//registry.addRecipeCategories(new CoffeeMachineRecipeCategory(helpers.getGuiHelper()), new CompostRecipeCategory(helpers.getGuiHelper()), new CrusherRecipeCategory(helpers.getGuiHelper()), new ReconstructorRecipeCategory(helpers.getGuiHelper()), new EmpowererRecipeCategory(helpers.getGuiHelper()), new BookletRecipeCategory(helpers.getGuiHelper()));
|
||||
registry.addRecipeCategories(new CoffeeMachineCategory(helpers.getGuiHelper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,11 +66,10 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin {
|
|||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.FERMENTING_BARREL.getItem()), FERMENTING);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getItem()), LASER);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.EMPOWERER.getItem()), EMPOWERER);
|
||||
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.COFFEE_MACHINE.getItem()), COFFEE_MACHINE);
|
||||
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockFurnaceDouble.get()), VanillaRecipeCategoryUid.SMELTING);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockGrinder.get()), CrusherRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockGrinderDouble.get()), CrusherRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockCoffeeMachine.get()), CoffeeMachineRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockAtomicReconstructor.get()), ReconstructorRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockEmpowerer.get()), EmpowererRecipeCategory.NAME);
|
||||
// registry.addRecipeCatalyst(new ItemStack(ActuallyItems.itemBooklet.get()), BookletRecipeCategory.NAME);
|
||||
|
@ -83,7 +84,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin {
|
|||
registry.addRecipes(LASER, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.LASER.get()).stream().map(RecipeHolder::value).toList());
|
||||
registry.addRecipes(EMPOWERER, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.EMPOWERING.get()).stream().map(RecipeHolder::value).toList());
|
||||
|
||||
|
||||
registry.addRecipes(COFFEE_MACHINE, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.COFFEE_INGREDIENT.get()).stream().map(RecipeHolder::value).toList());
|
||||
//registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, BookletRecipeCategory.NAME);
|
||||
//registry.addRecipes(ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS, CoffeeMachineRecipeCategory.NAME);
|
||||
//registry.addRecipes(ActuallyAdditionsAPI.CRUSHER_RECIPES, CrusherRecipeCategory.NAME);
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package de.ellpeck.actuallyadditions.mod.jei.coffee;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyTags;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.jei.JEIActuallyAdditionsPlugin;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.recipe.IFocusGroup;
|
||||
import mezz.jei.api.recipe.RecipeIngredientRole;
|
||||
import mezz.jei.api.recipe.RecipeType;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
|
||||
public class CoffeeMachineCategory implements IRecipeCategory<CoffeeIngredientRecipe> {
|
||||
private final IDrawableStatic background;
|
||||
|
||||
public CoffeeMachineCategory(IGuiHelper helper) {
|
||||
this.background = helper.drawableBuilder(AssetUtil.getGuiLocation("gui_nei_coffee_machine"), 0, 0, 126, 92).setTextureSize(256,256).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeType<CoffeeIngredientRecipe> getRecipeType() {
|
||||
return JEIActuallyAdditionsPlugin.COFFEE_MACHINE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTitle() {
|
||||
return Component.translatable("container.actuallyadditions.coffeeMachine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayoutBuilder builder, CoffeeIngredientRecipe recipe, IFocusGroup focuses) {
|
||||
builder.addSlot(RecipeIngredientRole.INPUT, 2, 39).addIngredients(Ingredient.of(ActuallyTags.Items.COFFEE_BEANS));
|
||||
builder.addSlot(RecipeIngredientRole.INPUT, 90, 21).addIngredients(recipe.getIngredient());
|
||||
builder.addSlot(RecipeIngredientRole.INPUT, 45, 39).addItemStack(new ItemStack(ActuallyItems.EMPTY_CUP.get()));
|
||||
|
||||
ItemStack output = new ItemStack(ActuallyItems.COFFEE_CUP.get());
|
||||
ActuallyAdditionsAPI.methodHandler.addRecipeEffectToStack(output, recipe);
|
||||
builder.addSlot(RecipeIngredientRole.OUTPUT, 45, 70).addItemStack(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(CoffeeIngredientRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) {
|
||||
IRecipeCategory.super.draw(recipe, recipeSlotsView, guiGraphics, mouseX, mouseY);
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (!Strings.isNullOrEmpty(recipe.getExtraText())) {
|
||||
guiGraphics.drawString(mc.font, Component.translatable("jei." + ActuallyAdditions.MODID + ".coffee.special").append( ":"), 2, 4, 4210752, false);
|
||||
guiGraphics.drawString(mc.font, I18n.get(recipe.getExtraText()), 2, 16, 4210752, false);
|
||||
}
|
||||
|
||||
if (recipe.getMaxAmplifier() > 0) {
|
||||
guiGraphics.drawString(mc.font, Component.translatable("jei." + ActuallyAdditions.MODID + ".coffee.maxAmount").append(": " + recipe.getMaxAmplifier()), 2, 28, 4210752, false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
|
|||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
|
@ -62,6 +63,29 @@ public class MethodHandler implements IMethodHandler {
|
|||
return worked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addRecipeEffectToStack(ItemStack stack, CoffeeIngredientRecipe ingredient) {
|
||||
boolean worked = false;
|
||||
if (ingredient != null) {
|
||||
List<MobEffectInstance> effects = ingredient.getEffects();
|
||||
if (!effects.isEmpty()) {
|
||||
for (MobEffectInstance effect : effects) {
|
||||
MobEffectInstance effectHas = this.getSameEffectFromStack(stack, effect);
|
||||
if (effectHas != null) {
|
||||
if (effectHas.getAmplifier() < ingredient.getMaxAmplifier() - 1) {
|
||||
this.addEffectProperties(stack, effect, false, true);
|
||||
worked = true;
|
||||
}
|
||||
} else {
|
||||
this.addEffectToStack(stack, effect);
|
||||
worked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return worked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MobEffectInstance getSameEffectFromStack(ItemStack stack, MobEffectInstance effect) {
|
||||
MobEffectInstance[] effectsStack = this.getEffectsFromStack(stack);
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyTags;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.AASounds;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoffeeMachine;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||
|
@ -31,6 +31,7 @@ import net.minecraft.world.entity.player.Inventory;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
@ -158,12 +159,12 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
|||
|
||||
@Override
|
||||
public IAcceptor getAcceptor() {
|
||||
return (slot, stack, automation) -> !automation || slot >= 3 && ItemCoffee.getIngredientFromStack(stack) != null || slot == SLOT_COFFEE_BEANS && stack.is(ActuallyTags.Items.COFFEE_BEANS) || slot == SLOT_INPUT && stack.getItem() == ActuallyItems.COFFEE_CUP.get();
|
||||
return (slot, stack, automation) -> !automation || slot >= 3 && ItemCoffee.getIngredientRecipeFromStack(stack) != null || slot == SLOT_COFFEE_BEANS && stack.is(ActuallyTags.Items.COFFEE_BEANS) || slot == SLOT_INPUT && stack.getItem() == ActuallyItems.COFFEE_CUP.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemover getRemover() {
|
||||
return (slot, automation) -> !automation || slot == SLOT_OUTPUT || slot >= 3 && slot < this.inv.getSlots() && ItemCoffee.getIngredientFromStack(this.inv.getStackInSlot(slot)) == null;
|
||||
return (slot, automation) -> !automation || slot == SLOT_OUTPUT || slot >= 3 && slot < this.inv.getSlots() && ItemCoffee.getIngredientRecipeFromStack(this.inv.getStackInSlot(slot)) == null;
|
||||
}
|
||||
|
||||
public void storeCoffee() {
|
||||
|
@ -195,9 +196,9 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
|||
ItemStack output = new ItemStack(ActuallyItems.COFFEE_BEANS.get());
|
||||
for (int i = 3; i < this.inv.getSlots(); i++) {
|
||||
if (StackUtil.isValid(this.inv.getStackInSlot(i))) {
|
||||
CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.inv.getStackInSlot(i));
|
||||
if (ingredient != null) {
|
||||
if (ingredient.effect(output)) {
|
||||
RecipeHolder<CoffeeIngredientRecipe> recipeHolder = ItemCoffee.getIngredientRecipeFromStack(this.inv.getStackInSlot(i));
|
||||
if (recipeHolder != null) {
|
||||
if (recipeHolder.value().effect(output)) {
|
||||
this.inv.setStackInSlot(i, StackUtil.shrinkForContainer(this.inv.getStackInSlot(i), 1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,5 +44,8 @@ public class ResourceReloader implements ResourceManagerReloadListener {
|
|||
|
||||
ActuallyAdditionsAPI.CRUSHER_RECIPES.clear();
|
||||
ActuallyAdditionsAPI.CRUSHER_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.CRUSHING.get()));
|
||||
|
||||
ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS.clear();
|
||||
ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.COFFEE_INGREDIENT.get()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -978,5 +978,9 @@
|
|||
"booklet.actuallyadditions.chapter.crystalClusters.text.1": "<item>Crystal Clusters<r> are blocks that generate naturally inside of <imp>Lush Caves<r>. <n>When broken, they <imp>drop<r> one or more <item>Crystal Shards<r> that can be crafted together to create <item>Crystals<r>. <n><item>Crystal Clusters<r> emit a bit of light, making them perfect for <imp>decoration<r>. To harvest them in their block form, <imp>Silk Touch<r> can be used.",
|
||||
"booklet.actuallyadditions.chapter.trialsIntro": "Intro to Trials",
|
||||
"booklet.actuallyadditions.chapter.trialsIntro.text.1": "<item>Trials<r> are a set of fun and interesting <imp>challenges<r> that you can use to <imp>get inspiration<r> on what to build next. <n>Once you <imp>complete<r> a <item>Trial<r>, you can <imp>press the button<r> in the bottom right to mark the trial as completed, turning its name in the list green. <n>Since there is <imp>no way to check<r> if a trial is actually completed, <item>Trials<r> are meant as <imp>personal goals<r>. <n><n>To <imp>visit<r> the <item>Trials<r> page, you can click the <imp>bookmark<r> in the <imp>top right<r> corner of the manual GUI.",
|
||||
"booklet.actuallyadditions.chapter.trialsIntro.text.2": "Note that <item>Trials<r> are designed in a way that they should be completed with the concepts of <imp>Minecraft<r> and <imp>Actually Additions<r> alone."
|
||||
"booklet.actuallyadditions.chapter.trialsIntro.text.2": "Note that <item>Trials<r> are designed in a way that they should be completed with the concepts of <imp>Minecraft<r> and <imp>Actually Additions<r> alone.",
|
||||
"_comment": "JEI",
|
||||
"jei.actuallyadditions.coffee.special": "Special Feature",
|
||||
"jei.actuallyadditions.coffee.maxAmount": "Max Amount",
|
||||
"jei.actuallyadditions.coffee.extra.milk": "+01:00, -1 Level"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue