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 me.shedaniel.math.Point;
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.Widgets;
import me.shedaniel.rei.api.client.registry.display.TransferDisplayCategory;
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.util.EntryStacks;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.NotNull;
import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.registry.EndBlocks;
import java.text.DecimalFormat;
@ -37,7 +36,8 @@ public class REIAlloyingCategory implements TransferDisplayCategory<REIAlloyingD
@Override
public @NotNull EntryStack getIcon() {
return REIPlugin.END_STONE_SMELTER;
//return REIPluginClient.END_STONE_SMELTER;
return EntryStacks.of(Items.COAL);
}
@Override

View file

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

View file

@ -8,7 +8,7 @@ import net.minecraft.nbt.CompoundTag;
import java.util.Collections;
import java.util.List;
public class REIAlloyingFuelDisplay extends BasicDisplay {
public abstract class REIAlloyingFuelDisplay extends BasicDisplay {
private final int fuelTime;
public REIAlloyingFuelDisplay(List<EntryIngredient> fuel, CompoundTag tag) {
@ -24,10 +24,10 @@ public class REIAlloyingFuelDisplay extends BasicDisplay {
this.fuelTime = fuelTime;
}*/
@Override
/*@Override
public CategoryIdentifier<?> getCategoryIdentifier() {
return REIPlugin.ALLOYING_FUEL;
}
return REIPluginClient.ALLOYING_FUEL;
}*/
public int getFuelTime() {
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.entry.EntryIngredient;
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.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
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.Blocks;
import org.jetbrains.annotations.NotNull;
import ru.betterend.blocks.basis.EndAnvilBlock;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@ -39,11 +40,12 @@ public class REIAnvilCategory implements TransferDisplayCategory<REIAnvilDisplay
@Override
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) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10);
List<Widget> widgets = Lists.newArrayList();
@ -54,7 +56,7 @@ public class REIAnvilCategory implements TransferDisplayCategory<REIAnvilDisplay
List<EntryIngredient> inputEntries = display.getInputEntries();
EntryIngredient materials = inputEntries.get(1);
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();
if (block instanceof EndAnvilBlock) {
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));
return widgets;
}
}*/
@Override
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;
import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
import ru.betterend.recipe.builders.AlloyingRecipe;
public class REIContainer implements Runnable {
@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.entry.EntryIngredient;
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.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.NotNull;
import ru.betterend.BetterEnd;
import ru.betterend.registry.EndBlocks;
@ -36,7 +38,8 @@ public class REIInfusionCategory implements TransferDisplayCategory<REIInfusionD
@Override
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 me.shedaniel.rei.api.client.plugins.REIClientPlugin;
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.entry.EntryIngredient;
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.EntryStacks;
import me.shedaniel.rei.impl.ClientInternals;
import me.shedaniel.rei.impl.Internals;
import me.shedaniel.rei.plugin.common.DefaultPlugin;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
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 org.jetbrains.annotations.ApiStatus;
import ru.bclib.blocks.BaseFurnaceBlock;
import ru.betterend.BetterEnd;
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.InfusionRecipe;
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.function.Supplier;
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
@Environment(EnvType.CLIENT)
@ApiStatus.Internal
public class REIPlugin implements me.shedaniel.rei.api.client.plugins.REIClientPlugin {
public class REIPlugin implements REIClientPlugin {
public final static int VAL = 13;
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 = AlloyingRecipe.ID;
public final static CategoryIdentifier SMITHING = CategoryIdentifier.of(BetterEnd.MOD_ID, AnvilRecipe.ID.getPath());
public final static CategoryIdentifier INFUSION = InfusionRecipe.ID;
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[] FURNACES;
public final static EntryStack[] ANVILS;
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[] FURNACES;
//public final static EntryStack[] ANVILS;
//@Override
//public ResourceLocation getPluginIdentifier() {
// return PLUGIN_ID;
//}
//public REIPlugin() {
// ClientInternals.attachInstance((Supplier<Object>) () -> this, PLUGIN_ID);
//}
/*@Override
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
public void registerCategories(CategoryRegistry registry) {
@ -74,24 +86,30 @@ public class REIPlugin implements me.shedaniel.rei.api.client.plugins.REIClientP
new REIAnvilCategory()
);
registry.addWorkstations(ALLOYING_FUEL, END_STONE_SMELTER);
registry.addWorkstations(ALLOYING, END_STONE_SMELTER);
registry.addWorkstations(INFUSION, INFUSION_RITUAL);
registry.addWorkstations(SMITHING, ANVILS);
//registry.addWorkstations(ALLOYING_FUEL, END_STONE_SMELTER);
//registry.addWorkstations(ALLOYING, END_STONE_SMELTER);
//registry.addWorkstations(INFUSION, INFUSION_RITUAL);
//registry.addWorkstations(SMITHING, ANVILS);
registry.removePlusButton(ALLOYING_FUEL);
registry.removePlusButton(SMITHING);
registry.addWorkstations(DefaultPlugin.SMELTING, FURNACES);
registry.addWorkstations(DefaultPlugin.FUEL, FURNACES);
}
//registry.addWorkstations(DefaultPlugin.SMELTING, FURNACES);
//registry.addWorkstations(DefaultPlugin.FUEL, FURNACES);
}
static EntryType<ItemStack> BLOCK = EntryType.deferred(new ResourceLocation("block"));
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())));
anvils.add(0, EntryStacks.of(Blocks.ANVIL));
ANVILS = anvils.toArray(new EntryStack[0]);
FURNACES = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks().stream()
ANVILS = anvils.toArray(new EntryStack[0]);*/
/*FURNACES = Lists.newArrayList(EntryIngredients.ofItems(EndBlocks.getModBlocks().stream()
.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"
],
"rei_plugins": [
"ru.betterend.integration.rei.REIPlugin"
],
"rei_containers": [
"ru.betterend.integration.rei.REIContainer"
]
"ru.betterend.integration.rei.REIPlugin"
]
},
"mixins": [
"betterend.mixins.common.json",