From 20ab49e46e047db3f7cda54503a8e9e607986a9b Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Mon, 11 May 2020 17:48:00 +0200 Subject: [PATCH] Better game element rendering in GUIs - Fixed uv issues with connected textures - Fixed chromatic scope not showing on blockzappers - Refactored game element rendering in user interfaces, such as JEI screens --- .../jei/category/BlastingViaFanCategory.java | 30 +-- .../jei/category/BlockCuttingCategory.java | 3 +- .../category/BlockzapperUpgradeCategory.java | 9 +- .../compat/jei/category/CrushingCategory.java | 2 +- .../category/MechanicalCraftingCategory.java | 5 +- .../compat/jei/category/MillingCategory.java | 4 +- .../compat/jei/category/MixingCategory.java | 2 +- .../compat/jei/category/PackingCategory.java | 2 +- .../compat/jei/category/PressingCategory.java | 2 +- .../category/ProcessingViaFanCategory.java | 54 ++-- .../compat/jei/category/SawingCategory.java | 3 +- .../jei/category/SmokingViaFanCategory.java | 9 +- .../jei/category/SplashingCategory.java | 39 +-- .../category/animations/AnimatedCrafter.java | 57 ++-- .../animations/AnimatedCrushingWheels.java | 56 ++-- .../category/animations/AnimatedKinetics.java | 15 ++ .../animations/AnimatedMillstone.java | 51 +--- .../category/animations/AnimatedMixer.java | 88 ++---- .../category/animations/AnimatedPress.java | 92 ++----- .../jei/category/animations/AnimatedSaw.java | 56 ++-- .../foundation/block/connected/CTModel.java | 2 +- .../create/foundation/gui/GuiGameElement.java | 251 ++++++++++++++++++ .../foundation/gui/ScreenElementRenderer.java | 130 --------- .../goggle/GoggleOverlayRenderer.java | 45 ++-- .../sequencer/SequencedGearshiftScreen.java | 30 ++- .../blockzapper/BlockzapperItemRenderer.java | 30 ++- .../zapper/blockzapper/BlockzapperModel.java | 2 +- .../logistics/block/StockswitchScreen.java | 40 +-- .../block/inventories/FlexcrateScreen.java | 36 +-- 29 files changed, 543 insertions(+), 602 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java delete mode 100644 src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java diff --git a/src/main/java/com/simibubi/create/compat/jei/category/BlastingViaFanCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/BlastingViaFanCategory.java index 09639ad45..96b526d40 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/BlastingViaFanCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/BlastingViaFanCategory.java @@ -2,11 +2,9 @@ package com.simibubi.create.compat.jei.category; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FlowingFluidBlock; +import net.minecraft.fluid.Fluids; import net.minecraft.item.Items; import net.minecraft.item.crafting.AbstractCookingRecipe; @@ -23,28 +21,12 @@ public class BlastingViaFanCategory extends ProcessingViaFanCategory state); - RenderSystem.popMatrix(); - RenderSystem.pushMatrix(); - RenderSystem.translated(0, 200, 0); - RenderSystem.rotatef(90, 1, 0, 0); - RenderSystem.rotatef(270, 0, 0, 1); - ScreenElementRenderer.renderBlock(() -> state); - RenderSystem.popMatrix(); - - RenderSystem.pushMatrix(); - RenderSystem.translated(-103, -100, 0); - ScreenElementRenderer.renderBlock(() -> state); - RenderSystem.popMatrix(); + GuiGameElement.of(Fluids.LAVA) + .scale(24) + .atLocal(0, 0, 2) + .render(); RenderSystem.popMatrix(); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/BlockCuttingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/BlockCuttingCategory.java index a499d9ce1..b11f30e91 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/BlockCuttingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/BlockCuttingCategory.java @@ -66,8 +66,7 @@ public class BlockCuttingCategory extends CreateRecipeCategory recipe.getRecipeOutput()); + GuiGameElement.of(recipe.getRecipeOutput()).render(); RenderSystem.popMatrix(); } } \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java index 0b2fb2238..59c388522 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/CrushingCategory.java @@ -63,7 +63,7 @@ public class CrushingCategory extends CreateRecipeCategory { ScreenResources.JEI_SLOT.draw(141, 50); ScreenResources.JEI_DOWN_ARROW.draw(136, 32); ScreenResources.JEI_SHADOW.draw(81, 57); - mixer.draw(getBackground().getWidth() / 2 + 20, 8); + mixer.draw(getBackground().getWidth() / 2 + 3, 25); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/PackingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/PackingCategory.java index 90b1d180f..b2a91f637 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/PackingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/PackingCategory.java @@ -65,7 +65,7 @@ public class PackingCategory extends CreateRecipeCategory> { ScreenResources.JEI_SLOT.draw(141, 50); ScreenResources.JEI_DOWN_ARROW.draw(136, 32); ScreenResources.JEI_SHADOW.draw(81, 57); - press.draw(getBackground().getWidth() / 2 + 20, 8); + press.draw(getBackground().getWidth() / 2 + 6, 30); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/PressingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/PressingCategory.java index 0d867616a..e01e749b4 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/PressingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/PressingCategory.java @@ -58,7 +58,7 @@ public class PressingCategory extends CreateRecipeCategory { getRenderedSlot(recipe, 1).draw(131 + 19, 50); ScreenResources.JEI_SHADOW.draw(61, 41); ScreenResources.JEI_LONG_ARROW.draw(52, 54); - press.draw(getBackground().getWidth() / 2, 8); + press.draw(getBackground().getWidth() / 2 - 17, 22); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java index 5ac987bfa..78bc1c9c9 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java @@ -7,18 +7,14 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.ScreenResources; import com.simibubi.create.compat.jei.category.animations.AnimatedKinetics; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; public abstract class ProcessingViaFanCategory> extends CreateRecipeCategory { @@ -53,47 +49,29 @@ public abstract class ProcessingViaFanCategory> extends Cre @Override public void draw(T recipe, double mouseX, double mouseY) { renderWidgets(recipe, mouseX, mouseY); - RenderSystem.pushMatrix(); - RenderSystem.color3f(1, 1, 1); - RenderSystem.enableDepthTest(); + + RenderSystem.translatef(56, 33, 0); + RenderSystem.rotatef(-12.5f, 1, 0, 0); + RenderSystem.rotatef(22.5f, 0, 1, 0); + int scale = 24; - RenderSystem.translated(28, 18, 0); - RenderSystem.rotatef(10.5f, -1f, 0, 0); - RenderSystem.rotatef(15.5f, 0, 1, 0); - RenderSystem.scaled(.6f, .6f, .6f); - ScreenElementRenderer.renderBlock(this::renderFanCasing); - - RenderSystem.pushMatrix(); - float angle = AnimatedKinetics.getCurrentAngle() * 12; - float t = 25; - RenderSystem.translatef(t, -t, t); - RenderSystem.rotatef(angle, 0, 0, 1); - RenderSystem.translatef(-t, t, -t); - - RenderSystem.translatef(t, 0, 175); - RenderSystem.rotatef(90, 0, 1, 0); - RenderSystem.translatef(-t, 0, -175); - - ScreenElementRenderer.renderModel(this::renderFanInner); - RenderSystem.popMatrix(); + GuiGameElement.of(AllBlockPartials.ENCASED_FAN_INNER) + .rotateBlock(180, 0, AnimatedKinetics.getCurrentAngle() * 16) + .scale(scale) + .render(); - RenderSystem.translated(-10, 0, 95); - RenderSystem.rotatef(7, 0, 1, 0); + GuiGameElement.of(AllBlocks.ENCASED_FAN.getDefault()) + .rotateBlock(0, 180, 0) + .atLocal(0, 0, 0) + .scale(scale) + .render(); + renderAttachedBlock(); - RenderSystem.popMatrix(); } - protected BlockState renderFanCasing() { - return AllBlocks.ENCASED_FAN.get().getDefaultState().with(BlockStateProperties.FACING, Direction.WEST); - } - - protected IBakedModel renderFanInner() { - return AllBlockPartials.ENCASED_FAN_INNER.get(); - } - public abstract void renderAttachedBlock(); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/SawingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/SawingCategory.java index b0a17e4c2..c41b2d9ee 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/SawingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/SawingCategory.java @@ -62,8 +62,7 @@ public class SawingCategory extends CreateRecipeCategory { getRenderedSlot(recipe, i).draw(117 + xOffset, 47 + yOffset); } ScreenResources.JEI_DOWN_ARROW.draw(70, 6); - ScreenResources.JEI_SHADOW.draw(58, 55); - saw.draw(72, 35); + saw.draw(72, 42); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/SmokingViaFanCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/SmokingViaFanCategory.java index 1ddd16611..5be594658 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/SmokingViaFanCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/SmokingViaFanCategory.java @@ -1,7 +1,7 @@ package com.simibubi.create.compat.jei.category; import com.simibubi.create.AllItems; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; import net.minecraft.block.Blocks; import net.minecraft.item.Items; @@ -20,6 +20,11 @@ public class SmokingViaFanCategory extends ProcessingViaFanCategory Blocks.FIRE.getDefaultState()); + + GuiGameElement.of(Blocks.FIRE.getDefaultState()) + .scale(24) + .atLocal(0, 0, 2) + .render(); + } } \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/compat/jei/category/SplashingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/SplashingCategory.java index 9e2ed7923..52314979f 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/SplashingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/SplashingCategory.java @@ -6,7 +6,7 @@ import java.util.List; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; import com.simibubi.create.ScreenResources; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.modules.contraptions.components.fan.SplashingRecipe; import com.simibubi.create.modules.contraptions.processing.ProcessingOutput; @@ -14,9 +14,7 @@ import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FlowingFluidBlock; +import net.minecraft.fluid.Fluids; import net.minecraft.item.Items; public class SplashingCategory extends ProcessingViaFanCategory { @@ -40,7 +38,9 @@ public class SplashingCategory extends ProcessingViaFanCategory public void setRecipe(IRecipeLayout recipeLayout, SplashingRecipe recipe, IIngredients ingredients) { IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); itemStacks.init(0, true, 20, 47); - itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks())); + itemStacks.set(0, Arrays.asList(recipe.getIngredients() + .get(0) + .getMatchingStacks())); List results = recipe.getRollableResults(); boolean single = results.size() == 1; @@ -49,7 +49,8 @@ public class SplashingCategory extends ProcessingViaFanCategory int yOffset = (outputIndex / 2) * -19; itemStacks.init(outputIndex + 1, false, single ? 139 : 133 + xOffset, 47 + yOffset); - itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack()); + itemStacks.set(outputIndex + 1, results.get(outputIndex) + .getStack()); } addStochasticTooltip(itemStacks, results); @@ -57,7 +58,8 @@ public class SplashingCategory extends ProcessingViaFanCategory @Override protected void renderWidgets(SplashingRecipe recipe, double mouseX, double mouseY) { - int size = recipe.getPossibleOutputs().size(); + int size = recipe.getPossibleOutputs() + .size(); ScreenResources.JEI_SLOT.draw(20, 47); ScreenResources.JEI_SHADOW.draw(47, 29); @@ -78,27 +80,12 @@ public class SplashingCategory extends ProcessingViaFanCategory @Override public void renderAttachedBlock() { - BlockState state = Blocks.WATER.getDefaultState().with(FlowingFluidBlock.LEVEL, 8); RenderSystem.pushMatrix(); - RenderSystem.translated(0, 0, 200); - RenderSystem.pushMatrix(); - RenderSystem.translated(0, 200, 0); - RenderSystem.rotatef(90, 1, 0, 0); - ScreenElementRenderer.renderBlock(() -> state); - RenderSystem.popMatrix(); - - RenderSystem.pushMatrix(); - RenderSystem.translated(0, 200, 0); - RenderSystem.rotatef(90, 1, 0, 0); - RenderSystem.rotatef(270, 0, 0, 1); - ScreenElementRenderer.renderBlock(() -> state); - RenderSystem.popMatrix(); - - RenderSystem.pushMatrix(); - RenderSystem.translated(-103, -100, 0); - ScreenElementRenderer.renderBlock(() -> state); - RenderSystem.popMatrix(); + GuiGameElement.of(Fluids.WATER) + .scale(24) + .atLocal(0, 0, 2) + .render(); RenderSystem.popMatrix(); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java index 2a0b5da6c..a00ad0f2a 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrafter.java @@ -1,57 +1,34 @@ package com.simibubi.create.compat.jei.category.animations; import com.mojang.blaze3d.systems.RenderSystem; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; -import com.simibubi.create.modules.contraptions.components.crafter.MechanicalCrafterBlock; - -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.util.Direction; +import com.simibubi.create.ScreenResources; +import com.simibubi.create.foundation.gui.GuiGameElement; public class AnimatedCrafter extends AnimatedKinetics { - @Override - public int getWidth() { - return 50; - } - - @Override - public int getHeight() { - return 50; - } - @Override public void draw(int xOffset, int yOffset) { RenderSystem.pushMatrix(); - RenderSystem.enableDepthTest(); - RenderSystem.rotatef(-15.5f, 1, 0, 0); - RenderSystem.rotatef(-22.5f, 0, 1, 0); RenderSystem.translatef(xOffset, yOffset, 0); - RenderSystem.translatef(-45, -5, 0); - RenderSystem.scaled(.45f, .45f, .45f); + ScreenResources.JEI_SHADOW.draw(-16, 13); + + RenderSystem.translatef(3, 16, 0); + RenderSystem.rotatef(-12.5f, 1, 0, 0); + RenderSystem.rotatef(-22.5f, 0, 1, 0); + int scale = 22; - ScreenElementRenderer.renderModel(() -> cogwheel(true)); - ScreenElementRenderer.renderBlock(this::body); + GuiGameElement.of(cogwheel()) + .rotateBlock(90, 0, getCurrentAngle()) + .scale(scale) + .render(); + + GuiGameElement.of(AllBlocks.MECHANICAL_CRAFTER.getDefault()) + .rotateBlock(0, 180, 0) + .scale(scale) + .render(); RenderSystem.popMatrix(); } - private IBakedModel cogwheel(boolean forward) { - float t = 25; - RenderSystem.translatef(t, -t, -t); - RenderSystem.rotatef(getCurrentAngle() * 2 * (forward ? 1 : -1), 0, 0, 1); - RenderSystem.rotatef(90, 1, 0, 0); - RenderSystem.translatef(-t, t, t); - return AllBlockPartials.SHAFTLESS_COGWHEEL.get(); - } - - private BlockState body() { - return AllBlocks.MECHANICAL_CRAFTER - .get() - .getDefaultState() - .with(MechanicalCrafterBlock.HORIZONTAL_FACING, Direction.WEST); - } - } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrushingWheels.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrushingWheels.java index 32aa96e8f..1ae4cf281 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrushingWheels.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedCrushingWheels.java @@ -2,7 +2,7 @@ package com.simibubi.create.compat.jei.category.animations; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; import net.minecraft.block.BlockState; import net.minecraft.state.properties.BlockStateProperties; @@ -10,49 +10,27 @@ import net.minecraft.util.Direction.Axis; public class AnimatedCrushingWheels extends AnimatedKinetics { - @Override - public int getWidth() { - return 150; - } - - @Override - public int getHeight() { - return 100; - } - @Override public void draw(int xOffset, int yOffset) { RenderSystem.enableDepthTest(); - RenderSystem.translatef(xOffset, yOffset, 0); - RenderSystem.translatef(-45, 10, 0); - RenderSystem.rotatef(22.5f, 0, 1, 0); - RenderSystem.scaled(.45f, .45f, .45f); - ScreenElementRenderer.renderBlock(this::leftWheel); - ScreenElementRenderer.renderBlock(this::rightWheel); - } + RenderSystem.translatef(xOffset, yOffset, 300); + RenderSystem.rotatef(-22.5f, 0, 1, 0); + int scale = 22; + + BlockState wheel = AllBlocks.CRUSHING_WHEEL.get() + .getDefaultState() + .with(BlockStateProperties.AXIS, Axis.X); - private BlockState leftWheel() { - float angle = getCurrentAngle(); - RenderSystem.translatef(-50, 0, 0); - - float t = 25; - RenderSystem.translatef(t, -t, t); - RenderSystem.rotatef(angle, 0, 0, 1); - RenderSystem.translatef(-t, t, -t); - - return AllBlocks.CRUSHING_WHEEL.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X); - } + GuiGameElement.of(wheel) + .rotateBlock(0, 90, -getCurrentAngle()) + .scale(scale) + .render(); - private BlockState rightWheel() { - float angle = -getCurrentAngle(); - RenderSystem.translatef(50, 0, 0); - - float t = 25; - RenderSystem.translatef(t, -t, t); - RenderSystem.rotatef(angle, 0, 0, 1); - RenderSystem.translatef(-t, t, -t); - - return AllBlocks.CRUSHING_WHEEL.get().getDefaultState().with(BlockStateProperties.AXIS, Axis.X); + GuiGameElement.of(wheel) + .rotateBlock(0, 90, getCurrentAngle()) + .atLocal(2, 0, 0) + .scale(scale) + .render(); } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java index bf212b18a..71b6c0753 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java @@ -1,5 +1,6 @@ package com.simibubi.create.compat.jei.category.animations; +import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocksNew; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -18,5 +19,19 @@ public abstract class AnimatedKinetics implements IDrawable { protected BlockState shaft(Axis axis) { return AllBlocksNew.getDefault(AllBlocksNew.SHAFT).with(BlockStateProperties.AXIS, axis); } + + protected AllBlockPartials cogwheel() { + return AllBlockPartials.SHAFTLESS_COGWHEEL; + } + + @Override + public int getWidth() { + return 50; + } + + @Override + public int getHeight() { + return 50; + } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java index 9df7715aa..b0ef9dfd9 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java @@ -3,53 +3,30 @@ package com.simibubi.create.compat.jei.category.animations; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; - -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.IBakedModel; +import com.simibubi.create.ScreenResources; +import com.simibubi.create.foundation.gui.GuiGameElement; public class AnimatedMillstone extends AnimatedKinetics { - @Override - public int getWidth() { - return 50; - } - - @Override - public int getHeight() { - return 50; - } - @Override public void draw(int xOffset, int yOffset) { RenderSystem.pushMatrix(); - RenderSystem.enableDepthTest(); RenderSystem.translatef(xOffset, yOffset, 0); - RenderSystem.rotatef(-15.5f, 1, 0, 0); - RenderSystem.rotatef(22.5f, 0, 1, 0); - RenderSystem.translatef(-45, -5, 0); - RenderSystem.scaled(.45f, .45f, .45f); + ScreenResources.JEI_SHADOW.draw(-16, 13); + RenderSystem.translatef(-2, 18, 0); + int scale = 22; - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderModel(this::cogwheel); - RenderSystem.popMatrix(); - - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderBlock(this::body); - RenderSystem.popMatrix(); + GuiGameElement.of(AllBlockPartials.MILLSTONE_COG) + .rotateBlock(22.5, getCurrentAngle() * 2, 0) + .scale(scale) + .render(); + + GuiGameElement.of(AllBlocks.MILLSTONE.getDefault()) + .rotateBlock(22.5, 22.5, 0) + .scale(scale) + .render(); RenderSystem.popMatrix(); } - private IBakedModel cogwheel() { - float t = 25; - RenderSystem.translatef(t, -t, -t); - RenderSystem.rotatef(getCurrentAngle() * 2, 0, 1, 0); - RenderSystem.translatef(-t, t, t); - return AllBlockPartials.MILLSTONE_COG.get(); - } - - private BlockState body() { - return AllBlocks.MILLSTONE.get().getDefaultState(); - } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMixer.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMixer.java index 24beceb43..6ee161b52 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMixer.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMixer.java @@ -3,84 +3,46 @@ package com.simibubi.create.compat.jei.category.animations; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; - -import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.model.IBakedModel; +import com.simibubi.create.foundation.gui.GuiGameElement; public class AnimatedMixer extends AnimatedKinetics { - @Override - public int getWidth() { - return 50; - } - - @Override - public int getHeight() { - return 150; - } - @Override public void draw(int xOffset, int yOffset) { RenderSystem.pushMatrix(); - RenderSystem.enableDepthTest(); - RenderSystem.translatef(xOffset, yOffset, 0); + RenderSystem.translatef(xOffset, yOffset, 200); RenderSystem.rotatef(-15.5f, 1, 0, 0); RenderSystem.rotatef(22.5f, 0, 1, 0); - RenderSystem.translatef(-45, -5, 0); - RenderSystem.scaled(.45f, .45f, .45f); + int scale = 23; - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderModel(this::cogwheel); - RenderSystem.popMatrix(); + GuiGameElement.of(cogwheel()) + .rotateBlock(0, getCurrentAngle() * 2, 0) + .atLocal(0, 0, 0) + .scale(scale) + .render(); - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderBlock(this::body); - RenderSystem.popMatrix(); + GuiGameElement.of(AllBlocks.MECHANICAL_MIXER.getDefault()) + .atLocal(0, 0, 0) + .scale(scale) + .render(); - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderModel(this::pole); - RenderSystem.popMatrix(); + GuiGameElement.of(AllBlockPartials.MECHANICAL_MIXER_POLE) + .atLocal(0, 1, 0) + .scale(scale) + .render(); - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderModel(this::head); - RenderSystem.popMatrix(); + GuiGameElement.of(AllBlockPartials.MECHANICAL_MIXER_HEAD) + .rotateBlock(0, getCurrentAngle() * 4, 0) + .atLocal(0, 1, 0) + .scale(scale) + .render(); - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderBlock(this::basin); - RenderSystem.popMatrix(); + GuiGameElement.of(AllBlocks.BASIN.getDefault()) + .atLocal(0, 1.65, 0) + .scale(scale) + .render(); RenderSystem.popMatrix(); } - private IBakedModel cogwheel() { - float t = 25; - RenderSystem.translatef(t, -t, -t); - RenderSystem.rotatef(getCurrentAngle() * 2, 0, 1, 0); - RenderSystem.translatef(-t, t, t); - return AllBlockPartials.SHAFTLESS_COGWHEEL.get(); - } - - private BlockState body() { - return AllBlocks.MECHANICAL_MIXER.get().getDefaultState(); - } - - private IBakedModel pole() { - RenderSystem.translatef(0, 51, 0); - return AllBlockPartials.MECHANICAL_MIXER_POLE.get(); - } - - private IBakedModel head() { - float t = 25; - RenderSystem.translatef(0, 51, 0); - RenderSystem.translatef(t, -t, -t); - RenderSystem.rotatef(getCurrentAngle() * 4, 0, 1, 0); - RenderSystem.translatef(-t, t, t); - return AllBlockPartials.MECHANICAL_MIXER_HEAD.get(); - } - - private BlockState basin() { - RenderSystem.translatef(0, 85, 0); - return AllBlocks.BASIN.get().getDefaultState(); - } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java index 133e0e788..4cb25e41b 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedPress.java @@ -5,14 +5,9 @@ import static com.simibubi.create.foundation.utility.AnimationTickHolder.ticks; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; -import com.simibubi.create.AllBlocksNew; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; -import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; public class AnimatedPress extends AnimatedKinetics { @@ -23,80 +18,49 @@ public class AnimatedPress extends AnimatedKinetics { this.basin = basin; } - @Override - public int getWidth() { - return 50; - } - - @Override - public int getHeight() { - return 100; - } - @Override public void draw(int xOffset, int yOffset) { RenderSystem.pushMatrix(); - RenderSystem.enableDepthTest(); - RenderSystem.translatef(xOffset, yOffset, 0); + RenderSystem.translatef(xOffset, yOffset, 100); RenderSystem.rotatef(-15.5f, 1, 0, 0); RenderSystem.rotatef(22.5f, 0, 1, 0); - RenderSystem.translatef(-45, -5, 0); - RenderSystem.scaled(.45f, .45f, .45f); + int scale = basin ? 20 : 24; - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderBlock(this::shaft); - RenderSystem.popMatrix(); + GuiGameElement.of(shaft(Axis.Z)) + .rotateBlock(0, 0, getCurrentAngle()) + .scale(scale) + .render(); - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderBlock(this::body); - RenderSystem.popMatrix(); + GuiGameElement.of(AllBlocks.MECHANICAL_PRESS.getDefault()) + .scale(scale) + .render(); - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderModel(this::head); - RenderSystem.popMatrix(); + GuiGameElement.of(AllBlockPartials.MECHANICAL_PRESS_HEAD) + .atLocal(0, -getAnimatedHeadOffset(), 0) + .scale(scale) + .render(); - if (basin) { - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderBlock(this::basin); - RenderSystem.popMatrix(); - } + if (basin) + GuiGameElement.of(AllBlocks.BASIN.getDefault()) + .atLocal(0, 1.65, 0) + .scale(scale) + .render(); RenderSystem.popMatrix(); } - private BlockState shaft() { - float t = 25; - RenderSystem.translatef(t, -t, -t); - RenderSystem.rotatef(getCurrentAngle() * 2, 1, 0, 0); - RenderSystem.translatef(-t, t, t); - return AllBlocksNew.getDefault(AllBlocksNew.SHAFT).with(BlockStateProperties.AXIS, Axis.Z); - } - - private BlockState body() { - return AllBlocks.MECHANICAL_PRESS.get().getDefaultState().with(BlockStateProperties.HORIZONTAL_FACING, - Direction.SOUTH); - } - - private IBakedModel head() { - float cycle = (ticks + Minecraft.getInstance().getRenderPartialTicks()) % 30; - float verticalOffset = 0; + private float getAnimatedHeadOffset() { + float cycle = (ticks + Minecraft.getInstance() + .getRenderPartialTicks()) % 30; if (cycle < 10) { float progress = cycle / 10; - verticalOffset = -(progress * progress * progress); - } else if (cycle < 15) { - verticalOffset = -1; - } else if (cycle < 20) { - verticalOffset = -1 + (1 - ((20 - cycle) / 5)); - } else { - verticalOffset = 0; + return -(progress * progress * progress); } - RenderSystem.translated(0, -verticalOffset * 50, 0); - return AllBlockPartials.MECHANICAL_PRESS_HEAD.get(); - } - - private BlockState basin() { - RenderSystem.translatef(0, 85, 0); - return AllBlocks.BASIN.get().getDefaultState(); + if (cycle < 15) + return -1; + if (cycle < 20) + return -1 + (1 - ((20 - cycle) / 5)); + return 0; } } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java index 85d83d134..069de9139 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java @@ -2,58 +2,40 @@ package com.simibubi.create.compat.jei.category.animations; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.ScreenResources; +import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.modules.contraptions.components.saw.SawBlock; -import net.minecraft.block.BlockState; -import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; public class AnimatedSaw extends AnimatedKinetics { - @Override - public int getWidth() { - return 50; - } - - @Override - public int getHeight() { - return 50; - } - @Override public void draw(int xOffset, int yOffset) { RenderSystem.pushMatrix(); - RenderSystem.enableDepthTest(); RenderSystem.translatef(xOffset, yOffset, 0); - RenderSystem.rotatef(-15.5f, 1, 0, 0); - RenderSystem.rotatef(22.5f, 0, 1, 0); - RenderSystem.translatef(-45, -5, 0); - RenderSystem.scaled(.6f, .6f, .6f); + ScreenResources.JEI_SHADOW.draw(-16, 13); + + RenderSystem.translatef(0, 0, 200); + RenderSystem.translatef(-6, 19, 0); + RenderSystem.rotatef(-22.5f, 1, 0, 0); + RenderSystem.rotatef(90 - 22.5f, 0, 1, 0); + int scale = 25; - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderBlock(this::shaft); - RenderSystem.popMatrix(); + GuiGameElement.of(shaft(Axis.X)) + .rotateBlock(-getCurrentAngle(), 0, 0) + .scale(scale) + .render(); - RenderSystem.pushMatrix(); - ScreenElementRenderer.renderBlock(this::block); - RenderSystem.popMatrix(); + GuiGameElement.of(AllBlocks.SAW.getDefault() + .with(SawBlock.FACING, Direction.UP) + .with(SawBlock.RUNNING, true)) + .rotateBlock(0, 0, 0) + .scale(scale) + .render(); RenderSystem.popMatrix(); } - private BlockState shaft() { - float t = 25; - RenderSystem.translatef(t, -t, t); - RenderSystem.rotatef(-getCurrentAngle() * 2, 0, 0, 1); - RenderSystem.translatef(-t, t, -t); - return shaft(Axis.X); - } - - private BlockState block() { - return AllBlocks.SAW.get().getDefaultState().with(BlockStateProperties.FACING, Direction.UP) - .with(SawBlock.RUNNING, true).with(SawBlock.AXIS_ALONG_FIRST_COORDINATE, true); - } - } diff --git a/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java b/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java index 799981d4c..7a827e153 100644 --- a/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java +++ b/src/main/java/com/simibubi/create/foundation/block/connected/CTModel.java @@ -94,7 +94,7 @@ public class CTModel extends BakedModelWrapper { int[] vertexData = newQuad.getVertexData(); for (int vertex = 0; vertex < vertexData.length; vertex += format.getIntegerSize()) { - int uvOffset = 20 / 4; // TODO 1.15 is this the right offset? + int uvOffset = 16 / 4; int uIndex = vertex + uvOffset; int vIndex = vertex + uvOffset + 1; float u = Float.intBitsToFloat(vertexData[uIndex]); diff --git a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java new file mode 100644 index 000000000..f1c7f5a88 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java @@ -0,0 +1,251 @@ +package com.simibubi.create.foundation.gui; + +import javax.annotation.Nullable; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.platform.GlStateManager.DestFactor; +import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.IVertexBuilder; +import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.foundation.utility.ColorHelper; +import com.simibubi.create.foundation.utility.VecHelper; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FireBlock; +import net.minecraft.block.FlowingFluidBlock; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.fluid.Fluid; +import net.minecraft.inventory.container.PlayerContainer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IItemProvider; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraftforge.client.model.data.EmptyModelData; + +public class GuiGameElement { + + public static GuiRenderBuilder of(ItemStack stack) { + return new GuiItemRenderBuilder(stack); + } + + public static GuiRenderBuilder of(IItemProvider itemProvider) { + return new GuiItemRenderBuilder(itemProvider); + } + + public static GuiRenderBuilder of(BlockState state) { + return new GuiBlockStateRenderBuilder(state); + } + + public static GuiRenderBuilder of(AllBlockPartials partial) { + return new GuiBlockPartialRenderBuilder(partial); + } + + public static GuiRenderBuilder of(Fluid fluid) { + return new GuiBlockStateRenderBuilder(fluid.getDefaultState() + .getBlockState() + .with(FlowingFluidBlock.LEVEL, 5)); + } + + public static abstract class GuiRenderBuilder { + double xBeforeScale, yBeforeScale; + double x, y, z; + double xRot, yRot, zRot; + double scale = 1; + int color = 0xFFFFFF; + Vec3d rotationOffset = Vec3d.ZERO; + + public GuiRenderBuilder atLocal(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + return this; + } + + public GuiRenderBuilder at(double x, double y) { + this.xBeforeScale = x; + this.yBeforeScale = y; + return this; + } + + public GuiRenderBuilder rotate(double xRot, double yRot, double zRot) { + this.xRot = xRot; + this.yRot = yRot; + this.zRot = zRot; + return this; + } + + public GuiRenderBuilder rotateBlock(double xRot, double yRot, double zRot) { + return this.rotate(xRot, yRot, zRot) + .withRotationOffset(VecHelper.getCenterOf(BlockPos.ZERO)); + } + + public GuiRenderBuilder scale(double scale) { + this.scale = scale; + return this; + } + + public GuiRenderBuilder color(int color) { + this.color = color; + return this; + } + + public GuiRenderBuilder withRotationOffset(Vec3d offset) { + this.rotationOffset = offset; + return this; + } + + public abstract void render(); + + protected void prepare() { + RenderSystem.pushMatrix(); + RenderSystem.enableBlend(); + RenderSystem.enableRescaleNormal(); + RenderSystem.enableAlphaTest(); + RenderHelper.enableGuiDepthLighting(); + RenderSystem.alphaFunc(516, 0.1F); + RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); + RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + protected void transform() { + int verticalFlip = (this instanceof GuiItemRenderBuilder) ? 1 : -1; + + RenderSystem.translated(xBeforeScale, yBeforeScale, 0); + RenderSystem.scaled(scale, scale, scale); + RenderSystem.translated(x, y, z); + RenderSystem.scaled(1, verticalFlip, 1); + RenderSystem.translated(rotationOffset.x, rotationOffset.y, rotationOffset.z); + RenderSystem.rotatef((float) zRot, 0, 0, 1); + RenderSystem.rotatef((float) xRot, 1, 0, 0); + RenderSystem.rotatef((float) yRot, 0, 1, 0); + RenderSystem.translated(-rotationOffset.x, -rotationOffset.y, -rotationOffset.z); + } + + protected void cleanUp() { + RenderSystem.popMatrix(); + RenderSystem.disableAlphaTest(); + RenderSystem.disableRescaleNormal(); + } + } + + private static class GuiBlockModelRenderBuilder extends GuiRenderBuilder { + + protected IBakedModel blockmodel; + protected BlockState blockState; + + public GuiBlockModelRenderBuilder(IBakedModel blockmodel, @Nullable BlockState blockState) { + this.blockState = blockState == null ? Blocks.AIR.getDefaultState() : blockState; + this.blockmodel = blockmodel; + } + + @Override + public void render() { + prepare(); + + Minecraft mc = Minecraft.getInstance(); + BlockRendererDispatcher blockRenderer = mc.getBlockRendererDispatcher(); + IRenderTypeBuffer.Impl buffer = mc.getBufferBuilders() + .getEntityVertexConsumers(); + RenderType renderType = RenderTypeLookup.getEntityBlockLayer(blockState); + IVertexBuilder vb = buffer.getBuffer(renderType); + MatrixStack ms = new MatrixStack(); + + transform(); + + mc.getTextureManager() + .bindTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE); + renderModel(blockRenderer, buffer, renderType, vb, ms); + + cleanUp(); + } + + protected void renderModel(BlockRendererDispatcher blockRenderer, IRenderTypeBuffer.Impl buffer, + RenderType renderType, IVertexBuilder vb, MatrixStack ms) { + Vec3d rgb = ColorHelper.getRGB(color); + blockRenderer.getBlockModelRenderer() + .renderModel(ms.peek(), vb, blockState, blockmodel, (float) rgb.x, (float) rgb.y, (float) rgb.z, + 0xF000F0, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); + buffer.draw(); + } + } + + public static class GuiBlockStateRenderBuilder extends GuiBlockModelRenderBuilder { + + public GuiBlockStateRenderBuilder(BlockState blockstate) { + super(Minecraft.getInstance() + .getBlockRendererDispatcher() + .getModelForState(blockstate), blockstate); + } + + @Override + protected void renderModel(BlockRendererDispatcher blockRenderer, IRenderTypeBuffer.Impl buffer, + RenderType renderType, IVertexBuilder vb, MatrixStack ms) { + if (blockState.getBlock() instanceof FireBlock) { + RenderHelper.disableGuiDepthLighting(); + blockRenderer.renderBlock(blockState, ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, + EmptyModelData.INSTANCE); + RenderHelper.enable(); + buffer.draw(); + return; + } + + super.renderModel(blockRenderer, buffer, renderType, vb, ms); + + if (blockState.getFluidState().isEmpty()) + return; + + // TODO fluids are not visible for some reason. See fan washing recipes in JEI for an example use case + for (RenderType type : RenderType.getBlockLayers()) { + if (!RenderTypeLookup.canRenderInLayer(blockState.getFluidState(), type)) + continue; + + vb = buffer.getBuffer(type); + blockRenderer.renderFluid(new BlockPos(0, 0, 0), Minecraft.getInstance().world, vb, + blockState.getFluidState()); + buffer.draw(type); + break; + } + } + } + + public static class GuiBlockPartialRenderBuilder extends GuiBlockModelRenderBuilder { + + public GuiBlockPartialRenderBuilder(AllBlockPartials partial) { + super(partial.get(), null); + } + + } + + public static class GuiItemRenderBuilder extends GuiRenderBuilder { + + private ItemStack stack; + + public GuiItemRenderBuilder(ItemStack stack) { + this.stack = stack; + } + + public GuiItemRenderBuilder(IItemProvider provider) { + this(new ItemStack(provider)); + } + + @Override + public void render() { + prepare(); + transform(); + Minecraft.getInstance() + .getItemRenderer() + .renderItemIntoGUI(stack, 0, 0); + cleanUp(); + } + + } +} diff --git a/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java b/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java deleted file mode 100644 index 415142e84..000000000 --- a/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.simibubi.create.foundation.gui; - -import java.util.function.Supplier; - -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager.DestFactor; -import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.foundation.utility.ColorHelper; - -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.FireBlock; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.inventory.container.PlayerContainer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraftforge.client.model.data.EmptyModelData; - -public class ScreenElementRenderer { - - public static void render3DItem(Supplier transformsAndStack) { - RenderSystem.pushMatrix(); - - RenderSystem.enableBlend(); - RenderSystem.enableRescaleNormal(); - RenderSystem.enableAlphaTest(); - RenderHelper.enableGuiDepthLighting(); // TODO 1.15 buffered render - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - - ItemStack stack = transformsAndStack.get(); - - Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(stack, 0, 0); - RenderSystem.popMatrix(); - } - - public static void renderBlock(Supplier transformsAndState) { - renderBlock(transformsAndState, -1); - } - - public static void renderBlock(Supplier transformsAndState, int color) { - render(transformsAndState, null, -1); - } - - public static void renderModel(Supplier transformsAndModel) { - render(null, transformsAndModel, -1); - } - - private static void render(Supplier transformsAndState, Supplier transformsAndModel, - int color) { - RenderSystem.pushMatrix(); - - RenderSystem.enableBlend(); - RenderSystem.enableRescaleNormal(); - RenderSystem.enableAlphaTest(); - RenderHelper.enableGuiDepthLighting(); - RenderSystem.alphaFunc(516, 0.1F); - RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.translated(0, 0, 200); - - Minecraft mc = Minecraft.getInstance(); - BlockRendererDispatcher blockRenderer = mc.getBlockRendererDispatcher(); - IBakedModel modelToRender = null; - BlockState blockToRender = Blocks.AIR.getDefaultState(); - boolean stateMode = transformsAndModel == null; - boolean fire = false; - - if (transformsAndModel == null) { - blockToRender = transformsAndState.get(); - fire = (blockToRender.getBlock() instanceof FireBlock); - modelToRender = blockRenderer.getModelForState(blockToRender); - } else { - modelToRender = transformsAndModel.get(); - } - - RenderSystem.scaled(50, -50, 50); - IRenderTypeBuffer.Impl buffer = mc.getBufferBuilders().getEntityVertexConsumers(); - RenderType renderType = RenderTypeLookup.getEntityBlockLayer(blockToRender); - IVertexBuilder vb = buffer.getBuffer(renderType); - MatrixStack ms = new MatrixStack(); - mc.getTextureManager().bindTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE); - - RenderSystem.pushMatrix(); - if (fire) { - blockRenderer.renderBlock(blockToRender, ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, - EmptyModelData.INSTANCE); - } else { - if (modelToRender != null) { - RenderSystem.rotatef(90, 0, 1, 0); - if (color == -1) { - blockRenderer.getBlockModelRenderer().renderModel(ms.peek(), vb, blockToRender, modelToRender, 1, 1, - 1, 0xF000F0, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); - } else { - Vec3d rgb = ColorHelper.getRGB(color); - blockRenderer.getBlockModelRenderer().renderModel(ms.peek(), vb, blockToRender, modelToRender, - (float) rgb.x, (float) rgb.y, (float) rgb.z, 0xF000F0, OverlayTexture.DEFAULT_UV, - EmptyModelData.INSTANCE); - } - } - } - - RenderSystem.popMatrix(); - buffer.draw(renderType); - - if (blockToRender != null && !blockToRender.getFluidState().isEmpty()) { - renderType = RenderTypeLookup.getFluidLayer(blockToRender.getFluidState()); - vb = buffer.getBuffer(renderType); - RenderHelper.disableStandardItemLighting(); - RenderSystem.translatef(0, -300, 0); - blockRenderer.renderFluid(new BlockPos(0, 300, 0), mc.world, vb, blockToRender.getFluidState()); - buffer.draw(renderType); - } - - RenderSystem.disableAlphaTest(); - RenderSystem.disableRescaleNormal(); - - RenderSystem.popMatrix(); - } - -} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/goggle/GoggleOverlayRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/goggle/GoggleOverlayRenderer.java index eac08658f..c7b62f9a1 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/goggle/GoggleOverlayRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/goggle/GoggleOverlayRenderer.java @@ -3,9 +3,9 @@ package com.simibubi.create.modules.contraptions.goggle; import java.util.ArrayList; import java.util.List; -import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; @@ -16,6 +16,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; @@ -25,6 +26,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @EventBusSubscriber(value = Dist.CLIENT) public class GoggleOverlayRenderer { + @SubscribeEvent public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) { if (event.getType() != ElementType.HOTBAR) @@ -71,29 +73,30 @@ public class GoggleOverlayRenderer { if (tooltip.isEmpty()) return; - GlStateManager.pushMatrix(); - Screen tooltipScreen = new Screen(null) { - - @Override - public void init(Minecraft mc, int width, int height) { - this.minecraft = mc; - this.itemRenderer = mc.getItemRenderer(); - this.font = mc.fontRenderer; - this.width = width; - this.height = height; - } - - }; - + RenderSystem.pushMatrix(); + Screen tooltipScreen = new TooltipScreen(null); tooltipScreen.init(mc, mc.getWindow().getScaledWidth(), mc.getWindow().getScaledHeight()); tooltipScreen.renderTooltip(tooltip, tooltipScreen.width / 2, tooltipScreen.height / 2); + ItemStack item = AllItems.GOGGLES.asStack(); - ScreenElementRenderer.render3DItem(() -> { - GlStateManager.translated(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16, 0); - return item; - }); - GlStateManager.popMatrix(); + GuiGameElement.of(item).at(tooltipScreen.width / 2 + 10, tooltipScreen.height / 2 - 16).render(); + RenderSystem.popMatrix(); + } + + private static final class TooltipScreen extends Screen { + private TooltipScreen(ITextComponent p_i51108_1_) { + super(p_i51108_1_); + } + + @Override + public void init(Minecraft mc, int width, int height) { + this.minecraft = mc; + this.itemRenderer = mc.getItemRenderer(); + this.font = mc.fontRenderer; + this.width = width; + this.height = height; + } } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/sequencer/SequencedGearshiftScreen.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/sequencer/SequencedGearshiftScreen.java index aed66919e..a5be9d539 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/sequencer/SequencedGearshiftScreen.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/sequencer/SequencedGearshiftScreen.java @@ -7,7 +7,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiScreen; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; import com.simibubi.create.foundation.utility.Lang; @@ -18,8 +18,8 @@ import net.minecraft.util.math.BlockPos; public class SequencedGearshiftScreen extends AbstractSimiScreen { - private static final ItemStack renderedItem = new ItemStack(AllBlocks.SEQUENCED_GEARSHIFT.get()); - private static final ScreenResources background = ScreenResources.SEQUENCER; + private final ItemStack renderedItem = new ItemStack(AllBlocks.SEQUENCED_GEARSHIFT.get()); + private final ScreenResources background = ScreenResources.SEQUENCER; private final String title = Lang.translate("gui.sequenced_gearshift.title"); private ListNBT compareTag; @@ -61,7 +61,8 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { ScrollInput type = new SelectionScrollInput(x, y + rowHeight * row, 50, 14).forOptions(SequencerInstructions.getOptions()) - .calling(state -> instructionUpdated(index, state)).setState(instruction.instruction.ordinal()) + .calling(state -> instructionUpdated(index, state)) + .setState(instruction.instruction.ordinal()) .titled(Lang.translate("gui.sequenced_gearshift.instruction")); ScrollInput value = new ScrollInput(x + 54, y + rowHeight * row, 30, 14).calling(state -> instruction.value = state); @@ -88,8 +89,11 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { ScrollInput value = rowInputs.get(1); value.active = value.visible = hasValue; if (hasValue) - value.withRange(1, def.maxValue + 1).titled(Lang.translate(def.parameterKey)).withShiftStep(def.shiftStep) - .setState(instruction.value).onChanged(); + value.withRange(1, def.maxValue + 1) + .titled(Lang.translate(def.parameterKey)) + .withShiftStep(def.shiftStep) + .setState(instruction.value) + .onChanged(); if (def == SequencerInstructions.WAIT) { value.withStepFunction(context -> { int v = context.currentValue; @@ -139,7 +143,13 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { font.drawStringWithShadow(title, guiLeft - 3 + (background.width - font.getStringWidth(title)) / 2, guiTop + 10, hFontColor); - ScreenElementRenderer.render3DItem(this::getRenderedBlock); + + RenderSystem.pushMatrix(); + RenderSystem.translated(guiLeft + background.width + 20, guiTop + 50, 0); + GuiGameElement.of(renderedItem) + .scale(5) + .render(); + RenderSystem.popMatrix(); } private void label(int x, int y, String text) { @@ -158,12 +168,6 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen { sendPacket(); } - public ItemStack getRenderedBlock() { - RenderSystem.translated(guiLeft + background.width + 20, guiTop + 50, 0); - RenderSystem.scaled(5, 5, 5); - return renderedItem; - } - private void instructionUpdated(int index, int state) { SequencerInstructions newValue = SequencerInstructions.values()[state]; instructions.get(index).instruction = newValue; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java index 123b5a1b1..ea2fe2f31 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java @@ -27,26 +27,30 @@ import net.minecraft.util.math.MathHelper; @SuppressWarnings("deprecation") public class BlockzapperItemRenderer extends ZapperItemRenderer { - + @Override public void render(ItemStack stack, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); - BlockzapperModel mainModel = (BlockzapperModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, null); - float pt = Minecraft.getInstance().getRenderPartialTicks(); + ItemRenderer itemRenderer = Minecraft.getInstance() + .getItemRenderer(); + BlockzapperModel mainModel = + (BlockzapperModel) itemRenderer.getItemModelWithOverrides(stack, Minecraft.getInstance().world, null); + float pt = Minecraft.getInstance() + .getRenderPartialTicks(); float worldTime = AnimationTickHolder.getRenderTick() / 20; ms.push(); ms.translate(0.5F, 0.5F, 0.5F); - itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, mainModel.getBakedModel()); + itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, light, overlay, + mainModel.getBakedModel()); renderComponent(stack, mainModel, Body, itemRenderer, ms, buffer, light, overlay); renderComponent(stack, mainModel, Amplifier, itemRenderer, ms, buffer, light, overlay); renderComponent(stack, mainModel, Retriever, itemRenderer, ms, buffer, light, overlay); renderComponent(stack, mainModel, Scope, itemRenderer, ms, buffer, light, overlay); // Block indicator - if (mainModel.getCurrentPerspective() == TransformType.GUI && stack.hasTag() - && stack.getTag().contains("BlockUsed")) + if (mainModel.getCurrentPerspective() == TransformType.GUI && stack.hasTag() && stack.getTag() + .contains("BlockUsed")) renderBlockUsed(stack, itemRenderer, ms, buffer, light, overlay); ClientPlayerEntity player = Minecraft.getInstance().player; @@ -55,8 +59,8 @@ public class BlockzapperItemRenderer extends ZapperItemRenderer { boolean offHand = player.getHeldItemOffhand() == stack; float last = mainHand ^ leftHanded ? ZapperRenderHandler.lastRightHandAnimation : ZapperRenderHandler.lastLeftHandAnimation; - float current = mainHand ^ leftHanded ? ZapperRenderHandler.rightHandAnimation - : ZapperRenderHandler.leftHandAnimation; + float current = + mainHand ^ leftHanded ? ZapperRenderHandler.rightHandAnimation : ZapperRenderHandler.leftHandAnimation; float animation = MathHelper.clamp(MathHelper.lerp(pt, last, current) * 5, 0, 1); // Core glows @@ -64,10 +68,12 @@ public class BlockzapperItemRenderer extends ZapperItemRenderer { if (mainHand || offHand) { multiplier = animation; } - int glowLight = LightTexture.pack((int) (15 * multiplier), 15); - itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay, mainModel.getPartial("core")); + int glowLight = LightTexture.pack(0, (int) (15 * multiplier)); + itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay, + mainModel.getPartial("core")); if (BlockzapperItem.getTier(Amplifier, stack) != ComponentTier.None) - itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay, mainModel.getPartial("amplifier_core")); + itemRenderer.renderItem(stack, TransformType.NONE, false, ms, buffer, glowLight, overlay, + mainModel.getPartial("amplifier_core")); // Accelerator spins float angle = worldTime * -25; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperModel.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperModel.java index 30be590ec..0851e98f0 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperModel.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperModel.java @@ -14,7 +14,7 @@ public class BlockzapperModel extends CustomRenderedItemModel { public BlockzapperModel(IBakedModel template) { super(template, "blockzapper"); addPartials("core", "body", "amplifier_core", "accelerator", "gold_body", "gold_scope", "gold_amplifier", - "gold_retriever", "gold_accelerator", "chorus_body", "chorus_amplifier", "chorus_retriever", + "gold_retriever", "gold_accelerator", "chorus_body", "chorus_scope", "chorus_amplifier", "chorus_retriever", "chorus_accelerator"); } diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchScreen.java b/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchScreen.java index 2fb94eec1..09e341ce6 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchScreen.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/StockswitchScreen.java @@ -9,13 +9,13 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiScreen; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.widgets.Label; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.logistics.packet.ConfigureStockswitchPacket; -import net.minecraft.block.BlockState; +import net.minecraft.item.ItemStack; public class StockswitchScreen extends AbstractSimiScreen { @@ -31,6 +31,7 @@ public class StockswitchScreen extends AbstractSimiScreen { private final String stopAt = Lang.translate("gui.stockswitch.stopAt"); private final String lowerLimit = Lang.translate("gui.stockswitch.lowerLimit"); private final String upperLimit = Lang.translate("gui.stockswitch.upperLimit"); + private final ItemStack renderedItem = new ItemStack(AllBlocks.STOCKSWITCH.get()); private int lastModification; private StockswitchTileEntity te; @@ -48,8 +49,10 @@ public class StockswitchScreen extends AbstractSimiScreen { widgets.clear(); cursorPos = te.currentLevel == -1 ? 0 : te.currentLevel; - offBelowLabel = new Label(guiLeft + 116, guiTop + 72, "").colored(0xD3CBBE).withShadow(); - offBelow = new ScrollInput(guiLeft + 113, guiTop + 69, 33, 14).withRange(0, 96).titled(lowerLimit) + offBelowLabel = new Label(guiLeft + 116, guiTop + 72, "").colored(0xD3CBBE) + .withShadow(); + offBelow = new ScrollInput(guiLeft + 113, guiTop + 69, 33, 14).withRange(0, 96) + .titled(lowerLimit) .calling(state -> { offBelowLabel.text = state + "%"; lastModification = 0; @@ -57,10 +60,13 @@ public class StockswitchScreen extends AbstractSimiScreen { onAbove.setState(state + 5); onAbove.onChanged(); } - }).setState((int) (te.offWhenBelow * 100)); + }) + .setState((int) (te.offWhenBelow * 100)); - onAboveLabel = new Label(guiLeft + 116, guiTop + 55, "").colored(0xD3CBBE).withShadow(); - onAbove = new ScrollInput(guiLeft + 113, guiTop + 52, 33, 14).withRange(5, 101).titled(upperLimit) + onAboveLabel = new Label(guiLeft + 116, guiTop + 55, "").colored(0xD3CBBE) + .withShadow(); + onAbove = new ScrollInput(guiLeft + 113, guiTop + 52, 33, 14).withRange(5, 101) + .titled(upperLimit) .calling(state -> { onAboveLabel.text = state + "%"; lastModification = 0; @@ -68,7 +74,8 @@ public class StockswitchScreen extends AbstractSimiScreen { offBelow.setState(state - 5); offBelow.onChanged(); } - }).setState((int) (te.onWhenAbove * 100)); + }) + .setState((int) (te.onWhenAbove * 100)); onAbove.onChanged(); offBelow.onChanged(); @@ -101,14 +108,19 @@ public class StockswitchScreen extends AbstractSimiScreen { ScreenResources.STOCKSWITCH_BOUND_LEFT.draw(this, (int) (guiLeft + lowerBound) - 1, guiTop + 24); ScreenResources.STOCKSWITCH_BOUND_RIGHT.draw(this, (int) (guiLeft + upperBound) - 5, guiTop + 24); - ScreenResources cursor = te.powered ? ScreenResources.STOCKSWITCH_CURSOR_ON - : ScreenResources.STOCKSWITCH_CURSOR_OFF; + ScreenResources cursor = + te.powered ? ScreenResources.STOCKSWITCH_CURSOR_ON : ScreenResources.STOCKSWITCH_CURSOR_OFF; RenderSystem.pushMatrix(); RenderSystem.translatef((cursorPos * (sprite.width - 20) + 10), 0, 0); cursor.draw(this, guiLeft - 4, guiTop + 24); RenderSystem.popMatrix(); - ScreenElementRenderer.renderBlock(this::getRenderedBlock); + RenderSystem.pushMatrix(); + GuiGameElement.of(renderedItem) + .at(guiLeft + STOCKSWITCH.width + 15, guiTop + 20) + .scale(5) + .render(); + RenderSystem.popMatrix(); } @Override @@ -136,10 +148,4 @@ public class StockswitchScreen extends AbstractSimiScreen { new ConfigureStockswitchPacket(te.getPos(), offBelow.getState() / 100f, onAbove.getState() / 100f)); } - public BlockState getRenderedBlock() { - RenderSystem.translated(guiLeft + STOCKSWITCH.width + 50, guiTop + 100, 0); - RenderSystem.rotatef(50, -.5f, 1, -.2f); - return AllBlocks.STOCKSWITCH.get().getDefaultState(); - } - } diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/inventories/FlexcrateScreen.java b/src/main/java/com/simibubi/create/modules/logistics/block/inventories/FlexcrateScreen.java index 49557fe03..c27104122 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/inventories/FlexcrateScreen.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/inventories/FlexcrateScreen.java @@ -12,15 +12,15 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPackets; import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; -import com.simibubi.create.foundation.gui.ScreenElementRenderer; +import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.widgets.Label; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.modules.logistics.packet.ConfigureFlexcratePacket; -import net.minecraft.block.BlockState; import net.minecraft.client.renderer.Rectangle2d; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; public class FlexcrateScreen extends AbstractSimiContainerScreen { @@ -32,6 +32,7 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen extraAreas; + private final ItemStack renderedItem = new ItemStack(AllBlocks.FLEXCRATE.get()); private final String title = Lang.translate("gui.flexcrate.title"); private final String storageSpace = Lang.translate("gui.flexcrate.storageSpace"); @@ -47,10 +48,14 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen lastModification = 0); + .withRange(1, (container.doubleCrate ? 2049 : 1025)) + .writingTo(allowedItemsLabel) + .withShiftStep(64) + .setState(te.allowedAmount) + .calling(s -> lastModification = 0); allowedItems.onChanged(); widgets.add(allowedItemsLabel); widgets.add(allowedItems); @@ -80,7 +85,8 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen slot * 64) @@ -91,12 +97,12 @@ public class FlexcrateScreen extends AbstractSimiContainerScreen getExtraAreas() { return extraAreas;