More REI compat
This commit is contained in:
parent
e0cf41db63
commit
fbe25dbd85
8 changed files with 107 additions and 76 deletions
|
@ -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<REIAlloyingDi
|
|||
|
||||
@Override
|
||||
public @NotNull Identifier getIdentifier() {
|
||||
return REICompat.ALLOYING;
|
||||
return AlloyingRecipe.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,7 @@ public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDi
|
|||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return REICompat.END_STONE_SMELTER;
|
||||
return REIPlugin.END_STONE_SMELTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,8 +56,13 @@ public class REIAlloyingCategory implements TransferRecipeCategory<REIAlloyingDi
|
|||
widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5),
|
||||
new TranslatableText("category.rei.cooking.time&xp", df.format(display.getXp()), df.format(smeltTime / 20D))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
|
||||
widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(smeltTime));
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x - 20, startPoint.y + 1)).entries(display.getInputEntries().get(0)).markInput());
|
||||
widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entries(display.getInputEntries().get(1)).markInput());
|
||||
List<List<EntryStack>> 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;
|
||||
}
|
||||
|
|
|
@ -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<EntryStack> fuel;
|
||||
|
||||
private AlloyingRecipe recipe;
|
||||
private Recipe<?> recipe;
|
||||
private List<List<EntryStack>> input;
|
||||
private List<EntryStack> 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<EntryStack> getFuel() {
|
||||
return fuel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<Identifier> 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<AlloyingRecipe> getOptionalRecipe() {
|
||||
public Optional<Recipe<?>> getOptionalRecipe() {
|
||||
return Optional.ofNullable(recipe);
|
||||
}
|
||||
|
||||
|
@ -90,8 +100,7 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo,
|
||||
ScreenHandler container) {
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<ScreenHandler> containerInfo, ScreenHandler container) {
|
||||
return input;
|
||||
}
|
||||
|
||||
|
|
15
src/main/java/ru/betterend/compat/REIContainer.java
Normal file
15
src/main/java/ru/betterend/compat/REIContainer.java
Normal file
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
|
@ -28,6 +28,7 @@ public class AlloyingRecipe implements Recipe<Inventory> {
|
|||
public final static String GROUP = "alloying";
|
||||
public final static RecipeType<AlloyingRecipe> 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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
"ru.betterend.client.BetterEndClient"
|
||||
],
|
||||
"rei_plugins": [
|
||||
"ru.betterend.compat.REICompat"
|
||||
"ru.betterend.compat.REIPlugin"
|
||||
],
|
||||
"rei_containers": [
|
||||
"ru.betterend.compat.REIContainer"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue