From 0c3696dd21c818bf25d1137c34b7836128745d88 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Wed, 21 Jul 2021 12:49:55 -0700 Subject: [PATCH] Extra alternative - Rename AnimatedKinetics#defaultBlockElement to AnimatedKinetics#blockElement - Add static alternative to AnimatedKinetics#blockElement meant to be used outside of subclasses --- .../category/ProcessingViaFanCategory.java | 7 ++--- .../animations/AnimatedBlazeBurner.java | 4 +-- .../category/animations/AnimatedCrafter.java | 4 +-- .../animations/AnimatedCrushingWheels.java | 4 +-- .../category/animations/AnimatedDeployer.java | 10 +++---- .../animations/AnimatedItemDrain.java | 2 +- .../category/animations/AnimatedKinetics.java | 28 +++++++++++++++---- .../animations/AnimatedMillstone.java | 4 +-- .../category/animations/AnimatedMixer.java | 10 +++---- .../category/animations/AnimatedPress.java | 8 +++--- .../jei/category/animations/AnimatedSaw.java | 6 ++-- .../category/animations/AnimatedSpout.java | 10 +++---- 12 files changed, 55 insertions(+), 42 deletions(-) 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 b8c27e694..4d0467a57 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 @@ -10,7 +10,6 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.compat.jei.category.animations.AnimatedKinetics; import com.simibubi.create.foundation.gui.AllGuiTextures; -import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.utility.Lang; import mezz.jei.api.constants.VanillaTypes; @@ -75,17 +74,15 @@ public abstract class ProcessingViaFanCategory> extends Cre matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 24; - GuiGameElement.of(AllBlockPartials.ENCASED_FAN_INNER) + AnimatedKinetics.defaultBlockElement(AllBlockPartials.ENCASED_FAN_INNER) .rotateBlock(180, 0, AnimatedKinetics.getCurrentAngle() * 16) .scale(scale) - .lighting(AnimatedKinetics.DEFAULT_LIGHTING) .render(matrixStack); - GuiGameElement.of(AllBlocks.ENCASED_FAN.getDefaultState()) + AnimatedKinetics.defaultBlockElement(AllBlocks.ENCASED_FAN.getDefaultState()) .rotateBlock(0, 180, 0) .atLocal(0, 0, 0) .scale(scale) - .lighting(AnimatedKinetics.DEFAULT_LIGHTING) .render(matrixStack); renderAttachedBlock(matrixStack); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java index 7a0bcd91d..84302d924 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java @@ -26,14 +26,14 @@ public class AnimatedBlazeBurner extends AnimatedKinetics { matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 23; - defaultBlockElement(AllBlocks.BLAZE_BURNER.getDefaultState()) + blockElement(AllBlocks.BLAZE_BURNER.getDefaultState()) .atLocal(0, 1.65, 0) .scale(scale) .render(matrixStack); float offset = (MathHelper.sin(AnimationTickHolder.getRenderTime() / 16f) + 0.5f) / 16f; PartialModel blaze = AllBlockPartials.BLAZES.get(heatLevel); - defaultBlockElement(blaze) + blockElement(blaze) .atLocal(1, 1.65 + offset, 1) .rotate(0, 180, 0) .scale(scale) 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 2fc1b195d..38fdb4ab6 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 @@ -19,12 +19,12 @@ public class AnimatedCrafter extends AnimatedKinetics { .rotateY(-22.5f); int scale = 22; - defaultBlockElement(cogwheel()) + blockElement(cogwheel()) .rotateBlock(90, 0, getCurrentAngle()) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlocks.MECHANICAL_CRAFTER.getDefaultState()) + blockElement(AllBlocks.MECHANICAL_CRAFTER.getDefaultState()) .rotateBlock(0, 180, 0) .scale(scale) .render(matrixStack); 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 d4f0f7e7f..29ef44198 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 @@ -20,12 +20,12 @@ public class AnimatedCrushingWheels extends AnimatedKinetics { matrixStack.mulPose(Vector3f.YP.rotationDegrees(-22.5f)); int scale = 22; - defaultBlockElement(wheel) + blockElement(wheel) .rotateBlock(0, 90, -getCurrentAngle()) .scale(scale) .render(matrixStack); - defaultBlockElement(wheel) + blockElement(wheel) .rotateBlock(0, 90, getCurrentAngle()) .atLocal(2, 0, 0) .scale(scale) diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedDeployer.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedDeployer.java index a1fe3e741..e5236ee95 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedDeployer.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedDeployer.java @@ -20,12 +20,12 @@ public class AnimatedDeployer extends AnimatedKinetics { matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 20; - defaultBlockElement(shaft(Axis.Z)) + blockElement(shaft(Axis.Z)) .rotateBlock(0, 0, getCurrentAngle()) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlocks.DEPLOYER.getDefaultState() + blockElement(AllBlocks.DEPLOYER.getDefaultState() .setValue(DeployerBlock.FACING, Direction.DOWN) .setValue(DeployerBlock.AXIS_ALONG_FIRST_COORDINATE, false)) .scale(scale) @@ -37,18 +37,18 @@ public class AnimatedDeployer extends AnimatedKinetics { matrixStack.pushPose(); matrixStack.translate(0, offset * 17, 0); - defaultBlockElement(AllBlockPartials.DEPLOYER_POLE) + blockElement(AllBlockPartials.DEPLOYER_POLE) .rotateBlock(90, 0, 0) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlockPartials.DEPLOYER_HAND_HOLDING) + blockElement(AllBlockPartials.DEPLOYER_HAND_HOLDING) .rotateBlock(90, 0, 0) .scale(scale) .render(matrixStack); matrixStack.popPose(); - defaultBlockElement(AllBlocks.DEPOT.getDefaultState()) + blockElement(AllBlocks.DEPOT.getDefaultState()) .atLocal(0, 2, 0) .scale(scale) .render(matrixStack); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java index 1b792cdbb..3186ad0c7 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java @@ -27,7 +27,7 @@ public class AnimatedItemDrain extends AnimatedKinetics { matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 20; - defaultBlockElement(AllBlocks.ITEM_DRAIN.getDefaultState()) + blockElement(AllBlocks.ITEM_DRAIN.getDefaultState()) .scale(scale) .render(matrixStack); 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 d41bdccec..069a397e2 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 @@ -22,6 +22,24 @@ public abstract class AnimatedKinetics implements IDrawable { .secondLightRotation(-20.0f, 50.0f) .build(); + /** + * Only use this method outside of subclasses. + * Use {@link #blockElement(BlockState)} if calling from inside a subclass. + */ + public static GuiGameElement.GuiRenderBuilder defaultBlockElement(BlockState state) { + return GuiGameElement.of(state) + .lighting(DEFAULT_LIGHTING); + } + + /** + * Only use this method outside of subclasses. + * Use {@link #blockElement(PartialModel)} if calling from inside a subclass. + */ + public static GuiGameElement.GuiRenderBuilder defaultBlockElement(PartialModel partial) { + return GuiGameElement.of(partial) + .lighting(DEFAULT_LIGHTING); + } + public static float getCurrentAngle() { return (AnimationTickHolder.getRenderTime() * 4f) % 360; } @@ -34,14 +52,12 @@ public abstract class AnimatedKinetics implements IDrawable { return AllBlockPartials.SHAFTLESS_COGWHEEL; } - protected GuiGameElement.GuiRenderBuilder defaultBlockElement(BlockState state) { - return GuiGameElement.of(state) - .lighting(DEFAULT_LIGHTING); + protected GuiGameElement.GuiRenderBuilder blockElement(BlockState state) { + return defaultBlockElement(state); } - protected GuiGameElement.GuiRenderBuilder defaultBlockElement(PartialModel partial) { - return GuiGameElement.of(partial) - .lighting(DEFAULT_LIGHTING); + protected GuiGameElement.GuiRenderBuilder blockElement(PartialModel partial) { + return defaultBlockElement(partial); } @Override 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 8bd4827bf..4c9b87063 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 @@ -15,12 +15,12 @@ public class AnimatedMillstone extends AnimatedKinetics { matrixStack.translate(-2, 18, 0); int scale = 22; - defaultBlockElement(AllBlockPartials.MILLSTONE_COG) + blockElement(AllBlockPartials.MILLSTONE_COG) .rotateBlock(22.5, getCurrentAngle() * 2, 0) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlocks.MILLSTONE.getDefaultState()) + blockElement(AllBlocks.MILLSTONE.getDefaultState()) .rotateBlock(22.5, 22.5, 0) .scale(scale) .render(matrixStack); 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 ec24775ef..1b95917a9 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 @@ -18,31 +18,31 @@ public class AnimatedMixer extends AnimatedKinetics { matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 23; - defaultBlockElement(cogwheel()) + blockElement(cogwheel()) .rotateBlock(0, getCurrentAngle() * 2, 0) .atLocal(0, 0, 0) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlocks.MECHANICAL_MIXER.getDefaultState()) + blockElement(AllBlocks.MECHANICAL_MIXER.getDefaultState()) .atLocal(0, 0, 0) .scale(scale) .render(matrixStack); float animation = ((MathHelper.sin(AnimationTickHolder.getRenderTime() / 32f) + 1) / 5) + .5f; - defaultBlockElement(AllBlockPartials.MECHANICAL_MIXER_POLE) + blockElement(AllBlockPartials.MECHANICAL_MIXER_POLE) .atLocal(0, animation, 0) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlockPartials.MECHANICAL_MIXER_HEAD) + blockElement(AllBlockPartials.MECHANICAL_MIXER_HEAD) .rotateBlock(0, getCurrentAngle() * 4, 0) .atLocal(0, animation, 0) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlocks.BASIN.getDefaultState()) + blockElement(AllBlocks.BASIN.getDefaultState()) .atLocal(0, 1.65, 0) .scale(scale) .render(matrixStack); 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 ebfe6b88e..a812afaa8 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 @@ -24,22 +24,22 @@ public class AnimatedPress extends AnimatedKinetics { matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = basin ? 23 : 24; - defaultBlockElement(shaft(Axis.Z)) + blockElement(shaft(Axis.Z)) .rotateBlock(0, 0, getCurrentAngle()) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlocks.MECHANICAL_PRESS.getDefaultState()) + blockElement(AllBlocks.MECHANICAL_PRESS.getDefaultState()) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlockPartials.MECHANICAL_PRESS_HEAD) + blockElement(AllBlockPartials.MECHANICAL_PRESS_HEAD) .atLocal(0, -getAnimatedHeadOffset(), 0) .scale(scale) .render(matrixStack); if (basin) - defaultBlockElement(AllBlocks.BASIN.getDefaultState()) + blockElement(AllBlocks.BASIN.getDefaultState()) .atLocal(0, 1.65, 0) .scale(scale) .render(matrixStack); 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 a2f17a740..de5e9dd97 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 @@ -21,18 +21,18 @@ public class AnimatedSaw extends AnimatedKinetics { matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f + 90)); int scale = 25; - defaultBlockElement(shaft(Axis.X)) + blockElement(shaft(Axis.X)) .rotateBlock(-getCurrentAngle(), 0, 0) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlocks.MECHANICAL_SAW.getDefaultState() + blockElement(AllBlocks.MECHANICAL_SAW.getDefaultState() .setValue(SawBlock.FACING, Direction.UP)) .rotateBlock(0, 0, 0) .scale(scale) .render(matrixStack); - defaultBlockElement(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE) + blockElement(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE) .rotateBlock(0, -90, -90) .scale(scale) .render(matrixStack); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java index 94ee2df86..0e09a4c51 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java @@ -32,7 +32,7 @@ public class AnimatedSpout extends AnimatedKinetics { matrixStack.mulPose(Vector3f.YP.rotationDegrees(22.5f)); int scale = 20; - defaultBlockElement(AllBlocks.SPOUT.getDefaultState()) + blockElement(AllBlocks.SPOUT.getDefaultState()) .scale(scale) .render(matrixStack); @@ -42,22 +42,22 @@ public class AnimatedSpout extends AnimatedKinetics { matrixStack.pushPose(); - defaultBlockElement(AllBlockPartials.SPOUT_TOP) + blockElement(AllBlockPartials.SPOUT_TOP) .scale(scale) .render(matrixStack); matrixStack.translate(0, -3 * squeeze / 32f, 0); - defaultBlockElement(AllBlockPartials.SPOUT_MIDDLE) + blockElement(AllBlockPartials.SPOUT_MIDDLE) .scale(scale) .render(matrixStack); matrixStack.translate(0, -3 * squeeze / 32f, 0); - defaultBlockElement(AllBlockPartials.SPOUT_BOTTOM) + blockElement(AllBlockPartials.SPOUT_BOTTOM) .scale(scale) .render(matrixStack); matrixStack.translate(0, -3 * squeeze / 32f, 0); matrixStack.popPose(); - defaultBlockElement(AllBlocks.DEPOT.getDefaultState()) + blockElement(AllBlocks.DEPOT.getDefaultState()) .atLocal(0, 2, 0) .scale(scale) .render(matrixStack);