Partially working REI

This commit is contained in:
Frank Bauer 2021-06-29 20:23:19 +02:00
parent ea62902ee8
commit e7c85c8148
9 changed files with 85 additions and 56 deletions

View file

@ -5,19 +5,18 @@ import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import me.shedaniel.math.Point; import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.DisplayRenderer;
import me.shedaniel.rei.api.client.gui.SimpleDisplayRenderer;
import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.api.client.gui.widgets.Widgets;
import me.shedaniel.rei.api.client.registry.display.TransferDisplayCategory; import me.shedaniel.rei.api.client.registry.display.TransferDisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryStacks;
import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@ -37,7 +36,8 @@ public class REIAlloyingCategory implements TransferDisplayCategory<REIAlloyingD
@Override @Override
public @NotNull EntryStack getIcon() { public @NotNull EntryStack getIcon() {
return REIPlugin.END_STONE_SMELTER; //return REIPluginClient.END_STONE_SMELTER;
return EntryStacks.of(Items.COAL);
} }
@Override @Override

View file

@ -28,27 +28,23 @@ public class REIAlloyingDisplay extends BasicDisplay implements SimpleGridMenuDi
private Recipe<?> recipe; private Recipe<?> recipe;
private float xp; private float xp;
private double smeltTime; private double smeltTime;
public REIAlloyingDisplay(AlloyingRecipe recipe) { public REIAlloyingDisplay(AlloyingRecipe recipe) {
this(recipe, recipe.getExperience(), recipe.getSmeltTime());
}
protected REIAlloyingDisplay(Recipe<?> recipe, float xp, double smeltTime) {
super( super(
EntryIngredients.ofIngredients(recipe.getIngredients()), EntryIngredients.ofIngredients(recipe.getIngredients()),
Collections.singletonList(EntryIngredients.of(recipe.getResultItem())) Collections.singletonList(EntryIngredients.of(recipe.getResultItem()))
); );
this.recipe = recipe; this.recipe = recipe;
this.xp = recipe.getExperience(); this.xp = xp;
this.smeltTime = recipe.getSmeltTime(); this.smeltTime = smeltTime;
} }
public REIAlloyingDisplay(BlastingRecipe recipe) {
super(
EntryIngredients.ofIngredients(recipe.getIngredients()),
Collections.singletonList(EntryIngredients.of(recipe.getResultItem()))
);
this.recipe = recipe;
this.xp = recipe.getExperience();
this.smeltTime = recipe.getCookingTime();
}
public static List<EntryStack> getFuel() { public static List<EntryStack> getFuel() {
return fuel; return fuel;
} }

View file

@ -8,7 +8,7 @@ import net.minecraft.nbt.CompoundTag;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class REIAlloyingFuelDisplay extends BasicDisplay { public abstract class REIAlloyingFuelDisplay extends BasicDisplay {
private final int fuelTime; private final int fuelTime;
public REIAlloyingFuelDisplay(List<EntryIngredient> fuel, CompoundTag tag) { public REIAlloyingFuelDisplay(List<EntryIngredient> fuel, CompoundTag tag) {
@ -24,10 +24,10 @@ public class REIAlloyingFuelDisplay extends BasicDisplay {
this.fuelTime = fuelTime; this.fuelTime = fuelTime;
}*/ }*/
@Override /*@Override
public CategoryIdentifier<?> getCategoryIdentifier() { public CategoryIdentifier<?> getCategoryIdentifier() {
return REIPlugin.ALLOYING_FUEL; return REIPluginClient.ALLOYING_FUEL;
} }*/
public int getFuelTime() { public int getFuelTime() {
return fuelTime; return fuelTime;

View file

@ -11,17 +11,18 @@ import me.shedaniel.rei.api.client.registry.display.TransferDisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryStacks;
import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import ru.betterend.blocks.basis.EndAnvilBlock; import ru.betterend.blocks.basis.EndAnvilBlock;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -39,11 +40,12 @@ public class REIAnvilCategory implements TransferDisplayCategory<REIAnvilDisplay
@Override @Override
public @NotNull EntryStack getIcon() { public @NotNull EntryStack getIcon() {
return REIPlugin.ANVILS[0]; //return REIPluginClient.ANVILS[0];
return EntryStacks.of(Items.COAL);
} }
@Override /*@Override
public @NotNull List<Widget> setupDisplay(REIAnvilDisplay display, Rectangle bounds) { public @NotNull List<Widget> setupDisplay(REIAnvilDisplay display, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
List<Widget> widgets = Lists.newArrayList(); List<Widget> widgets = Lists.newArrayList();
@ -54,7 +56,7 @@ public class REIAnvilCategory implements TransferDisplayCategory<REIAnvilDisplay
List<EntryIngredient> inputEntries = display.getInputEntries(); List<EntryIngredient> inputEntries = display.getInputEntries();
EntryIngredient materials = inputEntries.get(1); EntryIngredient materials = inputEntries.get(1);
int anvilLevel = display.getAnvilLevel(); int anvilLevel = display.getAnvilLevel();
List anvils = Arrays.stream(REIPlugin.ANVILS).filter(anvil -> { List anvils = Arrays.stream(REIPluginClient.ANVILS).filter(anvil -> {
Block block = ((BlockItem) anvil.getValue()).getBlock(); Block block = ((BlockItem) anvil.getValue()).getBlock();
if (block instanceof EndAnvilBlock) { if (block instanceof EndAnvilBlock) {
return ((EndAnvilBlock) block).getCraftingLevel() >= anvilLevel; return ((EndAnvilBlock) block).getCraftingLevel() >= anvilLevel;
@ -71,7 +73,7 @@ public class REIAnvilCategory implements TransferDisplayCategory<REIAnvilDisplay
widgets.add(Widgets.createSlot(new Point(x - 9, y + 25)).entries(anvils)); widgets.add(Widgets.createSlot(new Point(x - 9, y + 25)).entries(anvils));
return widgets; return widgets;
} }*/
@Override @Override
public void renderRedSlots(PoseStack matrices, List<Widget> widgets, Rectangle bounds, REIAnvilDisplay display, public void renderRedSlots(PoseStack matrices, List<Widget> widgets, Rectangle bounds, REIAnvilDisplay display,

View file

@ -0,0 +1,10 @@
package ru.betterend.integration.rei;
import net.minecraft.world.item.crafting.BlastingRecipe;
import ru.betterend.recipe.builders.AlloyingRecipe;
public class REIBlastingDisplay extends REIAlloyingDisplay{
public REIBlastingDisplay(BlastingRecipe recipe) {
super(recipe, recipe.getExperience(), recipe.getCookingTime());
}
}

View file

@ -1,5 +1,8 @@
package ru.betterend.integration.rei; package ru.betterend.integration.rei;
import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
import ru.betterend.recipe.builders.AlloyingRecipe;
public class REIContainer implements Runnable { public class REIContainer implements Runnable {
@Override @Override

View file

@ -11,9 +11,11 @@ import me.shedaniel.rei.api.client.registry.display.TransferDisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryStacks;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
@ -36,7 +38,8 @@ public class REIInfusionCategory implements TransferDisplayCategory<REIInfusionD
@Override @Override
public @NotNull EntryStack getIcon() { public @NotNull EntryStack getIcon() {
return REIPlugin.INFUSION_RITUAL; //return REIPluginClient.INFUSION_RITUAL;
return EntryStacks.of(Items.COAL);
} }

View file

@ -3,17 +3,25 @@ package ru.betterend.integration.rei;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.plugins.REIServerPlugin; import me.shedaniel.rei.api.common.entry.type.EntryType;
import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.impl.ClientInternals; import me.shedaniel.rei.impl.ClientInternals;
import me.shedaniel.rei.impl.Internals;
import me.shedaniel.rei.plugin.common.DefaultPlugin; import me.shedaniel.rei.plugin.common.DefaultPlugin;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.BlastingRecipe;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import org.jetbrains.annotations.ApiStatus;
import ru.bclib.blocks.BaseFurnaceBlock; import ru.bclib.blocks.BaseFurnaceBlock;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.blocks.basis.EndAnvilBlock; import ru.betterend.blocks.basis.EndAnvilBlock;
@ -21,36 +29,32 @@ import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.recipe.builders.AnvilRecipe; import ru.betterend.recipe.builders.AnvilRecipe;
import ru.betterend.recipe.builders.InfusionRecipe; import ru.betterend.recipe.builders.InfusionRecipe;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import org.jetbrains.annotations.ApiStatus; import ru.betterend.registry.EndItems;
import ru.betterend.registry.EndPortals;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
//https://github.com/shedaniel/RoughlyEnoughItems/blob/6.x-1.17/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java //https://github.com/shedaniel/RoughlyEnoughItems/blob/6.x-1.17/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
@Environment(EnvType.CLIENT) public class REIPlugin implements REIClientPlugin {
@ApiStatus.Internal
public class REIPlugin implements me.shedaniel.rei.api.client.plugins.REIClientPlugin {
public final static int VAL = 13;
public final static ResourceLocation PLUGIN_ID = BetterEnd.makeID("rei_plugin"); public final static ResourceLocation PLUGIN_ID = BetterEnd.makeID("rei_plugin");
public final static CategoryIdentifier ALLOYING_FUEL = CategoryIdentifier.of(BetterEnd.MOD_ID, "alloying_fuel"); public final static CategoryIdentifier ALLOYING_FUEL = CategoryIdentifier.of(BetterEnd.MOD_ID, "alloying_fuel");
public final static CategoryIdentifier ALLOYING = AlloyingRecipe.ID; public final static CategoryIdentifier ALLOYING = AlloyingRecipe.ID;
public final static CategoryIdentifier SMITHING = CategoryIdentifier.of(BetterEnd.MOD_ID, AnvilRecipe.ID.getPath()); public final static CategoryIdentifier SMITHING = CategoryIdentifier.of(BetterEnd.MOD_ID, AnvilRecipe.ID.getPath());
public final static CategoryIdentifier INFUSION = InfusionRecipe.ID; public final static CategoryIdentifier INFUSION = InfusionRecipe.ID;
public final static EntryStack END_STONE_SMELTER = EntryStacks.of(EndBlocks.END_STONE_SMELTER); public final static EntryStack END_STONE_SMELTER;// = EntryStacks.of(EndBlocks.END_STONE_SMELTER);
public final static EntryStack INFUSION_RITUAL = EntryStacks.of(EndBlocks.INFUSION_PEDESTAL); //public final static EntryStack INFUSION_RITUAL = EntryStacks.of(EndBlocks.INFUSION_PEDESTAL);
public final static EntryStack[] FURNACES; //public final static EntryStack[] FURNACES;
public final static EntryStack[] ANVILS; //public final static EntryStack[] ANVILS;
//@Override //@Override
//public ResourceLocation getPluginIdentifier() { //public ResourceLocation getPluginIdentifier() {
// return PLUGIN_ID; // return PLUGIN_ID;
//} //}
//public REIPlugin() {
// ClientInternals.attachInstance((Supplier<Object>) () -> this, PLUGIN_ID);
//}
/*@Override /*@Override
public void registerRecipeDisplays(RecipeHelper recipeHelper) { public void registerRecipeDisplays(RecipeHelper recipeHelper) {
@ -64,6 +68,14 @@ public class REIPlugin implements me.shedaniel.rei.api.client.plugins.REIClientP
} }
}); });
}*/ }*/
@Override
public void registerDisplays(DisplayRegistry registry) {
registry.registerRecipeFiller(AlloyingRecipe.class, AlloyingRecipe.TYPE, REIAlloyingDisplay::new);
registry.registerRecipeFiller(BlastingRecipe.class, RecipeType.BLASTING, REIBlastingDisplay::new);
registry.registerRecipeFiller(AnvilRecipe.class, AnvilRecipe.TYPE, REIAnvilDisplay::new);
registry.registerRecipeFiller(InfusionRecipe.class, InfusionRecipe.TYPE, REIInfusionDisplay::new);
}
@Override @Override
public void registerCategories(CategoryRegistry registry) { public void registerCategories(CategoryRegistry registry) {
@ -74,24 +86,30 @@ public class REIPlugin implements me.shedaniel.rei.api.client.plugins.REIClientP
new REIAnvilCategory() new REIAnvilCategory()
); );
registry.addWorkstations(ALLOYING_FUEL, END_STONE_SMELTER); //registry.addWorkstations(ALLOYING_FUEL, END_STONE_SMELTER);
registry.addWorkstations(ALLOYING, END_STONE_SMELTER); //registry.addWorkstations(ALLOYING, END_STONE_SMELTER);
registry.addWorkstations(INFUSION, INFUSION_RITUAL); //registry.addWorkstations(INFUSION, INFUSION_RITUAL);
registry.addWorkstations(SMITHING, ANVILS); //registry.addWorkstations(SMITHING, ANVILS);
registry.removePlusButton(ALLOYING_FUEL); registry.removePlusButton(ALLOYING_FUEL);
registry.removePlusButton(SMITHING); registry.removePlusButton(SMITHING);
registry.addWorkstations(DefaultPlugin.SMELTING, FURNACES); //registry.addWorkstations(DefaultPlugin.SMELTING, FURNACES);
registry.addWorkstations(DefaultPlugin.FUEL, FURNACES); //registry.addWorkstations(DefaultPlugin.FUEL, FURNACES);
}
}
static EntryType<ItemStack> BLOCK = EntryType.deferred(new ResourceLocation("block"));
static { static {
List<EntryStack> anvils = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks().stream() //initialize static state
EndPortals.loadPortals();
System.out.println(EndBlocks.END_STONE_SMELTER + " - " + EndBlocks.END_STONE_SMELTER.asItem());
//END_STONE_SMELTER = EntryStacks.of(EndBlocks.END_STONE_SMELTER.asItem());
/*List<EntryStack> anvils = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks().stream()
.filter(EndAnvilBlock.class::isInstance).collect(Collectors.toList()))); .filter(EndAnvilBlock.class::isInstance).collect(Collectors.toList())));
anvils.add(0, EntryStacks.of(Blocks.ANVIL)); anvils.add(0, EntryStacks.of(Blocks.ANVIL));
ANVILS = anvils.toArray(new EntryStack[0]); ANVILS = anvils.toArray(new EntryStack[0]);*/
FURNACES = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks().stream()
/*FURNACES = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks().stream()
.filter(BaseFurnaceBlock.class::isInstance).collect(Collectors.toList()))) .filter(BaseFurnaceBlock.class::isInstance).collect(Collectors.toList())))
.toArray(new EntryStack[0]); .toArray(new EntryStack[0]);*/
} }
} }

View file

@ -31,11 +31,8 @@
"ru.betterend.client.BetterEndClient" "ru.betterend.client.BetterEndClient"
], ],
"rei_plugins": [ "rei_plugins": [
"ru.betterend.integration.rei.REIPlugin" "ru.betterend.integration.rei.REIPlugin"
], ]
"rei_containers": [
"ru.betterend.integration.rei.REIContainer"
]
}, },
"mixins": [ "mixins": [
"betterend.mixins.common.json", "betterend.mixins.common.json",