This commit is contained in:
attackeight 2024-04-26 23:03:11 +00:00 committed by GitHub
commit 23220694b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 36 additions and 13 deletions

View file

@ -199,13 +199,13 @@ dependencies {
// implementation fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-1.16.5:0.10.0-Beta25")
// runtimeOnly fg.deobf("vazkii.arl:AutoRegLib:1.4-35.69")
// runtimeOnly fg.deobf("vazkii.quark:Quark:r2.0-212.984")
// runtimeOnly fg.deobf("slimeknights.mantle:Mantle:1.16.5-1.6.115")
// runtimeOnly fg.deobf("slimeknights.tconstruct:TConstruct:1.16.5-3.1.1.252")
// implementation fg.deobf("curse.maven:mantle-74924:4509007")
// implementation fg.deobf("curse.maven:tinkers-construct-74072:4509008")
// runtimeOnly fg.deobf("maven.modrinth:rubidium:0.5.3")
// implementation fg.deobf("com.railwayteam.railways:railways-1.18.2-1.1.1:all") { transitive = false }
// runtimeOnly fg.deobf("maven.modrinth:spark:1.10.38-forge")
//runtimeOnly fg.deobf("curse.maven:forbidden-arcanus-309858:4729924")
//runtimeOnly fg.deobf("curse.maven:valhelsia-core-416935:3886212")
// runtimeOnly fg.deobf("curse.maven:forbidden-arcanus-309858:4729924")
// runtimeOnly fg.deobf("curse.maven:valhelsia-core-416935:3886212")
// https://discord.com/channels/313125603924639766/725850371834118214/910619168821354497
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings

View file

@ -24,6 +24,7 @@ import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.runtime.IIngredientManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.PotionItem;
@ -46,9 +47,12 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
public static void consumeRecipes(Consumer<FillingRecipe> consumer, IIngredientManager ingredientManager) {
Collection<FluidStack> fluidStacks = ingredientManager.getAllIngredients(ForgeTypes.FLUID_STACK);
for (ItemStack stack : ingredientManager.getAllIngredients(VanillaTypes.ITEM_STACK)) {
if (stack.getItem() instanceof PotionItem) {
FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack);
if (stack.getItem() instanceof PotionItem pi) {
Ingredient bottle = Ingredient.of(Items.GLASS_BOTTLE);
if (pi.getContainerItem(stack).getItem() instanceof BucketItem) {
bottle = Ingredient.of(Items.BUCKET);
}
FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack);
consumer.accept(new ProcessingRecipeBuilder<>(FillingRecipe::new, Create.asResource("potions"))
.withItemIngredients(bottle)
.withFluidIngredients(FluidIngredient.fromFluidStack(fluidFromPotionItem))

View file

@ -64,7 +64,7 @@ public class PotionFluid extends VirtualFluid {
}
public enum BottleType {
REGULAR, SPLASH, LINGERING;
REGULAR, SPLASH, LINGERING, BUCKET;
}
public static class PotionFluidAttributes extends FluidAttributes {

View file

@ -16,15 +16,18 @@ import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Tuple;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffectUtil;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.PotionItem;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.Potions;
@ -38,9 +41,11 @@ public class PotionFluidHandler {
public static Pair<FluidStack, ItemStack> emptyPotion(ItemStack stack, boolean simulate) {
FluidStack fluid = getFluidFromPotionItem(stack);
BottleType type = bottleTypeFromItem(stack.getItem());
Item bottle = type == BottleType.BUCKET ? Items.BUCKET : Items.GLASS_BOTTLE;
if (!simulate)
stack.shrink(1);
return Pair.of(fluid, new ItemStack(Items.GLASS_BOTTLE));
return Pair.of(fluid, new ItemStack(bottle));
}
public static FluidIngredient potionIngredient(Potion potion, int amount) {
@ -52,9 +57,10 @@ public class PotionFluidHandler {
Potion potion = PotionUtils.getPotion(stack);
List<MobEffectInstance> list = PotionUtils.getCustomEffects(stack);
BottleType bottleTypeFromItem = bottleTypeFromItem(stack.getItem());
int amount = bottleTypeFromItem == BottleType.BUCKET ? 1000 : 250;
if (potion == Potions.WATER && list.isEmpty() && bottleTypeFromItem == BottleType.REGULAR)
return new FluidStack(Fluids.WATER, 250);
FluidStack fluid = PotionFluid.withEffects(250, potion, list);
return new FluidStack(Fluids.WATER, amount);
FluidStack fluid = PotionFluid.withEffects(amount, potion, list);
NBTHelper.writeEnum(fluid.getOrCreateTag(), "Bottle", bottleTypeFromItem);
return fluid;
}
@ -72,6 +78,8 @@ public class PotionFluidHandler {
return BottleType.LINGERING;
if (item == Items.SPLASH_POTION)
return BottleType.SPLASH;
if (item.getContainerItem(new ItemStack(item)).getItem() instanceof BucketItem)
return BottleType.BUCKET;
return BottleType.REGULAR;
}

View file

@ -2,14 +2,19 @@ package com.simibubi.create.content.fluids.transfer;
import com.simibubi.create.AllFluids;
import com.simibubi.create.AllItems;
import com.simibubi.create.compat.Mods;
import com.simibubi.create.content.fluids.potion.PotionFluid;
import com.simibubi.create.content.fluids.potion.PotionFluidHandler;
import com.simibubi.create.foundation.fluid.FluidHelper;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.MilkBucketItem;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.level.Level;
@ -21,6 +26,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper;
import net.minecraftforge.registries.ForgeRegistries;
public class GenericItemFilling {
@ -31,10 +37,10 @@ public class GenericItemFilling {
* Forge without looking into what it actually does. In all cases this is
* incorrect because having a non-bucket item turn into a bucket item does not
* make sense.
*
*
* <p>This check is only necessary for filling since a FluidBucketWrapper will be
* empty if it is initialized with a non-bucket item.
*
*
* @param stack The ItemStack.
* @param fluidHandler The IFluidHandlerItem instance retrieved from the ItemStack.
* @return If the IFluidHandlerItem is valid for the passed ItemStack.
@ -110,7 +116,7 @@ public class GenericItemFilling {
}
private static boolean canFillBucketInternally(FluidStack availableFluid) {
return false;
return availableFluid.getFluid().isSame(AllFluids.POTION.get());
}
public static ItemStack fillItem(Level world, int requiredAmount, ItemStack stack, FluidStack availableFluid) {
@ -129,6 +135,11 @@ public class GenericItemFilling {
fillBottle = PotionFluidHandler.fillBottle(stack, toFill);
stack.shrink(1);
return fillBottle;
} else if (stack.getItem() == Items.BUCKET && Mods.TCONSTRUCT.isLoaded() && toFill.getFluid() instanceof PotionFluid p) {
ItemStack toFillBucket = new ItemStack(Registry.ITEM.get(Mods.TCONSTRUCT.rl("potion_bucket")));
PotionUtils.setPotion(toFillBucket, PotionUtils.getPotion(toFill.getOrCreateTag()));
stack.shrink(1);
return toFillBucket;
}
ItemStack split = stack.copy();