[Feature] Vanilla Water Bottles do return empty bottle when consumed in recipes (quiqueck/BetterEnd#21)
This commit is contained in:
parent
e08fc8c29c
commit
34993a81d0
3 changed files with 38 additions and 0 deletions
|
@ -0,0 +1,34 @@
|
||||||
|
package org.betterx.bclib.mixin.common;
|
||||||
|
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.world.Container;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.item.PotionItem;
|
||||||
|
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||||
|
import net.minecraft.world.item.alchemy.Potions;
|
||||||
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(Recipe.class)
|
||||||
|
public interface RecipeMixin<C extends Container> {
|
||||||
|
//Water Bottles are potions and they do not return an empty bottle in crafting Recipes
|
||||||
|
//This mixin will fix that behaviour
|
||||||
|
|
||||||
|
@Inject(method = "getRemainingItems", at = @At("RETURN"))
|
||||||
|
default void bcl_getRemainingItems(C container, CallbackInfoReturnable<NonNullList<ItemStack>> cir) {
|
||||||
|
NonNullList<ItemStack> remaining = cir.getReturnValue();
|
||||||
|
|
||||||
|
for (int i = 0; i < remaining.size(); ++i) {
|
||||||
|
ItemStack stack = container.getItem(i);
|
||||||
|
if (stack.getItem() instanceof PotionItem pi) {
|
||||||
|
if (PotionUtils.getPotion(stack) == Potions.WATER)
|
||||||
|
remaining.set(i, new ItemStack(Items.GLASS_BOTTLE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,11 +19,14 @@ public class CommonItemTags {
|
||||||
public static final TagKey<Item> WOODEN_CHEST = TagManager.ITEMS.makeCommonTag("wooden_chests");
|
public static final TagKey<Item> WOODEN_CHEST = TagManager.ITEMS.makeCommonTag("wooden_chests");
|
||||||
public static final TagKey<Item> WORKBENCHES = TagManager.ITEMS.makeCommonTag("workbench");
|
public static final TagKey<Item> WORKBENCHES = TagManager.ITEMS.makeCommonTag("workbench");
|
||||||
|
|
||||||
|
public static final TagKey<Item> WATER_BOTTLES = TagManager.ITEMS.makeCommonTag("`water_bottles`");
|
||||||
|
|
||||||
static void prepareTags() {
|
static void prepareTags() {
|
||||||
TagManager.ITEMS.add(SOUL_GROUND, Blocks.SOUL_SAND.asItem(), Blocks.SOUL_SOIL.asItem());
|
TagManager.ITEMS.add(SOUL_GROUND, Blocks.SOUL_SAND.asItem(), Blocks.SOUL_SOIL.asItem());
|
||||||
|
|
||||||
TagManager.ITEMS.add(CommonItemTags.CHEST, Items.CHEST);
|
TagManager.ITEMS.add(CommonItemTags.CHEST, Items.CHEST);
|
||||||
TagManager.ITEMS.add(CommonItemTags.IRON_INGOTS, Items.IRON_INGOT);
|
TagManager.ITEMS.add(CommonItemTags.IRON_INGOTS, Items.IRON_INGOT);
|
||||||
TagManager.ITEMS.add(CommonItemTags.FURNACES, Blocks.FURNACE.asItem());
|
TagManager.ITEMS.add(CommonItemTags.FURNACES, Blocks.FURNACE.asItem());
|
||||||
|
TagManager.ITEMS.add(CommonItemTags.WATER_BOTTLES, Items.WATER_BUCKET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"PotionBrewingAccessor",
|
"PotionBrewingAccessor",
|
||||||
"RecipeManagerAccessor",
|
"RecipeManagerAccessor",
|
||||||
"RecipeManagerMixin",
|
"RecipeManagerMixin",
|
||||||
|
"RecipeMixin",
|
||||||
"RegistryAccessMixin",
|
"RegistryAccessMixin",
|
||||||
"ServerAdvancementManagerMixin",
|
"ServerAdvancementManagerMixin",
|
||||||
"ServerLevelMixin",
|
"ServerLevelMixin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue