More REI compat

This commit is contained in:
Aleksey 2020-10-02 17:29:43 +03:00
parent e0cf41db63
commit fbe25dbd85
8 changed files with 107 additions and 76 deletions

View file

@ -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;
}

View file

@ -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;
}

View 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));
}
}

View file

@ -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