Update JEI integration and add potion fluids to the ingredient list (#6934)

* Update JEI integration and add potion fluids to the ingredient list

This also resolves a minor issue where all virtual fluids were considered "flowing".
Fixes https://github.com/mezz/JustEnoughItems/issues/3754

* Fixed JEI potion fluids registered without Bottle tag

---------

Co-authored-by: goshante <admin@drulia.ru>
This commit is contained in:
James Mitchell 2025-01-26 13:36:17 -10:00 committed by GitHub
parent 7a7993deb8
commit 28d30f3c62
Failed to generate hash of commit
22 changed files with 105 additions and 55 deletions

View file

@ -25,7 +25,7 @@ registrate_version = MC1.20-1.3.3
flywheel_minecraft_version = 1.20.1 flywheel_minecraft_version = 1.20.1
flywheel_version = 1.0.0-beta-145 flywheel_version = 1.0.0-beta-145
jei_minecraft_version = 1.20.1 jei_minecraft_version = 1.20.1
jei_version = 15.10.0.39 jei_version = 15.19.0.85
curios_minecraft_version = 1.20.1 curios_minecraft_version = 1.20.1
curios_version = 5.3.1 curios_version = 5.3.1

View file

@ -7,6 +7,8 @@ import java.util.function.Supplier;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.simibubi.create.content.fluids.VirtualFluid;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.joml.Vector3f; import org.joml.Vector3f;
@ -14,7 +16,6 @@ import com.mojang.blaze3d.shaders.FogShape;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllTags.AllFluidTags; import com.simibubi.create.AllTags.AllFluidTags;
import com.simibubi.create.content.decoration.palettes.AllPaletteStoneTypes; import com.simibubi.create.content.decoration.palettes.AllPaletteStoneTypes;
import com.simibubi.create.content.fluids.VirtualFluid;
import com.simibubi.create.content.fluids.potion.PotionFluid; import com.simibubi.create.content.fluids.potion.PotionFluid;
import com.simibubi.create.content.fluids.potion.PotionFluid.PotionFluidType; import com.simibubi.create.content.fluids.potion.PotionFluid.PotionFluidType;
import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Color;
@ -46,7 +47,7 @@ public class AllFluids {
} }
public static final FluidEntry<PotionFluid> POTION = public static final FluidEntry<PotionFluid> POTION =
REGISTRATE.virtualFluid("potion", PotionFluidType::new, PotionFluid::new) REGISTRATE.virtualFluid("potion", PotionFluidType::new, PotionFluid::createSource, PotionFluid::createFlowing)
.lang("Potion") .lang("Potion")
.register(); .register();

View file

@ -78,6 +78,7 @@ import mezz.jei.api.forge.ForgeTypes;
import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IPlatformFluidHelper; import mezz.jei.api.helpers.IPlatformFluidHelper;
import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.recipe.category.IRecipeCategory;
import mezz.jei.api.registration.IExtraIngredientRegistration;
import mezz.jei.api.registration.IGuiHandlerRegistration; import mezz.jei.api.registration.IGuiHandlerRegistration;
import mezz.jei.api.registration.IRecipeCatalystRegistration; import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration; import mezz.jei.api.registration.IRecipeCategoryRegistration;
@ -90,6 +91,7 @@ import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.AbstractCookingRecipe;
import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.Recipe;
@ -98,7 +100,9 @@ import net.minecraft.world.item.crafting.SmokingRecipe;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.crafting.IShapedRecipe; import net.minecraftforge.common.crafting.IShapedRecipe;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModList;
import net.minecraftforge.registries.ForgeRegistries;
@JeiPlugin @JeiPlugin
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -363,6 +367,22 @@ public class CreateJEI implements IModPlugin {
registration.registerSubtypeInterpreter(ForgeTypes.FLUID_STACK, potionFluid.getFlowing(), interpreter); registration.registerSubtypeInterpreter(ForgeTypes.FLUID_STACK, potionFluid.getFlowing(), interpreter);
} }
@Override
public void registerExtraIngredients(IExtraIngredientRegistration registration) {
Collection<Potion> potions = ForgeRegistries.POTIONS.getValues();
Collection<FluidStack> potionFluids = new ArrayList<>(potions.size() * 3);
for (Potion potion : potions) {
// @goshante: Ingame potion fluids always have Bottle tag that specifies
// to what bottle type this potion belongs
// Potion fluid without this tag wouldn't be recognized by other mods
for (PotionFluid.BottleType bottleType : PotionFluid.BottleType.values()) {
FluidStack potionFluid = PotionFluid.of(1000, potion, bottleType);
potionFluids.add(potionFluid);
}
}
registration.addExtraIngredients(ForgeTypes.FLUID_STACK, potionFluids);
}
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void registerGuiHandlers(IGuiHandlerRegistration registration) { public void registerGuiHandlers(IGuiHandlerRegistration registration) {

View file

@ -67,7 +67,7 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
.addSlot(RecipeIngredientRole.INPUT, 17 + xOffset + (i % 3) * 19, 51 - (i / 3) * 19) .addSlot(RecipeIngredientRole.INPUT, 17 + xOffset + (i % 3) * 19, 51 - (i / 3) * 19)
.setBackground(getRenderedSlot(), -1, -1) .setBackground(getRenderedSlot(), -1, -1)
.addIngredients(ForgeTypes.FLUID_STACK, withImprovedVisibility(fluidIngredient.getMatchingFluidStacks())) .addIngredients(ForgeTypes.FLUID_STACK, withImprovedVisibility(fluidIngredient.getMatchingFluidStacks()))
.addTooltipCallback(addFluidTooltip(fluidIngredient.getRequiredAmount())); .addRichTooltipCallback(addFluidTooltip(fluidIngredient.getRequiredAmount()));
i++; i++;
} }
@ -82,7 +82,7 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
.addSlot(RecipeIngredientRole.OUTPUT, xPosition, yPosition) .addSlot(RecipeIngredientRole.OUTPUT, xPosition, yPosition)
.setBackground(getRenderedSlot(result), -1, -1) .setBackground(getRenderedSlot(result), -1, -1)
.addItemStack(result.getStack()) .addItemStack(result.getStack())
.addTooltipCallback(addStochasticTooltip(result)); .addRichTooltipCallback(addStochasticTooltip(result));
i++; i++;
} }
@ -94,7 +94,7 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
.addSlot(RecipeIngredientRole.OUTPUT, xPosition, yPosition) .addSlot(RecipeIngredientRole.OUTPUT, xPosition, yPosition)
.setBackground(getRenderedSlot(), -1, -1) .setBackground(getRenderedSlot(), -1, -1)
.addIngredient(ForgeTypes.FLUID_STACK, withImprovedVisibility(fluidResult)) .addIngredient(ForgeTypes.FLUID_STACK, withImprovedVisibility(fluidResult))
.addTooltipCallback(addFluidTooltip(fluidResult.getAmount())); .addRichTooltipCallback(addFluidTooltip(fluidResult.getAmount()));
i++; i++;
} }

View file

@ -8,6 +8,8 @@ import java.util.stream.Collectors;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
import mezz.jei.api.gui.ingredient.IRecipeSlotRichTooltipCallback;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import com.simibubi.create.AllFluids; import com.simibubi.create.AllFluids;
@ -108,11 +110,11 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
return recipe.getResultItem(level.registryAccess()); return recipe.getResultItem(level.registryAccess());
} }
public static IRecipeSlotTooltipCallback addStochasticTooltip(ProcessingOutput output) { public static IRecipeSlotRichTooltipCallback addStochasticTooltip(ProcessingOutput output) {
return (view, tooltip) -> { return (view, tooltip) -> {
float chance = output.getChance(); float chance = output.getChance();
if (chance != 1) if (chance != 1)
tooltip.add(1, Lang.translateDirect("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100)) tooltip.add(Lang.translateDirect("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100))
.withStyle(ChatFormatting.GOLD)); .withStyle(ChatFormatting.GOLD));
}; };
} }
@ -130,11 +132,11 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
return display; return display;
} }
public static IRecipeSlotTooltipCallback addFluidTooltip() { public static IRecipeSlotRichTooltipCallback addFluidTooltip() {
return addFluidTooltip(-1); return addFluidTooltip(-1);
} }
public static IRecipeSlotTooltipCallback addFluidTooltip(int mbAmount) { public static IRecipeSlotRichTooltipCallback addFluidTooltip(int mbAmount) {
return (view, tooltip) -> { return (view, tooltip) -> {
Optional<FluidStack> displayed = view.getDisplayedIngredient(ForgeTypes.FLUID_STACK); Optional<FluidStack> displayed = view.getDisplayedIngredient(ForgeTypes.FLUID_STACK);
if (displayed.isEmpty()) if (displayed.isEmpty())
@ -143,26 +145,14 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
FluidStack fluidStack = displayed.get(); FluidStack fluidStack = displayed.get();
if (fluidStack.getFluid().isSame(AllFluids.POTION.get())) { if (fluidStack.getFluid().isSame(AllFluids.POTION.get())) {
Component name = fluidStack.getDisplayName();
if (tooltip.isEmpty())
tooltip.add(0, name);
else
tooltip.set(0, name);
ArrayList<Component> potionTooltip = new ArrayList<>(); ArrayList<Component> potionTooltip = new ArrayList<>();
PotionFluidHandler.addPotionTooltip(fluidStack, potionTooltip, 1); PotionFluidHandler.addPotionTooltip(fluidStack, potionTooltip, 1);
tooltip.addAll(1, potionTooltip.stream().toList()); tooltip.addAll(potionTooltip.stream().toList());
} }
int amount = mbAmount == -1 ? fluidStack.getAmount() : mbAmount; int amount = mbAmount == -1 ? fluidStack.getAmount() : mbAmount;
Component text = Components.literal(String.valueOf(amount)).append(Lang.translateDirect("generic.unit.millibuckets")).withStyle(ChatFormatting.GOLD); Component text = Components.literal(String.valueOf(amount)).append(Lang.translateDirect("generic.unit.millibuckets")).withStyle(ChatFormatting.GOLD);
if (tooltip.isEmpty()) tooltip.add(text);
tooltip.add(0, text);
else {
List<Component> siblings = tooltip.get(0).getSiblings();
siblings.add(Components.literal(" "));
siblings.add(text);
}
}; };
} }

View file

@ -41,7 +41,7 @@ public class CrushingCategory extends CreateRecipeCategory<AbstractCrushingRecip
.addSlot(RecipeIngredientRole.OUTPUT, (xOffset) + layoutEntry.posX() + 1, yOffset + layoutEntry.posY() + 1) .addSlot(RecipeIngredientRole.OUTPUT, (xOffset) + layoutEntry.posX() + 1, yOffset + layoutEntry.posY() + 1)
.setBackground(getRenderedSlot(layoutEntry.output()), -1, -1) .setBackground(getRenderedSlot(layoutEntry.output()), -1, -1)
.addItemStack(layoutEntry.output().getStack()) .addItemStack(layoutEntry.output().getStack())
.addTooltipCallback(addStochasticTooltip(layoutEntry.output())) .addRichTooltipCallback(addStochasticTooltip(layoutEntry.output()))
); );
} }

View file

@ -47,7 +47,7 @@ public class DeployingCategory extends CreateRecipeCategory<DeployerApplicationR
builder.addSlot(RecipeIngredientRole.OUTPUT, single ? 132 : 132 + xOffset, 51 + yOffset) builder.addSlot(RecipeIngredientRole.OUTPUT, single ? 132 : 132 + xOffset, 51 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1) .setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack()) .addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output)); .addRichTooltipCallback(addStochasticTooltip(output));
} }
if (recipe.shouldKeepHeldItem()) if (recipe.shouldKeepHeldItem())

View file

@ -58,7 +58,7 @@ public class ItemApplicationCategory extends CreateRecipeCategory<ItemApplicatio
builder.addSlot(RecipeIngredientRole.OUTPUT, single ? 132 : 132 + xOffset, 38 + yOffset) builder.addSlot(RecipeIngredientRole.OUTPUT, single ? 132 : 132 + xOffset, 38 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1) .setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack()) .addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output)); .addRichTooltipCallback(addStochasticTooltip(output));
} }
} }

View file

@ -100,7 +100,7 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
.addSlot(RecipeIngredientRole.OUTPUT, 132, 8) .addSlot(RecipeIngredientRole.OUTPUT, 132, 8)
.setBackground(getRenderedSlot(), -1, -1) .setBackground(getRenderedSlot(), -1, -1)
.addIngredient(ForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getResultingFluid())) .addIngredient(ForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getResultingFluid()))
.addTooltipCallback(addFluidTooltip(recipe.getResultingFluid().getAmount())); .addRichTooltipCallback(addFluidTooltip(recipe.getResultingFluid().getAmount()));
builder builder
.addSlot(RecipeIngredientRole.OUTPUT, 132, 27) .addSlot(RecipeIngredientRole.OUTPUT, 132, 27)
.setBackground(getRenderedSlot(), -1, -1) .setBackground(getRenderedSlot(), -1, -1)

View file

@ -42,7 +42,7 @@ public class MillingCategory extends CreateRecipeCategory<AbstractCrushingRecipe
.addSlot(RecipeIngredientRole.OUTPUT, single ? 139 : 133 + xOffset, 27 + yOffset) .addSlot(RecipeIngredientRole.OUTPUT, single ? 139 : 133 + xOffset, 27 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1) .setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack()) .addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output)); .addRichTooltipCallback(addStochasticTooltip(output));
i++; i++;
} }

View file

@ -40,7 +40,7 @@ public class PolishingCategory extends CreateRecipeCategory<SandPaperPolishingRe
.addSlot(RecipeIngredientRole.OUTPUT, 132, 29) .addSlot(RecipeIngredientRole.OUTPUT, 132, 29)
.setBackground(getRenderedSlot(output), -1, -1) .setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack()) .addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output)); .addRichTooltipCallback(addStochasticTooltip(output));
} }
@Override @Override

View file

@ -37,7 +37,7 @@ public class PressingCategory extends CreateRecipeCategory<PressingRecipe> {
builder.addSlot(RecipeIngredientRole.OUTPUT, 131 + 19 * i, 50) builder.addSlot(RecipeIngredientRole.OUTPUT, 131 + 19 * i, 50)
.setBackground(getRenderedSlot(output), -1, -1) .setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack()) .addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output)); .addRichTooltipCallback(addStochasticTooltip(output));
i++; i++;
} }
} }

View file

@ -117,7 +117,7 @@ public abstract class ProcessingViaFanCategory<T extends Recipe<?>> extends Crea
.addSlot(RecipeIngredientRole.OUTPUT, 141 + xOffset, 48 + yOffset) .addSlot(RecipeIngredientRole.OUTPUT, 141 + xOffset, 48 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1) .setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack()) .addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output)); .addRichTooltipCallback(addStochasticTooltip(output));
i++; i++;
} }
} }

View file

@ -40,7 +40,7 @@ public class SawingCategory extends CreateRecipeCategory<CuttingRecipe> {
.addSlot(RecipeIngredientRole.OUTPUT, 118 + xOffset, 48 + yOffset) .addSlot(RecipeIngredientRole.OUTPUT, 118 + xOffset, 48 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1) .setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack()) .addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output)); .addRichTooltipCallback(addStochasticTooltip(output));
i++; i++;
} }
} }

View file

@ -112,7 +112,7 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
.addSlot(RecipeIngredientRole.INPUT, 27, 32) .addSlot(RecipeIngredientRole.INPUT, 27, 32)
.setBackground(getRenderedSlot(), -1, -1) .setBackground(getRenderedSlot(), -1, -1)
.addIngredients(ForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getRequiredFluid().getMatchingFluidStacks())) .addIngredients(ForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getRequiredFluid().getMatchingFluidStacks()))
.addTooltipCallback(addFluidTooltip(recipe.getRequiredFluid().getRequiredAmount())); .addRichTooltipCallback(addFluidTooltip(recipe.getRequiredFluid().getRequiredAmount()));
builder builder
.addSlot(RecipeIngredientRole.OUTPUT, 132, 51) .addSlot(RecipeIngredientRole.OUTPUT, 132, 51)
.setBackground(getRenderedSlot(), -1, -1) .setBackground(getRenderedSlot(), -1, -1)

View file

@ -76,7 +76,7 @@ public abstract class SequencedAssemblySubCategory {
.addSlot(RecipeIngredientRole.INPUT, x + 4, 15) .addSlot(RecipeIngredientRole.INPUT, x + 4, 15)
.setBackground(CreateRecipeCategory.getRenderedSlot(), -1, -1) .setBackground(CreateRecipeCategory.getRenderedSlot(), -1, -1)
.addIngredients(ForgeTypes.FLUID_STACK, CreateRecipeCategory.withImprovedVisibility(fluidIngredient.getMatchingFluidStacks())) .addIngredients(ForgeTypes.FLUID_STACK, CreateRecipeCategory.withImprovedVisibility(fluidIngredient.getMatchingFluidStacks()))
.addTooltipCallback(CreateRecipeCategory.addFluidTooltip(fluidIngredient.getRequiredAmount())); .addRichTooltipCallback(CreateRecipeCategory.addFluidTooltip(fluidIngredient.getRequiredAmount()));
} }
@Override @Override

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.fluids; package com.simibubi.create.content.fluids;
import com.simibubi.create.content.fluids.potion.PotionFluid;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
@ -10,17 +12,35 @@ import net.minecraftforge.fluids.ForgeFlowingFluid;
public class VirtualFluid extends ForgeFlowingFluid { public class VirtualFluid extends ForgeFlowingFluid {
public VirtualFluid(Properties properties) { public static VirtualFluid createSource(Properties properties) {
return new VirtualFluid(properties, true);
}
public static VirtualFluid createFlowing(Properties properties) {
return new VirtualFluid(properties, false);
}
private final boolean source;
public VirtualFluid(Properties properties, boolean source) {
super(properties); super(properties);
this.source = source;
} }
@Override @Override
public Fluid getSource() { public Fluid getSource() {
if (source) {
return this;
}
return super.getSource(); return super.getSource();
} }
@Override @Override
public Fluid getFlowing() { public Fluid getFlowing() {
if (source) {
return super.getFlowing();
}
return this; return this;
} }
@ -36,7 +56,7 @@ public class VirtualFluid extends ForgeFlowingFluid {
@Override @Override
public boolean isSource(FluidState p_207193_1_) { public boolean isSource(FluidState p_207193_1_) {
return false; return source;
} }
@Override @Override

View file

@ -24,19 +24,29 @@ import net.minecraftforge.fluids.FluidStack;
public class PotionFluid extends VirtualFluid { public class PotionFluid extends VirtualFluid {
public PotionFluid(Properties properties) { public static PotionFluid createSource(Properties properties) {
super(properties); return new PotionFluid(properties, true);
} }
public static FluidStack of(int amount, Potion potion) { public static PotionFluid createFlowing(Properties properties) {
FluidStack fluidStack = new FluidStack(AllFluids.POTION.get() return new PotionFluid(properties, false);
.getSource(), amount); }
public PotionFluid(Properties properties, boolean source) {
super(properties, source);
}
public static FluidStack of(int amount, Potion potion, BottleType bottleType) {
FluidStack fluidStack;
fluidStack = new FluidStack(AllFluids.POTION.get().getSource(), amount);
addPotionToFluidStack(fluidStack, potion); addPotionToFluidStack(fluidStack, potion);
NBTHelper.writeEnum(fluidStack.getOrCreateTag(), "Bottle", bottleType);
return fluidStack; return fluidStack;
} }
public static FluidStack withEffects(int amount, Potion potion, List<MobEffectInstance> customEffects) { public static FluidStack withEffects(int amount, Potion potion, List<MobEffectInstance> customEffects) {
FluidStack fluidStack = of(amount, potion); FluidStack fluidStack = of(amount, potion, BottleType.REGULAR);
appendEffects(fluidStack, customEffects); appendEffects(fluidStack, customEffects);
return fluidStack; return fluidStack;
} }

View file

@ -69,8 +69,7 @@ public class PotionFluidHandler {
public static FluidStack getFluidFromPotion(Potion potion, BottleType bottleType, int amount) { public static FluidStack getFluidFromPotion(Potion potion, BottleType bottleType, int amount) {
if (potion == Potions.WATER && bottleType == BottleType.REGULAR) if (potion == Potions.WATER && bottleType == BottleType.REGULAR)
return new FluidStack(Fluids.WATER, amount); return new FluidStack(Fluids.WATER, amount);
FluidStack fluid = PotionFluid.of(amount, potion); FluidStack fluid = PotionFluid.of(amount, potion, bottleType);
NBTHelper.writeEnum(fluid.getOrCreateTag(), "Bottle", bottleType);
return fluid; return fluid;
} }

View file

@ -172,29 +172,30 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
/* Fluids */ /* Fluids */
public <T extends ForgeFlowingFluid> FluidBuilder<T, CreateRegistrate> virtualFluid(String name, public <T extends ForgeFlowingFluid> FluidBuilder<T, CreateRegistrate> virtualFluid(String name,
FluidBuilder.FluidTypeFactory typeFactory, NonNullFunction<ForgeFlowingFluid.Properties, T> factory) { FluidBuilder.FluidTypeFactory typeFactory, NonNullFunction<ForgeFlowingFluid.Properties, T> sourceFactory,
NonNullFunction<ForgeFlowingFluid.Properties, T> flowingFactory) {
return entry(name, return entry(name,
c -> new VirtualFluidBuilder<>(self(), self(), name, c, new ResourceLocation(getModid(), "fluid/" + name + "_still"), c -> new VirtualFluidBuilder<>(self(), self(), name, c, new ResourceLocation(getModid(), "fluid/" + name + "_still"),
new ResourceLocation(getModid(), "fluid/" + name + "_flow"), typeFactory, factory)); new ResourceLocation(getModid(), "fluid/" + name + "_flow"), typeFactory, sourceFactory, flowingFactory));
} }
public <T extends ForgeFlowingFluid> FluidBuilder<T, CreateRegistrate> virtualFluid(String name, public <T extends ForgeFlowingFluid> FluidBuilder<T, CreateRegistrate> virtualFluid(String name,
ResourceLocation still, ResourceLocation flow, FluidBuilder.FluidTypeFactory typeFactory, ResourceLocation still, ResourceLocation flow, FluidBuilder.FluidTypeFactory typeFactory,
NonNullFunction<ForgeFlowingFluid.Properties, T> factory) { NonNullFunction<ForgeFlowingFluid.Properties, T> sourceFactory, NonNullFunction<ForgeFlowingFluid.Properties, T> flowingFactory) {
return entry(name, c -> new VirtualFluidBuilder<>(self(), self(), name, c, still, flow, typeFactory, factory)); return entry(name, c -> new VirtualFluidBuilder<>(self(), self(), name, c, still, flow, typeFactory, sourceFactory, flowingFactory));
} }
public FluidBuilder<VirtualFluid, CreateRegistrate> virtualFluid(String name) { public FluidBuilder<VirtualFluid, CreateRegistrate> virtualFluid(String name) {
return entry(name, return entry(name,
c -> new VirtualFluidBuilder<VirtualFluid, CreateRegistrate>(self(), self(), name, c, c -> new VirtualFluidBuilder<VirtualFluid, CreateRegistrate>(self(), self(), name, c,
new ResourceLocation(getModid(), "fluid/" + name + "_still"), new ResourceLocation(getModid(), "fluid/" + name + "_flow"), new ResourceLocation(getModid(), "fluid/" + name + "_still"), new ResourceLocation(getModid(), "fluid/" + name + "_flow"),
CreateRegistrate::defaultFluidType, VirtualFluid::new)); CreateRegistrate::defaultFluidType, VirtualFluid::createSource, VirtualFluid::createFlowing));
} }
public FluidBuilder<VirtualFluid, CreateRegistrate> virtualFluid(String name, ResourceLocation still, public FluidBuilder<VirtualFluid, CreateRegistrate> virtualFluid(String name, ResourceLocation still,
ResourceLocation flow) { ResourceLocation flow) {
return entry(name, c -> new VirtualFluidBuilder<>(self(), self(), name, c, still, flow, return entry(name, c -> new VirtualFluidBuilder<>(self(), self(), name, c, still, flow,
CreateRegistrate::defaultFluidType, VirtualFluid::new)); CreateRegistrate::defaultFluidType, VirtualFluid::createSource, VirtualFluid::createFlowing));
} }
public FluidBuilder<ForgeFlowingFluid.Flowing, CreateRegistrate> standardFluid(String name) { public FluidBuilder<ForgeFlowingFluid.Flowing, CreateRegistrate> standardFluid(String name) {

View file

@ -17,9 +17,11 @@ public class VirtualFluidBuilder<T extends ForgeFlowingFluid, P> extends FluidBu
public VirtualFluidBuilder(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback, public VirtualFluidBuilder(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback,
ResourceLocation stillTexture, ResourceLocation flowingTexture, FluidBuilder.FluidTypeFactory typeFactory, ResourceLocation stillTexture, ResourceLocation flowingTexture, FluidBuilder.FluidTypeFactory typeFactory,
NonNullFunction<Properties, T> factory) { NonNullFunction<Properties, T> sourceFactory,
super(owner, parent, name, callback, stillTexture, flowingTexture, typeFactory, factory); NonNullFunction<Properties, T> flowingFactory
source(factory); ) {
super(owner, parent, name, callback, stillTexture, flowingTexture, typeFactory, flowingFactory);
source(sourceFactory);
} }
@Override @Override

View file

@ -36,3 +36,10 @@ Technology that empowers the player.'''
versionRange="[1.0.0-alpha,2.0)" versionRange="[1.0.0-alpha,2.0)"
ordering="AFTER" ordering="AFTER"
side="CLIENT" side="CLIENT"
[[dependencies.create]]
modId="jei"
mandatory=false
versionRange="[15.19.0,)"
ordering="NONE"
side="CLIENT"