JEI Integration: Spout and Drain

This commit is contained in:
simibubi 2020-11-13 20:56:39 +01:00
parent 103c1a7441
commit 9a7596286d
23 changed files with 541 additions and 39 deletions

View file

@ -393,16 +393,16 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
69f3eb168fafdc42a2cba5c5821eeb87dbcdbce7 assets/create/lang/en_ud.json
efc32f0591cbfb1c2c3e5119bab629fed04c6f1a assets/create/lang/en_us.json
3b9923c1a5cb59ef08b762e88f1c44c55348f551 assets/create/lang/unfinished/de_de.json
03ce43a553db3cb2b1d668a24028771275043014 assets/create/lang/unfinished/fr_fr.json
2779bb9bad72e6cfd8bfe6cd4ee2a1a13db1d5c7 assets/create/lang/unfinished/it_it.json
dc9efaab4de074be3c265a28ce173710a57d6df7 assets/create/lang/unfinished/ja_jp.json
e5e98067186ef92d140288fa096c9f7d4e9f64b3 assets/create/lang/unfinished/ko_kr.json
35707109ce7442f9ab8e188c75f3755c1f6373fe assets/create/lang/unfinished/nl_nl.json
92be279a0b85825ae52903bf213ea7fbcdfadaa1 assets/create/lang/unfinished/pt_br.json
990a59a78dea2887b4568c00a208bf19c8df9e61 assets/create/lang/unfinished/ru_ru.json
f55a881954595cde52362fb42e7e8d3cdd3a0ae8 assets/create/lang/unfinished/zh_cn.json
83a8328bc741c1414536cda04dd9851c6b62fafe assets/create/lang/en_us.json
30e9741d978aa10141b4173ee805ff73306479c7 assets/create/lang/unfinished/de_de.json
1179406deedf240244a3f1d2c46c5f50c5fd9d28 assets/create/lang/unfinished/fr_fr.json
c78ed168a8891e4b8689f7040d75b69886ec8624 assets/create/lang/unfinished/it_it.json
859806f0d375938e07db1bb64abddade04f3d54b assets/create/lang/unfinished/ja_jp.json
5cb7908df97c2080dd393a22da71409881cc2ae4 assets/create/lang/unfinished/ko_kr.json
87b31c690863eb570b90d83f612af0dd0069c0b0 assets/create/lang/unfinished/nl_nl.json
71aaab91d665a02decbb2230698311b34e3b6936 assets/create/lang/unfinished/pt_br.json
e88e4e5ad08f7b49ee08d5715d02eba1886b5bb0 assets/create/lang/unfinished/ru_ru.json
55655931d8773aab371710fb30b075005a8f34db assets/create/lang/unfinished/zh_cn.json
846200eb548d3bfa2e77b41039de159b4b6cfb45 assets/create/models/block/acacia_window.json
1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets/create/models/block/acacia_window_pane_noside.json
1763ea2c9b981d187f5031ba608f3d5d3be3986a assets/create/models/block/acacia_window_pane_noside_alt.json

View file

@ -585,6 +585,8 @@
"create.recipe.blockzapper_upgrade": "Handheld Blockzapper",
"create.recipe.sandpaper_polishing": "Sandpaper Polishing",
"create.recipe.mystery_conversion": "Mysterious Conversion",
"create.recipe.spout_filling": "Filling by Spout",
"create.recipe.draining": "Item Draining",
"create.recipe.processing.chance": "%1$s%% Chance",
"create.recipe.heat_requirement.none": "No Heating Required",
"create.recipe.heat_requirement.heated": "Heated",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1039",
"_": "Missing Localizations: 1041",
"_": "->------------------------] Game Elements [------------------------<-",
@ -586,6 +586,8 @@
"create.recipe.blockzapper_upgrade": "Blockpistole",
"create.recipe.sandpaper_polishing": "UNLOCALIZED: Sandpaper Polishing",
"create.recipe.mystery_conversion": "UNLOCALIZED: Mysterious Conversion",
"create.recipe.spout_filling": "UNLOCALIZED: Filling by Spout",
"create.recipe.draining": "UNLOCALIZED: Item Draining",
"create.recipe.processing.chance": "Chance: %1$s%%",
"create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required",
"create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 668",
"_": "Missing Localizations: 670",
"_": "->------------------------] Game Elements [------------------------<-",
@ -586,6 +586,8 @@
"create.recipe.blockzapper_upgrade": "Blockzappeur portable",
"create.recipe.sandpaper_polishing": "Polissage au papier de verre",
"create.recipe.mystery_conversion": "Métamorphose chromatique",
"create.recipe.spout_filling": "UNLOCALIZED: Filling by Spout",
"create.recipe.draining": "UNLOCALIZED: Item Draining",
"create.recipe.processing.chance": "%1$s%% de chance",
"create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required",
"create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 652",
"_": "Missing Localizations: 654",
"_": "->------------------------] Game Elements [------------------------<-",
@ -586,6 +586,8 @@
"create.recipe.blockzapper_upgrade": "UNLOCALIZED: Handheld Blockzapper",
"create.recipe.sandpaper_polishing": "Carta Vetrata Levigata",
"create.recipe.mystery_conversion": "Metamorfosi Cromatica",
"create.recipe.spout_filling": "UNLOCALIZED: Filling by Spout",
"create.recipe.draining": "UNLOCALIZED: Item Draining",
"create.recipe.processing.chance": "%1$s%% Possibilità",
"create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required",
"create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 651",
"_": "Missing Localizations: 653",
"_": "->------------------------] Game Elements [------------------------<-",
@ -586,6 +586,8 @@
"create.recipe.blockzapper_upgrade": "携帯型ブロックザッパー",
"create.recipe.sandpaper_polishing": "紙やすりでの研磨",
"create.recipe.mystery_conversion": "色彩変態",
"create.recipe.spout_filling": "UNLOCALIZED: Filling by Spout",
"create.recipe.draining": "UNLOCALIZED: Item Draining",
"create.recipe.processing.chance": "%1$s%%チャンス",
"create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required",
"create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 652",
"_": "Missing Localizations: 654",
"_": "->------------------------] Game Elements [------------------------<-",
@ -586,6 +586,8 @@
"create.recipe.blockzapper_upgrade": "UNLOCALIZED: Handheld Blockzapper",
"create.recipe.sandpaper_polishing": "사포 연마",
"create.recipe.mystery_conversion": "?",
"create.recipe.spout_filling": "UNLOCALIZED: Filling by Spout",
"create.recipe.draining": "UNLOCALIZED: Item Draining",
"create.recipe.processing.chance": "%1$s%% 확률",
"create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required",
"create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 980",
"_": "Missing Localizations: 982",
"_": "->------------------------] Game Elements [------------------------<-",
@ -586,6 +586,8 @@
"create.recipe.blockzapper_upgrade": "Blokzapper",
"create.recipe.sandpaper_polishing": "UNLOCALIZED: Sandpaper Polishing",
"create.recipe.mystery_conversion": "UNLOCALIZED: Mysterious Conversion",
"create.recipe.spout_filling": "UNLOCALIZED: Filling by Spout",
"create.recipe.draining": "UNLOCALIZED: Item Draining",
"create.recipe.processing.chance": "%1$s%% Kans",
"create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required",
"create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1046",
"_": "Missing Localizations: 1048",
"_": "->------------------------] Game Elements [------------------------<-",
@ -586,6 +586,8 @@
"create.recipe.blockzapper_upgrade": "Blockzapper Portátil",
"create.recipe.sandpaper_polishing": "UNLOCALIZED: Sandpaper Polishing",
"create.recipe.mystery_conversion": "UNLOCALIZED: Mysterious Conversion",
"create.recipe.spout_filling": "UNLOCALIZED: Filling by Spout",
"create.recipe.draining": "UNLOCALIZED: Item Draining",
"create.recipe.processing.chance": "%1$s%% de chance",
"create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required",
"create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 321",
"_": "Missing Localizations: 323",
"_": "->------------------------] Game Elements [------------------------<-",
@ -586,6 +586,8 @@
"create.recipe.blockzapper_upgrade": "Ручная блоковая пушка",
"create.recipe.sandpaper_polishing": "Полировка наждачной бумагой",
"create.recipe.mystery_conversion": "Хроматический метаморфоз",
"create.recipe.spout_filling": "UNLOCALIZED: Filling by Spout",
"create.recipe.draining": "UNLOCALIZED: Item Draining",
"create.recipe.processing.chance": "%1$s%% шанса",
"create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required",
"create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated",

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 334",
"_": "Missing Localizations: 336",
"_": "->------------------------] Game Elements [------------------------<-",
@ -586,6 +586,8 @@
"create.recipe.blockzapper_upgrade": "UNLOCALIZED: Handheld Blockzapper",
"create.recipe.sandpaper_polishing": "砂纸抛光",
"create.recipe.mystery_conversion": "化合物变异",
"create.recipe.spout_filling": "UNLOCALIZED: Filling by Spout",
"create.recipe.draining": "UNLOCALIZED: Item Draining",
"create.recipe.processing.chance": "%1$s%% 概率",
"create.recipe.heat_requirement.none": "UNLOCALIZED: No Heating Required",
"create.recipe.heat_requirement.heated": "UNLOCALIZED: Heated",

View file

@ -23,6 +23,7 @@ import com.simibubi.create.compat.jei.category.CrushingCategory;
import com.simibubi.create.compat.jei.category.FanBlastingCategory;
import com.simibubi.create.compat.jei.category.FanSmokingCategory;
import com.simibubi.create.compat.jei.category.FanWashingCategory;
import com.simibubi.create.compat.jei.category.ItemDrainCategory;
import com.simibubi.create.compat.jei.category.MechanicalCraftingCategory;
import com.simibubi.create.compat.jei.category.MillingCategory;
import com.simibubi.create.compat.jei.category.MixingCategory;
@ -32,8 +33,9 @@ import com.simibubi.create.compat.jei.category.PolishingCategory;
import com.simibubi.create.compat.jei.category.PressingCategory;
import com.simibubi.create.compat.jei.category.ProcessingViaFanCategory;
import com.simibubi.create.compat.jei.category.SawingCategory;
import com.simibubi.create.compat.jei.category.SpoutCategory;
import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity;
import com.simibubi.create.content.contraptions.fluids.potion.PotionMixingRecipeManager;
import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager;
import com.simibubi.create.content.contraptions.processing.BasinRecipe;
import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateScreen;
import com.simibubi.create.content.logistics.item.filter.AbstractFilterScreen;
@ -49,6 +51,7 @@ import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import mezz.jei.api.registration.ISubtypeRegistration;
import mezz.jei.api.runtime.IIngredientManager;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe;
@ -70,6 +73,7 @@ public class CreateJEI implements IModPlugin {
return ID;
}
public IIngredientManager ingredientManager;
final List<CreateRecipeCategory<?>> ALL = new ArrayList<>();
final CreateRecipeCategory<?>
@ -155,6 +159,18 @@ public class CreateJEI implements IModPlugin {
.recipeList(MysteriousItemConversionCategory::getRecipes)
.build(),
spoutFilling =
register("spout_filling", SpoutCategory::new).recipeList(() -> SpoutCategory.getRecipes(ingredientManager))
.recipes(AllRecipeTypes.FILLING)
.catalyst(AllBlocks.SPOUT::get)
.build(),
draining = register("draining", ItemDrainCategory::new)
.recipeList(() -> ItemDrainCategory.getRecipes(ingredientManager))
.recipes(AllRecipeTypes.EMPTYING)
.catalyst(AllBlocks.ITEM_DRAIN::get)
.build(),
autoShaped = register("automatic_shaped", MechanicalCraftingCategory::new)
.recipes(
r -> (r.getType() == IRecipeType.CRAFTING && r.getType() != AllRecipeTypes.MECHANICAL_CRAFTING.type)
@ -187,6 +203,7 @@ public class CreateJEI implements IModPlugin {
@Override
public void registerRecipes(IRecipeRegistration registration) {
ingredientManager = registration.getIngredientManager();
ALL.forEach(c -> c.recipes.forEach(s -> registration.addRecipes(s.get(), c.getUid())));
}
@ -213,9 +230,10 @@ public class CreateJEI implements IModPlugin {
}
CategoryBuilder<T> catalyst(Supplier<IItemProvider> supplier) {
return catalystStack(() -> new ItemStack(supplier.get().asItem()));
return catalystStack(() -> new ItemStack(supplier.get()
.asItem()));
}
CategoryBuilder<T> catalystStack(Supplier<ItemStack> supplier) {
category.recipeCatalysts.add(supplier);
return this;

View file

@ -139,19 +139,6 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
}
}
public List<FluidStack> withImprovedVisibility(List<FluidStack> stacks) {
return stacks.stream()
.map(this::withImprovedVisibility)
.collect(Collectors.toList());
}
public FluidStack withImprovedVisibility(FluidStack stack) {
FluidStack display = stack.copy();
int displayedAmount = (int) (stack.getAmount() * .75f) + 250;
display.setAmount(displayedAmount);
return display;
}
@Override
public void draw(BasinRecipe recipe, double mouseX, double mouseY) {
List<Pair<Ingredient, MutableInt>> actualIngredients = ItemHelper.condenseIngredients(recipe.getIngredients());

View file

@ -106,6 +106,19 @@ public abstract class CreateRecipeCategory<T extends IRecipe<?>> implements IRec
TextFormatting.GOLD + Lang.translate("recipe.processing.chance", (int) (output.getChance() * 100)));
});
}
public List<FluidStack> withImprovedVisibility(List<FluidStack> stacks) {
return stacks.stream()
.map(this::withImprovedVisibility)
.collect(Collectors.toList());
}
public FluidStack withImprovedVisibility(FluidStack stack) {
FluidStack display = stack.copy();
int displayedAmount = (int) (stack.getAmount() * .75f) + 250;
display.setAmount(displayedAmount);
return display;
}
protected static void addFluidTooltip(IGuiFluidStackGroup fluidStacks, List<FluidIngredient> inputs,
List<FluidStack> outputs) {

View file

@ -0,0 +1,137 @@
package com.simibubi.create.compat.jei.category;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.Create;
import com.simibubi.create.compat.jei.category.animations.AnimatedItemDrain;
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler;
import com.simibubi.create.content.contraptions.processing.EmptyingRecipe;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.ingredient.IGuiFluidStackGroup;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.runtime.IIngredientManager;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.PotionItem;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
AnimatedItemDrain drain;
public ItemDrainCategory() {
super(doubleItemIcon(AllBlocks.ITEM_DRAIN.get(), Items.WATER_BUCKET), emptyBackground(177, 50));
drain = new AnimatedItemDrain();
}
public static List<EmptyingRecipe> getRecipes(IIngredientManager ingredientManager) {
List<EmptyingRecipe> recipes = new ArrayList<>();
ingredientManager.getAllIngredients(VanillaTypes.ITEM)
.stream()
.forEach(stack -> {
if (stack.getItem() instanceof PotionItem) {
FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack);
Ingredient potion = Ingredient.fromStacks(stack);
recipes.add(new ProcessingRecipeBuilder<>(EmptyingRecipe::new, Create.asResource("potions"))
.withItemIngredients(potion)
.withFluidOutputs(fluidFromPotionItem)
.withSingleItemOutput(new ItemStack(Items.GLASS_BOTTLE))
.build());
return;
}
LazyOptional<IFluidHandlerItem> capability =
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
if (!capability.isPresent())
return;
ItemStack copy = stack.copy();
capability = copy.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
IFluidHandlerItem handler = capability.orElse(null);
FluidStack extracted = handler.drain(1000, FluidAction.EXECUTE);
ItemStack result = handler.getContainer();
if (extracted.isEmpty())
return;
Ingredient ingredient = Ingredient.fromStacks(stack);
ResourceLocation itemName = stack.getItem()
.getRegistryName();
ResourceLocation fluidName = extracted.getFluid()
.getRegistryName();
recipes.add(new ProcessingRecipeBuilder<>(EmptyingRecipe::new,
Create.asResource("empty_" + itemName.getNamespace() + "_" + itemName.getPath() + "_of_"
+ fluidName.getNamespace() + "_" + fluidName.getPath())).withItemIngredients(ingredient)
.withFluidOutputs(extracted)
.withSingleItemOutput(result)
.build());
});
return recipes;
}
@Override
public Class<? extends EmptyingRecipe> getRecipeClass() {
return EmptyingRecipe.class;
}
@Override
public void setIngredients(EmptyingRecipe recipe, IIngredients ingredients) {
ingredients.setInputIngredients(recipe.getIngredients());
if (!recipe.getRollableResults()
.isEmpty())
ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput());
if (!recipe.getFluidResults()
.isEmpty())
ingredients.setOutputs(VanillaTypes.FLUID, recipe.getFluidResults());
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, EmptyingRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
FluidStack fluidOutput = recipe.getResultingFluid();
List<ItemStack> matchingIngredients = Arrays.asList(recipe.getIngredients()
.get(0)
.getMatchingStacks());
fluidStacks.init(0, true, 132, 8);
fluidStacks.set(0, withImprovedVisibility(fluidOutput));
itemStacks.init(0, true, 26, 7);
itemStacks.set(0, matchingIngredients);
itemStacks.init(1, false, 131, 26);
itemStacks.set(1, recipe.getRecipeOutput());
addFluidTooltip(fluidStacks, Collections.emptyList(), ImmutableList.of(fluidOutput));
}
@Override
public void draw(EmptyingRecipe recipe, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(131, 7);
AllGuiTextures.JEI_SLOT.draw(26, 7);
getRenderedSlot(recipe, 0).draw(131, 26);
AllGuiTextures.JEI_SHADOW.draw(62, 37);
AllGuiTextures.JEI_DOWN_ARROW.draw(73, 4);
drain.withFluid(recipe.getResultingFluid())
.draw(getBackground().getWidth() / 2 - 13, 40);
}
}

View file

@ -0,0 +1,151 @@
package com.simibubi.create.compat.jei.category;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.Create;
import com.simibubi.create.compat.jei.category.animations.AnimatedSpout;
import com.simibubi.create.content.contraptions.fluids.actors.FillingRecipe;
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder;
import com.simibubi.create.foundation.fluid.FluidIngredient;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.ingredient.IGuiFluidStackGroup;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.runtime.IIngredientManager;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.PotionItem;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
AnimatedSpout spout;
public SpoutCategory() {
super(doubleItemIcon(AllBlocks.SPOUT.get(), Items.WATER_BUCKET), emptyBackground(177, 70));
spout = new AnimatedSpout();
}
public static List<FillingRecipe> getRecipes(IIngredientManager ingredientManager) {
List<FillingRecipe> recipes = new ArrayList<>();
ingredientManager.getAllIngredients(VanillaTypes.ITEM)
.stream()
.forEach(stack -> {
if (stack.getItem() instanceof PotionItem) {
FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack);
Ingredient bottle = Ingredient.fromItems(Items.GLASS_BOTTLE);
recipes.add(new ProcessingRecipeBuilder<>(FillingRecipe::new, Create.asResource("potions"))
.withItemIngredients(bottle)
.withFluidIngredients(FluidIngredient.fromFluidStack(fluidFromPotionItem))
.withSingleItemOutput(stack)
.build());
return;
}
LazyOptional<IFluidHandlerItem> capability =
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
if (!capability.isPresent())
return;
ingredientManager.getAllIngredients(VanillaTypes.FLUID)
.stream()
.forEach(fluidStack -> {
ItemStack copy = stack.copy();
copy.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY)
.ifPresent(fhi -> {
FluidStack fluidCopy = fluidStack.copy();
fluidCopy.setAmount(1000);
fhi.fill(fluidCopy, FluidAction.EXECUTE);
ItemStack container = fhi.getContainer();
if (container.isItemEqual(copy))
return;
Ingredient bucket = Ingredient.fromStacks(stack);
ResourceLocation itemName = stack.getItem()
.getRegistryName();
ResourceLocation fluidName = fluidCopy.getFluid()
.getRegistryName();
recipes.add(new ProcessingRecipeBuilder<>(FillingRecipe::new,
Create.asResource("fill_" + itemName.getNamespace() + "_" + itemName.getPath()
+ "_with_" + fluidName.getNamespace() + "_" + fluidName.getPath()))
.withItemIngredients(bucket)
.withFluidIngredients(FluidIngredient.fromFluidStack(fluidCopy))
.withSingleItemOutput(container)
.build());
});
});
});
return recipes;
}
@Override
public Class<? extends FillingRecipe> getRecipeClass() {
return FillingRecipe.class;
}
@Override
public void setIngredients(FillingRecipe recipe, IIngredients ingredients) {
ingredients.setInputIngredients(recipe.getIngredients());
ingredients.setInputLists(VanillaTypes.FLUID, recipe.getFluidIngredients()
.stream()
.map(FluidIngredient::getMatchingFluidStacks)
.collect(Collectors.toList()));
if (!recipe.getRollableResults()
.isEmpty())
ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput());
if (!recipe.getFluidResults()
.isEmpty())
ingredients.setOutputs(VanillaTypes.FLUID, recipe.getFluidResults());
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, FillingRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
FluidIngredient fluidIngredient = recipe.getRequiredFluid();
List<ItemStack> matchingIngredients = Arrays.asList(recipe.getIngredients()
.get(0)
.getMatchingStacks());
fluidStacks.init(0, true, 27, 32);
fluidStacks.set(0, withImprovedVisibility(fluidIngredient.getMatchingFluidStacks()));
itemStacks.init(0, true, 26, 50);
itemStacks.set(0, matchingIngredients);
itemStacks.init(1, false, 131, 50);
itemStacks.set(1, recipe.getRecipeOutput());
addFluidTooltip(fluidStacks, ImmutableList.of(fluidIngredient), Collections.emptyList());
}
@Override
public void draw(FillingRecipe recipe, double mouseX, double mouseY) {
AllGuiTextures.JEI_SLOT.draw(26, 31);
AllGuiTextures.JEI_SLOT.draw(26, 50);
getRenderedSlot(recipe, 0).draw(131, 50);
AllGuiTextures.JEI_SHADOW.draw(62, 57);
AllGuiTextures.JEI_DOWN_ARROW.draw(126, 29);
spout.withFluids(recipe.getRequiredFluid()
.getMatchingFluidStacks())
.draw(getBackground().getWidth() / 2 - 13, 22);
}
}

View file

@ -0,0 +1,46 @@
package com.simibubi.create.compat.jei.category.animations;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.fluid.FluidRenderer;
import com.simibubi.create.foundation.gui.GuiGameElement;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
import net.minecraft.client.renderer.Tessellator;
import net.minecraftforge.fluids.FluidStack;
public class AnimatedItemDrain extends AnimatedKinetics {
private FluidStack fluid;
public AnimatedItemDrain withFluid(FluidStack fluid) {
this.fluid = fluid;
return this;
}
@Override
public void draw(int xOffset, int yOffset) {
RenderSystem.pushMatrix();
RenderSystem.translatef(xOffset, yOffset, 100);
RenderSystem.rotatef(-15.5f, 1, 0, 0);
RenderSystem.rotatef(22.5f, 0, 1, 0);
int scale = 20;
GuiGameElement.of(AllBlocks.ITEM_DRAIN.getDefaultState())
.scale(scale)
.render();
Impl buffer = IRenderTypeBuffer.immediate(Tessellator.getInstance()
.getBuffer());
MatrixStack ms = new MatrixStack();
ms.scale(scale, -scale, scale);
float from = 2/16f;
float to = 1f - from;
FluidRenderer.renderTiledFluidBB(fluid, from, from, from, to, 3/4f, to, buffer, ms, 0xf000f0, false);
buffer.draw();
RenderSystem.popMatrix();
}
}

View file

@ -0,0 +1,90 @@
package com.simibubi.create.compat.jei.category.animations;
import static com.simibubi.create.foundation.utility.AnimationTickHolder.ticks;
import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.fluid.FluidRenderer;
import com.simibubi.create.foundation.gui.GuiGameElement;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fluids.FluidStack;
public class AnimatedSpout extends AnimatedKinetics {
private List<FluidStack> fluids;
public AnimatedSpout withFluids(List<FluidStack> fluids) {
this.fluids = fluids;
return this;
}
@Override
public void draw(int xOffset, int yOffset) {
RenderSystem.pushMatrix();
RenderSystem.translatef(xOffset, yOffset, 100);
RenderSystem.rotatef(-15.5f, 1, 0, 0);
RenderSystem.rotatef(22.5f, 0, 1, 0);
int scale = 20;
GuiGameElement.of(AllBlocks.SPOUT.getDefaultState())
.scale(scale)
.render();
float cycle = (ticks + Minecraft.getInstance()
.getRenderPartialTicks()) % 30;
float squeeze = cycle < 20 ? MathHelper.sin((float) (cycle / 20f * Math.PI)) : 0;
squeeze *= 20;
RenderSystem.pushMatrix();
GuiGameElement.of(AllBlockPartials.SPOUT_TOP)
.scale(scale)
.render();
RenderSystem.translatef(0, -3 * squeeze / 32f, 0);
GuiGameElement.of(AllBlockPartials.SPOUT_MIDDLE)
.scale(scale)
.render();
RenderSystem.translatef(0, -3 * squeeze / 32f, 0);
GuiGameElement.of(AllBlockPartials.SPOUT_BOTTOM)
.scale(scale)
.render();
RenderSystem.translatef(0, -3 * squeeze / 32f, 0);
RenderSystem.popMatrix();
GuiGameElement.of(AllBlocks.DEPOT.getDefaultState())
.atLocal(0, 2, 0)
.scale(scale)
.render();
Impl buffer = IRenderTypeBuffer.immediate(Tessellator.getInstance()
.getBuffer());
MatrixStack ms = new MatrixStack();
ms.push();
ms.scale(16, -16, 16);
float from = 2/16f;
float to = 1f - from;
FluidRenderer.renderTiledFluidBB(fluids.get(0), from, from, from, to, to, to, buffer, ms, 0xf000f0, false);
ms.pop();
float width = 1 / 128f * squeeze;
ms.translate(scale / 2f, scale * 1.5f, scale / 2f);
ms.scale(16, -16, 16);
ms.translate(-width / 2, 0, -width / 2);
FluidRenderer.renderTiledFluidBB(fluids.get(0), 0, -0.001f, 0, width, 2.001f, width, buffer, ms, 0xf000f0,
false);
buffer.draw();
RenderSystem.popMatrix();
}
}

View file

@ -6,7 +6,7 @@ import java.util.Optional;
import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity;
import com.simibubi.create.content.contraptions.fluids.FluidFX;
import com.simibubi.create.content.contraptions.fluids.potion.PotionMixingRecipeManager;
import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager;
import com.simibubi.create.content.contraptions.processing.BasinOperatingTileEntity;
import com.simibubi.create.content.contraptions.processing.BasinTileEntity;
import com.simibubi.create.foundation.advancement.AllTriggers;

View file

@ -0,0 +1,35 @@
package com.simibubi.create.content.contraptions.fluids.recipe;
import java.util.ArrayList;
import java.util.List;
import com.simibubi.create.content.contraptions.fluids.actors.FillingRecipe;
import net.minecraft.client.resources.ReloadListener;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.IProfiler;
import net.minecraft.resources.IResourceManager;
public class FluidTransferRecipes {
public static List<ItemStack> POTION_ITEMS = new ArrayList<>();
public static List<Item> FILLED_BUCKETS = new ArrayList<>();
public static final ReloadListener<Object> LISTENER = new ReloadListener<Object>() {
@Override
protected Object prepare(IResourceManager p_212854_1_, IProfiler p_212854_2_) {
return new Object();
}
@Override
protected void apply(Object p_212853_1_, IResourceManager p_212853_2_, IProfiler p_212853_3_) {
POTION_ITEMS.clear();
FILLED_BUCKETS.clear();
}
};
}

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.contraptions.fluids.potion;
package com.simibubi.create.content.contraptions.fluids.recipe;
import java.util.ArrayList;
import java.util.Collection;
@ -11,6 +11,7 @@ import java.util.stream.Collectors;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.mixer.MixingRecipe;
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler;
import com.simibubi.create.content.contraptions.processing.HeatCondition;
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder;
import com.simibubi.create.foundation.fluid.FluidIngredient;
@ -34,7 +35,7 @@ import net.minecraftforge.registries.ForgeRegistries;
public class PotionMixingRecipeManager {
public static Map<Item, List<MixingRecipe>> ALL = new HashMap<>();
public static List<MixingRecipe> getAllBrewingRecipes() {
List<MixingRecipe> mixingRecipes = new ArrayList<>();

View file

@ -4,7 +4,8 @@ import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler;
import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingPhysics;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController;
import com.simibubi.create.content.contraptions.fluids.potion.PotionMixingRecipeManager;
import com.simibubi.create.content.contraptions.fluids.recipe.FluidTransferRecipes;
import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipeManager;
import com.simibubi.create.content.contraptions.wrench.WrenchItem;
import com.simibubi.create.content.schematics.ServerSchematicLoader;
import com.simibubi.create.foundation.command.AllCommands;
@ -93,6 +94,7 @@ public class CommonEvents {
.getResourceManager();
resourceManager.addReloadListener(RecipeFinder.LISTENER);
resourceManager.addReloadListener(PotionMixingRecipeManager.LISTENER);
resourceManager.addReloadListener(FluidTransferRecipes.LISTENER);
}
@SubscribeEvent

View file

@ -33,6 +33,8 @@
"create.recipe.blockzapper_upgrade": "Handheld Blockzapper",
"create.recipe.sandpaper_polishing": "Sandpaper Polishing",
"create.recipe.mystery_conversion": "Mysterious Conversion",
"create.recipe.spout_filling": "Filling by Spout",
"create.recipe.draining": "Item Draining",
"create.recipe.processing.chance": "%1$s%% Chance",
"create.recipe.heat_requirement.none": "No Heating Required",