improved rei compat (#2054)
This commit is contained in:
parent
3920ff79d9
commit
a88d34b87f
7 changed files with 28 additions and 19 deletions
|
@ -72,7 +72,7 @@ dependencies {
|
||||||
//Fabric api
|
//Fabric api
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.4.29+build.290-1.15"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:0.4.29+build.290-1.15"
|
||||||
|
|
||||||
optionalDependency ("me.shedaniel:RoughlyEnoughItems:3.2.31")
|
optionalDependency ("me.shedaniel:RoughlyEnoughItems:3.6.0")
|
||||||
optionalDependency ('io.github.cottonmc:LibCD:2.0.1+1.15')
|
optionalDependency ('io.github.cottonmc:LibCD:2.0.1+1.15')
|
||||||
|
|
||||||
def rcVersion = 'RebornCore:RebornCore-1.15:+'
|
def rcVersion = 'RebornCore:RebornCore-1.15:+'
|
||||||
|
|
|
@ -81,36 +81,35 @@ public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCate
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Widget> setupDisplay(Supplier<MachineRecipeDisplay<R>> recipeDisplaySupplier, Rectangle bounds) {
|
public List<Widget> setupDisplay(Supplier<MachineRecipeDisplay<R>> recipeDisplaySupplier, Rectangle bounds) {
|
||||||
|
|
||||||
MachineRecipeDisplay<R> machineRecipe = recipeDisplaySupplier.get();
|
MachineRecipeDisplay<R> machineRecipe = recipeDisplaySupplier.get();
|
||||||
|
|
||||||
Point startPoint = new Point( bounds.getCenterX() - 41, bounds.getCenterY() - recipeLines*12 -1);
|
Point startPoint = new Point( bounds.getCenterX() - 41, bounds.getCenterY() - recipeLines*12 -1);
|
||||||
|
|
||||||
List<Widget> widgets = new LinkedList<>();
|
List<Widget> widgets = new LinkedList<>();
|
||||||
widgets.add(new RecipeBaseWidget(bounds));
|
widgets.add(new RecipeBaseWidget(bounds));
|
||||||
widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 1, true));
|
widgets.add(RecipeArrowWidget.create(new Point(startPoint.x + 24, startPoint.y + 1), true).time(machineRecipe.getTime() * 50.0));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (List<EntryStack> inputs : machineRecipe.getInputEntries()){
|
for (List<EntryStack> inputs : machineRecipe.getInputEntries()){
|
||||||
widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)).entries(inputs));
|
widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)).entries(inputs).markIsInput());
|
||||||
}
|
}
|
||||||
|
|
||||||
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
|
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
|
||||||
LabelWidget costLabel;
|
LabelWidget costLabel;
|
||||||
widgets.add(costLabel = new LabelWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), energyPerTick.asFormattedString()));
|
widgets.add(costLabel = LabelWidget.create(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)), energyPerTick.asFormattedString()));
|
||||||
costLabel.setHasShadows(false);
|
costLabel.setHasShadows(false);
|
||||||
costLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
costLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (EntryStack outputs : machineRecipe.getOutputEntries()){
|
for (EntryStack outputs : machineRecipe.getOutputEntries()){
|
||||||
widgets.add(EntryWidget.create(startPoint.x + 61, startPoint.y + 1 + (i++ * 20)).entry(outputs));
|
widgets.add(EntryWidget.create(startPoint.x + 61, startPoint.y + 1 + (i++ * 20)).entry(outputs).markIsOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
int heat = machineRecipe.getHeat();
|
int heat = machineRecipe.getHeat();
|
||||||
if (heat > 0) {
|
if (heat > 0) {
|
||||||
String neededHeat = heat + " " + StringUtils.t("techreborn.jei.recipe.heat");
|
String neededHeat = heat + " " + StringUtils.t("techreborn.jei.recipe.heat");
|
||||||
LabelWidget heatLabel;
|
LabelWidget heatLabel;
|
||||||
widgets.add(heatLabel = new LabelWidget(startPoint.x + 61, startPoint.y + 1 + (i++ * 20), neededHeat));
|
widgets.add(heatLabel = LabelWidget.create(new Point(startPoint.x + 61, startPoint.y + 1 + (i++ * 20)), neededHeat));
|
||||||
heatLabel.setHasShadows(false);
|
heatLabel.setHasShadows(false);
|
||||||
heatLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
heatLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,14 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
|
||||||
private List<EntryStack> outputs;
|
private List<EntryStack> outputs;
|
||||||
private int energy = 0;
|
private int energy = 0;
|
||||||
private int heat = 0;
|
private int heat = 0;
|
||||||
|
private int time = 0;
|
||||||
private FluidInstance fluidInstance = null;
|
private FluidInstance fluidInstance = null;
|
||||||
|
|
||||||
public MachineRecipeDisplay(R recipe) {
|
public MachineRecipeDisplay(R recipe) {
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), RebornEntryStack::create));
|
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), RebornEntryStack::create));
|
||||||
this.outputs = CollectionUtils.map(recipe.getOutputs(), RebornEntryStack::create);
|
this.outputs = CollectionUtils.map(recipe.getOutputs(), RebornEntryStack::create);
|
||||||
|
this.time = recipe.getTime();
|
||||||
this.energy = recipe.getPower();
|
this.energy = recipe.getPower();
|
||||||
if (recipe instanceof BlastFurnaceRecipe) {
|
if (recipe instanceof BlastFurnaceRecipe) {
|
||||||
this.heat = ((BlastFurnaceRecipe) recipe).getHeat();
|
this.heat = ((BlastFurnaceRecipe) recipe).getHeat();
|
||||||
|
@ -73,6 +75,10 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
|
||||||
return heat;
|
return heat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
public FluidInstance getFluidInstance() {
|
public FluidInstance getFluidInstance() {
|
||||||
return fluidInstance;
|
return fluidInstance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
package techreborn.compat.rei;
|
package techreborn.compat.rei;
|
||||||
|
|
||||||
import me.shedaniel.rei.RoughlyEnoughItemsCore;
|
import me.shedaniel.rei.api.EntryRegistry;
|
||||||
import me.shedaniel.rei.api.EntryStack;
|
import me.shedaniel.rei.api.EntryStack;
|
||||||
import me.shedaniel.rei.api.RecipeDisplay;
|
import me.shedaniel.rei.api.RecipeDisplay;
|
||||||
import me.shedaniel.rei.api.RecipeHelper;
|
import me.shedaniel.rei.api.RecipeHelper;
|
||||||
|
@ -169,7 +169,7 @@ public class ReiPlugin implements REIPluginV0 {
|
||||||
public void postRegister() {
|
public void postRegister() {
|
||||||
// Alright we are going to apply check tags to cells, this should not take long at all.
|
// Alright we are going to apply check tags to cells, this should not take long at all.
|
||||||
// Check Tags will not check the amount of the ItemStack, but will enable checking their tags.
|
// Check Tags will not check the amount of the ItemStack, but will enable checking their tags.
|
||||||
for (EntryStack stack : RoughlyEnoughItemsCore.getEntryRegistry().getStacksList())
|
for (EntryStack stack : EntryRegistry.getInstance().getStacksList())
|
||||||
applyCellEntry(stack);
|
applyCellEntry(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ public class ReiPlugin implements REIPluginV0 {
|
||||||
private void registerFluidGeneratorDisplays(RecipeHelper recipeHelper, EFluidGenerator generator, Machine machine) {
|
private void registerFluidGeneratorDisplays(RecipeHelper recipeHelper, EFluidGenerator generator, Machine machine) {
|
||||||
Identifier identifier = new Identifier(TechReborn.MOD_ID, machine.name);
|
Identifier identifier = new Identifier(TechReborn.MOD_ID, machine.name);
|
||||||
GeneratorRecipeHelper.getFluidRecipesForGenerator(generator).getRecipes().forEach(recipe -> {
|
GeneratorRecipeHelper.getFluidRecipesForGenerator(generator).getRecipes().forEach(recipe -> {
|
||||||
recipeHelper.registerDisplay(identifier, new FluidGeneratorRecipeDisplay(recipe, identifier));
|
recipeHelper.registerDisplay(new FluidGeneratorRecipeDisplay(recipe, identifier));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,22 +68,21 @@ public class FluidGeneratorRecipeCategory implements RecipeCategory<FluidGenerat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Widget> setupDisplay(Supplier<FluidGeneratorRecipeDisplay> recipeDisplaySupplier, Rectangle bounds) {
|
public List<Widget> setupDisplay(Supplier<FluidGeneratorRecipeDisplay> recipeDisplaySupplier, Rectangle bounds) {
|
||||||
|
|
||||||
FluidGeneratorRecipeDisplay machineRecipe = recipeDisplaySupplier.get();
|
FluidGeneratorRecipeDisplay machineRecipe = recipeDisplaySupplier.get();
|
||||||
|
|
||||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
||||||
|
|
||||||
List<Widget> widgets = new LinkedList<>();
|
List<Widget> widgets = new LinkedList<>();
|
||||||
widgets.add(new RecipeBaseWidget(bounds));
|
widgets.add(new RecipeBaseWidget(bounds));
|
||||||
widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 1, true));
|
widgets.add(RecipeArrowWidget.create(new Point(startPoint.x + 24, startPoint.y + 1), true).time(1000.0));
|
||||||
|
|
||||||
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
|
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
|
||||||
widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1).entries(inputs));
|
widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1).entries(inputs).markIsInput());
|
||||||
}
|
}
|
||||||
|
|
||||||
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.generator.total", machineRecipe.getTotalEnergy());
|
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.generator.total", machineRecipe.getTotalEnergy());
|
||||||
LabelWidget costLabel;
|
LabelWidget costLabel;
|
||||||
widgets.add(costLabel = new LabelWidget(bounds.getCenterX(), startPoint.y + 20, energyPerTick.asFormattedString()));
|
widgets.add(costLabel = LabelWidget.create(new Point(bounds.getCenterX(), startPoint.y + 20), energyPerTick.asFormattedString()));
|
||||||
costLabel.setHasShadows(false);
|
costLabel.setHasShadows(false);
|
||||||
costLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
costLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||||
|
|
||||||
|
|
|
@ -69,28 +69,27 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplic
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Widget> setupDisplay(Supplier<FluidReplicatorRecipeDisplay> recipeDisplaySupplier, Rectangle bounds) {
|
public List<Widget> setupDisplay(Supplier<FluidReplicatorRecipeDisplay> recipeDisplaySupplier, Rectangle bounds) {
|
||||||
|
|
||||||
FluidReplicatorRecipeDisplay machineRecipe = recipeDisplaySupplier.get();
|
FluidReplicatorRecipeDisplay machineRecipe = recipeDisplaySupplier.get();
|
||||||
|
|
||||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
||||||
|
|
||||||
List<Widget> widgets = new LinkedList<>();
|
List<Widget> widgets = new LinkedList<>();
|
||||||
widgets.add(new RecipeBaseWidget(bounds));
|
widgets.add(new RecipeBaseWidget(bounds));
|
||||||
widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 1, true));
|
widgets.add(RecipeArrowWidget.create(new Point(startPoint.x + 24, startPoint.y + 1), true).time(machineRecipe.getTime() * 50.0));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
|
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
|
||||||
widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)).entries(inputs));
|
widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)).entries(inputs).markIsInput());
|
||||||
}
|
}
|
||||||
|
|
||||||
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
|
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
|
||||||
LabelWidget costLabel;
|
LabelWidget costLabel;
|
||||||
widgets.add(costLabel = new LabelWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), energyPerTick.asFormattedString()));
|
widgets.add(costLabel = LabelWidget.create(new Point(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)), energyPerTick.asFormattedString()));
|
||||||
costLabel.setHasShadows(false);
|
costLabel.setHasShadows(false);
|
||||||
costLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
costLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||||
|
|
||||||
if (!machineRecipe.getOutputEntries().isEmpty())
|
if (!machineRecipe.getOutputEntries().isEmpty())
|
||||||
widgets.add(EntryWidget.create(startPoint.x + 61, startPoint.y + 1).entries(machineRecipe.getOutputEntries()));
|
widgets.add(EntryWidget.create(startPoint.x + 61, startPoint.y + 1).entries(machineRecipe.getOutputEntries()).markIsOutput());
|
||||||
|
|
||||||
return widgets;
|
return widgets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
||||||
private List<EntryStack> output;
|
private List<EntryStack> output;
|
||||||
private FluidInstance fluidInstance;
|
private FluidInstance fluidInstance;
|
||||||
private int energy = 0;
|
private int energy = 0;
|
||||||
|
private int time = 0;
|
||||||
|
|
||||||
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
|
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
|
@ -52,6 +53,7 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
||||||
this.fluidInstance = recipe.getFluidInstance();
|
this.fluidInstance = recipe.getFluidInstance();
|
||||||
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(RebornEntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
|
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(RebornEntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount().getRawValue()));
|
||||||
this.energy = recipe.getPower();
|
this.energy = recipe.getPower();
|
||||||
|
this.time = recipe.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FluidInstance getFluidInstance() {
|
public FluidInstance getFluidInstance() {
|
||||||
|
@ -62,6 +64,10 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
||||||
return energy;
|
return energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<List<EntryStack>> getInputEntries() {
|
public List<List<EntryStack>> getInputEntries() {
|
||||||
return inputs;
|
return inputs;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue