From 0dde12274e142b007a5458a2f8d7a6780eddab8f Mon Sep 17 00:00:00 2001 From: goshante Date: Fri, 20 Sep 2024 21:26:34 +0300 Subject: [PATCH] Fixed JEI potion fluids registered without Bottle tag --- .../com/simibubi/create/compat/jei/CreateJEI.java | 11 ++++++++--- .../create/content/fluids/potion/PotionFluid.java | 10 ++++++---- .../content/fluids/potion/PotionFluidHandler.java | 5 ++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java index ae9ac4bdc..56351d019 100644 --- a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java +++ b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java @@ -370,10 +370,15 @@ public class CreateJEI implements IModPlugin { @Override public void registerExtraIngredients(IExtraIngredientRegistration registration) { Collection potions = ForgeRegistries.POTIONS.getValues(); - Collection potionFluids = new ArrayList<>(potions.size()); + Collection potionFluids = new ArrayList<>(potions.size() * 3); for (Potion potion : potions) { - FluidStack potionFluid = PotionFluid.of(1000, potion); - potionFluids.add(potionFluid); + // @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); } diff --git a/src/main/java/com/simibubi/create/content/fluids/potion/PotionFluid.java b/src/main/java/com/simibubi/create/content/fluids/potion/PotionFluid.java index 07842a364..3bc1b75be 100644 --- a/src/main/java/com/simibubi/create/content/fluids/potion/PotionFluid.java +++ b/src/main/java/com/simibubi/create/content/fluids/potion/PotionFluid.java @@ -36,15 +36,17 @@ public class PotionFluid extends VirtualFluid { super(properties, source); } - public static FluidStack of(int amount, Potion potion) { - FluidStack fluidStack = new FluidStack(AllFluids.POTION.get() - .getSource(), amount); + public static FluidStack of(int amount, Potion potion, BottleType bottleType) { + + FluidStack fluidStack; + fluidStack = new FluidStack(AllFluids.POTION.get().getSource(), amount); addPotionToFluidStack(fluidStack, potion); + NBTHelper.writeEnum(fluidStack.getOrCreateTag(), "Bottle", bottleType); return fluidStack; } public static FluidStack withEffects(int amount, Potion potion, List customEffects) { - FluidStack fluidStack = of(amount, potion); + FluidStack fluidStack = of(amount, potion, BottleType.REGULAR); appendEffects(fluidStack, customEffects); return fluidStack; } diff --git a/src/main/java/com/simibubi/create/content/fluids/potion/PotionFluidHandler.java b/src/main/java/com/simibubi/create/content/fluids/potion/PotionFluidHandler.java index 19fd4411c..2c5c34b5a 100644 --- a/src/main/java/com/simibubi/create/content/fluids/potion/PotionFluidHandler.java +++ b/src/main/java/com/simibubi/create/content/fluids/potion/PotionFluidHandler.java @@ -42,7 +42,7 @@ public class PotionFluidHandler { return stack.getItem() instanceof PotionItem && !(stack.getCraftingRemainingItem() .getItem() instanceof BucketItem); } - + public static Pair emptyPotion(ItemStack stack, boolean simulate) { FluidStack fluid = getFluidFromPotionItem(stack); if (!simulate) @@ -69,8 +69,7 @@ public class PotionFluidHandler { public static FluidStack getFluidFromPotion(Potion potion, BottleType bottleType, int amount) { if (potion == Potions.WATER && bottleType == BottleType.REGULAR) return new FluidStack(Fluids.WATER, amount); - FluidStack fluid = PotionFluid.of(amount, potion); - NBTHelper.writeEnum(fluid.getOrCreateTag(), "Bottle", bottleType); + FluidStack fluid = PotionFluid.of(amount, potion, bottleType); return fluid; }