Some fixes for **rei** 6.x
This commit is contained in:
parent
63b524af62
commit
aa1b0d87bb
4 changed files with 113 additions and 124 deletions
|
@ -1,47 +1,52 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
|
||||
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay;
|
||||
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
|
||||
import me.shedaniel.rei.api.common.entry.EntryStack;
|
||||
import me.shedaniel.rei.api.common.util.EntryIngredients;
|
||||
import me.shedaniel.rei.api.common.util.EntryStacks;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.crafting.BlastingRecipe;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.TransferRecipeDisplay;
|
||||
import me.shedaniel.rei.server.ContainerInfo;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.crafting.BlastingRecipe;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
|
||||
public class REIAlloyingDisplay implements TransferRecipeDisplay {
|
||||
public class REIAlloyingDisplay extends BasicDisplay implements SimpleGridMenuDisplay {
|
||||
|
||||
private static List<EntryStack> fuel;
|
||||
|
||||
private Recipe<?> recipe;
|
||||
private List<List<EntryStack>> input;
|
||||
private List<EntryStack> output;
|
||||
private float xp;
|
||||
private double smeltTime;
|
||||
|
||||
|
||||
|
||||
public REIAlloyingDisplay(AlloyingRecipe recipe) {
|
||||
super(
|
||||
EntryIngredients.ofIngredients(recipe.getIngredients()),
|
||||
Collections.singletonList(EntryIngredients.of(recipe.getResultItem()))
|
||||
);
|
||||
this.recipe = recipe;
|
||||
this.input = EntryStack.ofIngredients(recipe.getIngredients());
|
||||
this.output = Collections.singletonList(EntryStack.create(recipe.getResultItem()));
|
||||
this.xp = recipe.getExperience();
|
||||
this.smeltTime = recipe.getSmeltTime();
|
||||
}
|
||||
|
||||
public REIAlloyingDisplay(BlastingRecipe recipe) {
|
||||
super(
|
||||
EntryIngredients.ofIngredients(recipe.getIngredients()),
|
||||
Collections.singletonList(EntryIngredients.of(recipe.getResultItem()))
|
||||
);
|
||||
this.recipe = recipe;
|
||||
this.input = EntryStack.ofIngredients(recipe.getIngredients());
|
||||
this.output = Collections.singletonList(EntryStack.create(recipe.getResultItem()));
|
||||
this.xp = recipe.getExperience();
|
||||
this.smeltTime = recipe.getCookingTime();
|
||||
}
|
||||
|
@ -51,29 +56,19 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Optional<ResourceLocation> getRecipeLocation() {
|
||||
public @NotNull Optional<ResourceLocation> getDisplayLocation() {
|
||||
return Optional.ofNullable(recipe).map(Recipe::getId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getInputEntries() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getResultingEntries() {
|
||||
return Collections.singletonList(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ResourceLocation getRecipeCategory() {
|
||||
public CategoryIdentifier<?> getCategoryIdentifier() {
|
||||
return AlloyingRecipe.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
return this.input;
|
||||
}
|
||||
// @Override
|
||||
// public @NotNull List<List<EntryStack>> getRequiredEntries() {
|
||||
// return this.input;
|
||||
// }
|
||||
|
||||
public float getXp() {
|
||||
return this.xp;
|
||||
|
@ -97,14 +92,14 @@ public class REIAlloyingDisplay implements TransferRecipeDisplay {
|
|||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<AbstractContainerMenu> containerInfo, AbstractContainerMenu container) {
|
||||
return this.input;
|
||||
}
|
||||
// @Override
|
||||
// public List<List<EntryStack>> getOrganisedInputEntries(ContainerInfo<AbstractContainerMenu> containerInfo, AbstractContainerMenu container) {
|
||||
// return this.input;
|
||||
// }
|
||||
|
||||
static {
|
||||
fuel = EndStoneSmelterBlockEntity.availableFuels().keySet().stream()
|
||||
.map(Item::getDefaultInstance).map(EntryStack::create)
|
||||
.map(Item::getDefaultInstance).map(EntryStacks::of)
|
||||
.map(e -> e.setting(EntryStack.Settings.TOOLTIP_APPEND_EXTRA, stack -> Collections.singletonList(new TranslatableComponent("category.rei.smelting.fuel")
|
||||
.withStyle(ChatFormatting.YELLOW)))).collect(Collectors.toList());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue