diff --git a/src/main/java/ru/betterend/compat/REIAlloyingCategory.java b/src/main/java/ru/betterend/compat/REIAlloyingCategory.java index 44013036..5e9279b9 100644 --- a/src/main/java/ru/betterend/compat/REIAlloyingCategory.java +++ b/src/main/java/ru/betterend/compat/REIAlloyingCategory.java @@ -23,7 +23,7 @@ import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; - +import ru.betterend.recipe.AlloyingRecipe; import ru.betterend.registry.BlockRegistry; import ru.betterend.util.LangUtil; @@ -31,7 +31,7 @@ public class REIAlloyingCategory implements TransferRecipeCategory> inputEntries = display.getInputEntries(); + widgets.add(Widgets.createSlot(new Point(startPoint.x - 20, startPoint.y + 1)).entries(inputEntries.get(0)).markInput()); + if (inputEntries.size() > 1) { + widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(inputEntries.get(1)).markInput()); + } else { + widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(Lists.newArrayList()).markInput()); + } widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getResultingEntries().get(0)).disableBackground().markOutput()); return widgets; } diff --git a/src/main/java/ru/betterend/compat/REIAlloyingDisplay.java b/src/main/java/ru/betterend/compat/REIAlloyingDisplay.java index 8a54a012..3d5ca517 100644 --- a/src/main/java/ru/betterend/compat/REIAlloyingDisplay.java +++ b/src/main/java/ru/betterend/compat/REIAlloyingDisplay.java @@ -12,6 +12,8 @@ import me.shedaniel.rei.api.TransferRecipeDisplay; import me.shedaniel.rei.server.ContainerInfo; import net.minecraft.item.Item; +import net.minecraft.recipe.BlastingRecipe; +import net.minecraft.recipe.Recipe; import net.minecraft.screen.ScreenHandler; import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; @@ -24,7 +26,7 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { private static List fuel; - private AlloyingRecipe recipe; + private Recipe recipe; private List> input; private List output; private float xp; @@ -38,13 +40,21 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { this.smeltTime = recipe.getSmeltTime(); } + public REIAlloyingDisplay(BlastingRecipe recipe) { + this.recipe = recipe; + this.input = EntryStack.ofIngredients(recipe.getPreviewInputs()); + this.output = Collections.singletonList(EntryStack.create(recipe.getOutput())); + this.xp = recipe.getExperience(); + this.smeltTime = recipe.getCookTime(); + } + public static List getFuel() { return fuel; } @Override public @NotNull Optional getRecipeLocation() { - return Optional.ofNullable(recipe).map(AlloyingRecipe::getId); + return Optional.ofNullable(recipe).map(Recipe::getId); } @Override @@ -59,7 +69,7 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { @Override public @NotNull Identifier getRecipeCategory() { - return REICompat.ALLOYING; + return AlloyingRecipe.ID; } @Override @@ -75,7 +85,7 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { return this.smeltTime; } - public Optional getOptionalRecipe() { + public Optional> getOptionalRecipe() { return Optional.ofNullable(recipe); } @@ -90,8 +100,7 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay { } @Override - public List> getOrganisedInputEntries(ContainerInfo containerInfo, - ScreenHandler container) { + public List> getOrganisedInputEntries(ContainerInfo containerInfo, ScreenHandler container) { return input; } diff --git a/src/main/java/ru/betterend/compat/REIContainer.java b/src/main/java/ru/betterend/compat/REIContainer.java new file mode 100644 index 00000000..9dbed06c --- /dev/null +++ b/src/main/java/ru/betterend/compat/REIContainer.java @@ -0,0 +1,15 @@ +package ru.betterend.compat; + +import me.shedaniel.rei.plugin.containers.CraftingContainerInfoWrapper; +import me.shedaniel.rei.server.ContainerInfoHandler; +import ru.betterend.client.gui.EndStoneSmelterScreenHandler; +import ru.betterend.recipe.AlloyingRecipe; + +public class REIContainer implements Runnable { + + @Override + public void run() { + ContainerInfoHandler.registerContainerInfo(AlloyingRecipe.ID, CraftingContainerInfoWrapper.create(EndStoneSmelterScreenHandler.class)); + } + +} diff --git a/src/main/java/ru/betterend/compat/REICompat.java b/src/main/java/ru/betterend/compat/REIPlugin.java similarity index 73% rename from src/main/java/ru/betterend/compat/REICompat.java rename to src/main/java/ru/betterend/compat/REIPlugin.java index ec2c9f92..1b7f50ef 100644 --- a/src/main/java/ru/betterend/compat/REICompat.java +++ b/src/main/java/ru/betterend/compat/REIPlugin.java @@ -7,6 +7,7 @@ import me.shedaniel.rei.api.plugins.REIPluginV0; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.recipe.BlastingRecipe; import net.minecraft.util.Identifier; import ru.betterend.BetterEnd; @@ -14,10 +15,9 @@ import ru.betterend.recipe.AlloyingRecipe; import ru.betterend.registry.BlockRegistry; @Environment(EnvType.CLIENT) -public class REICompat implements REIPluginV0 { +public class REIPlugin implements REIPluginV0 { public final static Identifier PLUGIN_ID = BetterEnd.getIdentifier("rei_plugin"); - public final static Identifier ALLOYING = BetterEnd.getIdentifier("alloying"); public final static EntryStack END_STONE_SMELTER = EntryStack.create(BlockRegistry.END_STONE_SMELTER); @Override @@ -27,12 +27,13 @@ public class REICompat implements REIPluginV0 { @Override public void registerRecipeDisplays(RecipeHelper recipeHelper) { - recipeHelper.registerRecipes(ALLOYING, AlloyingRecipe.class, REIAlloyingDisplay::new); + recipeHelper.registerRecipes(AlloyingRecipe.ID, AlloyingRecipe.class, REIAlloyingDisplay::new); + recipeHelper.registerRecipes(AlloyingRecipe.ID, BlastingRecipe.class, REIAlloyingDisplay::new); } @Override public void registerOthers(RecipeHelper recipeHelper) { - recipeHelper.registerWorkingStations(ALLOYING, END_STONE_SMELTER); + recipeHelper.registerWorkingStations(AlloyingRecipe.ID, END_STONE_SMELTER); } @Override diff --git a/src/main/java/ru/betterend/recipe/AlloyingRecipe.java b/src/main/java/ru/betterend/recipe/AlloyingRecipe.java index 3acbb1df..2b5600fc 100644 --- a/src/main/java/ru/betterend/recipe/AlloyingRecipe.java +++ b/src/main/java/ru/betterend/recipe/AlloyingRecipe.java @@ -28,6 +28,7 @@ public class AlloyingRecipe implements Recipe { public final static String GROUP = "alloying"; public final static RecipeType TYPE = EndRecipeManager.registerType(GROUP); public final static Serializer SERIALIZER = EndRecipeManager.registerSerializer(GROUP, new Serializer()); + public final static Identifier ID = BetterEnd.getIdentifier("alloying"); protected final RecipeType type; protected final Identifier id; diff --git a/src/main/java/ru/betterend/recipe/CraftingRecipes.java b/src/main/java/ru/betterend/recipe/CraftingRecipes.java index 58dd893a..8831c3b8 100644 --- a/src/main/java/ru/betterend/recipe/CraftingRecipes.java +++ b/src/main/java/ru/betterend/recipe/CraftingRecipes.java @@ -10,33 +10,6 @@ import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.ItemRegistry; public class CraftingRecipes { - private static String[] helmet_recipe = new String[] { - "III", "I I" - }; - private static String[] chestplate_recipe = new String[] { - "I I", "III", "III" - }; - private static String[] leggings_recipe = new String[] { - "III", "I I", "I I" - }; - private static String[] boots_recipe = new String[] { - "I I", "I I" - }; - private static String[] shovel_recipe = new String[] { - "I", "#", "#" - }; - private static String[] sword_recipe = new String[] { - "I", "I", "#" - }; - private static String[] pickaxe_recipe = new String[] { - "III", " # ", " # " - }; - private static String[] axe_recipe = new String[] { - "II", "#I", "# " - }; - private static String[] hoe_recipe = new String[] { - "II", "# ", "# " - }; public static void register() { if (blockExists(BlockRegistry.ENDER_BLOCK)) { @@ -52,67 +25,79 @@ public class CraftingRecipes { } if (blockExists(BlockRegistry.END_STONE_SMELTER)) { RecipeBuilder.make("end_stone_smelter", BlockRegistry.END_STONE_SMELTER) - .setShape(new String[] { "###", "V#V", "###" }) + .setShape(new String[] { "###", "V V", "###" }) .addMaterial('#', Blocks.END_STONE_BRICKS) .addMaterial('V', Items.BUCKET) .build(); } if (itemExists(ItemRegistry.TERMINITE_INGOT)) { - registerHelmet("terminite", ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_HELMET); - registerChestplate("terminite", ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_CHESTPLATE); - registerLeggings("terminite", ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_LEGGINGS); - registerBoots("terminite", ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_BOOTS); - registerShovel("terminite", ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_SHOVEL); - registerSword("terminite", ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_SWORD); - registerPickaxe("terminite", ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_PICKAXE); - registerAxe("terminite", ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_AXE); - registerHoe("terminite", ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_HOE); + String material = "terminite"; + RecipeBuilder.make(material + "_block", BlockRegistry.TERMINITE_BLOCK) + .setShape(new String[] { "III", "III", "III" }) + .addMaterial('I', ItemRegistry.TERMINITE_INGOT) + .build(); + + registerHelmet(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_HELMET); + registerChestplate(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_CHESTPLATE); + registerLeggings(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_LEGGINGS); + registerBoots(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_BOOTS); + registerShovel(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_SHOVEL); + registerSword(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_SWORD); + registerPickaxe(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_PICKAXE); + registerAxe(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_AXE); + registerHoe(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_HOE); } if (itemExists(ItemRegistry.AETERNIUM_INGOT)) { - registerHelmet("aeternium", ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_HELMET); - registerChestplate("aeternium", ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_CHESTPLATE); - registerLeggings("aeternium", ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_LEGGINGS); - registerBoots("aeternium", ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_BOOTS); - registerShovel("aeternium", ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_SHOVEL); - registerSword("aeternium", ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_SWORD); - registerPickaxe("aeternium", ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_PICKAXE); - registerAxe("aeternium", ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_AXE); - registerHoe("aeternium", ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_HOE); + String material = "aeternium"; + RecipeBuilder.make(material + "_block", BlockRegistry.AETERNIUM_BLOCK) + .setShape(new String[] { "III", "III", "III" }) + .addMaterial('I', ItemRegistry.AETERNIUM_INGOT) + .build(); + + registerHelmet(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_HELMET); + registerChestplate(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_CHESTPLATE); + registerLeggings(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_LEGGINGS); + registerBoots(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_BOOTS); + registerShovel(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_SHOVEL); + registerSword(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_SWORD); + registerPickaxe(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_PICKAXE); + registerAxe(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_AXE); + registerHoe(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_HOE); } } private static void registerHelmet(String name, Item material, Item result) { RecipeBuilder.make(name + "_helmet", result) - .setShape(helmet_recipe) + .setShape(new String[] { "III", "I I" }) .addMaterial('I', material) .build(); } private static void registerChestplate(String name, Item material, Item result) { RecipeBuilder.make(name + "_chestplate", result) - .setShape(chestplate_recipe) + .setShape(new String[] { "I I", "III", "III" }) .addMaterial('I', material) .build(); } private static void registerLeggings(String name, Item material, Item result) { RecipeBuilder.make(name + "_leggings", result) - .setShape(leggings_recipe) + .setShape(new String[] { "III", "I I", "I I" }) .addMaterial('I', material) .build(); } private static void registerBoots(String name, Item material, Item result) { RecipeBuilder.make(name + "_boots", result) - .setShape(boots_recipe) + .setShape(new String[] { "I I", "I I" }) .addMaterial('I', material) .build(); } private static void registerShovel(String name, Item material, Item result) { RecipeBuilder.make(name + "_shovel", result) - .setShape(shovel_recipe) + .setShape(new String[] { "I", "#", "#" }) .addMaterial('I', material) .addMaterial('#', Items.STICK) .build(); @@ -120,7 +105,7 @@ public class CraftingRecipes { private static void registerSword(String name, Item material, Item result) { RecipeBuilder.make(name + "_sword", result) - .setShape(sword_recipe) + .setShape(new String[] { "I", "I", "#" }) .addMaterial('I', material) .addMaterial('#', Items.STICK) .build(); @@ -128,7 +113,7 @@ public class CraftingRecipes { private static void registerPickaxe(String name, Item material, Item result) { RecipeBuilder.make(name + "_pickaxe", result) - .setShape(pickaxe_recipe) + .setShape(new String[] { "III", " # ", " # " }) .addMaterial('I', material) .addMaterial('#', Items.STICK) .build(); @@ -136,7 +121,7 @@ public class CraftingRecipes { private static void registerAxe(String name, Item material, Item result) { RecipeBuilder.make(name + "_axe", result) - .setShape(axe_recipe) + .setShape(new String[] { "II", "#I", "# " }) .addMaterial('I', material) .addMaterial('#', Items.STICK) .build(); @@ -144,7 +129,7 @@ public class CraftingRecipes { private static void registerHoe(String name, Item material, Item result) { RecipeBuilder.make(name + "_hoe", result) - .setShape(hoe_recipe) + .setShape(new String[] { "II", "# ", "# " }) .addMaterial('I', material) .addMaterial('#', Items.STICK) .build(); diff --git a/src/main/java/ru/betterend/registry/ItemRegistry.java b/src/main/java/ru/betterend/registry/ItemRegistry.java index 60a41da6..1f621c7f 100644 --- a/src/main/java/ru/betterend/registry/ItemRegistry.java +++ b/src/main/java/ru/betterend/registry/ItemRegistry.java @@ -4,6 +4,7 @@ import java.util.List; import com.google.common.collect.Lists; +import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ArmorItem; import net.minecraft.item.BlockItem; @@ -65,10 +66,21 @@ public class ItemRegistry { } protected static ToolItem registerTool(String name, ToolItem item) { - if (item != Items.AIR) { - Registry.register(Registry.ITEM, BetterEnd.getIdentifier(name), item); - MOD_ITEMS.add(item); - } + Registry.register(Registry.ITEM, BetterEnd.getIdentifier(name), item); + MOD_ITEMS.add(item); + +// if (item instanceof ShovelItem) { +// FabricToolTags.SHOVELS.values().add(item); +// } else if (item instanceof SwordItem) { +// FabricToolTags.SWORDS.values().add(item); +// } else if (item instanceof EndPickaxe) { +// FabricToolTags.PICKAXES.values().add(item); +// } else if (item instanceof EndAxe) { +// FabricToolTags.AXES.values().add(item); +// } else if (item instanceof EndHoe) { +// FabricToolTags.HOES.values().add(item); +// } + return item; } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index daff9fc3..7b7a88c4 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,8 +26,11 @@ "ru.betterend.client.BetterEndClient" ], "rei_plugins": [ - "ru.betterend.compat.REICompat" - ] + "ru.betterend.compat.REIPlugin" + ], + "rei_containers": [ + "ru.betterend.compat.REIContainer" + ] }, "mixins": [ "betterend.mixins.common.json",