diff options
| author | Danielshe <shekwancheung0528@gmail.com> | 2019-11-03 14:44:52 +0800 |
|---|---|---|
| committer | Danielshe <shekwancheung0528@gmail.com> | 2019-11-03 14:44:59 +0800 |
| commit | 9f5a9eae9a7863412cc5eb433bf15e5ee71da616 (patch) | |
| tree | 0e6b0b94af061c5e9023b1ff19f339a6c30149be /src/main/java/me/shedaniel/rei/plugin/blasting | |
| parent | 3e3e25855b9f6df507a7d4c8a07c64b9a502fae2 (diff) | |
| download | RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.tar.gz RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.tar.bz2 RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.zip | |
3.2.1
Diffstat (limited to 'src/main/java/me/shedaniel/rei/plugin/blasting')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java | 92 | ||||
| -rw-r--r-- | src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java | 68 |
2 files changed, 3 insertions, 157 deletions
diff --git a/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java b/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java deleted file mode 100644 index 4c5f3dac3..000000000 --- a/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Roughly Enough Items by Danielshe. - * Licensed under the MIT License. - */ - -package me.shedaniel.rei.plugin.blasting; - -import com.mojang.blaze3d.systems.RenderSystem; -import it.unimi.dsi.fastutil.ints.IntList; -import me.shedaniel.math.api.Point; -import me.shedaniel.math.api.Rectangle; -import me.shedaniel.rei.api.Renderer; -import me.shedaniel.rei.api.TransferRecipeCategory; -import me.shedaniel.rei.gui.renderers.RecipeRenderer; -import me.shedaniel.rei.gui.widget.RecipeArrowWidget; -import me.shedaniel.rei.gui.widget.RecipeBaseWidget; -import me.shedaniel.rei.gui.widget.SlotWidget; -import me.shedaniel.rei.gui.widget.Widget; -import me.shedaniel.rei.plugin.DefaultPlugin; -import net.minecraft.block.Blocks; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; -import net.minecraft.client.render.GuiLighting; -import net.minecraft.client.resource.language.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Formatting; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; - -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.function.Supplier; - -public class DefaultBlastingCategory implements TransferRecipeCategory<DefaultBlastingDisplay> { - - @Override - public Identifier getIdentifier() { - return DefaultPlugin.BLASTING; - } - - @Override - public Renderer getIcon() { - return Renderer.fromItemStack(new ItemStack(Blocks.BLAST_FURNACE)); - } - - @Override - public String getCategoryName() { - return I18n.translate("category.rei.blasting"); - } - - @Override - public RecipeRenderer getSimpleRenderer(DefaultBlastingDisplay recipe) { - return Renderer.fromRecipe(() -> Arrays.asList(recipe.getInput().get(0)), recipe::getOutput); - } - - @Override - public List<Widget> setupDisplay(Supplier<DefaultBlastingDisplay> recipeDisplaySupplier, Rectangle bounds) { - final DefaultBlastingDisplay recipeDisplay = recipeDisplaySupplier.get(); - Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27); - List<Widget> widgets = new LinkedList<>(Arrays.asList(new RecipeBaseWidget(bounds) { - @Override - public void render(int mouseX, int mouseY, float delta) { - super.render(mouseX, mouseY, delta); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiLighting.disable(); - MinecraftClient.getInstance().getTextureManager().bindTexture(DefaultPlugin.getDisplayTexture()); - blit(startPoint.x, startPoint.y, 0, 54, 82, 54); - int height = MathHelper.ceil((System.currentTimeMillis() / 250 % 14d) / 1f); - blit(startPoint.x + 2, startPoint.y + 21 + (14 - height), 82, 77 + (14 - height), 14, height); - } - })); - widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 18, true)); - List<List<ItemStack>> input = recipeDisplay.getInput(); - widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1, Renderer.fromItemStacks(input.get(0)), true, true, true)); - widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 37, Renderer.fromItemStacks(() -> recipeDisplay.getFuel(), true, stack -> Collections.singletonList(Formatting.YELLOW.toString() + I18n.translate("category.rei.smelting.fuel"))), true, true, true)); - widgets.add(new SlotWidget(startPoint.x + 61, startPoint.y + 19, Renderer.fromItemStacks(recipeDisplay.getOutput()), false, true, true)); - return widgets; - } - - @Override - public void renderRedSlots(List<Widget> widgets, Rectangle bounds, DefaultBlastingDisplay display, IntList redSlots) { - Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 27); - RenderSystem.translatef(0, 0, 400); - if (redSlots.contains(0)) { - DrawableHelper.fill(startPoint.x + 1, startPoint.y + 1, startPoint.x + 1 + 16, startPoint.y + 1 + 16, 822018048); - } - RenderSystem.translatef(0, 0, -400); - } - -} diff --git a/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java index 52f521a99..510d5eb96 100644 --- a/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java @@ -5,81 +5,19 @@ package me.shedaniel.rei.plugin.blasting; -import me.shedaniel.rei.api.TransferRecipeDisplay; import me.shedaniel.rei.plugin.DefaultPlugin; -import me.shedaniel.rei.server.ContainerInfo; -import net.minecraft.block.entity.FurnaceBlockEntity; -import net.minecraft.container.Container; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.recipe.AbstractCookingRecipe; +import me.shedaniel.rei.plugin.cooking.DefaultCookingDisplay; import net.minecraft.recipe.BlastingRecipe; import net.minecraft.util.Identifier; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -public class DefaultBlastingDisplay implements TransferRecipeDisplay { - - private BlastingRecipe display; - private List<List<ItemStack>> input; - private List<ItemStack> output; +public class DefaultBlastingDisplay extends DefaultCookingDisplay { public DefaultBlastingDisplay(BlastingRecipe recipe) { - this.display = recipe; - this.input = recipe.getPreviewInputs().stream().map(i -> Arrays.asList(i.getMatchingStacksClient())).collect(Collectors.toList()); - this.input.add(FurnaceBlockEntity.createFuelTimeMap().keySet().stream().map(Item::getStackForRender).collect(Collectors.toList())); - this.output = Collections.singletonList(recipe.getOutput()); - } - - @Override - public Optional<Identifier> getRecipeLocation() { - return Optional.ofNullable(display).map(AbstractCookingRecipe::getId); - } - - @Override - public List<List<ItemStack>> getInput() { - return input; - } - - public List<ItemStack> getFuel() { - return input.get(1); - } - - @Override - public List<ItemStack> getOutput() { - return output; + super(recipe); } @Override public Identifier getRecipeCategory() { return DefaultPlugin.BLASTING; } - - @Override - public List<List<ItemStack>> getRequiredItems() { - return input; - } - - public Optional<BlastingRecipe> getOptionalRecipe() { - return Optional.ofNullable(display); - } - - @Override - public int getWidth() { - return 1; - } - - @Override - public int getHeight() { - return 1; - } - - @Override - public List<List<ItemStack>> getOrganisedInput(ContainerInfo<Container> containerInfo, Container container) { - return display.getPreviewInputs().stream().map(i -> Arrays.asList(i.getMatchingStacksClient())).collect(Collectors.toList()); - } } |
