From 08b2c498e6592d8e1c4bbaa3f767af3fa05c4253 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Fri, 9 Apr 2021 16:16:25 -0700 Subject: [PATCH 001/198] Add basic blocks and TEs for the chromatic projector --- build.gradle | 4 +-- .../java/com/simibubi/create/AllBlocks.java | 11 +++++++ .../com/simibubi/create/AllTileEntities.java | 7 +++++ .../curiosities/ChromaticProjectorBlock.java | 27 +++++++++++++++++ .../ChromaticProjectorTileEntity.java | 10 +++++++ .../backend/effects/EffectsHandler.java | 30 +++++++++++++++++++ .../create/flywheel/shaders/chromatic.frag | 13 ++++++++ 7 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorBlock.java create mode 100644 src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorTileEntity.java create mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java create mode 100644 src/main/resources/assets/create/flywheel/shaders/chromatic.frag diff --git a/build.gradle b/build.gradle index 2fc5362b4..44288edb4 100644 --- a/build.gradle +++ b/build.gradle @@ -33,8 +33,8 @@ sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = co minecraft { mappings channel: 'snapshot', version: '20200920-mixed-1.16.3' accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - runs { + + runs { client { workingDirectory project.file('run') // property 'mixin.env.disableRefMap', 'true' diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 62fec60ab..c1a9c1f7f 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -1338,6 +1338,17 @@ public class AllBlocks { .build() .register(); + static { + REGISTRATE.startSection(AllSections.CURIOSITIES); + } + + public static final BlockEntry CHROMATIC_PROJECTOR = + REGISTRATE.block("chromatic_projector", Block::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .item() + .build() + .register(); + // Load this class public static void register() {} diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index be2086c82..767531933 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -116,6 +116,7 @@ import com.simibubi.create.content.contraptions.relays.gearbox.GearboxInstance; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxRenderer; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity; import com.simibubi.create.content.contraptions.relays.gearbox.GearshiftTileEntity; +import com.simibubi.create.content.curiosities.ChromaticProjectorTileEntity; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelInstance; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelRenderer; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelTileEntity; @@ -654,5 +655,11 @@ public class AllTileEntities { .renderer(() -> AdjustableRepeaterRenderer::new) .register(); + public static final TileEntityEntry TESTFX = + Create.registrate() + .tileEntity("chromatic_projector", ChromaticProjectorTileEntity::new) + .validBlocks(AllBlocks.CHROMATIC_PROJECTOR) + .register(); + public static void register() {} } diff --git a/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorBlock.java b/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorBlock.java new file mode 100644 index 000000000..729cdf60f --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorBlock.java @@ -0,0 +1,27 @@ +package com.simibubi.create.content.curiosities; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockReader; + +import javax.annotation.Nullable; + +import com.simibubi.create.AllTileEntities; + +public class ChromaticProjectorBlock extends Block { + public ChromaticProjectorBlock(Properties p_i48440_1_) { + super(p_i48440_1_); + } + + @Override + public boolean hasTileEntity(BlockState state) { + return true; + } + + @Nullable + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + return AllTileEntities.TESTFX.create(); + } +} diff --git a/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorTileEntity.java new file mode 100644 index 000000000..8fe2e4644 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorTileEntity.java @@ -0,0 +1,10 @@ +package com.simibubi.create.content.curiosities; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityType; + +public class ChromaticProjectorTileEntity extends TileEntity { + public ChromaticProjectorTileEntity(TileEntityType te) { + super(te); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java new file mode 100644 index 000000000..509e5fb5b --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -0,0 +1,30 @@ +package com.simibubi.create.foundation.render.backend.effects; + +import net.minecraft.client.MainWindow; +import net.minecraft.client.Minecraft; +import net.minecraft.client.shader.Framebuffer; + +public class EffectsHandler { + + final Minecraft mc; + + private final Framebuffer framebuffer; + + public EffectsHandler(Minecraft minecraft) { + this.mc = minecraft; + + Framebuffer render = minecraft.getFramebuffer(); + framebuffer = new Framebuffer(render.framebufferWidth, render.framebufferHeight, false, Minecraft.IS_RUNNING_ON_MAC); + } + + public void prepFramebufferSize() { + MainWindow window = mc.getWindow(); + if (framebuffer.framebufferWidth != window.getFramebufferWidth() + || framebuffer.framebufferHeight != window.getFramebufferHeight()) { + framebuffer.func_216491_a(window.getFramebufferWidth(), window.getFramebufferHeight(), + Minecraft.IS_RUNNING_ON_MAC); + } + } + + +} diff --git a/src/main/resources/assets/create/flywheel/shaders/chromatic.frag b/src/main/resources/assets/create/flywheel/shaders/chromatic.frag new file mode 100644 index 000000000..7a1546907 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/chromatic.frag @@ -0,0 +1,13 @@ +#version 120 + +layout (std140) struct Sphere { + vec4 positionRadius; + vec4 color; +} uSpheres; + +uniform sampler2D uDepth; +uniform sampler2D uColor; + +void main() { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} From db7913d91b3435c1b9b4c5ecdf9b130ca74bc32c Mon Sep 17 00:00:00 2001 From: JozsefA Date: Mon, 12 Apr 2021 16:00:13 -0700 Subject: [PATCH 002/198] It all works, needs some cleanup --- .../render/ContraptionProgram.java | 2 +- .../simibubi/create/events/ClientEvents.java | 2 + .../foundation/mixin/RenderHooksMixin.java | 10 +- .../mixin/StoreProjectionMatrixMixin.java | 39 ++++- .../foundation/render/AllProgramSpecs.java | 39 +++-- .../foundation/render/KineticRenderer.java | 2 +- .../foundation/render/backend/Backend.java | 8 +- .../render/backend/FastRenderDispatcher.java | 7 - .../render/backend/ShaderLoader.java | 58 +++---- .../backend/{gl => core}/BasicProgram.java | 7 +- .../backend/effects/EffectsHandler.java | 121 +++++++++++++- .../effects/PostProcessingProgram.java | 76 +++++++++ .../backend/effects/ScreenQuadAttributes.java | 38 +++++ .../render/backend/gl/GlBuffer.java | 35 +++-- .../gl/shader/FogSensitiveProgram.java | 59 +++++-- .../render/backend/gl/shader/GlProgram.java | 147 +++++++++--------- .../render/backend/gl/shader/ProgramSpec.java | 64 +++----- .../backend/gl/shader/ShaderSpecLoader.java | 7 + .../backend/gl/shader/SingleProgram.java | 24 +++ .../backend/instancing/InstancedModel.java | 2 +- .../instancing/InstancedTileRenderer.java | 2 +- .../backend/instancing/RenderMaterial.java | 2 +- .../create/flywheel/shaders/chromatic.frag | 59 ++++++- .../create/flywheel/shaders/screen_quad.vert | 20 +++ 24 files changed, 611 insertions(+), 219 deletions(-) rename src/main/java/com/simibubi/create/foundation/render/backend/{gl => core}/BasicProgram.java (85%) create mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/effects/PostProcessingProgram.java create mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/effects/ScreenQuadAttributes.java create mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderSpecLoader.java create mode 100644 src/main/resources/assets/create/flywheel/shaders/screen_quad.vert diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java index 977593f34..7e0d2750e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.re import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.gl.BasicProgram; +import com.simibubi.create.foundation.render.backend.core.BasicProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramFogMode; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 88d13aece..d33a3c3bb 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -186,6 +186,8 @@ public class ClientEvents { ms.pop(); RenderWork.runAll(); + + //Backend.effects.render(); } @SubscribeEvent diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index da41425e6..2ea27cea7 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -46,9 +46,9 @@ public class RenderHooksMixin { if (!Backend.available()) return; - Matrix4f viewProjection = stack.peek() - .getModel() - .copy(); + Matrix4f view = stack.peek() + .getModel(); + Matrix4f viewProjection = view.copy(); viewProjection.multiplyBackward(Backend.projectionMatrix); FastRenderDispatcher.renderLayer(type, viewProjection, camX, camY, camZ); @@ -56,6 +56,10 @@ public class RenderHooksMixin { ContraptionRenderDispatcher.renderLayer(type, viewProjection, camX, camY, camZ); GL20.glUseProgram(0); + + if (type == RenderType.getTranslucent()) { + Backend.effects.render(view); + } } @Inject(at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.updateChunks(J)V"), method = "render") diff --git a/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java index 7b1d5c7cd..0fe562376 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java @@ -1,19 +1,41 @@ package com.simibubi.create.foundation.mixin; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.render.backend.Backend; +import com.simibubi.create.foundation.render.backend.effects.EffectsHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.util.math.vector.Matrix4f; @Mixin(GameRenderer.class) -public class StoreProjectionMatrixMixin { +public abstract class StoreProjectionMatrixMixin { + + @Shadow + private float cameraZoom; + @Shadow + private float zoomX; + @Shadow + private float zoomY; + + @Shadow + public abstract double getFOVModifier(ActiveRenderInfo p_215311_1_, float p_215311_2_, boolean p_215311_3_); + + @Shadow + @Final + private Minecraft mc; + @Shadow + private float farPlaneDistance; @Unique private boolean shouldCopy = false; @@ -34,4 +56,19 @@ public class StoreProjectionMatrixMixin { shouldCopy = false; } } + + @Inject(method = "getBasicProjectionMatrix", + at = @At("HEAD"), + cancellable = true) + private void overrideNearPlane(ActiveRenderInfo p_228382_1_, float p_228382_2_, boolean p_228382_3_, CallbackInfoReturnable cir) { + MatrixStack matrixstack = new MatrixStack(); + matrixstack.peek().getModel().loadIdentity(); + if (this.cameraZoom != 1.0F) { + matrixstack.translate((double) this.zoomX, (double) (-this.zoomY), 0.0D); + matrixstack.scale(this.cameraZoom, this.cameraZoom, 1.0F); + } + + matrixstack.peek().getModel().multiply(Matrix4f.perspective(this.getFOVModifier(p_228382_1_, p_228382_2_, p_228382_3_), (float) this.mc.getWindow().getFramebufferWidth() / (float) this.mc.getWindow().getFramebufferHeight(), EffectsHandler.getNearPlane(), EffectsHandler.getFarPlane())); + cir.setReturnValue(matrixstack.peek().getModel()); + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index 840732670..8592dbeb4 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -11,12 +11,15 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.content.contraptions.relays.belt.BeltAttributes; import com.simibubi.create.content.logistics.block.FlapAttributes; import com.simibubi.create.foundation.render.backend.core.BasicAttributes; +import com.simibubi.create.foundation.render.backend.core.BasicProgram; import com.simibubi.create.foundation.render.backend.core.ModelAttributes; import com.simibubi.create.foundation.render.backend.core.OrientedAttributes; import com.simibubi.create.foundation.render.backend.core.TransformAttributes; -import com.simibubi.create.foundation.render.backend.gl.BasicProgram; +import com.simibubi.create.foundation.render.backend.effects.PostProcessingProgram; +import com.simibubi.create.foundation.render.backend.gl.shader.FogSensitiveProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; import com.simibubi.create.foundation.render.backend.gl.shader.ShaderConstants; +import com.simibubi.create.foundation.render.backend.gl.shader.SingleProgram; import net.minecraft.util.ResourceLocation; @@ -25,7 +28,15 @@ public class AllProgramSpecs { // noop, make sure the static field are loaded. } - public static final ProgramSpec MODEL = register(ProgramSpec.builder("model", BasicProgram::new) + public static final ProgramSpec CHROMATIC = register(ProgramSpec.builder("chromatic", new SingleProgram.SpecLoader<>(PostProcessingProgram::new)) + .addAttributes(ModelAttributes.class) + .addAttributes(BasicAttributes.class) + .addAttributes(TransformAttributes.class) + .setVert(Locations.SCREEN_QUAD) + .setFrag(Locations.CHROMATIC) + .createProgramSpec()); + + public static final ProgramSpec MODEL = register(ProgramSpec.builder("model", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(TransformAttributes.class) @@ -33,7 +44,7 @@ public class AllProgramSpecs { .setFrag(Locations.MODEL_FRAG) .createProgramSpec()); - public static final ProgramSpec ORIENTED = register(ProgramSpec.builder("oriented", BasicProgram::new) + public static final ProgramSpec ORIENTED = register(ProgramSpec.builder("oriented", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(OrientedAttributes.class) @@ -41,7 +52,7 @@ public class AllProgramSpecs { .setFrag(Locations.MODEL_FRAG) .createProgramSpec()); - public static final ProgramSpec ROTATING = register(ProgramSpec.builder("rotating", BasicProgram::new) + public static final ProgramSpec ROTATING = register(ProgramSpec.builder("rotating", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(KineticAttributes.class) @@ -50,7 +61,7 @@ public class AllProgramSpecs { .setFrag(Locations.MODEL_FRAG) .createProgramSpec()); - public static final ProgramSpec BELT = register(ProgramSpec.builder("belt", BasicProgram::new) + public static final ProgramSpec BELT = register(ProgramSpec.builder("belt", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(KineticAttributes.class) @@ -59,18 +70,18 @@ public class AllProgramSpecs { .setFrag(Locations.MODEL_FRAG) .createProgramSpec()); - public static final ProgramSpec FLAPS = register(ProgramSpec.builder("flap", BasicProgram::new) + public static final ProgramSpec FLAPS = register(ProgramSpec.builder("flap", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(FlapAttributes.class) .setVert(Locations.FLAP) .setFrag(Locations.MODEL_FRAG) .createProgramSpec()); - public static final ProgramSpec C_STRUCTURE = register(ProgramSpec.builder("contraption_structure", ContraptionProgram::new) + public static final ProgramSpec C_STRUCTURE = register(ProgramSpec.builder("contraption_structure", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ContraptionAttributes.class) .setVert(Locations.CONTRAPTION_STRUCTURE) .setFrag(Locations.CONTRAPTION) .createProgramSpec()); - public static final ProgramSpec C_MODEL = register(ProgramSpec.builder("contraption_model", ContraptionProgram::new) + public static final ProgramSpec C_MODEL = register(ProgramSpec.builder("contraption_model", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(TransformAttributes.class) @@ -78,7 +89,7 @@ public class AllProgramSpecs { .setFrag(Locations.CONTRAPTION) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); - public static final ProgramSpec C_ORIENTED = register(ProgramSpec.builder("contraption_oriented", ContraptionProgram::new) + public static final ProgramSpec C_ORIENTED = register(ProgramSpec.builder("contraption_oriented", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(OrientedAttributes.class) @@ -86,7 +97,7 @@ public class AllProgramSpecs { .setFrag(Locations.CONTRAPTION) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); - public static final ProgramSpec C_ROTATING = register(ProgramSpec.builder("contraption_rotating", ContraptionProgram::new) + public static final ProgramSpec C_ROTATING = register(ProgramSpec.builder("contraption_rotating", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(KineticAttributes.class) @@ -95,7 +106,7 @@ public class AllProgramSpecs { .setFrag(Locations.CONTRAPTION) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); - public static final ProgramSpec C_BELT = register(ProgramSpec.builder("contraption_belt", ContraptionProgram::new) + public static final ProgramSpec C_BELT = register(ProgramSpec.builder("contraption_belt", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(KineticAttributes.class) @@ -104,14 +115,14 @@ public class AllProgramSpecs { .setFrag(Locations.CONTRAPTION) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); - public static final ProgramSpec C_FLAPS = register(ProgramSpec.builder("contraption_flap", ContraptionProgram::new) + public static final ProgramSpec C_FLAPS = register(ProgramSpec.builder("contraption_flap", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(FlapAttributes.class) .setVert(Locations.FLAP) .setFrag(Locations.CONTRAPTION) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); - public static final ProgramSpec C_ACTOR = register(ProgramSpec.builder("contraption_actor", ContraptionProgram::new) + public static final ProgramSpec C_ACTOR = register(ProgramSpec.builder("contraption_actor", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(ActorVertexAttributes.class) .setVert(Locations.CONTRAPTION_ACTOR) @@ -120,6 +131,8 @@ public class AllProgramSpecs { public static class Locations { + public static final ResourceLocation SCREEN_QUAD = loc("screen_quad.vert"); + public static final ResourceLocation CHROMATIC = loc("chromatic.frag"); public static final ResourceLocation MODEL_FRAG = loc("model.frag"); public static final ResourceLocation MODEL_VERT = loc("model.vert"); public static final ResourceLocation ORIENTED = loc("oriented.vert"); diff --git a/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java b/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java index 451122105..d6dd5bb80 100644 --- a/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java @@ -7,9 +7,9 @@ import com.simibubi.create.content.contraptions.base.RotatingModel; import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; import com.simibubi.create.content.logistics.block.FlapModel; import com.simibubi.create.foundation.render.backend.MaterialTypes; +import com.simibubi.create.foundation.render.backend.core.BasicProgram; import com.simibubi.create.foundation.render.backend.core.OrientedModel; import com.simibubi.create.foundation.render.backend.core.TransformedModel; -import com.simibubi.create.foundation.render.backend.gl.BasicProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ShaderCallback; import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/Backend.java b/src/main/java/com/simibubi/create/foundation/render/backend/Backend.java index 9c17503c9..095f96b84 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/Backend.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/Backend.java @@ -9,7 +9,7 @@ import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; import com.simibubi.create.foundation.config.AllConfigs; -import com.simibubi.create.foundation.render.backend.gl.GlFog; +import com.simibubi.create.foundation.render.backend.effects.EffectsHandler; import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; import com.simibubi.create.foundation.render.backend.gl.shader.IMultiProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; @@ -28,6 +28,7 @@ public class Backend { public static final Logger log = LogManager.getLogger(Backend.class); public static final ShaderLoader shaderLoader = new ShaderLoader(); + public static EffectsHandler effects; public static Matrix4f projectionMatrix = new Matrix4f(); @@ -108,5 +109,10 @@ public class Backend { compat.instancedArraysSupported(); enabled = AllConfigs.CLIENT.experimentalRendering.get() && !OptifineHandler.usingShaders(); + + if (enabled) { + if (effects != null) effects.delete(); + effects = new EffectsHandler(); + } } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java b/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java index f4deae1dc..fd516cdd8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java @@ -2,24 +2,17 @@ package com.simibubi.create.foundation.render.backend; import java.util.concurrent.ConcurrentHashMap; -import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.render.KineticRenderer; -import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.WorldAttached; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; -import net.minecraft.potion.Effects; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3f; import net.minecraft.world.World; public class FastRenderDispatcher { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoader.java b/src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoader.java index 41c5dfb33..1683c63bf 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoader.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoader.java @@ -12,7 +12,6 @@ import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; import java.util.ArrayList; import java.util.Collection; -import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -27,11 +26,9 @@ import org.lwjgl.system.MemoryUtil; import com.google.common.collect.Lists; import com.mojang.blaze3d.systems.RenderSystem; -import com.simibubi.create.foundation.render.backend.gl.GlFogMode; -import com.simibubi.create.foundation.render.backend.gl.shader.SingleProgram; +import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; import com.simibubi.create.foundation.render.backend.gl.shader.GlShader; -import com.simibubi.create.foundation.render.backend.gl.shader.FogSensitiveProgram; import com.simibubi.create.foundation.render.backend.gl.shader.IMultiProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; import com.simibubi.create.foundation.render.backend.gl.shader.ShaderConstants; @@ -96,43 +93,34 @@ public class ShaderLoader { private

> void loadProgramFromSpec(S programSpec) { - if (programSpec.fogSensitive) { - Map programGroup = new EnumMap<>(GlFogMode.class); - - for (GlFogMode fogMode : GlFogMode.values()) { - programGroup.put(fogMode, loadProgram(programSpec, fogMode)); - } - - Backend.programs.put(programSpec, new FogSensitiveProgram<>(programGroup)); - } else { - P program = loadProgram(programSpec, GlFogMode.NONE); - - Backend.programs.put(programSpec, new SingleProgram<>(program)); - } + Backend.programs.put(programSpec, programSpec.finalizer.create(this, programSpec)); Backend.log.debug("Loaded program {}", programSpec.name); } - private

> P loadProgram(S programSpec, GlFogMode fogMode) { - GlShader vert = null; - GlShader frag = null; + public GlProgram.Builder loadProgram(ProgramSpec programSpec) { + return loadProgram(programSpec, programSpec.defines); + } + + public GlProgram.Builder loadProgram(ProgramSpec programSpec, ShaderConstants defines) { + return loadProgram(programSpec.name, programSpec.vert, programSpec.frag, programSpec.attributes, defines); + } + + public GlProgram.Builder loadProgram(ResourceLocation name, ResourceLocation vert, ResourceLocation frag, Collection attribs, ShaderConstants defines) { + GlShader vsh = null; + GlShader fsh = null; try { - ShaderConstants defines = new ShaderConstants(programSpec.defines); - - defines.defineAll(fogMode.getDefines()); - - vert = loadShader(programSpec.getVert(), ShaderType.VERTEX, defines); - frag = loadShader(programSpec.getFrag(), ShaderType.FRAGMENT, defines); - - GlProgram.Builder builder = GlProgram.builder(programSpec.name, fogMode).attachShader(vert).attachShader(frag); - - programSpec.attributes.forEach(builder::addAttribute); - - return builder.build(programSpec.factory); + vsh = loadShader(vert, ShaderType.VERTEX, defines); + fsh = loadShader(frag, ShaderType.FRAGMENT, defines); + return GlProgram.builder(name) + .attachShader(vsh) + .attachShader(fsh) + .addAttributes(attribs) + .link(); } finally { - if (vert != null) vert.delete(); - if (frag != null) frag.delete(); + if (vsh != null) vsh.delete(); + if (fsh != null) fsh.delete(); } } @@ -166,7 +154,7 @@ public class ShaderLoader { }); } - private GlShader loadShader(ResourceLocation name, ShaderType type, ShaderConstants defines) { + public GlShader loadShader(ResourceLocation name, ShaderType type, ShaderConstants defines) { String source = shaderSource.get(name); source = processIncludes(name, source); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/BasicProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/core/BasicProgram.java similarity index 85% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/BasicProgram.java rename to src/main/java/com/simibubi/create/foundation/render/backend/core/BasicProgram.java index 2087795b0..5f2e671d3 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/BasicProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/core/BasicProgram.java @@ -1,8 +1,7 @@ -package com.simibubi.create.foundation.render.backend.gl; +package com.simibubi.create.foundation.render.backend.core; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.RenderUtil; import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramFogMode; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -51,8 +50,4 @@ public class BasicProgram extends GlProgram { fogMode.bind(); } - - protected static void uploadMatrixUniform(int uniform, Matrix4f mat) { - GL20.glUniformMatrix4fv(uniform, false, RenderUtil.writeMatrix(mat)); - } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index 509e5fb5b..e0bbdaadb 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -1,24 +1,72 @@ package com.simibubi.create.foundation.render.backend.effects; +import org.lwjgl.opengl.GL15; +import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL30; + +import com.simibubi.create.foundation.render.AllProgramSpecs; +import com.simibubi.create.foundation.render.backend.Backend; +import com.simibubi.create.foundation.render.backend.gl.GlBuffer; +import com.simibubi.create.foundation.render.backend.gl.GlPrimitiveType; +import com.simibubi.create.foundation.render.backend.gl.GlVertexArray; +import com.simibubi.create.foundation.utility.AnimationTickHolder; + import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.shader.Framebuffer; +import net.minecraft.client.shader.FramebufferConstants; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3d; public class EffectsHandler { - final Minecraft mc; + public static float getNearPlane() { + return 0.05f; + } + + public static float getFarPlane() { + return Minecraft.getInstance().gameRenderer.getFarPlaneDistance(); + } + + public static final float[] vertices = { + // pos // tex + -1.0f, -1.0f, 0.0f, 0.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + -1.0f, 1.0f, 0.0f, 1.0f, + + -1.0f, -1.0f, 0.0f, 0.0f, + 1.0f, -1.0f, 1.0f, 0.0f, + 1.0f, 1.0f, 1.0f, 1.0f + }; + + private static final int bufferSize = vertices.length * 4; private final Framebuffer framebuffer; + private final GlVertexArray vao = new GlVertexArray(); - public EffectsHandler(Minecraft minecraft) { - this.mc = minecraft; + private final GlBuffer vbo = new GlBuffer(GL20.GL_ARRAY_BUFFER); - Framebuffer render = minecraft.getFramebuffer(); + public EffectsHandler() { + Framebuffer render = Minecraft.getInstance().getFramebuffer(); framebuffer = new Framebuffer(render.framebufferWidth, render.framebufferHeight, false, Minecraft.IS_RUNNING_ON_MAC); + + vbo.bind(); + vbo.alloc(bufferSize, GL15.GL_STATIC_DRAW); + vbo.map(bufferSize, buf -> buf.asFloatBuffer().put(vertices)); + + vao.bind(); + + GL20.glEnableVertexAttribArray(0); + + GL20.glVertexAttribPointer(0, 4, GlPrimitiveType.FLOAT.getGlConstant(), false, 4 * 4, 0); + + vao.unbind(); + vbo.unbind(); } public void prepFramebufferSize() { - MainWindow window = mc.getWindow(); + MainWindow window = Minecraft.getInstance().getWindow(); if (framebuffer.framebufferWidth != window.getFramebufferWidth() || framebuffer.framebufferHeight != window.getFramebufferHeight()) { framebuffer.func_216491_a(window.getFramebufferWidth(), window.getFramebufferHeight(), @@ -26,5 +74,68 @@ public class EffectsHandler { } } + public void render(Matrix4f view) { + GL20.glEnable(GL20.GL_DEPTH_TEST); + GL20.glDepthRange(getNearPlane(), getFarPlane()); + +// float[] floats = new float[2]; +// GL20.glGetFloatv(GL20.GL_DEPTH_RANGE, floats); + + prepFramebufferSize(); + + Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); + + GL30.glBindFramebuffer(FramebufferConstants.FRAME_BUFFER, framebuffer.framebufferObject); + + PostProcessingProgram program = Backend.getProgram(AllProgramSpecs.CHROMATIC); + program.bind(); + + program.bindColorTexture(mainBuffer.getColorAttachment()); + program.bindDepthTexture(mainBuffer.getDepthAttachment()); + + GameRenderer gameRenderer = Minecraft.getInstance().gameRenderer; + Matrix4f projection = gameRenderer.getBasicProjectionMatrix(gameRenderer.getActiveRenderInfo(), AnimationTickHolder.getPartialTicks(), true); + //Matrix4f projection = Backend.projectionMatrix.copy(); + //projection.a23 = projection.a32 = 0; + projection.a33 = 1; + projection.invert(); + program.bindInverseProjection(projection); + + Matrix4f inverseView = view.copy(); + inverseView.invert(); +// Matrix4f inverseView = new Matrix4f(); +// inverseView.loadIdentity(); + program.bindInverseView(inverseView); + + Vector3d pos = new Vector3d(286, 73, -149); + Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView(); + + Vector3d shaderPos = pos.subtract(cameraPos).scale(1 / getFarPlane()); + program.setSphere(shaderPos, 20f / getFarPlane(), 0.01f); + + program.setFarPlane(getFarPlane()); + program.setNearPlane(getNearPlane()); + + vao.bind(); + GL20.glDrawArrays(GL20.GL_TRIANGLES, 0, 6); + vao.unbind(); + + program.bindColorTexture(0); + program.bindDepthTexture(0); + + program.unbind(); + + GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebuffer.framebufferObject); + GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject); + GL30.glBlitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); + GL30.glBindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject); + } + + public void delete() { + framebuffer.deleteFramebuffer(); + + vao.delete(); + vbo.delete(); + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/PostProcessingProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/PostProcessingProgram.java new file mode 100644 index 000000000..19f239ad2 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/PostProcessingProgram.java @@ -0,0 +1,76 @@ +package com.simibubi.create.foundation.render.backend.effects; + +import org.lwjgl.opengl.GL20; + +import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; + +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3d; + +public class PostProcessingProgram extends GlProgram { + + final int uDepth; + final int uColor; + + final int uInverseProjection; + final int uInverseView; + + final int uNearPlane; + final int uFarPlane; + final int uSphereCenter; + final int uSphereRadius; + final int uSphereFeather; + + + public PostProcessingProgram(ResourceLocation name, int handle) { + super(name, handle); + + uInverseProjection = getUniformLocation("uInverseProjection"); + uInverseView = getUniformLocation("uInverseView"); + uNearPlane = getUniformLocation("uNearPlane"); + uFarPlane = getUniformLocation("uFarPlane"); + uSphereCenter = getUniformLocation("uSphereCenter"); + uSphereRadius = getUniformLocation("uSphereRadius"); + uSphereFeather = getUniformLocation("uSphereFeather"); + + bind(); + uDepth = setSamplerBinding("uDepth", 8); + uColor = setSamplerBinding("uColor", 9); + unbind(); + } + + public void setNearPlane(float nearPlane) { + GL20.glUniform1f(uNearPlane, nearPlane); + } + + public void setFarPlane(float farPlane) { + GL20.glUniform1f(uFarPlane, farPlane); + } + + public void setSphere(Vector3d center, float radius, float feather) { + GL20.glUniform3f(uSphereCenter, (float) center.x, (float) center.y, (float) center.z); + + GL20.glUniform1f(uSphereRadius, radius); + GL20.glUniform1f(uSphereFeather, feather); + } + + public void bindInverseProjection(Matrix4f mat) { + uploadMatrixUniform(uInverseProjection, mat); + } + + public void bindInverseView(Matrix4f mat) { + uploadMatrixUniform(uInverseView, mat); + } + + public void bindDepthTexture(int textureObject) { + GL20.glActiveTexture(GL20.GL_TEXTURE8); + GL20.glBindTexture(GL20.GL_TEXTURE_2D, textureObject); + } + + public void bindColorTexture(int textureObject) { + GL20.glActiveTexture(GL20.GL_TEXTURE9); + GL20.glBindTexture(GL20.GL_TEXTURE_2D, textureObject); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ScreenQuadAttributes.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ScreenQuadAttributes.java new file mode 100644 index 000000000..5b81e2383 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ScreenQuadAttributes.java @@ -0,0 +1,38 @@ +package com.simibubi.create.foundation.render.backend.effects; + +import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; +import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; +import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; + +public enum ScreenQuadAttributes implements IVertexAttrib { + INSTANCE_POS("aVertex", CommonAttributes.VEC4), + ; + + private final String name; + private final IAttribSpec spec; + + ScreenQuadAttributes(String name, IAttribSpec spec) { + this.name = name; + this.spec = spec; + } + + @Override + public String attribName() { + return name; + } + + @Override + public IAttribSpec attribSpec() { + return spec; + } + + @Override + public int getDivisor() { + return 0; + } + + @Override + public int getBufferIndex() { + return 0; + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java index f39913ccd..7cb688703 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java @@ -3,6 +3,7 @@ package com.simibubi.create.foundation.render.backend.gl; import java.nio.ByteBuffer; import java.util.function.Consumer; +import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import com.simibubi.create.foundation.render.backend.Backend; @@ -18,25 +19,29 @@ public class GlBuffer extends GlObject { public int getBufferType() { return bufferType; - } + } - public void bind() { - GL20.glBindBuffer(bufferType, handle()); - } + public void bind() { + GL20.glBindBuffer(bufferType, handle()); + } - public void unbind() { - GL20.glBindBuffer(bufferType, 0); - } + public void unbind() { + GL20.glBindBuffer(bufferType, 0); + } - public void with(Consumer action) { - bind(); - action.accept(this); - unbind(); - } + public void alloc(int size, int usage) { + GL15.glBufferData(bufferType, size, usage); + } - public void map(int length, Consumer upload) { - Backend.compat.mapBuffer(bufferType, 0, length, upload); - } + public void with(Consumer action) { + bind(); + action.accept(this); + unbind(); + } + + public void map(int length, Consumer upload) { + Backend.compat.mapBuffer(bufferType, 0, length, upload); + } public void map(int offset, int length, Consumer upload) { Backend.compat.mapBuffer(bufferType, offset, length, upload); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/FogSensitiveProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/FogSensitiveProgram.java index 426dbc4ac..b308a6bd3 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/FogSensitiveProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/FogSensitiveProgram.java @@ -1,26 +1,61 @@ package com.simibubi.create.foundation.render.backend.gl.shader; +import java.util.EnumMap; import java.util.Map; +import com.simibubi.create.foundation.render.backend.ShaderLoader; import com.simibubi.create.foundation.render.backend.gl.GlFog; import com.simibubi.create.foundation.render.backend.gl.GlFogMode; +import net.minecraft.util.ResourceLocation; + public class FogSensitiveProgram

implements IMultiProgram

{ - private final Map programs; + private final Map programs; - public FogSensitiveProgram(Map programs) { - this.programs = programs; - } + public FogSensitiveProgram(Map programs) { + this.programs = programs; + } - @Override - public P get() { - return programs.get(GlFog.getFogMode()); - } + @Override + public P get() { + return programs.get(GlFog.getFogMode()); + } - @Override - public void delete() { - programs.values().forEach(GlProgram::delete); - } + @Override + public void delete() { + programs.values().forEach(GlProgram::delete); + } + public static class SpecLoader

implements ShaderSpecLoader

{ + + private final FogProgramLoader

fogProgramLoader; + + public SpecLoader(FogProgramLoader

fogProgramLoader) { + this.fogProgramLoader = fogProgramLoader; + } + + @Override + public IMultiProgram

create(ShaderLoader loader, ProgramSpec

spec) { + Map programs = new EnumMap<>(GlFogMode.class); + + for (GlFogMode fogMode : GlFogMode.values()) { + ShaderConstants defines = new ShaderConstants(spec.defines); + + defines.defineAll(fogMode.getDefines()); + + GlProgram.Builder builder = loader.loadProgram(spec, defines); + + programs.put(fogMode, fogProgramLoader.create(builder.name, builder.program, fogMode.getFogFactory())); + } + + return new FogSensitiveProgram<>(programs); + } + + } + + public interface FogProgramLoader

{ + + P create(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory); + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlProgram.java index 56dce3fd8..40d2e62ae 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlProgram.java @@ -1,34 +1,37 @@ package com.simibubi.create.foundation.render.backend.gl.shader; +import java.util.Collection; + import org.lwjgl.opengl.GL20; import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.gl.GlFogMode; +import com.simibubi.create.foundation.render.backend.RenderUtil; import com.simibubi.create.foundation.render.backend.gl.GlObject; import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.vector.Matrix4f; public abstract class GlProgram extends GlObject { - public final ResourceLocation name; + public final ResourceLocation name; - protected GlProgram(ResourceLocation name, int handle) { - setHandle(handle); - this.name = name; - } + protected GlProgram(ResourceLocation name, int handle) { + setHandle(handle); + this.name = name; + } - public static Builder builder(ResourceLocation name, GlFogMode fogMode) { - return new Builder(name, fogMode); - } + public static Builder builder(ResourceLocation name) { + return new Builder(name); + } - public void bind() { - GL20.glUseProgram(handle()); - } + public void bind() { + GL20.glUseProgram(handle()); + } - public void unbind() { - GL20.glUseProgram(0); - } + public void unbind() { + GL20.glUseProgram(0); + } /** * Retrieves the index of the uniform with the given name. @@ -52,76 +55,78 @@ public abstract class GlProgram extends GlObject { * @return The sampler uniform's index. * @throws NullPointerException If no uniform exists with the given name. */ - public int setSamplerBinding(String name, int binding) { - int samplerUniform = getUniformLocation(name); + public int setSamplerBinding(String name, int binding) { + int samplerUniform = getUniformLocation(name); - if (samplerUniform >= 0) { - GL20.glUniform1i(samplerUniform, binding); - } + if (samplerUniform >= 0) { + GL20.glUniform1i(samplerUniform, binding); + } - return samplerUniform; - } + return samplerUniform; + } - @Override - protected void deleteInternal(int handle) { - GL20.glDeleteProgram(handle); - } + protected static void uploadMatrixUniform(int uniform, Matrix4f mat) { + GL20.glUniformMatrix4fv(uniform, false, RenderUtil.writeMatrix(mat)); + } - public static class Builder { - private final ResourceLocation name; - private final int program; - private final GlFogMode fogMode; + @Override + protected void deleteInternal(int handle) { + GL20.glDeleteProgram(handle); + } - private int attributeIndex; + public static class Builder { + public final ResourceLocation name; + public final int program; - public Builder(ResourceLocation name, GlFogMode fogMode) { - this.name = name; - this.program = GL20.glCreateProgram(); - this.fogMode = fogMode; - } + private int attributeIndex; - public Builder attachShader(GlShader shader) { - GL20.glAttachShader(this.program, shader.handle()); + public Builder(ResourceLocation name) { + this.name = name; + this.program = GL20.glCreateProgram(); + } - return this; - } + public Builder attachShader(GlShader shader) { + GL20.glAttachShader(this.program, shader.handle()); - public Builder addAttribute(A attrib) { - GL20.glBindAttribLocation(this.program, attributeIndex, attrib.attribName()); - attributeIndex += attrib.attribSpec().getAttributeCount(); - return this; - } + return this; + } - /** - * Links the attached shaders to this program and returns a user-defined container which wraps the shader - * program. This container can, for example, provide methods for updating the specific uniforms of that shader - * set. - * - * @param factory The factory which will create the shader program's container - * @param

The type which should be instantiated with the new program's handle - * @return An instantiated shader container as provided by the factory - */ - public

P build(ProgramFactory

factory) { - GL20.glLinkProgram(this.program); + public Builder addAttributes(Collection attributes) { + attributes.forEach(this::addAttribute); + return this; + } - String log = GL20.glGetProgramInfoLog(this.program); + public Builder addAttribute(A attrib) { + GL20.glBindAttribLocation(this.program, attributeIndex, attrib.attribName()); + attributeIndex += attrib.attribSpec().getAttributeCount(); + return this; + } - if (!log.isEmpty()) { - Backend.log.debug("Program link log for " + this.name + ": " + log); - } + /** + * Links the attached shaders to this program and returns a user-defined container which wraps the shader + * program. This container can, for example, provide methods for updating the specific uniforms of that shader + * set. + * + * @param factory The factory which will create the shader program's container + * @param

The type which should be instantiated with the new program's handle + * @return An instantiated shader container as provided by the factory + */ + public Builder link() { + GL20.glLinkProgram(this.program); - int result = GL20.glGetProgrami(this.program, GL20.GL_LINK_STATUS); + String log = GL20.glGetProgramInfoLog(this.program); - if (result != GL20.GL_TRUE) { - throw new RuntimeException("Shader program linking failed, see log for details"); - } + if (!log.isEmpty()) { + Backend.log.debug("Program link log for " + this.name + ": " + log); + } - return factory.create(this.name, this.program, this.fogMode.getFogFactory()); - } - } + int result = GL20.glGetProgrami(this.program, GL20.GL_LINK_STATUS); - @FunctionalInterface - public interface ProgramFactory

{ - P create(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory); - } + if (result != GL20.GL_TRUE) { + throw new RuntimeException("Shader program linking failed, see log for details"); + } + + return this; + } + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramSpec.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramSpec.java index 26c3b0eb2..33c891517 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramSpec.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramSpec.java @@ -16,54 +16,42 @@ public class ProgramSpec

{ public final ShaderConstants defines; - public final GlProgram.ProgramFactory

factory; - public final ArrayList attributes; - public final boolean fogSensitive; + public final ShaderSpecLoader

finalizer; - public static

Builder

builder(String name, GlProgram.ProgramFactory

factory) { - return builder(new ResourceLocation(Create.ID, name), factory); - } - - public static

Builder

builder(ResourceLocation name, GlProgram.ProgramFactory

factory) { - return new Builder<>(name, factory); - } - - public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag, GlProgram.ProgramFactory

factory, ShaderConstants defines, ArrayList attributes, boolean fogSensitive) { - this.name = name; - this.vert = vert; - this.frag = frag; - this.defines = defines; - - this.factory = factory; - this.attributes = attributes; - this.fogSensitive = fogSensitive; + public static

Builder

builder(String name, ShaderSpecLoader

factory) { + return builder(new ResourceLocation(Create.ID, name), factory); } - public ResourceLocation getVert() { - return vert; - } + public static

Builder

builder(ResourceLocation name, ShaderSpecLoader

factory) { + return new Builder<>(name, factory); + } - public ResourceLocation getFrag() { - return frag; - } + public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag, ShaderConstants defines, ArrayList attributes, ShaderSpecLoader

finalizer) { + this.name = name; + this.vert = vert; + this.frag = frag; + this.defines = defines; + + this.attributes = attributes; + this.finalizer = finalizer; + } public static class Builder

{ private ResourceLocation vert; private ResourceLocation frag; - private ShaderConstants defines = ShaderConstants.EMPTY; - private boolean fogSensitive = true; + private ShaderConstants defines = ShaderConstants.EMPTY; + private final ShaderSpecLoader

loader; private final ResourceLocation name; - private final GlProgram.ProgramFactory

factory; private final ArrayList attributes; - public Builder(ResourceLocation name, GlProgram.ProgramFactory

factory) { - this.name = name; - this.factory = factory; - attributes = new ArrayList<>(); - } + public Builder(ResourceLocation name, ShaderSpecLoader

factory) { + this.name = name; + this.loader = factory; + attributes = new ArrayList<>(); + } public Builder

setVert(ResourceLocation vert) { this.vert = vert; @@ -80,18 +68,14 @@ public class ProgramSpec

{ return this; } - public Builder

setFogSensitive(boolean fogSensitive) { - this.fogSensitive = fogSensitive; - return this; - } - public & IVertexAttrib> Builder

addAttributes(Class attributeEnum) { attributes.addAll(Arrays.asList(attributeEnum.getEnumConstants())); return this; } public ProgramSpec

createProgramSpec() { - return new ProgramSpec<>(name, vert, frag, factory, defines, attributes, fogSensitive); + return new ProgramSpec<>(name, vert, frag, defines, attributes, loader); } } + } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderSpecLoader.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderSpecLoader.java new file mode 100644 index 000000000..3747a572c --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderSpecLoader.java @@ -0,0 +1,7 @@ +package com.simibubi.create.foundation.render.backend.gl.shader; + +import com.simibubi.create.foundation.render.backend.ShaderLoader; + +public interface ShaderSpecLoader

{ + IMultiProgram

create(ShaderLoader loader, ProgramSpec

spec); +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/SingleProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/SingleProgram.java index c3ee700ab..832e6d8e3 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/SingleProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/SingleProgram.java @@ -1,5 +1,9 @@ package com.simibubi.create.foundation.render.backend.gl.shader; +import com.simibubi.create.foundation.render.backend.ShaderLoader; + +import net.minecraft.util.ResourceLocation; + public class SingleProgram

implements IMultiProgram

{ final P program; @@ -16,4 +20,24 @@ public class SingleProgram

implements IMultiProgram

{ public void delete() { program.delete(); } + + public static class SpecLoader

implements ShaderSpecLoader

{ + final ProgramFactory

factory; + + public SpecLoader(ProgramFactory

factory) { + this.factory = factory; + } + + @Override + public IMultiProgram

create(ShaderLoader loader, ProgramSpec

spec) { + GlProgram.Builder builder = loader.loadProgram(spec); + + return new SingleProgram<>(factory.create(builder.name, builder.program)); + } + } + + @FunctionalInterface + public interface ProgramFactory

{ + P create(ResourceLocation name, int handle); + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java index fc6be1b40..10f182d46 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java @@ -182,7 +182,7 @@ public abstract class InstancedModel extends BufferedMod int requiredSize = size * stride; if (requiredSize > glBufferSize) { glBufferSize = requiredSize + stride * 16; - GL15.glBufferData(instanceVBO.getBufferType(), glBufferSize, GL15.GL_STATIC_DRAW); + instanceVBO.alloc(glBufferSize, GL15.GL_STATIC_DRAW); instanceVBO.map(glBufferSize, buffer -> { for (D datum : data) { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java index a7bdc1dcc..fd080bf7d 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java @@ -9,9 +9,9 @@ import javax.annotation.Nullable; import com.simibubi.create.foundation.render.backend.Backend; import com.simibubi.create.foundation.render.backend.MaterialType; import com.simibubi.create.foundation.render.backend.MaterialTypes; +import com.simibubi.create.foundation.render.backend.core.BasicProgram; import com.simibubi.create.foundation.render.backend.core.ModelData; import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.gl.BasicProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ShaderCallback; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java index f2f3e1bc7..a56770802 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java @@ -19,7 +19,7 @@ import com.simibubi.create.foundation.render.Compartment; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.backend.Backend; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.gl.BasicProgram; +import com.simibubi.create.foundation.render.backend.core.BasicProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; import com.simibubi.create.foundation.render.backend.gl.shader.ShaderCallback; diff --git a/src/main/resources/assets/create/flywheel/shaders/chromatic.frag b/src/main/resources/assets/create/flywheel/shaders/chromatic.frag index 7a1546907..bd70e8d22 100644 --- a/src/main/resources/assets/create/flywheel/shaders/chromatic.frag +++ b/src/main/resources/assets/create/flywheel/shaders/chromatic.frag @@ -1,13 +1,62 @@ #version 120 -layout (std140) struct Sphere { - vec4 positionRadius; - vec4 color; -} uSpheres; +varying vec4 Vertex; +varying vec3 CameraDir; + +//layout (std140) struct Sphere { +// vec4 positionRadius; +// vec4 color; +//} uSphere; uniform sampler2D uDepth; uniform sampler2D uColor; +uniform mat4 uInverseProjection; +uniform mat4 uInverseView; + +uniform float uNearPlane = 0.15; +uniform float uFarPlane = 1; +uniform vec3 uSphereCenter = vec3(0, 0, 0); +uniform float uSphereRadius = 1; +uniform float uSphereFeather = 0.05; + +float linearizeDepth(float d, float zNear, float zFar) { + float z_n = 2.0 * d - 1.0; + return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear)); +} + +vec4 filterColor(vec4 frag) { + const vec3 lum = vec3(0.21, 0.71, 0.07); + float grey = dot(frag.rgb, lum.rgb); + return vec4(grey, grey, grey, frag.a); +} + +vec3 getWorldPos(float depth) { + vec3 cameraPos = CameraDir * depth; + + vec3 worldPos = (uInverseView * vec4(cameraPos, 1)).xyz; + + return worldPos; +} + +float getDepth() { + float depth = texture2D(uDepth, Vertex.zw).r; + + depth = linearizeDepth(depth, uNearPlane, uFarPlane); + //depth = ( - uNearPlane) / (uFarPlane - uNearPlane); + depth = depth / uFarPlane; + + return depth; +} void main() { - gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + float depth = getDepth(); + vec3 worldPos = getWorldPos(depth); + + float distance = distance(uSphereCenter, worldPos); + float strength = smoothstep(uSphereRadius - uSphereFeather, uSphereRadius + uSphereFeather, distance); + + vec4 fragColor = texture2D(uColor, Vertex.zw); + + gl_FragColor = mix(fragColor, filterColor(fragColor), strength); + //gl_FragColor = vec4(worldPos, 1); } diff --git a/src/main/resources/assets/create/flywheel/shaders/screen_quad.vert b/src/main/resources/assets/create/flywheel/shaders/screen_quad.vert new file mode 100644 index 000000000..248157475 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/screen_quad.vert @@ -0,0 +1,20 @@ +#version 120 + +attribute vec4 aVertex;// + +varying vec4 Vertex; +varying vec3 CameraDir; + +uniform mat4 uInverseProjection; + +void main() { + gl_Position = vec4(aVertex.xy, 0.0f, 1.0f); + Vertex = aVertex; + + vec4 clip = vec4(aVertex.xy, 0, 1); + + clip *= uInverseProjection; + + CameraDir = clip.xyz / clip.w; + //worldDirection = (uInverseProjection * vec4(aVertex.xy, 0, 1.)).xyz; +} From 7988fb69a7c9ebaf19c333e6bf204c98640fd411 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 13 Apr 2021 23:52:52 -0700 Subject: [PATCH 003/198] Color matrices and many effect spheres --- .../foundation/mixin/RenderHooksMixin.java | 19 +- .../foundation/render/AllProgramSpecs.java | 12 +- .../render/backend/effects/ColorMatrices.java | 81 ++++++++ .../backend/effects/EffectsHandler.java | 43 ++++- .../effects/PostProcessingProgram.java | 76 -------- .../backend/effects/SphereFilterProgram.java | 177 ++++++++++++++++++ .../render/backend/gl/GlBuffer.java | 38 ++-- .../create/flywheel/shaders/area_effect.frag | 67 +++++++ .../create/flywheel/shaders/area_effect.vert | 22 +++ .../create/flywheel/shaders/chromatic.frag | 62 ------ .../create/flywheel/shaders/core/color.glsl | 22 +++ .../create/flywheel/shaders/screen_quad.vert | 20 -- 12 files changed, 449 insertions(+), 190 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/effects/PostProcessingProgram.java create mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java create mode 100644 src/main/resources/assets/create/flywheel/shaders/area_effect.frag create mode 100644 src/main/resources/assets/create/flywheel/shaders/area_effect.vert delete mode 100644 src/main/resources/assets/create/flywheel/shaders/chromatic.frag create mode 100644 src/main/resources/assets/create/flywheel/shaders/core/color.glsl delete mode 100644 src/main/resources/assets/create/flywheel/shaders/screen_quad.vert diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index 2ea27cea7..d140a4bef 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.KineticRenderer; @@ -56,10 +57,6 @@ public class RenderHooksMixin { ContraptionRenderDispatcher.renderLayer(type, viewProjection, camX, camY, camZ); GL20.glUseProgram(0); - - if (type == RenderType.getTranslucent()) { - Backend.effects.render(view); - } } @Inject(at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.updateChunks(J)V"), method = "render") @@ -72,14 +69,24 @@ public class RenderHooksMixin { double camZ = cameraPos.getZ(); CreateClient.kineticRenderer.get(world) - .beginFrame(info, camX, camY, camZ); + .beginFrame(info, camX, camY, camZ); ContraptionRenderDispatcher.beginFrame(info, camX, camY, camZ); } + @Inject(method = "render", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;render(F)V")) + private void disableTransparencyShaderDepth(MatrixStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) { + GlStateManager.depthMask(false); + } + + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/renderer/ActiveRenderInfo;)V")) + private void applyFilters(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) { + Backend.effects.render(stack.peek().getModel()); + } + @Inject(at = @At("TAIL"), method = "scheduleBlockRerenderIfNeeded") private void checkUpdate(BlockPos pos, BlockState lastState, BlockState newState, CallbackInfo ci) { CreateClient.kineticRenderer.get(world) - .update(world.getTileEntity(pos)); + .update(world.getTileEntity(pos)); } @Inject(at = @At("TAIL"), method = "loadRenderers") diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index 8592dbeb4..df7bfb5b6 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -15,7 +15,7 @@ import com.simibubi.create.foundation.render.backend.core.BasicProgram; import com.simibubi.create.foundation.render.backend.core.ModelAttributes; import com.simibubi.create.foundation.render.backend.core.OrientedAttributes; import com.simibubi.create.foundation.render.backend.core.TransformAttributes; -import com.simibubi.create.foundation.render.backend.effects.PostProcessingProgram; +import com.simibubi.create.foundation.render.backend.effects.SphereFilterProgram; import com.simibubi.create.foundation.render.backend.gl.shader.FogSensitiveProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; import com.simibubi.create.foundation.render.backend.gl.shader.ShaderConstants; @@ -28,12 +28,12 @@ public class AllProgramSpecs { // noop, make sure the static field are loaded. } - public static final ProgramSpec CHROMATIC = register(ProgramSpec.builder("chromatic", new SingleProgram.SpecLoader<>(PostProcessingProgram::new)) + public static final ProgramSpec CHROMATIC = register(ProgramSpec.builder("chromatic", new SingleProgram.SpecLoader<>(SphereFilterProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(TransformAttributes.class) - .setVert(Locations.SCREEN_QUAD) - .setFrag(Locations.CHROMATIC) + .setVert(Locations.EFFECT_VERT) + .setFrag(Locations.EFFECT_FRAG) .createProgramSpec()); public static final ProgramSpec MODEL = register(ProgramSpec.builder("model", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) @@ -131,8 +131,8 @@ public class AllProgramSpecs { public static class Locations { - public static final ResourceLocation SCREEN_QUAD = loc("screen_quad.vert"); - public static final ResourceLocation CHROMATIC = loc("chromatic.frag"); + public static final ResourceLocation EFFECT_VERT = loc("area_effect.vert"); + public static final ResourceLocation EFFECT_FRAG = loc("area_effect.frag"); public static final ResourceLocation MODEL_FRAG = loc("model.frag"); public static final ResourceLocation MODEL_VERT = loc("model.vert"); public static final ResourceLocation ORIENTED = loc("oriented.vert"); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java new file mode 100644 index 000000000..ab32b6b97 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java @@ -0,0 +1,81 @@ +package com.simibubi.create.foundation.render.backend.effects; + +import com.simibubi.create.foundation.utility.AngleHelper; + +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.vector.Matrix4f; + +public class ColorMatrices { + + public static final float lumaR = 0.3086f; + public static final float lumaG = 0.6094f; + public static final float lumaB = 0.0820f; + + public static Matrix4f grayscale() { + Matrix4f mat = new Matrix4f(); + + mat.a00 = mat.a01 = mat.a02 = lumaR; + mat.a10 = mat.a11 = mat.a12 = lumaG; + mat.a20 = mat.a21 = mat.a22 = lumaB; + mat.a33 = 1; + + return mat; + } + + public static Matrix4f saturate(float s) { + Matrix4f mat = new Matrix4f(); + + mat.a00 = (1.0f - s) * lumaR + s; + mat.a01 = (1.0f - s) * lumaR; + mat.a02 = (1.0f - s) * lumaR; + mat.a10 = (1.0f - s) * lumaG; + mat.a11 = (1.0f - s) * lumaG + s; + mat.a12 = (1.0f - s) * lumaG; + mat.a20 = (1.0f - s) * lumaB; + mat.a21 = (1.0f - s) * lumaB; + mat.a22 = (1.0f - s) * lumaB + s; + + mat.a33 = 1; + + return mat; + } + + public static Matrix4f sepia(float amount) { + Matrix4f mat = new Matrix4f(); + + mat.a00 = (float) (0.393 + 0.607 * (1 - amount)); + mat.a10 = (float) (0.769 - 0.769 * (1 - amount)); + mat.a20 = (float) (0.189 - 0.189 * (1 - amount)); + mat.a01 = (float) (0.349 - 0.349 * (1 - amount)); + mat.a11 = (float) (0.686 + 0.314 * (1 - amount)); + mat.a21 = (float) (0.168 - 0.168 * (1 - amount)); + mat.a02 = (float) (0.272 - 0.272 * (1 - amount)); + mat.a12 = (float) (0.534 - 0.534 * (1 - amount)); + mat.a22 = (float) (0.131 + 0.869 * (1 - amount)); + + mat.a33 = 1; + + return mat; + } + + // https://stackoverflow.com/a/8510751 + public static Matrix4f hueShift(float rot) { + Matrix4f mat = new Matrix4f(); + + mat.loadIdentity(); + + float cosA = MathHelper.cos(AngleHelper.rad(rot)); + float sinA = MathHelper.sin(AngleHelper.rad(rot)); + mat.a00 = (float) (cosA + (1.0 - cosA) / 3.0); + mat.a01 = (float) (1. / 3. * (1.0 - cosA) - MathHelper.sqrt(1. / 3.) * sinA); + mat.a02 = (float) (1. / 3. * (1.0 - cosA) + MathHelper.sqrt(1. / 3.) * sinA); + mat.a10 = (float) (1. / 3. * (1.0 - cosA) + MathHelper.sqrt(1. / 3.) * sinA); + mat.a11 = (float) (cosA + 1. / 3. * (1.0 - cosA)); + mat.a12 = (float) (1. / 3. * (1.0 - cosA) - MathHelper.sqrt(1. / 3.) * sinA); + mat.a20 = (float) (1. / 3. * (1.0 - cosA) - MathHelper.sqrt(1. / 3.) * sinA); + mat.a21 = (float) (1. / 3. * (1.0 - cosA) + MathHelper.sqrt(1. / 3.) * sinA); + mat.a22 = (float) (cosA + 1. / 3. * (1.0 - cosA)); + + return mat; + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index e0bbdaadb..080825807 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -26,7 +26,7 @@ public class EffectsHandler { } public static float getFarPlane() { - return Minecraft.getInstance().gameRenderer.getFarPlaneDistance(); + return Minecraft.getInstance().gameRenderer.getFarPlaneDistance() * 4; } public static final float[] vertices = { @@ -75,6 +75,10 @@ public class EffectsHandler { } public void render(Matrix4f view) { +// if (true) { +// return; +// } + GL20.glEnable(GL20.GL_DEPTH_TEST); GL20.glDepthRange(getNearPlane(), getFarPlane()); @@ -87,8 +91,9 @@ public class EffectsHandler { Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); GL30.glBindFramebuffer(FramebufferConstants.FRAME_BUFFER, framebuffer.framebufferObject); + GL30.glClear(GL30.GL_COLOR_BUFFER_BIT); - PostProcessingProgram program = Backend.getProgram(AllProgramSpecs.CHROMATIC); + SphereFilterProgram program = Backend.getProgram(AllProgramSpecs.CHROMATIC); program.bind(); program.bindColorTexture(mainBuffer.getColorAttachment()); @@ -104,15 +109,37 @@ public class EffectsHandler { Matrix4f inverseView = view.copy(); inverseView.invert(); -// Matrix4f inverseView = new Matrix4f(); -// inverseView.loadIdentity(); program.bindInverseView(inverseView); - Vector3d pos = new Vector3d(286, 73, -149); + Vector3d pos1 = new Vector3d(330, 0, 110); +// Vector3d pos1 = new Vector3d(852, 79, -204); +// Vector3d pos2 = new Vector3d(858, 95, -260); +// Vector3d pos3 = new Vector3d(906, 84, -207); Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView(); - Vector3d shaderPos = pos.subtract(cameraPos).scale(1 / getFarPlane()); - program.setSphere(shaderPos, 20f / getFarPlane(), 0.01f); + for (int i = 0; i < 16; i++) { + double angle = (Math.PI * AnimationTickHolder.getRenderTime() / 40) + i * Math.PI / 4; + + program.addSphere(new SphereFilterProgram.FilterSphere() + .setCenter(pos1.subtract(cameraPos).add(0, 0, i * 30)) + .setRadius(15) + .setFeather(0.5f) + .setFilter(ColorMatrices.hueShift((float) i / 16 * 360 + AnimationTickHolder.getRenderTime()))); + } + +// program.addSphere(new SphereFilterProgram.FilterSphere() +// .setCenter(pos2.subtract(cameraPos)) +// .setRadius(50) +// .setFeather(0.5f) +// .setFilter(ColorMatrices.sepia(1))); +// +// program.addSphere(new SphereFilterProgram.FilterSphere() +// .setCenter(pos3.subtract(cameraPos)) +// .setRadius(20) +// .setFeather(3f) +// .setFilter(ColorMatrices.saturate(4))); + + program.uploadFilters(); program.setFarPlane(getFarPlane()); program.setNearPlane(getNearPlane()); @@ -123,7 +150,9 @@ public class EffectsHandler { program.bindColorTexture(0); program.bindDepthTexture(0); + GL20.glActiveTexture(GL20.GL_TEXTURE0); + program.clear(); program.unbind(); GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebuffer.framebufferObject); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/PostProcessingProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/PostProcessingProgram.java deleted file mode 100644 index 19f239ad2..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/PostProcessingProgram.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.simibubi.create.foundation.render.backend.effects; - -import org.lwjgl.opengl.GL20; - -import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; - -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3d; - -public class PostProcessingProgram extends GlProgram { - - final int uDepth; - final int uColor; - - final int uInverseProjection; - final int uInverseView; - - final int uNearPlane; - final int uFarPlane; - final int uSphereCenter; - final int uSphereRadius; - final int uSphereFeather; - - - public PostProcessingProgram(ResourceLocation name, int handle) { - super(name, handle); - - uInverseProjection = getUniformLocation("uInverseProjection"); - uInverseView = getUniformLocation("uInverseView"); - uNearPlane = getUniformLocation("uNearPlane"); - uFarPlane = getUniformLocation("uFarPlane"); - uSphereCenter = getUniformLocation("uSphereCenter"); - uSphereRadius = getUniformLocation("uSphereRadius"); - uSphereFeather = getUniformLocation("uSphereFeather"); - - bind(); - uDepth = setSamplerBinding("uDepth", 8); - uColor = setSamplerBinding("uColor", 9); - unbind(); - } - - public void setNearPlane(float nearPlane) { - GL20.glUniform1f(uNearPlane, nearPlane); - } - - public void setFarPlane(float farPlane) { - GL20.glUniform1f(uFarPlane, farPlane); - } - - public void setSphere(Vector3d center, float radius, float feather) { - GL20.glUniform3f(uSphereCenter, (float) center.x, (float) center.y, (float) center.z); - - GL20.glUniform1f(uSphereRadius, radius); - GL20.glUniform1f(uSphereFeather, feather); - } - - public void bindInverseProjection(Matrix4f mat) { - uploadMatrixUniform(uInverseProjection, mat); - } - - public void bindInverseView(Matrix4f mat) { - uploadMatrixUniform(uInverseView, mat); - } - - public void bindDepthTexture(int textureObject) { - GL20.glActiveTexture(GL20.GL_TEXTURE8); - GL20.glBindTexture(GL20.GL_TEXTURE_2D, textureObject); - } - - public void bindColorTexture(int textureObject) { - GL20.glActiveTexture(GL20.GL_TEXTURE9); - GL20.glBindTexture(GL20.GL_TEXTURE_2D, textureObject); - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java new file mode 100644 index 000000000..ab25bb6bf --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java @@ -0,0 +1,177 @@ +package com.simibubi.create.foundation.render.backend.effects; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.util.ArrayList; + +import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL31; + +import com.simibubi.create.foundation.render.backend.RenderUtil; +import com.simibubi.create.foundation.render.backend.gl.GlBuffer; +import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; + +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3d; + +public class SphereFilterProgram extends GlProgram { + + protected static final int BLOCK_BINDING = 4; + + protected static final int SPHERE_FILTER_SIZE = 4 * 16 + 16 + 4 * 16 * 16; + + protected static final int MAX_FILTERS = 16; + + protected static final int BUFFER_SIZE = 4 + MAX_FILTERS * SPHERE_FILTER_SIZE; + + GlBuffer effectsUBO; + + protected final ArrayList filters = new ArrayList<>(16); + + protected final int uniformBlock; + + protected final int uDepth; + protected final int uColor; + + protected final int uInverseProjection; + protected final int uInverseView; + + protected final int uNearPlane; + protected final int uFarPlane; +// protected final int uSphereCenter; +// protected final int uSphereRadius; +// protected final int uSphereFeather; +// protected final int uColorFilter; + + public SphereFilterProgram(ResourceLocation name, int handle) { + super(name, handle); + + effectsUBO = new GlBuffer(GL31.GL_UNIFORM_BUFFER); + + uniformBlock = GL31.glGetUniformBlockIndex(handle, "Filters"); + + GL31.glUniformBlockBinding(handle, uniformBlock, BLOCK_BINDING); + + effectsUBO.bind(); + effectsUBO.alloc(BUFFER_SIZE, GL20.GL_STATIC_DRAW); + GL31.glBindBufferBase(effectsUBO.getBufferType(), BLOCK_BINDING, effectsUBO.handle()); + effectsUBO.unbind(); + + uInverseProjection = getUniformLocation("uInverseProjection"); + uInverseView = getUniformLocation("uInverseView"); + uNearPlane = getUniformLocation("uNearPlane"); + uFarPlane = getUniformLocation("uFarPlane"); +// +// uSphereCenter = getUniformLocation("uSphereCenter"); +// uSphereRadius = getUniformLocation("uSphereRadius"); +// uSphereFeather = getUniformLocation("uSphereFeather"); +// uColorFilter = getUniformLocation("uColorFilter"); + + bind(); + uDepth = setSamplerBinding("uDepth", 8); + uColor = setSamplerBinding("uColor", 9); + unbind(); + } + + public void setNearPlane(float nearPlane) { + GL20.glUniform1f(uNearPlane, nearPlane); + } + + public void setFarPlane(float farPlane) { + GL20.glUniform1f(uFarPlane, farPlane); + } + + public void clear() { + filters.clear(); + } + + public void addSphere(FilterSphere filterSphere) { + filters.add(filterSphere); + } + + public void uploadFilters() { + effectsUBO.bind(GL20.GL_ARRAY_BUFFER); + effectsUBO.map(GL20.GL_ARRAY_BUFFER, 0, BUFFER_SIZE, this::uploadUBO); + effectsUBO.unbind(GL20.GL_ARRAY_BUFFER); + } + +// public void setSphere(FilterSphere sphere) { +// GL20.glUniform3f(uSphereCenter, (float) sphere.center.x, (float) sphere.center.y, (float) sphere.center.z); +// +// GL20.glUniform1f(uSphereRadius, sphere.radius); +// GL20.glUniform1f(uSphereFeather, sphere.feather); +// +// uploadMatrixUniform(uColorFilter, sphere.filter); +// } + + public void bindInverseProjection(Matrix4f mat) { + uploadMatrixUniform(uInverseProjection, mat); + } + + public void bindInverseView(Matrix4f mat) { + uploadMatrixUniform(uInverseView, mat); + } + + public void bindDepthTexture(int textureObject) { + GL20.glActiveTexture(GL20.GL_TEXTURE8); + GL20.glBindTexture(GL20.GL_TEXTURE_2D, textureObject); + } + + public void bindColorTexture(int textureObject) { + GL20.glActiveTexture(GL20.GL_TEXTURE9); + GL20.glBindTexture(GL20.GL_TEXTURE_2D, textureObject); + } + + private void uploadUBO(ByteBuffer buf) { + buf.putInt(filters.size()); + buf.position(16); + FloatBuffer floatBuffer = buf.asFloatBuffer(); + + //floatBuffer.position(4); + filters.forEach(it -> it.write(floatBuffer)); + } + + public static class FilterSphere { + public Vector3d center; + public float radius; + public float feather; + + public Matrix4f filter; + + public FilterSphere setCenter(Vector3d center) { + this.center = center; + return this; + } + + public FilterSphere setRadius(float radius) { + this.radius = radius; + return this; + } + + public FilterSphere setFeather(float feather) { + this.feather = feather; + return this; + } + + public FilterSphere setFilter(Matrix4f filter) { + this.filter = filter; + return this; + } + + public void write(FloatBuffer buf) { + buf.put(new float[]{ + (float) center.x, + (float) center.y, + (float) center.z, + radius, + feather, + 0, + 0, + 0 + }); + + buf.put(RenderUtil.writeMatrix(filter)); + } + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java index 7cb688703..7680f1790 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java @@ -12,20 +12,28 @@ public class GlBuffer extends GlObject { protected final int bufferType; - public GlBuffer(int bufferType) { - setHandle(GL20.glGenBuffers()); - this.bufferType = bufferType; - } + public GlBuffer(int bufferType) { + setHandle(GL20.glGenBuffers()); + this.bufferType = bufferType; + } - public int getBufferType() { - return bufferType; + public int getBufferType() { + return bufferType; } public void bind() { - GL20.glBindBuffer(bufferType, handle()); + bind(bufferType); + } + + public void bind(int type) { + GL20.glBindBuffer(type, handle()); } public void unbind() { + unbind(bufferType); + } + + public void unbind(int bufferType) { GL20.glBindBuffer(bufferType, 0); } @@ -43,11 +51,15 @@ public class GlBuffer extends GlObject { Backend.compat.mapBuffer(bufferType, 0, length, upload); } - public void map(int offset, int length, Consumer upload) { - Backend.compat.mapBuffer(bufferType, offset, length, upload); - } + public void map(int offset, int length, Consumer upload) { + Backend.compat.mapBuffer(bufferType, offset, length, upload); + } - protected void deleteInternal(int handle) { - GL20.glDeleteBuffers(handle); - } + public void map(int type, int offset, int length, Consumer upload) { + Backend.compat.mapBuffer(type, offset, length, upload); + } + + protected void deleteInternal(int handle) { + GL20.glDeleteBuffers(handle); + } } diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag new file mode 100644 index 000000000..0d2b4659a --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -0,0 +1,67 @@ +#version 140 + +#flwinclude <"create:core/color.glsl"> + +in vec2 ScreenCoord; +in vec3 WorldDir; + +out vec4 Color; + +// constants +uniform sampler2D uDepth; +uniform sampler2D uColor; +uniform float uNearPlane = 0.15; +uniform float uFarPlane = 1.; + +struct SphereFilter { + vec4 sphere;// + float feather; + mat4 colorOp; +}; + +#define N 16 +layout (std140) uniform Filters { + int uCount; + SphereFilter uSpheres[N]; +}; + +float linearizeDepth(float d, float zNear, float zFar) { + float z_n = 2.0 * d - 1.0; + return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear)); +} + +vec4 filterColor(mat4 colorOp, vec4 frag) { + // preserve alpha while transforming color + vec4 i = vec4(frag.rgb, 1.); + i *= colorOp; + return vec4(i.rgb, frag.a); +} + +float getDepth() { + float depth = texture2D(uDepth, ScreenCoord).r; + + depth = linearizeDepth(depth, uNearPlane, uFarPlane); + //depth = ( - uNearPlane) / (uFarPlane - uNearPlane); + //depth = depth / uFarPlane; + + return depth; +} + +void main() { + float depth = getDepth(); + vec3 worldPos = WorldDir * depth; + + vec4 accum = texture2D(uColor, ScreenCoord); + + for (int i = 0; i < uCount; i++) { + SphereFilter s = uSpheres[i]; + + float distance = distance(s.sphere.xyz, worldPos); + float strength = 1 - smoothstep(s.sphere.w - s.feather, s.sphere.w + s.feather, distance); + + accum = mix(accum, filterColor(s.colorOp, accum), strength); + } + + Color = accum; + //Color = vec4(vec3(distance / uFarPlane), 1.); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.vert b/src/main/resources/assets/create/flywheel/shaders/area_effect.vert new file mode 100644 index 000000000..525191aa1 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.vert @@ -0,0 +1,22 @@ +#version 140 + +in vec4 aVertex;// + +out vec2 ScreenCoord; +out vec3 WorldDir; + +uniform mat4 uInverseProjection; +uniform mat4 uInverseView; + +void main() { + gl_Position = vec4(aVertex.xy, 0., 1.); + ScreenCoord = aVertex.zw; + + vec4 clip = vec4(aVertex.xy, 0., 1.); + + clip *= uInverseProjection; + + vec3 cameraDir = clip.xyz / clip.w; + WorldDir = (uInverseView * vec4(cameraDir, 1.)).xyz; + //worldDirection = (uInverseProjection * vec4(aVertex.xy, 0, 1.)).xyz; +} diff --git a/src/main/resources/assets/create/flywheel/shaders/chromatic.frag b/src/main/resources/assets/create/flywheel/shaders/chromatic.frag deleted file mode 100644 index bd70e8d22..000000000 --- a/src/main/resources/assets/create/flywheel/shaders/chromatic.frag +++ /dev/null @@ -1,62 +0,0 @@ -#version 120 - -varying vec4 Vertex; -varying vec3 CameraDir; - -//layout (std140) struct Sphere { -// vec4 positionRadius; -// vec4 color; -//} uSphere; - -uniform sampler2D uDepth; -uniform sampler2D uColor; -uniform mat4 uInverseProjection; -uniform mat4 uInverseView; - -uniform float uNearPlane = 0.15; -uniform float uFarPlane = 1; -uniform vec3 uSphereCenter = vec3(0, 0, 0); -uniform float uSphereRadius = 1; -uniform float uSphereFeather = 0.05; - -float linearizeDepth(float d, float zNear, float zFar) { - float z_n = 2.0 * d - 1.0; - return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear)); -} - -vec4 filterColor(vec4 frag) { - const vec3 lum = vec3(0.21, 0.71, 0.07); - float grey = dot(frag.rgb, lum.rgb); - return vec4(grey, grey, grey, frag.a); -} - -vec3 getWorldPos(float depth) { - vec3 cameraPos = CameraDir * depth; - - vec3 worldPos = (uInverseView * vec4(cameraPos, 1)).xyz; - - return worldPos; -} - -float getDepth() { - float depth = texture2D(uDepth, Vertex.zw).r; - - depth = linearizeDepth(depth, uNearPlane, uFarPlane); - //depth = ( - uNearPlane) / (uFarPlane - uNearPlane); - depth = depth / uFarPlane; - - return depth; -} - -void main() { - float depth = getDepth(); - vec3 worldPos = getWorldPos(depth); - - float distance = distance(uSphereCenter, worldPos); - float strength = smoothstep(uSphereRadius - uSphereFeather, uSphereRadius + uSphereFeather, distance); - - vec4 fragColor = texture2D(uColor, Vertex.zw); - - gl_FragColor = mix(fragColor, filterColor(fragColor), strength); - //gl_FragColor = vec4(worldPos, 1); -} diff --git a/src/main/resources/assets/create/flywheel/shaders/core/color.glsl b/src/main/resources/assets/create/flywheel/shaders/core/color.glsl new file mode 100644 index 000000000..f6f9d271b --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/core/color.glsl @@ -0,0 +1,22 @@ +// All components are in the range [0…1], including hue. +vec3 rgb2hsv(vec3 c) { + const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 1.0e-10; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); +} + +// All components are in the range [0…1], including hue. +vec3 hsv2rgb(vec3 hsv) { + const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(hsv.xxx + K.xyz) * 6.0 - K.www); + return hsv.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), hsv.y); +} + +vec3 hsv2rgbWrapped(vec3 hsv) { + hsv.x = fract(hsv.x); + return hsv2rgb(hsv); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/screen_quad.vert b/src/main/resources/assets/create/flywheel/shaders/screen_quad.vert deleted file mode 100644 index 248157475..000000000 --- a/src/main/resources/assets/create/flywheel/shaders/screen_quad.vert +++ /dev/null @@ -1,20 +0,0 @@ -#version 120 - -attribute vec4 aVertex;// - -varying vec4 Vertex; -varying vec3 CameraDir; - -uniform mat4 uInverseProjection; - -void main() { - gl_Position = vec4(aVertex.xy, 0.0f, 1.0f); - Vertex = aVertex; - - vec4 clip = vec4(aVertex.xy, 0, 1); - - clip *= uInverseProjection; - - CameraDir = clip.xyz / clip.w; - //worldDirection = (uInverseProjection * vec4(aVertex.xy, 0, 1.)).xyz; -} From f12d9452b45fc40402c6e707d18fb9725e83dbbe Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 15 Apr 2021 12:46:54 -0700 Subject: [PATCH 004/198] Shader debugging: scaling the world In the linearizeDepth function in area_effect.frag, I was multiplying by 2, but the scaling of the world was off. The number I found that works best is e - 0.99, and I have no idea why. --- .../backend/effects/EffectsHandler.java | 7 +++- .../backend/effects/SphereFilterProgram.java | 13 ++++++ .../create/flywheel/shaders/area_effect.frag | 40 ++++++++++++------- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index 080825807..996f05147 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -100,8 +100,8 @@ public class EffectsHandler { program.bindDepthTexture(mainBuffer.getDepthAttachment()); GameRenderer gameRenderer = Minecraft.getInstance().gameRenderer; - Matrix4f projection = gameRenderer.getBasicProjectionMatrix(gameRenderer.getActiveRenderInfo(), AnimationTickHolder.getPartialTicks(), true); - //Matrix4f projection = Backend.projectionMatrix.copy(); + //Matrix4f projection = gameRenderer.getBasicProjectionMatrix(gameRenderer.getActiveRenderInfo(), AnimationTickHolder.getPartialTicks(), true); + Matrix4f projection = Backend.projectionMatrix.copy(); //projection.a23 = projection.a32 = 0; projection.a33 = 1; projection.invert(); @@ -117,6 +117,9 @@ public class EffectsHandler { // Vector3d pos3 = new Vector3d(906, 84, -207); Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView(); + program.setTestParam((float) (Math.E - 0.99)); + program.setCameraPos(cameraPos.inverse()); + for (int i = 0; i < 16; i++) { double angle = (Math.PI * AnimationTickHolder.getRenderTime() / 40) + i * Math.PI / 4; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java index ab25bb6bf..afa618d0f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java @@ -39,6 +39,9 @@ public class SphereFilterProgram extends GlProgram { protected final int uNearPlane; protected final int uFarPlane; + + protected final int uCameraPos; + protected final int testParam; // protected final int uSphereCenter; // protected final int uSphereRadius; // protected final int uSphereFeather; @@ -62,6 +65,8 @@ public class SphereFilterProgram extends GlProgram { uInverseView = getUniformLocation("uInverseView"); uNearPlane = getUniformLocation("uNearPlane"); uFarPlane = getUniformLocation("uFarPlane"); + uCameraPos = getUniformLocation("uCameraPos"); + testParam = getUniformLocation("testParam"); // // uSphereCenter = getUniformLocation("uSphereCenter"); // uSphereRadius = getUniformLocation("uSphereRadius"); @@ -82,6 +87,14 @@ public class SphereFilterProgram extends GlProgram { GL20.glUniform1f(uFarPlane, farPlane); } + public void setTestParam(float farPlane) { + GL20.glUniform1f(testParam, farPlane); + } + + public void setCameraPos(Vector3d pos) { + GL20.glUniform3f(uCameraPos, (float) pos.x, (float) pos.y, (float) pos.z); + } + public void clear() { filters.clear(); } diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index 0d2b4659a..70a82542f 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -12,6 +12,12 @@ uniform sampler2D uDepth; uniform sampler2D uColor; uniform float uNearPlane = 0.15; uniform float uFarPlane = 1.; +uniform vec3 uCameraPos; + +uniform float testParam = 2.0; + +uniform mat4 uInverseProjection; +uniform mat4 uInverseView; struct SphereFilter { vec4 sphere;// @@ -26,8 +32,9 @@ layout (std140) uniform Filters { }; float linearizeDepth(float d, float zNear, float zFar) { - float z_n = 2.0 * d - 1.0; - return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear)); + float clipZ = 2.0 * d - 1.0; + float linearized = zNear * zFar / (zFar + zNear - clipZ * (zFar - zNear)); + return testParam * linearized; } vec4 filterColor(mat4 colorOp, vec4 frag) { @@ -41,7 +48,7 @@ float getDepth() { float depth = texture2D(uDepth, ScreenCoord).r; depth = linearizeDepth(depth, uNearPlane, uFarPlane); - //depth = ( - uNearPlane) / (uFarPlane - uNearPlane); + //depth = (depth - uNearPlane) / (uFarPlane - uNearPlane); //depth = depth / uFarPlane; return depth; @@ -49,19 +56,24 @@ float getDepth() { void main() { float depth = getDepth(); - vec3 worldPos = WorldDir * depth; + vec3 worldPos = WorldDir * depth - uCameraPos; - vec4 accum = texture2D(uColor, ScreenCoord); + vec4 diffuse = texture2D(uColor, ScreenCoord); + // + // for (int i = 0; i < uCount; i++) { + // SphereFilter s = uSpheres[i]; + // + // float distance = distance(s.sphere.xyz, worldPos); + // float strength = 1 - smoothstep(s.sphere.w - s.feather, s.sphere.w + s.feather, distance); + // + // accum = mix(accum, filterColor(s.colorOp, accum), strength); + // } + // + // Color = accum; - for (int i = 0; i < uCount; i++) { - SphereFilter s = uSpheres[i]; + vec3 fractionalCoords = fract(worldPos); - float distance = distance(s.sphere.xyz, worldPos); - float strength = 1 - smoothstep(s.sphere.w - s.feather, s.sphere.w + s.feather, distance); + vec3 isBonudary = step(15./16., fractionalCoords); - accum = mix(accum, filterColor(s.colorOp, accum), strength); - } - - Color = accum; - //Color = vec4(vec3(distance / uFarPlane), 1.); + Color = vec4(mix(diffuse.rgb, fractionalCoords, isBonudary), 1.); } From 45b14128370d0bf817eaaac7f128e88f14ed735f Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 15 Apr 2021 13:28:23 -0700 Subject: [PATCH 005/198] Code sanity --- .../backend/effects/EffectsHandler.java | 24 +--------- .../create/flywheel/shaders/area_effect.frag | 47 ++++++++++++------- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index 996f05147..57ad125bb 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -83,9 +83,6 @@ public class EffectsHandler { GL20.glDepthRange(getNearPlane(), getFarPlane()); -// float[] floats = new float[2]; -// GL20.glGetFloatv(GL20.GL_DEPTH_RANGE, floats); - prepFramebufferSize(); Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); @@ -112,36 +109,19 @@ public class EffectsHandler { program.bindInverseView(inverseView); Vector3d pos1 = new Vector3d(330, 0, 110); -// Vector3d pos1 = new Vector3d(852, 79, -204); -// Vector3d pos2 = new Vector3d(858, 95, -260); -// Vector3d pos3 = new Vector3d(906, 84, -207); Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView(); program.setTestParam((float) (Math.E - 0.99)); program.setCameraPos(cameraPos.inverse()); for (int i = 0; i < 16; i++) { - double angle = (Math.PI * AnimationTickHolder.getRenderTime() / 40) + i * Math.PI / 4; - program.addSphere(new SphereFilterProgram.FilterSphere() - .setCenter(pos1.subtract(cameraPos).add(0, 0, i * 30)) + .setCenter(pos1.subtract(cameraPos).add(0, 0, i * 10)) .setRadius(15) - .setFeather(0.5f) + .setFeather(0f) .setFilter(ColorMatrices.hueShift((float) i / 16 * 360 + AnimationTickHolder.getRenderTime()))); } -// program.addSphere(new SphereFilterProgram.FilterSphere() -// .setCenter(pos2.subtract(cameraPos)) -// .setRadius(50) -// .setFeather(0.5f) -// .setFilter(ColorMatrices.sepia(1))); -// -// program.addSphere(new SphereFilterProgram.FilterSphere() -// .setCenter(pos3.subtract(cameraPos)) -// .setRadius(20) -// .setFeather(3f) -// .setFilter(ColorMatrices.saturate(4))); - program.uploadFilters(); program.setFarPlane(getFarPlane()); diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index 70a82542f..7f0d6f5e2 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -1,5 +1,7 @@ #version 140 +#define LC 1.7282818// e - 0.99 + #flwinclude <"create:core/color.glsl"> in vec2 ScreenCoord; @@ -34,7 +36,7 @@ layout (std140) uniform Filters { float linearizeDepth(float d, float zNear, float zFar) { float clipZ = 2.0 * d - 1.0; float linearized = zNear * zFar / (zFar + zNear - clipZ * (zFar - zNear)); - return testParam * linearized; + return LC * linearized; } vec4 filterColor(mat4 colorOp, vec4 frag) { @@ -54,26 +56,35 @@ float getDepth() { return depth; } -void main() { - float depth = getDepth(); - vec3 worldPos = WorldDir * depth - uCameraPos; +vec4 applyFilters(vec3 worldPos, vec4 diffuse) { + vec4 accum = diffuse; - vec4 diffuse = texture2D(uColor, ScreenCoord); - // - // for (int i = 0; i < uCount; i++) { - // SphereFilter s = uSpheres[i]; - // - // float distance = distance(s.sphere.xyz, worldPos); - // float strength = 1 - smoothstep(s.sphere.w - s.feather, s.sphere.w + s.feather, distance); - // - // accum = mix(accum, filterColor(s.colorOp, accum), strength); - // } - // - // Color = accum; + for (int i = 0; i < uCount; i++) { + SphereFilter s = uSpheres[i]; - vec3 fractionalCoords = fract(worldPos); + float distance = distance(s.sphere.xyz, worldPos); + float strength = 1 - smoothstep(s.sphere.w - s.feather, s.sphere.w + s.feather, distance); + + accum = mix(accum, filterColor(s.colorOp, diffuse), strength); + } + + return accum; +} + +vec4 debugGrid(vec3 worldPos, vec4 diffuse) { + vec3 fractionalCoords = fract(worldPos - uCameraPos); vec3 isBonudary = step(15./16., fractionalCoords); - Color = vec4(mix(diffuse.rgb, fractionalCoords, isBonudary), 1.); + return vec4(mix(diffuse.rgb, fractionalCoords, isBonudary), 1.); +} + +void main() { + float depth = getDepth(); + vec3 worldPos = WorldDir * depth; + + vec4 diffuse = texture2D(uColor, ScreenCoord); + + //Color = applyFilters(worldPos, diffuse); + Color = debugGrid(worldPos, diffuse); } From fafd7c84bef4eca34c4742563e7a1e87f3c60568 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 15 Apr 2021 15:39:34 -0700 Subject: [PATCH 006/198] Everything works as intended --- .../backend/effects/EffectsHandler.java | 5 +-- .../backend/effects/SphereFilterProgram.java | 43 +++++-------------- .../create/flywheel/shaders/area_effect.frag | 20 ++------- .../create/flywheel/shaders/area_effect.vert | 6 ++- 4 files changed, 20 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index 57ad125bb..79d71205f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -97,9 +97,7 @@ public class EffectsHandler { program.bindDepthTexture(mainBuffer.getDepthAttachment()); GameRenderer gameRenderer = Minecraft.getInstance().gameRenderer; - //Matrix4f projection = gameRenderer.getBasicProjectionMatrix(gameRenderer.getActiveRenderInfo(), AnimationTickHolder.getPartialTicks(), true); - Matrix4f projection = Backend.projectionMatrix.copy(); - //projection.a23 = projection.a32 = 0; + Matrix4f projection = gameRenderer.getBasicProjectionMatrix(gameRenderer.getActiveRenderInfo(), AnimationTickHolder.getPartialTicks(), true); projection.a33 = 1; projection.invert(); program.bindInverseProjection(projection); @@ -111,7 +109,6 @@ public class EffectsHandler { Vector3d pos1 = new Vector3d(330, 0, 110); Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView(); - program.setTestParam((float) (Math.E - 0.99)); program.setCameraPos(cameraPos.inverse()); for (int i = 0; i < 16; i++) { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java index afa618d0f..dfa0c397d 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java @@ -17,15 +17,17 @@ import net.minecraft.util.math.vector.Vector3d; public class SphereFilterProgram extends GlProgram { - protected static final int BLOCK_BINDING = 4; + protected static final int UBO_BINDING = 4; - protected static final int SPHERE_FILTER_SIZE = 4 * 16 + 16 + 4 * 16 * 16; + protected static final int SPHERE_FILTER_SIZE = 24 * 4; // + protected static final int MAX_FILTERS = 16; // arbitrary - protected static final int MAX_FILTERS = 16; + protected static final int EXTRA_INFO = 16; // array length: int + padding + protected static final int ALL_FILTERS_SIZE = MAX_FILTERS * SPHERE_FILTER_SIZE; - protected static final int BUFFER_SIZE = 4 + MAX_FILTERS * SPHERE_FILTER_SIZE; + protected static final int BUFFER_SIZE = EXTRA_INFO + ALL_FILTERS_SIZE; - GlBuffer effectsUBO; + public final GlBuffer effectsUBO; protected final ArrayList filters = new ArrayList<>(16); @@ -41,11 +43,6 @@ public class SphereFilterProgram extends GlProgram { protected final int uFarPlane; protected final int uCameraPos; - protected final int testParam; -// protected final int uSphereCenter; -// protected final int uSphereRadius; -// protected final int uSphereFeather; -// protected final int uColorFilter; public SphereFilterProgram(ResourceLocation name, int handle) { super(name, handle); @@ -54,11 +51,11 @@ public class SphereFilterProgram extends GlProgram { uniformBlock = GL31.glGetUniformBlockIndex(handle, "Filters"); - GL31.glUniformBlockBinding(handle, uniformBlock, BLOCK_BINDING); + GL31.glUniformBlockBinding(handle, uniformBlock, UBO_BINDING); effectsUBO.bind(); effectsUBO.alloc(BUFFER_SIZE, GL20.GL_STATIC_DRAW); - GL31.glBindBufferBase(effectsUBO.getBufferType(), BLOCK_BINDING, effectsUBO.handle()); + GL31.glBindBufferBase(effectsUBO.getBufferType(), UBO_BINDING, effectsUBO.handle()); effectsUBO.unbind(); uInverseProjection = getUniformLocation("uInverseProjection"); @@ -66,12 +63,6 @@ public class SphereFilterProgram extends GlProgram { uNearPlane = getUniformLocation("uNearPlane"); uFarPlane = getUniformLocation("uFarPlane"); uCameraPos = getUniformLocation("uCameraPos"); - testParam = getUniformLocation("testParam"); -// -// uSphereCenter = getUniformLocation("uSphereCenter"); -// uSphereRadius = getUniformLocation("uSphereRadius"); -// uSphereFeather = getUniformLocation("uSphereFeather"); -// uColorFilter = getUniformLocation("uColorFilter"); bind(); uDepth = setSamplerBinding("uDepth", 8); @@ -87,10 +78,6 @@ public class SphereFilterProgram extends GlProgram { GL20.glUniform1f(uFarPlane, farPlane); } - public void setTestParam(float farPlane) { - GL20.glUniform1f(testParam, farPlane); - } - public void setCameraPos(Vector3d pos) { GL20.glUniform3f(uCameraPos, (float) pos.x, (float) pos.y, (float) pos.z); } @@ -109,15 +96,6 @@ public class SphereFilterProgram extends GlProgram { effectsUBO.unbind(GL20.GL_ARRAY_BUFFER); } -// public void setSphere(FilterSphere sphere) { -// GL20.glUniform3f(uSphereCenter, (float) sphere.center.x, (float) sphere.center.y, (float) sphere.center.z); -// -// GL20.glUniform1f(uSphereRadius, sphere.radius); -// GL20.glUniform1f(uSphereFeather, sphere.feather); -// -// uploadMatrixUniform(uColorFilter, sphere.filter); -// } - public void bindInverseProjection(Matrix4f mat) { uploadMatrixUniform(uInverseProjection, mat); } @@ -141,7 +119,6 @@ public class SphereFilterProgram extends GlProgram { buf.position(16); FloatBuffer floatBuffer = buf.asFloatBuffer(); - //floatBuffer.position(4); filters.forEach(it -> it.write(floatBuffer)); } @@ -179,7 +156,7 @@ public class SphereFilterProgram extends GlProgram { (float) center.z, radius, feather, - 0, + 0, // padding, we could add more parameters here 0, 0 }); diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index 7f0d6f5e2..1e06411d8 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -1,7 +1,5 @@ #version 140 -#define LC 1.7282818// e - 0.99 - #flwinclude <"create:core/color.glsl"> in vec2 ScreenCoord; @@ -16,11 +14,6 @@ uniform float uNearPlane = 0.15; uniform float uFarPlane = 1.; uniform vec3 uCameraPos; -uniform float testParam = 2.0; - -uniform mat4 uInverseProjection; -uniform mat4 uInverseView; - struct SphereFilter { vec4 sphere;// float feather; @@ -35,8 +28,7 @@ layout (std140) uniform Filters { float linearizeDepth(float d, float zNear, float zFar) { float clipZ = 2.0 * d - 1.0; - float linearized = zNear * zFar / (zFar + zNear - clipZ * (zFar - zNear)); - return LC * linearized; + return zNear * zFar / (zFar + zNear - clipZ * (zFar - zNear)); } vec4 filterColor(mat4 colorOp, vec4 frag) { @@ -49,11 +41,7 @@ vec4 filterColor(mat4 colorOp, vec4 frag) { float getDepth() { float depth = texture2D(uDepth, ScreenCoord).r; - depth = linearizeDepth(depth, uNearPlane, uFarPlane); - //depth = (depth - uNearPlane) / (uFarPlane - uNearPlane); - //depth = depth / uFarPlane; - - return depth; + return linearizeDepth(depth, uNearPlane, uFarPlane); } vec4 applyFilters(vec3 worldPos, vec4 diffuse) { @@ -85,6 +73,6 @@ void main() { vec4 diffuse = texture2D(uColor, ScreenCoord); - //Color = applyFilters(worldPos, diffuse); - Color = debugGrid(worldPos, diffuse); + Color = applyFilters(worldPos, diffuse); + //Color = debugGrid(worldPos, diffuse); } diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.vert b/src/main/resources/assets/create/flywheel/shaders/area_effect.vert index 525191aa1..6c1d35d5f 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.vert +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.vert @@ -1,5 +1,9 @@ #version 140 +// scaling constants +#define SXY 1.7282818// e - 0.99, this works too well +#define SZ 1.905// who knows, but it works + in vec4 aVertex;// out vec2 ScreenCoord; @@ -17,6 +21,6 @@ void main() { clip *= uInverseProjection; vec3 cameraDir = clip.xyz / clip.w; + cameraDir = cameraDir * vec3(SXY, SXY, SZ); WorldDir = (uInverseView * vec4(cameraDir, 1.)).xyz; - //worldDirection = (uInverseProjection * vec4(aVertex.xy, 0, 1.)).xyz; } From 83dc241cd215a4fed8b7bcf0c1d63823eef26cdc Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sat, 17 Apr 2021 13:04:42 -0700 Subject: [PATCH 007/198] Basic spherical effect --- .../render/backend/effects/ColorMatrices.java | 12 ++- .../backend/effects/EffectsHandler.java | 28 +++++-- .../backend/effects/SphereFilterProgram.java | 20 ++++- .../create/flywheel/shaders/area_effect.frag | 74 +++++++++++++++---- 4 files changed, 108 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java index ab32b6b97..db3097b21 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java @@ -59,7 +59,7 @@ public class ColorMatrices { } // https://stackoverflow.com/a/8510751 - public static Matrix4f hueShift(float rot) { + public static Matrix4f hueShiftRGB(float rot) { Matrix4f mat = new Matrix4f(); mat.loadIdentity(); @@ -78,4 +78,14 @@ public class ColorMatrices { return mat; } + + public static Matrix4f hueShiftHSV(float rot) { + Matrix4f mat = new Matrix4f(); + + mat.loadIdentity(); + + //mat.a03 = 0.5f; + + return mat; + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index 79d71205f..d3f7f4e06 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -106,18 +106,30 @@ public class EffectsHandler { inverseView.invert(); program.bindInverseView(inverseView); - Vector3d pos1 = new Vector3d(330, 0, 110); + Vector3d pos1 = new Vector3d(852, 79, -204); Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView(); program.setCameraPos(cameraPos.inverse()); - for (int i = 0; i < 16; i++) { - program.addSphere(new SphereFilterProgram.FilterSphere() - .setCenter(pos1.subtract(cameraPos).add(0, 0, i * 10)) - .setRadius(15) - .setFeather(0f) - .setFilter(ColorMatrices.hueShift((float) i / 16 * 360 + AnimationTickHolder.getRenderTime()))); - } +// int n = 20; +// double rad = 15; +// for (int i = 0; i < n; i++) { +// double angle = ((double) i) / n * Math.PI * 2; +// program.addSphere(new SphereFilterProgram.FilterSphere() +// .setCenter(pos1.subtract(cameraPos).add(Math.sin(angle) * rad, 0, Math.cos(angle) * rad)) +// .setRadius(10) +// .setFeather(0f) +// .setFilter(ColorMatrices.hueShiftRGB((float) i / n * 360 + i / 2f))); +// } + + Matrix4f filter = ColorMatrices.sepia(1f); + + program.addSphere(new SphereFilterProgram.FilterSphere() + .setCenter(pos1.subtract(cameraPos)) + .setRadius(40) + .setFeather(20f) + .setHsv(false) + .setFilter(filter)); program.uploadFilters(); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java index dfa0c397d..5492c0b42 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java @@ -20,7 +20,7 @@ public class SphereFilterProgram extends GlProgram { protected static final int UBO_BINDING = 4; protected static final int SPHERE_FILTER_SIZE = 24 * 4; // - protected static final int MAX_FILTERS = 16; // arbitrary + protected static final int MAX_FILTERS = 256; // arbitrary protected static final int EXTRA_INFO = 16; // array length: int + padding protected static final int ALL_FILTERS_SIZE = MAX_FILTERS * SPHERE_FILTER_SIZE; @@ -126,6 +126,8 @@ public class SphereFilterProgram extends GlProgram { public Vector3d center; public float radius; public float feather; + public float strength = 1; + public boolean hsv; public Matrix4f filter; @@ -144,6 +146,16 @@ public class SphereFilterProgram extends GlProgram { return this; } + public FilterSphere setStrength(float strength) { + this.strength = strength; + return this; + } + + public FilterSphere setHsv(boolean hsv) { + this.hsv = hsv; + return this; + } + public FilterSphere setFilter(Matrix4f filter) { this.filter = filter; return this; @@ -156,9 +168,9 @@ public class SphereFilterProgram extends GlProgram { (float) center.z, radius, feather, - 0, // padding, we could add more parameters here - 0, - 0 + strength, + hsv ? 1f : 0f, + 0 // padding, we could add more parameters here }); buf.put(RenderUtil.writeMatrix(filter)); diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index 1e06411d8..005fe91f8 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -16,11 +16,11 @@ uniform vec3 uCameraPos; struct SphereFilter { vec4 sphere;// - float feather; + vec3 data;// mat4 colorOp; }; -#define N 16 +#define N 256 layout (std140) uniform Filters { int uCount; SphereFilter uSpheres[N]; @@ -31,11 +31,11 @@ float linearizeDepth(float d, float zNear, float zFar) { return zNear * zFar / (zFar + zNear - clipZ * (zFar - zNear)); } -vec4 filterColor(mat4 colorOp, vec4 frag) { +vec3 filterColor(mat4 colorOp, vec3 color) { // preserve alpha while transforming color - vec4 i = vec4(frag.rgb, 1.); + vec4 i = vec4(color, 1.); i *= colorOp; - return vec4(i.rgb, frag.a); + return i.rgb; } float getDepth() { @@ -44,16 +44,65 @@ float getDepth() { return linearizeDepth(depth, uNearPlane, uFarPlane); } -vec4 applyFilters(vec3 worldPos, vec4 diffuse) { - vec4 accum = diffuse; +float overlayFilterAmount(in vec3 worldPos, in vec4 sphere, in float feather) { + float distance = distance(sphere.xyz, worldPos); + return 1 - smoothstep(sphere.w, sphere.w + feather, distance); +} + +float sphereFilterAmount(in vec3 worldDir, in float depth, in vec4 sphere, in float feather) { + float feathering = 1 - smoothstep(sphere.w, sphere.w + feather, length(sphere.xyz)); + feathering += overlayFilterAmount(worldDir * depth, sphere, feather); + vec3 oc = -sphere.xyz; + + float rayLengthSqr = dot(worldDir, worldDir); + float b = 2.0 * dot(-sphere.xyz, worldDir); + float sphereDistSqr = dot(sphere.xyz, sphere.xyz); + float b2 = b*b; + float d = 4. * rayLengthSqr; + float e = 1. / (2.0*rayLengthSqr); + + float radius = sphere.w; + float c = sphereDistSqr - radius*radius; + float discriminant = b2 - d * c; + float hitDepth = (-b - sqrt(discriminant)) * e; + + + if (discriminant > 0 && hitDepth > 0 && hitDepth < depth) { + // float c = sphereDistSqr - sphere.w*sphere.w; + // float discriminant = b2 - d * c; + // float hitDepth = (-b - sqrt(discriminant)) * e; + + vec3 hitPos = worldDir * hitDepth; + + vec3 normal = normalize(hitPos - sphere.xyz); + + return feathering - dot(normal, normalize(worldDir)) * 1.3 - 0.1; + } else { + return feathering; + } +} + +vec3 applyFilters(in vec3 worldDir, in float depth, in vec3 diffuse) { + vec3 worldPos = worldDir * depth; + + vec3 accum = diffuse; + vec3 diffuseHSV = rgb2hsv(accum); for (int i = 0; i < uCount; i++) { SphereFilter s = uSpheres[i]; - float distance = distance(s.sphere.xyz, worldPos); - float strength = 1 - smoothstep(s.sphere.w - s.feather, s.sphere.w + s.feather, distance); + //float strength = overlayFilterAmount(worldPos, s.sphere, s.data.x); + float strength = sphereFilterAmount(worldDir, depth, s.sphere, s.data.x); - accum = mix(accum, filterColor(s.colorOp, diffuse), strength); + //accum = vec3(strength, strength, strength); + + vec3 toFilter = mix(diffuse, diffuseHSV, s.data.z); + + vec3 filtered = filterColor(s.colorOp, diffuse); + + filtered = mix(filtered, hsv2rgbWrapped(filtered), s.data.z); + + accum = mix(accum, filtered, clamp(strength * s.data.y, 0., 1.)); } return accum; @@ -69,10 +118,9 @@ vec4 debugGrid(vec3 worldPos, vec4 diffuse) { void main() { float depth = getDepth(); - vec3 worldPos = WorldDir * depth; vec4 diffuse = texture2D(uColor, ScreenCoord); - Color = applyFilters(worldPos, diffuse); - //Color = debugGrid(worldPos, diffuse); + Color = vec4(applyFilters(WorldDir, depth, diffuse.rgb), diffuse.a); + //Color = debugGrid(WorldDir * depth, Color); } From 128a2c2e06844ffff52d388d2172e9ea8fb94cab Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sat, 17 Apr 2021 18:54:57 -0700 Subject: [PATCH 008/198] Remove compat layer wrapper functions --- .../backend/effects/SphereFilterProgram.java | 8 +- .../render/backend/gl/GlBuffer.java | 6 +- .../render/backend/gl/GlVertexArray.java | 16 +-- .../render/backend/gl/versioned/GlCompat.java | 121 +++++++++--------- .../{ => instancing}/DrawInstanced.java | 34 ++--- .../{ => instancing}/InstancedArrays.java | 34 ++--- .../{ => instancing}/VertexArrayObject.java | 34 ++--- .../backend/instancing/InstancedModel.java | 6 +- 8 files changed, 132 insertions(+), 127 deletions(-) rename src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/{ => instancing}/DrawInstanced.java (71%) rename src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/{ => instancing}/InstancedArrays.java (62%) rename src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/{ => instancing}/VertexArrayObject.java (78%) diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java index 5492c0b42..8b885b5b6 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java @@ -126,6 +126,7 @@ public class SphereFilterProgram extends GlProgram { public Vector3d center; public float radius; public float feather; + public float fade; public float strength = 1; public boolean hsv; @@ -146,6 +147,11 @@ public class SphereFilterProgram extends GlProgram { return this; } + public FilterSphere setFade(float fade) { + this.fade = fade; + return this; + } + public FilterSphere setStrength(float strength) { this.strength = strength; return this; @@ -168,9 +174,9 @@ public class SphereFilterProgram extends GlProgram { (float) center.z, radius, feather, + fade, strength, hsv ? 1f : 0f, - 0 // padding, we could add more parameters here }); buf.put(RenderUtil.writeMatrix(filter)); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java index 7680f1790..af5f0db3f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java @@ -48,15 +48,15 @@ public class GlBuffer extends GlObject { } public void map(int length, Consumer upload) { - Backend.compat.mapBuffer(bufferType, 0, length, upload); + Backend.compat.mapBuffer.mapBuffer(bufferType, 0, length, upload); } public void map(int offset, int length, Consumer upload) { - Backend.compat.mapBuffer(bufferType, offset, length, upload); + Backend.compat.mapBuffer.mapBuffer(bufferType, offset, length, upload); } public void map(int type, int offset, int length, Consumer upload) { - Backend.compat.mapBuffer(type, offset, length, upload); + Backend.compat.mapBuffer.mapBuffer(type, offset, length, upload); } protected void deleteInternal(int handle) { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlVertexArray.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlVertexArray.java index e4854990e..7cb3fb0de 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlVertexArray.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlVertexArray.java @@ -6,16 +6,16 @@ import com.simibubi.create.foundation.render.backend.Backend; public class GlVertexArray extends GlObject { public GlVertexArray() { - setHandle(Backend.compat.genVertexArrays()); - } + setHandle(Backend.compat.vao.genVertexArrays()); + } public void bind() { - Backend.compat.bindVertexArray(handle()); - } + Backend.compat.vao.bindVertexArray(handle()); + } public void unbind() { - Backend.compat.bindVertexArray(0); - } + Backend.compat.vao.bindVertexArray(0); + } public void with(Consumer action) { bind(); @@ -24,6 +24,6 @@ public class GlVertexArray extends GlObject { } protected void deleteInternal(int handle) { - Backend.compat.deleteVertexArrays(handle); - } + Backend.compat.vao.deleteVertexArrays(handle); + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlCompat.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlCompat.java index 1c152fce3..13e3a2418 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlCompat.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlCompat.java @@ -2,7 +2,6 @@ package com.simibubi.create.foundation.render.backend.gl.versioned; import java.nio.ByteBuffer; import java.util.Arrays; -import java.util.function.Consumer; import org.lwjgl.PointerBuffer; import org.lwjgl.opengl.GL20C; @@ -10,89 +9,83 @@ import org.lwjgl.opengl.GLCapabilities; import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryUtil; +import com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer.Blit; +import com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer.Framebuffer; +import com.simibubi.create.foundation.render.backend.gl.versioned.instancing.DrawInstanced; +import com.simibubi.create.foundation.render.backend.gl.versioned.instancing.InstancedArrays; +import com.simibubi.create.foundation.render.backend.gl.versioned.instancing.VertexArrayObject; + /** * An instance of this class stores information * about what OpenGL features are available. - * + *

* Each field stores an enum variant that provides access to the * most appropriate version of a feature for the current system. */ public class GlCompat { - public final MapBuffer mapBuffer; + public final MapBuffer mapBuffer; - public final VertexArrayObject vertexArrayObject; - public final InstancedArrays instancedArrays; - public final DrawInstanced drawInstanced; + public final VertexArrayObject vao; + public final InstancedArrays instancedArrays; + public final DrawInstanced drawInstanced; + public final Blit blit; + public final Framebuffer fbo; - public final RGPixelFormat pixelFormat; + public final RGPixelFormat pixelFormat; - public GlCompat(GLCapabilities caps) { - mapBuffer = getLatest(MapBuffer.class, caps); + public GlCompat(GLCapabilities caps) { + mapBuffer = getLatest(MapBuffer.class, caps); - vertexArrayObject = getLatest(VertexArrayObject.class, caps); - instancedArrays = getLatest(InstancedArrays.class, caps); - drawInstanced = getLatest(DrawInstanced.class, caps); + vao = getLatest(VertexArrayObject.class, caps); + instancedArrays = getLatest(InstancedArrays.class, caps); + drawInstanced = getLatest(DrawInstanced.class, caps); + blit = getLatest(Blit.class, caps); + fbo = getLatest(Framebuffer.class, caps); - pixelFormat = getLatest(RGPixelFormat.class, caps); - } + pixelFormat = getLatest(RGPixelFormat.class, caps); + } - public void mapBuffer(int target, int offset, int length, Consumer upload) { - mapBuffer.mapBuffer(target, offset, length, upload); - } + public boolean vertexArrayObjectsSupported() { + return vao != VertexArrayObject.UNSUPPORTED; + } - public void vertexAttribDivisor(int index, int divisor) { - instancedArrays.vertexAttribDivisor(index, divisor); - } + public boolean instancedArraysSupported() { + return instancedArrays != InstancedArrays.UNSUPPORTED; + } - public void drawArraysInstanced(int mode, int first, int count, int primcount) { - drawInstanced.drawArraysInstanced(mode, first, count, primcount); - } + public boolean drawInstancedSupported() { + return drawInstanced != DrawInstanced.UNSUPPORTED; + } - public int genVertexArrays() { - return vertexArrayObject.genVertexArrays(); - } + public boolean fbosSupported() { + return fbo != Framebuffer.UNSUPPORTED; + } - public void deleteVertexArrays(int array) { - vertexArrayObject.deleteVertexArrays(array); - } + public boolean blitSupported() { + return blit != Blit.UNSUPPORTED; + } - public void bindVertexArray(int array) { - vertexArrayObject.bindVertexArray(array); - } + /** + * Get the most compatible version of a specific OpenGL feature by iterating over enum constants in order. + * + * @param clazz The class of the versioning enum. + * @param caps The current system's supported features. + * @param The type of the versioning enum. + * @return The first defined enum variant to return true. + */ + public static & GlVersioned> V getLatest(Class clazz, GLCapabilities caps) { + V[] constants = clazz.getEnumConstants(); + V last = constants[constants.length - 1]; + if (!last.supported(caps)) { + throw new IllegalStateException(""); + } - public boolean vertexArrayObjectsSupported() { - return vertexArrayObject != VertexArrayObject.UNSUPPORTED; - } + return Arrays.stream(constants).filter(it -> it.supported(caps)).findFirst().get(); + } - public boolean instancedArraysSupported() { - return instancedArrays != InstancedArrays.UNSUPPORTED; - } - - public boolean drawInstancedSupported() { - return drawInstanced != DrawInstanced.UNSUPPORTED; - } - - /** - * Get the most compatible version of a specific OpenGL feature by iterating over enum constants in order. - * - * @param clazz The class of the versioning enum. - * @param caps The current system's supported features. - * @param The type of the versioning enum. - * @return The first defined enum variant to return true. - */ - public static & GlVersioned> V getLatest(Class clazz, GLCapabilities caps) { - V[] constants = clazz.getEnumConstants(); - V last = constants[constants.length - 1]; - if (!last.supported(caps)) { - throw new IllegalStateException(""); - } - - return Arrays.stream(constants).filter(it -> it.supported(caps)).findFirst().get(); - } - - /** - * Copied from: - *
https://github.com/grondag/canvas/commit/820bf754092ccaf8d0c169620c2ff575722d7d96 + /** + * Copied from: + *
https://github.com/grondag/canvas/commit/820bf754092ccaf8d0c169620c2ff575722d7d96 * *

Identical in function to {@link GL20C#glShaderSource(int, CharSequence)} but * passes a null pointer for string length to force the driver to rely on the null diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/DrawInstanced.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/DrawInstanced.java similarity index 71% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/DrawInstanced.java rename to src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/DrawInstanced.java index d8cca0eb5..9d9070e15 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/DrawInstanced.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/DrawInstanced.java @@ -1,26 +1,28 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned; +package com.simibubi.create.foundation.render.backend.gl.versioned.instancing; import org.lwjgl.opengl.ARBDrawInstanced; import org.lwjgl.opengl.EXTDrawInstanced; import org.lwjgl.opengl.GL31; import org.lwjgl.opengl.GLCapabilities; -public enum DrawInstanced implements GlVersioned { - GL31_DRAW_INSTANCED { - @Override - public boolean supported(GLCapabilities caps) { - return caps.OpenGL31; - } +import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; - @Override - public void drawArraysInstanced(int mode, int first, int count, int primcount) { - GL31.glDrawArraysInstanced(mode, first, count, primcount); - } - }, - ARB_DRAW_INSTANCED { - @Override - public boolean supported(GLCapabilities caps) { - return caps.GL_ARB_draw_instanced; +public enum DrawInstanced implements GlVersioned { + GL31_DRAW_INSTANCED { + @Override + public boolean supported(GLCapabilities caps) { + return caps.OpenGL31; + } + + @Override + public void drawArraysInstanced(int mode, int first, int count, int primcount) { + GL31.glDrawArraysInstanced(mode, first, count, primcount); + } + }, + ARB_DRAW_INSTANCED { + @Override + public boolean supported(GLCapabilities caps) { + return caps.GL_ARB_draw_instanced; } @Override diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/InstancedArrays.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/InstancedArrays.java similarity index 62% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/InstancedArrays.java rename to src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/InstancedArrays.java index ee00f760f..be45f4896 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/InstancedArrays.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/InstancedArrays.java @@ -1,25 +1,27 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned; +package com.simibubi.create.foundation.render.backend.gl.versioned.instancing; import org.lwjgl.opengl.ARBInstancedArrays; import org.lwjgl.opengl.GL33; import org.lwjgl.opengl.GLCapabilities; -public enum InstancedArrays implements GlVersioned { - GL33_INSTANCED_ARRAYS { - @Override - public boolean supported(GLCapabilities caps) { - return caps.OpenGL33; - } +import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; - @Override - public void vertexAttribDivisor(int index, int divisor) { - GL33.glVertexAttribDivisor(index, divisor); - } - }, - ARB_INSTANCED_ARRAYS { - @Override - public boolean supported(GLCapabilities caps) { - return caps.GL_ARB_instanced_arrays; +public enum InstancedArrays implements GlVersioned { + GL33_INSTANCED_ARRAYS { + @Override + public boolean supported(GLCapabilities caps) { + return caps.OpenGL33; + } + + @Override + public void vertexAttribDivisor(int index, int divisor) { + GL33.glVertexAttribDivisor(index, divisor); + } + }, + ARB_INSTANCED_ARRAYS { + @Override + public boolean supported(GLCapabilities caps) { + return caps.GL_ARB_instanced_arrays; } @Override diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/VertexArrayObject.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/VertexArrayObject.java similarity index 78% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/VertexArrayObject.java rename to src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/VertexArrayObject.java index 356970877..28b8e013a 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/VertexArrayObject.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/VertexArrayObject.java @@ -1,28 +1,30 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned; +package com.simibubi.create.foundation.render.backend.gl.versioned.instancing; import org.lwjgl.opengl.ARBVertexArrayObject; import org.lwjgl.opengl.GL30; import org.lwjgl.opengl.GLCapabilities; +import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; + public enum VertexArrayObject implements GlVersioned { - GL30_VAO { - @Override - public boolean supported(GLCapabilities caps) { - return caps.OpenGL30; - } + GL30_VAO { + @Override + public boolean supported(GLCapabilities caps) { + return caps.OpenGL30; + } - @Override - public int genVertexArrays() { - return GL30.glGenVertexArrays(); - } + @Override + public int genVertexArrays() { + return GL30.glGenVertexArrays(); + } - @Override - public void bindVertexArray(int array) { - GL30.glBindVertexArray(array); - } + @Override + public void bindVertexArray(int array) { + GL30.glBindVertexArray(array); + } - @Override - public void deleteVertexArrays(int array) { + @Override + public void deleteVertexArrays(int array) { GL30.glDeleteVertexArrays(array); } }, diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java index 10f182d46..b6c16f21b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java @@ -83,7 +83,7 @@ public abstract class InstancedModel extends BufferedMod renderSetup(); if (glInstanceCount > 0) - Backend.compat.drawArraysInstanced(GL11.GL_QUADS, 0, vertexCount, glInstanceCount); + Backend.compat.drawInstanced.drawArraysInstanced(GL11.GL_QUADS, 0, vertexCount, glInstanceCount); }); } @@ -118,8 +118,8 @@ public abstract class InstancedModel extends BufferedMod getInstanceFormat().vertexAttribPointers(staticAttributes); for (int i = 0; i < getInstanceFormat().getShaderAttributeCount(); i++) { - Backend.compat.vertexAttribDivisor(i + staticAttributes, 1); - } + Backend.compat.instancedArrays.vertexAttribDivisor(i + staticAttributes, 1); + } } private void clearBufferTail() { From a6248daf7eb271315db5a1aaeb8f44f91716cfc3 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sat, 17 Apr 2021 18:55:29 -0700 Subject: [PATCH 009/198] Better spheres and framebuffer compat layer --- .../backend/effects/EffectsHandler.java | 20 ++++--- .../gl/versioned/framebuffer/Blit.java | 45 +++++++++++++++ .../gl/versioned/framebuffer/Framebuffer.java | 57 +++++++++++++++++++ .../create/flywheel/shaders/area_effect.frag | 22 +++---- 4 files changed, 124 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Blit.java create mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Framebuffer.java diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index d3f7f4e06..749b2ca57 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -1,5 +1,6 @@ package com.simibubi.create.foundation.render.backend.effects; +import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; @@ -87,8 +88,8 @@ public class EffectsHandler { Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); - GL30.glBindFramebuffer(FramebufferConstants.FRAME_BUFFER, framebuffer.framebufferObject); - GL30.glClear(GL30.GL_COLOR_BUFFER_BIT); + Backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, framebuffer.framebufferObject); + GL11.glClear(GL30.GL_COLOR_BUFFER_BIT); SphereFilterProgram program = Backend.getProgram(AllProgramSpecs.CHROMATIC); program.bind(); @@ -106,7 +107,7 @@ public class EffectsHandler { inverseView.invert(); program.bindInverseView(inverseView); - Vector3d pos1 = new Vector3d(852, 79, -204); + Vector3d pos1 = new Vector3d(865.5, 79, -240.5); Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView(); program.setCameraPos(cameraPos.inverse()); @@ -126,8 +127,9 @@ public class EffectsHandler { program.addSphere(new SphereFilterProgram.FilterSphere() .setCenter(pos1.subtract(cameraPos)) - .setRadius(40) - .setFeather(20f) + .setRadius(10f) + .setFeather(3f) + .setFade(1.5f) .setHsv(false) .setFilter(filter)); @@ -147,10 +149,10 @@ public class EffectsHandler { program.clear(); program.unbind(); - GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebuffer.framebufferObject); - GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject); - GL30.glBlitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); - GL30.glBindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject); + Backend.compat.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebuffer.framebufferObject); + Backend.compat.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject); + Backend.compat.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); + Backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject); } public void delete() { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Blit.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Blit.java new file mode 100644 index 000000000..b5809fa29 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Blit.java @@ -0,0 +1,45 @@ +package com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer; + +import org.lwjgl.opengl.EXTFramebufferBlit; +import org.lwjgl.opengl.GL30; +import org.lwjgl.opengl.GLCapabilities; + +import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; + +public enum Blit implements GlVersioned { + CORE { + @Override + public boolean supported(GLCapabilities caps) { + return caps.OpenGL30; + } + + @Override + public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) { + GL30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); + } + }, + EXT { + @Override + public boolean supported(GLCapabilities caps) { + return caps.GL_EXT_framebuffer_blit; + } + + @Override + public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) { + EXTFramebufferBlit.glBlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); + } + }, + UNSUPPORTED { + @Override + public boolean supported(GLCapabilities caps) { + return true; + } + + @Override + public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) { + throw new UnsupportedOperationException("Framebuffer blitting not supported."); + } + }; + + public abstract void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter); +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Framebuffer.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Framebuffer.java new file mode 100644 index 000000000..02b64c8d5 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Framebuffer.java @@ -0,0 +1,57 @@ +package com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer; + +import org.lwjgl.opengl.ARBFramebufferObject; +import org.lwjgl.opengl.EXTFramebufferObject; +import org.lwjgl.opengl.GL30C; +import org.lwjgl.opengl.GLCapabilities; + +import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; + +public enum Framebuffer implements GlVersioned { + CORE { + @Override + public boolean supported(GLCapabilities caps) { + return caps.OpenGL30; + } + + @Override + public void bindFramebuffer(int target, int framebuffer) { + GL30C.glBindFramebuffer(target, framebuffer); + } + }, + ARB { + @Override + public boolean supported(GLCapabilities caps) { + return caps.GL_ARB_framebuffer_object; + } + + @Override + public void bindFramebuffer(int target, int framebuffer) { + ARBFramebufferObject.glBindFramebuffer(target, framebuffer); + } + }, + EXT { + @Override + public boolean supported(GLCapabilities caps) { + return caps.GL_EXT_framebuffer_object; + } + + @Override + public void bindFramebuffer(int target, int framebuffer) { + EXTFramebufferObject.glBindFramebufferEXT(target, framebuffer); + } + }, + UNSUPPORTED { + @Override + public boolean supported(GLCapabilities caps) { + return true; + } + + @Override + public void bindFramebuffer(int target, int framebuffer) { + throw new UnsupportedOperationException("Framebuffers not supported"); + } + }; + + public abstract void bindFramebuffer(int target, int framebuffer); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index 005fe91f8..de6fb2f23 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -16,7 +16,7 @@ uniform vec3 uCameraPos; struct SphereFilter { vec4 sphere;// - vec3 data;// + vec4 data;// mat4 colorOp; }; @@ -49,9 +49,9 @@ float overlayFilterAmount(in vec3 worldPos, in vec4 sphere, in float feather) { return 1 - smoothstep(sphere.w, sphere.w + feather, distance); } -float sphereFilterAmount(in vec3 worldDir, in float depth, in vec4 sphere, in float feather) { - float feathering = 1 - smoothstep(sphere.w, sphere.w + feather, length(sphere.xyz)); - feathering += overlayFilterAmount(worldDir * depth, sphere, feather); +float sphereFilterAmount(in vec3 worldDir, in float depth, in vec4 sphere, in vec4 data) { + float feathering = 1 - smoothstep(sphere.w + data.x, sphere.w + data.x + data.y, length(sphere.xyz)); + feathering += overlayFilterAmount(worldDir * depth, sphere, data.x); vec3 oc = -sphere.xyz; float rayLengthSqr = dot(worldDir, worldDir); @@ -61,7 +61,7 @@ float sphereFilterAmount(in vec3 worldDir, in float depth, in vec4 sphere, in fl float d = 4. * rayLengthSqr; float e = 1. / (2.0*rayLengthSqr); - float radius = sphere.w; + float radius = sphere.w + data.x; float c = sphereDistSqr - radius*radius; float discriminant = b2 - d * c; float hitDepth = (-b - sqrt(discriminant)) * e; @@ -75,8 +75,8 @@ float sphereFilterAmount(in vec3 worldDir, in float depth, in vec4 sphere, in fl vec3 hitPos = worldDir * hitDepth; vec3 normal = normalize(hitPos - sphere.xyz); - - return feathering - dot(normal, normalize(worldDir)) * 1.3 - 0.1; + float normalDot = dot(normal, normalize(worldDir)); + return feathering + normalDot * normalDot; } else { return feathering; } @@ -92,17 +92,17 @@ vec3 applyFilters(in vec3 worldDir, in float depth, in vec3 diffuse) { SphereFilter s = uSpheres[i]; //float strength = overlayFilterAmount(worldPos, s.sphere, s.data.x); - float strength = sphereFilterAmount(worldDir, depth, s.sphere, s.data.x); + float strength = sphereFilterAmount(worldDir, depth, s.sphere, s.data); //accum = vec3(strength, strength, strength); - vec3 toFilter = mix(diffuse, diffuseHSV, s.data.z); + vec3 toFilter = mix(diffuse, diffuseHSV, s.data.w); vec3 filtered = filterColor(s.colorOp, diffuse); - filtered = mix(filtered, hsv2rgbWrapped(filtered), s.data.z); + filtered = mix(filtered, hsv2rgbWrapped(filtered), s.data.w); - accum = mix(accum, filtered, clamp(strength * s.data.y, 0., 1.)); + accum = mix(accum, filtered, clamp(strength * s.data.z, 0., 1.)); } return accum; From e50590f6b760d36a1d7511ccb25678825737951c Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sun, 18 Apr 2021 22:23:41 -0700 Subject: [PATCH 010/198] Start working on the blocks - Also better control and visuals --- .../java/com/simibubi/create/AllBlocks.java | 26 ++--- .../simibubi/create/AllContainerTypes.java | 4 + .../com/simibubi/create/AllTileEntities.java | 2 +- .../curiosities/ChromaticProjectorBlock.java | 27 ------ .../ChromaticProjectorTileEntity.java | 10 -- .../projector/ChromaticProjectorBlock.java | 52 ++++++++++ .../ChromaticProjectorContainer.java | 33 +++++++ .../projector/ChromaticProjectorScreen.java | 62 ++++++++++++ .../ChromaticProjectorTileEntity.java | 40 ++++++++ .../create/foundation/gui/AllGuiTextures.java | 2 + .../backend/effects/EffectsHandler.java | 37 ++++++-- .../backend/effects/SphereFilterProgram.java | 12 +-- .../create/flywheel/shaders/area_effect.frag | 89 ++++++++++++------ .../assets/create/textures/gui/projector.png | Bin 0 -> 2307 bytes 14 files changed, 302 insertions(+), 94 deletions(-) delete mode 100644 src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorBlock.java delete mode 100644 src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorTileEntity.java create mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java create mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorContainer.java create mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java create mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java create mode 100644 src/main/resources/assets/create/textures/gui/projector.png diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index c1a9c1f7f..e06604377 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -113,6 +113,7 @@ import com.simibubi.create.content.contraptions.relays.encased.GearshiftBlock; import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock; import com.simibubi.create.content.contraptions.relays.gauge.GaugeGenerator; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxBlock; +import com.simibubi.create.content.curiosities.projector.ChromaticProjectorBlock; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock; import com.simibubi.create.content.logistics.block.belts.tunnel.BrassTunnelBlock; import com.simibubi.create.content.logistics.block.belts.tunnel.BrassTunnelCTBehaviour; @@ -1332,25 +1333,26 @@ public class AllBlocks { .blockstate((c, p) -> p.simpleBlock(c.get(), p.models() .cubeAll(c.getName(), p.modLoc("block/brass_storage_block")))) .tag(Tags.Blocks.STORAGE_BLOCKS) - .tag(BlockTags.BEACON_BASE_BLOCKS) - .transform(tagBlockAndItem("storage_blocks/brass")) - .tag(Tags.Items.STORAGE_BLOCKS) - .build() - .register(); + .tag(BlockTags.BEACON_BASE_BLOCKS) + .transform(tagBlockAndItem("storage_blocks/brass")) + .tag(Tags.Items.STORAGE_BLOCKS) + .build() + .register(); static { REGISTRATE.startSection(AllSections.CURIOSITIES); } - public static final BlockEntry CHROMATIC_PROJECTOR = - REGISTRATE.block("chromatic_projector", Block::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .item() - .build() - .register(); + public static final BlockEntry CHROMATIC_PROJECTOR = + REGISTRATE.block("chromatic_projector", ChromaticProjectorBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .item() + .build() + .register(); // Load this class - public static void register() {} + public static void register() { + } } diff --git a/src/main/java/com/simibubi/create/AllContainerTypes.java b/src/main/java/com/simibubi/create/AllContainerTypes.java index f7ea37a0c..d17d0ffce 100644 --- a/src/main/java/com/simibubi/create/AllContainerTypes.java +++ b/src/main/java/com/simibubi/create/AllContainerTypes.java @@ -1,5 +1,7 @@ package com.simibubi.create; +import com.simibubi.create.content.curiosities.projector.ChromaticProjectorContainer; +import com.simibubi.create.content.curiosities.projector.ChromaticProjectorScreen; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateContainer; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateScreen; import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer; @@ -32,6 +34,7 @@ public enum AllContainerTypes { FLEXCRATE(AdjustableCrateContainer::new), FILTER(FilterContainer::new), ATTRIBUTE_FILTER(AttributeFilterContainer::new), + CHROMATIC_PROJECTOR(ChromaticProjectorContainer::new), ; @@ -58,6 +61,7 @@ public enum AllContainerTypes { bind(FLEXCRATE, AdjustableCrateScreen::new); bind(FILTER, FilterScreen::new); bind(ATTRIBUTE_FILTER, AttributeFilterScreen::new); + bind(CHROMATIC_PROJECTOR, ChromaticProjectorScreen::new); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index 767531933..17e3b9a63 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -116,7 +116,7 @@ import com.simibubi.create.content.contraptions.relays.gearbox.GearboxInstance; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxRenderer; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity; import com.simibubi.create.content.contraptions.relays.gearbox.GearshiftTileEntity; -import com.simibubi.create.content.curiosities.ChromaticProjectorTileEntity; +import com.simibubi.create.content.curiosities.projector.ChromaticProjectorTileEntity; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelInstance; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelRenderer; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelTileEntity; diff --git a/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorBlock.java b/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorBlock.java deleted file mode 100644 index 729cdf60f..000000000 --- a/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorBlock.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.simibubi.create.content.curiosities; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockReader; - -import javax.annotation.Nullable; - -import com.simibubi.create.AllTileEntities; - -public class ChromaticProjectorBlock extends Block { - public ChromaticProjectorBlock(Properties p_i48440_1_) { - super(p_i48440_1_); - } - - @Override - public boolean hasTileEntity(BlockState state) { - return true; - } - - @Nullable - @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return AllTileEntities.TESTFX.create(); - } -} diff --git a/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorTileEntity.java deleted file mode 100644 index 8fe2e4644..000000000 --- a/src/main/java/com/simibubi/create/content/curiosities/ChromaticProjectorTileEntity.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.simibubi.create.content.curiosities; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; - -public class ChromaticProjectorTileEntity extends TileEntity { - public ChromaticProjectorTileEntity(TileEntityType te) { - super(te); - } -} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java new file mode 100644 index 000000000..0ae33f6b2 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java @@ -0,0 +1,52 @@ +package com.simibubi.create.content.curiosities.projector; + +import javax.annotation.Nullable; + +import com.simibubi.create.AllTileEntities; +import com.simibubi.create.foundation.block.ITE; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraftforge.fml.network.NetworkHooks; + +public class ChromaticProjectorBlock extends Block implements ITE { + public ChromaticProjectorBlock(Properties p_i48440_1_) { + super(p_i48440_1_); + } + + @Override + public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + BlockRayTraceResult hit) { + if (worldIn.isRemote) + return ActionResultType.SUCCESS; + + withTileEntityDo(worldIn, pos, + te -> NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer)); + return ActionResultType.SUCCESS; + } + + @Override + public boolean hasTileEntity(BlockState state) { + return true; + } + + @Nullable + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + return AllTileEntities.TESTFX.create(); + } + + @Override + public Class getTileEntityClass() { + return ChromaticProjectorTileEntity.class; + } +} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorContainer.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorContainer.java new file mode 100644 index 000000000..bfe6444ee --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorContainer.java @@ -0,0 +1,33 @@ +package com.simibubi.create.content.curiosities.projector; + +import javax.annotation.Nullable; + +import com.simibubi.create.AllContainerTypes; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.network.PacketBuffer; + +public class ChromaticProjectorContainer extends Container { + + public ChromaticProjectorContainer(int id, PlayerInventory inv, PacketBuffer extraData) { + super(AllContainerTypes.CHROMATIC_PROJECTOR.type, id); + + + } + + public ChromaticProjectorContainer(int id, PlayerInventory inv, ChromaticProjectorTileEntity te) { + super(AllContainerTypes.CHROMATIC_PROJECTOR.type, id); + } + + public ChromaticProjectorContainer(@Nullable ContainerType p_i50105_1_, int p_i50105_2_) { + super(p_i50105_1_, p_i50105_2_); + } + + @Override + public boolean canInteractWith(PlayerEntity p_75145_1_) { + return true; + } +} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java new file mode 100644 index 000000000..0c5652339 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java @@ -0,0 +1,62 @@ +package com.simibubi.create.content.curiosities.projector; + +import java.util.ArrayList; +import java.util.Collections; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; +import com.simibubi.create.foundation.gui.AllGuiTextures; +import com.simibubi.create.foundation.gui.widgets.ScrollInput; +import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; + +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; + +public class ChromaticProjectorScreen extends AbstractSimiContainerScreen { + + private ScrollInput filter; + private ScrollInput radius; + private ScrollInput feather; + private ScrollInput fade; + + public ChromaticProjectorScreen(ChromaticProjectorContainer container, PlayerInventory inv, ITextComponent title) { + super(container, inv, title); + } + + @Override + protected void init() { + super.init(); + + widgets.clear(); + + int x = guiLeft + 11; + int y = guiTop + 20; + + ArrayList filterOptions = new ArrayList<>(); + + filterOptions.add(new StringTextComponent("Test")); + filterOptions.add(new StringTextComponent("Test1")); + + filter = new SelectionScrollInput(x, y, 77, 18) + .forOptions(filterOptions); + y += 20; + radius = new ScrollInput(x, y, 30, 20); + y += 20; + feather = new ScrollInput(x, y, 30, 20); + y += 20; + fade = new ScrollInput(x, y, 30, 20); + y += 20; + Collections.addAll(widgets, filter, radius, feather, fade); + + } + + @Override + protected void renderWindow(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + //AllGuiTextures.PLAYER_INVENTORY.draw(matrixStack, this, guiLeft - 10, guiTop + 145); + AllGuiTextures.PROJECTOR.draw(matrixStack, this, guiLeft, guiTop); +// BG_TOP.draw(matrixStack, this, guiLeft + 20, guiTop); +// BG_BOTTOM.draw(matrixStack, this, guiLeft + 20, guiTop + BG_TOP.height); + + } +} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java new file mode 100644 index 000000000..d7d9974ff --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java @@ -0,0 +1,40 @@ +package com.simibubi.create.content.curiosities.projector; + +import javax.annotation.Nullable; + +import com.simibubi.create.foundation.render.backend.effects.SphereFilterProgram; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; +import net.minecraft.network.PacketBuffer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; + +public class ChromaticProjectorTileEntity extends TileEntity implements INamedContainerProvider { + + SphereFilterProgram.FilterSphere filter; + + public ChromaticProjectorTileEntity(TileEntityType te) { + super(te); + } + + public void sendToContainer(PacketBuffer buffer) { + buffer.writeBlockPos(getPos()); + buffer.writeCompoundTag(getUpdateTag()); + } + + @Override + public ITextComponent getDisplayName() { + return new StringTextComponent("Chromatic Projector"); + } + + @Nullable + @Override + public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) { + return new ChromaticProjectorContainer(p_createMenu_1_, p_createMenu_2_, this); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java index 610721e21..3db38433b 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java @@ -56,6 +56,8 @@ public enum AllGuiTextures implements IScreenRenderable { SEQUENCER_EMPTY("sequencer.png", 0, 102, 162, 22), SEQUENCER_AWAIT("sequencer.png", 0, 160, 162, 22), + PROJECTOR("projector.png", 173, 159), + // JEI JEI_SLOT("jei/widgets.png", 18, 18), JEI_CHANCE_SLOT("jei/widgets.png", 20, 156, 18, 18), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index 749b2ca57..977c8d064 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -107,7 +107,6 @@ public class EffectsHandler { inverseView.invert(); program.bindInverseView(inverseView); - Vector3d pos1 = new Vector3d(865.5, 79, -240.5); Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView(); program.setCameraPos(cameraPos.inverse()); @@ -123,15 +122,39 @@ public class EffectsHandler { // .setFilter(ColorMatrices.hueShiftRGB((float) i / n * 360 + i / 2f))); // } - Matrix4f filter = ColorMatrices.sepia(1f); - program.addSphere(new SphereFilterProgram.FilterSphere() - .setCenter(pos1.subtract(cameraPos)) + .setCenter(new Vector3d(865.5, 79, -240.5).subtract(cameraPos)) .setRadius(10f) .setFeather(3f) - .setFade(1.5f) - .setHsv(false) - .setFilter(filter)); + .setFade(1.8f) + .setDensity(1.3f) + .setFilter(ColorMatrices.grayscale())); + + program.addSphere(new SphereFilterProgram.FilterSphere() + .setCenter(new Vector3d(858.5, 88, -259.5).subtract(cameraPos)) + .setRadius(10f) + .setFeather(3f) + .setFade(1.8f) + .setDensity(1.3f) + .setStrength(1f) + .setFilter(ColorMatrices.sepia(1f))); + + Matrix4f test = ColorMatrices.grayscale(); + Matrix4f colorize = new Matrix4f(); + colorize.a00 = 1f; + colorize.a11 = 0.5f; + colorize.a22 = 0.5f; + colorize.a33 = 1f; + test = colorize; + + program.addSphere(new SphereFilterProgram.FilterSphere() + .setCenter(new Vector3d(2310, 60, -954).subtract(cameraPos)) + .setRadius(8f) + .setFeather(3f) + .setFade(0.1f) + .setDensity(0.5f) + .setStrength(1f) + .setFilter(test)); program.uploadFilters(); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java index 8b885b5b6..4616e8768 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java @@ -127,8 +127,8 @@ public class SphereFilterProgram extends GlProgram { public float radius; public float feather; public float fade; + public float density = 2; public float strength = 1; - public boolean hsv; public Matrix4f filter; @@ -152,13 +152,13 @@ public class SphereFilterProgram extends GlProgram { return this; } - public FilterSphere setStrength(float strength) { - this.strength = strength; + public FilterSphere setDensity(float density) { + this.density = density; return this; } - public FilterSphere setHsv(boolean hsv) { - this.hsv = hsv; + public FilterSphere setStrength(float strength) { + this.strength = strength; return this; } @@ -175,8 +175,8 @@ public class SphereFilterProgram extends GlProgram { radius, feather, fade, + density, strength, - hsv ? 1f : 0f, }); buf.put(RenderUtil.writeMatrix(filter)); diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index de6fb2f23..b723dd5e4 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -16,11 +16,35 @@ uniform vec3 uCameraPos; struct SphereFilter { vec4 sphere;// - vec4 data;// + vec4 data;// mat4 colorOp; }; -#define N 256 +vec3 getPosition(SphereFilter f) { + return f.sphere.xyz; +} + +float getRadius(SphereFilter f) { + return f.sphere.w; +} + +float getFeather(SphereFilter f) { + return f.data.x; +} + +float getFade(SphereFilter f) { + return f.data.y; +} + +float getDensity(SphereFilter f) { + return f.data.z; +} + +float getStrength(SphereFilter f) { + return f.data.w; +} + + #define N 256 layout (std140) uniform Filters { int uCount; SphereFilter uSpheres[N]; @@ -44,65 +68,68 @@ float getDepth() { return linearizeDepth(depth, uNearPlane, uFarPlane); } -float overlayFilterAmount(in vec3 worldPos, in vec4 sphere, in float feather) { +float surfaceFilterStrength(vec3 worldPos, vec4 sphere, float feather) { float distance = distance(sphere.xyz, worldPos); return 1 - smoothstep(sphere.w, sphere.w + feather, distance); } -float sphereFilterAmount(in vec3 worldDir, in float depth, in vec4 sphere, in vec4 data) { - float feathering = 1 - smoothstep(sphere.w + data.x, sphere.w + data.x + data.y, length(sphere.xyz)); - feathering += overlayFilterAmount(worldDir * depth, sphere, data.x); - vec3 oc = -sphere.xyz; +float bubbleFilterStrength(vec3 worldDir, float depth, vec4 sphere, float feather, float density) { + vec3 position = sphere.xyz; float rayLengthSqr = dot(worldDir, worldDir); - float b = 2.0 * dot(-sphere.xyz, worldDir); - float sphereDistSqr = dot(sphere.xyz, sphere.xyz); + float b = 2.0 * dot(-position, worldDir); + float sphereDistSqr = dot(position, position); float b2 = b*b; float d = 4. * rayLengthSqr; float e = 1. / (2.0*rayLengthSqr); - float radius = sphere.w + data.x; + float radius = sphere.w + feather; float c = sphereDistSqr - radius*radius; float discriminant = b2 - d * c; float hitDepth = (-b - sqrt(discriminant)) * e; - + float strength = 0.; if (discriminant > 0 && hitDepth > 0 && hitDepth < depth) { - // float c = sphereDistSqr - sphere.w*sphere.w; - // float discriminant = b2 - d * c; - // float hitDepth = (-b - sqrt(discriminant)) * e; - vec3 hitPos = worldDir * hitDepth; - vec3 normal = normalize(hitPos - sphere.xyz); + vec3 normal = normalize(hitPos - position); float normalDot = dot(normal, normalize(worldDir)); - return feathering + normalDot * normalDot; - } else { - return feathering; + // blend into the effect based on the distance between the fragcoord and point on the sphere + // this avoinds having hard edges + strength += mix(0., normalDot * normalDot * density, clamp(depth - hitDepth, 0., feather + 1.)); } + + return clamp(strength, 0., 1.); } -vec3 applyFilters(in vec3 worldDir, in float depth, in vec3 diffuse) { +float filterStrength(vec3 worldDir, float depth, vec4 sphere, vec4 data) { + float feather = data.x; + + float strength = 0.; + // transition effect + float transitionRadius = sphere.w + feather; + strength += 1. - smoothstep(transitionRadius, transitionRadius + data.y, length(sphere.xyz)); + // surface effect + strength += surfaceFilterStrength(worldDir * depth, sphere, feather); + // bubble effect + strength += bubbleFilterStrength(worldDir, depth, sphere, feather, data.z); + + return strength; +} + +vec3 applyFilters(vec3 worldDir, float depth, vec3 diffuse) { vec3 worldPos = worldDir * depth; - vec3 accum = diffuse; - vec3 diffuseHSV = rgb2hsv(accum); + vec3 accum = vec3(diffuse); for (int i = 0; i < uCount; i++) { SphereFilter s = uSpheres[i]; - //float strength = overlayFilterAmount(worldPos, s.sphere, s.data.x); - float strength = sphereFilterAmount(worldDir, depth, s.sphere, s.data); - - //accum = vec3(strength, strength, strength); - - vec3 toFilter = mix(diffuse, diffuseHSV, s.data.w); + float strength = filterStrength(worldDir, depth, s.sphere, s.data); vec3 filtered = filterColor(s.colorOp, diffuse); - filtered = mix(filtered, hsv2rgbWrapped(filtered), s.data.w); - - accum = mix(accum, filtered, clamp(strength * s.data.z, 0., 1.)); + accum = mix(accum, filtered, clamp(strength * s.data.w, 0., 1.)); } return accum; diff --git a/src/main/resources/assets/create/textures/gui/projector.png b/src/main/resources/assets/create/textures/gui/projector.png new file mode 100644 index 0000000000000000000000000000000000000000..f35f17bc65b433efa833d37e70bec3e2d690ce20 GIT binary patch literal 2307 zcmdT`Sx{418a^Ry&=5!msL&GvL5gY|L2zV8WsyZFZD4F#K)?i%MOz300C$RPymhRI)kktM+Z?Cx`QwD*iFSYfwk6ohCg3TAG6qq#@@ z0#aq7;7D}F63%1q#C4ZU)v>vn2Z~Tt)!ZnlA}q$o$rz=ey3ZB)>aL5s_Q@run!i%D za?0fPntm099UMcQ3~R2;sFE<&%AFjK#BFO#PC-zp z)#+_gVe1})pfFR+3Tc%~9Z?E`aI|Q{Wwd0p->8qN8P|pmu4qyL}2GvEi3(=sQQm{h`J)9;*OoG(JOQz&(d+5IN z@@B0G+jGXqYgG`>CTU^-M+$g+zjcM#AA%V;)aA`LqxR_Jy}10P=rhIb2U}7wWDb6M zN5DeV>_${P>N^Raw6w-=71TXYCM3;Dmdwc6oIxq5Y~4P4^5Jm# z%J)M9`4+TjpCu{8Cet0(nu($JMub8qnxiegrsaEof!=uh5TH=9cN^}PZLgI;Lcw=F zug%C6Ct?E+<(&@;{Pwru3oYU|Wr{{q)6@UpGVf~2RY!O#(UhvMEQPnMGY|VrP5vZu zBHZNAWWsrSTz>EQ+Km{5Y?4Q)@(o_A~qUQz-t;Axxi@*x2 z=5hMYLWC#b^E&@w$v?n(db)kgyEtJ$d+MpV1vM@Ukr0`!q+!%qL~8xX#_zyFzb#xJ z<~o?*PQUAJ^EU}4xJN>ur9U0I2CU*Ke<@i+7Cb}O?BzQsGe(bP6^(xn91K?b%^zb@ z%Tn}?^I?N)if+NmgdT|pBclGtg+Tx>3urpy61fqtL6A}z+E*JoAJyB+n2Oh5rm>N< zJUL}?EF>}%q>LW)JD_J(YNP9sj&HdC@ynFlaq+84bQTt47hs0)QgT&MzE}N`stPtJ z?$u{ftSp2{B_Ak0_eey4DoTTScz@8zkmvbHhqbodvOc9r7AMTkACXfQ&qEeokAgF{ zqE3+sw_v(>NG~l=p>KZ{_BPzG%tfxO_Lg26Oy|GAC@8uO$y9Fgw%#A1!i5d$GVu@pZ27!gkY5b4k=h_tl0SFYR3$tAycSftP|_lzOSXYNCK{tsbM z-}gtTz~XlI{KVAMl)L5a)i|tIrC)mGvU3_c#?*S_Yr{}=l>e49UG1dM zZcJCVnTfH}+Tq)j*NcpKY-&!umS=EOlu7u@7OM$<=jQUbqA1q#^$5oT;UsuILAE`YVXQ3)xkMy(Kh4m{sW!vr>>|HxXl%^flnyU#7-*2$Y*MFKe8NA@AmU3j zC>6ZQCw8r~XkVgGR4TQmtt}k&6?q(#bTQJ9=Nj-Yc)ai%g(J7>fXB~iNE}bb*7f*x z7kSPI--gXG#-9~#p_4h@U|%U~mX&`%!GGN63wSN?c(x*hMg%{ABb6%&0Jw(DcQL@h~(AQ}U@&20t!+V2Ji2Bfr^<|_sr zZIBZ|klCJBiaWhtVr7!1A;9(z!`OmGh62520NKJJW@tcsZUrH(-QeJUf!UcMWCBCr z*)HG;)X8V%#sjSj(GpQA$r}ygpTw;`C=wOu{Hj2Q*MX12H{)j0<#}gE$LY4D!&d@J v`Zb9ycUt$TzgoCA(nFQsH~zOz0YV1NI#gl)%*1oyJ(H`Gn`7lM!Vmuf017q! literal 0 HcmV?d00001 From f75422f895dfcdbc586c7c6ee55fcc66e7d79b45 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 20 Apr 2021 14:05:50 -0700 Subject: [PATCH 011/198] Instruction parallel ray sphere intersection --- .../render/backend/effects/ColorMatrices.java | 23 +++++---- .../backend/effects/EffectsHandler.java | 40 +++++++++------ .../create/flywheel/shaders/area_effect.frag | 49 +++++++++++++------ 3 files changed, 71 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java index db3097b21..93b2ae186 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java @@ -11,6 +11,19 @@ public class ColorMatrices { public static final float lumaG = 0.6094f; public static final float lumaB = 0.0820f; + public static Matrix4f invert() { + Matrix4f invert = new Matrix4f(); + invert.a00 = -1.0F; + invert.a11 = -1.0F; + invert.a22 = -1.0F; + invert.a33 = -1.0F; + invert.a30 = 1; + invert.a31 = 1; + invert.a32 = 1; + + return invert; + } + public static Matrix4f grayscale() { Matrix4f mat = new Matrix4f(); @@ -78,14 +91,4 @@ public class ColorMatrices { return mat; } - - public static Matrix4f hueShiftHSV(float rot) { - Matrix4f mat = new Matrix4f(); - - mat.loadIdentity(); - - //mat.a03 = 0.5f; - - return mat; - } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index 977c8d064..33151d5ce 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -111,14 +111,16 @@ public class EffectsHandler { program.setCameraPos(cameraPos.inverse()); -// int n = 20; +// int n = 64; // double rad = 15; // for (int i = 0; i < n; i++) { // double angle = ((double) i) / n * Math.PI * 2; // program.addSphere(new SphereFilterProgram.FilterSphere() -// .setCenter(pos1.subtract(cameraPos).add(Math.sin(angle) * rad, 0, Math.cos(angle) * rad)) -// .setRadius(10) -// .setFeather(0f) +// .setCenter(new Vector3d(852, 77, -204).subtract(cameraPos).add(Math.sin(angle) * rad, 0, Math.cos(angle) * rad)) +// .setRadius(15) +// .setFeather(3f) +// .setFade(1f) +// .setDensity(0.5f) // .setFilter(ColorMatrices.hueShiftRGB((float) i / n * 360 + i / 2f))); // } @@ -130,31 +132,37 @@ public class EffectsHandler { .setDensity(1.3f) .setFilter(ColorMatrices.grayscale())); + Matrix4f test = ColorMatrices.sepia(1f); + + + test.multiply(ColorMatrices.invert()); + + Matrix4f darken = new Matrix4f(); + darken.loadIdentity(); + darken.multiply(0.7f); + darken.a03 = 0.7f; + darken.a13 = 0.7f; + darken.a23 = 0.7f; + test.multiply(darken); + program.addSphere(new SphereFilterProgram.FilterSphere() .setCenter(new Vector3d(858.5, 88, -259.5).subtract(cameraPos)) .setRadius(10f) .setFeather(3f) .setFade(1.8f) - .setDensity(1.3f) + .setDensity(0.5f) .setStrength(1f) - .setFilter(ColorMatrices.sepia(1f))); + .setFilter(test)); - Matrix4f test = ColorMatrices.grayscale(); - Matrix4f colorize = new Matrix4f(); - colorize.a00 = 1f; - colorize.a11 = 0.5f; - colorize.a22 = 0.5f; - colorize.a33 = 1f; - test = colorize; program.addSphere(new SphereFilterProgram.FilterSphere() .setCenter(new Vector3d(2310, 60, -954).subtract(cameraPos)) .setRadius(8f) .setFeather(3f) - .setFade(0.1f) - .setDensity(0.5f) + .setFade(0.8f) + .setDensity(1.3f) .setStrength(1f) - .setFilter(test)); + .setFilter(ColorMatrices.grayscale())); program.uploadFilters(); diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index b723dd5e4..00691aeb1 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -73,23 +73,34 @@ float surfaceFilterStrength(vec3 worldPos, vec4 sphere, float feather) { return 1 - smoothstep(sphere.w, sphere.w + feather, distance); } +vec2 raySphere(vec3 worldDir, vec3 position, float radius) { + float rayLengthSqr = dot(worldDir, worldDir); + float sphereDistSqr = dot(position, position); + + const vec3 M = vec3(2., 2., 4.); + vec3 f = M * vec3(dot(-position, worldDir), vec2(rayLengthSqr)); + + vec2 s = vec2(f.x, radius); + vec2 s2 = s * s; + float c = sphereDistSqr - s2.y; + float dc = f.z * c; + + float discriminant = s2.x - dc; + float hitDepth = (-f.x - sqrt(discriminant)) / f.y; + + return vec2(discriminant, hitDepth); +} + float bubbleFilterStrength(vec3 worldDir, float depth, vec4 sphere, float feather, float density) { vec3 position = sphere.xyz; - float rayLengthSqr = dot(worldDir, worldDir); - float b = 2.0 * dot(-position, worldDir); - float sphereDistSqr = dot(position, position); - float b2 = b*b; - float d = 4. * rayLengthSqr; - float e = 1. / (2.0*rayLengthSqr); - - float radius = sphere.w + feather; - float c = sphereDistSqr - radius*radius; - float discriminant = b2 - d * c; - float hitDepth = (-b - sqrt(discriminant)) * e; + vec2 hit = raySphere(worldDir, position, sphere.w + feather); + float hitDepth = hit.y; float strength = 0.; - if (discriminant > 0 && hitDepth > 0 && hitDepth < depth) { + + //float boo = step(0., discriminant) * step(0., hitDepth) * step(0., depth - hitDepth); + if (hit.x > 0 && hitDepth > 0 && hitDepth < depth) { vec3 hitPos = worldDir * hitDepth; vec3 normal = normalize(hitPos - position); @@ -99,7 +110,7 @@ float bubbleFilterStrength(vec3 worldDir, float depth, vec4 sphere, float feathe strength += mix(0., normalDot * normalDot * density, clamp(depth - hitDepth, 0., feather + 1.)); } - return clamp(strength, 0., 1.); + return clamp(strength, 0., 1.);// * boo; } float filterStrength(vec3 worldDir, float depth, vec4 sphere, vec4 data) { @@ -120,6 +131,7 @@ float filterStrength(vec3 worldDir, float depth, vec4 sphere, vec4 data) { vec3 applyFilters(vec3 worldDir, float depth, vec3 diffuse) { vec3 worldPos = worldDir * depth; + vec3 hsv = rgb2hsv(diffuse); vec3 accum = vec3(diffuse); for (int i = 0; i < uCount; i++) { @@ -127,9 +139,16 @@ vec3 applyFilters(vec3 worldDir, float depth, vec3 diffuse) { float strength = filterStrength(worldDir, depth, s.sphere, s.data); - vec3 filtered = filterColor(s.colorOp, diffuse); + if (strength > 0) { + const float fcon = 0.; - accum = mix(accum, filtered, clamp(strength * s.data.w, 0., 1.)); + vec3 formatted = mix(diffuse, hsv, fcon); + vec3 filtered = filterColor(s.colorOp, formatted); + filtered = mix(filtered, hsv2rgbWrapped(filtered), fcon); + + float mixing = clamp(strength * s.data.w, 0., 1.); + accum = mix(accum, filtered, mixing); + } } return accum; From fc919c4ac4360deedd4578798d874318e090bcec Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 22 Apr 2021 16:02:16 -0700 Subject: [PATCH 012/198] Basic projector gui --- src/generated/resources/.cache/cache | 32 +-- .../resources/assets/create/lang/en_ud.json | 1 + .../resources/assets/create/lang/en_us.json | 86 ++++---- .../assets/create/lang/unfinished/de_de.json | 63 +++--- .../assets/create/lang/unfinished/es_es.json | 63 +++--- .../assets/create/lang/unfinished/es_mx.json | 63 +++--- .../assets/create/lang/unfinished/fr_fr.json | 63 +++--- .../assets/create/lang/unfinished/it_it.json | 63 +++--- .../assets/create/lang/unfinished/ja_jp.json | 63 +++--- .../assets/create/lang/unfinished/ko_kr.json | 63 +++--- .../assets/create/lang/unfinished/nl_nl.json | 63 +++--- .../assets/create/lang/unfinished/pt_br.json | 63 +++--- .../assets/create/lang/unfinished/ru_ru.json | 63 +++--- .../assets/create/lang/unfinished/zh_cn.json | 63 +++--- .../assets/create/lang/unfinished/zh_tw.json | 63 +++--- .../simibubi/create/AllContainerTypes.java | 4 - .../projector/ChromaticProjectorBlock.java | 24 ++- .../ChromaticProjectorContainer.java | 33 ---- .../projector/ChromaticProjectorScreen.java | 186 +++++++++++++++--- .../ChromaticProjectorTileEntity.java | 31 +-- .../curiosities/projector/ColorEffects.java | 59 ++++++ .../curiosities/projector/FilterStep.java | 25 +++ .../create/foundation/gui/AllGuiTextures.java | 6 +- .../render/backend/effects/ColorMatrices.java | 8 +- .../backend/effects/EffectsHandler.java | 30 ++- .../assets/create/textures/gui/projector.png | Bin 2307 -> 3095 bytes 26 files changed, 729 insertions(+), 552 deletions(-) delete mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorContainer.java create mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java create mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 5fff6584f..4f61b4399 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -47,6 +47,7 @@ e81608346d43406ee72cae0f78b8bcfb37ba2d75 assets/create/blockstates/brown_seat.js cbcdab42d01f8085db9e5f8db884f8adf7f17625 assets/create/blockstates/chiseled_scoria.json 291952556c52fba2af5bbd793c71af81abd27e71 assets/create/blockstates/chiseled_weathered_limestone.json 470e8c6a9c37b91fa745bc4f6e9d3740bd72467e assets/create/blockstates/chocolate.json +4319ddb44dabbb1ed189d86429ca57091ba2dcf6 assets/create/blockstates/chromatic_projector.json b59324f051f21d8ce1a48a08f4721a61a3c414d6 assets/create/blockstates/chute.json 4947c261310445fa55b92038326ac82967d192dd assets/create/blockstates/clockwork_bearing.json 1f33834c685e3243882acfe20183fe64dfa872be assets/create/blockstates/clutch.json @@ -406,20 +407,20 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j 6801fa1f466f172700e573e5b8ee8ee5f9ca4583 assets/create/blockstates/yellow_valve_handle.json 7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json -97e9ee471ea650f6b7f3d3f39f00201cd5ad752d assets/create/lang/en_ud.json -514ab1f6fa3d24dc575a5dcaaaa96a8009da7414 assets/create/lang/en_us.json -7e45e9a69fb4d21d199174673f2ea6fe35ee6859 assets/create/lang/unfinished/de_de.json -2af0dd8cd0776b8ed5110990405f3cd515abe8e8 assets/create/lang/unfinished/es_es.json -90fc3a9475b957eebf10380a960416b072987541 assets/create/lang/unfinished/es_mx.json -997cc00c6a9afbb142e25c5a1840908363afad41 assets/create/lang/unfinished/fr_fr.json -6a9c89ff7a7c2df5f78a6a739a204744a4a5607a assets/create/lang/unfinished/it_it.json -e21697e70444e3c8fb367b7a4fe867726157390d assets/create/lang/unfinished/ja_jp.json -9f2d7b6fc84f6257837b4c517489f6ef31a4e1a5 assets/create/lang/unfinished/ko_kr.json -5bcfe026f3bb3f0aa0ea415e54dedad4195bb70a assets/create/lang/unfinished/nl_nl.json -bc60cb08266e8d13523d086cdb85aa12da78a47b assets/create/lang/unfinished/pt_br.json -288e3e76a1aa090a676415aeb9f5383b3386e40d assets/create/lang/unfinished/ru_ru.json -0b6852ca1cea71d24cfdee7004ab37fa7810a0fe assets/create/lang/unfinished/zh_cn.json -619d82eba592f4ae88ddbc2c9dfae02627876300 assets/create/lang/unfinished/zh_tw.json +ca9a861ca831a782966c22ad0c68ff966710769a assets/create/lang/en_ud.json +02f2424747d50bad2f844e905646d816899a03d7 assets/create/lang/en_us.json +08e387354ee4ab1a4837277c10847e603cf7ac59 assets/create/lang/unfinished/de_de.json +b5b3c69b4539aac10f03a5cb2b3459ca094d373c assets/create/lang/unfinished/es_es.json +5d17d28dc81011ab21e013fedd707fcf8ece0572 assets/create/lang/unfinished/es_mx.json +9fd9df90d1ecf8ac8c95fadfcd5bf4a04d182681 assets/create/lang/unfinished/fr_fr.json +1cd6952f8b65a75861e17f4c4de867af54a6b055 assets/create/lang/unfinished/it_it.json +0db66a9cf76bbbafc487a5483e3f10ec306f96d9 assets/create/lang/unfinished/ja_jp.json +07f51957cb8776b53c6665c8cea3b544e09d13d9 assets/create/lang/unfinished/ko_kr.json +62df112c0264af0962c39c953497217240e2c92d assets/create/lang/unfinished/nl_nl.json +1c86e439423a682b8de29777f1641b0a3f138c42 assets/create/lang/unfinished/pt_br.json +5d54f4997ba80ec505c1f38c5f6f3fde0a41a0f5 assets/create/lang/unfinished/ru_ru.json +89e04cc0bdf17762f089c673aa3bb1fe0707d3df assets/create/lang/unfinished/zh_cn.json +c310383e5617d0cfec551eef31272d9a19cd4445 assets/create/lang/unfinished/zh_tw.json 487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json 3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json @@ -540,6 +541,7 @@ db7279f05c1d89e21da8887a15d3a1cfff4a9cf2 assets/create/models/block/chiseled_dar 1cf4b68c8cf1885ede334fbfa54e52c76ba211b6 assets/create/models/block/chiseled_scoria.json 041a20dd674277ff4f1613a0a89600f05458edf4 assets/create/models/block/chiseled_weathered_limestone.json 4156227e18c0896ce83f260f71b939abbbf4f01e assets/create/models/block/chocolate.json +5e3819de78eb6e7511839905fa0fdde4babcaf21 assets/create/models/block/chromatic_projector.json 30fe120af3cb32faf0729df4d2cdf868f804be17 assets/create/models/block/clockwork_bearing.json 1f01a4b6608f75145734b60ddf4a33ce318425ff assets/create/models/block/copper_casing.json b2c528cfd24a5cb0cb96c45d0a914f1090f8c32b assets/create/models/block/copper_valve_handle.json @@ -1253,6 +1255,7 @@ a47fbe5f2da79080d99ef0975bfa8da4d08f8be4 assets/create/models/item/chiseled_scor 70232ce9b88119fb383717e2c1ad113f7aad6a99 assets/create/models/item/chiseled_weathered_limestone.json 7a3737f6156213762e28a4dbedc4c6828dc1878c assets/create/models/item/chocolate_bucket.json 87637b39c3a5a386457d52b37eb65f1c4bcabaf0 assets/create/models/item/chocolate_glazed_berries.json +7ee3446e9164e466421e4349e1eada3101f3c976 assets/create/models/item/chromatic_projector.json fe67c3f380d17735a9436a4579a8be1a02b8e4a0 assets/create/models/item/chute.json 6680a68526576ded5dac2aa3bc9fb9de3e744146 assets/create/models/item/cinder_flour.json c1da21be9f1af4f7a2ef4ec9cd92195d65ada316 assets/create/models/item/clockwork_bearing.json @@ -2420,6 +2423,7 @@ ab820bbaaf67c6697dfbab33c05fb73b18c70bfb data/create/loot_tables/blocks/chiseled 4b09725707bac4c5813e2bb489ff848d0d964ae9 data/create/loot_tables/blocks/chiseled_limestone.json 43f446abd3c1c184a08645979edf620e59955a30 data/create/loot_tables/blocks/chiseled_scoria.json adde89e46b12de1eee6fd0c5cb98c5f45feefc15 data/create/loot_tables/blocks/chiseled_weathered_limestone.json +7ea58979dbc1ac44626728afe8fe771c88e250d2 data/create/loot_tables/blocks/chromatic_projector.json 07ccc1576a71338cb73c4e06f8c28a2c86843877 data/create/loot_tables/blocks/chute.json 778b53c36d73b6e9c78fd6c091c9c3535c3c18f7 data/create/loot_tables/blocks/clockwork_bearing.json d76113310fc56eca6382d44df174096f2210d416 data/create/loot_tables/blocks/clutch.json diff --git a/src/generated/resources/assets/create/lang/en_ud.json b/src/generated/resources/assets/create/lang/en_ud.json index 33c7d7480..d63f206fa 100644 --- a/src/generated/resources/assets/create/lang/en_ud.json +++ b/src/generated/resources/assets/create/lang/en_ud.json @@ -48,6 +48,7 @@ "block.create.chiseled_scoria": "\u0250\u0131\u0279o\u0254S p\u01DD\u05DF\u01DDs\u0131\u0265\u0186", "block.create.chiseled_weathered_limestone": "\u01DDuo\u0287s\u01DD\u026F\u0131\uA780 p\u01DD\u0279\u01DD\u0265\u0287\u0250\u01DDM p\u01DD\u05DF\u01DDs\u0131\u0265\u0186", "block.create.chocolate": "\u01DD\u0287\u0250\u05DFo\u0254o\u0265\u0186", + "block.create.chromatic_projector": "\u0279o\u0287\u0254\u01DD\u0638o\u0279\u0500 \u0254\u0131\u0287\u0250\u026Fo\u0279\u0265\u0186", "block.create.chute": "\u01DD\u0287n\u0265\u0186", "block.create.clockwork_bearing": "bu\u0131\u0279\u0250\u01DD\u15FA \u029E\u0279o\u028D\u029E\u0254o\u05DF\u0186", "block.create.clutch": "\u0265\u0254\u0287n\u05DF\u0186", diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index 04ab46cf4..e5aa55e81 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -41,26 +41,27 @@ "block.create.brass_funnel": "Brass Funnel", "block.create.brass_tunnel": "Brass Tunnel", "block.create.brown_sail": "Brown Sail", - "block.create.brown_seat": "Brown Seat", - "block.create.brown_valve_handle": "Brown Valve Handle", - "block.create.cart_assembler": "Cart Assembler", - "block.create.chiseled_dark_scoria": "Chiseled Dark Scoria", - "block.create.chiseled_dolomite": "Chiseled Dolomite", - "block.create.chiseled_gabbro": "Chiseled Gabbro", - "block.create.chiseled_limestone": "Chiseled Limestone", - "block.create.chiseled_scoria": "Chiseled Scoria", - "block.create.chiseled_weathered_limestone": "Chiseled Weathered Limestone", - "block.create.chocolate": "Chocolate", - "block.create.chute": "Chute", - "block.create.clockwork_bearing": "Clockwork Bearing", - "block.create.clutch": "Clutch", - "block.create.cogwheel": "Cogwheel", - "block.create.content_observer": "Content Observer", - "block.create.controller_rail": "Controller Rail", - "block.create.copper_block": "Block of Copper", - "block.create.copper_casing": "Copper Casing", - "block.create.copper_ore": "Copper Ore", - "block.create.copper_shingles": "Copper Shingles", + "block.create.brown_seat": "Brown Seat", + "block.create.brown_valve_handle": "Brown Valve Handle", + "block.create.cart_assembler": "Cart Assembler", + "block.create.chiseled_dark_scoria": "Chiseled Dark Scoria", + "block.create.chiseled_dolomite": "Chiseled Dolomite", + "block.create.chiseled_gabbro": "Chiseled Gabbro", + "block.create.chiseled_limestone": "Chiseled Limestone", + "block.create.chiseled_scoria": "Chiseled Scoria", + "block.create.chiseled_weathered_limestone": "Chiseled Weathered Limestone", + "block.create.chocolate": "Chocolate", + "block.create.chromatic_projector": "Chromatic Projector", + "block.create.chute": "Chute", + "block.create.clockwork_bearing": "Clockwork Bearing", + "block.create.clutch": "Clutch", + "block.create.cogwheel": "Cogwheel", + "block.create.content_observer": "Content Observer", + "block.create.controller_rail": "Controller Rail", + "block.create.copper_block": "Block of Copper", + "block.create.copper_casing": "Copper Casing", + "block.create.copper_ore": "Copper Ore", + "block.create.copper_shingles": "Copper Shingles", "block.create.copper_tiles": "Copper Tiles", "block.create.copper_valve_handle": "Copper Valve Handle", "block.create.creative_crate": "Creative Crate", @@ -1138,26 +1139,29 @@ "create.gui.config.overlay6": "and save the new position", "create.gui.config.overlay7": "Run /create overlay reset", "create.gui.config.overlay8": "to reset to the default position", - - "create.command.killTPSCommand": "killtps", - "create.command.killTPSCommand.status.slowed_by.0": "[Create]: Server tick is currently slowed by %s ms :o", - "create.command.killTPSCommand.status.slowed_by.1": "[Create]: Server tick is slowed by %s ms now >:)", - "create.command.killTPSCommand.status.slowed_by.2": "[Create]: Server tick is back to regular speed :D", - "create.command.killTPSCommand.status.usage.0": "[Create]: use /killtps stop to bring back server tick to regular speed", - "create.command.killTPSCommand.status.usage.1": "[Create]: use /killtps start to artificially slow down the server tick", - "create.command.killTPSCommand.argument.tickTime": "tickTime", - - "create.contraption.minecart_contraption_too_big": "This Cart Contraption seems too big to pick up", - - - "_": "->------------------------] Subtitles [------------------------<-", - - "create.subtitle.cogs": "Cogwheels rumble", - "create.subtitle.slime_added": "Slime squishes", - "create.subtitle.mixing": "Mixing Noises", - "create.subtitle.mechanical_press_activation_belt": "Mechanical Press bonks", - "create.subtitle.blockzapper_confirm": "Affirmative ding", - "create.subtitle.depot_slide": "Item slides", + "create.command.killTPSCommand": "killtps", + "create.command.killTPSCommand.status.slowed_by.0": "[Create]: Server tick is currently slowed by %s ms :o", + "create.command.killTPSCommand.status.slowed_by.1": "[Create]: Server tick is slowed by %s ms now >:)", + "create.command.killTPSCommand.status.slowed_by.2": "[Create]: Server tick is back to regular speed :D", + "create.command.killTPSCommand.status.usage.0": "[Create]: use /killtps stop to bring back server tick to regular speed", + "create.command.killTPSCommand.status.usage.1": "[Create]: use /killtps start to artificially slow down the server tick", + "create.command.killTPSCommand.argument.tickTime": "tickTime", + "create.contraption.minecart_contraption_too_big": "This Cart Contraption seems too big to pick up", + "create.gui.chromatic_projector.title": "Chromatic Projector", + "create.gui.chromatic_projector.filter.invert": "Invert", + "create.gui.chromatic_projector.filter.sepia": "Sepia", + "create.gui.chromatic_projector.filter.grayscale": "Grayscale", + "create.gui.chromatic_projector.filter.saturate": "Saturate", + "create.gui.chromatic_projector.filter.hue_shift": "Hue shift", + "create.gui.chromatic_projector.filter.end": "End", + "create.gui.chromatic_projector.filter": "Filter", + "_": "->------------------------] Subtitles [------------------------<-", + "create.subtitle.cogs": "Cogwheels rumble", + "create.subtitle.slime_added": "Slime squishes", + "create.subtitle.mixing": "Mixing Noises", + "create.subtitle.mechanical_press_activation_belt": "Mechanical Press bonks", + "create.subtitle.blockzapper_confirm": "Affirmative ding", + "create.subtitle.depot_slide": "Item slides", "create.subtitle.blockzapper_place": "Blockzapper zaps", "create.subtitle.blaze_munch": "Blaze Burner munches", "create.subtitle.schematicannon_launch_block": "Schematicannon fires", @@ -2127,4 +2131,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/de_de.json b/src/generated/resources/assets/create/lang/unfinished/de_de.json index cf3ae191f..fb6675930 100644 --- a/src/generated/resources/assets/create/lang/unfinished/de_de.json +++ b/src/generated/resources/assets/create/lang/unfinished/de_de.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 921", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "Akazienholzfenster", - "block.create.acacia_window_pane": "Akazienholzfensterscheibe", - "block.create.adjustable_chain_gearshift": "Verstellbares Kettengetriebe", - "block.create.adjustable_crate": "Verstellbare Kiste", - "block.create.adjustable_pulse_repeater": "Verstellbarer Pulsverstärker", - "block.create.adjustable_repeater": "Verstellbarer Verstärker", - "block.create.analog_lever": "Analoger Schalter", + "_": "Missing Localizations: 922", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "Akazienholzfenster", + "block.create.acacia_window_pane": "Akazienholzfensterscheibe", + "block.create.adjustable_chain_gearshift": "Verstellbares Kettengetriebe", + "block.create.adjustable_crate": "Verstellbare Kiste", + "block.create.adjustable_pulse_repeater": "Verstellbarer Pulsverstärker", + "block.create.adjustable_repeater": "Verstellbarer Verstärker", + "block.create.analog_lever": "Analoger Schalter", "block.create.andesite_belt_funnel": "Riementrichter aus Andesit", "block.create.andesite_bricks": "Andesitziegel", "block.create.andesite_bricks_slab": "Andesitziegelstufe", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "Messingtrichter", "block.create.brass_tunnel": "Messingtunnel", "block.create.brown_sail": "Braunes Segel", - "block.create.brown_seat": "Brauner Sitz", - "block.create.brown_valve_handle": "Brauner Ventilgriff", - "block.create.cart_assembler": "Lorenmonteur", - "block.create.chiseled_dark_scoria": "Gemeißelte dunkle Schlacke", - "block.create.chiseled_dolomite": "Gemeißeltes Dolomit", - "block.create.chiseled_gabbro": "Gemeißeltes Gabbro", - "block.create.chiseled_limestone": "Gemeißelter Kalkstein", - "block.create.chiseled_scoria": "Gemeißelte Schlacke", - "block.create.chiseled_weathered_limestone": "Gemeißelter verwitterter Kalkstein", - "block.create.chocolate": "Schokolade", - "block.create.chute": "Rinne", - "block.create.clockwork_bearing": "Uhrwerk-Lager", - "block.create.clutch": "Kupplung", - "block.create.cogwheel": "Zahnrad", - "block.create.content_observer": "Inhaltsbeobachter", - "block.create.controller_rail": "Steuerungsschiene", - "block.create.copper_block": "Kupfer Block", - "block.create.copper_casing": "Kupferrahmen", - "block.create.copper_ore": "Kupfererz", - "block.create.copper_shingles": "Kupferschindeln", + "block.create.brown_seat": "Brauner Sitz", + "block.create.brown_valve_handle": "Brauner Ventilgriff", + "block.create.cart_assembler": "Lorenmonteur", + "block.create.chiseled_dark_scoria": "Gemeißelte dunkle Schlacke", + "block.create.chiseled_dolomite": "Gemeißeltes Dolomit", + "block.create.chiseled_gabbro": "Gemeißeltes Gabbro", + "block.create.chiseled_limestone": "Gemeißelter Kalkstein", + "block.create.chiseled_scoria": "Gemeißelte Schlacke", + "block.create.chiseled_weathered_limestone": "Gemeißelter verwitterter Kalkstein", + "block.create.chocolate": "Schokolade", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "Rinne", + "block.create.clockwork_bearing": "Uhrwerk-Lager", + "block.create.clutch": "Kupplung", + "block.create.cogwheel": "Zahnrad", + "block.create.content_observer": "Inhaltsbeobachter", + "block.create.controller_rail": "Steuerungsschiene", + "block.create.copper_block": "Kupfer Block", + "block.create.copper_casing": "Kupferrahmen", + "block.create.copper_ore": "Kupfererz", + "block.create.copper_shingles": "Kupferschindeln", "block.create.copper_tiles": "Kupferfliesen", "block.create.copper_valve_handle": "Kupfer Ventilgriff", "block.create.creative_crate": "Kreative anpassbare Kiste", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/es_es.json b/src/generated/resources/assets/create/lang/unfinished/es_es.json index 6b9899146..646282bd2 100644 --- a/src/generated/resources/assets/create/lang/unfinished/es_es.json +++ b/src/generated/resources/assets/create/lang/unfinished/es_es.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 614", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "Ventana de acacia", - "block.create.acacia_window_pane": "Panel de ventana de acacia", - "block.create.adjustable_chain_gearshift": "Cadena de transmisión ajustable", - "block.create.adjustable_crate": "Caja ajustable", - "block.create.adjustable_pulse_repeater": "Repetidor de pulso ajustable", - "block.create.adjustable_repeater": "Repetidor ajustable", - "block.create.analog_lever": "Palanca analógica", + "_": "Missing Localizations: 615", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "Ventana de acacia", + "block.create.acacia_window_pane": "Panel de ventana de acacia", + "block.create.adjustable_chain_gearshift": "Cadena de transmisión ajustable", + "block.create.adjustable_crate": "Caja ajustable", + "block.create.adjustable_pulse_repeater": "Repetidor de pulso ajustable", + "block.create.adjustable_repeater": "Repetidor ajustable", + "block.create.analog_lever": "Palanca analógica", "block.create.andesite_belt_funnel": "Embudo de cinta de andesita", "block.create.andesite_bricks": "Ladrillos de andesita", "block.create.andesite_bricks_slab": "Losa de ladrillos de andesita", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "Embudo de latón", "block.create.brass_tunnel": "Túnel de latón", "block.create.brown_sail": "Vela marrón", - "block.create.brown_seat": "Asiento marrón", - "block.create.brown_valve_handle": "Asa de válvula marrón", - "block.create.cart_assembler": "Ensamblador de vagonetas", - "block.create.chiseled_dark_scoria": "Escoria oscura cincelada", - "block.create.chiseled_dolomite": "Dolomita cincelada", - "block.create.chiseled_gabbro": "Gabro cincelado", - "block.create.chiseled_limestone": "Caliza cincelada", - "block.create.chiseled_scoria": "Escoria cincelada", - "block.create.chiseled_weathered_limestone": "Piedra caliza erosionada cincelada", - "block.create.chocolate": "Chocolate", - "block.create.chute": "Ducto", - "block.create.clockwork_bearing": "Rodamiento de reloj", - "block.create.clutch": "Embrague", - "block.create.cogwheel": "Rueda dentada", - "block.create.content_observer": "Observador de contenidos", - "block.create.controller_rail": "Raíl de control", - "block.create.copper_block": "Bloque de cobre", - "block.create.copper_casing": "Revestidor de caliza", - "block.create.copper_ore": "Mineral de cobre", - "block.create.copper_shingles": "Bloque de tejas de cobre", + "block.create.brown_seat": "Asiento marrón", + "block.create.brown_valve_handle": "Asa de válvula marrón", + "block.create.cart_assembler": "Ensamblador de vagonetas", + "block.create.chiseled_dark_scoria": "Escoria oscura cincelada", + "block.create.chiseled_dolomite": "Dolomita cincelada", + "block.create.chiseled_gabbro": "Gabro cincelado", + "block.create.chiseled_limestone": "Caliza cincelada", + "block.create.chiseled_scoria": "Escoria cincelada", + "block.create.chiseled_weathered_limestone": "Piedra caliza erosionada cincelada", + "block.create.chocolate": "Chocolate", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "Ducto", + "block.create.clockwork_bearing": "Rodamiento de reloj", + "block.create.clutch": "Embrague", + "block.create.cogwheel": "Rueda dentada", + "block.create.content_observer": "Observador de contenidos", + "block.create.controller_rail": "Raíl de control", + "block.create.copper_block": "Bloque de cobre", + "block.create.copper_casing": "Revestidor de caliza", + "block.create.copper_ore": "Mineral de cobre", + "block.create.copper_shingles": "Bloque de tejas de cobre", "block.create.copper_tiles": "Bloque de baldosas de cobre", "block.create.copper_valve_handle": "Asa de válvula de cobre", "block.create.creative_crate": "Caja creativa", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/es_mx.json b/src/generated/resources/assets/create/lang/unfinished/es_mx.json index 76705092c..93c20ff29 100644 --- a/src/generated/resources/assets/create/lang/unfinished/es_mx.json +++ b/src/generated/resources/assets/create/lang/unfinished/es_mx.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 1272", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "Ventana de Acacia", - "block.create.acacia_window_pane": "Panel de Ventana de Acacia", - "block.create.adjustable_chain_gearshift": "Cambio Ajustable de Velocidad de Cadena", - "block.create.adjustable_crate": "Caja Ajustable", - "block.create.adjustable_pulse_repeater": "Repetidor de Pulso Ajustable", - "block.create.adjustable_repeater": "Repetidor Ajustable", - "block.create.analog_lever": "Palanca Analogica", + "_": "Missing Localizations: 1273", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "Ventana de Acacia", + "block.create.acacia_window_pane": "Panel de Ventana de Acacia", + "block.create.adjustable_chain_gearshift": "Cambio Ajustable de Velocidad de Cadena", + "block.create.adjustable_crate": "Caja Ajustable", + "block.create.adjustable_pulse_repeater": "Repetidor de Pulso Ajustable", + "block.create.adjustable_repeater": "Repetidor Ajustable", + "block.create.analog_lever": "Palanca Analogica", "block.create.andesite_belt_funnel": "UNLOCALIZED: Andesite Belt Funnel", "block.create.andesite_bricks": "Ladrillos de Andesita", "block.create.andesite_bricks_slab": "Losa de Ladrillos de Andesita", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "Embudo de Latón", "block.create.brass_tunnel": "Túnel de Latón", "block.create.brown_sail": "Vela Café", - "block.create.brown_seat": "Asiento Café ", - "block.create.brown_valve_handle": "Manija de Válvula Café", - "block.create.cart_assembler": "Ensamblador de Vagonetas", - "block.create.chiseled_dark_scoria": "Escoria Oscura Grabada", - "block.create.chiseled_dolomite": "Dolomita Grabada", - "block.create.chiseled_gabbro": "Gabro Grabado", - "block.create.chiseled_limestone": "Caliza Grabada", - "block.create.chiseled_scoria": "Escoria Grabada", - "block.create.chiseled_weathered_limestone": "Caliza Meteorizada Grabada", - "block.create.chocolate": "Chocolate", - "block.create.chute": "Vertedor", - "block.create.clockwork_bearing": "Rodamiento de Reloj", - "block.create.clutch": "Embrague", - "block.create.cogwheel": "Rueda Dentada", - "block.create.content_observer": "Observador de Contenido", - "block.create.controller_rail": "Vía de Control", - "block.create.copper_block": "Bloque de Cobre", - "block.create.copper_casing": "Carcasa de Cobre", - "block.create.copper_ore": "Mineral de Cobre", - "block.create.copper_shingles": "Techado de Cobre", + "block.create.brown_seat": "Asiento Café ", + "block.create.brown_valve_handle": "Manija de Válvula Café", + "block.create.cart_assembler": "Ensamblador de Vagonetas", + "block.create.chiseled_dark_scoria": "Escoria Oscura Grabada", + "block.create.chiseled_dolomite": "Dolomita Grabada", + "block.create.chiseled_gabbro": "Gabro Grabado", + "block.create.chiseled_limestone": "Caliza Grabada", + "block.create.chiseled_scoria": "Escoria Grabada", + "block.create.chiseled_weathered_limestone": "Caliza Meteorizada Grabada", + "block.create.chocolate": "Chocolate", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "Vertedor", + "block.create.clockwork_bearing": "Rodamiento de Reloj", + "block.create.clutch": "Embrague", + "block.create.cogwheel": "Rueda Dentada", + "block.create.content_observer": "Observador de Contenido", + "block.create.controller_rail": "Vía de Control", + "block.create.copper_block": "Bloque de Cobre", + "block.create.copper_casing": "Carcasa de Cobre", + "block.create.copper_ore": "Mineral de Cobre", + "block.create.copper_shingles": "Techado de Cobre", "block.create.copper_tiles": "Baldosas de Cobre", "block.create.copper_valve_handle": "Manija de Válvula de Cobre", "block.create.creative_crate": "Caja del Creativo", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/fr_fr.json b/src/generated/resources/assets/create/lang/unfinished/fr_fr.json index 7de31748c..19ed662fb 100644 --- a/src/generated/resources/assets/create/lang/unfinished/fr_fr.json +++ b/src/generated/resources/assets/create/lang/unfinished/fr_fr.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 1171", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "Fenêtre en acacia", - "block.create.acacia_window_pane": "Vitre en acacia", - "block.create.adjustable_chain_gearshift": "UNLOCALIZED: Adjustable Chain Gearshift", - "block.create.adjustable_crate": "Caisse ajustable", - "block.create.adjustable_pulse_repeater": "Répéteur d'impulsions réglable", - "block.create.adjustable_repeater": "Répéteur réglable", - "block.create.analog_lever": "Levier analogique", + "_": "Missing Localizations: 1172", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "Fenêtre en acacia", + "block.create.acacia_window_pane": "Vitre en acacia", + "block.create.adjustable_chain_gearshift": "UNLOCALIZED: Adjustable Chain Gearshift", + "block.create.adjustable_crate": "Caisse ajustable", + "block.create.adjustable_pulse_repeater": "Répéteur d'impulsions réglable", + "block.create.adjustable_repeater": "Répéteur réglable", + "block.create.analog_lever": "Levier analogique", "block.create.andesite_belt_funnel": "Entonnoir en andésite pour tapis roulant", "block.create.andesite_bricks": "Briques d'andésite", "block.create.andesite_bricks_slab": "Dalle en briques d'andésite", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "Entonnoir en laiton", "block.create.brass_tunnel": "Tunnel en laiton", "block.create.brown_sail": "Voile brune", - "block.create.brown_seat": "Siège brun", - "block.create.brown_valve_handle": "Vanne brune", - "block.create.cart_assembler": "Assembleur de wagon", - "block.create.chiseled_dark_scoria": "Scoria sombre taillé", - "block.create.chiseled_dolomite": "Dolomite taillée", - "block.create.chiseled_gabbro": "Gabbro taillé", - "block.create.chiseled_limestone": "Calcaire taillé", - "block.create.chiseled_scoria": "Scoria taillé", - "block.create.chiseled_weathered_limestone": "Calcaire altéré taillé", - "block.create.chocolate": "Chocolat", - "block.create.chute": "Glissière", - "block.create.clockwork_bearing": "Roulement mécanique horloger", - "block.create.clutch": "Embrayage", - "block.create.cogwheel": "Roue dentée", - "block.create.content_observer": "Observateur de contenu", - "block.create.controller_rail": "Rails controlleurs", - "block.create.copper_block": "Bloc de cuivre", - "block.create.copper_casing": "Revêtement en cuivre", - "block.create.copper_ore": "Minerai de cuivre", - "block.create.copper_shingles": "Bardeaux de cuivre", + "block.create.brown_seat": "Siège brun", + "block.create.brown_valve_handle": "Vanne brune", + "block.create.cart_assembler": "Assembleur de wagon", + "block.create.chiseled_dark_scoria": "Scoria sombre taillé", + "block.create.chiseled_dolomite": "Dolomite taillée", + "block.create.chiseled_gabbro": "Gabbro taillé", + "block.create.chiseled_limestone": "Calcaire taillé", + "block.create.chiseled_scoria": "Scoria taillé", + "block.create.chiseled_weathered_limestone": "Calcaire altéré taillé", + "block.create.chocolate": "Chocolat", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "Glissière", + "block.create.clockwork_bearing": "Roulement mécanique horloger", + "block.create.clutch": "Embrayage", + "block.create.cogwheel": "Roue dentée", + "block.create.content_observer": "Observateur de contenu", + "block.create.controller_rail": "Rails controlleurs", + "block.create.copper_block": "Bloc de cuivre", + "block.create.copper_casing": "Revêtement en cuivre", + "block.create.copper_ore": "Minerai de cuivre", + "block.create.copper_shingles": "Bardeaux de cuivre", "block.create.copper_tiles": "Tuiles en cuivre", "block.create.copper_valve_handle": "Vanne en cuivre", "block.create.creative_crate": "Créateur de schémacanon", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/it_it.json b/src/generated/resources/assets/create/lang/unfinished/it_it.json index c306ac7a8..dd82ebb1b 100644 --- a/src/generated/resources/assets/create/lang/unfinished/it_it.json +++ b/src/generated/resources/assets/create/lang/unfinished/it_it.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 631", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "Finestra di acacia", - "block.create.acacia_window_pane": "Pannello di finestra di acacia", - "block.create.adjustable_chain_gearshift": "Cambio a catena regolabile", - "block.create.adjustable_crate": "Baule regolabile", - "block.create.adjustable_pulse_repeater": "Ripetitore di impulsi regolabile", - "block.create.adjustable_repeater": "Ripetitore regolabile", - "block.create.analog_lever": "Leva analogica", + "_": "Missing Localizations: 632", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "Finestra di acacia", + "block.create.acacia_window_pane": "Pannello di finestra di acacia", + "block.create.adjustable_chain_gearshift": "Cambio a catena regolabile", + "block.create.adjustable_crate": "Baule regolabile", + "block.create.adjustable_pulse_repeater": "Ripetitore di impulsi regolabile", + "block.create.adjustable_repeater": "Ripetitore regolabile", + "block.create.analog_lever": "Leva analogica", "block.create.andesite_belt_funnel": "Imbuto per nastro di andesite", "block.create.andesite_bricks": "Mattoni di andesite", "block.create.andesite_bricks_slab": "Lastra di mattoni di andesite", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "Imbuto di ottone", "block.create.brass_tunnel": "Tunnel di ottone", "block.create.brown_sail": "Vela marrone", - "block.create.brown_seat": "Sedile marrone", - "block.create.brown_valve_handle": "Maniglia per valvola marrone", - "block.create.cart_assembler": "Assemblatore di carrelli da miniera", - "block.create.chiseled_dark_scoria": "Scoria scura cesellata", - "block.create.chiseled_dolomite": "Dolomite cesellata", - "block.create.chiseled_gabbro": "Gabbro cesellato", - "block.create.chiseled_limestone": "Calcare cesellato", - "block.create.chiseled_scoria": "Scoria cesellata", - "block.create.chiseled_weathered_limestone": "Calcare consumato cesellato", - "block.create.chocolate": "Cioccolato", - "block.create.chute": "Scivolo", - "block.create.clockwork_bearing": "Supporto dell'orologio", - "block.create.clutch": "Frizione", - "block.create.cogwheel": "Ruota dentata", - "block.create.content_observer": "Osservatore dei contenuti", - "block.create.controller_rail": "Binario di controllo", - "block.create.copper_block": "Blocco di rame", - "block.create.copper_casing": "Involucro di rame", - "block.create.copper_ore": "Rame grezzo", - "block.create.copper_shingles": "Tegole di rame", + "block.create.brown_seat": "Sedile marrone", + "block.create.brown_valve_handle": "Maniglia per valvola marrone", + "block.create.cart_assembler": "Assemblatore di carrelli da miniera", + "block.create.chiseled_dark_scoria": "Scoria scura cesellata", + "block.create.chiseled_dolomite": "Dolomite cesellata", + "block.create.chiseled_gabbro": "Gabbro cesellato", + "block.create.chiseled_limestone": "Calcare cesellato", + "block.create.chiseled_scoria": "Scoria cesellata", + "block.create.chiseled_weathered_limestone": "Calcare consumato cesellato", + "block.create.chocolate": "Cioccolato", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "Scivolo", + "block.create.clockwork_bearing": "Supporto dell'orologio", + "block.create.clutch": "Frizione", + "block.create.cogwheel": "Ruota dentata", + "block.create.content_observer": "Osservatore dei contenuti", + "block.create.controller_rail": "Binario di controllo", + "block.create.copper_block": "Blocco di rame", + "block.create.copper_casing": "Involucro di rame", + "block.create.copper_ore": "Rame grezzo", + "block.create.copper_shingles": "Tegole di rame", "block.create.copper_tiles": "Piastrelle di rame", "block.create.copper_valve_handle": "Maniglia per valvola di rame", "block.create.creative_crate": "Creatore cannoneschematico", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/ja_jp.json b/src/generated/resources/assets/create/lang/unfinished/ja_jp.json index 1847cbfab..f8f15797b 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ja_jp.json +++ b/src/generated/resources/assets/create/lang/unfinished/ja_jp.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 613", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "アカシアの窓", - "block.create.acacia_window_pane": "アカシアの窓パネル", - "block.create.adjustable_chain_gearshift": "可変チェーンギアシフト", - "block.create.adjustable_crate": "可変クレート", - "block.create.adjustable_pulse_repeater": "可変パルスリピーター", - "block.create.adjustable_repeater": "可変リピーター", - "block.create.analog_lever": "アナログレバー", + "_": "Missing Localizations: 614", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "アカシアの窓", + "block.create.acacia_window_pane": "アカシアの窓パネル", + "block.create.adjustable_chain_gearshift": "可変チェーンギアシフト", + "block.create.adjustable_crate": "可変クレート", + "block.create.adjustable_pulse_repeater": "可変パルスリピーター", + "block.create.adjustable_repeater": "可変リピーター", + "block.create.analog_lever": "アナログレバー", "block.create.andesite_belt_funnel": "安山岩のベルトファンネル", "block.create.andesite_bricks": "安山岩レンガ", "block.create.andesite_bricks_slab": "安山岩レンガのハーフブロック", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "真鍮ファンネル", "block.create.brass_tunnel": "真鍮トンネル", "block.create.brown_sail": "茶色の帆", - "block.create.brown_seat": "茶色のシート", - "block.create.brown_valve_handle": "茶色のバルブハンドル", - "block.create.cart_assembler": "トロッコアセンブラ", - "block.create.chiseled_dark_scoria": "模様入りのダークスコリア", - "block.create.chiseled_dolomite": "模様入りの苦灰岩", - "block.create.chiseled_gabbro": "模様入りの斑れい岩", - "block.create.chiseled_limestone": "模様入りの石灰岩", - "block.create.chiseled_scoria": "模様入りのスコリア", - "block.create.chiseled_weathered_limestone": "模様入りの風化した石灰岩", - "block.create.chocolate": "チョコレート", - "block.create.chute": "シュート", - "block.create.clockwork_bearing": "時計仕掛けのベアリング", - "block.create.clutch": "クラッチ", - "block.create.cogwheel": "歯車", - "block.create.content_observer": "コンテンツオブザーバー", - "block.create.controller_rail": "コントローラーレール", - "block.create.copper_block": "銅ブロック", - "block.create.copper_casing": "銅ケーシング", - "block.create.copper_ore": "銅鉱石", - "block.create.copper_shingles": "銅の屋根板", + "block.create.brown_seat": "茶色のシート", + "block.create.brown_valve_handle": "茶色のバルブハンドル", + "block.create.cart_assembler": "トロッコアセンブラ", + "block.create.chiseled_dark_scoria": "模様入りのダークスコリア", + "block.create.chiseled_dolomite": "模様入りの苦灰岩", + "block.create.chiseled_gabbro": "模様入りの斑れい岩", + "block.create.chiseled_limestone": "模様入りの石灰岩", + "block.create.chiseled_scoria": "模様入りのスコリア", + "block.create.chiseled_weathered_limestone": "模様入りの風化した石灰岩", + "block.create.chocolate": "チョコレート", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "シュート", + "block.create.clockwork_bearing": "時計仕掛けのベアリング", + "block.create.clutch": "クラッチ", + "block.create.cogwheel": "歯車", + "block.create.content_observer": "コンテンツオブザーバー", + "block.create.controller_rail": "コントローラーレール", + "block.create.copper_block": "銅ブロック", + "block.create.copper_casing": "銅ケーシング", + "block.create.copper_ore": "銅鉱石", + "block.create.copper_shingles": "銅の屋根板", "block.create.copper_tiles": "銅のタイル", "block.create.copper_valve_handle": "銅のバルブハンドル", "block.create.creative_crate": "クリエティブクレート", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/ko_kr.json b/src/generated/resources/assets/create/lang/unfinished/ko_kr.json index 560628b7e..b6b7e0670 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ko_kr.json +++ b/src/generated/resources/assets/create/lang/unfinished/ko_kr.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 684", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "아카시아 유리창", - "block.create.acacia_window_pane": "아카시아나무 유리판 ", - "block.create.adjustable_chain_gearshift": "벨트 변속기", - "block.create.adjustable_crate": "가변 창고", - "block.create.adjustable_pulse_repeater": "가변 펄스 리피터", - "block.create.adjustable_repeater": "가변 리피터", - "block.create.analog_lever": "아날로그 레버", + "_": "Missing Localizations: 685", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "아카시아 유리창", + "block.create.acacia_window_pane": "아카시아나무 유리판 ", + "block.create.adjustable_chain_gearshift": "벨트 변속기", + "block.create.adjustable_crate": "가변 창고", + "block.create.adjustable_pulse_repeater": "가변 펄스 리피터", + "block.create.adjustable_repeater": "가변 리피터", + "block.create.analog_lever": "아날로그 레버", "block.create.andesite_belt_funnel": "안산암 깔때기", "block.create.andesite_bricks": "안산암 벽돌", "block.create.andesite_bricks_slab": "안산암 벽돌 반 블록", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "황동 깔때기", "block.create.brass_tunnel": "황동 터널", "block.create.brown_sail": "갈색 날개", - "block.create.brown_seat": "갈색 좌석", - "block.create.brown_valve_handle": "갈색 밸브 손잡이", - "block.create.cart_assembler": "카트 조립기", - "block.create.chiseled_dark_scoria": "조각된 짙은 스코리아", - "block.create.chiseled_dolomite": "조각된 백운암", - "block.create.chiseled_gabbro": "조각된 반려암", - "block.create.chiseled_limestone": "조각된 석회암", - "block.create.chiseled_scoria": "조각된 스코리아", - "block.create.chiseled_weathered_limestone": "조각된 풍화된 석회암", - "block.create.chocolate": "초콜릿", - "block.create.chute": "슈트", - "block.create.clockwork_bearing": "시계 베어링", - "block.create.clutch": "클러치", - "block.create.cogwheel": "톱니바퀴", - "block.create.content_observer": "정보 감지기", - "block.create.controller_rail": "방향 레일", - "block.create.copper_block": "구리 블록", - "block.create.copper_casing": "구리 케이스", - "block.create.copper_ore": "구리 광석", - "block.create.copper_shingles": "구리 판자", + "block.create.brown_seat": "갈색 좌석", + "block.create.brown_valve_handle": "갈색 밸브 손잡이", + "block.create.cart_assembler": "카트 조립기", + "block.create.chiseled_dark_scoria": "조각된 짙은 스코리아", + "block.create.chiseled_dolomite": "조각된 백운암", + "block.create.chiseled_gabbro": "조각된 반려암", + "block.create.chiseled_limestone": "조각된 석회암", + "block.create.chiseled_scoria": "조각된 스코리아", + "block.create.chiseled_weathered_limestone": "조각된 풍화된 석회암", + "block.create.chocolate": "초콜릿", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "슈트", + "block.create.clockwork_bearing": "시계 베어링", + "block.create.clutch": "클러치", + "block.create.cogwheel": "톱니바퀴", + "block.create.content_observer": "정보 감지기", + "block.create.controller_rail": "방향 레일", + "block.create.copper_block": "구리 블록", + "block.create.copper_casing": "구리 케이스", + "block.create.copper_ore": "구리 광석", + "block.create.copper_shingles": "구리 판자", "block.create.copper_tiles": "구리 타일", "block.create.copper_valve_handle": "구리 밸브 손잡이", "block.create.creative_crate": "크리에이티브 창고", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/nl_nl.json b/src/generated/resources/assets/create/lang/unfinished/nl_nl.json index fd213b6f6..738fd4845 100644 --- a/src/generated/resources/assets/create/lang/unfinished/nl_nl.json +++ b/src/generated/resources/assets/create/lang/unfinished/nl_nl.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 1561", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "UNLOCALIZED: Acacia Window", - "block.create.acacia_window_pane": "UNLOCALIZED: Acacia Window Pane", - "block.create.adjustable_chain_gearshift": "UNLOCALIZED: Adjustable Chain Gearshift", - "block.create.adjustable_crate": "FlexKrat", - "block.create.adjustable_pulse_repeater": "UNLOCALIZED: Adjustable Pulse Repeater", - "block.create.adjustable_repeater": "FlexSterker", - "block.create.analog_lever": "UNLOCALIZED: Analog Lever", + "_": "Missing Localizations: 1562", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "UNLOCALIZED: Acacia Window", + "block.create.acacia_window_pane": "UNLOCALIZED: Acacia Window Pane", + "block.create.adjustable_chain_gearshift": "UNLOCALIZED: Adjustable Chain Gearshift", + "block.create.adjustable_crate": "FlexKrat", + "block.create.adjustable_pulse_repeater": "UNLOCALIZED: Adjustable Pulse Repeater", + "block.create.adjustable_repeater": "FlexSterker", + "block.create.analog_lever": "UNLOCALIZED: Analog Lever", "block.create.andesite_belt_funnel": "UNLOCALIZED: Andesite Belt Funnel", "block.create.andesite_bricks": "Andesietstenen", "block.create.andesite_bricks_slab": "UNLOCALIZED: Andesite Bricks Slab", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "UNLOCALIZED: Brass Funnel", "block.create.brass_tunnel": "UNLOCALIZED: Brass Tunnel", "block.create.brown_sail": "UNLOCALIZED: Brown Sail", - "block.create.brown_seat": "UNLOCALIZED: Brown Seat", - "block.create.brown_valve_handle": "UNLOCALIZED: Brown Valve Handle", - "block.create.cart_assembler": "Kar Assembler", - "block.create.chiseled_dark_scoria": "UNLOCALIZED: Chiseled Dark Scoria", - "block.create.chiseled_dolomite": "UNLOCALIZED: Chiseled Dolomite", - "block.create.chiseled_gabbro": "UNLOCALIZED: Chiseled Gabbro", - "block.create.chiseled_limestone": "UNLOCALIZED: Chiseled Limestone", - "block.create.chiseled_scoria": "UNLOCALIZED: Chiseled Scoria", - "block.create.chiseled_weathered_limestone": "UNLOCALIZED: Chiseled Weathered Limestone", - "block.create.chocolate": "UNLOCALIZED: Chocolate", - "block.create.chute": "UNLOCALIZED: Chute", - "block.create.clockwork_bearing": "UNLOCALIZED: Clockwork Bearing", - "block.create.clutch": "Koppeling", - "block.create.cogwheel": "Tandwiel", - "block.create.content_observer": "UNLOCALIZED: Content Observer", - "block.create.controller_rail": "UNLOCALIZED: Controller Rail", - "block.create.copper_block": "UNLOCALIZED: Block of Copper", - "block.create.copper_casing": "UNLOCALIZED: Copper Casing", - "block.create.copper_ore": "UNLOCALIZED: Copper Ore", - "block.create.copper_shingles": "UNLOCALIZED: Copper Shingles", + "block.create.brown_seat": "UNLOCALIZED: Brown Seat", + "block.create.brown_valve_handle": "UNLOCALIZED: Brown Valve Handle", + "block.create.cart_assembler": "Kar Assembler", + "block.create.chiseled_dark_scoria": "UNLOCALIZED: Chiseled Dark Scoria", + "block.create.chiseled_dolomite": "UNLOCALIZED: Chiseled Dolomite", + "block.create.chiseled_gabbro": "UNLOCALIZED: Chiseled Gabbro", + "block.create.chiseled_limestone": "UNLOCALIZED: Chiseled Limestone", + "block.create.chiseled_scoria": "UNLOCALIZED: Chiseled Scoria", + "block.create.chiseled_weathered_limestone": "UNLOCALIZED: Chiseled Weathered Limestone", + "block.create.chocolate": "UNLOCALIZED: Chocolate", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "UNLOCALIZED: Chute", + "block.create.clockwork_bearing": "UNLOCALIZED: Clockwork Bearing", + "block.create.clutch": "Koppeling", + "block.create.cogwheel": "Tandwiel", + "block.create.content_observer": "UNLOCALIZED: Content Observer", + "block.create.controller_rail": "UNLOCALIZED: Controller Rail", + "block.create.copper_block": "UNLOCALIZED: Block of Copper", + "block.create.copper_casing": "UNLOCALIZED: Copper Casing", + "block.create.copper_ore": "UNLOCALIZED: Copper Ore", + "block.create.copper_shingles": "UNLOCALIZED: Copper Shingles", "block.create.copper_tiles": "UNLOCALIZED: Copper Tiles", "block.create.copper_valve_handle": "UNLOCALIZED: Copper Valve Handle", "block.create.creative_crate": "Bouwtekeningkannon Creatiefeerder", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/pt_br.json b/src/generated/resources/assets/create/lang/unfinished/pt_br.json index d29401108..c51acbd2e 100644 --- a/src/generated/resources/assets/create/lang/unfinished/pt_br.json +++ b/src/generated/resources/assets/create/lang/unfinished/pt_br.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 1615", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "UNLOCALIZED: Acacia Window", - "block.create.acacia_window_pane": "UNLOCALIZED: Acacia Window Pane", - "block.create.adjustable_chain_gearshift": "UNLOCALIZED: Adjustable Chain Gearshift", - "block.create.adjustable_crate": "adjustable_crate", - "block.create.adjustable_pulse_repeater": "UNLOCALIZED: Adjustable Pulse Repeater", - "block.create.adjustable_repeater": "Repetidor Flex", - "block.create.analog_lever": "UNLOCALIZED: Analog Lever", + "_": "Missing Localizations: 1616", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "UNLOCALIZED: Acacia Window", + "block.create.acacia_window_pane": "UNLOCALIZED: Acacia Window Pane", + "block.create.adjustable_chain_gearshift": "UNLOCALIZED: Adjustable Chain Gearshift", + "block.create.adjustable_crate": "adjustable_crate", + "block.create.adjustable_pulse_repeater": "UNLOCALIZED: Adjustable Pulse Repeater", + "block.create.adjustable_repeater": "Repetidor Flex", + "block.create.analog_lever": "UNLOCALIZED: Analog Lever", "block.create.andesite_belt_funnel": "UNLOCALIZED: Andesite Belt Funnel", "block.create.andesite_bricks": "Tijolos de Andesite", "block.create.andesite_bricks_slab": "UNLOCALIZED: Andesite Bricks Slab", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "UNLOCALIZED: Brass Funnel", "block.create.brass_tunnel": "UNLOCALIZED: Brass Tunnel", "block.create.brown_sail": "UNLOCALIZED: Brown Sail", - "block.create.brown_seat": "UNLOCALIZED: Brown Seat", - "block.create.brown_valve_handle": "UNLOCALIZED: Brown Valve Handle", - "block.create.cart_assembler": "UNLOCALIZED: Cart Assembler", - "block.create.chiseled_dark_scoria": "UNLOCALIZED: Chiseled Dark Scoria", - "block.create.chiseled_dolomite": "UNLOCALIZED: Chiseled Dolomite", - "block.create.chiseled_gabbro": "UNLOCALIZED: Chiseled Gabbro", - "block.create.chiseled_limestone": "UNLOCALIZED: Chiseled Limestone", - "block.create.chiseled_scoria": "UNLOCALIZED: Chiseled Scoria", - "block.create.chiseled_weathered_limestone": "UNLOCALIZED: Chiseled Weathered Limestone", - "block.create.chocolate": "UNLOCALIZED: Chocolate", - "block.create.chute": "UNLOCALIZED: Chute", - "block.create.clockwork_bearing": "UNLOCALIZED: Clockwork Bearing", - "block.create.clutch": "Embreagem", - "block.create.cogwheel": "Roda Dentada", - "block.create.content_observer": "UNLOCALIZED: Content Observer", - "block.create.controller_rail": "UNLOCALIZED: Controller Rail", - "block.create.copper_block": "UNLOCALIZED: Block of Copper", - "block.create.copper_casing": "UNLOCALIZED: Copper Casing", - "block.create.copper_ore": "UNLOCALIZED: Copper Ore", - "block.create.copper_shingles": "UNLOCALIZED: Copper Shingles", + "block.create.brown_seat": "UNLOCALIZED: Brown Seat", + "block.create.brown_valve_handle": "UNLOCALIZED: Brown Valve Handle", + "block.create.cart_assembler": "UNLOCALIZED: Cart Assembler", + "block.create.chiseled_dark_scoria": "UNLOCALIZED: Chiseled Dark Scoria", + "block.create.chiseled_dolomite": "UNLOCALIZED: Chiseled Dolomite", + "block.create.chiseled_gabbro": "UNLOCALIZED: Chiseled Gabbro", + "block.create.chiseled_limestone": "UNLOCALIZED: Chiseled Limestone", + "block.create.chiseled_scoria": "UNLOCALIZED: Chiseled Scoria", + "block.create.chiseled_weathered_limestone": "UNLOCALIZED: Chiseled Weathered Limestone", + "block.create.chocolate": "UNLOCALIZED: Chocolate", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "UNLOCALIZED: Chute", + "block.create.clockwork_bearing": "UNLOCALIZED: Clockwork Bearing", + "block.create.clutch": "Embreagem", + "block.create.cogwheel": "Roda Dentada", + "block.create.content_observer": "UNLOCALIZED: Content Observer", + "block.create.controller_rail": "UNLOCALIZED: Controller Rail", + "block.create.copper_block": "UNLOCALIZED: Block of Copper", + "block.create.copper_casing": "UNLOCALIZED: Copper Casing", + "block.create.copper_ore": "UNLOCALIZED: Copper Ore", + "block.create.copper_shingles": "UNLOCALIZED: Copper Shingles", "block.create.copper_tiles": "UNLOCALIZED: Copper Tiles", "block.create.copper_valve_handle": "UNLOCALIZED: Copper Valve Handle", "block.create.creative_crate": "Criativador Esquemaannon", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/ru_ru.json b/src/generated/resources/assets/create/lang/unfinished/ru_ru.json index 4e61e7a7c..d3caf4c2b 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ru_ru.json +++ b/src/generated/resources/assets/create/lang/unfinished/ru_ru.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 528", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "Акациевое окно", - "block.create.acacia_window_pane": "Панель из акациевого окна", - "block.create.adjustable_chain_gearshift": "Регулируемый цепной механизм", - "block.create.adjustable_crate": "Регулируемый ящик", - "block.create.adjustable_pulse_repeater": "Регулируемый импульсный повторитель", - "block.create.adjustable_repeater": "Регулируемый повторитель", - "block.create.analog_lever": "Аналоговый рычаг", + "_": "Missing Localizations: 529", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "Акациевое окно", + "block.create.acacia_window_pane": "Панель из акациевого окна", + "block.create.adjustable_chain_gearshift": "Регулируемый цепной механизм", + "block.create.adjustable_crate": "Регулируемый ящик", + "block.create.adjustable_pulse_repeater": "Регулируемый импульсный повторитель", + "block.create.adjustable_repeater": "Регулируемый повторитель", + "block.create.analog_lever": "Аналоговый рычаг", "block.create.andesite_belt_funnel": "Андезитовая конвейерная воронка", "block.create.andesite_bricks": "Андезитовый кирпич", "block.create.andesite_bricks_slab": "Плита из андезитового кирпича", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "Латунная воронка", "block.create.brass_tunnel": "Латунный туннель", "block.create.brown_sail": "Коричневый парус", - "block.create.brown_seat": "Коричневое сиденье", - "block.create.brown_valve_handle": "Коричневый ручной вентиль", - "block.create.cart_assembler": "Сборщик вагонеток", - "block.create.chiseled_dark_scoria": "Резной тёмный пепел", - "block.create.chiseled_dolomite": "Резной доломит", - "block.create.chiseled_gabbro": "Резной габбро", - "block.create.chiseled_limestone": "Резной известняк", - "block.create.chiseled_scoria": "Резной пепел", - "block.create.chiseled_weathered_limestone": "Выветренный резной известняк", - "block.create.chocolate": "Шоколад", - "block.create.chute": "Желоб", - "block.create.clockwork_bearing": "Часовой механизм", - "block.create.clutch": "Сцепление", - "block.create.cogwheel": "Шестерня", - "block.create.content_observer": "Наблюдетель за содержимым", - "block.create.controller_rail": "Контролирующая рельса", - "block.create.copper_block": "Медный блок", - "block.create.copper_casing": "Медный корпус", - "block.create.copper_ore": "Медная руда", - "block.create.copper_shingles": "Медная черепица", + "block.create.brown_seat": "Коричневое сиденье", + "block.create.brown_valve_handle": "Коричневый ручной вентиль", + "block.create.cart_assembler": "Сборщик вагонеток", + "block.create.chiseled_dark_scoria": "Резной тёмный пепел", + "block.create.chiseled_dolomite": "Резной доломит", + "block.create.chiseled_gabbro": "Резной габбро", + "block.create.chiseled_limestone": "Резной известняк", + "block.create.chiseled_scoria": "Резной пепел", + "block.create.chiseled_weathered_limestone": "Выветренный резной известняк", + "block.create.chocolate": "Шоколад", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "Желоб", + "block.create.clockwork_bearing": "Часовой механизм", + "block.create.clutch": "Сцепление", + "block.create.cogwheel": "Шестерня", + "block.create.content_observer": "Наблюдетель за содержимым", + "block.create.controller_rail": "Контролирующая рельса", + "block.create.copper_block": "Медный блок", + "block.create.copper_casing": "Медный корпус", + "block.create.copper_ore": "Медная руда", + "block.create.copper_shingles": "Медная черепица", "block.create.copper_tiles": "Медная плитка", "block.create.copper_valve_handle": "Медный ручной вентиль", "block.create.creative_crate": "Творческий ящик", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/zh_cn.json b/src/generated/resources/assets/create/lang/unfinished/zh_cn.json index ef0da1165..3d8a6dfa9 100644 --- a/src/generated/resources/assets/create/lang/unfinished/zh_cn.json +++ b/src/generated/resources/assets/create/lang/unfinished/zh_cn.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 628", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "金合欢窗户", - "block.create.acacia_window_pane": "金合欢窗户板", - "block.create.adjustable_chain_gearshift": "可调节链式传动箱", - "block.create.adjustable_crate": "可调节板条箱", - "block.create.adjustable_pulse_repeater": "可调节脉冲中继器", - "block.create.adjustable_repeater": "可调节中继器", - "block.create.analog_lever": "可调节拉杆", + "_": "Missing Localizations: 629", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "金合欢窗户", + "block.create.acacia_window_pane": "金合欢窗户板", + "block.create.adjustable_chain_gearshift": "可调节链式传动箱", + "block.create.adjustable_crate": "可调节板条箱", + "block.create.adjustable_pulse_repeater": "可调节脉冲中继器", + "block.create.adjustable_repeater": "可调节中继器", + "block.create.analog_lever": "可调节拉杆", "block.create.andesite_belt_funnel": "安山岩传送带漏斗", "block.create.andesite_bricks": "安山岩砖", "block.create.andesite_bricks_slab": "安山岩砖台阶", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "黄铜漏斗", "block.create.brass_tunnel": "黄铜隧道", "block.create.brown_sail": "棕色风帆", - "block.create.brown_seat": "棕色坐垫", - "block.create.brown_valve_handle": "棕色阀门手轮", - "block.create.cart_assembler": "矿车装配站", - "block.create.chiseled_dark_scoria": "錾制深色熔渣", - "block.create.chiseled_dolomite": "錾制白云岩", - "block.create.chiseled_gabbro": "錾制辉长岩", - "block.create.chiseled_limestone": "錾制石灰岩", - "block.create.chiseled_scoria": "錾制熔渣", - "block.create.chiseled_weathered_limestone": "錾制风化石灰岩", - "block.create.chocolate": "巧克力", - "block.create.chute": "溜槽", - "block.create.clockwork_bearing": "时钟轴承", - "block.create.clutch": "离合器", - "block.create.cogwheel": "齿轮", - "block.create.content_observer": "物品侦测器", - "block.create.controller_rail": "控制铁轨", - "block.create.copper_block": "铜块", - "block.create.copper_casing": "铜机壳", - "block.create.copper_ore": "铜矿石", - "block.create.copper_shingles": "铜砖块", + "block.create.brown_seat": "棕色坐垫", + "block.create.brown_valve_handle": "棕色阀门手轮", + "block.create.cart_assembler": "矿车装配站", + "block.create.chiseled_dark_scoria": "錾制深色熔渣", + "block.create.chiseled_dolomite": "錾制白云岩", + "block.create.chiseled_gabbro": "錾制辉长岩", + "block.create.chiseled_limestone": "錾制石灰岩", + "block.create.chiseled_scoria": "錾制熔渣", + "block.create.chiseled_weathered_limestone": "錾制风化石灰岩", + "block.create.chocolate": "巧克力", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "溜槽", + "block.create.clockwork_bearing": "时钟轴承", + "block.create.clutch": "离合器", + "block.create.cogwheel": "齿轮", + "block.create.content_observer": "物品侦测器", + "block.create.controller_rail": "控制铁轨", + "block.create.copper_block": "铜块", + "block.create.copper_casing": "铜机壳", + "block.create.copper_ore": "铜矿石", + "block.create.copper_shingles": "铜砖块", "block.create.copper_tiles": "铜砖块", "block.create.copper_valve_handle": "铜阀门手轮", "block.create.creative_crate": "创造板条箱", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json index e7fb6b633..9858e48e2 100644 --- a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json +++ b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json @@ -1,15 +1,13 @@ { - "_": "Missing Localizations: 633", - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "相思木窗戶", - "block.create.acacia_window_pane": "相思木窗戶片", - "block.create.adjustable_chain_gearshift": "可調式鏈式變速箱", - "block.create.adjustable_crate": "可調式板條箱", - "block.create.adjustable_pulse_repeater": "可調式脈衝中繼器", - "block.create.adjustable_repeater": "可調式中繼器", - "block.create.analog_lever": "可調式拉桿", + "_": "Missing Localizations: 634", + "_": "->------------------------] Game Elements [------------------------<-", + "block.create.acacia_window": "相思木窗戶", + "block.create.acacia_window_pane": "相思木窗戶片", + "block.create.adjustable_chain_gearshift": "可調式鏈式變速箱", + "block.create.adjustable_crate": "可調式板條箱", + "block.create.adjustable_pulse_repeater": "可調式脈衝中繼器", + "block.create.adjustable_repeater": "可調式中繼器", + "block.create.analog_lever": "可調式拉桿", "block.create.andesite_belt_funnel": "安山岩輸送帶漏斗", "block.create.andesite_bricks": "安山岩磚", "block.create.andesite_bricks_slab": "安山岩半磚", @@ -42,26 +40,27 @@ "block.create.brass_funnel": "黃銅漏斗", "block.create.brass_tunnel": "黃銅物品隧道", "block.create.brown_sail": "棕色風帆", - "block.create.brown_seat": "棕色坐墊", - "block.create.brown_valve_handle": "棕色閥門開關", - "block.create.cart_assembler": "礦車裝修站", - "block.create.chiseled_dark_scoria": "鏨製黑火成岩", - "block.create.chiseled_dolomite": "鏨製白雲石", - "block.create.chiseled_gabbro": "鏨製輝長岩", - "block.create.chiseled_limestone": "鏨製石灰岩", - "block.create.chiseled_scoria": "鏨製火成岩", - "block.create.chiseled_weathered_limestone": "鏨製風化石灰岩", - "block.create.chocolate": "巧克力", - "block.create.chute": "滑道", - "block.create.clockwork_bearing": "時鐘軸承", - "block.create.clutch": "離合器", - "block.create.cogwheel": "齒輪", - "block.create.content_observer": "物品偵測器", - "block.create.controller_rail": "控制鐵軌", - "block.create.copper_block": "銅磚", - "block.create.copper_casing": "銅機殼", - "block.create.copper_ore": "銅礦石", - "block.create.copper_shingles": "塊狀銅磚", + "block.create.brown_seat": "棕色坐墊", + "block.create.brown_valve_handle": "棕色閥門開關", + "block.create.cart_assembler": "礦車裝修站", + "block.create.chiseled_dark_scoria": "鏨製黑火成岩", + "block.create.chiseled_dolomite": "鏨製白雲石", + "block.create.chiseled_gabbro": "鏨製輝長岩", + "block.create.chiseled_limestone": "鏨製石灰岩", + "block.create.chiseled_scoria": "鏨製火成岩", + "block.create.chiseled_weathered_limestone": "鏨製風化石灰岩", + "block.create.chocolate": "巧克力", + "block.create.chromatic_projector": "UNLOCALIZED: Chromatic Projector", + "block.create.chute": "滑道", + "block.create.clockwork_bearing": "時鐘軸承", + "block.create.clutch": "離合器", + "block.create.cogwheel": "齒輪", + "block.create.content_observer": "物品偵測器", + "block.create.controller_rail": "控制鐵軌", + "block.create.copper_block": "銅磚", + "block.create.copper_casing": "銅機殼", + "block.create.copper_ore": "銅礦石", + "block.create.copper_shingles": "塊狀銅磚", "block.create.copper_tiles": "菱形銅磚", "block.create.copper_valve_handle": "銅製閥門開關", "block.create.creative_crate": "創造板條箱", @@ -2128,4 +2127,4 @@ "_": "Thank you for translating Create!" -} \ No newline at end of file +} diff --git a/src/main/java/com/simibubi/create/AllContainerTypes.java b/src/main/java/com/simibubi/create/AllContainerTypes.java index d17d0ffce..f7ea37a0c 100644 --- a/src/main/java/com/simibubi/create/AllContainerTypes.java +++ b/src/main/java/com/simibubi/create/AllContainerTypes.java @@ -1,7 +1,5 @@ package com.simibubi.create; -import com.simibubi.create.content.curiosities.projector.ChromaticProjectorContainer; -import com.simibubi.create.content.curiosities.projector.ChromaticProjectorScreen; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateContainer; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateScreen; import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer; @@ -34,7 +32,6 @@ public enum AllContainerTypes { FLEXCRATE(AdjustableCrateContainer::new), FILTER(FilterContainer::new), ATTRIBUTE_FILTER(AttributeFilterContainer::new), - CHROMATIC_PROJECTOR(ChromaticProjectorContainer::new), ; @@ -61,7 +58,6 @@ public enum AllContainerTypes { bind(FLEXCRATE, AdjustableCrateScreen::new); bind(FILTER, FilterScreen::new); bind(ATTRIBUTE_FILTER, AttributeFilterScreen::new); - bind(CHROMATIC_PROJECTOR, ChromaticProjectorScreen::new); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java index 0ae33f6b2..86b6ebeec 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java @@ -2,13 +2,16 @@ package com.simibubi.create.content.curiosities.projector; import javax.annotation.Nullable; +import com.simibubi.create.AllItems; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.gui.ScreenOpener; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; @@ -16,7 +19,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.DistExecutor; public class ChromaticProjectorBlock extends Block implements ITE { public ChromaticProjectorBlock(Properties p_i48440_1_) { @@ -26,14 +31,21 @@ public class ChromaticProjectorBlock extends Block implements ITE NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, + () -> () -> withTileEntityDo(worldIn, pos, te -> this.displayScreen(te, player))); return ActionResultType.SUCCESS; } + @OnlyIn(value = Dist.CLIENT) + protected void displayScreen(ChromaticProjectorTileEntity te, PlayerEntity player) { + if (player instanceof ClientPlayerEntity) + ScreenOpener.open(new ChromaticProjectorScreen(te)); + } + @Override public boolean hasTileEntity(BlockState state) { return true; diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorContainer.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorContainer.java deleted file mode 100644 index bfe6444ee..000000000 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorContainer.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.simibubi.create.content.curiosities.projector; - -import javax.annotation.Nullable; - -import com.simibubi.create.AllContainerTypes; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.network.PacketBuffer; - -public class ChromaticProjectorContainer extends Container { - - public ChromaticProjectorContainer(int id, PlayerInventory inv, PacketBuffer extraData) { - super(AllContainerTypes.CHROMATIC_PROJECTOR.type, id); - - - } - - public ChromaticProjectorContainer(int id, PlayerInventory inv, ChromaticProjectorTileEntity te) { - super(AllContainerTypes.CHROMATIC_PROJECTOR.type, id); - } - - public ChromaticProjectorContainer(@Nullable ContainerType p_i50105_1_, int p_i50105_2_) { - super(p_i50105_1_, p_i50105_2_); - } - - @Override - public boolean canInteractWith(PlayerEntity p_75145_1_) { - return true; - } -} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java index 0c5652339..1c74cf804 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java @@ -1,62 +1,186 @@ package com.simibubi.create.content.curiosities.projector; -import java.util.ArrayList; -import java.util.Collections; +import java.util.Vector; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.gui.AbstractSimiScreen; import com.simibubi.create.foundation.gui.AllGuiTextures; +import com.simibubi.create.foundation.gui.AllIcons; +import com.simibubi.create.foundation.gui.GuiGameElement; +import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; +import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.ListNBT; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; -public class ChromaticProjectorScreen extends AbstractSimiContainerScreen { +public class ChromaticProjectorScreen extends AbstractSimiScreen { - private ScrollInput filter; - private ScrollInput radius; - private ScrollInput feather; - private ScrollInput fade; + public static final int MAX_STEPS = 4; - public ChromaticProjectorScreen(ChromaticProjectorContainer container, PlayerInventory inv, ITextComponent title) { - super(container, inv, title); + private final ItemStack renderedItem = AllBlocks.CHROMATIC_PROJECTOR.asStack(); + private final AllGuiTextures background = AllGuiTextures.PROJECTOR; + private IconButton confirmButton; + + private final ITextComponent title = Lang.translate("gui.chromatic_projector.title"); + private ListNBT compareTag; + private Vector stages; + private BlockPos pos; + + private Vector> inputs; + + public ChromaticProjectorScreen(ChromaticProjectorTileEntity te) { + this.stages = te.stages; + this.pos = te.getPos(); + //compareTag = Instruction.serializeAll(stages); } @Override protected void init() { + setWindowSize(background.width + 50, background.height); super.init(); - widgets.clear(); - int x = guiLeft + 11; - int y = guiTop + 20; + inputs = new Vector<>(MAX_STEPS); + for (int row = 0; row < inputs.capacity(); row++) + inputs.add(new Vector<>(2)); - ArrayList filterOptions = new ArrayList<>(); + for (int row = 0; row < stages.size(); row++) + initInputsOfRow(row); - filterOptions.add(new StringTextComponent("Test")); - filterOptions.add(new StringTextComponent("Test1")); + confirmButton = + new IconButton(guiLeft + background.width - 33, guiTop + background.height - 24, AllIcons.I_CONFIRM); + widgets.add(confirmButton); + } - filter = new SelectionScrollInput(x, y, 77, 18) - .forOptions(filterOptions); - y += 20; - radius = new ScrollInput(x, y, 30, 20); - y += 20; - feather = new ScrollInput(x, y, 30, 20); - y += 20; - fade = new ScrollInput(x, y, 30, 20); - y += 20; - Collections.addAll(widgets, filter, radius, feather, fade); + public void initInputsOfRow(int row) { + int x = guiLeft + 30; + int y = guiTop + 18; + int rowHeight = 22; + Vector rowInputs = inputs.get(row); + rowInputs.forEach(widgets::remove); + rowInputs.clear(); + int index = row; + FilterStep instruction = stages.get(row); + + ScrollInput type = + new SelectionScrollInput(x, y + rowHeight * row, 86, 18).forOptions(ColorEffects.getOptions()) + .calling(state -> instructionUpdated(index, state)) + .setState(instruction.instruction.ordinal()) + .titled(Lang.translate("gui.chromatic_projector.filter")); + ScrollInput value = + new ScrollInput(x + 86 + 2, y + rowHeight * row, 28, 18).calling(state -> instruction.value = state); + + rowInputs.add(type); + rowInputs.add(value); + + widgets.addAll(rowInputs); + updateParamsOfRow(row); + } + + public void updateParamsOfRow(int row) { + FilterStep instruction = stages.get(row); + Vector rowInputs = inputs.get(row); + ColorEffects def = instruction.instruction; + boolean hasValue = def.hasParameter; + + ScrollInput value = rowInputs.get(1); + value.active = value.visible = hasValue; + if (hasValue) + value.withRange(0, 100) + //.titled(Lang.translate(def.parameterKey)) + //.withShiftStep(def.shiftStep) + .setState(instruction.value) + .onChanged(); + + value.withStepFunction(value.standardStep()); } @Override protected void renderWindow(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - //AllGuiTextures.PLAYER_INVENTORY.draw(matrixStack, this, guiLeft - 10, guiTop + 145); - AllGuiTextures.PROJECTOR.draw(matrixStack, this, guiLeft, guiTop); -// BG_TOP.draw(matrixStack, this, guiLeft + 20, guiTop); -// BG_BOTTOM.draw(matrixStack, this, guiLeft + 20, guiTop + BG_TOP.height); + int hFontColor = 0xD3CBBE; + background.draw(matrixStack, this, guiLeft, guiTop); + for (int row = 0; row < stages.capacity(); row++) { + AllGuiTextures toDraw = AllGuiTextures.PROJECTOR_EMPTY; + int yOffset = toDraw.height * row; + if (row >= stages.size()) { + toDraw.draw(matrixStack, guiLeft, guiTop + 14 + yOffset); + continue; + } + + FilterStep instruction = stages.get(row); + ColorEffects def = instruction.instruction; + def.background.draw(matrixStack, guiLeft, guiTop + 14 + yOffset); + + label(matrixStack, 36, yOffset - 3, Lang.translate(def.translationKey)); + if (def.hasParameter) { + String text = instruction.value + " %"; + int stringWidth = textRenderer.getStringWidth(text); + label(matrixStack, 118 + (12 - stringWidth / 2), yOffset - 3, new StringTextComponent(text)); + } + } + + textRenderer.drawWithShadow(matrixStack, title, guiLeft - 3 + (background.width - textRenderer.getWidth(title)) / 2, guiTop + 3, + 0xffffff); + + GuiGameElement.of(renderedItem) + .at(guiLeft + background.width + 10, guiTop + 100, -150) + .scale(5) + .render(matrixStack); } + + private void label(MatrixStack matrixStack, int x, int y, ITextComponent text) { + textRenderer.drawWithShadow(matrixStack, text, guiLeft + x, guiTop + 26 + y, 0xFFFFEE); + } + + public void sendPacket() { +// ListNBT serialized = Instruction.serializeAll(stages); +// if (serialized.equals(compareTag)) +// return; +// AllPackets.channel.sendToServer(new ConfigureSequencedGearshiftPacket(pos, serialized)); + } + + @Override + public void removed() { + sendPacket(); + } + + private void instructionUpdated(int index, int state) { + ColorEffects newValue = ColorEffects.values()[state]; + stages.get(index).instruction = newValue; + stages.get(index).value = 100; + updateParamsOfRow(index); + if (newValue == ColorEffects.END) { + for (int i = stages.size() - 1; i > index; i--) { + stages.remove(i); + Vector rowInputs = inputs.get(i); + rowInputs.forEach(widgets::remove); + rowInputs.clear(); + } + } else { + if (index + 1 < stages.capacity() && index + 1 == stages.size()) { + stages.add(new FilterStep(ColorEffects.END)); + initInputsOfRow(index + 1); + } + } + } + + @Override + public boolean mouseClicked(double x, double y, int button) { + if (confirmButton.isHovered()) { + Minecraft.getInstance().player.closeScreen(); + return true; + } + + return super.mouseClicked(x, y, button); + } + } diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java index d7d9974ff..79b20d45c 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java @@ -1,40 +1,15 @@ package com.simibubi.create.content.curiosities.projector; -import javax.annotation.Nullable; +import java.util.Vector; -import com.simibubi.create.foundation.render.backend.effects.SphereFilterProgram; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -public class ChromaticProjectorTileEntity extends TileEntity implements INamedContainerProvider { +public class ChromaticProjectorTileEntity extends TileEntity { - SphereFilterProgram.FilterSphere filter; + Vector stages = FilterStep.createDefault(); public ChromaticProjectorTileEntity(TileEntityType te) { super(te); } - - public void sendToContainer(PacketBuffer buffer) { - buffer.writeBlockPos(getPos()); - buffer.writeCompoundTag(getUpdateTag()); - } - - @Override - public ITextComponent getDisplayName() { - return new StringTextComponent("Chromatic Projector"); - } - - @Nullable - @Override - public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) { - return new ChromaticProjectorContainer(p_createMenu_1_, p_createMenu_2_, this); - } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java new file mode 100644 index 000000000..abddf5773 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java @@ -0,0 +1,59 @@ +package com.simibubi.create.content.curiosities.projector; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + +import com.simibubi.create.foundation.gui.AllGuiTextures; +import com.simibubi.create.foundation.render.backend.effects.ColorMatrices; +import com.simibubi.create.foundation.utility.Lang; + +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.text.ITextComponent; + +public enum ColorEffects { + INVERT(ColorMatrices::invert), + SEPIA(ColorMatrices::sepia), + GRAYSCALE(ColorMatrices::grayscale), + SATURATE(ColorMatrices::saturate), + HUE_SHIFT(ColorMatrices::hueShift), + END(ColorMatrices::identity, AllGuiTextures.PROJECTOR_END), + + ; + + FilterFactory filter; + boolean hasParameter; + String translationKey; + AllGuiTextures background; + + ColorEffects(Supplier filter, AllGuiTextures background) { + this($ -> filter.get(), false, background); + } + + ColorEffects(Supplier filter) { + this($ -> filter.get(), false, AllGuiTextures.PROJECTOR_FILTER); + } + + ColorEffects(FilterFactory filter) { + this(filter, true, AllGuiTextures.PROJECTOR_FILTER_STRENGTH); + } + + ColorEffects(FilterFactory filter, boolean hasParameter, AllGuiTextures background) { + this.filter = filter; + this.hasParameter = hasParameter; + this.background = background; + translationKey = "gui.chromatic_projector.filter." + Lang.asId(name()); + } + + static List getOptions() { + List options = new ArrayList<>(); + for (ColorEffects entry : values()) + options.add(Lang.translate(entry.translationKey)); + return options; + } + + @FunctionalInterface + public interface FilterFactory { + Matrix4f create(float param); + } +} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java new file mode 100644 index 000000000..576df6c31 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java @@ -0,0 +1,25 @@ +package com.simibubi.create.content.curiosities.projector; + +import java.util.Vector; + +public class FilterStep { + + ColorEffects instruction; + int value; + + public FilterStep(ColorEffects instruction) { + this.instruction = instruction; + } + + public FilterStep(ColorEffects instruction, int value) { + this.instruction = instruction; + this.value = value; + } + + public static Vector createDefault() { + Vector instructions = new Vector<>(ChromaticProjectorScreen.MAX_STEPS); + instructions.add(new FilterStep(ColorEffects.SEPIA, 100)); + instructions.add(new FilterStep(ColorEffects.END)); + return instructions; + } +} diff --git a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java index 3db38433b..49820aaba 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java @@ -56,7 +56,11 @@ public enum AllGuiTextures implements IScreenRenderable { SEQUENCER_EMPTY("sequencer.png", 0, 102, 162, 22), SEQUENCER_AWAIT("sequencer.png", 0, 160, 162, 22), - PROJECTOR("projector.png", 173, 159), + PROJECTOR("projector.png", 173, 194), + PROJECTOR_FILTER_STRENGTH("projector.png", 0, 14, 162, 22), + PROJECTOR_FILTER("projector.png", 0, 36, 162, 22), + PROJECTOR_END("projector.png", 0, 58, 162, 22), + PROJECTOR_EMPTY("projector.png", 0, 80, 162, 22), // JEI JEI_SLOT("jei/widgets.png", 18, 18), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java index 93b2ae186..2bab3cfe0 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java @@ -72,7 +72,7 @@ public class ColorMatrices { } // https://stackoverflow.com/a/8510751 - public static Matrix4f hueShiftRGB(float rot) { + public static Matrix4f hueShift(float rot) { Matrix4f mat = new Matrix4f(); mat.loadIdentity(); @@ -91,4 +91,10 @@ public class ColorMatrices { return mat; } + + public static Matrix4f identity() { + Matrix4f mat = new Matrix4f(); + mat.loadIdentity(); + return mat; + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index 33151d5ce..0252924d1 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -132,18 +132,30 @@ public class EffectsHandler { .setDensity(1.3f) .setFilter(ColorMatrices.grayscale())); - Matrix4f test = ColorMatrices.sepia(1f); + program.addSphere(new SphereFilterProgram.FilterSphere() + .setCenter(new Vector3d(852.5, 70, -203.5).subtract(cameraPos)) + .setRadius(20f) + .setFeather(3f) + .setFade(1f) + .setDensity(1.3f) + .setFilter(ColorMatrices.sepia(1f))); +// Matrix4f test = ColorMatrices.sepia(1f); +// +// +// test.multiply(ColorMatrices.invert()); +// +// Matrix4f darken = new Matrix4f(); +// darken.loadIdentity(); +// darken.multiply(0.7f); +// darken.a03 = 0.7f; +// darken.a13 = 0.7f; +// darken.a23 = 0.7f; +// test.multiply(darken); - test.multiply(ColorMatrices.invert()); + Matrix4f test = ColorMatrices.saturate(2f); - Matrix4f darken = new Matrix4f(); - darken.loadIdentity(); - darken.multiply(0.7f); - darken.a03 = 0.7f; - darken.a13 = 0.7f; - darken.a23 = 0.7f; - test.multiply(darken); + test.multiply(ColorMatrices.hueShift(120f)); program.addSphere(new SphereFilterProgram.FilterSphere() .setCenter(new Vector3d(858.5, 88, -259.5).subtract(cameraPos)) diff --git a/src/main/resources/assets/create/textures/gui/projector.png b/src/main/resources/assets/create/textures/gui/projector.png index f35f17bc65b433efa833d37e70bec3e2d690ce20..b2eaa0404874786d448563f2956a112ca51bc31d 100644 GIT binary patch literal 3095 zcmcgueLRzEAHVj34QWFqDbmn!gu;_EM@@%99ZE(MrsL$bLf(?tq)r^twB)5GPUNi& z8EM#3k(V>2v{-rRk(HSxAvQes@|;iS`RDoXdG3F%`}*GZ@8$Ylzu)(|Qun*;S)r`0 z3;)R%mwENoB<5!xVFA0w% zDsDG*Q#e+0@1DLVPW^W_;-7}5XK6>;i7}DH3%}c8KCd1}oHMwdnHTEz zXr1G_S`5$dx_+cyj^;IDfUx#u*Z8$r%2NH{${fyZAMtqevv{c>ce|^;e&2`ZB^KCr z7Y05n)zMJDFV`aQR&zGzqTu-8#Mst~M9wMc$PT*n=L!1J+(wb^Ymz#4ZnX1Se>Vby z&E&aKN)|L%ceqvb;^(``i}TKtWqz5qvWMCIu17X*dABr`JX@Qu2v!_Ka4F5tPiq59 z8lWodhJ)2wXmH362mF#UA)xNc4Uz+#S|@ANw3KXy$>v{59PCHf_0JD(84PumU{2Ii zq$Basx)o!yfwlt?Ib))}o*p+S+aiwzehBN<=t+K)ZoQP9Fwj;$A4!)8!_0gUw52u{ zSgfrvp?g$h9Y1lRBgoQtA=&BjlORicIrqoQxXkJ4==PfNN8RAezHs6DO@zE#HE~P1 zwcSl-VVs3o8&RwH+BPlKB7wN$PWJ@k6vcSD=(J?Y)k^xH1)sI#+Q-OR(_*%=H}QN% z8LWWEQy$K~5W?A|gr;iSLr^LqI>v*+c=N++y31jEwUwnAV{N)VnPRi%nStgx@ntZc zs}0T=P+boH8Xes$Qn~2E(M|@IKn62&4_6IRUXAqp%;b(4re`!Q?qW*hvWU@1w+Wyl- zFv|?ht#l5Aok)mrz5iz71>!}n>bZcRuW-i{_>@dw@F>j*To_mJvozs@&O}+Q+`=mm z_S?h4D7Md9wF^;;)F9Rt2<*3j8Qoa=Ak%}rdUxD#Xkwz0zebVb2x5BW;hpORS(ZQV zm5iiiXBYED!A&lfDM&w0G17bvwg0G*1A%!1w5L@XVAaeRl(!j>S?aH;{f>7O+j*g2~yEuA>90-nMEo zf8tPzrVafPPZDDD^g%fn`<)@sRr=_CTuJU&9|znY%fXmiw=}4oV#1y~ap1PHjv|X_iIftZ{|LyOMumWR=C&IU}(L^8+_>xEd(1Vbd$aEAM5F@q_>4@ zX7X7yM^IYs2G?qnCCSFJeb!#weHoW3n{;a6pifPHs*#B+c5X#Mg+eWF%vbOu4h3W` zvs84ClIH?U>k;c&l?sl}Kfgc56@=X&4)ihVIzlgQfT-xrM_X&DF2;W5wDLy1sJr*c zJ7IHLE)^@Mv{E7ENd&r}-Rrd}n!CY6A;U3o395t+D8zr^s8k2>u_;9ShdcH_@L;=~ z;?nC1n8|twdcx#=-%`%qyyu-3VNzH&<(VlVs|>}naUkA35PtuZupp6Ro4{g1`+gw= zjw+mbv_DP!p(4TOgc7s?*cZRV&xeq+A%4{fNY<ivpbevh%^+3c-~V$F*!*hOmmE8`-n@bXrs%?@ z5C|WT{TY`0Mb(Mrv;D;2=lQftTX}G~mj|S;9l2bbe|KM4vw@n{|Cf4dGj%CZ4t1O_ zUQP5XcZ32Z-~Qs~s~bMibvvgR6dFi}gn;WHu66M6^lY+pTb5G0s0lZz@FO==aEyH4 z8E)Qj3{HE9aJu~H@K3?9W97*=yXzuqb{4jbZv}(3HqlQQ?Qa(!<$OSzYhP@%x)M`T znFr3)U3_e(;*X6_BE2@3**Obj>`>xv~ihfy^cl;-KRi``r-l;g!>85$%5v5UG}rVX znh=RW71A%@Q8X~VEen!o?#xUb|F@or*F;6w;8$yJ_|wyEsKUq#{kbL+uIah?=qD`D z=2@vgApJ+OACO!YxT^v9@B-DlBG~IMzxIl-VPY4b;>yLhfxd#@kbc>H$ne==m4>Cy z#is*Rss||ZZWBAs6fXYg2!<`@0~v~qXjD9-IceM(`&lE_G|38 zE~Fq%0UE#pHfU?TO#^c@$5wIZT1<&rg9YjJ4J``>$U$4%z|5g9G~nDb@nU1FVVYFK z-w+ZNbDSY9{gGW` zY(8e51uT`4F!;FAWbls5CACgHc%Qtd~g24N~$*b zyqY@rc91NW?YB#Y2R`;XE;W7k&6~E<#6{oENkP<}t0 zZ<3nw>so)%!ez6`2Q`vnVq$9ZmEd=)t2bWK-8nO3Gdc7CVJ3J`d(dc5fpA+3x+Jv% zU{X~~m%wF%=T+8>CZ^xHvxP(=MSMJFZl(y_>sTx+e)p_&As4|7{}Su;T=!^88No~o zV9ts7%uXd;*?xO_=rAt|?$8^8wE;{zpUKH=Z>${--`s*@wQdD^o0(+Jj`=*hf;d$W z^t!)4@AjQLSsXL*$dsfDc?Q4-WCjOWp3<7A=C9-Iq&WKWyC(}389A(`GsJpua zb4CM=agm>`lBx067447HU3|xfD)CE?7&ft^iK;r6kkp2EHjN@4r@A`g^EBPa)jnt4 zkR}3zbjE&so0*8`tWX6xoe}F9yf7sM7`-a_7?pU~8ig|Qjyi+IbHZ={naq>uBEVUK zkpEy0aIayp3>FeO)omqH(#L@6?BU^Y=uad4Gf3!)i2zkxIdgS5{ZH?oZNg&XX2x^J x=yr!Heb~1aG@qI;T5sOC$RPymhRI)kktM+Z?Cx`QwD*iFSYfwk6ohCg3TAG6qq#@@ z0#aq7;7D}F63%1q#C4ZU)v>vn2Z~Tt)!ZnlA}q$o$rz=ey3ZB)>aL5s_Q@run!i%D za?0fPntm099UMcQ3~R2;sFE<&%AFjK#BFO#PC-zp z)#+_gVe1})pfFR+3Tc%~9Z?E`aI|Q{Wwd0p->8qN8P|pmu4qyL}2GvEi3(=sQQm{h`J)9;*OoG(JOQz&(d+5IN z@@B0G+jGXqYgG`>CTU^-M+$g+zjcM#AA%V;)aA`LqxR_Jy}10P=rhIb2U}7wWDb6M zN5DeV>_${P>N^Raw6w-=71TXYCM3;Dmdwc6oIxq5Y~4P4^5Jm# z%J)M9`4+TjpCu{8Cet0(nu($JMub8qnxiegrsaEof!=uh5TH=9cN^}PZLgI;Lcw=F zug%C6Ct?E+<(&@;{Pwru3oYU|Wr{{q)6@UpGVf~2RY!O#(UhvMEQPnMGY|VrP5vZu zBHZNAWWsrSTz>EQ+Km{5Y?4Q)@(o_A~qUQz-t;Axxi@*x2 z=5hMYLWC#b^E&@w$v?n(db)kgyEtJ$d+MpV1vM@Ukr0`!q+!%qL~8xX#_zyFzb#xJ z<~o?*PQUAJ^EU}4xJN>ur9U0I2CU*Ke<@i+7Cb}O?BzQsGe(bP6^(xn91K?b%^zb@ z%Tn}?^I?N)if+NmgdT|pBclGtg+Tx>3urpy61fqtL6A}z+E*JoAJyB+n2Oh5rm>N< zJUL}?EF>}%q>LW)JD_J(YNP9sj&HdC@ynFlaq+84bQTt47hs0)QgT&MzE}N`stPtJ z?$u{ftSp2{B_Ak0_eey4DoTTScz@8zkmvbHhqbodvOc9r7AMTkACXfQ&qEeokAgF{ zqE3+sw_v(>NG~l=p>KZ{_BPzG%tfxO_Lg26Oy|GAC@8uO$y9Fgw%#A1!i5d$GVu@pZ27!gkY5b4k=h_tl0SFYR3$tAycSftP|_lzOSXYNCK{tsbM z-}gtTz~XlI{KVAMl)L5a)i|tIrC)mGvU3_c#?*S_Yr{}=l>e49UG1dM zZcJCVnTfH}+Tq)j*NcpKY-&!umS=EOlu7u@7OM$<=jQUbqA1q#^$5oT;UsuILAE`YVXQ3)xkMy(Kh4m{sW!vr>>|HxXl%^flnyU#7-*2$Y*MFKe8NA@AmU3j zC>6ZQCw8r~XkVgGR4TQmtt}k&6?q(#bTQJ9=Nj-Yc)ai%g(J7>fXB~iNE}bb*7f*x z7kSPI--gXG#-9~#p_4h@U|%U~mX&`%!GGN63wSN?c(x*hMg%{ABb6%&0Jw(DcQL@h~(AQ}U@&20t!+V2Ji2Bfr^<|_sr zZIBZ|klCJBiaWhtVr7!1A;9(z!`OmGh62520NKJJW@tcsZUrH(-QeJUf!UcMWCBCr z*)HG;)X8V%#sjSj(GpQA$r}ygpTw;`C=wOu{Hj2Q*MX12H{)j0<#}gE$LY4D!&d@J v`Zb9ycUt$TzgoCA(nFQsH~zOz0YV1NI#gl)%*1oyJ(H`Gn`7lM!Vmuf017q! From 3879d555172c0caa5bd2c0df250cdb63f0cb0b59 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 22 Apr 2021 23:42:49 -0700 Subject: [PATCH 013/198] Better projector gui --- .../resources/assets/create/lang/en_us.json | 1 + .../com/simibubi/create/AllTileEntities.java | 29 ++--- .../projector/ChromaticProjectorBlock.java | 2 +- .../projector/ChromaticProjectorInstance.java | 28 +++++ .../projector/ChromaticProjectorScreen.java | 82 ++++++++++--- .../ChromaticProjectorTileEntity.java | 52 ++++++++- .../curiosities/projector/ColorEffects.java | 26 ++++- .../curiosities/projector/FilterStep.java | 33 +++++- .../render/backend/effects/ColorMatrices.java | 10 ++ .../backend/effects/EffectsHandler.java | 108 +++++------------- .../backend/effects/SphereFilterProgram.java | 46 ++++---- .../create/flywheel/shaders/area_effect.frag | 47 +++----- .../create/flywheel/shaders/area_effect.vert | 7 +- .../assets/create/textures/gui/projector.png | Bin 3095 -> 3086 bytes 14 files changed, 300 insertions(+), 171 deletions(-) create mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index e5aa55e81..b266bf403 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -1153,6 +1153,7 @@ "create.gui.chromatic_projector.filter.grayscale": "Grayscale", "create.gui.chromatic_projector.filter.saturate": "Saturate", "create.gui.chromatic_projector.filter.hue_shift": "Hue shift", + "create.gui.chromatic_projector.filter.darken": "Darken", "create.gui.chromatic_projector.filter.end": "End", "create.gui.chromatic_projector.filter": "Filter", "_": "->------------------------] Subtitles [------------------------<-", diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index d654be591..9369fa6f1 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -116,6 +116,7 @@ import com.simibubi.create.content.contraptions.relays.gearbox.GearboxInstance; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxRenderer; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity; import com.simibubi.create.content.contraptions.relays.gearbox.GearshiftTileEntity; +import com.simibubi.create.content.curiosities.projector.ChromaticProjectorInstance; import com.simibubi.create.content.curiosities.projector.ChromaticProjectorTileEntity; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelInstance; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelRenderer; @@ -646,21 +647,23 @@ public class AllTileEntities { .instance(() -> AdjustableRepeaterInstance::new) .validBlocks(AllBlocks.ADJUSTABLE_REPEATER) .renderer(() -> AdjustableRepeaterRenderer::new) - .register(); + .register(); public static final TileEntityEntry ADJUSTABLE_PULSE_REPEATER = - Create.registrate() - .tileEntity("adjustable_pulse_repeater", AdjustablePulseRepeaterTileEntity::new) - .instance(() -> AdjustableRepeaterInstance::new) - .validBlocks(AllBlocks.ADJUSTABLE_PULSE_REPEATER) - .renderer(() -> AdjustableRepeaterRenderer::new) - .register(); + Create.registrate() + .tileEntity("adjustable_pulse_repeater", AdjustablePulseRepeaterTileEntity::new) + .instance(() -> AdjustableRepeaterInstance::new) + .validBlocks(AllBlocks.ADJUSTABLE_PULSE_REPEATER) + .renderer(() -> AdjustableRepeaterRenderer::new) + .register(); - public static final TileEntityEntry TESTFX = - Create.registrate() - .tileEntity("chromatic_projector", ChromaticProjectorTileEntity::new) - .validBlocks(AllBlocks.CHROMATIC_PROJECTOR) - .register(); + public static final TileEntityEntry CHROMATIC_PROJECTOR = + Create.registrate() + .tileEntity("chromatic_projector", ChromaticProjectorTileEntity::new) + .instance(() -> ChromaticProjectorInstance::new) + .validBlocks(AllBlocks.CHROMATIC_PROJECTOR) + .register(); - public static void register() {} + public static void register() { + } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java index 86b6ebeec..28d493cc5 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorBlock.java @@ -54,7 +54,7 @@ public class ChromaticProjectorBlock extends Block implements ITE implements IDynamicInstance { + + public ChromaticProjectorInstance(InstancedTileRenderer renderer, ChromaticProjectorTileEntity tile) { + super(renderer, tile); + } + + @Override + public void beginFrame() { + Backend.effects.addSphere(tile.makeFilter()); + } + + @Override + public boolean decreaseFramerateWithDistance() { + return false; + } + + @Override + public void remove() { + + } +} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java index 1c74cf804..e7074cb6d 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.curiosities.projector; +import java.util.Collections; import java.util.Vector; import com.mojang.blaze3d.matrix.MatrixStack; @@ -11,6 +12,7 @@ import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; +import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.Minecraft; @@ -35,12 +37,24 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { private Vector> inputs; + ChromaticProjectorTileEntity tile; + + private ScrollInput radius; + private ScrollInput density; + private ScrollInput feather; + private ScrollInput fade; + public ChromaticProjectorScreen(ChromaticProjectorTileEntity te) { + this.tile = te; this.stages = te.stages; this.pos = te.getPos(); //compareTag = Instruction.serializeAll(stages); } + private static Integer step(ScrollValueBehaviour.StepContext ctx, int base) { + return ctx.control ? 1 : base * (ctx.shift ? 5 : 1); + } + @Override protected void init() { setWindowSize(background.width + 50, background.height); @@ -57,6 +71,32 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { confirmButton = new IconButton(guiLeft + background.width - 33, guiTop + background.height - 24, AllIcons.I_CONFIRM); widgets.add(confirmButton); + radius = new ScrollInput(guiLeft + 46, guiTop + 117, 28, 18) + .titled(new StringTextComponent("Radius")) + .withStepFunction(ctx -> step(ctx, 2)) + .calling(tile::setRadius) + .withRange(0, 201) + .setState((int) (tile.radius * 2)); + feather = new ScrollInput(guiLeft + 46, guiTop + 139, 28, 18) + .titled(new StringTextComponent("Feather")) + .withStepFunction(ctx -> step(ctx, 5)) + .calling(tile::setFeather) + .withRange(0, 201) + .setState((int) (tile.feather * 4)); + fade = new ScrollInput(guiLeft + 117, guiTop + 139, 28, 18) + .titled(new StringTextComponent("Fade")) + .withStepFunction(ctx -> step(ctx, 1)) + .calling(tile::setFade) + .withRange(0, 51) + .setState((int) (tile.fade * 10)); + density = new ScrollInput(guiLeft + 117, guiTop + 117, 28, 18) + .titled(new StringTextComponent("Density")) + .withStepFunction(ctx -> step(ctx, 10)) + .calling(tile::setDensity) + .withRange(0, 401) + .setState((int) (tile.density * 100)); + + Collections.addAll(widgets, radius, density, feather, fade); } public void initInputsOfRow(int row) { @@ -73,10 +113,11 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { ScrollInput type = new SelectionScrollInput(x, y + rowHeight * row, 86, 18).forOptions(ColorEffects.getOptions()) .calling(state -> instructionUpdated(index, state)) - .setState(instruction.instruction.ordinal()) + .setState(instruction.filter.ordinal()) .titled(Lang.translate("gui.chromatic_projector.filter")); ScrollInput value = - new ScrollInput(x + 86 + 2, y + rowHeight * row, 28, 18).calling(state -> instruction.value = state); + new ScrollInput(x + 86 + 2, y + rowHeight * row, 28, 18) + .calling(state -> instruction.value = state); rowInputs.add(type); rowInputs.add(value); @@ -88,15 +129,15 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { public void updateParamsOfRow(int row) { FilterStep instruction = stages.get(row); Vector rowInputs = inputs.get(row); - ColorEffects def = instruction.instruction; + ColorEffects def = instruction.filter; boolean hasValue = def.hasParameter; ScrollInput value = rowInputs.get(1); value.active = value.visible = hasValue; if (hasValue) - value.withRange(0, 100) + value.withRange(def.minValue, def.maxValue + 1) //.titled(Lang.translate(def.parameterKey)) - //.withShiftStep(def.shiftStep) + .withShiftStep(5) .setState(instruction.value) .onChanged(); @@ -116,36 +157,47 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { continue; } - FilterStep instruction = stages.get(row); - ColorEffects def = instruction.instruction; + FilterStep step = stages.get(row); + ColorEffects def = step.filter; def.background.draw(matrixStack, guiLeft, guiTop + 14 + yOffset); - label(matrixStack, 36, yOffset - 3, Lang.translate(def.translationKey)); + if (def != ColorEffects.END) + label(matrixStack, 36, yOffset - 3, Lang.translate(def.translationKey)); if (def.hasParameter) { - String text = instruction.value + " %"; + String text = step.filter.formatValue(step.value); int stringWidth = textRenderer.getStringWidth(text); label(matrixStack, 118 + (12 - stringWidth / 2), yOffset - 3, new StringTextComponent(text)); } } + renderScroll(matrixStack, radius, 2f); + renderScroll(matrixStack, density, 100f); + renderScroll(matrixStack, feather, 4f); + renderScroll(matrixStack, fade, 10f); + textRenderer.drawWithShadow(matrixStack, title, guiLeft - 3 + (background.width - textRenderer.getWidth(title)) / 2, guiTop + 3, 0xffffff); GuiGameElement.of(renderedItem) - .at(guiLeft + background.width + 10, guiTop + 100, -150) + .at(guiLeft + background.width + 10, guiTop + 140, -150) .scale(5) .render(matrixStack); } + private void renderScroll(MatrixStack matrixStack, ScrollInput input, float divisor) { + + String text = String.valueOf(input.getState() / divisor); + + int stringWidth = textRenderer.getStringWidth(text); + textRenderer.drawWithShadow(matrixStack, text, input.x + (12 - stringWidth / 2), input.y + 5, 0xFFFFEE); + } + private void label(MatrixStack matrixStack, int x, int y, ITextComponent text) { textRenderer.drawWithShadow(matrixStack, text, guiLeft + x, guiTop + 26 + y, 0xFFFFEE); } public void sendPacket() { -// ListNBT serialized = Instruction.serializeAll(stages); -// if (serialized.equals(compareTag)) -// return; -// AllPackets.channel.sendToServer(new ConfigureSequencedGearshiftPacket(pos, serialized)); + } @Override @@ -155,7 +207,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { private void instructionUpdated(int index, int state) { ColorEffects newValue = ColorEffects.values()[state]; - stages.get(index).instruction = newValue; + stages.get(index).filter = newValue; stages.get(index).value = 100; updateParamsOfRow(index); if (newValue == ColorEffects.END) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java index 79b20d45c..b6f9f4089 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java @@ -2,14 +2,64 @@ package com.simibubi.create.content.curiosities.projector; import java.util.Vector; +import com.simibubi.create.foundation.render.backend.effects.SphereFilterProgram; +import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; + import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Matrix4f; -public class ChromaticProjectorTileEntity extends TileEntity { +public class ChromaticProjectorTileEntity extends TileEntity implements IInstanceRendered { Vector stages = FilterStep.createDefault(); + float radius = 10f; + float density = 1f; + float feather = 3; + float fade = 1.3f; + boolean blend = true; + public ChromaticProjectorTileEntity(TileEntityType te) { super(te); } + + public SphereFilterProgram.FilterSphere makeFilter() { + Matrix4f filter = FilterStep.fold(stages); + + BlockPos pos = getPos(); + return new SphereFilterProgram.FilterSphere() + .setFilter(filter) + .setCenter(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5) + .setRadius(radius) + .setDensity(density) + .setFeather(feather) + .setBlendOver(false) + .setFade(fade); + } + + public ChromaticProjectorTileEntity setRadius(int radius) { + this.radius = radius / 2f; + return this; + } + + public ChromaticProjectorTileEntity setDensity(int density) { + this.density = density / 100f; + return this; + } + + public ChromaticProjectorTileEntity setFeather(int feather) { + this.feather = feather / 4f; + return this; + } + + public ChromaticProjectorTileEntity setFade(int fade) { + this.fade = feather / 10f; + return this; + } + + public ChromaticProjectorTileEntity setBlend(boolean blend) { + this.blend = blend; + return this; + } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java index abddf5773..964af44d0 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java @@ -15,8 +15,9 @@ public enum ColorEffects { INVERT(ColorMatrices::invert), SEPIA(ColorMatrices::sepia), GRAYSCALE(ColorMatrices::grayscale), - SATURATE(ColorMatrices::saturate), - HUE_SHIFT(ColorMatrices::hueShift), + DARKEN(ColorMatrices::darken), + SATURATE(ColorMatrices::saturate, 0, 200), + HUE_SHIFT(ColorMatrices::hueShift, 0, 360, 1f), END(ColorMatrices::identity, AllGuiTextures.PROJECTOR_END), ; @@ -26,6 +27,10 @@ public enum ColorEffects { String translationKey; AllGuiTextures background; + int minValue = 0; + int maxValue = 100; + float divisor = 100f; + ColorEffects(Supplier filter, AllGuiTextures background) { this($ -> filter.get(), false, background); } @@ -35,7 +40,18 @@ public enum ColorEffects { } ColorEffects(FilterFactory filter) { + this(filter, 0, 100); + } + + ColorEffects(FilterFactory filter, int minValue, int maxValue) { + this(filter, minValue, maxValue, 100f); + } + + ColorEffects(FilterFactory filter, int minValue, int maxValue, float divisor) { this(filter, true, AllGuiTextures.PROJECTOR_FILTER_STRENGTH); + this.minValue = minValue; + this.maxValue = maxValue; + this.divisor = divisor; } ColorEffects(FilterFactory filter, boolean hasParameter, AllGuiTextures background) { @@ -45,6 +61,12 @@ public enum ColorEffects { translationKey = "gui.chromatic_projector.filter." + Lang.asId(name()); } + String formatValue(int value) { + if (this == HUE_SHIFT) + return value + Lang.translate("generic.unit.degrees").getString(); + return "" + value; + } + static List getOptions() { List options = new ArrayList<>(); for (ColorEffects entry : values()) diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java index 576df6c31..cb77ed07e 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java @@ -1,21 +1,44 @@ package com.simibubi.create.content.curiosities.projector; +import java.util.Iterator; import java.util.Vector; +import com.simibubi.create.foundation.render.backend.effects.ColorMatrices; + +import net.minecraft.util.math.vector.Matrix4f; + public class FilterStep { - ColorEffects instruction; + ColorEffects filter; int value; - public FilterStep(ColorEffects instruction) { - this.instruction = instruction; + public FilterStep(ColorEffects filter) { + this.filter = filter; } - public FilterStep(ColorEffects instruction, int value) { - this.instruction = instruction; + public FilterStep(ColorEffects filter, int value) { + this.filter = filter; this.value = value; } + public Matrix4f createFilter() { + return filter.filter.create(value / filter.divisor); + } + + public static Matrix4f fold(Vector filters) { + Iterator stepIterator = filters.stream().filter(it -> it != null && it.filter != ColorEffects.END).iterator(); + + if (stepIterator.hasNext()) { + Matrix4f accum = stepIterator.next().createFilter(); + + stepIterator.forEachRemaining(filterStep -> accum.multiply(filterStep.createFilter())); + + return accum; + } + + return ColorMatrices.identity(); + } + public static Vector createDefault() { Vector instructions = new Vector<>(ChromaticProjectorScreen.MAX_STEPS); instructions.add(new FilterStep(ColorEffects.SEPIA, 100)); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java index 2bab3cfe0..99340ea31 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java @@ -92,6 +92,16 @@ public class ColorMatrices { return mat; } + public static Matrix4f darken(float amount) { + Matrix4f darken = new Matrix4f(); + darken.loadIdentity(); + darken.multiply(1f - amount); + darken.a03 = amount; + darken.a13 = amount; + darken.a23 = amount; + return darken; + } + public static Matrix4f identity() { Matrix4f mat = new Matrix4f(); mat.loadIdentity(); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index 0252924d1..f6368c9b5 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -1,5 +1,7 @@ package com.simibubi.create.foundation.render.backend.effects; +import java.util.ArrayList; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; @@ -14,6 +16,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.shader.Framebuffer; import net.minecraft.client.shader.FramebufferConstants; @@ -48,7 +51,11 @@ public class EffectsHandler { private final GlBuffer vbo = new GlBuffer(GL20.GL_ARRAY_BUFFER); + private final ArrayList spheres; + public EffectsHandler() { + spheres = new ArrayList<>(); + Framebuffer render = Minecraft.getInstance().getFramebuffer(); framebuffer = new Framebuffer(render.framebufferWidth, render.framebufferHeight, false, Minecraft.IS_RUNNING_ON_MAC); @@ -64,21 +71,17 @@ public class EffectsHandler { vao.unbind(); vbo.unbind(); + } - public void prepFramebufferSize() { - MainWindow window = Minecraft.getInstance().getWindow(); - if (framebuffer.framebufferWidth != window.getFramebufferWidth() - || framebuffer.framebufferHeight != window.getFramebufferHeight()) { - framebuffer.func_216491_a(window.getFramebufferWidth(), window.getFramebufferHeight(), - Minecraft.IS_RUNNING_ON_MAC); - } + public void addSphere(SphereFilterProgram.FilterSphere sphere) { + this.spheres.add(sphere); } public void render(Matrix4f view) { -// if (true) { -// return; -// } + if (spheres.size() == 0) { + return; + } GL20.glEnable(GL20.GL_DEPTH_TEST); @@ -98,7 +101,8 @@ public class EffectsHandler { program.bindDepthTexture(mainBuffer.getDepthAttachment()); GameRenderer gameRenderer = Minecraft.getInstance().gameRenderer; - Matrix4f projection = gameRenderer.getBasicProjectionMatrix(gameRenderer.getActiveRenderInfo(), AnimationTickHolder.getPartialTicks(), true); + ActiveRenderInfo activeRenderInfo = gameRenderer.getActiveRenderInfo(); + Matrix4f projection = gameRenderer.getBasicProjectionMatrix(activeRenderInfo, AnimationTickHolder.getPartialTicks(), true); projection.a33 = 1; projection.invert(); program.bindInverseProjection(projection); @@ -107,76 +111,17 @@ public class EffectsHandler { inverseView.invert(); program.bindInverseView(inverseView); - Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView(); + Vector3d cameraPos = activeRenderInfo.getProjectedView(); program.setCameraPos(cameraPos.inverse()); -// int n = 64; -// double rad = 15; -// for (int i = 0; i < n; i++) { -// double angle = ((double) i) / n * Math.PI * 2; -// program.addSphere(new SphereFilterProgram.FilterSphere() -// .setCenter(new Vector3d(852, 77, -204).subtract(cameraPos).add(Math.sin(angle) * rad, 0, Math.cos(angle) * rad)) -// .setRadius(15) -// .setFeather(3f) -// .setFade(1f) -// .setDensity(0.5f) -// .setFilter(ColorMatrices.hueShiftRGB((float) i / n * 360 + i / 2f))); -// } + for (SphereFilterProgram.FilterSphere sphere : spheres) { + sphere.center = sphere.center.subtract(cameraPos); + } - program.addSphere(new SphereFilterProgram.FilterSphere() - .setCenter(new Vector3d(865.5, 79, -240.5).subtract(cameraPos)) - .setRadius(10f) - .setFeather(3f) - .setFade(1.8f) - .setDensity(1.3f) - .setFilter(ColorMatrices.grayscale())); + spheres.sort((o1, o2) -> (int) Math.signum(o2.center.length() - o1.center.length())); - program.addSphere(new SphereFilterProgram.FilterSphere() - .setCenter(new Vector3d(852.5, 70, -203.5).subtract(cameraPos)) - .setRadius(20f) - .setFeather(3f) - .setFade(1f) - .setDensity(1.3f) - .setFilter(ColorMatrices.sepia(1f))); - -// Matrix4f test = ColorMatrices.sepia(1f); -// -// -// test.multiply(ColorMatrices.invert()); -// -// Matrix4f darken = new Matrix4f(); -// darken.loadIdentity(); -// darken.multiply(0.7f); -// darken.a03 = 0.7f; -// darken.a13 = 0.7f; -// darken.a23 = 0.7f; -// test.multiply(darken); - - Matrix4f test = ColorMatrices.saturate(2f); - - test.multiply(ColorMatrices.hueShift(120f)); - - program.addSphere(new SphereFilterProgram.FilterSphere() - .setCenter(new Vector3d(858.5, 88, -259.5).subtract(cameraPos)) - .setRadius(10f) - .setFeather(3f) - .setFade(1.8f) - .setDensity(0.5f) - .setStrength(1f) - .setFilter(test)); - - - program.addSphere(new SphereFilterProgram.FilterSphere() - .setCenter(new Vector3d(2310, 60, -954).subtract(cameraPos)) - .setRadius(8f) - .setFeather(3f) - .setFade(0.8f) - .setDensity(1.3f) - .setStrength(1f) - .setFilter(ColorMatrices.grayscale())); - - program.uploadFilters(); + program.uploadFilters(spheres); program.setFarPlane(getFarPlane()); program.setNearPlane(getNearPlane()); @@ -189,8 +134,8 @@ public class EffectsHandler { program.bindDepthTexture(0); GL20.glActiveTexture(GL20.GL_TEXTURE0); - program.clear(); program.unbind(); + spheres.clear(); Backend.compat.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebuffer.framebufferObject); Backend.compat.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject); @@ -204,4 +149,13 @@ public class EffectsHandler { vao.delete(); vbo.delete(); } + + private void prepFramebufferSize() { + MainWindow window = Minecraft.getInstance().getWindow(); + if (framebuffer.framebufferWidth != window.getFramebufferWidth() + || framebuffer.framebufferHeight != window.getFramebufferHeight()) { + framebuffer.func_216491_a(window.getFramebufferWidth(), window.getFramebufferHeight(), + Minecraft.IS_RUNNING_ON_MAC); + } + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java index 4616e8768..406059e74 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java @@ -1,6 +1,5 @@ package com.simibubi.create.foundation.render.backend.effects; -import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.util.ArrayList; @@ -29,8 +28,6 @@ public class SphereFilterProgram extends GlProgram { public final GlBuffer effectsUBO; - protected final ArrayList filters = new ArrayList<>(16); - protected final int uniformBlock; protected final int uDepth; @@ -82,17 +79,15 @@ public class SphereFilterProgram extends GlProgram { GL20.glUniform3f(uCameraPos, (float) pos.x, (float) pos.y, (float) pos.z); } - public void clear() { - filters.clear(); - } - - public void addSphere(FilterSphere filterSphere) { - filters.add(filterSphere); - } - - public void uploadFilters() { + public void uploadFilters(ArrayList filters) { effectsUBO.bind(GL20.GL_ARRAY_BUFFER); - effectsUBO.map(GL20.GL_ARRAY_BUFFER, 0, BUFFER_SIZE, this::uploadUBO); + effectsUBO.map(GL20.GL_ARRAY_BUFFER, 0, BUFFER_SIZE, buf -> { + buf.putInt(filters.size()); + buf.position(16); + FloatBuffer floatBuffer = buf.asFloatBuffer(); + + filters.forEach(it -> it.write(floatBuffer)); + }); effectsUBO.unbind(GL20.GL_ARRAY_BUFFER); } @@ -114,14 +109,6 @@ public class SphereFilterProgram extends GlProgram { GL20.glBindTexture(GL20.GL_TEXTURE_2D, textureObject); } - private void uploadUBO(ByteBuffer buf) { - buf.putInt(filters.size()); - buf.position(16); - FloatBuffer floatBuffer = buf.asFloatBuffer(); - - filters.forEach(it -> it.write(floatBuffer)); - } - public static class FilterSphere { public Vector3d center; public float radius; @@ -129,6 +116,7 @@ public class SphereFilterProgram extends GlProgram { public float fade; public float density = 2; public float strength = 1; + public boolean blendOver = false; public Matrix4f filter; @@ -137,6 +125,11 @@ public class SphereFilterProgram extends GlProgram { return this; } + public FilterSphere setCenter(double x, double y, double z) { + this.center = new Vector3d(x, y, z); + return this; + } + public FilterSphere setRadius(float radius) { this.radius = radius; return this; @@ -167,6 +160,11 @@ public class SphereFilterProgram extends GlProgram { return this; } + public FilterSphere setBlendOver(boolean blendOver) { + this.blendOver = blendOver; + return this; + } + public void write(FloatBuffer buf) { buf.put(new float[]{ (float) center.x, @@ -176,7 +174,11 @@ public class SphereFilterProgram extends GlProgram { feather, fade, density, - strength, + blendOver ? 1f : 0f, + 1f, + 1f, + 0f, + 0f, }); buf.put(RenderUtil.writeMatrix(filter)); diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index 00691aeb1..e36d9056d 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -16,34 +16,11 @@ uniform vec3 uCameraPos; struct SphereFilter { vec4 sphere;// - vec4 data;// + vec4 d1;// + vec4 d2;// mat4 colorOp; }; -vec3 getPosition(SphereFilter f) { - return f.sphere.xyz; -} - -float getRadius(SphereFilter f) { - return f.sphere.w; -} - -float getFeather(SphereFilter f) { - return f.data.x; -} - -float getFade(SphereFilter f) { - return f.data.y; -} - -float getDensity(SphereFilter f) { - return f.data.z; -} - -float getStrength(SphereFilter f) { - return f.data.w; -} - #define N 256 layout (std140) uniform Filters { int uCount; @@ -113,18 +90,22 @@ float bubbleFilterStrength(vec3 worldDir, float depth, vec4 sphere, float feathe return clamp(strength, 0., 1.);// * boo; } -float filterStrength(vec3 worldDir, float depth, vec4 sphere, vec4 data) { +float filterStrength(vec3 worldDir, float depth, inout SphereFilter f) { + vec4 sphere = f.sphere; + vec4 data = f.d1; float feather = data.x; float strength = 0.; // transition effect float transitionRadius = sphere.w + feather; strength += 1. - smoothstep(transitionRadius, transitionRadius + data.y, length(sphere.xyz)); - // surface effect - strength += surfaceFilterStrength(worldDir * depth, sphere, feather); // bubble effect strength += bubbleFilterStrength(worldDir, depth, sphere, feather, data.z); + strength *= f.d2.y; + // surface effect + strength += surfaceFilterStrength(worldDir * depth, sphere, feather) * f.d2.x; + return strength; } @@ -137,16 +118,16 @@ vec3 applyFilters(vec3 worldDir, float depth, vec3 diffuse) { for (int i = 0; i < uCount; i++) { SphereFilter s = uSpheres[i]; - float strength = filterStrength(worldDir, depth, s.sphere, s.data); + float strength = filterStrength(worldDir, depth, s); if (strength > 0) { const float fcon = 0.; - vec3 formatted = mix(diffuse, hsv, fcon); - vec3 filtered = filterColor(s.colorOp, formatted); - filtered = mix(filtered, hsv2rgbWrapped(filtered), fcon); + //vec3 formatted = mix(diffuse, hsv, fcon); + vec3 filtered = filterColor(s.colorOp, mix(diffuse, accum, s.d1.w)); + //filtered = mix(filtered, hsv2rgbWrapped(filtered), fcon); - float mixing = clamp(strength * s.data.w, 0., 1.); + float mixing = clamp(strength, 0., 1.); accum = mix(accum, filtered, mixing); } } diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.vert b/src/main/resources/assets/create/flywheel/shaders/area_effect.vert index 6c1d35d5f..0a0d8443a 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.vert +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.vert @@ -1,8 +1,11 @@ #version 140 // scaling constants -#define SXY 1.7282818// e - 0.99, this works too well -#define SZ 1.905// who knows, but it works +// e - 0.99, this works well, no idea why +#define SXY 1.7282818 +// 1.90 -> highp close, mediump far +// 1.91 -> mediump close, highp far +#define SZ 1.905 in vec4 aVertex;// diff --git a/src/main/resources/assets/create/textures/gui/projector.png b/src/main/resources/assets/create/textures/gui/projector.png index b2eaa0404874786d448563f2956a112ca51bc31d..165ac24d206aa6a5ded0317397fded44b7030006 100644 GIT binary patch literal 3086 zcmcImdpwlc8$a)B7(*&1mrBtjid@p#%E$~6BbSoaB{OX3HWhNqWX8A@ev-^=rHeNKn3< z7Mh_S_#1NvD)5|diMh7zj>K$%4<5-Qsu zv88)?aX27Ca{rIUyFGo~S6tCQkwGguDjd4ku;CcbyXd{Uvz@pzN08E zM;CuG3U}TPB3!@wYFq=wHXg&7or)eqfo*%bT3W2tRWkyjNf90``2^G0n&~KsD2HHz z;pe5u^F86!s@^_6Q*+yo`ky`P(jHqUrpHV-Zh<-rSm5el;jKMk4Wrnzat|jXCIdjY zhZE@gddzTYPgB=_biNp5HK}&PFaScBfgcpy;cu+9EsK;GE|FqO4E5uEKRUJBqT%^ zN&CoJKQ$)#aj*RF+-Fu%$;@ZEek`%7;RZ5_IG0(FznrzG3v~{jH4uLIaJ$1mA=VK@ zwmAV3%Q3r%rAHcJ*K@0lsZ^>@3swaObsoV(R~V?`^DJ*v_Twi{ip;rspsrqm^7Z@u z#?XoUDH<~Xaju|!xL41ch?|>4I4C@Cp__f%LgrYlp^Nho9e~SIQL9zez&-Z^09oF= z_IVZ3@2)x}_s{ zuWJ}CP~Xk6{8fEEzvZ$H!TOWC{c*Q=#6#$~rVh@xrvLUjG(A0?1TH_qn&Cu~5%ak< zZ;p-s!4T?@<2Ji%`{}Uz+Cn)ArF_+G`as82SYx?THY5(=)812gD~3N9$|-2K z2DNZf3W|AeSV>!!`j18-c8;L`aodgMwEdaR&rMP z(H4ziuCu$e5}C_=MCl6BsEw(G3sy$L`va}G;qv=QW2h^Rp)qu4hG%1(tocqR$iB6x z$J~7l;A~;yk={8-u)ciH%jwo|I3!wocw!+ZE_1ONhX4rXtxay~v!cimk6c&d56?ks zu1lA|u2r#{&}cL_&(kOa96VBp3JJe&>ZXy`6vdb@Ub{l!oj7u^NqnA%4WWk~wU&z9 zyix1ykclXL@*Ja(%C7`%%gZmqGGB{`4iBjiYvA2{53|73jWL_g7NarXNLw$ab97eE zrPaqEhYDry*yx93A;Y4GbcPxe|G`sIDSxYM&Dv{+>?>{2d!Z7fRyjsy7RgE*^ni@7 z@LKrdxKH;DL!6-qZ;6!Y#>b_6Zf*M$doI3AksNpE>MvCAvh40#ianQR%#_GTKh%R6 z?#H8N?~6vLG31SCOAjnjk!^6L^>MZNZ`eZhDM5x8HhUm8(J_r8$+Pj z8M+)6CkdQ(ZUL_A{JY=aq1Z6-xz&Vy?q@q*cbG&krKfM|mH%^;C`cxh{~S2Ui2yWb zf6eI)kVbC6rwN(A7rt#-&kLxeeK5rEw^m|^y~*Kqi z@|-nV3@$qxFrWJi&vL2^BHB>Guru3De6(=T4|o1@7?&Gv*${m(IHvWB6;AG6PS2M1}Qu)mDjA{+AB?CCU%X`1cO+R%AyRQffI$&ovL?oH! zZ$8O+)l~G)st1cnCe|jQ2fWBRmKo!Mdi|8uv|d6d>#c6 z$ci^y1!CHL+oUEsct3B5lo>#+_!;y6rH8tD3 zZ$!A(p1m8^?{d)H!OmQahSr$9*qf!P+GO4i65}M}43{$~+JrE!T}1ScjEWkZm=JU? zr{wGkrtMj&-<%tR1&@wF$Q4Omc0FPT!;5`2VME8c=}Sv=Zwe)H;-s082Jm>o;}Kdr zBx7UFWU#Qrb7IBp!uBf7#LEL4FEaW1D#Bt>ax!vmlURxNd^toK%_z@k+Y0EXmKc7C zE~nE1AmTx!#o`M-l{oDM1l4J2DqWqOTj>`ypjgB%HpCKws}uvh8*l<$4e*UVK{{F= zcFhm9k-*sg6HchD4A$)!9ngthT9}=eY=_4uztugx-esyE6=flHDD~r6Pt%2BN08~w z_^B>$v97L8#OveIk0w5YTpt0>lSPy%_g%}t(>QssGrHUE#8mfln3*+bV8!m!pr8`5 zCi+}OcHb^F5dVB&E*(MTKQ$_J03H=Qo+%!WPwOGD`%DoYD(dTIy literal 3095 zcmcgueLRzEAHVj34QWFqDbmn!gu;_EM@@%99ZE(MrsL$bLf(?tq)r^twB)5GPUNi& z8EM#3k(V>2v{-rRk(HSxAvQes@|;iS`RDoXdG3F%`}*GZ@8$Ylzu)(|Qun*;S)r`0 z3;)R%mwENoB<5!xVFA0w% zDsDG*Q#e+0@1DLVPW^W_;-7}5XK6>;i7}DH3%}c8KCd1}oHMwdnHTEz zXr1G_S`5$dx_+cyj^;IDfUx#u*Z8$r%2NH{${fyZAMtqevv{c>ce|^;e&2`ZB^KCr z7Y05n)zMJDFV`aQR&zGzqTu-8#Mst~M9wMc$PT*n=L!1J+(wb^Ymz#4ZnX1Se>Vby z&E&aKN)|L%ceqvb;^(``i}TKtWqz5qvWMCIu17X*dABr`JX@Qu2v!_Ka4F5tPiq59 z8lWodhJ)2wXmH362mF#UA)xNc4Uz+#S|@ANw3KXy$>v{59PCHf_0JD(84PumU{2Ii zq$Basx)o!yfwlt?Ib))}o*p+S+aiwzehBN<=t+K)ZoQP9Fwj;$A4!)8!_0gUw52u{ zSgfrvp?g$h9Y1lRBgoQtA=&BjlORicIrqoQxXkJ4==PfNN8RAezHs6DO@zE#HE~P1 zwcSl-VVs3o8&RwH+BPlKB7wN$PWJ@k6vcSD=(J?Y)k^xH1)sI#+Q-OR(_*%=H}QN% z8LWWEQy$K~5W?A|gr;iSLr^LqI>v*+c=N++y31jEwUwnAV{N)VnPRi%nStgx@ntZc zs}0T=P+boH8Xes$Qn~2E(M|@IKn62&4_6IRUXAqp%;b(4re`!Q?qW*hvWU@1w+Wyl- zFv|?ht#l5Aok)mrz5iz71>!}n>bZcRuW-i{_>@dw@F>j*To_mJvozs@&O}+Q+`=mm z_S?h4D7Md9wF^;;)F9Rt2<*3j8Qoa=Ak%}rdUxD#Xkwz0zebVb2x5BW;hpORS(ZQV zm5iiiXBYED!A&lfDM&w0G17bvwg0G*1A%!1w5L@XVAaeRl(!j>S?aH;{f>7O+j*g2~yEuA>90-nMEo zf8tPzrVafPPZDDD^g%fn`<)@sRr=_CTuJU&9|znY%fXmiw=}4oV#1y~ap1PHjv|X_iIftZ{|LyOMumWR=C&IU}(L^8+_>xEd(1Vbd$aEAM5F@q_>4@ zX7X7yM^IYs2G?qnCCSFJeb!#weHoW3n{;a6pifPHs*#B+c5X#Mg+eWF%vbOu4h3W` zvs84ClIH?U>k;c&l?sl}Kfgc56@=X&4)ihVIzlgQfT-xrM_X&DF2;W5wDLy1sJr*c zJ7IHLE)^@Mv{E7ENd&r}-Rrd}n!CY6A;U3o395t+D8zr^s8k2>u_;9ShdcH_@L;=~ z;?nC1n8|twdcx#=-%`%qyyu-3VNzH&<(VlVs|>}naUkA35PtuZupp6Ro4{g1`+gw= zjw+mbv_DP!p(4TOgc7s?*cZRV&xeq+A%4{fNY<ivpbevh%^+3c-~V$F*!*hOmmE8`-n@bXrs%?@ z5C|WT{TY`0Mb(Mrv;D;2=lQftTX}G~mj|S;9l2bbe|KM4vw@n{|Cf4dGj%CZ4t1O_ zUQP5XcZ32Z-~Qs~s~bMibvvgR6dFi}gn;WHu66M6^lY+pTb5G0s0lZz@FO==aEyH4 z8E)Qj3{HE9aJu~H@K3?9W97*=yXzuqb{4jbZv}(3HqlQQ?Qa(!<$OSzYhP@%x)M`T znFr3)U3_e(;*X6_BE2@3**Obj>`>xv~ihfy^cl;-KRi``r-l;g!>85$%5v5UG}rVX znh=RW71A%@Q8X~VEen!o?#xUb|F@or*F;6w;8$yJ_|wyEsKUq#{kbL+uIah?=qD`D z=2@vgApJ+OACO!YxT^v9@B-DlBG~IMzxIl-VPY4b;>yLhfxd#@kbc>H$ne==m4>Cy z#is*Rss||ZZWBAs6fXYg2!<`@0~v~qXjD9-IceM(`&lE_G|38 zE~Fq%0UE#pHfU?TO#^c@$5wIZT1<&rg9YjJ4J``>$U$4%z|5g9G~nDb@nU1FVVYFK z-w+ZNbDSY9{gGW` zY(8e51uT`4F!;FAWbls5CACgHc%Qtd~g24N~$*b zyqY@rc91NW?YB#Y2R`;XE;W7k&6~E<#6{oENkP<}t0 zZ<3nw>so)%!ez6`2Q`vnVq$9ZmEd=)t2bWK-8nO3Gdc7CVJ3J`d(dc5fpA+3x+Jv% zU{X~~m%wF%=T+8>CZ^xHvxP(=MSMJFZl(y_>sTx+e)p_&As4|7{}Su;T=!^88No~o zV9ts7%uXd;*?xO_=rAt|?$8^8wE;{zpUKH=Z>${--`s*@wQdD^o0(+Jj`=*hf;d$W z^t!)4@AjQLSsXL*$dsfDc?Q4-WCjOWp3<7A=C9-Iq&WKWyC(}389A(`GsJpua zb4CM=agm>`lBx067447HU3|xfD)CE?7&ft^iK;r6kkp2EHjN@4r@A`g^EBPa)jnt4 zkR}3zbjE&so0*8`tWX6xoe}F9yf7sM7`-a_7?pU~8ig|Qjyi+IbHZ={naq>uBEVUK zkpEy0aIayp3>FeO)omqH(#L@6?BU^Y=uad4Gf3!)i2zkxIdgS5{ZH?oZNg&XX2x^J x=yr!Heb~1aG@qI;T5sO Date: Fri, 23 Apr 2021 14:38:31 -0700 Subject: [PATCH 014/198] More polish - UI icons - Color masking - Better scroll ux - FilterSphere now has its own file --- .../projector/ChromaticProjectorScreen.java | 60 +++++----- .../ChromaticProjectorTileEntity.java | 12 +- .../curiosities/projector/ColorEffect.java | 112 ++++++++++++++++++ .../curiosities/projector/ColorEffects.java | 81 ------------- .../curiosities/projector/FilterStep.java | 12 +- .../backend/effects/EffectsHandler.java | 6 +- .../render/backend/effects/FilterSphere.java | 93 +++++++++++++++ .../backend/effects/SphereFilterProgram.java | 76 ------------ .../create/flywheel/shaders/area_effect.frag | 16 ++- .../assets/create/textures/gui/projector.png | Bin 3086 -> 3428 bytes 10 files changed, 264 insertions(+), 204 deletions(-) create mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java delete mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java create mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java index e7074cb6d..ed898a196 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java @@ -52,7 +52,8 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { } private static Integer step(ScrollValueBehaviour.StepContext ctx, int base) { - return ctx.control ? 1 : base * (ctx.shift ? 5 : 1); + if (ctx.control) return 1; + return base * (ctx.shift ? 5 : 1) - ctx.currentValue % base; } @Override @@ -71,30 +72,36 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { confirmButton = new IconButton(guiLeft + background.width - 33, guiTop + background.height - 24, AllIcons.I_CONFIRM); widgets.add(confirmButton); - radius = new ScrollInput(guiLeft + 46, guiTop + 117, 28, 18) + + int xRight = guiLeft + 53; + int xLeft = guiLeft + 93; + int yTop = guiTop + 117; + int yBottom = guiTop + 139; + + radius = new ScrollInput(xRight, yTop, 28, 18) .titled(new StringTextComponent("Radius")) .withStepFunction(ctx -> step(ctx, 2)) .calling(tile::setRadius) .withRange(0, 201) .setState((int) (tile.radius * 2)); - feather = new ScrollInput(guiLeft + 46, guiTop + 139, 28, 18) + feather = new ScrollInput(xRight, yBottom, 28, 18) .titled(new StringTextComponent("Feather")) .withStepFunction(ctx -> step(ctx, 5)) .calling(tile::setFeather) .withRange(0, 201) - .setState((int) (tile.feather * 4)); - fade = new ScrollInput(guiLeft + 117, guiTop + 139, 28, 18) - .titled(new StringTextComponent("Fade")) - .withStepFunction(ctx -> step(ctx, 1)) - .calling(tile::setFade) - .withRange(0, 51) - .setState((int) (tile.fade * 10)); - density = new ScrollInput(guiLeft + 117, guiTop + 117, 28, 18) + .setState((int) (tile.feather * 10)); + density = new ScrollInput(xLeft, yTop, 28, 18) .titled(new StringTextComponent("Density")) .withStepFunction(ctx -> step(ctx, 10)) .calling(tile::setDensity) .withRange(0, 401) .setState((int) (tile.density * 100)); + fade = new ScrollInput(xLeft, yBottom, 28, 18) + .titled(new StringTextComponent("Fade")) + .withStepFunction(ctx -> step(ctx, 1)) + .calling(tile::setFade) + .withRange(0, 51) + .setState((int) (tile.fade * 10)); Collections.addAll(widgets, radius, density, feather, fade); } @@ -107,17 +114,17 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { Vector rowInputs = inputs.get(row); rowInputs.forEach(widgets::remove); rowInputs.clear(); - int index = row; - FilterStep instruction = stages.get(row); + FilterStep filter = stages.get(row); ScrollInput type = - new SelectionScrollInput(x, y + rowHeight * row, 86, 18).forOptions(ColorEffects.getOptions()) - .calling(state -> instructionUpdated(index, state)) - .setState(instruction.filter.ordinal()) + new SelectionScrollInput(x, y + rowHeight * row, 86, 18) + .forOptions(ColorEffect.getOptions()) + .calling(state -> instructionUpdated(row, state)) + .setState(filter.filter.id) .titled(Lang.translate("gui.chromatic_projector.filter")); ScrollInput value = new ScrollInput(x + 86 + 2, y + rowHeight * row, 28, 18) - .calling(state -> instruction.value = state); + .calling(state -> filter.value = state); rowInputs.add(type); rowInputs.add(value); @@ -129,7 +136,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { public void updateParamsOfRow(int row) { FilterStep instruction = stages.get(row); Vector rowInputs = inputs.get(row); - ColorEffects def = instruction.filter; + ColorEffect def = instruction.filter; boolean hasValue = def.hasParameter; ScrollInput value = rowInputs.get(1); @@ -137,11 +144,10 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { if (hasValue) value.withRange(def.minValue, def.maxValue + 1) //.titled(Lang.translate(def.parameterKey)) - .withShiftStep(5) .setState(instruction.value) .onChanged(); - value.withStepFunction(value.standardStep()); + value.withStepFunction(def.step()); } @Override @@ -158,10 +164,10 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { } FilterStep step = stages.get(row); - ColorEffects def = step.filter; + ColorEffect def = step.filter; def.background.draw(matrixStack, guiLeft, guiTop + 14 + yOffset); - if (def != ColorEffects.END) + if (def != ColorEffect.END) label(matrixStack, 36, yOffset - 3, Lang.translate(def.translationKey)); if (def.hasParameter) { String text = step.filter.formatValue(step.value); @@ -172,7 +178,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { renderScroll(matrixStack, radius, 2f); renderScroll(matrixStack, density, 100f); - renderScroll(matrixStack, feather, 4f); + renderScroll(matrixStack, feather, 10f); renderScroll(matrixStack, fade, 10f); textRenderer.drawWithShadow(matrixStack, title, guiLeft - 3 + (background.width - textRenderer.getWidth(title)) / 2, guiTop + 3, @@ -206,11 +212,11 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { } private void instructionUpdated(int index, int state) { - ColorEffects newValue = ColorEffects.values()[state]; + ColorEffect newValue = ColorEffect.all.get(state); stages.get(index).filter = newValue; - stages.get(index).value = 100; + stages.get(index).value = newValue.defaultValue; updateParamsOfRow(index); - if (newValue == ColorEffects.END) { + if (newValue == ColorEffect.END) { for (int i = stages.size() - 1; i > index; i--) { stages.remove(i); Vector rowInputs = inputs.get(i); @@ -219,7 +225,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { } } else { if (index + 1 < stages.capacity() && index + 1 == stages.size()) { - stages.add(new FilterStep(ColorEffects.END)); + stages.add(new FilterStep(ColorEffect.END)); initInputsOfRow(index + 1); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java index b6f9f4089..d2ebe9f6f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.curiosities.projector; import java.util.Vector; -import com.simibubi.create.foundation.render.backend.effects.SphereFilterProgram; +import com.simibubi.create.foundation.render.backend.effects.FilterSphere; import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import net.minecraft.tileentity.TileEntity; @@ -24,17 +24,17 @@ public class ChromaticProjectorTileEntity extends TileEntity implements IInstanc super(te); } - public SphereFilterProgram.FilterSphere makeFilter() { + public FilterSphere makeFilter() { Matrix4f filter = FilterStep.fold(stages); BlockPos pos = getPos(); - return new SphereFilterProgram.FilterSphere() + return new FilterSphere() .setFilter(filter) .setCenter(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5) .setRadius(radius) .setDensity(density) .setFeather(feather) - .setBlendOver(false) + .setBlendOver(true) .setFade(fade); } @@ -49,12 +49,12 @@ public class ChromaticProjectorTileEntity extends TileEntity implements IInstanc } public ChromaticProjectorTileEntity setFeather(int feather) { - this.feather = feather / 4f; + this.feather = feather / 10f; return this; } public ChromaticProjectorTileEntity setFade(int fade) { - this.fade = feather / 10f; + this.fade = fade / 10f; return this; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java new file mode 100644 index 000000000..12c0a0822 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java @@ -0,0 +1,112 @@ +package com.simibubi.create.content.curiosities.projector; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; + +import com.simibubi.create.foundation.gui.AllGuiTextures; +import com.simibubi.create.foundation.render.backend.effects.ColorMatrices; +import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; +import com.simibubi.create.foundation.utility.Lang; + +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.text.ITextComponent; + +public class ColorEffect { + static final ArrayList all = new ArrayList<>(); + static final HashMap lookup = new HashMap<>(); + private static int nextId = 0; + + public static final ColorEffect INVERT = create("invert", ColorMatrices::invert); + public static final ColorEffect SEPIA = create("sepia", ColorMatrices::sepia); + public static final ColorEffect GRAYSCALE = create("grayscale", ColorMatrices::grayscale); + public static final ColorEffect DARKEN = create("darken", ColorMatrices::darken).setDefaultValue(20); + public static final ColorEffect SATURATE = create("saturate", ColorMatrices::saturate).setRange(0, 200); + public static final ColorEffect HUE_SHIFT = create("hue_shift", ColorMatrices::hueShift).setRange(0, 360).setDivisor(1f).setDefaultValue(120); + public static final ColorEffect END = create("end", ColorMatrices::identity).setBackground(AllGuiTextures.PROJECTOR_END); + + boolean hasParameter; + AllGuiTextures background; + + int defaultValue = 100; + int minValue = 0; + int maxValue = 100; + float divisor = 100f; + + final int id; + final FilterFactory filter; + final String name; + final String translationKey; + + public ColorEffect(String name, FilterFactory filter) { + this.filter = filter; + this.name = name; + this.translationKey = "gui.chromatic_projector.filter." + Lang.asId(name); + this.id = nextId++; + + lookup.put(name, this); + all.add(this); + } + + public ColorEffect setHasParameter(boolean hasParameter) { + this.hasParameter = hasParameter; + return setBackground(hasParameter ? AllGuiTextures.PROJECTOR_FILTER_STRENGTH : AllGuiTextures.PROJECTOR_FILTER); + } + + public ColorEffect setBackground(AllGuiTextures background) { + this.background = background; + return this; + } + + public ColorEffect setDefaultValue(int defaultValue) { + this.defaultValue = defaultValue; + return this; + } + + public ColorEffect setRange(int minValue, int maxValue) { + this.minValue = minValue; + this.maxValue = maxValue; + return this; + } + + public ColorEffect setDivisor(float divisor) { + this.divisor = divisor; + return this; + } + + public Function step() { + return c -> { + if (c.control) return 1; + if (c.shift) return 20; + return 5; + }; + } + + String formatValue(int value) { + if (this == HUE_SHIFT) + return value + Lang.translate("generic.unit.degrees").getString(); + return "" + value; + } + + static List getOptions() { + List options = new ArrayList<>(); + for (ColorEffect entry : all) + options.add(Lang.translate(entry.translationKey)); + return options; + } + + @FunctionalInterface + public interface FilterFactory { + Matrix4f create(float param); + } + + public static ColorEffect create(String name, Supplier filter) { + return new ColorEffect(name, $ -> filter.get()).setHasParameter(false); + } + + public static ColorEffect create(String name, FilterFactory filter) { + return new ColorEffect(name, filter).setHasParameter(true); + } +} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java deleted file mode 100644 index 964af44d0..000000000 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffects.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.simibubi.create.content.curiosities.projector; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; - -import com.simibubi.create.foundation.gui.AllGuiTextures; -import com.simibubi.create.foundation.render.backend.effects.ColorMatrices; -import com.simibubi.create.foundation.utility.Lang; - -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.text.ITextComponent; - -public enum ColorEffects { - INVERT(ColorMatrices::invert), - SEPIA(ColorMatrices::sepia), - GRAYSCALE(ColorMatrices::grayscale), - DARKEN(ColorMatrices::darken), - SATURATE(ColorMatrices::saturate, 0, 200), - HUE_SHIFT(ColorMatrices::hueShift, 0, 360, 1f), - END(ColorMatrices::identity, AllGuiTextures.PROJECTOR_END), - - ; - - FilterFactory filter; - boolean hasParameter; - String translationKey; - AllGuiTextures background; - - int minValue = 0; - int maxValue = 100; - float divisor = 100f; - - ColorEffects(Supplier filter, AllGuiTextures background) { - this($ -> filter.get(), false, background); - } - - ColorEffects(Supplier filter) { - this($ -> filter.get(), false, AllGuiTextures.PROJECTOR_FILTER); - } - - ColorEffects(FilterFactory filter) { - this(filter, 0, 100); - } - - ColorEffects(FilterFactory filter, int minValue, int maxValue) { - this(filter, minValue, maxValue, 100f); - } - - ColorEffects(FilterFactory filter, int minValue, int maxValue, float divisor) { - this(filter, true, AllGuiTextures.PROJECTOR_FILTER_STRENGTH); - this.minValue = minValue; - this.maxValue = maxValue; - this.divisor = divisor; - } - - ColorEffects(FilterFactory filter, boolean hasParameter, AllGuiTextures background) { - this.filter = filter; - this.hasParameter = hasParameter; - this.background = background; - translationKey = "gui.chromatic_projector.filter." + Lang.asId(name()); - } - - String formatValue(int value) { - if (this == HUE_SHIFT) - return value + Lang.translate("generic.unit.degrees").getString(); - return "" + value; - } - - static List getOptions() { - List options = new ArrayList<>(); - for (ColorEffects entry : values()) - options.add(Lang.translate(entry.translationKey)); - return options; - } - - @FunctionalInterface - public interface FilterFactory { - Matrix4f create(float param); - } -} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java index cb77ed07e..e2c900236 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java @@ -9,14 +9,14 @@ import net.minecraft.util.math.vector.Matrix4f; public class FilterStep { - ColorEffects filter; + ColorEffect filter; int value; - public FilterStep(ColorEffects filter) { + public FilterStep(ColorEffect filter) { this.filter = filter; } - public FilterStep(ColorEffects filter, int value) { + public FilterStep(ColorEffect filter, int value) { this.filter = filter; this.value = value; } @@ -26,7 +26,7 @@ public class FilterStep { } public static Matrix4f fold(Vector filters) { - Iterator stepIterator = filters.stream().filter(it -> it != null && it.filter != ColorEffects.END).iterator(); + Iterator stepIterator = filters.stream().filter(it -> it != null && it.filter != ColorEffect.END).iterator(); if (stepIterator.hasNext()) { Matrix4f accum = stepIterator.next().createFilter(); @@ -41,8 +41,8 @@ public class FilterStep { public static Vector createDefault() { Vector instructions = new Vector<>(ChromaticProjectorScreen.MAX_STEPS); - instructions.add(new FilterStep(ColorEffects.SEPIA, 100)); - instructions.add(new FilterStep(ColorEffects.END)); + instructions.add(new FilterStep(ColorEffect.SEPIA, 100)); + instructions.add(new FilterStep(ColorEffect.END)); return instructions; } } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java index f6368c9b5..24e95175c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java @@ -51,7 +51,7 @@ public class EffectsHandler { private final GlBuffer vbo = new GlBuffer(GL20.GL_ARRAY_BUFFER); - private final ArrayList spheres; + private final ArrayList spheres; public EffectsHandler() { spheres = new ArrayList<>(); @@ -74,7 +74,7 @@ public class EffectsHandler { } - public void addSphere(SphereFilterProgram.FilterSphere sphere) { + public void addSphere(FilterSphere sphere) { this.spheres.add(sphere); } @@ -115,7 +115,7 @@ public class EffectsHandler { program.setCameraPos(cameraPos.inverse()); - for (SphereFilterProgram.FilterSphere sphere : spheres) { + for (FilterSphere sphere : spheres) { sphere.center = sphere.center.subtract(cameraPos); } diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java new file mode 100644 index 000000000..77aa77123 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java @@ -0,0 +1,93 @@ +package com.simibubi.create.foundation.render.backend.effects; + +import java.nio.FloatBuffer; + +import com.simibubi.create.foundation.render.backend.RenderUtil; + +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3d; + +public class FilterSphere { + public Vector3d center; + public float radius; + public float feather; + public float fade; + public float density = 2; + public float strength = 1; + public boolean blendOver = false; + + public float r; + public float g; + public float b; + public float colorFeather; + + public Matrix4f filter; + + public FilterSphere setCenter(Vector3d center) { + this.center = center; + return this; + } + + public FilterSphere setCenter(double x, double y, double z) { + this.center = new Vector3d(x, y, z); + return this; + } + + public FilterSphere setRadius(float radius) { + this.radius = radius; + return this; + } + + public FilterSphere setFeather(float feather) { + this.feather = feather; + return this; + } + + public FilterSphere setFade(float fade) { + this.fade = fade; + return this; + } + + public FilterSphere setDensity(float density) { + this.density = density; + return this; + } + + public FilterSphere setStrength(float strength) { + this.strength = strength; + return this; + } + + public FilterSphere setFilter(Matrix4f filter) { + this.filter = filter; + return this; + } + + public FilterSphere setBlendOver(boolean blendOver) { + this.blendOver = blendOver; + return this; + } + + public void write(FloatBuffer buf) { + buf.put(new float[]{ + (float) center.x, + (float) center.y, + (float) center.z, + radius, + feather, + fade, + density, + blendOver ? 1f : 0f, + 1f, + 1f, + 0f, + 0f, + 0.5f, //r, + 0.1f, //g, + 0.1f, //b, + 0.12f, //colorFeather, + }); + + buf.put(RenderUtil.writeMatrix(filter)); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java index 406059e74..229aa2f5c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL31; -import com.simibubi.create.foundation.render.backend.RenderUtil; import com.simibubi.create.foundation.render.backend.gl.GlBuffer; import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; @@ -109,79 +108,4 @@ public class SphereFilterProgram extends GlProgram { GL20.glBindTexture(GL20.GL_TEXTURE_2D, textureObject); } - public static class FilterSphere { - public Vector3d center; - public float radius; - public float feather; - public float fade; - public float density = 2; - public float strength = 1; - public boolean blendOver = false; - - public Matrix4f filter; - - public FilterSphere setCenter(Vector3d center) { - this.center = center; - return this; - } - - public FilterSphere setCenter(double x, double y, double z) { - this.center = new Vector3d(x, y, z); - return this; - } - - public FilterSphere setRadius(float radius) { - this.radius = radius; - return this; - } - - public FilterSphere setFeather(float feather) { - this.feather = feather; - return this; - } - - public FilterSphere setFade(float fade) { - this.fade = fade; - return this; - } - - public FilterSphere setDensity(float density) { - this.density = density; - return this; - } - - public FilterSphere setStrength(float strength) { - this.strength = strength; - return this; - } - - public FilterSphere setFilter(Matrix4f filter) { - this.filter = filter; - return this; - } - - public FilterSphere setBlendOver(boolean blendOver) { - this.blendOver = blendOver; - return this; - } - - public void write(FloatBuffer buf) { - buf.put(new float[]{ - (float) center.x, - (float) center.y, - (float) center.z, - radius, - feather, - fade, - density, - blendOver ? 1f : 0f, - 1f, - 1f, - 0f, - 0f, - }); - - buf.put(RenderUtil.writeMatrix(filter)); - } - } } diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index e36d9056d..3a43ac7a4 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -18,6 +18,7 @@ struct SphereFilter { vec4 sphere;// vec4 d1;// vec4 d2;// + vec4 colorMask;// mat4 colorOp; }; @@ -112,7 +113,6 @@ float filterStrength(vec3 worldDir, float depth, inout SphereFilter f) { vec3 applyFilters(vec3 worldDir, float depth, vec3 diffuse) { vec3 worldPos = worldDir * depth; - vec3 hsv = rgb2hsv(diffuse); vec3 accum = vec3(diffuse); for (int i = 0; i < uCount; i++) { @@ -123,12 +123,18 @@ vec3 applyFilters(vec3 worldDir, float depth, vec3 diffuse) { if (strength > 0) { const float fcon = 0.; - //vec3 formatted = mix(diffuse, hsv, fcon); - vec3 filtered = filterColor(s.colorOp, mix(diffuse, accum, s.d1.w)); - //filtered = mix(filtered, hsv2rgbWrapped(filtered), fcon); + vec3 baseColor = mix(diffuse, accum, s.d1.w); + vec3 filtered = filterColor(s.colorOp, baseColor); + + vec3 baseHsv = rgb2hsv(baseColor); + vec3 maskHsv = rgb2hsv(s.colorMask.rgb); + vec3 diff = abs(baseHsv - maskHsv) * vec3(1., 1.1, 0.1); + float colorMask = step(s.colorMask.w, length(diff)); float mixing = clamp(strength, 0., 1.); - accum = mix(accum, filtered, mixing); + + accum = mix(accum, filtered, mixing * colorMask); + //accum = vec3(colorMask); } } diff --git a/src/main/resources/assets/create/textures/gui/projector.png b/src/main/resources/assets/create/textures/gui/projector.png index 165ac24d206aa6a5ded0317397fded44b7030006..968618e948b3dde383ab64f20f199f5166f4d068 100644 GIT binary patch literal 3428 zcmd5lL^ZA_f@A-Vr{@CvOzOMVeuj_k#uj{^+?(4ln zQ{7k{0HEo<({&F3FlYz^sz~T3@OVWiw2pIk-AXupO*r6{M(ESyeBSHTzwHt^IC&r1 zpzmBuB;FXVbrt8|hS|QeHoU^?+@19=()NFB_rj;V+F(Xrj!sq!KX^%NzbazyEI6p4 zy8nrKa>sL*-8%WPhUg%Dub!4Othpx9`{EN6SrX>yCq|;EmwJ+N{fwx0H99MnSNzl6 zwA&sY9?&;7yQ;GCl5E}CC5@@nvj_WQWmLI%nEJD1$)JVT-U6}q^nQJG{O3P?>ic17 zXrmXtn;DY>pdjQ-=Y=3!A?I$|tbh~jOu6b=3uQ+$3R~QQ=h;*TDr@*q!vQllO zwUm*Avwut{-D%e`$Z)Ub=XjT|C<&Z9HY!Vhvj6^xyQOv-`usiO)Oc;btLH7W*Uzgi zJFJ5*NC_G4*rws^f-(XxUC(9QKaUU5@+(M@O$v0-=)Nq2Cxw3u|C%}?YE=B$np7uU ziBRReSs=h67NPAE=bP9&9)d>$Rh2_OiGD~kcOh$5SdkTSS&->R?2GXshe0GhbuV(N z)zl)}tm6&RJJ8NtmYDR(BW>yA=#gowG0--01!m@sZ4IKtDuxwXu4gy~#gAWsIVQ>9 zjlB<4Js|TyE?QU41dunL4%eT*L3XY|x@_PAL1+9jeB9zy8)i zu4PFbpp7_giDwVxK`6))OCD3w{D!h&=a}DiafYQyNM|l|Yvf9SSp0yGLMA~oq9tNy zwyVSS3^R8d$<`p}<3W&Lz3*L9lrjf|AxkCNp6dyJHXhe(`Q0E94#v;CmKTO9iFUdX zIuPaG>&N4=a!<8Ntc>tY1Sie3P{=!III{-tT0fVkfe9o7^l}6Z*Pub;!MlB!N-N9u zXbWaOzYo+rLi1BV270VS%yd;d=cTga1G{jj^%?T>S`qNYUalW+SXx5?(y{@!(p8rc zR5Hvmh$?c)>wzKB|D zKRpTBxRaGc)sR0DBb2A?bV5wUz^kidcodPo!UYNZm5Yhio36vUADVt#)u2UVa5iVb zIC_7HRgFO4Zaq6J8AQ7g1!$wuoe!!d5z>obW*5(s?q7!64F< z=Ejpy_(;y^hfJT>M)>Pex>og&#uEWWUn!D?VvtE+?NGqq+lVtI1z$#I6KPBO+1V5P zYU!E4h3Oig>Y5D=O0h4eNA4z!p@y;_2V;bB0VYF*qAlM^kSU)#VNORvFy-=@fS?kk zJXi_Q?EBZTNZ+x<8>QW0u52}a<-*~v2 zeGS36wolCvZ3CMAr~~NLouKg2tPCPXDuaXWFfnDo51T*{vcCG$x)ho2fp@j1b=9`i<$`w6q>AJ+6gONS=)E z{vhPRX9gjPo+kLidp~z>O=xzePE(Zd^k{I}1nJ91rLX-Jy$}x|7%~4x6JH)koAw`j zCZ9aPKIv&b<#Er1#$z;Gbor4}=!(f9^m`%czp@C4S7N3?JA!rDF~S7SE#K&TB%;En z>?CLn;+;B+zUy6H3Oxjb)d;~2*x#5fi>D+8PMbfQWE;jg#ti54Eu7+F^px9C{xBuv zmtl+k;^_C&x0RXTB?itAPkiqVLrjrR)j8`&vDx2zKm0Q3P0@TRVJlc%YU5K%8P&@a zWdo#yab*cSB^tcfJ#}L2d51xDlK(rFEw(V{s^yotJ$3nuq6 zRn4%q_wTQNaPQu|wdL(T@8qvO;c~2=XAbR@77jWY(Wnu6bk{+XsXn#86?X)`#Z~(J zn~Y(EAB=uMId+WO-roMZJ0w2VBYCi{lMM9V^1q2YpbMS>^A7I?eI;Kj*=+|Xq#!3m zmsnA+Rsa<;#?V4*k3=jN_f|eeIWy>8<8?GO*Fu_$^Cv4_QlAU+H_lwlP*Ijawn4DT z>p|o`!+AGhjhO5lEx-?(S$oBC#_H&fHnivh2bA@n49;!c?lu9h@$ldYz*=S(jsH-= z{pw8Y0v9gB&UF!x))Ti$iOJk3$>S7MRc7nvn~r@}Bvzn3V%3?2c<6E1I|j^K`39?t zm)7dCx$T`XYnrlOQB$Hmrf)c`|N7 z*j3c6=o>nrhglcuv{2wMQx2^kI6EOcdPYhH;sQIAZ|IcI(P~O>$)s0fiV`&=d;z^g zRuo=cqu={BfI@oR-{`pdP+q4!Es<@-WHNJ&2SpN#C`C7_yd_98nmX?X#R4i}H9jj5 z6{X3)*UwaEy7fL7xDY#Y>7Sy^LYgx9E7U#z#cHUM-&KG2M!7MQ!O`2Tm(SoV-$2yn z^gIzR*&iO(O7)_YXmFgMs@YZhgJgHiACJhS!!aevkO>(t!d)h+^jBFfviL)PYEU`jDXVoFBlIJoGpjI+25oE8v1! z2BEafGWxy^k$%yf#4^A*JthOUH5&4SEtO7v7tQJ6pdAnA*1SkI;QcEcG literal 3086 zcmcImdpwlc8$a)B7(*&1mrBtjid@p#%E$~6BbSoaB{OX3HWhNqWX8A@ev-^=rHeNKn3< z7Mh_S_#1NvD)5|diMh7zj>K$%4<5-Qsu zv88)?aX27Ca{rIUyFGo~S6tCQkwGguDjd4ku;CcbyXd{Uvz@pzN08E zM;CuG3U}TPB3!@wYFq=wHXg&7or)eqfo*%bT3W2tRWkyjNf90``2^G0n&~KsD2HHz z;pe5u^F86!s@^_6Q*+yo`ky`P(jHqUrpHV-Zh<-rSm5el;jKMk4Wrnzat|jXCIdjY zhZE@gddzTYPgB=_biNp5HK}&PFaScBfgcpy;cu+9EsK;GE|FqO4E5uEKRUJBqT%^ zN&CoJKQ$)#aj*RF+-Fu%$;@ZEek`%7;RZ5_IG0(FznrzG3v~{jH4uLIaJ$1mA=VK@ zwmAV3%Q3r%rAHcJ*K@0lsZ^>@3swaObsoV(R~V?`^DJ*v_Twi{ip;rspsrqm^7Z@u z#?XoUDH<~Xaju|!xL41ch?|>4I4C@Cp__f%LgrYlp^Nho9e~SIQL9zez&-Z^09oF= z_IVZ3@2)x}_s{ zuWJ}CP~Xk6{8fEEzvZ$H!TOWC{c*Q=#6#$~rVh@xrvLUjG(A0?1TH_qn&Cu~5%ak< zZ;p-s!4T?@<2Ji%`{}Uz+Cn)ArF_+G`as82SYx?THY5(=)812gD~3N9$|-2K z2DNZf3W|AeSV>!!`j18-c8;L`aodgMwEdaR&rMP z(H4ziuCu$e5}C_=MCl6BsEw(G3sy$L`va}G;qv=QW2h^Rp)qu4hG%1(tocqR$iB6x z$J~7l;A~;yk={8-u)ciH%jwo|I3!wocw!+ZE_1ONhX4rXtxay~v!cimk6c&d56?ks zu1lA|u2r#{&}cL_&(kOa96VBp3JJe&>ZXy`6vdb@Ub{l!oj7u^NqnA%4WWk~wU&z9 zyix1ykclXL@*Ja(%C7`%%gZmqGGB{`4iBjiYvA2{53|73jWL_g7NarXNLw$ab97eE zrPaqEhYDry*yx93A;Y4GbcPxe|G`sIDSxYM&Dv{+>?>{2d!Z7fRyjsy7RgE*^ni@7 z@LKrdxKH;DL!6-qZ;6!Y#>b_6Zf*M$doI3AksNpE>MvCAvh40#ianQR%#_GTKh%R6 z?#H8N?~6vLG31SCOAjnjk!^6L^>MZNZ`eZhDM5x8HhUm8(J_r8$+Pj z8M+)6CkdQ(ZUL_A{JY=aq1Z6-xz&Vy?q@q*cbG&krKfM|mH%^;C`cxh{~S2Ui2yWb zf6eI)kVbC6rwN(A7rt#-&kLxeeK5rEw^m|^y~*Kqi z@|-nV3@$qxFrWJi&vL2^BHB>Guru3De6(=T4|o1@7?&Gv*${m(IHvWB6;AG6PS2M1}Qu)mDjA{+AB?CCU%X`1cO+R%AyRQffI$&ovL?oH! zZ$8O+)l~G)st1cnCe|jQ2fWBRmKo!Mdi|8uv|d6d>#c6 z$ci^y1!CHL+oUEsct3B5lo>#+_!;y6rH8tD3 zZ$!A(p1m8^?{d)H!OmQahSr$9*qf!P+GO4i65}M}43{$~+JrE!T}1ScjEWkZm=JU? zr{wGkrtMj&-<%tR1&@wF$Q4Omc0FPT!;5`2VME8c=}Sv=Zwe)H;-s082Jm>o;}Kdr zBx7UFWU#Qrb7IBp!uBf7#LEL4FEaW1D#Bt>ax!vmlURxNd^toK%_z@k+Y0EXmKc7C zE~nE1AmTx!#o`M-l{oDM1l4J2DqWqOTj>`ypjgB%HpCKws}uvh8*l<$4e*UVK{{F= zcFhm9k-*sg6HchD4A$)!9ngthT9}=eY=_4uztugx-esyE6=flHDD~r6Pt%2BN08~w z_^B>$v97L8#OveIk0w5YTpt0>lSPy%_g%}t(>QssGrHUE#8mfln3*+bV8!m!pr8`5 zCi+}OcHb^F5dVB&E*(MTKQ$_J03H=Qo+%!WPwOGD`%DoYD(dTIy From 70188889bebbe7506766b437cde3cd3f7fdc328d Mon Sep 17 00:00:00 2001 From: JozsefA Date: Fri, 23 Apr 2021 17:20:16 -0700 Subject: [PATCH 015/198] Persistence is key - Projectors now remember their setting and sync between clients --- .../projector/ChromaticProjectorScreen.java | 13 +-- .../ChromaticProjectorTileEntity.java | 41 +++++++-- .../projector/ConfigureProjectorPacket.java | 76 +++++++++++++++++ .../curiosities/projector/FilterStep.java | 39 ++++++++- .../foundation/networking/AllPackets.java | 84 +++++++++---------- .../render/backend/effects/FilterSphere.java | 2 +- 6 files changed, 192 insertions(+), 63 deletions(-) create mode 100644 src/main/java/com/simibubi/create/content/curiosities/projector/ConfigureProjectorPacket.java diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java index ed898a196..a941f922b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java @@ -12,28 +12,23 @@ import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.widgets.IconButton; import com.simibubi.create.foundation.gui.widgets.ScrollInput; import com.simibubi.create.foundation.gui.widgets.SelectionScrollInput; +import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.ListNBT; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; public class ChromaticProjectorScreen extends AbstractSimiScreen { - public static final int MAX_STEPS = 4; - private final ItemStack renderedItem = AllBlocks.CHROMATIC_PROJECTOR.asStack(); private final AllGuiTextures background = AllGuiTextures.PROJECTOR; private IconButton confirmButton; private final ITextComponent title = Lang.translate("gui.chromatic_projector.title"); - private ListNBT compareTag; private Vector stages; - private BlockPos pos; private Vector> inputs; @@ -47,8 +42,6 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { public ChromaticProjectorScreen(ChromaticProjectorTileEntity te) { this.tile = te; this.stages = te.stages; - this.pos = te.getPos(); - //compareTag = Instruction.serializeAll(stages); } private static Integer step(ScrollValueBehaviour.StepContext ctx, int base) { @@ -62,7 +55,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { super.init(); widgets.clear(); - inputs = new Vector<>(MAX_STEPS); + inputs = new Vector<>(FilterStep.MAX_STEPS); for (int row = 0; row < inputs.capacity(); row++) inputs.add(new Vector<>(2)); @@ -203,7 +196,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { } public void sendPacket() { - + AllPackets.channel.sendToServer(new ConfigureProjectorPacket(tile)); } @Override diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java index d2ebe9f6f..338c2fd20 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java @@ -4,20 +4,23 @@ import java.util.Vector; import com.simibubi.create.foundation.render.backend.effects.FilterSphere; import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; +import com.simibubi.create.foundation.tileEntity.SyncedTileEntity; -import net.minecraft.tileentity.TileEntity; +import net.minecraft.block.BlockState; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; +import net.minecraftforge.common.util.Constants; -public class ChromaticProjectorTileEntity extends TileEntity implements IInstanceRendered { +public class ChromaticProjectorTileEntity extends SyncedTileEntity implements IInstanceRendered { Vector stages = FilterStep.createDefault(); - float radius = 10f; - float density = 1f; - float feather = 3; - float fade = 1.3f; + float radius = 3f; + float density = 1; + float feather = 1; + float fade = 1; boolean blend = true; public ChromaticProjectorTileEntity(TileEntityType te) { @@ -62,4 +65,30 @@ public class ChromaticProjectorTileEntity extends TileEntity implements IInstanc this.blend = blend; return this; } + + @Override + public CompoundNBT write(CompoundNBT tag) { + super.write(tag); + + tag.put("filters", FilterStep.writeAll(stages)); + + tag.putFloat("radius", radius); + tag.putFloat("density", density); + tag.putFloat("feather", feather); + tag.putFloat("fade", fade); + + return tag; + } + + @Override + public void fromTag(BlockState state, CompoundNBT tag) { + super.fromTag(state, tag); + + stages = FilterStep.readAll(tag.getList("filters", Constants.NBT.TAG_COMPOUND)); + + radius = tag.getFloat("radius"); + density = tag.getFloat("density"); + feather = tag.getFloat("feather"); + fade = tag.getFloat("fade"); + } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ConfigureProjectorPacket.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ConfigureProjectorPacket.java new file mode 100644 index 000000000..be616532b --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ConfigureProjectorPacket.java @@ -0,0 +1,76 @@ +package com.simibubi.create.content.curiosities.projector; + +import java.util.Vector; +import java.util.stream.Collectors; + +import com.simibubi.create.foundation.networking.TileEntityConfigurationPacket; + +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; + +public class ConfigureProjectorPacket extends TileEntityConfigurationPacket { + + Vector stages; + float radius; + float density; + float feather; + float fade; + + public ConfigureProjectorPacket(PacketBuffer buffer) { + super(buffer); + } + + public ConfigureProjectorPacket(ChromaticProjectorTileEntity tile) { + super(tile.getPos()); + + stages = tile.stages.stream() + .map(FilterStep::write) + .collect(Collectors.toCollection(Vector::new)); + this.radius = tile.radius; + this.density = tile.density; + this.feather = tile.feather; + this.fade = tile.fade; + } + + @Override + protected void writeSettings(PacketBuffer buffer) { + buffer.writeFloat(radius); + buffer.writeFloat(density); + buffer.writeFloat(feather); + buffer.writeFloat(fade); + + buffer.writeInt(stages.size()); + for (CompoundNBT stage : stages) { + buffer.writeCompoundTag(stage); + } + } + + @Override + protected void readSettings(PacketBuffer buffer) { + radius = buffer.readFloat(); + density = buffer.readFloat(); + feather = buffer.readFloat(); + fade = buffer.readFloat(); + + int count = buffer.readInt(); + stages = new Vector<>(FilterStep.MAX_STEPS); + + for (int i = 0; i < count; i++) { + stages.add(buffer.readCompoundTag()); + } + } + + @Override + protected void applySettings(ChromaticProjectorTileEntity tile) { + tile.stages = stages.stream() + .map(FilterStep::new) + .collect(Collectors.toCollection(Vector::new)); + + tile.radius = this.radius; + tile.density = this.density; + tile.feather = this.feather; + tile.fade = this.fade; + + tile.sendData(); + } +} diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java index e2c900236..a02d3bede 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java @@ -5,10 +5,13 @@ import java.util.Vector; import com.simibubi.create.foundation.render.backend.effects.ColorMatrices; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; import net.minecraft.util.math.vector.Matrix4f; public class FilterStep { + public static final int MAX_STEPS = 4; ColorEffect filter; int value; @@ -21,10 +24,44 @@ public class FilterStep { this.value = value; } + public FilterStep(CompoundNBT nbt) { + this.filter = ColorEffect.lookup.get(nbt.getString("id")); + this.value = nbt.getInt("value"); + } + public Matrix4f createFilter() { return filter.filter.create(value / filter.divisor); } + public CompoundNBT write() { + CompoundNBT nbt = new CompoundNBT(); + + nbt.putString("id", filter.name); + nbt.putInt("value", value); + + return nbt; + } + + public static Vector readAll(ListNBT list) { + Vector steps = new Vector<>(MAX_STEPS); + + for (int i = 0; i < list.size(); i++) { + steps.add(new FilterStep(list.getCompound(i))); + } + + return steps; + } + + public static ListNBT writeAll(Vector filters) { + ListNBT out = new ListNBT(); + + for (FilterStep filter : filters) { + out.add(filter.write()); + } + + return out; + } + public static Matrix4f fold(Vector filters) { Iterator stepIterator = filters.stream().filter(it -> it != null && it.filter != ColorEffect.END).iterator(); @@ -40,7 +77,7 @@ public class FilterStep { } public static Vector createDefault() { - Vector instructions = new Vector<>(ChromaticProjectorScreen.MAX_STEPS); + Vector instructions = new Vector<>(MAX_STEPS); instructions.add(new FilterStep(ColorEffect.SEPIA, 100)); instructions.add(new FilterStep(ColorEffect.END)); return instructions; diff --git a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java index 3e417d17f..667ac2f5d 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java +++ b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java @@ -1,49 +1,5 @@ package com.simibubi.create.foundation.networking; -import static net.minecraftforge.fml.network.NetworkDirection.PLAY_TO_CLIENT; -import static net.minecraftforge.fml.network.NetworkDirection.PLAY_TO_SERVER; - -import java.util.function.BiConsumer; -import java.util.function.Function; -import java.util.function.Supplier; - -import com.simibubi.create.Create; -import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionDisassemblyPacket; -import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionStallPacket; -import com.simibubi.create.content.contraptions.components.structureMovement.gantry.GantryContraptionUpdatePacket; -import com.simibubi.create.content.contraptions.components.structureMovement.glue.GlueEffectPacket; -import com.simibubi.create.content.contraptions.components.structureMovement.sync.ClientMotionPacket; -import com.simibubi.create.content.contraptions.components.structureMovement.sync.ContraptionFluidPacket; -import com.simibubi.create.content.contraptions.components.structureMovement.sync.ContraptionInteractionPacket; -import com.simibubi.create.content.contraptions.components.structureMovement.sync.ContraptionSeatMappingPacket; -import com.simibubi.create.content.contraptions.components.structureMovement.sync.LimbSwingUpdatePacket; -import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingCreationPacket; -import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartControllerUpdatePacket; -import com.simibubi.create.content.contraptions.fluids.actors.FluidSplashPacket; -import com.simibubi.create.content.contraptions.relays.advanced.sequencer.ConfigureSequencedGearshiftPacket; -import com.simibubi.create.content.curiosities.symmetry.SymmetryEffectPacket; -import com.simibubi.create.content.curiosities.tools.ExtendoGripInteractionPacket; -import com.simibubi.create.content.curiosities.zapper.ZapperBeamPacket; -import com.simibubi.create.content.logistics.block.depot.EjectorElytraPacket; -import com.simibubi.create.content.logistics.block.depot.EjectorPlacementPacket; -import com.simibubi.create.content.logistics.block.depot.EjectorTriggerPacket; -import com.simibubi.create.content.logistics.block.mechanicalArm.ArmPlacementPacket; -import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket; -import com.simibubi.create.content.logistics.packet.ConfigureFlexcratePacket; -import com.simibubi.create.content.logistics.packet.ConfigureStockswitchPacket; -import com.simibubi.create.content.logistics.packet.FunnelFlapPacket; -import com.simibubi.create.content.logistics.packet.TunnelFlapPacket; -import com.simibubi.create.content.schematics.packet.ConfigureSchematicannonPacket; -import com.simibubi.create.content.schematics.packet.InstantSchematicPacket; -import com.simibubi.create.content.schematics.packet.SchematicPlacePacket; -import com.simibubi.create.content.schematics.packet.SchematicSyncPacket; -import com.simibubi.create.content.schematics.packet.SchematicUploadPacket; -import com.simibubi.create.foundation.command.ConfigureConfigPacket; -import com.simibubi.create.foundation.command.HighlightPacket; -import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringCountUpdatePacket; -import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueUpdatePacket; -import com.simibubi.create.foundation.utility.ServerSpeedProvider; - import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; @@ -55,6 +11,43 @@ import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fml.network.PacketDistributor.TargetPoint; import net.minecraftforge.fml.network.simple.SimpleChannel; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.function.Supplier; + +import com.simibubi.create.Create; +import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionDisassemblyPacket; +import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionStallPacket; +import com.simibubi.create.content.contraptions.components.structureMovement.gantry.GantryContraptionUpdatePacket; +import com.simibubi.create.content.contraptions.components.structureMovement.glue.GlueEffectPacket; +import com.simibubi.create.content.contraptions.components.structureMovement.sync.*; +import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingCreationPacket; +import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartControllerUpdatePacket; +import com.simibubi.create.content.contraptions.fluids.actors.FluidSplashPacket; +import com.simibubi.create.content.contraptions.relays.advanced.sequencer.ConfigureSequencedGearshiftPacket; +import com.simibubi.create.content.curiosities.projector.ConfigureProjectorPacket; +import com.simibubi.create.content.curiosities.symmetry.SymmetryEffectPacket; +import com.simibubi.create.content.curiosities.tools.ExtendoGripInteractionPacket; +import com.simibubi.create.content.curiosities.zapper.ZapperBeamPacket; +import com.simibubi.create.content.logistics.block.depot.EjectorElytraPacket; +import com.simibubi.create.content.logistics.block.depot.EjectorPlacementPacket; +import com.simibubi.create.content.logistics.block.depot.EjectorTriggerPacket; +import com.simibubi.create.content.logistics.block.mechanicalArm.ArmPlacementPacket; +import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket; +import com.simibubi.create.content.logistics.packet.ConfigureFlexcratePacket; +import com.simibubi.create.content.logistics.packet.ConfigureStockswitchPacket; +import com.simibubi.create.content.logistics.packet.FunnelFlapPacket; +import com.simibubi.create.content.logistics.packet.TunnelFlapPacket; +import com.simibubi.create.content.schematics.packet.*; +import com.simibubi.create.foundation.command.ConfigureConfigPacket; +import com.simibubi.create.foundation.command.HighlightPacket; +import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringCountUpdatePacket; +import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueUpdatePacket; +import com.simibubi.create.foundation.utility.ServerSpeedProvider; + +import static net.minecraftforge.fml.network.NetworkDirection.PLAY_TO_CLIENT; +import static net.minecraftforge.fml.network.NetworkDirection.PLAY_TO_SERVER; + public enum AllPackets { // Client to Server @@ -63,7 +56,8 @@ public enum AllPackets { CONFIGURE_FLEXCRATE(ConfigureFlexcratePacket.class, ConfigureFlexcratePacket::new, PLAY_TO_SERVER), CONFIGURE_STOCKSWITCH(ConfigureStockswitchPacket.class, ConfigureStockswitchPacket::new, PLAY_TO_SERVER), CONFIGURE_SEQUENCER(ConfigureSequencedGearshiftPacket.class, ConfigureSequencedGearshiftPacket::new, - PLAY_TO_SERVER), + PLAY_TO_SERVER), + CONFIGURE_PROJECTOR(ConfigureProjectorPacket.class, ConfigureProjectorPacket::new, PLAY_TO_SERVER), PLACE_SCHEMATIC(SchematicPlacePacket.class, SchematicPlacePacket::new, PLAY_TO_SERVER), UPLOAD_SCHEMATIC(SchematicUploadPacket.class, SchematicUploadPacket::new, PLAY_TO_SERVER), CONFIGURE_FILTER(FilterScreenPacket.class, FilterScreenPacket::new, PLAY_TO_SERVER), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java index 77aa77123..6cf354755 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java @@ -85,7 +85,7 @@ public class FilterSphere { 0.5f, //r, 0.1f, //g, 0.1f, //b, - 0.12f, //colorFeather, + 0f, //colorFeather, }); buf.put(RenderUtil.writeMatrix(filter)); From 54f57834898144557492b148e9d34ea7f7b61d3e Mon Sep 17 00:00:00 2001 From: JozsefA Date: Wed, 28 Apr 2021 00:01:26 -0700 Subject: [PATCH 016/198] More versatile ui/settings - The channel mask still needs work - Add contrast filter --- .../resources/assets/create/lang/en_us.json | 13 +- .../projector/ChromaticProjectorInstance.java | 2 +- .../projector/ChromaticProjectorScreen.java | 112 +++++++++++++++--- .../ChromaticProjectorTileEntity.java | 74 +++++++++--- .../curiosities/projector/ColorEffect.java | 3 +- .../projector/ConfigureProjectorPacket.java | 72 +++++++++-- .../curiosities/projector/FilterStep.java | 2 +- .../create/foundation/gui/AllGuiTextures.java | 2 +- .../create/foundation/gui/AllIcons.java | 17 +-- .../foundation/gui/widgets/IconButton.java | 3 + .../foundation/render/backend/RenderUtil.java | 12 +- .../render/backend/effects/ColorMatrices.java | 33 ++++-- .../backend/effects/EffectsHandler.java | 11 +- .../render/backend/effects/FilterSphere.java | 92 +++++--------- .../create/flywheel/shaders/area_effect.frag | 32 +++-- .../assets/create/textures/gui/icons.png | Bin 2923 -> 4934 bytes .../assets/create/textures/gui/projector.png | Bin 3428 -> 4461 bytes 17 files changed, 336 insertions(+), 144 deletions(-) diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index b266bf403..b43e08e8e 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -1154,8 +1154,17 @@ "create.gui.chromatic_projector.filter.saturate": "Saturate", "create.gui.chromatic_projector.filter.hue_shift": "Hue shift", "create.gui.chromatic_projector.filter.darken": "Darken", + "create.gui.chromatic_projector.filter.contrast": "Contrast", "create.gui.chromatic_projector.filter.end": "End", "create.gui.chromatic_projector.filter": "Filter", + "create.gui.chromatic_projector.surface": "Surface", + "create.gui.chromatic_projector.field": "Field", + "create.gui.chromatic_projector.strength": "Strength", + "create.gui.chromatic_projector.radius": "Radius", + "create.gui.chromatic_projector.feather": "Feather", + "create.gui.chromatic_projector.density": "Density", + "create.gui.chromatic_projector.fade": "Fade", + "create.gui.chromatic_projector.blend": "Blend", "_": "->------------------------] Subtitles [------------------------<-", "create.subtitle.cogs": "Cogwheels rumble", "create.subtitle.slime_added": "Slime squishes", @@ -1163,8 +1172,8 @@ "create.subtitle.mechanical_press_activation_belt": "Mechanical Press bonks", "create.subtitle.blockzapper_confirm": "Affirmative ding", "create.subtitle.depot_slide": "Item slides", - "create.subtitle.blockzapper_place": "Blockzapper zaps", - "create.subtitle.blaze_munch": "Blaze Burner munches", + "create.subtitle.blockzapper_place": "Blockzapper zaps", + "create.subtitle.blaze_munch": "Blaze Burner munches", "create.subtitle.schematicannon_launch_block": "Schematicannon fires", "create.subtitle.funnel_flap": "Funnel Flaps", "create.subtitle.schematicannon_finish": "Schematicannon dings", diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java index 3394a08c3..ea7aa760a 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java @@ -13,7 +13,7 @@ public class ChromaticProjectorInstance extends TileEntityInstance stages; + private final Vector stages; private Vector> inputs; @@ -39,6 +41,15 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { private ScrollInput feather; private ScrollInput fade; + private IconButton blend; + + private ScrollInput strength; + private IconButton fieldEffect; + + private IconButton rChannel; + private IconButton gChannel; + private IconButton bChannel; + public ChromaticProjectorScreen(ChromaticProjectorTileEntity te) { this.tile = te; this.stages = te.stages; @@ -62,35 +73,73 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { for (int row = 0; row < stages.size(); row++) initInputsOfRow(row); + int guiBottom = guiTop + background.height; + int guiRight = guiLeft + background.width; confirmButton = - new IconButton(guiLeft + background.width - 33, guiTop + background.height - 24, AllIcons.I_CONFIRM); + new IconButton(guiRight - 33, guiBottom - 26, AllIcons.I_CONFIRM); widgets.add(confirmButton); - int xRight = guiLeft + 53; - int xLeft = guiLeft + 93; - int yTop = guiTop + 117; - int yBottom = guiTop + 139; + initEffectSettings(); + initMetaSettings(); + } - radius = new ScrollInput(xRight, yTop, 28, 18) - .titled(new StringTextComponent("Radius")) + private void initMetaSettings() { + int guiBottom = guiTop + background.height; + int y = guiBottom - 23; + + blend = new IconButton(guiLeft + 16, y, AllIcons.I_FX_BLEND); + blend.setToolTip(Lang.translate("gui.chromatic_projector.blend")); + + int channelX = guiLeft + 39; + rChannel = new IconButton(channelX, y, AllIcons.I_FX_BLEND); + rChannel.setToolTip(new StringTextComponent("R")); + channelX += 18; + gChannel = new IconButton(channelX, y, AllIcons.I_FX_BLEND); + gChannel.setToolTip(new StringTextComponent("G")); + channelX += 18; + bChannel = new IconButton(channelX, y, AllIcons.I_FX_BLEND); + bChannel.setToolTip(new StringTextComponent("B")); + + fieldEffect = new IconButton(guiLeft + 135, y, tile.field ? AllIcons.I_FX_FIELD_ON : AllIcons.I_FX_FIELD_OFF); + fieldEffect.setToolTip(Lang.translate("gui.chromatic_projector.field")); + + strength = new ScrollInput(guiLeft + 159, y, 25, 18) + .titled(Lang.translate("gui.chromatic_projector.strength")) + .withStepFunction(ctx -> step(ctx, 5)) + .calling(tile::setStrength) + .withRange(0, 101) + .setState((int) (tile.strength * 100)); + + Collections.addAll(widgets, blend, rChannel, gChannel, bChannel, fieldEffect, strength); + } + + private void initEffectSettings() { + int x = guiLeft + 188; + int y = guiTop + 40; + + radius = new ScrollInput(x, y, 28, 18) + .titled(Lang.translate("gui.chromatic_projector.radius")) .withStepFunction(ctx -> step(ctx, 2)) .calling(tile::setRadius) .withRange(0, 201) .setState((int) (tile.radius * 2)); - feather = new ScrollInput(xRight, yBottom, 28, 18) - .titled(new StringTextComponent("Feather")) + y += 22; + feather = new ScrollInput(x, y, 28, 18) + .titled(Lang.translate("gui.chromatic_projector.feather")) .withStepFunction(ctx -> step(ctx, 5)) .calling(tile::setFeather) .withRange(0, 201) .setState((int) (tile.feather * 10)); - density = new ScrollInput(xLeft, yTop, 28, 18) - .titled(new StringTextComponent("Density")) + y += 22; + density = new ScrollInput(x, y, 28, 18) + .titled(Lang.translate("gui.chromatic_projector.density")) .withStepFunction(ctx -> step(ctx, 10)) .calling(tile::setDensity) .withRange(0, 401) .setState((int) (tile.density * 100)); - fade = new ScrollInput(xLeft, yBottom, 28, 18) - .titled(new StringTextComponent("Fade")) + y += 22; + fade = new ScrollInput(x, y, 28, 18) + .titled(Lang.translate("gui.chromatic_projector.fade")) .withStepFunction(ctx -> step(ctx, 1)) .calling(tile::setFade) .withRange(0, 51) @@ -112,7 +161,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { ScrollInput type = new SelectionScrollInput(x, y + rowHeight * row, 86, 18) .forOptions(ColorEffect.getOptions()) - .calling(state -> instructionUpdated(row, state)) + .calling(state -> stageUpdated(row, state)) .setState(filter.filter.id) .titled(Lang.translate("gui.chromatic_projector.filter")); ScrollInput value = @@ -174,6 +223,8 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { renderScroll(matrixStack, feather, 10f); renderScroll(matrixStack, fade, 10f); + renderScroll(matrixStack, strength, 100f); + textRenderer.drawWithShadow(matrixStack, title, guiLeft - 3 + (background.width - textRenderer.getWidth(title)) / 2, guiTop + 3, 0xffffff); @@ -188,7 +239,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { String text = String.valueOf(input.getState() / divisor); int stringWidth = textRenderer.getStringWidth(text); - textRenderer.drawWithShadow(matrixStack, text, input.x + (12 - stringWidth / 2), input.y + 5, 0xFFFFEE); + textRenderer.drawWithShadow(matrixStack, text, input.x + 2, input.y + 5, 0xFFFFEE); } private void label(MatrixStack matrixStack, int x, int y, ITextComponent text) { @@ -204,7 +255,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { sendPacket(); } - private void instructionUpdated(int index, int state) { + private void stageUpdated(int index, int state) { ColorEffect newValue = ColorEffect.all.get(state); stages.get(index).filter = newValue; stages.get(index).value = newValue.defaultValue; @@ -231,6 +282,33 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { return true; } + if (blend.isHovered()) { + tile.blend = !tile.blend; + return true; + } + + if (fieldEffect.isHovered()) { + tile.field = !tile.field; + + fieldEffect.setIcon(tile.field ? AllIcons.I_FX_FIELD_ON : AllIcons.I_FX_FIELD_OFF); + return fieldEffect.mouseClicked(x, y, button); + } + + if (rChannel.isHovered()) { + tile.rMask = !tile.rMask; + return true; + } + + if (gChannel.isHovered()) { + tile.gMask = !tile.gMask; + return true; + } + + if (bChannel.isHovered()) { + tile.bMask = !tile.bMask; + return true; + } + return super.mouseClicked(x, y, button); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java index 338c2fd20..0bb20e983 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java @@ -10,7 +10,6 @@ import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.vector.Matrix4f; import net.minecraftforge.common.util.Constants; public class ChromaticProjectorTileEntity extends SyncedTileEntity implements IInstanceRendered { @@ -18,27 +17,49 @@ public class ChromaticProjectorTileEntity extends SyncedTileEntity implements II Vector stages = FilterStep.createDefault(); float radius = 3f; - float density = 1; + float feather = 1; + float density = 1; float fade = 1; boolean blend = true; + public boolean surface = true; + public boolean field = true; + public float strength = 1; + + public boolean rMask = true; + public boolean gMask = true; + public boolean bMask = true; + public ChromaticProjectorTileEntity(TileEntityType te) { super(te); } - public FilterSphere makeFilter() { - Matrix4f filter = FilterStep.fold(stages); + public FilterSphere getFilter() { BlockPos pos = getPos(); - return new FilterSphere() - .setFilter(filter) - .setCenter(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5) - .setRadius(radius) - .setDensity(density) - .setFeather(feather) - .setBlendOver(true) - .setFade(fade); + FilterSphere sphere = new FilterSphere(); + + sphere.x = (float) (pos.getX() + 0.5); + sphere.y = (float) (pos.getY() + 0.5); + sphere.z = (float) (pos.getZ() + 0.5); + sphere.radius = radius; + + sphere.feather = feather; + sphere.density = density; + sphere.fade = fade; + sphere.blend = blend; + + sphere.surface = surface; + sphere.field = field; + sphere.strength = strength; + + sphere.rMask = rMask; + sphere.gMask = gMask; + sphere.bMask = bMask; + + sphere.filter = FilterStep.fold(stages); + return sphere; } public ChromaticProjectorTileEntity setRadius(int radius) { @@ -66,6 +87,11 @@ public class ChromaticProjectorTileEntity extends SyncedTileEntity implements II return this; } + public ChromaticProjectorTileEntity setStrength(int strength) { + this.strength = strength / 100f; + return this; + } + @Override public CompoundNBT write(CompoundNBT tag) { super.write(tag); @@ -73,9 +99,19 @@ public class ChromaticProjectorTileEntity extends SyncedTileEntity implements II tag.put("filters", FilterStep.writeAll(stages)); tag.putFloat("radius", radius); - tag.putFloat("density", density); + tag.putFloat("feather", feather); + tag.putFloat("density", density); tag.putFloat("fade", fade); + tag.putBoolean("blend", blend); + + tag.putBoolean("surface", surface); + tag.putBoolean("field", field); + tag.putFloat("strength", strength); + + tag.putBoolean("rMask", rMask); + tag.putBoolean("gMask", gMask); + tag.putBoolean("bMask", bMask); return tag; } @@ -87,8 +123,18 @@ public class ChromaticProjectorTileEntity extends SyncedTileEntity implements II stages = FilterStep.readAll(tag.getList("filters", Constants.NBT.TAG_COMPOUND)); radius = tag.getFloat("radius"); - density = tag.getFloat("density"); + feather = tag.getFloat("feather"); + density = tag.getFloat("density"); fade = tag.getFloat("fade"); + blend = tag.getBoolean("blend"); + + surface = tag.getBoolean("surface"); + field = tag.getBoolean("field"); + strength = tag.getFloat("strength"); + + rMask = tag.getBoolean("rMask"); + gMask = tag.getBoolean("gMask"); + bMask = tag.getBoolean("bMask"); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java index 12c0a0822..0d072b419 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java @@ -19,12 +19,13 @@ public class ColorEffect { static final HashMap lookup = new HashMap<>(); private static int nextId = 0; - public static final ColorEffect INVERT = create("invert", ColorMatrices::invert); public static final ColorEffect SEPIA = create("sepia", ColorMatrices::sepia); public static final ColorEffect GRAYSCALE = create("grayscale", ColorMatrices::grayscale); public static final ColorEffect DARKEN = create("darken", ColorMatrices::darken).setDefaultValue(20); + public static final ColorEffect CONTRAST = create("contrast", ColorMatrices::contrast).setRange(0, 200).setDefaultValue(100); public static final ColorEffect SATURATE = create("saturate", ColorMatrices::saturate).setRange(0, 200); public static final ColorEffect HUE_SHIFT = create("hue_shift", ColorMatrices::hueShift).setRange(0, 360).setDivisor(1f).setDefaultValue(120); + public static final ColorEffect INVERT = create("invert", ColorMatrices::invert); public static final ColorEffect END = create("end", ColorMatrices::identity).setBackground(AllGuiTextures.PROJECTOR_END); boolean hasParameter; diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ConfigureProjectorPacket.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ConfigureProjectorPacket.java index be616532b..89eb463b3 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ConfigureProjectorPacket.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ConfigureProjectorPacket.java @@ -12,9 +12,19 @@ public class ConfigureProjectorPacket extends TileEntityConfigurationPacket stages; float radius; - float density; + float feather; + float density; float fade; + boolean blend; + + public boolean surface; + public boolean field; + public float strength; + + public boolean rMask; + public boolean gMask; + public boolean bMask; public ConfigureProjectorPacket(PacketBuffer buffer) { super(buffer); @@ -26,18 +36,38 @@ public class ConfigureProjectorPacket extends TileEntityConfigurationPacket(FilterStep.MAX_STEPS); @@ -66,10 +106,20 @@ public class ConfigureProjectorPacket extends TileEntityConfigurationPacket (int) Math.signum(o2.center.length() - o1.center.length())); + spheres.sort((o1, o2) -> { + double l1 = RenderUtil.length(o1.x, o1.y, o1.z); + double l2 = RenderUtil.length(o2.x, o2.y, o2.z); + return (int) Math.signum(l2 - l1); + }); program.uploadFilters(spheres); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java index 6cf354755..0b6d4f881 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java @@ -5,87 +5,49 @@ import java.nio.FloatBuffer; import com.simibubi.create.foundation.render.backend.RenderUtil; import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3d; public class FilterSphere { - public Vector3d center; + public float x; + public float y; + public float z; public float radius; + public float feather; public float fade; public float density = 2; - public float strength = 1; - public boolean blendOver = false; + public boolean blend = false; - public float r; - public float g; - public float b; - public float colorFeather; + public boolean surface = true; + public boolean field = true; + public float strength = 1; + + public boolean rMask; + public boolean gMask; + public boolean bMask; public Matrix4f filter; - public FilterSphere setCenter(Vector3d center) { - this.center = center; - return this; - } - - public FilterSphere setCenter(double x, double y, double z) { - this.center = new Vector3d(x, y, z); - return this; - } - - public FilterSphere setRadius(float radius) { - this.radius = radius; - return this; - } - - public FilterSphere setFeather(float feather) { - this.feather = feather; - return this; - } - - public FilterSphere setFade(float fade) { - this.fade = fade; - return this; - } - - public FilterSphere setDensity(float density) { - this.density = density; - return this; - } - - public FilterSphere setStrength(float strength) { - this.strength = strength; - return this; - } - - public FilterSphere setFilter(Matrix4f filter) { - this.filter = filter; - return this; - } - - public FilterSphere setBlendOver(boolean blendOver) { - this.blendOver = blendOver; - return this; - } - public void write(FloatBuffer buf) { buf.put(new float[]{ - (float) center.x, - (float) center.y, - (float) center.z, + x, + y, + z, radius, + feather, fade, density, - blendOver ? 1f : 0f, - 1f, - 1f, - 0f, - 0f, - 0.5f, //r, - 0.1f, //g, - 0.1f, //b, - 0f, //colorFeather, + blend ? 1 : 0, + + surface ? 1 : 0, + field ? 1 : 0, + strength, + 0, // padding + + rMask ? 1 : 0, + gMask ? 1 : 0, + bMask ? 1 : 0, + 0, // padding }); buf.put(RenderUtil.writeMatrix(filter)); diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index 3a43ac7a4..86e987ecc 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -17,8 +17,8 @@ uniform vec3 uCameraPos; struct SphereFilter { vec4 sphere;// vec4 d1;// - vec4 d2;// - vec4 colorMask;// + vec4 strength;// + vec4 channelMask;// mat4 colorOp; }; @@ -69,6 +69,12 @@ vec2 raySphere(vec3 worldDir, vec3 position, float radius) { return vec2(discriminant, hitDepth); } +// if i == 0 return s +// if i == 1 return 1 - s +float invert(float s, float i) { + return i - 2*i*s + s; +} + float bubbleFilterStrength(vec3 worldDir, float depth, vec4 sphere, float feather, float density) { vec3 position = sphere.xyz; @@ -96,18 +102,18 @@ float filterStrength(vec3 worldDir, float depth, inout SphereFilter f) { vec4 data = f.d1; float feather = data.x; - float strength = 0.; + float strength; // transition effect float transitionRadius = sphere.w + feather; - strength += 1. - smoothstep(transitionRadius, transitionRadius + data.y, length(sphere.xyz)); + strength = 1. - smoothstep(transitionRadius, transitionRadius + max(0.5, data.y), length(sphere.xyz)); // bubble effect - strength += bubbleFilterStrength(worldDir, depth, sphere, feather, data.z); + strength = max(strength, bubbleFilterStrength(worldDir, depth, sphere, feather, data.z)); - strength *= f.d2.y; + strength *= f.strength.y; // surface effect - strength += surfaceFilterStrength(worldDir * depth, sphere, feather) * f.d2.x; + strength = max(strength, surfaceFilterStrength(worldDir * depth, sphere, feather) * f.strength.x); - return strength; + return strength * f.strength.z; } vec3 applyFilters(vec3 worldDir, float depth, vec3 diffuse) { @@ -127,13 +133,13 @@ vec3 applyFilters(vec3 worldDir, float depth, vec3 diffuse) { vec3 filtered = filterColor(s.colorOp, baseColor); - vec3 baseHsv = rgb2hsv(baseColor); - vec3 maskHsv = rgb2hsv(s.colorMask.rgb); - vec3 diff = abs(baseHsv - maskHsv) * vec3(1., 1.1, 0.1); - float colorMask = step(s.colorMask.w, length(diff)); + // vec3 baseHsv = rgb2hsv(baseColor); + // vec3 maskHsv = rgb2hsv(s.colorMask.rgb); + // float diff = dot(abs(baseHsv - maskHsv), vec3(1., 1.1, 0.1)); + // float colorMask = step(s.colorMask.w, diff); float mixing = clamp(strength, 0., 1.); - accum = mix(accum, filtered, mixing * colorMask); + accum = mix(accum, filtered, mixing * s.channelMask.xyz); //accum = vec3(colorMask); } } diff --git a/src/main/resources/assets/create/textures/gui/icons.png b/src/main/resources/assets/create/textures/gui/icons.png index 1dff79b367fb92985f19643b0fe3032bca2a9dae..2fbdf43bb6a8df13e5eaa780edf8ca662ee9c0e7 100644 GIT binary patch literal 4934 zcmdT|c{r5o-=DEWvXw$AO=FKSn^{bDBkLekmMmiyCbONHv5Y9RSV~&7D=Hm@3Mr8e zN0P10mMz(pRD=?S-$Uini($@TOAhRv={9yY+(+uM8e=+W@-@P>wlfq{YH;o<1$=+mc9 zJ2^S!=jS^+JIBPt05BJqc0*v07q~gQ&;NRXY|1;Uft}@CJ1;%}NL%=UrBdBrgFwql z86KVjPm&XX!eJSbshmKXVFZf{pg|xL^9U}P5<(L|0%<`Ewkh<}gEA~w1Y}4Ai^=8_B21x+atXkEVHpmEEJ6e! zrclcTg%D4YE5w?^qd_o+SQrIqgo5CV4Ut%cG0MmQf1w8$*6v zP(T}xN+-AxxBk!t+?hgy1p+Ps4hI5e7>+jN@Pgn-V`F1D0tH8*U;qNf7qSK92pF5M z@lyhk#;5QYTmgf_hAc=V2XaCMrcl7r?=G;oOJdplA7KIl29F?f;YdTof=i1)DrE`B z4dpQxl~XBj8k5GNu?2hpi(JBTgE;~YKbZ4xL@#as7X?6QNu(tme`yPgwWNYCun7a) z_z{r5MDsm_TpHYs#^;3cC^VZez)Xz=Z@2_&9*r#E@H{vi=FddA{xlh4ZM~2fJVbXV zgH7dx^Ywl?LnD#}G*c)FfkMI%Xc!9bfkY9E@B}mhhQJXJi0@DmhsvM}e}x*sP&f}H zhJZFA7y-%t1q!f+N*0j+S1^@ApmTUEGT<|VMGm6Dx$Gb)WGRvaYYvmc0~9Y<_v^a7 zwY4jcLuW974ZfSL6~x}g8jCc>Vqqvl2i47HV^WJ_I`kA4sh5NAh6mFCq5pvw-(h?XT@X&@(JX_2X#E}P z!T+88d~(=-wjM#J;W0RBAdH4UB4Jn@z&kRTOoidmC^`m9rr{A3%1`fqwH}}<#si5Y zpwWbdzVw}{|Iqp$!KDO~*+Dd*xx%6U+@HV4$N!m)zbw7~Q-9zKZS_0V;QyV4i+jJc zU?81~OF&;=m@Yj~fSaX95{(UniU&M!g2a!`fIus{?TMBi5osTMJ5Kc7lV{dGOUu@% zpP$#=b>STKm9X0eWcQl++(P}1ew(jdY7;Y7#Ugcm*I2u1>GFua&aQe;@H@O;m&l}A z?5xa(9AA@&GukDH3w7RmK59D7gb+w^Foo{V@XfYW^G)aazn!hz_D!}VX}CAH^^A4n zy+fpmdhCja+1dH8U$lyKwo54{RAQEQD=!ZnbAaT>f}*Pg$34zhZfm0>@(Y^Rh7iya zkM?v$@4Vpm4t>NHVR1syowv!$y&>&vuF}eNDipq?<7In9DTgm4^R;)H+-YqbJ9hrO zOpwB%&Cg3#K=>x>z~{6jC%(1W6?x7}$?ccTCV-p!?flcr4;$JZ%c8^uE4CTJAh=kb z9W$W5-k`dE*R3{*T&dhYO9WSya#Ik#*Gu{e%@jMd|1_FBmpNA+=u002pT5Odr8zH_ zAm@*oxCzOXw;gG)>*5cXf0@f?ZwiRHzAMJ@@OWQSi~dL<`kr+88j%Q67m%3o(2w@! z_RiSzQuWC!VZ)XEYlOS>aPeCsy3ThQ)$O<^m*$v%jhkPfkqL4v$UZnJ|chWEl{(B&F}Q6tB~b@)l2IO*LyVs%|yNRaP2t91naQY<_xo z+^4w!UzZZjyqXTR{o1oYajyGvX5z z_hya!&Z4Q8;rtI#{Gm_ZKpe5Iw_*`WQ*MR7J60LElg9!qN3w)7Zv*Q7FqKtN$hb>> z{LETi?bJTWiT)-{%_L(ptFL||;Ay)eT13L0+&it49_rH3 zRF)&CvJx(<$mo5!Nmfe&oDeKsgU?cXCv$DerV5>O^=?iuvE5h!aw+}X^!qGPvDu2X z;0JF;v>>~hKfd3dCJl<`CKo5iSm9F31W#q*B-A30$cCqnKn_tiQpI#lqksA9YCJVDpg!sZyCP?kIt z-YV-5?%5AgHW8Dnsp%Tq?z2(h@O%ir@Nre7YU$e4we6_~sIB*}4zDgr=?L_ZQ6t6H z7NGLqgT*rWN!t=m+*JOpNgdJ1Fe|^8tnK6R$sngvS^J?2Uav(@|75uv{kc?x(&$!| zZhhyHFNkk*@lR78)$J)4J%VV+k=>~lRy$Oe_pIY@m{0~Y^o$Y?#n46NEv$Hn`O^+T^EiP8b z3u(!2t269SNU4=Fkma*xK)8)DQTU|#hQVc^w~`-Dt@;xEf!f$Pr{>e8Jf}ufc+nOU zc*@i6cG>M=^S(F3(K9xA-j_yidJaoCwz91?W_FL)8>L@=Xl_=0v4x{~FiP!lh9MJr zyTA^@hI8tPlG^e4V4p^1{p3XHvH7Sl-g_026>(i6dL=keWD4D0t6o5gWzaj@&3Le(m%CC7VJN`hz^xBzGqiIWfOJq*EL# zdLD3>89cz=S=N*NDI_YM(q$%%jenH#kn-f*a&^eY?!)SGk&Ah+>N~os{&liu`NyWp z$o>iw&Iaj$cX@NSlCWt`men};_V?GHAw%QBz@NqNdu3gMt*)PhHd_{r&hQep1?&;6q-;5_p!tfs ze&4Z2-Si!qW>c<@9BS^a@!vv-ahC>v=~~mlsHdOymZ>j&Ixjlg(3^84yF-hApncQn zlf4H@E`(YqEeqefdTny$sF@1t{fpUSCf!}?%zZXTPpp5p)Jp&|1K+9EYGY*oaf3QF zxf#aTXZ08HmKkjlU$BW;HvGgRUh)X{eqDa?4A)j^YOPo%#>%lw_hsR4nVD6lXMMD` z-X-hLqD?YV#LDOV=AX!d->Sa|iu3*1tVXw9TArOuAACX+6?)G`rJeHo8W1nFp3dsC ze(9;Z+;z^S2cNTLV`8C4nDNw&jXksL^?Ie&TxfpjXf?6lB*Ywk4}R+69$0TpzMj^h zyHZ^)M+zLA*vwqkncD)cm&Sy6n#B>Z9pYnCWxg*Tl}?8#@RTeze0Jero;FSBG?fjB z`(G)=%!h)7g->Yzpg@$Jqj>4@=bz5DyYL)_`;=?P$}TMkbIZn?6Z#=GX z-WeZV>Km_gC`7eldZoFnIO0H2S$s-LkDA}dFB)NS))6z(`$T(drk{|x(wr<6<{ap= zN5s_lm1cN;dCrdcQz4gLNb1ge*N@F5NN|<3^mEnut!LVYgCKjlPIi1DLv>PL4aG8) z&+c=&-T5^jI%cKSb+b~;kj|#c`ILlN$>pK@tg=Ow#nY`ms!z6UKJ9o4W|fRM8e_0m zlL%JLsKc}Fy3AD_-X1`l1H-BQE8n;_zNuT+>@Q^d(uhO|80|E8Z7R*LEQlgW{6Y(=ZnR+0;tkHk%4e z3+&a`6J~$%VkZr zzhNIOHRpF~N_oi>i!jOJF}Ki2*#qKV_Uoyt!5hrQ4K=C`uP>sW5_b|IcgM%v6iFtS z{brJSE+D#2LOGmWsqt(~^6d&u;C=Aw;;RT_b>7&=OPCmJyQyHphaBl|AzCJ%nhZ;q z+3S|(NUGBreLQ=+6lr-ZDX(>U1TW4YM}0d!_4(yn#$`=V#%z1*>d9w%qr}?GYXv1w z?>NLbH9M8nXv>_wuTbJ;;$nVmD|m+db>ldpd~-{@<-4IVoxy=;@k-O|31PV?3n8jd zD%_K}X)jdSV(tcMTkKGFEeo$9CpMfl)=yEGd3U74Tr<)xGc99ngZ)gbdQ+~b^X;$I zSbiY}R|4viD19k8s@}!MR9q;q}@cs+$`FzgjI@dY(59j`z>$>mr2y1SH;1uHo003cPtZxYb zAae-<><}h+mf2i6VE&dy7@(p{e2z(2-E_@#0iY^@YtI?VnqU6&zXLG%G}6vI;qW!S z=Fbc$KA514)pQ~Na8{b=>s|?RTzs)$D^tg9fE26G6CM3?*C_3TUD85QRFq(%wY(gT zeD6nQ{_}+O$vyh+<4s=k!Nt)hK@B}kVRR^$z>OpbPaEAxT)2508}oh@3(McDX~ zK586lXy$&{8--@SL^{`Rc~tD#JTqsz@pGmz54x@=nmsyvzZ9i+qldc zyJ2{5BQE1v%yAJB)aL@H2T@)@65b79QUeRhX}sBzaBC_#`(9Xdy*I&5JWePYLEPoA zZMlIr>{B)$vz@cemou|G`g7E<>Cn`Tq{|(VTe$CCApBvnJvBZ@vNj&%-@iW~S9S^` z5c+||!F0ZN#P6I~sV7n@ourRZvK<%u%6&Wx>c!FS;1V3pL)!keG5G6;eWXjGVcgU{ zIV-!Ki^tw+K^6j&U}?o%lml2%%~8JKZfoPbd53}zRU^|X9@a`9H)iyO#J;>u9DEc{&8)o-Wl z!VM<*=U`LA0dxePyQ~{7!u0NX$+yy{{qa`08ndxw&@@h@ZINAd>2M5-3xS&}FkvG- zHq6;fuwCshOhe??3XNH>B500^o$b+%i%(GJPUXddBTn92HN0+Osx=D1&e4-VxPRqkVu!P8_{!MTH`e^0h?Dt05 z;2pa0LQOH6k852|E?)SlDLEroYi1~$#ENG>`M1tzw(C+>GHzQlMbf|HC%I{e9pTJ# z-DA`kG2hU&JLaR~C4ZNHs9^+(`q~tNv97^h5ZWOfE!Y(`h)oP%OQiPPtCohv-KQO7 z21k3-RaW+h;YhEf}yIXQ#fQbY;MWnF<7m+4RQVUS*@|u zO1WS8o@)1YN?E!;-ISW#!!3$>PQeiA9E2Wi=OIqdRm-XK-ieLtCw}_i&zJ9Q>}3jk z7Yu)Pv|xLxbJ^|hPk87NrIN&Lk$3QWKXVlxEa~M(WpTXbxaR*wCEf>1Z)Nj(U(`KQ zBfrn-9gwIL>kJ7}an^M6 zsOTwmZmsE;BdX}>xF6k|-1|7X>_#fh-7(Eb7T!^WoxTAy<)y2fDOj^`JXYcjKZmoS zx2FpPWSv4QW!QZYjEVXs1eY?7mROq0d=)<^kx9Wk`|CY?7Ujn^l%jvuyL>U<@0()B z796XP^_nNvs|u%Fdh7>*VhZ8y^b>$=W%C+^L@>!IBgx|Z&qdUa?iZ&q*7)-651T0( zErgWe?M8BRMX?&L#D2DZV65L723r}5D=o}RE(4c)9i|MHbAK8*Zg3Ad*w>f6i4)B| zWao6VAv2>F&Py()SvRe4Z5DPf`pl!=-X_F^HHp{`zbve2wp&20UmR#Ph#ZX$|9s+o zc5a>3tfIonlZ{VF${QTxDXz|}X}Xtt(r#1>g(>d|5f3Z1h2;mSS>=&$PUc#zoc72n z*}QWzH%Mzo0Npu1kJ}GW7bk*nwkv{-g>OAnfJkq!M(B17${FqOZUln+1 zX6(^R2VB)M+sIQDcZHC{;e*wAk1xZD$>HILUcGkNSn6H$WG&t0I|GIP8_64G^V6h*7$_W$TNgR@@k%vBezw-H#`IpU(QKBu@H2~WL9WK z5C9>?*!Z!VtBqeuhe@TniV=cN8U@GTMMZoWdclDh`!ywt{Wwux?x?Zh^46wyQDaGM zFAHz)?`+i6(DB8AbH#syo0h9oyG{`U(6I zXnP=4(9riGLblHbQqAmef!0|d-a5(fTgN-a)Z*(dIiDonRCAZ_(hxn#J?onh0WZM4 zCCex-WhrrWk7JIxJatG0s)u(%aU=zyx0Y#C{4OuV)y3=bwI?s7{w&3ZvftCM<1dIX z3EN#&10J*0LfjAq%MDa`PZ0k^We3I`DREyMLXy~gT?syP79-fCx&t?^wE`hW7PxNr zpW$Oo+)Q9*Zk?E`~lHi#<}!NWVXUT0z5lE^R=~dw5zhz(r1B{bTz! zq!pncIBA6=2>wg{pYBk7;H4w5DJReTO;=0h(pay0#11*j8NDmBH7QydDY28M1JYTp ztxw1#_y&B@2DxCY#Sx}tdYfN|HCjYGSQfG&KbnwyCb4NHVHJ@2i*OGrn^AZrLP&C1 zy7r-DfYP|MBxGIS-`gM5$I}o;-cAtW==f)E|F!$+>z{^mw$sApB(M<2(NP^oCns(F zJ`6l4?`=~P=_3O*3m{jv7rPg7c>E?d%d;UapT@#{_Sl1_+t6BUVZFbd7@?uz@;urM zeDWUaeIjJ}@J8tlJJAi$KwA(pW)49H9}Gk|h3mql*hV?S_MvCS-_EaQf_D$ZQ-G}e zEkA0sv%9SPjj&?mZ5Hah$E9v%&UjrLCnuEW^eTzN{*v(~U5Q@x}Uma)K`nf3n{JQWrxkF9N>92d; z?YgzDUs3fHaT|8!zp6SA+re}FYqEdT_y4z1Pz&bd{DJsR+w{#&N(VDPw1A0$xqb!a Hdc=PKERk3x diff --git a/src/main/resources/assets/create/textures/gui/projector.png b/src/main/resources/assets/create/textures/gui/projector.png index 968618e948b3dde383ab64f20f199f5166f4d068..6638b2b2fc32dd365fc6bc49a593dd6031655705 100644 GIT binary patch literal 4461 zcmcgwXH=6}w?2tvkT8BK7(u!bzl@~^^ z*ZbFy+2w2B|6%5AalyF9I9beNxB6Ymi3d^-;|;N?T|ud83)&R!HZ8cqPi3L4(!(I* z#mNjDEabq`v2Ud=)om;<8p;H;Oem?glNQ2vcZ`{_ti z=$=!>T~Qxb)TzZ=+u2P8ajiW2M7NaKr|fdHhR^ZTsqF2Jp;2`UyBW={;bB`e+DPoD z?Neeg@vf=4n>uy#^Rr~#GV6qe#ze#LuH^Un24`Y=*I>hudL8bikPHc5{;t-UheDb z%kE(|+hD2MA9+zLu|=effq-ha%}mvkW%Im*7EqrH0AqgXf)3FBXieS(srGEJ3CFXvS3BXXW5O; zH$HPu=YE>^bm!q*O|cpVi|pHem+42)n7f6>lizRY_8LFHf~7A*Ez_7@%m0 zSQZJ-(_PpLsxx4(FwfVF^owWP2L^`CAE6&T_Cp$OSrtAHF@P}^25zR=_dE>mXY!x(;&Z`CI7|hFz*TM zI>u0X8YvMKUrYJ?%r`o{NR- z$S3gTZoA{R5ykdzP_%5d&9}lhd<{v_PT45S;*k}&jfg#;E=Mf#!bGs}rdqs&qN1Xd z?C#W?@_-DF!1N($%VI>Yi8T!YoHfkpfnq8osHH95g67C;a^!QksNZ6ora<-r;y{eg zhd~nkLql{A#vj>b3G$UYB%aAvARSYkw~QvL4hAA<6tF)kAO3^SqDai&6p)n%&_Xr{ z8Re0Bhf}ex=HPVP6r`;sf{sNas|teE>Jxd-eXk^OIXF+FzWfyP&zD%!UN*VVbdzb@UZnRc7H~c_Imb|AdBp6N?>asM%gTB=`ZyH$?Cl5RFcq`a8 zsYJCuTA_Mq>POmsTLIDiDpU*VAH9;8)?U{S7yt6In_GBMC8UHl2Z>GZf23V9hmw5` zKVP%`M2$Z`wBr-KL^ed?p3CV2^2BAL6%WK}?!PyrV|Rzzo(K0|`hC-z)%*7marM=i zUjm?S5T6jl%`H-kgWt(axJw}4k4vk?b;<$fjPGC7J5b1$VB#N=Q@BW(O)anz*FLqY z6IB)H`xG=%_?q2G#We0cIpVAc4r)sbo~}#l?9Ry?9&zo}A7q#K6{pd2TU^rapsbBDJI-Xw3SNdYno~ zJX_@adBn}ip>Freb2$3?MpI)nhH?ji-^1qh#%Ner0cO43b;Ny+fy3&yFF{agn80=& zyOQ52Ps}gjv$e5FG|4@=^7uW(`_&R~f$p9W1T*kF>WF*0VQB}Oj!k6D96Ir*^YBf1 z;@cM;62pRy4x=5pEh&h2B}y0_Q)s6Ea*lU2$pOq_Ej? z43hYncLEu%Ie*25lv1~vE3agC$Ct}QvYxrR**Vp)yHP2{G;*ySzoW8L*YS+vr9#cv z*MZNE`tfW9)L+gf5f4jfoxrJl-pHAmBc(@_aPuHZN8Zx0V_5k~B(7XFo?opN^5jG5 z@m*@mE!>!iy;f>(4pm|@X%<{)I+Duhu^{+1ov_B9n@0XB{f*h(PSk*o9C7#KR8uQ% zuVj-G<-jBPXCaWNzJxt?#>$cRO+>To3s#QOd-Qt)Qszqp|2O0CV%lmzjR?(2>+xv) z^bxAYL`sne%I;2KLlW_;Fgs}v3o8A_`8K!SA*|+J2ll0ar=Yt@cn&|+=6!m;$Q%p{ zdS+B|fGz&%Q$YtV)I+C{tYi{W=0$P&^M=kP*V3JZgW9kt6On-3Y=L9z23C%r3-c0e z-)F9%l5Y?t!}}E=i}CZXpi_WrrCZT`aKlu0n>{ecNwZ3S!AE-1TrVwgz&aP+91^_S zd0g}hU<0=V39dmK9>VnEp^9;1!G?@GOmPkzCsfA0$FwK9Fx;ukRWnB`o~FY5clTrp zxVMuWM!YWc8C!PE)g?~8AphLNw4yOf_E`j&(UzzR3IK_`^TRGa=!oPL#WX+6}B_+f#ezng!%DjK zLd|;g-EXA9|Mbj$69no^;MZ6C5#Kyb-jWV@Mb{>>jA*_#o;{nsF-V!;@+SXBrxoUu z%~JNFiZsd!Zm@$R<42lH3H-QN1XQ+P3!!)p>G&>;dQ+nR!fHQ18E*Ir8kh<|%MS&h zN@QFIS`asrV2&deB2!yQO$%I{Z>xCWAWz=2t*{igW1; zAJ_Yh-#}x{=W5Pn1xB4-H$d#u|35wiba>0&ebt4ka_>_6Z;v^@Een_jHu=dvCp-oSamGEA`(hr_*02Cde9H z>*lD62~!&`pT!By+8~tn@C?`Ze4w8SFHeKT{JYM6l1HfD**Z9Ilm%oCb8~Lh&>a`YP2GO|wYl82zv#{DK0I+BUkF^?bDS8w_C5mby}_%Z(fZV;l3v!KBi=Yv>CtK^9pc1zz6|Wt%+ME@qqp>8V7id!yh`^_%vtx*xV{d$Se57 z#ZC+u-KED$PEK|jtMiD8JWm}X;cMoWWiPJtUA*qH{N`lG<-ygU1&Z@^%@Ozh7W|EK zz1J7=f6o2UgW6ml#vdkM-8A@)e2lj`C%m77fytxvl5*l>-27@rGAm9BMk`yaY$@&x zzJz#a@O@BC_H}h_Z8egaCV@zY!rmqA-&?X#S@TA3n~aF^usg^LJZ~>oS7Y4#NM`>6 z=bT)f4G9VC8wQNgL5rqrpBA`(2yW7TJ@(-Teq2pt<3*q5It zlnEz_}(6;=b;|9Z?2o2zcg@s9OV@>~fc6!sB z;~$Wte-^<2f7Ap8lw~gqWVUoS_f?!7YA?zQ3>6U($>O@vif%=oPavp{7o9Q%1s~S4 z>buooAryX^2aG5-u_N_|klL^ZA_f@A-Vr{@CvOzOMVeuj_k#uj{^+?(4ln zQ{7k{0HEo<({&F3FlYz^sz~T3@OVWiw2pIk-AXupO*r6{M(ESyeBSHTzwHt^IC&r1 zpzmBuB;FXVbrt8|hS|QeHoU^?+@19=()NFB_rj;V+F(Xrj!sq!KX^%NzbazyEI6p4 zy8nrKa>sL*-8%WPhUg%Dub!4Othpx9`{EN6SrX>yCq|;EmwJ+N{fwx0H99MnSNzl6 zwA&sY9?&;7yQ;GCl5E}CC5@@nvj_WQWmLI%nEJD1$)JVT-U6}q^nQJG{O3P?>ic17 zXrmXtn;DY>pdjQ-=Y=3!A?I$|tbh~jOu6b=3uQ+$3R~QQ=h;*TDr@*q!vQllO zwUm*Avwut{-D%e`$Z)Ub=XjT|C<&Z9HY!Vhvj6^xyQOv-`usiO)Oc;btLH7W*Uzgi zJFJ5*NC_G4*rws^f-(XxUC(9QKaUU5@+(M@O$v0-=)Nq2Cxw3u|C%}?YE=B$np7uU ziBRReSs=h67NPAE=bP9&9)d>$Rh2_OiGD~kcOh$5SdkTSS&->R?2GXshe0GhbuV(N z)zl)}tm6&RJJ8NtmYDR(BW>yA=#gowG0--01!m@sZ4IKtDuxwXu4gy~#gAWsIVQ>9 zjlB<4Js|TyE?QU41dunL4%eT*L3XY|x@_PAL1+9jeB9zy8)i zu4PFbpp7_giDwVxK`6))OCD3w{D!h&=a}DiafYQyNM|l|Yvf9SSp0yGLMA~oq9tNy zwyVSS3^R8d$<`p}<3W&Lz3*L9lrjf|AxkCNp6dyJHXhe(`Q0E94#v;CmKTO9iFUdX zIuPaG>&N4=a!<8Ntc>tY1Sie3P{=!III{-tT0fVkfe9o7^l}6Z*Pub;!MlB!N-N9u zXbWaOzYo+rLi1BV270VS%yd;d=cTga1G{jj^%?T>S`qNYUalW+SXx5?(y{@!(p8rc zR5Hvmh$?c)>wzKB|D zKRpTBxRaGc)sR0DBb2A?bV5wUz^kidcodPo!UYNZm5Yhio36vUADVt#)u2UVa5iVb zIC_7HRgFO4Zaq6J8AQ7g1!$wuoe!!d5z>obW*5(s?q7!64F< z=Ejpy_(;y^hfJT>M)>Pex>og&#uEWWUn!D?VvtE+?NGqq+lVtI1z$#I6KPBO+1V5P zYU!E4h3Oig>Y5D=O0h4eNA4z!p@y;_2V;bB0VYF*qAlM^kSU)#VNORvFy-=@fS?kk zJXi_Q?EBZTNZ+x<8>QW0u52}a<-*~v2 zeGS36wolCvZ3CMAr~~NLouKg2tPCPXDuaXWFfnDo51T*{vcCG$x)ho2fp@j1b=9`i<$`w6q>AJ+6gONS=)E z{vhPRX9gjPo+kLidp~z>O=xzePE(Zd^k{I}1nJ91rLX-Jy$}x|7%~4x6JH)koAw`j zCZ9aPKIv&b<#Er1#$z;Gbor4}=!(f9^m`%czp@C4S7N3?JA!rDF~S7SE#K&TB%;En z>?CLn;+;B+zUy6H3Oxjb)d;~2*x#5fi>D+8PMbfQWE;jg#ti54Eu7+F^px9C{xBuv zmtl+k;^_C&x0RXTB?itAPkiqVLrjrR)j8`&vDx2zKm0Q3P0@TRVJlc%YU5K%8P&@a zWdo#yab*cSB^tcfJ#}L2d51xDlK(rFEw(V{s^yotJ$3nuq6 zRn4%q_wTQNaPQu|wdL(T@8qvO;c~2=XAbR@77jWY(Wnu6bk{+XsXn#86?X)`#Z~(J zn~Y(EAB=uMId+WO-roMZJ0w2VBYCi{lMM9V^1q2YpbMS>^A7I?eI;Kj*=+|Xq#!3m zmsnA+Rsa<;#?V4*k3=jN_f|eeIWy>8<8?GO*Fu_$^Cv4_QlAU+H_lwlP*Ijawn4DT z>p|o`!+AGhjhO5lEx-?(S$oBC#_H&fHnivh2bA@n49;!c?lu9h@$ldYz*=S(jsH-= z{pw8Y0v9gB&UF!x))Ti$iOJk3$>S7MRc7nvn~r@}Bvzn3V%3?2c<6E1I|j^K`39?t zm)7dCx$T`XYnrlOQB$Hmrf)c`|N7 z*j3c6=o>nrhglcuv{2wMQx2^kI6EOcdPYhH;sQIAZ|IcI(P~O>$)s0fiV`&=d;z^g zRuo=cqu={BfI@oR-{`pdP+q4!Es<@-WHNJ&2SpN#C`C7_yd_98nmX?X#R4i}H9jj5 z6{X3)*UwaEy7fL7xDY#Y>7Sy^LYgx9E7U#z#cHUM-&KG2M!7MQ!O`2Tm(SoV-$2yn z^gIzR*&iO(O7)_YXmFgMs@YZhgJgHiACJhS!!aevkO>(t!d)h+^jBFfviL)PYEU`jDXVoFBlIJoGpjI+25oE8v1! z2BEafGWxy^k$%yf#4^A*JthOUH5&4SEtO7v7tQJ6pdAnA*1SkI;QcEcG From dc3517eb3ae0fca1e962a58c945d35bbf2469144 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Fri, 30 Apr 2021 14:28:18 -0700 Subject: [PATCH 017/198] Inversion --- .../curiosities/projector/ChromaticProjectorScreen.java | 2 +- .../foundation/render/backend/effects/FilterSphere.java | 4 ++-- .../resources/assets/create/flywheel/shaders/area_effect.frag | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java index 076bf77a7..ee0620239 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorScreen.java @@ -107,7 +107,7 @@ public class ChromaticProjectorScreen extends AbstractSimiScreen { .titled(Lang.translate("gui.chromatic_projector.strength")) .withStepFunction(ctx -> step(ctx, 5)) .calling(tile::setStrength) - .withRange(0, 101) + .withRange(-100, 101) .setState((int) (tile.strength * 100)); Collections.addAll(widgets, blend, rChannel, gChannel, bChannel, fieldEffect, strength); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java b/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java index 0b6d4f881..91499610f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java @@ -41,8 +41,8 @@ public class FilterSphere { surface ? 1 : 0, field ? 1 : 0, - strength, - 0, // padding + Math.abs(strength), + strength < 0 ? 1 : 0, rMask ? 1 : 0, gMask ? 1 : 0, diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index 86e987ecc..e2e99fc66 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -17,7 +17,7 @@ uniform vec3 uCameraPos; struct SphereFilter { vec4 sphere;// vec4 d1;// - vec4 strength;// + vec4 strength;// vec4 channelMask;// mat4 colorOp; }; @@ -126,6 +126,8 @@ vec3 applyFilters(vec3 worldDir, float depth, vec3 diffuse) { float strength = filterStrength(worldDir, depth, s); + strength = invert(strength, s.strength.w); + if (strength > 0) { const float fcon = 0.; From 67e75d747a27c9480886898d681eb0d9df0ac680 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sat, 1 May 2021 16:32:09 -0700 Subject: [PATCH 018/198] Move backend --- .../flywheel}/backend/Backend.java | 14 ++++++------ .../flywheel}/backend/BufferedModel.java | 6 ++--- .../backend/FastRenderDispatcher.java | 2 +- .../flywheel}/backend/MaterialType.java | 4 ++-- .../flywheel/backend/MaterialTypes.java | 10 +++++++++ .../flywheel}/backend/OptifineHandler.java | 2 +- .../flywheel}/backend/RenderUtil.java | 2 +- .../flywheel}/backend/RenderWork.java | 2 +- .../flywheel}/backend/ShaderLoader.java | 16 +++++++------- .../backend/core/BasicAttributes.java | 8 +++---- .../flywheel}/backend/core/BasicData.java | 6 ++--- .../flywheel}/backend/core/BasicProgram.java | 6 ++--- .../flywheel}/backend/core/IFlatLight.java | 4 ++-- .../backend/core/ModelAttributes.java | 10 ++++----- .../flywheel}/backend/core/ModelData.java | 6 ++--- .../backend/core/OrientedAttributes.java | 8 +++---- .../flywheel}/backend/core/OrientedData.java | 4 ++-- .../flywheel}/backend/core/OrientedModel.java | 8 +++---- .../flywheel}/backend/core/PartialModel.java | 2 +- .../backend/core/TransformAttributes.java | 8 +++---- .../backend/core/TransformedModel.java | 8 +++---- .../backend/effects/ColorMatrices.java | 2 +- .../backend/effects/EffectsHandler.java | 12 +++++----- .../backend/effects/FilterSphere.java | 4 ++-- .../backend/effects/ScreenQuadAttributes.java | 8 +++---- .../backend/effects/SphereFilterProgram.java | 6 ++--- .../flywheel}/backend/gl/GlBuffer.java | 4 ++-- .../flywheel}/backend/gl/GlFog.java | 2 +- .../flywheel}/backend/gl/GlFogMode.java | 4 ++-- .../flywheel}/backend/gl/GlObject.java | 2 +- .../flywheel}/backend/gl/GlPrimitiveType.java | 2 +- .../flywheel}/backend/gl/GlTexture.java | 2 +- .../flywheel}/backend/gl/GlVertexArray.java | 4 ++-- .../backend/gl/attrib/CommonAttributes.java | 4 ++-- .../backend/gl/attrib/IAttribSpec.java | 2 +- .../backend/gl/attrib/IVertexAttrib.java | 2 +- .../backend/gl/attrib/MatrixAttributes.java | 4 ++-- .../backend/gl/attrib/VertexAttribSpec.java | 4 ++-- .../backend/gl/attrib/VertexFormat.java | 2 +- .../gl/shader/FogSensitiveProgram.java | 8 +++---- .../flywheel}/backend/gl/shader/GLSLType.java | 4 ++-- .../backend/gl/shader/GlProgram.java | 10 ++++----- .../flywheel}/backend/gl/shader/GlShader.java | 8 +++---- .../backend/gl/shader/IMultiProgram.java | 2 +- .../backend/gl/shader/ProgramFogMode.java | 4 ++-- .../backend/gl/shader/ProgramSpec.java | 4 ++-- .../backend/gl/shader/ShaderCallback.java | 2 +- .../backend/gl/shader/ShaderConstants.java | 2 +- .../backend/gl/shader/ShaderSpecLoader.java | 7 ++++++ .../backend/gl/shader/ShaderType.java | 2 +- .../backend/gl/shader/SingleProgram.java | 4 ++-- .../backend/gl/versioned/GlCompat.java | 12 +++++----- .../backend/gl/versioned/GlVersioned.java | 2 +- .../backend/gl/versioned/MapBuffer.java | 2 +- .../backend/gl/versioned/RGPixelFormat.java | 2 +- .../gl/versioned/framebuffer/Blit.java | 4 ++-- .../gl/versioned/framebuffer/Framebuffer.java | 4 ++-- .../versioned/instancing/DrawInstanced.java | 4 ++-- .../versioned/instancing/InstancedArrays.java | 4 ++-- .../instancing/VertexArrayObject.java | 4 ++-- .../backend/instancing/IDynamicInstance.java | 2 +- .../backend/instancing/IFlywheelWorld.java | 2 +- .../backend/instancing/IInstance.java | 2 +- .../backend/instancing/IInstanceRendered.java | 2 +- .../backend/instancing/IRendererFactory.java | 2 +- .../backend/instancing/ITickableInstance.java | 2 +- .../backend/instancing/InstanceData.java | 2 +- .../backend/instancing/InstancedModel.java | 14 ++++++------ .../InstancedTileRenderRegistry.java | 2 +- .../instancing/InstancedTileRenderer.java | 16 +++++++------- .../backend/instancing/ModelFactory.java | 2 +- .../backend/instancing/RenderMaterial.java | 16 +++++++------- .../instancing/TileEntityInstance.java | 8 +++---- .../instancing/util/ConditionalInstance.java | 6 ++--- .../instancing/util/InstanceGroup.java | 6 ++--- .../instancing/util/SelectInstance.java | 6 ++--- .../backend/light/CoordinateConsumer.java | 2 +- .../flywheel}/backend/light/EmptyLighter.java | 2 +- .../backend/light/GridAlignedBB.java | 6 ++--- .../backend/light/LightUpdateListener.java | 2 +- .../flywheel}/backend/light/LightUpdater.java | 2 +- .../flywheel}/backend/light/LightVolume.java | 10 ++++----- .../backend/light/LightVolumeDebugger.java | 2 +- .../com/simibubi/create/AllBlockPartials.java | 2 +- .../com/simibubi/create/CreateClient.java | 8 +++---- .../animations/AnimatedBlazeBurner.java | 2 +- .../category/animations/AnimatedKinetics.java | 2 +- .../base/BackHalfShaftInstance.java | 2 +- .../contraptions/base/HalfShaftInstance.java | 4 ++-- .../base/HorizontalHalfShaftInstance.java | 2 +- .../contraptions/base/KineticAttributes.java | 8 +++---- .../contraptions/base/KineticData.java | 4 ++-- .../base/KineticRenderMaterials.java | 4 ++-- .../contraptions/base/KineticTileEntity.java | 4 ++-- .../base/KineticTileEntityRenderer.java | 2 +- .../base/KineticTileInstance.java | 8 +++---- .../contraptions/base/RotatingAttributes.java | 8 +++---- .../contraptions/base/RotatingData.java | 2 +- .../contraptions/base/RotatingModel.java | 8 +++---- .../base/ShaftlessCogInstance.java | 4 ++-- .../base/SingleRotatingInstance.java | 4 ++-- .../components/actors/ActorData.java | 4 ++-- .../components/actors/ActorModel.java | 6 ++--- .../actors/ActorVertexAttributes.java | 8 +++---- .../components/actors/DrillActorInstance.java | 4 ++-- .../components/actors/DrillInstance.java | 4 ++-- .../actors/DrillMovementBehaviour.java | 2 +- .../actors/HarvesterActorInstance.java | 6 ++--- .../actors/HarvesterMovementBehaviour.java | 2 +- .../PortableStorageInterfaceRenderer.java | 2 +- .../components/clock/CuckooClockRenderer.java | 2 +- .../crafter/MechanicalCrafterInstance.java | 4 ++-- .../crafter/MechanicalCrafterRenderer.java | 4 ++-- .../components/crank/HandCrankBlock.java | 2 +- .../components/crank/HandCrankInstance.java | 10 ++++----- .../components/crank/HandCrankRenderer.java | 4 ++-- .../components/crank/ValveHandleBlock.java | 2 +- .../deployer/DeployerActorInstance.java | 8 +++---- .../components/deployer/DeployerInstance.java | 10 ++++----- .../deployer/DeployerMovementBehaviour.java | 4 ++-- .../components/deployer/DeployerRenderer.java | 4 ++-- .../deployer/DeployerTileEntity.java | 2 +- .../components/fan/EncasedFanRenderer.java | 2 +- .../components/fan/FanInstance.java | 2 +- .../components/flywheel/FlyWheelInstance.java | 12 +++++----- .../components/flywheel/FlywheelRenderer.java | 2 +- .../flywheel/engine/EngineBlock.java | 2 +- .../flywheel/engine/EngineInstance.java | 8 +++---- .../flywheel/engine/EngineRenderer.java | 4 ++-- .../flywheel/engine/EngineTileEntity.java | 2 +- .../flywheel/engine/FurnaceEngineBlock.java | 2 +- .../millstone/MillStoneCogInstance.java | 4 ++-- .../mixer/MechanicalMixerRenderer.java | 2 +- .../components/mixer/MixerInstance.java | 6 ++--- .../press/MechanicalPressRenderer.java | 2 +- .../components/press/PressInstance.java | 6 ++--- .../components/saw/SawInstance.java | 4 ++-- .../components/saw/SawRenderer.java | 4 ++-- .../structureMovement/Contraption.java | 6 ++--- .../structureMovement/ContraptionLighter.java | 8 +++---- .../NonStationaryLighter.java | 2 +- .../bearing/AnchoredLighter.java | 2 +- .../bearing/BearingInstance.java | 8 +++---- .../bearing/BearingRenderer.java | 4 ++-- .../bearing/StabilizedBearingInstance.java | 2 +- .../StabilizedBearingMovementBehaviour.java | 4 ++-- .../chassis/StickerInstance.java | 8 +++---- .../chassis/StickerRenderer.java | 2 +- .../chassis/StickerTileEntity.java | 4 ++-- .../gantry/GantryCarriageInstance.java | 6 ++--- .../gantry/GantryCarriageRenderer.java | 2 +- .../piston/PistonLighter.java | 2 +- .../pulley/AbstractPulleyInstance.java | 20 ++++++++--------- .../pulley/AbstractPulleyRenderer.java | 4 ++-- .../pulley/HosePulleyInstance.java | 6 ++--- .../pulley/PulleyLighter.java | 2 +- .../pulley/PulleyRenderer.java | 2 +- .../pulley/RopePulleyInstance.java | 6 ++--- .../render/ContraptionAttributes.java | 8 +++---- .../render/ContraptionKineticRenderer.java | 12 +++++----- .../render/ContraptionModel.java | 8 +++---- .../render/ContraptionProgram.java | 4 ++-- .../render/ContraptionRenderDispatcher.java | 4 ++-- .../render/RenderedContraption.java | 6 ++--- .../contraptions/fluids/PumpCogInstance.java | 4 ++-- .../fluids/actors/HosePulleyRenderer.java | 2 +- .../fluids/actors/SpoutRenderer.java | 2 +- .../fluids/pipes/FluidValveInstance.java | 6 ++--- .../fluids/pipes/FluidValveRenderer.java | 2 +- .../burner/BlazeBurnerRenderer.java | 2 +- .../advanced/SpeedControllerRenderer.java | 2 +- .../relays/belt/BeltAttributes.java | 8 +++---- .../contraptions/relays/belt/BeltData.java | 2 +- .../relays/belt/BeltInstance.java | 8 +++---- .../relays/belt/BeltInstancedModel.java | 8 +++---- .../relays/belt/BeltRenderer.java | 4 ++-- .../relays/belt/BeltTileEntity.java | 8 +++---- .../relays/encased/ShaftInstance.java | 2 +- .../relays/encased/SplitShaftInstance.java | 8 +++---- .../relays/encased/SplitShaftRenderer.java | 2 +- .../relays/gauge/GaugeInstance.java | 8 +++---- .../relays/gauge/GaugeRenderer.java | 4 ++-- .../relays/gearbox/GearboxInstance.java | 8 +++---- .../relays/gearbox/GearboxRenderer.java | 2 +- .../projector/ChromaticProjectorInstance.java | 8 +++---- .../ChromaticProjectorTileEntity.java | 4 ++-- .../curiosities/projector/ColorEffect.java | 2 +- .../curiosities/projector/FilterStep.java | 2 +- .../symmetry/mirror/CrossPlaneMirror.java | 2 +- .../symmetry/mirror/EmptyMirror.java | 2 +- .../symmetry/mirror/PlaneMirror.java | 2 +- .../symmetry/mirror/SymmetryMirror.java | 2 +- .../symmetry/mirror/TriplePlaneMirror.java | 2 +- .../tools/ExtendoGripRenderHandler.java | 2 +- .../logistics/block/FlapAttributes.java | 8 +++---- .../content/logistics/block/FlapData.java | 6 ++--- .../content/logistics/block/FlapModel.java | 6 ++--- .../belts/tunnel/BeltTunnelInstance.java | 10 ++++----- .../belts/tunnel/BeltTunnelRenderer.java | 2 +- .../belts/tunnel/BeltTunnelTileEntity.java | 20 ++++++++--------- .../block/depot/EjectorInstance.java | 6 ++--- .../block/depot/EjectorRenderer.java | 2 +- .../diodes/AdjustableRepeaterInstance.java | 8 +++---- .../diodes/AdjustableRepeaterTileEntity.java | 6 ++--- .../block/funnel/FunnelInstance.java | 12 +++++----- .../block/funnel/FunnelRenderer.java | 4 ++-- .../block/funnel/FunnelTileEntity.java | 4 ++-- .../block/mechanicalArm/ArmInstance.java | 12 +++++----- .../mechanicalArm/ArmInteractionPoint.java | 2 +- .../block/mechanicalArm/ArmRenderer.java | 2 +- .../block/redstone/AnalogLeverInstance.java | 12 +++++----- .../block/redstone/AnalogLeverRenderer.java | 2 +- .../block/redstone/AnalogLeverTileEntity.java | 2 +- .../block/SchematicannonInstance.java | 12 +++++----- .../block/SchematicannonRenderer.java | 2 +- .../block/SchematicannonTileEntity.java | 2 +- .../simibubi/create/events/ClientEvents.java | 6 ++--- .../command/ConfigureConfigPacket.java | 4 ++-- .../data/CreateTileEntityBuilder.java | 4 ++-- .../create/foundation/gui/GuiGameElement.java | 2 +- .../mixin/CancelTileEntityRenderMixin.java | 4 ++-- .../mixin/FogColorTrackerMixin.java | 2 +- .../foundation/mixin/LightUpdateMixin.java | 2 +- .../mixin/NetworkLightUpdateMixin.java | 4 ++-- .../foundation/mixin/RenderHooksMixin.java | 6 ++--- .../foundation/mixin/ShaderCloseMixin.java | 2 +- .../mixin/StoreProjectionMatrixMixin.java | 4 ++-- .../foundation/render/AllProgramSpecs.java | 22 +++++++++---------- .../create/foundation/render/Compartment.java | 2 +- .../foundation/render/KineticRenderer.java | 14 ++++++------ .../foundation/render/PartialBufferer.java | 2 +- .../render/SuperByteBufferCache.java | 2 +- .../render/backend/MaterialTypes.java | 10 --------- .../backend/gl/shader/ShaderSpecLoader.java | 7 ------ .../ColoredOverlayTileEntityRenderer.java | 2 +- .../PlacementSimulationWorld.java | 2 +- 236 files changed, 580 insertions(+), 580 deletions(-) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/Backend.java (86%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/BufferedModel.java (90%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/FastRenderDispatcher.java (97%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/MaterialType.java (51%) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/MaterialTypes.java rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/OptifineHandler.java (97%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/RenderUtil.java (97%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/RenderWork.java (87%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/ShaderLoader.java (91%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/BasicAttributes.java (64%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/BasicData.java (87%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/BasicProgram.java (86%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/IFlatLight.java (85%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/ModelAttributes.java (61%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/ModelData.java (73%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/OrientedAttributes.java (67%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/OrientedData.java (93%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/OrientedModel.java (65%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/PartialModel.java (96%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/TransformAttributes.java (65%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/core/TransformedModel.java (65%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/effects/ColorMatrices.java (98%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/effects/EffectsHandler.java (92%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/effects/FilterSphere.java (86%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/effects/ScreenQuadAttributes.java (63%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/effects/SphereFilterProgram.java (93%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/GlBuffer.java (91%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/GlFog.java (94%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/GlFogMode.java (85%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/GlObject.java (93%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/GlPrimitiveType.java (93%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/GlTexture.java (88%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/GlVertexArray.java (80%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/attrib/CommonAttributes.java (88%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/attrib/IAttribSpec.java (68%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/attrib/IVertexAttrib.java (66%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/attrib/MatrixAttributes.java (84%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/attrib/VertexAttribSpec.java (87%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/attrib/VertexFormat.java (95%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/FogSensitiveProgram.java (84%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/GLSLType.java (89%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/GlProgram.java (91%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/GlShader.java (79%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/IMultiProgram.java (87%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/ProgramFogMode.java (90%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/ProgramSpec.java (93%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/ShaderCallback.java (83%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/ShaderConstants.java (95%) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/ShaderType.java (76%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/shader/SingleProgram.java (87%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/versioned/GlCompat.java (86%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/versioned/GlVersioned.java (88%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/versioned/MapBuffer.java (96%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/versioned/RGPixelFormat.java (94%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/versioned/framebuffer/Blit.java (89%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/versioned/framebuffer/Framebuffer.java (89%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/versioned/instancing/DrawInstanced.java (90%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/versioned/instancing/InstancedArrays.java (86%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/gl/versioned/instancing/VertexArrayObject.java (90%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/IDynamicInstance.java (94%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/IFlywheelWorld.java (82%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/IInstance.java (83%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/IInstanceRendered.java (59%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/IRendererFactory.java (75%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/ITickableInstance.java (95%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/InstanceData.java (94%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/InstancedModel.java (92%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/InstancedTileRenderRegistry.java (93%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/InstancedTileRenderer.java (93%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/ModelFactory.java (75%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/RenderMaterial.java (88%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/TileEntityInstance.java (93%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/util/ConditionalInstance.java (81%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/util/InstanceGroup.java (86%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/instancing/util/SelectInstance.java (82%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/light/CoordinateConsumer.java (61%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/light/EmptyLighter.java (89%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/light/GridAlignedBB.java (97%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/light/LightUpdateListener.java (94%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/light/LightUpdater.java (99%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/light/LightVolume.java (96%) rename src/main/java/com/{simibubi/create/foundation/render => jozufozu/flywheel}/backend/light/LightVolumeDebugger.java (95%) delete mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/MaterialTypes.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderSpecLoader.java diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java similarity index 86% rename from src/main/java/com/simibubi/create/foundation/render/backend/Backend.java rename to src/main/java/com/jozufozu/flywheel/backend/Backend.java index 095f96b84..b66b67bf6 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend; +package com.jozufozu.flywheel.backend; import java.util.HashMap; import java.util.Map; @@ -8,13 +8,13 @@ import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; +import com.jozufozu.flywheel.backend.effects.EffectsHandler; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; +import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; +import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; import com.simibubi.create.foundation.config.AllConfigs; -import com.simibubi.create.foundation.render.backend.effects.EffectsHandler; -import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; -import com.simibubi.create.foundation.render.backend.gl.shader.IMultiProgram; -import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; -import com.simibubi.create.foundation.render.backend.gl.versioned.GlCompat; -import com.simibubi.create.foundation.render.backend.instancing.IFlywheelWorld; import net.minecraft.client.Minecraft; import net.minecraft.resources.IReloadableResourceManager; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/BufferedModel.java b/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java similarity index 90% rename from src/main/java/com/simibubi/create/foundation/render/backend/BufferedModel.java rename to src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java index 20c7436f9..ae076ea0b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/BufferedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java @@ -1,13 +1,13 @@ -package com.simibubi.create.foundation.render.backend; +package com.jozufozu.flywheel.backend; import java.nio.ByteBuffer; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; +import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.simibubi.create.foundation.render.TemplateBuffer; -import com.simibubi.create.foundation.render.backend.gl.GlBuffer; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; import net.minecraft.client.renderer.BufferBuilder; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java b/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java similarity index 97% rename from src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java rename to src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java index ee9fc282f..09879ff0c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java +++ b/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend; +package com.jozufozu.flywheel.backend; import java.util.concurrent.ConcurrentHashMap; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/MaterialType.java b/src/main/java/com/jozufozu/flywheel/backend/MaterialType.java similarity index 51% rename from src/main/java/com/simibubi/create/foundation/render/backend/MaterialType.java rename to src/main/java/com/jozufozu/flywheel/backend/MaterialType.java index f3c770051..7e55c49d6 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/MaterialType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/MaterialType.java @@ -1,6 +1,6 @@ -package com.simibubi.create.foundation.render.backend; +package com.jozufozu.flywheel.backend; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; public class MaterialType> { diff --git a/src/main/java/com/jozufozu/flywheel/backend/MaterialTypes.java b/src/main/java/com/jozufozu/flywheel/backend/MaterialTypes.java new file mode 100644 index 000000000..2ac7fe4d1 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/MaterialTypes.java @@ -0,0 +1,10 @@ +package com.jozufozu.flywheel.backend; + +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; + +public class MaterialTypes { + public static final MaterialType> TRANSFORMED = new MaterialType<>(); + public static final MaterialType> ORIENTED = new MaterialType<>(); +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/OptifineHandler.java b/src/main/java/com/jozufozu/flywheel/backend/OptifineHandler.java similarity index 97% rename from src/main/java/com/simibubi/create/foundation/render/backend/OptifineHandler.java rename to src/main/java/com/jozufozu/flywheel/backend/OptifineHandler.java index 58cc82188..c4d825c90 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/OptifineHandler.java +++ b/src/main/java/com/jozufozu/flywheel/backend/OptifineHandler.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend; +package com.jozufozu.flywheel.backend; import java.io.BufferedReader; import java.io.File; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/RenderUtil.java b/src/main/java/com/jozufozu/flywheel/backend/RenderUtil.java similarity index 97% rename from src/main/java/com/simibubi/create/foundation/render/backend/RenderUtil.java rename to src/main/java/com/jozufozu/flywheel/backend/RenderUtil.java index 46c89647d..9fd6d2897 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/RenderUtil.java +++ b/src/main/java/com/jozufozu/flywheel/backend/RenderUtil.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend; +package com.jozufozu.flywheel.backend; import java.util.function.Supplier; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/RenderWork.java b/src/main/java/com/jozufozu/flywheel/backend/RenderWork.java similarity index 87% rename from src/main/java/com/simibubi/create/foundation/render/backend/RenderWork.java rename to src/main/java/com/jozufozu/flywheel/backend/RenderWork.java index b20f1d64e..1e197860c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/RenderWork.java +++ b/src/main/java/com/jozufozu/flywheel/backend/RenderWork.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend; +package com.jozufozu.flywheel.backend; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java similarity index 91% rename from src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoader.java rename to src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index b58761b3c..abd224f1a 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend; +package com.jozufozu.flywheel.backend; import java.io.BufferedReader; import java.io.FileInputStream; @@ -25,14 +25,14 @@ import java.util.stream.Stream; import org.lwjgl.system.MemoryUtil; import com.google.common.collect.Lists; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.gl.shader.GlShader; +import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; +import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; +import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.mojang.blaze3d.systems.RenderSystem; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; -import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; -import com.simibubi.create.foundation.render.backend.gl.shader.GlShader; -import com.simibubi.create.foundation.render.backend.gl.shader.IMultiProgram; -import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; -import com.simibubi.create.foundation.render.backend.gl.shader.ShaderConstants; -import com.simibubi.create.foundation.render.backend.gl.shader.ShaderType; import net.minecraft.resources.IResource; import net.minecraft.resources.IResourceManager; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/BasicAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicAttributes.java similarity index 64% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/BasicAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/core/BasicAttributes.java index 8721aac88..1592e99fd 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/BasicAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicAttributes.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; public enum BasicAttributes implements IVertexAttrib { LIGHT("aLight", CommonAttributes.LIGHT), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/BasicData.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicData.java similarity index 87% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/BasicData.java rename to src/main/java/com/jozufozu/flywheel/backend/core/BasicData.java index 531b2d929..2f910eff4 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/BasicData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicData.java @@ -1,9 +1,9 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; import java.nio.ByteBuffer; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; public class BasicData extends InstanceData implements IFlatLight { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/BasicProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java similarity index 86% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/BasicProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java index 76f9460bc..cb8edd2b6 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/BasicProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java @@ -1,9 +1,9 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; -import com.simibubi.create.foundation.render.backend.gl.shader.ProgramFogMode; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/IFlatLight.java b/src/main/java/com/jozufozu/flywheel/backend/core/IFlatLight.java similarity index 85% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/IFlatLight.java rename to src/main/java/com/jozufozu/flywheel/backend/core/IFlatLight.java index fbbdd58b2..7b6885c12 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/IFlatLight.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/IFlatLight.java @@ -1,6 +1,6 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstanceData; /** * An interface that implementors of {@link InstanceData} should also implement diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/ModelAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/ModelAttributes.java similarity index 61% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/ModelAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/core/ModelAttributes.java index 970fd672e..c5ba5e858 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/ModelAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/ModelAttributes.java @@ -1,9 +1,9 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; public enum ModelAttributes implements IVertexAttrib { VERTEX_POSITION("aPos", CommonAttributes.VEC3), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/ModelData.java b/src/main/java/com/jozufozu/flywheel/backend/core/ModelData.java similarity index 73% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/ModelData.java rename to src/main/java/com/jozufozu/flywheel/backend/core/ModelData.java index c2f338bf6..cef67d359 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/ModelData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/ModelData.java @@ -1,10 +1,10 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; import java.nio.ByteBuffer; +import com.jozufozu.flywheel.backend.RenderUtil; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.render.backend.RenderUtil; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; public class ModelData extends BasicData { private static final float[] empty = new float[25]; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/OrientedAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/OrientedAttributes.java similarity index 67% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/OrientedAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/core/OrientedAttributes.java index 135958501..a92ed42ac 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/OrientedAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/OrientedAttributes.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; public enum OrientedAttributes implements IVertexAttrib { INSTANCE_POS("aInstancePos", CommonAttributes.VEC3), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/OrientedData.java b/src/main/java/com/jozufozu/flywheel/backend/core/OrientedData.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/OrientedData.java rename to src/main/java/com/jozufozu/flywheel/backend/core/OrientedData.java index 77becf79e..209458c17 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/OrientedData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/OrientedData.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; import java.nio.ByteBuffer; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Quaternion; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/OrientedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/OrientedModel.java similarity index 65% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/OrientedModel.java rename to src/main/java/com/jozufozu/flywheel/backend/core/OrientedModel.java index 42ee8334b..76ed0baac 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/OrientedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/OrientedModel.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import net.minecraft.client.renderer.BufferBuilder; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/PartialModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/PartialModel.java similarity index 96% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/PartialModel.java rename to src/main/java/com/jozufozu/flywheel/backend/core/PartialModel.java index 87fafb9dd..da0ebc65e 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/PartialModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/PartialModel.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/TransformAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/TransformAttributes.java similarity index 65% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/TransformAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/core/TransformAttributes.java index f35cdf988..a94064541 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/TransformAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/TransformAttributes.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; -import com.simibubi.create.foundation.render.backend.gl.attrib.MatrixAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.MatrixAttributes; public enum TransformAttributes implements IVertexAttrib { TRANSFORM("aTransform", MatrixAttributes.MAT4), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/TransformedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/TransformedModel.java similarity index 65% rename from src/main/java/com/simibubi/create/foundation/render/backend/core/TransformedModel.java rename to src/main/java/com/jozufozu/flywheel/backend/core/TransformedModel.java index e5fd44ed1..04436dc0b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/core/TransformedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/TransformedModel.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.core; +package com.jozufozu.flywheel.backend.core; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import net.minecraft.client.renderer.BufferBuilder; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java b/src/main/java/com/jozufozu/flywheel/backend/effects/ColorMatrices.java similarity index 98% rename from src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java rename to src/main/java/com/jozufozu/flywheel/backend/effects/ColorMatrices.java index 0cba9a59c..fc78551d8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ColorMatrices.java +++ b/src/main/java/com/jozufozu/flywheel/backend/effects/ColorMatrices.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.effects; +package com.jozufozu.flywheel.backend.effects; import com.simibubi.create.foundation.utility.AngleHelper; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java b/src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java similarity index 92% rename from src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java rename to src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java index a079c039b..4227ed861 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/EffectsHandler.java +++ b/src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.effects; +package com.jozufozu.flywheel.backend.effects; import java.util.ArrayList; @@ -7,12 +7,12 @@ import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.RenderUtil; +import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.GlVertexArray; import com.simibubi.create.foundation.render.AllProgramSpecs; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.RenderUtil; -import com.simibubi.create.foundation.render.backend.gl.GlBuffer; -import com.simibubi.create.foundation.render.backend.gl.GlPrimitiveType; -import com.simibubi.create.foundation.render.backend.gl.GlVertexArray; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.MainWindow; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java b/src/main/java/com/jozufozu/flywheel/backend/effects/FilterSphere.java similarity index 86% rename from src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java rename to src/main/java/com/jozufozu/flywheel/backend/effects/FilterSphere.java index 91499610f..e7485a705 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/FilterSphere.java +++ b/src/main/java/com/jozufozu/flywheel/backend/effects/FilterSphere.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.effects; +package com.jozufozu.flywheel.backend.effects; import java.nio.FloatBuffer; -import com.simibubi.create.foundation.render.backend.RenderUtil; +import com.jozufozu.flywheel.backend.RenderUtil; import net.minecraft.util.math.vector.Matrix4f; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ScreenQuadAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/effects/ScreenQuadAttributes.java similarity index 63% rename from src/main/java/com/simibubi/create/foundation/render/backend/effects/ScreenQuadAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/effects/ScreenQuadAttributes.java index 5b81e2383..40fd47ac8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/ScreenQuadAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/effects/ScreenQuadAttributes.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.effects; +package com.jozufozu.flywheel.backend.effects; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; public enum ScreenQuadAttributes implements IVertexAttrib { INSTANCE_POS("aVertex", CommonAttributes.VEC4), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java b/src/main/java/com/jozufozu/flywheel/backend/effects/SphereFilterProgram.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/effects/SphereFilterProgram.java index 229aa2f5c..f0aae1390 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/effects/SphereFilterProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/effects/SphereFilterProgram.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.effects; +package com.jozufozu.flywheel.backend.effects; import java.nio.FloatBuffer; import java.util.ArrayList; @@ -6,8 +6,8 @@ import java.util.ArrayList; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL31; -import com.simibubi.create.foundation.render.backend.gl.GlBuffer; -import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Matrix4f; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java similarity index 91% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java index 75e634063..7a70c600d 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl; +package com.jozufozu.flywheel.backend.gl; import java.nio.ByteBuffer; import java.util.function.Consumer; @@ -6,7 +6,7 @@ import java.util.function.Consumer; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.Backend; +import com.jozufozu.flywheel.backend.Backend; public class GlBuffer extends GlObject { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlFog.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlFog.java similarity index 94% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/GlFog.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/GlFog.java index 6dfab5be8..2ad61fcf2 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlFog.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlFog.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl; +package com.jozufozu.flywheel.backend.gl; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlFogMode.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlFogMode.java similarity index 85% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/GlFogMode.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/GlFogMode.java index eb333c732..ebb2354bb 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlFogMode.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlFogMode.java @@ -1,10 +1,10 @@ -package com.simibubi.create.foundation.render.backend.gl; +package com.jozufozu.flywheel.backend.gl; import java.util.Collections; import java.util.List; import com.google.common.collect.Lists; -import com.simibubi.create.foundation.render.backend.gl.shader.ProgramFogMode; +import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; public enum GlFogMode { NONE(ProgramFogMode.None::new), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlObject.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlObject.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/GlObject.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/GlObject.java index 5bc642869..1d13d8871 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlObject.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlObject.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl; +package com.jozufozu.flywheel.backend.gl; // Utility class for safely dealing with gl object handles. public abstract class GlObject { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlPrimitiveType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/GlPrimitiveType.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java index da1d0efba..3a143e3cf 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlPrimitiveType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl; +package com.jozufozu.flywheel.backend.gl; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlTexture.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlTexture.java similarity index 88% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/GlTexture.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/GlTexture.java index 67fbd8dc5..76e637a6e 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlTexture.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlTexture.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl; +package com.jozufozu.flywheel.backend.gl; import org.lwjgl.opengl.GL20; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlVertexArray.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlVertexArray.java similarity index 80% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/GlVertexArray.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/GlVertexArray.java index baf9e9545..4cfb770d9 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/GlVertexArray.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlVertexArray.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.gl; +package com.jozufozu.flywheel.backend.gl; import java.util.function.Consumer; -import com.simibubi.create.foundation.render.backend.Backend; +import com.jozufozu.flywheel.backend.Backend; public class GlVertexArray extends GlObject { public GlVertexArray() { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/CommonAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/CommonAttributes.java similarity index 88% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/CommonAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/attrib/CommonAttributes.java index 5c1a3a91a..99f754efe 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/CommonAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/CommonAttributes.java @@ -1,6 +1,6 @@ -package com.simibubi.create.foundation.render.backend.gl.attrib; +package com.jozufozu.flywheel.backend.gl.attrib; -import com.simibubi.create.foundation.render.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; public class CommonAttributes { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/IAttribSpec.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IAttribSpec.java similarity index 68% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/IAttribSpec.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IAttribSpec.java index 31369cd3f..779d5c502 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/IAttribSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IAttribSpec.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.attrib; +package com.jozufozu.flywheel.backend.gl.attrib; public interface IAttribSpec { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/IVertexAttrib.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IVertexAttrib.java similarity index 66% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/IVertexAttrib.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IVertexAttrib.java index 335ba8644..5775962d8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/IVertexAttrib.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IVertexAttrib.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.attrib; +package com.jozufozu.flywheel.backend.gl.attrib; public interface IVertexAttrib { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/MatrixAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java similarity index 84% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/MatrixAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java index 0e57cf59f..86cf089aa 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/MatrixAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.gl.attrib; +package com.jozufozu.flywheel.backend.gl.attrib; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; public enum MatrixAttributes implements IAttribSpec { MAT3(3, 3), diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/VertexAttribSpec.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java similarity index 87% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/VertexAttribSpec.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java index a9b451d01..7717114ab 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/VertexAttribSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.gl.attrib; +package com.jozufozu.flywheel.backend.gl.attrib; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; public class VertexAttribSpec implements IAttribSpec { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/VertexFormat.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java similarity index 95% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/VertexFormat.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java index 9a3fc8601..714c7e677 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/attrib/VertexFormat.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.attrib; +package com.jozufozu.flywheel.backend.gl.attrib; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/FogSensitiveProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java similarity index 84% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/FogSensitiveProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java index b308a6bd3..3a04cd9f4 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/FogSensitiveProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java @@ -1,11 +1,11 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; import java.util.EnumMap; import java.util.Map; -import com.simibubi.create.foundation.render.backend.ShaderLoader; -import com.simibubi.create.foundation.render.backend.gl.GlFog; -import com.simibubi.create.foundation.render.backend.gl.GlFogMode; +import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.gl.GlFog; +import com.jozufozu.flywheel.backend.gl.GlFogMode; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GLSLType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GLSLType.java similarity index 89% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GLSLType.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/GLSLType.java index 30037b7c2..0ef93042d 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GLSLType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GLSLType.java @@ -1,6 +1,6 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; -import com.simibubi.create.foundation.render.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; public class GLSLType { public static final GLSLType FLOAT = new GLSLType("mat4", GlPrimitiveType.FLOAT, 16); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java similarity index 91% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java index f416f072c..89eabc9d0 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java @@ -1,13 +1,13 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; import java.util.Collection; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.RenderUtil; -import com.simibubi.create.foundation.render.backend.gl.GlObject; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.RenderUtil; +import com.jozufozu.flywheel.backend.gl.GlObject; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Matrix4f; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlShader.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlShader.java similarity index 79% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlShader.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlShader.java index 208b3843d..6b1cd8cca 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlShader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlShader.java @@ -1,10 +1,10 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.gl.GlObject; -import com.simibubi.create.foundation.render.backend.gl.versioned.GlCompat; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.gl.GlObject; +import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/IMultiProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/IMultiProgram.java similarity index 87% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/IMultiProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/IMultiProgram.java index 072c8ab31..950bcddc1 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/IMultiProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/IMultiProgram.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; /** * Encapsulates any number of shader programs for use in similar contexts. diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramFogMode.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramFogMode.java similarity index 90% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramFogMode.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramFogMode.java index f0cb24123..ec1048f9b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramFogMode.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramFogMode.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.gl.GlFog; +import com.jozufozu.flywheel.backend.gl.GlFog; public abstract class ProgramFogMode { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramSpec.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramSpec.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java index 367f47020..f3c4036c4 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java @@ -1,10 +1,10 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; import java.util.ArrayList; import java.util.Arrays; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; import com.simibubi.create.Create; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderCallback.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderCallback.java similarity index 83% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderCallback.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderCallback.java index e6e17c096..cdf5cf2ff 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderCallback.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderCallback.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; /** * A Callback for when a shader is called. Used to define shader uniforms. diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderConstants.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java similarity index 95% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderConstants.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java index 3d1780628..7822c3553 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderConstants.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; import java.io.BufferedReader; import java.io.StringReader; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java new file mode 100644 index 000000000..a0d2d7d21 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java @@ -0,0 +1,7 @@ +package com.jozufozu.flywheel.backend.gl.shader; + +import com.jozufozu.flywheel.backend.ShaderLoader; + +public interface ShaderSpecLoader

{ + IMultiProgram

create(ShaderLoader loader, ProgramSpec

spec); +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderType.java similarity index 76% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderType.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderType.java index 63be397f2..8f6ec6801 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderType.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; import org.lwjgl.opengl.GL20; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/SingleProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java similarity index 87% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/SingleProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java index 832e6d8e3..b4fff4541 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/SingleProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java @@ -1,6 +1,6 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; +package com.jozufozu.flywheel.backend.gl.shader; -import com.simibubi.create.foundation.render.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.ShaderLoader; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlCompat.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlCompat.java similarity index 86% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlCompat.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlCompat.java index c55dbc4d2..17eeecef4 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlCompat.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlCompat.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned; +package com.jozufozu.flywheel.backend.gl.versioned; import java.nio.ByteBuffer; import java.util.Arrays; @@ -9,11 +9,11 @@ import org.lwjgl.opengl.GLCapabilities; import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryUtil; -import com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer.Blit; -import com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer.Framebuffer; -import com.simibubi.create.foundation.render.backend.gl.versioned.instancing.DrawInstanced; -import com.simibubi.create.foundation.render.backend.gl.versioned.instancing.InstancedArrays; -import com.simibubi.create.foundation.render.backend.gl.versioned.instancing.VertexArrayObject; +import com.jozufozu.flywheel.backend.gl.versioned.framebuffer.Blit; +import com.jozufozu.flywheel.backend.gl.versioned.framebuffer.Framebuffer; +import com.jozufozu.flywheel.backend.gl.versioned.instancing.DrawInstanced; +import com.jozufozu.flywheel.backend.gl.versioned.instancing.InstancedArrays; +import com.jozufozu.flywheel.backend.gl.versioned.instancing.VertexArrayObject; /** * An instance of this class stores information diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlVersioned.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlVersioned.java similarity index 88% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlVersioned.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlVersioned.java index a670cd8f9..d019832b7 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlVersioned.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlVersioned.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned; +package com.jozufozu.flywheel.backend.gl.versioned; import org.lwjgl.opengl.GLCapabilities; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/MapBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java similarity index 96% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/MapBuffer.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java index dc11699fb..27636f949 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/MapBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned; +package com.jozufozu.flywheel.backend.gl.versioned; import java.nio.ByteBuffer; import java.util.function.Consumer; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/RGPixelFormat.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/RGPixelFormat.java similarity index 94% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/RGPixelFormat.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/versioned/RGPixelFormat.java index 62233e7b4..339289894 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/RGPixelFormat.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/RGPixelFormat.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned; +package com.jozufozu.flywheel.backend.gl.versioned; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL30; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Blit.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/framebuffer/Blit.java similarity index 89% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Blit.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/versioned/framebuffer/Blit.java index b5809fa29..fdf5473d1 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Blit.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/framebuffer/Blit.java @@ -1,10 +1,10 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer; +package com.jozufozu.flywheel.backend.gl.versioned.framebuffer; import org.lwjgl.opengl.EXTFramebufferBlit; import org.lwjgl.opengl.GL30; import org.lwjgl.opengl.GLCapabilities; -import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; +import com.jozufozu.flywheel.backend.gl.versioned.GlVersioned; public enum Blit implements GlVersioned { CORE { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Framebuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/framebuffer/Framebuffer.java similarity index 89% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Framebuffer.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/versioned/framebuffer/Framebuffer.java index 02b64c8d5..a0e2b3e1b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/framebuffer/Framebuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/framebuffer/Framebuffer.java @@ -1,11 +1,11 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned.framebuffer; +package com.jozufozu.flywheel.backend.gl.versioned.framebuffer; import org.lwjgl.opengl.ARBFramebufferObject; import org.lwjgl.opengl.EXTFramebufferObject; import org.lwjgl.opengl.GL30C; import org.lwjgl.opengl.GLCapabilities; -import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; +import com.jozufozu.flywheel.backend.gl.versioned.GlVersioned; public enum Framebuffer implements GlVersioned { CORE { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/DrawInstanced.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/DrawInstanced.java similarity index 90% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/DrawInstanced.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/DrawInstanced.java index 063dab785..e30ba9bfc 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/DrawInstanced.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/DrawInstanced.java @@ -1,11 +1,11 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned.instancing; +package com.jozufozu.flywheel.backend.gl.versioned.instancing; import org.lwjgl.opengl.ARBDrawInstanced; import org.lwjgl.opengl.EXTDrawInstanced; import org.lwjgl.opengl.GL31; import org.lwjgl.opengl.GLCapabilities; -import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; +import com.jozufozu.flywheel.backend.gl.versioned.GlVersioned; public enum DrawInstanced implements GlVersioned { GL31_DRAW_INSTANCED { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/InstancedArrays.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/InstancedArrays.java similarity index 86% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/InstancedArrays.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/InstancedArrays.java index 6e2faf155..2c681d41d 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/InstancedArrays.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/InstancedArrays.java @@ -1,10 +1,10 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned.instancing; +package com.jozufozu.flywheel.backend.gl.versioned.instancing; import org.lwjgl.opengl.ARBInstancedArrays; import org.lwjgl.opengl.GL33; import org.lwjgl.opengl.GLCapabilities; -import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; +import com.jozufozu.flywheel.backend.gl.versioned.GlVersioned; public enum InstancedArrays implements GlVersioned { GL33_INSTANCED_ARRAYS { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/VertexArrayObject.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/VertexArrayObject.java similarity index 90% rename from src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/VertexArrayObject.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/VertexArrayObject.java index 18023f9aa..4a2d13c11 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/VertexArrayObject.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/VertexArrayObject.java @@ -1,10 +1,10 @@ -package com.simibubi.create.foundation.render.backend.gl.versioned.instancing; +package com.jozufozu.flywheel.backend.gl.versioned.instancing; import org.lwjgl.opengl.ARBVertexArrayObject; import org.lwjgl.opengl.GL30; import org.lwjgl.opengl.GLCapabilities; -import com.simibubi.create.foundation.render.backend.gl.versioned.GlVersioned; +import com.jozufozu.flywheel.backend.gl.versioned.GlVersioned; public enum VertexArrayObject implements GlVersioned { GL30_VAO { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IDynamicInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java similarity index 94% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/IDynamicInstance.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java index a125fd11a..6e825639c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IDynamicInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; /** * An interface giving {@link TileEntityInstance}s a hook to have a function called at diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IFlywheelWorld.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IFlywheelWorld.java similarity index 82% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/IFlywheelWorld.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/IFlywheelWorld.java index 86a00ab01..5a138fefc 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IFlywheelWorld.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IFlywheelWorld.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; /** * A marker interface custom worlds can override to indicate diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java similarity index 83% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/IInstance.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java index 88ec0eb22..32bab42ab 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IInstanceRendered.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java similarity index 59% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/IInstanceRendered.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java index 386fd9b9c..b9494058c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IInstanceRendered.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; public interface IInstanceRendered { default boolean shouldRenderAsTE() { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IRendererFactory.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IRendererFactory.java similarity index 75% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/IRendererFactory.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/IRendererFactory.java index 206a7534e..7a00d4276 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/IRendererFactory.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IRendererFactory.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/ITickableInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java similarity index 95% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/ITickableInstance.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java index c9280973b..e660195c1 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/ITickableInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; /** * An interface giving {@link TileEntityInstance}s a hook to have a function called at diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstanceData.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java similarity index 94% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstanceData.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java index 14d5f1fb4..320432890 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstanceData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; import java.nio.ByteBuffer; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java similarity index 92% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java index 1ba9b45a1..53a21c878 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; import java.nio.ByteBuffer; @@ -9,12 +9,12 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.BufferedModel; -import com.simibubi.create.foundation.render.backend.core.ModelAttributes; -import com.simibubi.create.foundation.render.backend.gl.GlBuffer; -import com.simibubi.create.foundation.render.backend.gl.GlVertexArray; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.BufferedModel; +import com.jozufozu.flywheel.backend.core.ModelAttributes; +import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.GlVertexArray; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import net.minecraft.client.renderer.BufferBuilder; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderRegistry.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderRegistry.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderRegistry.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderRegistry.java index 19370f6a0..ff8a320fb 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderRegistry.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderRegistry.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; import java.util.Map; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java index 859550904..2bc2049d8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; import java.util.ArrayList; import java.util.HashMap; @@ -6,13 +6,13 @@ import java.util.Map; import javax.annotation.Nullable; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.MaterialType; -import com.simibubi.create.foundation.render.backend.MaterialTypes; -import com.simibubi.create.foundation.render.backend.core.BasicProgram; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.gl.shader.ShaderCallback; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.MaterialType; +import com.jozufozu.flywheel.backend.MaterialTypes; +import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/ModelFactory.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/ModelFactory.java similarity index 75% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/ModelFactory.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/ModelFactory.java index 2042929a8..74edfc7b4 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/ModelFactory.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/ModelFactory.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; import net.minecraft.client.renderer.BufferBuilder; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java similarity index 88% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index bafe18da4..e29a9d5dd 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; @@ -9,15 +9,15 @@ import org.apache.commons.lang3.tuple.Pair; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.RenderUtil; +import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.render.SuperByteBufferCache; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.RenderUtil; -import com.simibubi.create.foundation.render.backend.core.BasicProgram; -import com.simibubi.create.foundation.render.backend.core.PartialModel; -import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; -import com.simibubi.create.foundation.render.backend.gl.shader.ShaderCallback; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/TileEntityInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/TileEntityInstance.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java index f5f23f31a..292021e48 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/TileEntityInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java @@ -1,11 +1,11 @@ -package com.simibubi.create.foundation.render.backend.instancing; +package com.jozufozu.flywheel.backend.instancing; import java.util.Arrays; import java.util.stream.Stream; -import com.simibubi.create.foundation.render.backend.core.IFlatLight; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.IFlatLight; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.OrientedData; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/util/ConditionalInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/util/ConditionalInstance.java similarity index 81% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/util/ConditionalInstance.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/util/ConditionalInstance.java index 386794900..f47c21269 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/util/ConditionalInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/util/ConditionalInstance.java @@ -1,11 +1,11 @@ -package com.simibubi.create.foundation.render.backend.instancing.util; +package com.jozufozu.flywheel.backend.instancing.util; import java.util.Optional; import javax.annotation.Nullable; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; public class ConditionalInstance { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/util/InstanceGroup.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/util/InstanceGroup.java similarity index 86% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/util/InstanceGroup.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/util/InstanceGroup.java index 6aa8f0cff..6ea964ea9 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/util/InstanceGroup.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/util/InstanceGroup.java @@ -1,12 +1,12 @@ -package com.simibubi.create.foundation.render.backend.instancing.util; +package com.jozufozu.flywheel.backend.instancing.util; import java.util.AbstractCollection; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; public class InstanceGroup extends AbstractCollection { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/util/SelectInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/util/SelectInstance.java similarity index 82% rename from src/main/java/com/simibubi/create/foundation/render/backend/instancing/util/SelectInstance.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/util/SelectInstance.java index 25a6445d8..e986763f2 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/util/SelectInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/util/SelectInstance.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.instancing.util; +package com.jozufozu.flywheel.backend.instancing.util; import java.util.ArrayList; import java.util.List; @@ -6,8 +6,8 @@ import java.util.Optional; import javax.annotation.Nullable; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; public class SelectInstance { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/light/CoordinateConsumer.java b/src/main/java/com/jozufozu/flywheel/backend/light/CoordinateConsumer.java similarity index 61% rename from src/main/java/com/simibubi/create/foundation/render/backend/light/CoordinateConsumer.java rename to src/main/java/com/jozufozu/flywheel/backend/light/CoordinateConsumer.java index 6f20a8c33..f4fed3d9f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/light/CoordinateConsumer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/light/CoordinateConsumer.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.light; +package com.jozufozu.flywheel.backend.light; @FunctionalInterface public interface CoordinateConsumer { diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/light/EmptyLighter.java b/src/main/java/com/jozufozu/flywheel/backend/light/EmptyLighter.java similarity index 89% rename from src/main/java/com/simibubi/create/foundation/render/backend/light/EmptyLighter.java rename to src/main/java/com/jozufozu/flywheel/backend/light/EmptyLighter.java index a92cf4e27..660e80d11 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/light/EmptyLighter.java +++ b/src/main/java/com/jozufozu/flywheel/backend/light/EmptyLighter.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.light; +package com.jozufozu.flywheel.backend.light; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/light/GridAlignedBB.java b/src/main/java/com/jozufozu/flywheel/backend/light/GridAlignedBB.java similarity index 97% rename from src/main/java/com/simibubi/create/foundation/render/backend/light/GridAlignedBB.java rename to src/main/java/com/jozufozu/flywheel/backend/light/GridAlignedBB.java index 3703143f5..d8f90f90b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/light/GridAlignedBB.java +++ b/src/main/java/com/jozufozu/flywheel/backend/light/GridAlignedBB.java @@ -1,8 +1,8 @@ -package com.simibubi.create.foundation.render.backend.light; +package com.jozufozu.flywheel.backend.light; -import static com.simibubi.create.foundation.render.backend.RenderUtil.isPowerOf2; +import static com.jozufozu.flywheel.backend.RenderUtil.isPowerOf2; -import com.simibubi.create.foundation.render.backend.RenderUtil; +import com.jozufozu.flywheel.backend.RenderUtil; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightUpdateListener.java b/src/main/java/com/jozufozu/flywheel/backend/light/LightUpdateListener.java similarity index 94% rename from src/main/java/com/simibubi/create/foundation/render/backend/light/LightUpdateListener.java rename to src/main/java/com/jozufozu/flywheel/backend/light/LightUpdateListener.java index 09ea1a04d..1dd0e95dc 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightUpdateListener.java +++ b/src/main/java/com/jozufozu/flywheel/backend/light/LightUpdateListener.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.light; +package com.jozufozu.flywheel.backend.light; import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.LightType; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightUpdater.java b/src/main/java/com/jozufozu/flywheel/backend/light/LightUpdater.java similarity index 99% rename from src/main/java/com/simibubi/create/foundation/render/backend/light/LightUpdater.java rename to src/main/java/com/jozufozu/flywheel/backend/light/LightUpdater.java index 089376a23..5210d02c8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightUpdater.java +++ b/src/main/java/com/jozufozu/flywheel/backend/light/LightUpdater.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.light; +package com.jozufozu.flywheel.backend.light; import java.util.WeakHashMap; import java.util.function.LongConsumer; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolume.java b/src/main/java/com/jozufozu/flywheel/backend/light/LightVolume.java similarity index 96% rename from src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolume.java rename to src/main/java/com/jozufozu/flywheel/backend/light/LightVolume.java index ae0bdaa23..48a86fcb6 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolume.java +++ b/src/main/java/com/jozufozu/flywheel/backend/light/LightVolume.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.light; +package com.jozufozu.flywheel.backend.light; import java.nio.ByteBuffer; @@ -8,10 +8,10 @@ import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL20; import org.lwjgl.system.MemoryUtil; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.RenderWork; -import com.simibubi.create.foundation.render.backend.gl.GlTexture; -import com.simibubi.create.foundation.render.backend.gl.versioned.RGPixelFormat; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.RenderWork; +import com.jozufozu.flywheel.backend.gl.GlTexture; +import com.jozufozu.flywheel.backend.gl.versioned.RGPixelFormat; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockDisplayReader; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolumeDebugger.java b/src/main/java/com/jozufozu/flywheel/backend/light/LightVolumeDebugger.java similarity index 95% rename from src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolumeDebugger.java rename to src/main/java/com/jozufozu/flywheel/backend/light/LightVolumeDebugger.java index e63257d04..6fbcd4d5b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/light/LightVolumeDebugger.java +++ b/src/main/java/com/jozufozu/flywheel/backend/light/LightVolumeDebugger.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.render.backend.light; +package com.jozufozu.flywheel.backend.light; import java.util.ArrayList; diff --git a/src/main/java/com/simibubi/create/AllBlockPartials.java b/src/main/java/com/simibubi/create/AllBlockPartials.java index 102fc4412..ec2984795 100644 --- a/src/main/java/com/simibubi/create/AllBlockPartials.java +++ b/src/main/java/com/simibubi/create/AllBlockPartials.java @@ -3,9 +3,9 @@ package com.simibubi.create; import java.util.HashMap; import java.util.Map; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 2940b484d..4b38736f7 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -7,6 +7,10 @@ import java.util.function.Function; import javax.annotation.Nullable; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.OptifineHandler; +import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivity; @@ -25,10 +29,6 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.render.KineticRenderer; import com.simibubi.create.foundation.render.SuperByteBufferCache; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.OptifineHandler; -import com.simibubi.create.foundation.render.backend.core.PartialModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.WorldAttached; import com.simibubi.create.foundation.utility.ghost.GhostBlocks; import com.simibubi.create.foundation.utility.outliner.Outliner; 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 920ab0bf3..8af7874a1 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 @@ -1,11 +1,11 @@ package com.simibubi.create.compat.jei.category.animations; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; import com.simibubi.create.foundation.gui.GuiGameElement; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import mezz.jei.api.gui.drawable.IDrawable; import net.minecraft.util.math.vector.Vector3f; 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 fb0e5a880..dcf4f1633 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,8 +1,8 @@ package com.simibubi.create.compat.jei.category.animations; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AnimationTickHolder; import mezz.jei.api.gui.drawable.IDrawable; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/BackHalfShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/BackHalfShaftInstance.java index 738155141..e613e7d28 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/BackHalfShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/BackHalfShaftInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.base; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/HalfShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/HalfShaftInstance.java index 6d3664988..aae8b7c2d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/HalfShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/HalfShaftInstance.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.base; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalHalfShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalHalfShaftInstance.java index d5a21d468..d34848692 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalHalfShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/HorizontalHalfShaftInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.base; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticAttributes.java index 8f7b9b15b..3d9f31d5f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticAttributes.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticAttributes.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.base; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; public enum KineticAttributes implements IVertexAttrib { INSTANCE_POSITION("aInstancePos", CommonAttributes.VEC3), diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java index b259c89aa..69d8d61b7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.base; import java.nio.ByteBuffer; -import com.simibubi.create.foundation.render.backend.core.BasicData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.core.BasicData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.simibubi.create.foundation.utility.ColorHelper; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticRenderMaterials.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticRenderMaterials.java index 29ee62162..d71c65ee6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticRenderMaterials.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticRenderMaterials.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.base; +import com.jozufozu.flywheel.backend.MaterialType; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.simibubi.create.content.contraptions.components.actors.ActorData; import com.simibubi.create.content.contraptions.relays.belt.BeltData; import com.simibubi.create.content.logistics.block.FlapData; -import com.simibubi.create.foundation.render.backend.MaterialType; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; public class KineticRenderMaterials { public static final MaterialType> ROTATING = new MaterialType<>(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java index 93058fb64..653240307 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java @@ -7,6 +7,8 @@ import java.util.List; import javax.annotation.Nullable; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.KineticNetwork; import com.simibubi.create.content.contraptions.RotationPropagator; @@ -18,8 +20,6 @@ import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxBlock; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.item.TooltipHelper; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.sound.SoundScapes; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java index dcefcadfe..e86972c03 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.contraptions.base; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlocks; @@ -8,7 +9,6 @@ import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; import com.simibubi.create.foundation.render.Compartment; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.ColorHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java index f5d6d902e..a21305de9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.base; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; +import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; -import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; import net.minecraft.block.BlockState; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingAttributes.java index ef0e1122c..215027123 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingAttributes.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingAttributes.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.base; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; public enum RotatingAttributes implements IVertexAttrib { AXIS("aAxis", CommonAttributes.NORMAL), diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java index 1ca50d3e8..e40d3cf07 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.base; import java.nio.ByteBuffer; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; import net.minecraft.util.Direction; import net.minecraft.util.math.vector.Vector3f; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java index 81582c35b..4cc26671f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.base; -import com.simibubi.create.foundation.render.backend.core.BasicAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.core.BasicAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import net.minecraft.client.renderer.BufferBuilder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessCogInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessCogInstance.java index 16f85ab32..733c23a01 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessCogInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessCogInstance.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.base; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; public class ShaftlessCogInstance extends SingleRotatingInstance { diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/SingleRotatingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/SingleRotatingInstance.java index 1749e308f..266f1f0cd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/SingleRotatingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/SingleRotatingInstance.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.base; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java index 191e3ebc0..42bd732c2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.actors; import java.nio.ByteBuffer; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Quaternion; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorModel.java index a8fdeac6c..9010ba9ca 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorModel.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.components.actors; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import net.minecraft.client.renderer.BufferBuilder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorVertexAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorVertexAttributes.java index ff633d817..696d9279a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorVertexAttributes.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorVertexAttributes.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.components.actors; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; public enum ActorVertexAttributes implements IVertexAttrib { INSTANCE_POSITION("aInstancePos", CommonAttributes.VEC3), diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java index 40df1e591..517e4fcdb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.components.actors; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillInstance.java index 7d1bdd735..35d8e766a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillInstance.java @@ -2,12 +2,12 @@ package com.simibubi.create.content.contraptions.components.actors; import static net.minecraft.state.properties.BlockStateProperties.FACING; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import net.minecraft.block.BlockState; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java index 8232772f3..3eeb3f58b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java @@ -2,11 +2,11 @@ package com.simibubi.create.content.contraptions.components.actors; import javax.annotation.Nullable; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java index 83f516058..2f5810e9d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java @@ -2,14 +2,14 @@ package com.simibubi.create.content.contraptions.components.actors; import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java index 6472d23d4..83b6a4bcc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -6,12 +6,12 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.mutable.MutableBoolean; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.VecHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java index 01c3d4d6f..4064f9db0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors; import java.util.function.Consumer; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -10,7 +11,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java index 412cd349b..a5e0a6a33 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.contraptions.components.clock; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -8,7 +9,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity.Animation; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AngleHelper; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterInstance.java index 2d88b431c..517258358 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterInstance.java @@ -2,13 +2,13 @@ package com.simibubi.create.content.contraptions.components.crafter; import java.util.function.Supplier; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.MatrixStacker; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java index 4e0e9bc73..b30da5db0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java @@ -3,6 +3,8 @@ package com.simibubi.create.content.contraptions.components.crafter; import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING; import static com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer.standardKineticRotationTransform; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -11,8 +13,6 @@ import com.simibubi.create.content.contraptions.components.crafter.MechanicalCra import com.simibubi.create.content.contraptions.components.crafter.RecipeGridHandler.GroupedItems; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankBlock.java index 2b2bda8d6..c1a4a3fe3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankBlock.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.components.crank; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.config.AllConfigs; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java index 843882dce..a1ed191ee 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.components.crank; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.core.PartialModel; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java index 7db258093..4e675698f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java @@ -2,13 +2,13 @@ package com.simibubi.create.content.contraptions.components.crank; import static net.minecraft.state.properties.BlockStateProperties.FACING; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java index e9e8c32d7..875992e8b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.crank; import javax.annotation.ParametersAreNonnullByDefault; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.AllBlocks; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.DyeHelper; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java index e91bc8a0d..69fddcb03 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java @@ -3,6 +3,10 @@ package com.simibubi.create.content.contraptions.components.deployer; import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.IRotate; @@ -13,10 +17,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.core.PartialModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java index 31b1d7665..ad3fcd28f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java @@ -3,14 +3,14 @@ package com.simibubi.create.content.contraptions.components.deployer; import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.ITickableInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; -import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.core.PartialModel; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.ITickableInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java index a146a6c3e..ba8a67dc7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -7,6 +7,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; @@ -23,7 +24,6 @@ import com.simibubi.create.content.schematics.SchematicWorld; import com.simibubi.create.content.schematics.filtering.SchematicInstances; import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTProcessors; @@ -115,7 +115,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { List requiredItems = requirement.getRequiredItems(); ItemStack firstRequired = requiredItems.isEmpty() ? ItemStack.EMPTY : requiredItems.get(0); - + if (!context.contraption.hasUniversalCreativeCrate) { IItemHandler iItemHandler = context.contraption.inventory; for (ItemStack required : requiredItems) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java index 0261f9651..6100d2c2e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java @@ -3,6 +3,8 @@ package com.simibubi.create.content.contraptions.components.deployer; import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -13,8 +15,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java index c1e5493a1..102d2bb2b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java @@ -5,13 +5,13 @@ import static com.simibubi.create.content.contraptions.base.DirectionalKineticBl import java.util.ArrayList; import java.util.List; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.curiosities.tools.SandPaperItem; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.item.TooltipHelper; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.NBTHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java index 6491d16e3..ec49792ae 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.fan; import static net.minecraft.state.properties.BlockStateProperties.FACING; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -9,7 +10,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.renderer.IRenderTypeBuffer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java index 2feec9410..0a440e67f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java @@ -2,10 +2,10 @@ package com.simibubi.create.content.contraptions.components.fan; import static net.minecraft.state.properties.BlockStateProperties.FACING; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.RotatingData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java index 219adb6d1..e085391c2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java @@ -6,16 +6,16 @@ import java.util.Collections; import java.util.List; import com.google.common.collect.Lists; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.RotatingData; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java index bf3b46295..edbe2baae 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.flywheel; import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -10,7 +11,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock.ConnectionState; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.AngleHelper; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java index f3d07cf66..6e8e09d51 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; import javax.annotation.Nullable; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.content.contraptions.wrench.IWrenchable; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java index 3f76914d0..eb5c2cb2b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.core.PartialModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java index 42be5bedf..a47c32400 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.render.PartialBufferer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineTileEntity.java index 6887efaf4..719a735ca 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineTileEntity.java @@ -2,10 +2,10 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; import java.util.List; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java index e50508ad0..82ab8ffea 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import net.minecraft.block.AbstractFurnaceBlock; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillStoneCogInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillStoneCogInstance.java index e2f931eba..7cad8bda9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillStoneCogInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillStoneCogInstance.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.components.millstone; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; public class MillStoneCogInstance extends SingleRotatingInstance { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java index cf0cfe81a..da872236b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.contraptions.components.mixer; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -7,7 +8,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java index 2df6346ab..a930a77e6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.components.mixer; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.ShaftlessCogInstance; -import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java index 189056eb1..9ce1c3d8c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java @@ -2,13 +2,13 @@ package com.simibubi.create.content.contraptions.components.press; import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java index 8dc92b64f..b0e78648e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.components.press; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; -import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawInstance.java index a3471f32a..47b49924a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawInstance.java @@ -2,12 +2,12 @@ package com.simibubi.create.content.contraptions.components.saw; import static net.minecraft.state.properties.BlockStateProperties.FACING; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import net.minecraft.block.BlockState; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index 5ab9a2960..5b267707e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -2,6 +2,8 @@ package com.simibubi.create.content.contraptions.components.saw; import static net.minecraft.state.properties.BlockStateProperties.FACING; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.CreateClient; @@ -11,8 +13,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index 63d400304..0a3d995b0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -25,6 +25,9 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; +import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; +import com.jozufozu.flywheel.backend.light.EmptyLighter; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.base.IRotate; @@ -55,9 +58,6 @@ import com.simibubi.create.content.logistics.block.inventories.CreativeCrateTile import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.fluid.CombinedTankWrapper; -import com.simibubi.create.foundation.render.backend.instancing.IFlywheelWorld; -import com.simibubi.create.foundation.render.backend.light.EmptyLighter; -import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.Coordinate; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java index 641c3a90c..518fa9dff 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionLighter.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; +import com.jozufozu.flywheel.backend.light.LightUpdateListener; +import com.jozufozu.flywheel.backend.light.LightUpdater; +import com.jozufozu.flywheel.backend.light.LightVolume; import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption; -import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; -import com.simibubi.create.foundation.render.backend.light.LightUpdateListener; -import com.simibubi.create.foundation.render.backend.light.LightUpdater; -import com.simibubi.create.foundation.render.backend.light.LightVolume; import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.LightType; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java index 9ce341586..50c0e7119 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption; -import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; public class NonStationaryLighter extends ContraptionLighter { public NonStationaryLighter(C contraption) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/AnchoredLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/AnchoredLighter.java index b5ed7ee45..4a0489ca1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/AnchoredLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/AnchoredLighter.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.bearing; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; -import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; public class AnchoredLighter extends ContraptionLighter { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java index f3c46d7d6..f5b8a1169 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.components.structureMovement.bearing; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.BackHalfShaftInstance; import com.simibubi.create.content.contraptions.base.KineticTileEntity; -import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.core.PartialModel; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java index cf6f59b7c..647a3423b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java @@ -1,13 +1,13 @@ package com.simibubi.create.content.contraptions.components.structureMovement.bearing; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AngleHelper; import net.minecraft.client.renderer.IRenderTypeBuffer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java index 49c7007b0..ecb98bee6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement.bearing; +import com.jozufozu.flywheel.backend.core.OrientedData; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; -import com.simibubi.create.foundation.render.backend.core.OrientedData; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java index 9d776cb3a..ba09371d2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java @@ -2,6 +2,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be import javax.annotation.Nullable; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; @@ -14,8 +16,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.renderer.IRenderTypeBuffer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java index 9e83b008c..cabddfe5b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.components.structureMovement.chassis; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java index 1abccec33..d100d7e9d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement.chassis; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java index 34d4a421f..0dcb89f85 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java @@ -2,12 +2,12 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch import java.util.List; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity; import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueItem; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.animation.LerpedFloat; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java index fba18244f..860923dc4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java @@ -1,13 +1,13 @@ package com.simibubi.create.content.contraptions.components.structureMovement.gantry; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java index 72152ff04..cfdeb46b1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.components.structureMovement.gantry; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java index 466d5bae5..6070a9ccb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonLighter.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.piston; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; -import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; import net.minecraft.util.math.vector.Vector3i; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java index d17c12582..3c09ecf5b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java @@ -2,18 +2,18 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu import java.util.Arrays; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.util.ConditionalInstance; +import com.jozufozu.flywheel.backend.instancing.util.InstanceGroup; +import com.jozufozu.flywheel.backend.instancing.util.SelectInstance; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; +import com.jozufozu.flywheel.backend.light.LightUpdateListener; +import com.jozufozu.flywheel.backend.light.LightUpdater; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; -import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.util.ConditionalInstance; -import com.simibubi.create.foundation.render.backend.instancing.util.InstanceGroup; -import com.simibubi.create.foundation.render.backend.instancing.util.SelectInstance; -import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; -import com.simibubi.create.foundation.render.backend.light.LightUpdateListener; -import com.simibubi.create.foundation.render.backend.light.LightUpdater; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java index 481b065d0..f1fa89220 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.content.contraptions.base.IRotate; @@ -7,8 +9,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AngleHelper; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/HosePulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/HosePulleyInstance.java index a1adb0e43..2c574c770 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/HosePulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/HosePulleyInstance.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.fluids.actors.HosePulleyTileEntity; -import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; public class HosePulleyInstance extends AbstractPulleyInstance { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java index 87cc4cacf..8235bc095 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyLighter.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; -import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java index 4db922553..1fa02d43f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.Direction.Axis; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java index a3bf2dd82..036c91ed1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; -import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; public class RopePulleyInstance extends AbstractPulleyInstance { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionAttributes.java index 4e3d65be9..649f5e680 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionAttributes.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionAttributes.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; public enum ContraptionAttributes implements IVertexAttrib { VERTEX_POSITION("aPos", CommonAttributes.VEC3), diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java index 51f02c77b..986ad162e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java @@ -7,6 +7,12 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; +import com.jozufozu.flywheel.backend.MaterialTypes; +import com.jozufozu.flywheel.backend.core.OrientedModel; +import com.jozufozu.flywheel.backend.core.TransformedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.contraptions.base.RotatingModel; @@ -17,12 +23,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; import com.simibubi.create.content.logistics.block.FlapModel; import com.simibubi.create.foundation.render.AllProgramSpecs; -import com.simibubi.create.foundation.render.backend.MaterialTypes; -import com.simibubi.create.foundation.render.backend.core.OrientedModel; -import com.simibubi.create.foundation.render.backend.core.TransformedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java index 270d8d08d..1b1343135 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java @@ -5,10 +5,10 @@ import java.nio.ByteBuffer; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.BufferedModel; -import com.simibubi.create.foundation.render.backend.gl.GlBuffer; -import com.simibubi.create.foundation.render.backend.gl.GlPrimitiveType; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.BufferedModel; +import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.LightTexture; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java index 7e0d2750e..868c121ab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.re import org.lwjgl.opengl.GL20; -import com.simibubi.create.foundation.render.backend.core.BasicProgram; -import com.simibubi.create.foundation.render.backend.gl.shader.ProgramFogMode; +import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 83c39757f..b7624b37a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -8,6 +8,8 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL40; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.CreateClient; @@ -20,8 +22,6 @@ import com.simibubi.create.foundation.render.Compartment; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.TileEntityRenderHelper; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index bf5ffde42..16b079aa8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -7,13 +7,13 @@ import java.util.Random; import org.lwjgl.opengl.GL11; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; -import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpCogInstance.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpCogInstance.java index 470b5ab4e..2aae2c2d6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpCogInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpCogInstance.java @@ -2,12 +2,12 @@ package com.simibubi.create.content.contraptions.fluids; import static net.minecraft.state.properties.BlockStateProperties.FACING; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import net.minecraft.block.BlockState; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java index 3e1a43506..6615a4a09 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.fluids.actors; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.pulley.AbstractPulleyRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.Direction.Axis; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java index 2cbacbd36..20db657b8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.fluids.actors; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.render.PartialBufferer; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java index 2e041cc60..6c2d1a278 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java @@ -1,13 +1,13 @@ package com.simibubi.create.content.contraptions.fluids.pipes; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java index 3d3a02951..5ea1d6dc5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.fluids.pipes; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java index 1d3765ac6..f581a022d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.contraptions.processing.burner; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java index 6d4fec12e..b3a66b92e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.contraptions.relays.advanced; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -7,7 +8,6 @@ import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltAttributes.java index 4753f1eb2..6a7b20814 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltAttributes.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltAttributes.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.relays.belt; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; public enum BeltAttributes implements IVertexAttrib { INSTANCE_ROTATION("aInstanceRot", CommonAttributes.QUATERNION), diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java index ec0b082c5..81d59d97b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java @@ -2,9 +2,9 @@ package com.simibubi.create.content.contraptions.relays.belt; import java.nio.ByteBuffer; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.simibubi.create.content.contraptions.base.KineticData; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.math.vector.Quaternion; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java index 5546490ea..08a35cff9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java @@ -3,6 +3,10 @@ package com.simibubi.create.content.contraptions.relays.belt; import java.util.ArrayList; import java.util.function.Supplier; +import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; @@ -10,10 +14,6 @@ import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; -import com.simibubi.create.foundation.render.backend.core.PartialModel; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java index 7b75ce395..10d68db54 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.relays.belt; +import com.jozufozu.flywheel.backend.core.BasicAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.content.contraptions.base.KineticAttributes; -import com.simibubi.create.foundation.render.backend.core.BasicAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import net.minecraft.client.renderer.BufferBuilder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java index 4beec3bb0..076fa64d2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java @@ -3,6 +3,8 @@ package com.simibubi.create.content.contraptions.relays.belt; import java.util.Random; import java.util.function.Supplier; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -15,8 +17,6 @@ import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.ShadowRenderHelper; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java index 1624eb195..1202e5d58 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java @@ -12,6 +12,10 @@ import java.util.Map; import java.util.Optional; import java.util.function.Function; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; +import com.jozufozu.flywheel.backend.light.LightUpdateListener; +import com.jozufozu.flywheel.backend.light.LightUpdater; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.KineticTileEntity; @@ -22,10 +26,6 @@ import com.simibubi.create.content.contraptions.relays.belt.transport.BeltTunnel import com.simibubi.create.content.contraptions.relays.belt.transport.ItemHandlerBeltSegment; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; import com.simibubi.create.content.logistics.block.belts.tunnel.BrassTunnelTileEntity; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; -import com.simibubi.create.foundation.render.backend.light.LightUpdateListener; -import com.simibubi.create.foundation.render.backend.light.LightUpdater; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ShaftInstance.java index b2929b67f..eb7185fc7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ShaftInstance.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.relays.encased; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java index f317fd24d..a2847452d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java @@ -2,14 +2,14 @@ package com.simibubi.create.content.contraptions.relays.encased; import java.util.ArrayList; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.RotatingData; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java index cac191681..c8016ed47 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.contraptions.relays.encased; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.IRotate; @@ -7,7 +8,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java index dd0a740dd..94178337b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java @@ -2,14 +2,14 @@ package com.simibubi.create.content.contraptions.relays.gauge; import java.util.ArrayList; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java index 56c9fb89b..1588b1c77 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.contraptions.relays.gauge; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -8,8 +10,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock.Type; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java index a991802fa..747c6a9ec 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java @@ -3,13 +3,13 @@ package com.simibubi.create.content.contraptions.relays.gearbox; import java.util.EnumMap; import java.util.Map; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.RotatingData; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.state.properties.BlockStateProperties; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java index 72c2e09e8..f0e0c5e5b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions.relays.gearbox; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java index ea7aa760a..e0b1edd59 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.curiosities.projector; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; public class ChromaticProjectorInstance extends TileEntityInstance implements IDynamicInstance { diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java index 0bb20e983..6af2872c5 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorTileEntity.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.curiosities.projector; import java.util.Vector; -import com.simibubi.create.foundation.render.backend.effects.FilterSphere; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; +import com.jozufozu.flywheel.backend.effects.FilterSphere; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SyncedTileEntity; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java index 0d072b419..ab56d6487 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ColorEffect.java @@ -6,8 +6,8 @@ import java.util.List; import java.util.function.Function; import java.util.function.Supplier; +import com.jozufozu.flywheel.backend.effects.ColorMatrices; import com.simibubi.create.foundation.gui.AllGuiTextures; -import com.simibubi.create.foundation.render.backend.effects.ColorMatrices; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; import com.simibubi.create.foundation.utility.Lang; diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java index a8a3795e8..d91f64ee6 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/FilterStep.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.curiosities.projector; import java.util.Iterator; import java.util.Vector; -import com.simibubi.create.foundation.render.backend.effects.ColorMatrices; +import com.jozufozu.flywheel.backend.effects.ColorMatrices; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/CrossPlaneMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/CrossPlaneMirror.java index 805673bec..45894d199 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/CrossPlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/CrossPlaneMirror.java @@ -5,9 +5,9 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java index 9e953ae5b..0fc2fe73b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; -import com.simibubi.create.foundation.render.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.PartialModel; import net.minecraft.block.BlockState; import net.minecraft.util.IStringSerializable; diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java index 53f8a55c3..2d849ba46 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java @@ -5,9 +5,9 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java index 02e950e9e..46df9226b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java @@ -5,8 +5,8 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java index 838d4b366..9cac8c376 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java @@ -5,8 +5,8 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java index 847935f56..e1090f707 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.curiosities.tools; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllItems; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapAttributes.java b/src/main/java/com/simibubi/create/content/logistics/block/FlapAttributes.java index 71a8db0af..ad6864629 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapAttributes.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/FlapAttributes.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.logistics.block; -import com.simibubi.create.foundation.render.backend.gl.attrib.CommonAttributes; -import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec; -import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; +import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; public enum FlapAttributes implements IVertexAttrib { INSTANCE_POSITION("aInstancePos",CommonAttributes.VEC3), diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java index 2a91a9e94..2eed76a0f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java @@ -2,9 +2,9 @@ package com.simibubi.create.content.logistics.block; import java.nio.ByteBuffer; -import com.simibubi.create.foundation.render.backend.core.IFlatLight; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.core.IFlatLight; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3f; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapModel.java b/src/main/java/com/simibubi/create/content/logistics/block/FlapModel.java index 7a6a00f14..42aeb46f5 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapModel.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/FlapModel.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.logistics.block; -import com.simibubi.create.foundation.render.backend.gl.attrib.VertexFormat; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import net.minecraft.client.renderer.BufferBuilder; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java index 81793455e..b238d2084 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java @@ -5,15 +5,15 @@ import java.util.Collection; import java.util.EnumMap; import java.util.Map; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.logistics.block.FlapData; import com.simibubi.create.foundation.gui.widgets.InterpolatedValue; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java index 49252ec37..14f7a8ceb 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.logistics.block.belts.tunnel; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java index 6527280b9..a039b6c7f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java @@ -9,14 +9,14 @@ import java.util.Set; import org.apache.commons.lang3.tuple.Pair; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape; import com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock; import com.simibubi.create.content.logistics.packet.TunnelFlapPacket; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.networking.AllPackets; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Iterate; @@ -44,7 +44,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe public Map flaps; public Set sides; - + protected LazyOptional cap = LazyOptional.empty(); protected List> flapsToSend; @@ -67,12 +67,12 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe for (Direction direction : flaps.keySet()) flapsNBT.add(IntNBT.of(direction.getIndex())); compound.put("Flaps", flapsNBT); - + ListNBT sidesNBT = new ListNBT(); for (Direction direction : sides) sidesNBT.add(IntNBT.of(direction.getIndex())); compound.put("Sides", sidesNBT); - + super.write(compound, clientPacket); } @@ -83,7 +83,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe for (INBT inbt : flapsNBT) if (inbt instanceof IntNBT) newFlaps.add(Direction.byIndex(((IntNBT) inbt).getInt())); - + sides.clear(); ListNBT sidesNBT = compound.getList("Sides", NBT.TAG_INT); for (INBT inbt : sidesNBT) @@ -97,7 +97,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe flaps.put(d, new InterpolatedChasingValue().start(.25f) .target(0) .withSpeed(.05f)); - + // Backwards compat if (!compound.contains("Sides") && compound.contains("Flaps")) sides.addAll(flaps.keySet()); @@ -122,9 +122,9 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe if (!positive && shape == Shape.T_RIGHT) continue; } - + sides.add(direction); - + // Flap might be occluded BlockState nextState = world.getBlockState(pos.offset(direction)); if (nextState.getBlock() instanceof BeltTunnelBlock) @@ -179,7 +179,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe public boolean shouldRenderAsTE() { return true; } - + @Override public void addBehaviours(List behaviours) {} diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java index ad44cb651..53b1db9ab 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.logistics.block.depot; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java index ddb028c7a..3b993fe6b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.logistics.block.depot; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -7,7 +8,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java index 4bef959ea..2c27676d0 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.logistics.block.diodes; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.ITickableInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.ITickableInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterTileEntity.java index 363daea76..c678c6085 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterTileEntity.java @@ -5,7 +5,7 @@ import static net.minecraft.block.RedstoneDiodeBlock.POWERED; import java.util.List; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; @@ -36,10 +36,10 @@ public class AdjustableRepeaterTileEntity extends SmartTileEntity implements IIn maxState.withFormatter(this::format); maxState.withUnit(this::getUnit); maxState.withCallback(this::onMaxDelayChanged); - + behaviours.add(maxState); } - + private void onMaxDelayChanged(int newMax) { state = MathHelper.clamp(state, 0, newMax); sendData(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java index 16090ddbd..4c378f3d7 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java @@ -2,15 +2,15 @@ package com.simibubi.create.content.logistics.block.funnel; import java.util.ArrayList; +import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.logistics.block.FlapData; -import com.simibubi.create.foundation.render.backend.core.PartialModel; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java index 87d762e51..735749775 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.logistics.block.funnel; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java index 02464be74..ddf7fd424 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java @@ -3,6 +3,8 @@ package com.simibubi.create.content.logistics.block.funnel; import java.lang.ref.WeakReference; import java.util.List; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.content.contraptions.goggles.IHaveHoveringInformation; @@ -14,8 +16,6 @@ import com.simibubi.create.content.logistics.packet.FunnelFlapPacket; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.networking.AllPackets; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java index 941b35260..a33af9b12 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java @@ -3,16 +3,16 @@ package com.simibubi.create.content.logistics.block.mechanicalArm; import java.util.ArrayList; import com.google.common.collect.Lists; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstanceData; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstanceData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java index 84baeee39..bb8f4e297 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java @@ -7,6 +7,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.mutable.MutableBoolean; import com.google.common.collect.ImmutableMap; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; @@ -27,7 +28,6 @@ import com.simibubi.create.content.logistics.block.funnel.FunnelBlock; import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.item.SmartInventory; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java index 2a9a72ac3..82294a44f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.logistics.block.mechanicalArm; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -8,7 +9,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity.Phase; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java index 416766dcf..8c2aaacac 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java @@ -1,13 +1,13 @@ package com.simibubi.create.content.logistics.block.redstone; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; +import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; -import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.ColorHelper; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java index 329760ede..991560762 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.logistics.block.redstone; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.ColorHelper; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverTileEntity.java index 2862ad0fe..624d2e8f5 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverTileEntity.java @@ -2,9 +2,9 @@ package com.simibubi.create.content.logistics.block.redstone; import java.util.List; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.Lang; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java index b91ca03a0..a64f62969 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java @@ -1,13 +1,13 @@ package com.simibubi.create.content.schematics.block; +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; +import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; -import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java index 6ac93df76..01e690db8 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.schematics.block; import java.util.Random; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -9,7 +10,6 @@ import com.simibubi.create.content.schematics.block.LaunchedItem.ForBlockState; import com.simibubi.create.content.schematics.block.LaunchedItem.ForEntity; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index 8a06c2464..d7f6f57d4 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -7,6 +7,7 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; @@ -25,7 +26,6 @@ import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.CSchematics; import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.BlockHelper; diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 0aa7c9131..7d0528748 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -3,6 +3,8 @@ package com.simibubi.create.events; import java.util.ArrayList; import java.util.List; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.RenderWork; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllFluids; @@ -35,8 +37,6 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.LeftClickPacket; import com.simibubi.create.foundation.ponder.PonderTooltipHandler; import com.simibubi.create.foundation.render.KineticRenderer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.RenderWork; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.sound.SoundScapes; import com.simibubi.create.foundation.tileEntity.behaviour.edgeInteraction.EdgeInteractionRenderer; @@ -90,7 +90,7 @@ public class ClientEvents { World world = Minecraft.getInstance().world; if (!isGameActive()) return; - + if (event.phase == Phase.START) { AirCurrent.tickClientPlayerSounds(); return; diff --git a/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigPacket.java b/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigPacket.java index 28339f5c0..7681c1094 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/foundation/command/ConfigureConfigPacket.java @@ -5,6 +5,8 @@ import java.util.function.Supplier; import org.apache.logging.log4j.LogManager; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.OptifineHandler; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.goggles.GoggleConfigScreen; import com.simibubi.create.foundation.config.AllConfigs; @@ -13,8 +15,6 @@ import com.simibubi.create.foundation.networking.SimplePacketBase; import com.simibubi.create.foundation.ponder.PonderRegistry; import com.simibubi.create.foundation.ponder.PonderUI; import com.simibubi.create.foundation.ponder.content.PonderIndexScreen; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.OptifineHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateTileEntityBuilder.java b/src/main/java/com/simibubi/create/foundation/data/CreateTileEntityBuilder.java index 64286f525..0a9530d23 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateTileEntityBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateTileEntityBuilder.java @@ -2,8 +2,8 @@ package com.simibubi.create.foundation.data; import javax.annotation.Nullable; -import com.simibubi.create.foundation.render.backend.instancing.IRendererFactory; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry; +import com.jozufozu.flywheel.backend.instancing.IRendererFactory; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderRegistry; import com.tterrag.registrate.AbstractRegistrate; import com.tterrag.registrate.builders.BuilderCallback; import com.tterrag.registrate.builders.TileEntityBuilder; diff --git a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java index 385f1a019..cab7b57df 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java @@ -2,6 +2,7 @@ package com.simibubi.create.foundation.gui; import javax.annotation.Nullable; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager.DestFactor; @@ -9,7 +10,6 @@ import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.foundation.fluid.FluidRenderer; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VirtualEmptyModelData; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/CancelTileEntityRenderMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/CancelTileEntityRenderMixin.java index 79994972e..f409c43a0 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/CancelTileEntityRenderMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/CancelTileEntityRenderMixin.java @@ -7,8 +7,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/FogColorTrackerMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/FogColorTrackerMixin.java index d4cb97910..d3e69ecf1 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/FogColorTrackerMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/FogColorTrackerMixin.java @@ -6,8 +6,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.jozufozu.flywheel.backend.gl.GlFog; import com.mojang.blaze3d.platform.GlStateManager; -import com.simibubi.create.foundation.render.backend.gl.GlFog; @Mixin(GlStateManager.class) public class FogColorTrackerMixin { diff --git a/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java index 440a3f68b..4b8e08f41 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java @@ -7,8 +7,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.jozufozu.flywheel.backend.light.LightUpdater; import com.simibubi.create.CreateClient; -import com.simibubi.create.foundation.render.backend.light.LightUpdater; import net.minecraft.client.multiplayer.ClientChunkProvider; import net.minecraft.client.world.ClientWorld; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java index 06ddf0c30..effe19da5 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java @@ -5,9 +5,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.jozufozu.flywheel.backend.RenderWork; +import com.jozufozu.flywheel.backend.light.LightUpdater; import com.simibubi.create.CreateClient; -import com.simibubi.create.foundation.render.backend.RenderWork; -import com.simibubi.create.foundation.render.backend.light.LightUpdater; import net.minecraft.client.Minecraft; import net.minecraft.client.network.play.ClientPlayNetHandler; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index d140a4bef..3ac8541a1 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -7,14 +7,14 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.OptifineHandler; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.KineticRenderer; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; -import com.simibubi.create.foundation.render.backend.OptifineHandler; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.ActiveRenderInfo; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/ShaderCloseMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/ShaderCloseMixin.java index d779d6582..8da970608 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/ShaderCloseMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/ShaderCloseMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.simibubi.create.foundation.render.backend.OptifineHandler; +import com.jozufozu.flywheel.backend.OptifineHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java index 0fe562376..822e05bd8 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java @@ -9,9 +9,9 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.effects.EffectsHandler; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.render.backend.Backend; -import com.simibubi.create.foundation.render.backend.effects.EffectsHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index df7bfb5b6..54836972d 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -1,7 +1,17 @@ package com.simibubi.create.foundation.render; -import static com.simibubi.create.foundation.render.backend.Backend.register; +import static com.jozufozu.flywheel.backend.Backend.register; +import com.jozufozu.flywheel.backend.core.BasicAttributes; +import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.core.ModelAttributes; +import com.jozufozu.flywheel.backend.core.OrientedAttributes; +import com.jozufozu.flywheel.backend.core.TransformAttributes; +import com.jozufozu.flywheel.backend.effects.SphereFilterProgram; +import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; +import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; +import com.jozufozu.flywheel.backend.gl.shader.SingleProgram; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.KineticAttributes; import com.simibubi.create.content.contraptions.base.RotatingAttributes; @@ -10,16 +20,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram; import com.simibubi.create.content.contraptions.relays.belt.BeltAttributes; import com.simibubi.create.content.logistics.block.FlapAttributes; -import com.simibubi.create.foundation.render.backend.core.BasicAttributes; -import com.simibubi.create.foundation.render.backend.core.BasicProgram; -import com.simibubi.create.foundation.render.backend.core.ModelAttributes; -import com.simibubi.create.foundation.render.backend.core.OrientedAttributes; -import com.simibubi.create.foundation.render.backend.core.TransformAttributes; -import com.simibubi.create.foundation.render.backend.effects.SphereFilterProgram; -import com.simibubi.create.foundation.render.backend.gl.shader.FogSensitiveProgram; -import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; -import com.simibubi.create.foundation.render.backend.gl.shader.ShaderConstants; -import com.simibubi.create.foundation.render.backend.gl.shader.SingleProgram; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/foundation/render/Compartment.java b/src/main/java/com/simibubi/create/foundation/render/Compartment.java index 01087fc22..8c7e45338 100644 --- a/src/main/java/com/simibubi/create/foundation/render/Compartment.java +++ b/src/main/java/com/simibubi/create/foundation/render/Compartment.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.render; import org.apache.commons.lang3.tuple.Pair; -import com.simibubi.create.foundation.render.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.PartialModel; import net.minecraft.block.BlockState; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java b/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java index d6dd5bb80..510641f19 100644 --- a/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java @@ -2,17 +2,17 @@ package com.simibubi.create.foundation.render; import java.util.ArrayList; +import com.jozufozu.flywheel.backend.MaterialTypes; +import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.core.OrientedModel; +import com.jozufozu.flywheel.backend.core.TransformedModel; +import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.contraptions.base.RotatingModel; import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; import com.simibubi.create.content.logistics.block.FlapModel; -import com.simibubi.create.foundation.render.backend.MaterialTypes; -import com.simibubi.create.foundation.render.backend.core.BasicProgram; -import com.simibubi.create.foundation.render.backend.core.OrientedModel; -import com.simibubi.create.foundation.render.backend.core.TransformedModel; -import com.simibubi.create.foundation.render.backend.gl.shader.ShaderCallback; -import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.RenderType; diff --git a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java index 4ed176c64..1c143cb0c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java +++ b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java @@ -4,9 +4,9 @@ import static net.minecraft.state.properties.BlockStateProperties.FACING; import java.util.function.Supplier; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.CreateClient; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.MatrixStacker; diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java index f5f7d7559..d0208773c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java @@ -11,8 +11,8 @@ import org.lwjgl.opengl.GL11; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.VirtualEmptyModelData; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/MaterialTypes.java b/src/main/java/com/simibubi/create/foundation/render/backend/MaterialTypes.java deleted file mode 100644 index e524b295c..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/backend/MaterialTypes.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.simibubi.create.foundation.render.backend; - -import com.simibubi.create.foundation.render.backend.core.ModelData; -import com.simibubi.create.foundation.render.backend.core.OrientedData; -import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; - -public class MaterialTypes { - public static final MaterialType> TRANSFORMED = new MaterialType<>(); - public static final MaterialType> ORIENTED = new MaterialType<>(); -} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderSpecLoader.java b/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderSpecLoader.java deleted file mode 100644 index 3747a572c..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ShaderSpecLoader.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.simibubi.create.foundation.render.backend.gl.shader; - -import com.simibubi.create.foundation.render.backend.ShaderLoader; - -public interface ShaderSpecLoader

{ - IMultiProgram

create(ShaderLoader loader, ProgramSpec

spec); -} diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java index c7b6ac979..e64b8fcda 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java @@ -1,8 +1,8 @@ package com.simibubi.create.foundation.tileEntity.renderer; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java index ac5fdae65..ae127670b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java @@ -5,7 +5,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.function.Predicate; -import com.simibubi.create.foundation.render.backend.instancing.IFlywheelWorld; +import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; From 2112061db016930edc9e3a1c302d93c5833bfefa Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sat, 1 May 2021 23:39:36 -0700 Subject: [PATCH 019/198] Vertex shader abstractions --- .../core/BasicInstancedTileRenderer.java | 72 +++++++++++++++++++ .../flywheel/backend/gl/shader/GlShader.java | 2 +- .../foundation/render/KineticRenderer.java | 72 ++----------------- .../assets/create/flywheel/shaders/belt.vert | 27 +++---- .../shaders/contraption/finalize.glsl | 20 ++++++ .../assets/create/flywheel/shaders/flap.vert | 27 +++---- .../assets/create/flywheel/shaders/model.vert | 30 +++----- .../create/flywheel/shaders/oriented.vert | 29 +++----- .../create/flywheel/shaders/rotating.vert | 29 +++----- .../create/flywheel/shaders/std/finalize.glsl | 10 +++ 10 files changed, 152 insertions(+), 166 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java create mode 100644 src/main/resources/assets/create/flywheel/shaders/contraption/finalize.glsl create mode 100644 src/main/resources/assets/create/flywheel/shaders/std/finalize.glsl diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java new file mode 100644 index 000000000..dcdf7d317 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java @@ -0,0 +1,72 @@ +package com.jozufozu.flywheel.backend.core; + +import java.util.ArrayList; + +import com.jozufozu.flywheel.backend.MaterialTypes; +import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; +import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.instancing.RenderMaterial; +import com.simibubi.create.foundation.render.AllProgramSpecs; + +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.vector.Matrix4f; + +public class BasicInstancedTileRenderer extends InstancedTileRenderer { + public static int MAX_ORIGIN_DISTANCE = 100; + + public BlockPos originCoordinate = BlockPos.ZERO; + + @Override + public void registerMaterials() { + materials.put(MaterialTypes.TRANSFORMED, + new RenderMaterial<>(this, AllProgramSpecs.MODEL, TransformedModel::new)); + materials.put(MaterialTypes.ORIENTED, new RenderMaterial<>(this, AllProgramSpecs.ORIENTED, OrientedModel::new)); + } + + @Override + public BlockPos getOriginCoordinate() { + return originCoordinate; + } + + @Override + public void beginFrame(ActiveRenderInfo info, double cameraX, double cameraY, double cameraZ) { + int cX = MathHelper.floor(cameraX); + int cY = MathHelper.floor(cameraY); + int cZ = MathHelper.floor(cameraZ); + + int dX = Math.abs(cX - originCoordinate.getX()); + int dY = Math.abs(cY - originCoordinate.getY()); + int dZ = Math.abs(cZ - originCoordinate.getZ()); + + if (dX > MAX_ORIGIN_DISTANCE || dY > MAX_ORIGIN_DISTANCE || dZ > MAX_ORIGIN_DISTANCE) { + + originCoordinate = new BlockPos(cX, cY, cZ); + + ArrayList instancedTiles = new ArrayList<>(instances.keySet()); + invalidate(); + instancedTiles.forEach(this::add); + } + + super.beginFrame(info, cameraX, cameraY, cameraZ); + } + + @Override + public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, + ShaderCallback callback) { + BlockPos originCoordinate = getOriginCoordinate(); + + camX -= originCoordinate.getX(); + camY -= originCoordinate.getY(); + camZ -= originCoordinate.getZ(); + + Matrix4f translate = Matrix4f.translate((float) -camX, (float) -camY, (float) -camZ); + + translate.multiplyBackward(viewProjection); + + super.render(layer, translate, camX, camY, camZ, callback); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlShader.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlShader.java index 6b1cd8cca..80c2270c0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlShader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlShader.java @@ -28,7 +28,7 @@ public class GlShader extends GlObject { } if (GL20.glGetShaderi(handle, GL20.GL_COMPILE_STATUS) != GL20.GL_TRUE) { - throw new RuntimeException("Could not compile shader. See log for details."); + throw new RuntimeException("Could not compile " + name + ". See log for details."); } setHandle(handle); diff --git a/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java b/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java index 510641f19..93cc288bd 100644 --- a/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java @@ -1,84 +1,22 @@ package com.simibubi.create.foundation.render; -import java.util.ArrayList; - -import com.jozufozu.flywheel.backend.MaterialTypes; -import com.jozufozu.flywheel.backend.core.BasicProgram; -import com.jozufozu.flywheel.backend.core.OrientedModel; -import com.jozufozu.flywheel.backend.core.TransformedModel; -import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; -import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; +import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.contraptions.base.RotatingModel; import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; import com.simibubi.create.content.logistics.block.FlapModel; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix4f; - -public class KineticRenderer extends InstancedTileRenderer { - public static int MAX_ORIGIN_DISTANCE = 100; - - public BlockPos originCoordinate = BlockPos.ZERO; +public class KineticRenderer extends BasicInstancedTileRenderer { @Override public void registerMaterials() { - materials.put(MaterialTypes.TRANSFORMED, - new RenderMaterial<>(this, AllProgramSpecs.MODEL, TransformedModel::new)); - materials.put(MaterialTypes.ORIENTED, new RenderMaterial<>(this, AllProgramSpecs.ORIENTED, OrientedModel::new)); + super.registerMaterials(); materials.put(KineticRenderMaterials.BELTS, - new RenderMaterial<>(this, AllProgramSpecs.BELT, BeltInstancedModel::new)); + new RenderMaterial<>(this, AllProgramSpecs.BELT, BeltInstancedModel::new)); materials.put(KineticRenderMaterials.ROTATING, - new RenderMaterial<>(this, AllProgramSpecs.ROTATING, RotatingModel::new)); + new RenderMaterial<>(this, AllProgramSpecs.ROTATING, RotatingModel::new)); materials.put(KineticRenderMaterials.FLAPS, new RenderMaterial<>(this, AllProgramSpecs.FLAPS, FlapModel::new)); } - - @Override - public BlockPos getOriginCoordinate() { - return originCoordinate; - } - - @Override - public void beginFrame(ActiveRenderInfo info, double cameraX, double cameraY, double cameraZ) { - int cX = MathHelper.floor(cameraX); - int cY = MathHelper.floor(cameraY); - int cZ = MathHelper.floor(cameraZ); - - int dX = Math.abs(cX - originCoordinate.getX()); - int dY = Math.abs(cY - originCoordinate.getY()); - int dZ = Math.abs(cZ - originCoordinate.getZ()); - - if (dX > MAX_ORIGIN_DISTANCE || dY > MAX_ORIGIN_DISTANCE || dZ > MAX_ORIGIN_DISTANCE) { - - originCoordinate = new BlockPos(cX, cY, cZ); - - ArrayList instancedTiles = new ArrayList<>(instances.keySet()); - invalidate(); - instancedTiles.forEach(this::add); - } - - super.beginFrame(info, cameraX, cameraY, cameraZ); - } - - @Override - public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, - ShaderCallback callback) { - BlockPos originCoordinate = getOriginCoordinate(); - - camX -= originCoordinate.getX(); - camY -= originCoordinate.getY(); - camZ -= originCoordinate.getZ(); - - Matrix4f translate = Matrix4f.translate((float) -camX, (float) -camY, (float) -camZ); - - translate.multiplyBackward(viewProjection); - - super.render(layer, translate, camX, camY, camZ, callback); - } } diff --git a/src/main/resources/assets/create/flywheel/shaders/belt.vert b/src/main/resources/assets/create/flywheel/shaders/belt.vert index 3a5fefcec..b0f066140 100644 --- a/src/main/resources/assets/create/flywheel/shaders/belt.vert +++ b/src/main/resources/assets/create/flywheel/shaders/belt.vert @@ -24,14 +24,6 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -#if defined(CONTRAPTION) -varying vec3 BoxCoord; - -uniform vec3 uLightBoxSize; -uniform vec3 uLightBoxMin; -uniform mat4 uModel; -#endif - uniform float uTime; uniform mat4 uViewProjection; uniform int uDebug; @@ -42,6 +34,12 @@ uniform vec3 uCameraPos; varying float FragDistance; #endif +#ifdef CONTRAPTION +#flwinclude <"create:contraption/finalize.glsl"> +#else +#flwinclude <"create:std/finalize.glsl"> +#endif + void main() { vec3 rotated = rotateVertexByQuat(aPos - .5, aInstanceRot) + aInstancePos + .5; @@ -49,17 +47,8 @@ void main() { vec3 norm = rotateVertexByQuat(aNormal, aInstanceRot); -#ifdef CONTRAPTION - worldPos = uModel * worldPos; - norm = normalize(modelToNormal(uModel) * norm); - - BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; - #if defined(USE_FOG) - FragDistance = length(worldPos.xyz); - #endif -#elif defined(USE_FOG) - FragDistance = length(worldPos.xyz - uCameraPos); -#endif + FLWFinalizeWorldPos(worldPos); + FLWFinalizeNormal(norm); float scrollSize = aScrollTexture.w - aScrollTexture.y; float scroll = fract(aSpeed * uTime / (31.5 * 16.) + aOffset) * scrollSize * aScrollMult; diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/finalize.glsl b/src/main/resources/assets/create/flywheel/shaders/contraption/finalize.glsl new file mode 100644 index 000000000..ed55cc3a9 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/contraption/finalize.glsl @@ -0,0 +1,20 @@ +varying vec3 BoxCoord; + +uniform vec3 uLightBoxSize; +uniform vec3 uLightBoxMin; +uniform mat4 uModel; + +void FLWFinalizeWorldPos(inout vec4 worldPos) { + worldPos = uModel * worldPos; + + BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; + #if defined(USE_FOG) + + FragDistance = length(worldPos.xyz); + #endif +} + +void FLWFinalizeNormal(inout vec3 normal) { + normal = modelToNormal(uModel) * normal; +} + diff --git a/src/main/resources/assets/create/flywheel/shaders/flap.vert b/src/main/resources/assets/create/flywheel/shaders/flap.vert index 496051288..bd877cc48 100644 --- a/src/main/resources/assets/create/flywheel/shaders/flap.vert +++ b/src/main/resources/assets/create/flywheel/shaders/flap.vert @@ -26,14 +26,6 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -#if defined(CONTRAPTION) -varying vec3 BoxCoord; - -uniform vec3 uLightBoxSize; -uniform vec3 uLightBoxMin; -uniform mat4 uModel; -#endif - uniform float uTime; uniform mat4 uViewProjection; uniform int uDebug; @@ -44,6 +36,12 @@ uniform vec3 uCameraPos; varying float FragDistance; #endif +#ifdef CONTRAPTION +#flwinclude <"create:contraption/finalize.glsl"> +#else +#flwinclude <"create:std/finalize.glsl"> +#endif + float toRad(float degrees) { return fract(degrees / 360.) * PI * 2.; } @@ -73,17 +71,8 @@ void main() { vec4 worldPos = vec4(rotated, 1.); vec3 norm = rotateVertexByQuat(rotateVertexByQuat(aNormal, flapRotation), orientation); - #ifdef CONTRAPTION - worldPos = uModel * worldPos; - norm = modelToNormal(uModel) * norm; - - BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; - #if defined(USE_FOG) - FragDistance = length(worldPos.xyz); - #endif - #elif defined(USE_FOG) - FragDistance = length(worldPos.xyz - uCameraPos); - #endif + FLWFinalizeWorldPos(worldPos); + FLWFinalizeNormal(norm); Diffuse = diffuse(norm); TexCoords = aTexCoords; diff --git a/src/main/resources/assets/create/flywheel/shaders/model.vert b/src/main/resources/assets/create/flywheel/shaders/model.vert index ea4503b75..c6a146695 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model.vert +++ b/src/main/resources/assets/create/flywheel/shaders/model.vert @@ -17,14 +17,6 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -#if defined(CONTRAPTION) -varying vec3 BoxCoord; - -uniform vec3 uLightBoxSize; -uniform vec3 uLightBoxMin; -uniform mat4 uModel; -#endif - uniform float uTime; uniform mat4 uViewProjection; uniform int uDebug; @@ -35,22 +27,20 @@ uniform vec3 uCameraPos; varying float FragDistance; #endif +#ifdef CONTRAPTION +#flwinclude <"create:contraption/finalize.glsl"> +#else +#flwinclude <"create:std/finalize.glsl"> +#endif + + void main() { vec4 worldPos = aTransform * vec4(aPos, 1.); vec3 norm = aNormalMat * aNormal; -#ifdef CONTRAPTION - worldPos = uModel * worldPos; - norm = modelToNormal(uModel) * norm; - - BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; - #if defined(USE_FOG) - FragDistance = length(worldPos.xyz); - #endif -#elif defined(USE_FOG) - FragDistance = length(worldPos.xyz - uCameraPos); -#endif + FLWFinalizeNormal(norm); + FLWFinalizeWorldPos(worldPos); norm = normalize(norm); @@ -60,4 +50,4 @@ void main() { gl_Position = uViewProjection * worldPos; Color = aColor; -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/flywheel/shaders/oriented.vert b/src/main/resources/assets/create/flywheel/shaders/oriented.vert index d32feca3b..79d76cfe9 100644 --- a/src/main/resources/assets/create/flywheel/shaders/oriented.vert +++ b/src/main/resources/assets/create/flywheel/shaders/oriented.vert @@ -19,14 +19,6 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -#if defined(CONTRAPTION) -varying vec3 BoxCoord; - -uniform vec3 uLightBoxSize; -uniform vec3 uLightBoxMin; -uniform mat4 uModel; -#endif - uniform float uTime; uniform mat4 uViewProjection; uniform int uDebug; @@ -37,22 +29,19 @@ uniform vec3 uCameraPos; varying float FragDistance; #endif +#ifdef CONTRAPTION +#flwinclude <"create:contraption/finalize.glsl"> +#else +#flwinclude <"create:std/finalize.glsl"> +#endif + void main() { vec4 worldPos = vec4(rotateVertexByQuat(aPos - aPivot, aRotation) + aPivot + aInstancePos, 1.); vec3 norm = rotateVertexByQuat(aNormal, aRotation); -#ifdef CONTRAPTION - worldPos = uModel * worldPos; - norm = normalize(modelToNormal(uModel) * norm); - - BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; - #if defined(USE_FOG) - FragDistance = length(worldPos.xyz); - #endif -#elif defined(USE_FOG) - FragDistance = length(worldPos.xyz - uCameraPos); -#endif + FLWFinalizeWorldPos(worldPos); + FLWFinalizeNormal(norm); Diffuse = diffuse(norm); TexCoords = aTexCoords; @@ -60,4 +49,4 @@ void main() { gl_Position = uViewProjection * worldPos; Color = aColor; -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/shaders/rotating.vert index 091e16faa..e428b7049 100644 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ b/src/main/resources/assets/create/flywheel/shaders/rotating.vert @@ -21,14 +21,6 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -#if defined(CONTRAPTION) -varying vec3 BoxCoord; - -uniform vec3 uLightBoxSize; -uniform vec3 uLightBoxMin; -uniform mat4 uModel; -#endif - uniform float uTime; uniform mat4 uViewProjection; uniform int uDebug; @@ -39,6 +31,12 @@ uniform vec3 uCameraPos; varying float FragDistance; #endif +#ifdef CONTRAPTION +#flwinclude <"create:contraption/finalize.glsl"> +#else +#flwinclude <"create:std/finalize.glsl"> +#endif + mat4 kineticRotation() { float degrees = aOffset + uTime * aSpeed * 3./10.; float angle = fract(degrees / 360.) * PI * 2.; @@ -52,17 +50,8 @@ void main() { vec3 norm = modelToNormal(kineticRotation) * aNormal; - #ifdef CONTRAPTION - worldPos = uModel * worldPos; - norm = normalize(modelToNormal(uModel) * norm); - - BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; - #if defined(USE_FOG) - FragDistance = length(worldPos.xyz); - #endif - #elif defined(USE_FOG) - FragDistance = length(worldPos.xyz - uCameraPos); - #endif + FLWFinalizeWorldPos(worldPos); + FLWFinalizeNormal(norm); Diffuse = diffuse(norm); TexCoords = aTexCoords; @@ -84,4 +73,4 @@ void main() { Color = vec4(1.); } #endif -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/flywheel/shaders/std/finalize.glsl b/src/main/resources/assets/create/flywheel/shaders/std/finalize.glsl new file mode 100644 index 000000000..e3f3180bf --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/std/finalize.glsl @@ -0,0 +1,10 @@ +void FLWFinalizeWorldPos(inout vec4 worldPos) { + #if defined(USE_FOG) + + FragDistance = length(worldPos.xyz - uCameraPos); + #endif +} + +void FLWFinalizeNormal(inout vec3 normal) { + // noop +} From 35768b5ade501a6e17c45e7c4f6f182b8085e215 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sun, 2 May 2021 14:10:38 -0700 Subject: [PATCH 020/198] Step towards arbitrary shader contexts --- .../flywheel/backend/ShaderLoader.java | 8 +++ .../foundation/render/AllProgramSpecs.java | 34 ++++++------ .../assets/create/flywheel/shaders/belt.vert | 4 +- .../shaders/{model.frag => block.frag} | 17 +++--- .../create/flywheel/shaders/contraption.frag | 54 ------------------- .../flywheel/shaders/contraption/builtin.frag | 7 +++ .../{finalize.glsl => builtin.vert} | 0 .../assets/create/flywheel/shaders/flap.vert | 4 +- .../assets/create/flywheel/shaders/model.vert | 4 +- .../create/flywheel/shaders/oriented.vert | 4 +- .../create/flywheel/shaders/rotating.vert | 4 +- .../create/flywheel/shaders/std/builtin.frag | 4 ++ .../std/{finalize.glsl => builtin.vert} | 0 13 files changed, 56 insertions(+), 88 deletions(-) rename src/main/resources/assets/create/flywheel/shaders/{model.frag => block.frag} (74%) delete mode 100644 src/main/resources/assets/create/flywheel/shaders/contraption.frag create mode 100644 src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag rename src/main/resources/assets/create/flywheel/shaders/contraption/{finalize.glsl => builtin.vert} (100%) create mode 100644 src/main/resources/assets/create/flywheel/shaders/std/builtin.frag rename src/main/resources/assets/create/flywheel/shaders/std/{finalize.glsl => builtin.vert} (100%) diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index abd224f1a..de256a9a4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -46,6 +46,7 @@ public class ShaderLoader { // #flwinclude <"valid_namespace:valid/path_to_file.glsl"> private static final Pattern includePattern = Pattern.compile("#flwinclude <\"([\\w\\d_]+:[\\w\\d_./]+)\">"); + private static boolean debugDumpFile = false; final Map shaderSource = new HashMap<>(); @@ -162,6 +163,13 @@ public class ShaderLoader { if (defines != null) source = defines.process(source); + if (debugDumpFile) { + Backend.log.debug("Finished processing '" + name + "':"); + int i = 1; + for (String s : source.split("\n")) { + Backend.log.debug(String.format("%1$4s: ", i++) + s); + } + } return new GlShader(type, name, source); } diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index 54836972d..72fc21f90 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -41,7 +41,7 @@ public class AllProgramSpecs { .addAttributes(BasicAttributes.class) .addAttributes(TransformAttributes.class) .setVert(Locations.MODEL_VERT) - .setFrag(Locations.MODEL_FRAG) + .setFrag(Locations.BLOCK) .createProgramSpec()); public static final ProgramSpec ORIENTED = register(ProgramSpec.builder("oriented", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) @@ -49,7 +49,7 @@ public class AllProgramSpecs { .addAttributes(BasicAttributes.class) .addAttributes(OrientedAttributes.class) .setVert(Locations.ORIENTED) - .setFrag(Locations.MODEL_FRAG) + .setFrag(Locations.BLOCK) .createProgramSpec()); public static final ProgramSpec ROTATING = register(ProgramSpec.builder("rotating", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) @@ -58,7 +58,7 @@ public class AllProgramSpecs { .addAttributes(KineticAttributes.class) .addAttributes(RotatingAttributes.class) .setVert(Locations.ROTATING) - .setFrag(Locations.MODEL_FRAG) + .setFrag(Locations.BLOCK) .createProgramSpec()); public static final ProgramSpec BELT = register(ProgramSpec.builder("belt", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) @@ -67,26 +67,27 @@ public class AllProgramSpecs { .addAttributes(KineticAttributes.class) .addAttributes(BeltAttributes.class) .setVert(Locations.BELT) - .setFrag(Locations.MODEL_FRAG) + .setFrag(Locations.BLOCK) .createProgramSpec()); public static final ProgramSpec FLAPS = register(ProgramSpec.builder("flap", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(FlapAttributes.class) .setVert(Locations.FLAP) - .setFrag(Locations.MODEL_FRAG) + .setFrag(Locations.BLOCK) .createProgramSpec()); public static final ProgramSpec C_STRUCTURE = register(ProgramSpec.builder("contraption_structure", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ContraptionAttributes.class) .setVert(Locations.CONTRAPTION_STRUCTURE) - .setFrag(Locations.CONTRAPTION) + .setFrag(Locations.BLOCK) + .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); public static final ProgramSpec C_MODEL = register(ProgramSpec.builder("contraption_model", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(TransformAttributes.class) .setVert(Locations.MODEL_VERT) - .setFrag(Locations.CONTRAPTION) + .setFrag(Locations.BLOCK) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); public static final ProgramSpec C_ORIENTED = register(ProgramSpec.builder("contraption_oriented", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) @@ -94,7 +95,7 @@ public class AllProgramSpecs { .addAttributes(BasicAttributes.class) .addAttributes(OrientedAttributes.class) .setVert(Locations.ORIENTED) - .setFrag(Locations.CONTRAPTION) + .setFrag(Locations.BLOCK) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); public static final ProgramSpec C_ROTATING = register(ProgramSpec.builder("contraption_rotating", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) @@ -103,7 +104,7 @@ public class AllProgramSpecs { .addAttributes(KineticAttributes.class) .addAttributes(RotatingAttributes.class) .setVert(Locations.ROTATING) - .setFrag(Locations.CONTRAPTION) + .setFrag(Locations.BLOCK) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); public static final ProgramSpec C_BELT = register(ProgramSpec.builder("contraption_belt", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) @@ -112,31 +113,30 @@ public class AllProgramSpecs { .addAttributes(KineticAttributes.class) .addAttributes(BeltAttributes.class) .setVert(Locations.BELT) - .setFrag(Locations.CONTRAPTION) + .setFrag(Locations.BLOCK) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); public static final ProgramSpec C_FLAPS = register(ProgramSpec.builder("contraption_flap", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(FlapAttributes.class) .setVert(Locations.FLAP) - .setFrag(Locations.CONTRAPTION) + .setFrag(Locations.BLOCK) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); public static final ProgramSpec C_ACTOR = register(ProgramSpec.builder("contraption_actor", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) .addAttributes(ModelAttributes.class) .addAttributes(ActorVertexAttributes.class) .setVert(Locations.CONTRAPTION_ACTOR) - .setFrag(Locations.CONTRAPTION) + .setFrag(Locations.BLOCK) + .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); public static class Locations { - public static final ResourceLocation EFFECT_VERT = loc("area_effect.vert"); - public static final ResourceLocation EFFECT_FRAG = loc("area_effect.frag"); - public static final ResourceLocation MODEL_FRAG = loc("model.frag"); + public static final ResourceLocation BLOCK = loc("block.frag"); + public static final ResourceLocation MODEL_VERT = loc("model.vert"); public static final ResourceLocation ORIENTED = loc("oriented.vert"); - public static final ResourceLocation CONTRAPTION = loc("contraption.frag"); public static final ResourceLocation ROTATING = loc("rotating.vert"); public static final ResourceLocation BELT = loc("belt.vert"); @@ -144,6 +144,8 @@ public class AllProgramSpecs { public static final ResourceLocation CONTRAPTION_STRUCTURE = loc("contraption_structure.vert"); public static final ResourceLocation CONTRAPTION_ACTOR = loc("contraption_actor.vert"); + public static final ResourceLocation EFFECT_VERT = loc("area_effect.vert"); + public static final ResourceLocation EFFECT_FRAG = loc("area_effect.frag"); private static ResourceLocation loc(String name) { return new ResourceLocation(Create.ID, name); diff --git a/src/main/resources/assets/create/flywheel/shaders/belt.vert b/src/main/resources/assets/create/flywheel/shaders/belt.vert index b0f066140..6edba4c07 100644 --- a/src/main/resources/assets/create/flywheel/shaders/belt.vert +++ b/src/main/resources/assets/create/flywheel/shaders/belt.vert @@ -35,9 +35,9 @@ varying float FragDistance; #endif #ifdef CONTRAPTION -#flwinclude <"create:contraption/finalize.glsl"> +#flwinclude <"create:contraption/builtin.vert"> #else -#flwinclude <"create:std/finalize.glsl"> +#flwinclude <"create:std/builtin.vert"> #endif void main() { diff --git a/src/main/resources/assets/create/flywheel/shaders/model.frag b/src/main/resources/assets/create/flywheel/shaders/block.frag similarity index 74% rename from src/main/resources/assets/create/flywheel/shaders/model.frag rename to src/main/resources/assets/create/flywheel/shaders/block.frag index e8ffaa00c..0ad89defe 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model.frag +++ b/src/main/resources/assets/create/flywheel/shaders/block.frag @@ -28,19 +28,20 @@ float fogFactor() { float dist = FragDistance * uFogDensity; return 1. / exp2(dist * dist); } -#endif + #endif -vec4 light() { - vec2 lm = Light * 0.9375 + 0.03125; - return texture2D(uLightMap, lm); -} + #ifdef CONTRAPTION + #flwinclude <"create:contraption/builtin.frag"> + #else + #flwinclude <"create:std/builtin.frag"> + #endif void main() { vec4 tex = texture2D(uBlockAtlas, TexCoords); - vec4 color = vec4(tex.rgb * light().rgb * Diffuse, tex.a) * Color; + vec4 color = vec4(tex.rgb * FLWLight(Light, uLightMap).rgb * Diffuse, tex.a) * Color; -#if defined(USE_FOG) + #if defined(USE_FOG) float fog = clamp(fogFactor(), 0., 1.); gl_FragColor = mix(uFogColor, color, fog); @@ -48,4 +49,4 @@ void main() { #else gl_FragColor = color; #endif -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption.frag b/src/main/resources/assets/create/flywheel/shaders/contraption.frag deleted file mode 100644 index 9049221f1..000000000 --- a/src/main/resources/assets/create/flywheel/shaders/contraption.frag +++ /dev/null @@ -1,54 +0,0 @@ -#version 110 - -varying vec2 TexCoords; -varying vec4 Color; -varying float Diffuse; -varying vec2 Light; - -varying vec3 BoxCoord; - -uniform sampler2D uBlockAtlas; -uniform sampler2D uLightMap; -uniform sampler3D uLightVolume; - -#if defined(USE_FOG) -varying float FragDistance; -uniform vec4 uFogColor; -#endif - -#if defined(USE_FOG_LINEAR) -uniform vec2 uFogRange; - -float fogFactor() { - return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x); -} -#endif - -#ifdef USE_FOG_EXP2 -uniform float uFogDensity; - -float fogFactor() { - float dist = FragDistance * uFogDensity; - return 1. / exp2(dist * dist); -} -#endif - -vec4 light() { - vec2 lm = texture3D(uLightVolume, BoxCoord).rg * 0.9375 + 0.03125; - return texture2D(uLightMap, max(lm, Light)); -} - -void main() { - vec4 tex = texture2D(uBlockAtlas, TexCoords); - - vec4 color = vec4(tex.rgb * light().rgb * Diffuse * Color.rgb, tex.a); - -#if defined(USE_FOG) - float fog = clamp(fogFactor(), 0., 1.); - - gl_FragColor = mix(uFogColor, color, fog); - gl_FragColor.a = color.a; -#else - gl_FragColor = color; -#endif -} \ No newline at end of file diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag new file mode 100644 index 000000000..eb9014677 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag @@ -0,0 +1,7 @@ +varying vec3 BoxCoord; +uniform sampler3D uLightVolume; + +vec4 FLWLight(vec2 lightCoords, sampler2D lightMap) { + vec2 lm = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg); + return texture2D(lightMap, lm * 0.9375 + 0.03125); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/finalize.glsl b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/contraption/finalize.glsl rename to src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert diff --git a/src/main/resources/assets/create/flywheel/shaders/flap.vert b/src/main/resources/assets/create/flywheel/shaders/flap.vert index bd877cc48..037c603c2 100644 --- a/src/main/resources/assets/create/flywheel/shaders/flap.vert +++ b/src/main/resources/assets/create/flywheel/shaders/flap.vert @@ -37,9 +37,9 @@ varying float FragDistance; #endif #ifdef CONTRAPTION -#flwinclude <"create:contraption/finalize.glsl"> +#flwinclude <"create:contraption/builtin.vert"> #else -#flwinclude <"create:std/finalize.glsl"> +#flwinclude <"create:std/builtin.vert"> #endif float toRad(float degrees) { diff --git a/src/main/resources/assets/create/flywheel/shaders/model.vert b/src/main/resources/assets/create/flywheel/shaders/model.vert index c6a146695..e0a62efe7 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model.vert +++ b/src/main/resources/assets/create/flywheel/shaders/model.vert @@ -28,9 +28,9 @@ varying float FragDistance; #endif #ifdef CONTRAPTION -#flwinclude <"create:contraption/finalize.glsl"> +#flwinclude <"create:contraption/builtin.vert"> #else -#flwinclude <"create:std/finalize.glsl"> +#flwinclude <"create:std/builtin.vert"> #endif diff --git a/src/main/resources/assets/create/flywheel/shaders/oriented.vert b/src/main/resources/assets/create/flywheel/shaders/oriented.vert index 79d76cfe9..e88371820 100644 --- a/src/main/resources/assets/create/flywheel/shaders/oriented.vert +++ b/src/main/resources/assets/create/flywheel/shaders/oriented.vert @@ -30,9 +30,9 @@ varying float FragDistance; #endif #ifdef CONTRAPTION -#flwinclude <"create:contraption/finalize.glsl"> +#flwinclude <"create:contraption/builtin.vert"> #else -#flwinclude <"create:std/finalize.glsl"> +#flwinclude <"create:std/builtin.vert"> #endif void main() { diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/shaders/rotating.vert index e428b7049..d2eaeb63b 100644 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ b/src/main/resources/assets/create/flywheel/shaders/rotating.vert @@ -32,9 +32,9 @@ varying float FragDistance; #endif #ifdef CONTRAPTION -#flwinclude <"create:contraption/finalize.glsl"> +#flwinclude <"create:contraption/builtin.vert"> #else -#flwinclude <"create:std/finalize.glsl"> +#flwinclude <"create:std/builtin.vert"> #endif mat4 kineticRotation() { diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag new file mode 100644 index 000000000..d133154cf --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag @@ -0,0 +1,4 @@ +vec4 FLWLight(vec2 lightCoords, sampler2D lightMap) { + vec2 lm = lightCoords * 0.9375 + 0.03125; + return texture2D(lightMap, lm); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/std/finalize.glsl b/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/std/finalize.glsl rename to src/main/resources/assets/create/flywheel/shaders/std/builtin.vert From fcbab5b820bba5303c85382632e366c1fae4167e Mon Sep 17 00:00:00 2001 From: JozsefA Date: Mon, 3 May 2021 13:42:23 -0700 Subject: [PATCH 021/198] #flwbuiltins and oh so much less overhead - Put a lot of the reusable code in a sort of standard library - Need to evaluate just how much should be lumped in there - Still need to allow for users to create alternate contexts for the builtins - Normal world and contraptions are still hardcoded contexts --- .../flywheel/backend/ShaderLoader.java | 76 ++++++++++++++----- .../flywheel/backend/gl/shader/GlProgram.java | 8 +- .../assets/create/flywheel/shaders/belt.vert | 13 +--- .../assets/create/flywheel/shaders/block.frag | 37 +-------- .../flywheel/shaders/contraption/builtin.frag | 10 +++ .../flywheel/shaders/contraption/builtin.vert | 14 +++- .../flywheel/shaders/contraption_actor.vert | 3 +- .../flywheel/shaders/core/matutils.glsl | 15 +--- .../assets/create/flywheel/shaders/flap.vert | 13 +--- .../assets/create/flywheel/shaders/model.vert | 14 +--- .../create/flywheel/shaders/oriented.vert | 13 +--- .../create/flywheel/shaders/rotating.vert | 13 +--- .../create/flywheel/shaders/std/builtin.frag | 17 +++++ .../create/flywheel/shaders/std/builtin.vert | 14 +++- .../create/flywheel/shaders/std/fog.glsl | 23 ++++++ 15 files changed, 144 insertions(+), 139 deletions(-) create mode 100644 src/main/resources/assets/create/flywheel/shaders/std/fog.glsl diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index de256a9a4..d4f3085f2 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -46,7 +46,8 @@ public class ShaderLoader { // #flwinclude <"valid_namespace:valid/path_to_file.glsl"> private static final Pattern includePattern = Pattern.compile("#flwinclude <\"([\\w\\d_]+:[\\w\\d_./]+)\">"); - private static boolean debugDumpFile = false; + private static final Pattern builtinPattern = Pattern.compile("#flwbuiltins"); + private static boolean debugDumpFile = true; final Map shaderSource = new HashMap<>(); @@ -64,6 +65,9 @@ public class ShaderLoader { Backend.registry.values().forEach(this::loadProgramFromSpec); Backend.log.info("Loaded all shader programs."); + + // no need to hog all that memory + shaderSource.clear(); } } } @@ -125,7 +129,54 @@ public class ShaderLoader { } } - private String processIncludes(ResourceLocation baseName, String source) { + public GlShader loadShader(ResourceLocation name, ShaderType type, ShaderConstants defines) { + String source = shaderSource.get(name); + + source = expandBuiltins(source, type); + source = processIncludes(source, name); + + if (defines != null) + source = defines.process(source); + + if (debugDumpFile) { + Backend.log.debug("Finished processing '" + name + "':"); + int i = 1; + for (String s : source.split("\n")) { + Backend.log.debug(String.format("%1$4s: ", i++) + s); + } + } + + return new GlShader(type, name, source); + } + + private String expandBuiltins(String source, ShaderType type) { + return lines(source).flatMap(line -> { + Matcher matcher = builtinPattern.matcher(line); + + if (matcher.find()) { + ResourceLocation builtins; + + switch (type) { + case FRAGMENT: + builtins = new ResourceLocation("create", "std/builtin.frag"); + break; + case VERTEX: + builtins = new ResourceLocation("create", "std/builtin.vert"); + break; + default: + builtins = null; + } + + String includeSource = shaderSource.get(builtins); + + return lines(includeSource); + } + + return Stream.of(line); + }).collect(Collectors.joining("\n")); + } + + private String processIncludes(String source, ResourceLocation baseName) { HashSet seen = new HashSet<>(); seen.add(baseName); @@ -133,7 +184,7 @@ public class ShaderLoader { } private Stream includeRecursive(String source, Set seen) { - return new BufferedReader(new StringReader(source)).lines().flatMap(line -> { + return lines(source).flatMap(line -> { Matcher matcher = includePattern.matcher(line); @@ -155,23 +206,8 @@ public class ShaderLoader { }); } - public GlShader loadShader(ResourceLocation name, ShaderType type, ShaderConstants defines) { - String source = shaderSource.get(name); - - source = processIncludes(name, source); - - if (defines != null) - source = defines.process(source); - - if (debugDumpFile) { - Backend.log.debug("Finished processing '" + name + "':"); - int i = 1; - for (String s : source.split("\n")) { - Backend.log.debug(String.format("%1$4s: ", i++) + s); - } - } - - return new GlShader(type, name, source); + public static Stream lines(String s) { + return new BufferedReader(new StringReader(s)).lines(); } public String readToString(InputStream is) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java index 89eabc9d0..cea898c4f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java @@ -105,13 +105,7 @@ public abstract class GlProgram extends GlObject { } /** - * Links the attached shaders to this program and returns a user-defined container which wraps the shader - * program. This container can, for example, provide methods for updating the specific uniforms of that shader - * set. - * - * @param factory The factory which will create the shader program's container - * @param

The type which should be instantiated with the new program's handle - * @return An instantiated shader container as provided by the factory + * Links the attached shaders to this program. */ public Builder link() { GL20.glLinkProgram(this.program); diff --git a/src/main/resources/assets/create/flywheel/shaders/belt.vert b/src/main/resources/assets/create/flywheel/shaders/belt.vert index 6edba4c07..78937f401 100644 --- a/src/main/resources/assets/create/flywheel/shaders/belt.vert +++ b/src/main/resources/assets/create/flywheel/shaders/belt.vert @@ -1,6 +1,7 @@ #version 110 #define PI 3.1415926538 +#flwbuiltins #flwinclude <"create:core/quaternion.glsl"> #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/diffuse.glsl"> @@ -30,16 +31,6 @@ uniform int uDebug; uniform vec3 uCameraPos; -#if defined(USE_FOG) -varying float FragDistance; -#endif - -#ifdef CONTRAPTION -#flwinclude <"create:contraption/builtin.vert"> -#else -#flwinclude <"create:std/builtin.vert"> -#endif - void main() { vec3 rotated = rotateVertexByQuat(aPos - .5, aInstanceRot) + aInstancePos + .5; @@ -47,7 +38,7 @@ void main() { vec3 norm = rotateVertexByQuat(aNormal, aInstanceRot); - FLWFinalizeWorldPos(worldPos); + FLWFinalizeWorldPos(worldPos, uCameraPos); FLWFinalizeNormal(norm); float scrollSize = aScrollTexture.w - aScrollTexture.y; diff --git a/src/main/resources/assets/create/flywheel/shaders/block.frag b/src/main/resources/assets/create/flywheel/shaders/block.frag index 0ad89defe..ccac8b02b 100644 --- a/src/main/resources/assets/create/flywheel/shaders/block.frag +++ b/src/main/resources/assets/create/flywheel/shaders/block.frag @@ -1,5 +1,7 @@ #version 110 +#flwbuiltins + varying vec2 TexCoords; varying vec2 Light; varying float Diffuse; @@ -8,45 +10,12 @@ varying vec4 Color; uniform sampler2D uBlockAtlas; uniform sampler2D uLightMap; -#if defined(USE_FOG) -varying float FragDistance; -uniform vec4 uFogColor; -#endif - -#if defined(USE_FOG_LINEAR) -uniform vec2 uFogRange; - -float fogFactor() { - return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x); -} -#endif - -#ifdef USE_FOG_EXP2 -uniform float uFogDensity; - -float fogFactor() { - float dist = FragDistance * uFogDensity; - return 1. / exp2(dist * dist); -} - #endif - - #ifdef CONTRAPTION - #flwinclude <"create:contraption/builtin.frag"> - #else - #flwinclude <"create:std/builtin.frag"> - #endif - void main() { vec4 tex = texture2D(uBlockAtlas, TexCoords); vec4 color = vec4(tex.rgb * FLWLight(Light, uLightMap).rgb * Diffuse, tex.a) * Color; - #if defined(USE_FOG) - float fog = clamp(fogFactor(), 0., 1.); + FLWFinalizeColor(color); - gl_FragColor = mix(uFogColor, color, fog); - gl_FragColor.a = color.a; -#else gl_FragColor = color; -#endif } diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag index eb9014677..f1562aad4 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag @@ -1,6 +1,16 @@ varying vec3 BoxCoord; uniform sampler3D uLightVolume; +void FLWFinalizeColor(vec4 color) { + #if defined(USE_FOG) + float a = color.a; + float fog = clamp(FLWFogFactor(), 0., 1.); + + color = mix(uFogColor, color, fog); + color.a = a; + #endif +} + vec4 FLWLight(vec2 lightCoords, sampler2D lightMap) { vec2 lm = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg); return texture2D(lightMap, lm * 0.9375 + 0.03125); diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert index ed55cc3a9..63aafdbda 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert @@ -1,20 +1,28 @@ +#if defined(USE_FOG) +varying float FragDistance; +#endif + varying vec3 BoxCoord; uniform vec3 uLightBoxSize; uniform vec3 uLightBoxMin; uniform mat4 uModel; -void FLWFinalizeWorldPos(inout vec4 worldPos) { +void FLWFinalizeWorldPos(inout vec4 worldPos, vec3 cameraPos) { worldPos = uModel * worldPos; BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; - #if defined(USE_FOG) + #if defined(USE_FOG) FragDistance = length(worldPos.xyz); #endif } void FLWFinalizeNormal(inout vec3 normal) { - normal = modelToNormal(uModel) * normal; + mat3 m; + m[0] = uModel[0].xyz; + m[1] = uModel[1].xyz; + m[2] = uModel[2].xyz; + normal = m * normal; } diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert index b58a4df0e..4de728759 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert @@ -19,7 +19,6 @@ attribute vec4 aInstanceRot; attribute vec3 aRotationCenter; attribute float aSpeed; - varying float Diffuse; varying vec2 TexCoords; varying vec4 Color; @@ -68,4 +67,4 @@ void main() { } else { Color = vec4(1.); } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/flywheel/shaders/core/matutils.glsl b/src/main/resources/assets/create/flywheel/shaders/core/matutils.glsl index f7c846e71..d5f4d9c6c 100644 --- a/src/main/resources/assets/create/flywheel/shaders/core/matutils.glsl +++ b/src/main/resources/assets/create/flywheel/shaders/core/matutils.glsl @@ -1,17 +1,4 @@ -//mat4 rotate(vec3 axis, float angle) { -// float s = sin(angle); -// float c = cos(angle); -// float oc = 1. - c; -// -// return mat4( -// oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0., -// oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0., -// oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0., -// 0., 0., 0., 1. -// ); -//} - mat4 rotate(vec3 axis, float angle) { float s = sin(angle); float c = cos(angle); @@ -39,4 +26,4 @@ mat3 modelToNormal(mat4 mat) { m[1] = mat[1].xyz; m[2] = mat[2].xyz; return m; -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/flywheel/shaders/flap.vert b/src/main/resources/assets/create/flywheel/shaders/flap.vert index 037c603c2..8b79964c1 100644 --- a/src/main/resources/assets/create/flywheel/shaders/flap.vert +++ b/src/main/resources/assets/create/flywheel/shaders/flap.vert @@ -1,6 +1,7 @@ #version 110 #define PI 3.1415926538 +#flwbuiltins #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/quaternion.glsl"> #flwinclude <"create:core/diffuse.glsl"> @@ -32,16 +33,6 @@ uniform int uDebug; uniform vec3 uCameraPos; -#if defined(USE_FOG) -varying float FragDistance; -#endif - -#ifdef CONTRAPTION -#flwinclude <"create:contraption/builtin.vert"> -#else -#flwinclude <"create:std/builtin.vert"> -#endif - float toRad(float degrees) { return fract(degrees / 360.) * PI * 2.; } @@ -71,7 +62,7 @@ void main() { vec4 worldPos = vec4(rotated, 1.); vec3 norm = rotateVertexByQuat(rotateVertexByQuat(aNormal, flapRotation), orientation); - FLWFinalizeWorldPos(worldPos); + FLWFinalizeWorldPos(worldPos, uCameraPos); FLWFinalizeNormal(norm); Diffuse = diffuse(norm); diff --git a/src/main/resources/assets/create/flywheel/shaders/model.vert b/src/main/resources/assets/create/flywheel/shaders/model.vert index e0a62efe7..a6c5e3ec1 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model.vert +++ b/src/main/resources/assets/create/flywheel/shaders/model.vert @@ -1,5 +1,6 @@ #version 110 +#flwbuiltins #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/diffuse.glsl"> @@ -23,24 +24,13 @@ uniform int uDebug; uniform vec3 uCameraPos; -#if defined(USE_FOG) -varying float FragDistance; -#endif - -#ifdef CONTRAPTION -#flwinclude <"create:contraption/builtin.vert"> -#else -#flwinclude <"create:std/builtin.vert"> -#endif - - void main() { vec4 worldPos = aTransform * vec4(aPos, 1.); vec3 norm = aNormalMat * aNormal; + FLWFinalizeWorldPos(worldPos, uCameraPos); FLWFinalizeNormal(norm); - FLWFinalizeWorldPos(worldPos); norm = normalize(norm); diff --git a/src/main/resources/assets/create/flywheel/shaders/oriented.vert b/src/main/resources/assets/create/flywheel/shaders/oriented.vert index e88371820..8c94ecd04 100644 --- a/src/main/resources/assets/create/flywheel/shaders/oriented.vert +++ b/src/main/resources/assets/create/flywheel/shaders/oriented.vert @@ -1,5 +1,6 @@ #version 110 +#flwbuiltins #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/quaternion.glsl"> #flwinclude <"create:core/diffuse.glsl"> @@ -25,22 +26,12 @@ uniform int uDebug; uniform vec3 uCameraPos; -#if defined(USE_FOG) -varying float FragDistance; -#endif - -#ifdef CONTRAPTION -#flwinclude <"create:contraption/builtin.vert"> -#else -#flwinclude <"create:std/builtin.vert"> -#endif - void main() { vec4 worldPos = vec4(rotateVertexByQuat(aPos - aPivot, aRotation) + aPivot + aInstancePos, 1.); vec3 norm = rotateVertexByQuat(aNormal, aRotation); - FLWFinalizeWorldPos(worldPos); + FLWFinalizeWorldPos(worldPos, uCameraPos); FLWFinalizeNormal(norm); Diffuse = diffuse(norm); diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/shaders/rotating.vert index d2eaeb63b..770ef4ccc 100644 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ b/src/main/resources/assets/create/flywheel/shaders/rotating.vert @@ -1,6 +1,7 @@ #version 110 #define PI 3.1415926538 +#flwbuiltins #flwinclude <"create:core/quaternion.glsl"> #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/diffuse.glsl"> @@ -27,16 +28,6 @@ uniform int uDebug; uniform vec3 uCameraPos; -#if defined(USE_FOG) -varying float FragDistance; -#endif - -#ifdef CONTRAPTION -#flwinclude <"create:contraption/builtin.vert"> -#else -#flwinclude <"create:std/builtin.vert"> -#endif - mat4 kineticRotation() { float degrees = aOffset + uTime * aSpeed * 3./10.; float angle = fract(degrees / 360.) * PI * 2.; @@ -50,7 +41,7 @@ void main() { vec3 norm = modelToNormal(kineticRotation) * aNormal; - FLWFinalizeWorldPos(worldPos); + FLWFinalizeWorldPos(worldPos, uCameraPos); FLWFinalizeNormal(norm); Diffuse = diffuse(norm); diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag index d133154cf..347537366 100644 --- a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag @@ -1,4 +1,21 @@ +#flwinclude <"create:std/fog.glsl"> + +#if defined(CONTRAPTION) +#flwinclude <"create:contraption/builtin.frag"> +#else + +void FLWFinalizeColor(vec4 color) { + #if defined(USE_FOG) + float a = color.a; + float fog = clamp(FLWFogFactor(), 0., 1.); + + color = mix(uFogColor, color, fog); + color.a = a; + #endif +} + vec4 FLWLight(vec2 lightCoords, sampler2D lightMap) { vec2 lm = lightCoords * 0.9375 + 0.03125; return texture2D(lightMap, lm); } + #endif diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert index e3f3180bf..5c542b77f 100644 --- a/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert +++ b/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert @@ -1,10 +1,18 @@ -void FLWFinalizeWorldPos(inout vec4 worldPos) { - #if defined(USE_FOG) +#if defined(CONTRAPTION) +#flwinclude <"create:contraption/builtin.vert"> +#else - FragDistance = length(worldPos.xyz - uCameraPos); +#if defined(USE_FOG) +varying float FragDistance; +#endif + +void FLWFinalizeWorldPos(inout vec4 worldPos, vec3 cameraPos) { + #if defined(USE_FOG) + FragDistance = length(worldPos.xyz - cameraPos); #endif } void FLWFinalizeNormal(inout vec3 normal) { // noop } + #endif diff --git a/src/main/resources/assets/create/flywheel/shaders/std/fog.glsl b/src/main/resources/assets/create/flywheel/shaders/std/fog.glsl new file mode 100644 index 000000000..09cc7af18 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/std/fog.glsl @@ -0,0 +1,23 @@ +#if defined(USE_FOG) +varying float FragDistance; +uniform vec4 uFogColor; +#endif + +#if defined(USE_FOG_LINEAR) +uniform vec2 uFogRange; + +float FLWFogFactor() { + return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x); +} + #elif defined(USE_FOG_EXP2) +uniform float uFogDensity; + +float FLWFogFactor() { + float dist = FragDistance * uFogDensity; + return 1. / exp2(dist * dist); +} + #else +float FLWFogFactor() { + return 0.; +} + #endif From 77ee23c208b449da0625f55fe3f32204aa2ddf38 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Mon, 3 May 2021 18:35:57 -0700 Subject: [PATCH 022/198] Fix crate rarity --- .../simibubi/create/foundation/data/BuilderTransformers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java b/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java index 922586443..48a2bac64 100644 --- a/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java +++ b/src/main/java/com/simibubi/create/foundation/data/BuilderTransformers.java @@ -212,7 +212,7 @@ public class BuilderTransformers { }); }) .item() - .properties(p -> type.equals("creative") ? p : p.rarity(Rarity.EPIC)) + .properties(p -> type.equals("creative") ? p.rarity(Rarity.EPIC) : p) .transform(ModelGen.customItemModel("crate", type, "single")); } From bc5630e593936a3850b4b8c882342338c2621885 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Mon, 3 May 2021 21:46:33 -0700 Subject: [PATCH 023/198] ShaderContexts - A huge step towards more arbitrary shader usage - Need to work on registration of the different parts - Things are unorganized --- .../jozufozu/flywheel/backend/Backend.java | 36 ++++++--- .../backend/FastRenderDispatcher.java | 32 +++++++- .../flywheel/backend/ResourceUtil.java | 10 +++ .../flywheel/backend/ShaderContext.java | 54 +++++++++++++ .../flywheel/backend/ShaderLoader.java | 66 +++++----------- .../core/BasicInstancedTileRenderer.java | 10 +-- .../backend/core/ContraptionContext.java | 17 +++++ .../flywheel/backend/core/EffectsContext.java | 32 ++++++++ .../flywheel/backend/core/WorldContext.java | 76 +++++++++++++++++++ .../backend/effects/EffectsHandler.java | 3 +- .../gl/shader/FogSensitiveProgram.java | 5 +- .../backend/gl/shader/ProgramSpec.java | 34 +++------ .../backend/gl/shader/ShaderSpecLoader.java | 3 +- .../backend/gl/shader/SingleProgram.java | 5 +- .../instancing/InstancedTileRenderer.java | 12 ++- .../backend/instancing/MaterialFactory.java | 19 +++++ .../backend/instancing/RenderMaterial.java | 11 ++- .../com/simibubi/create/CreateClient.java | 6 +- .../render/ContraptionKineticRenderer.java | 25 +----- .../render/ContraptionRenderDispatcher.java | 13 ++-- .../simibubi/create/events/ClientEvents.java | 4 +- .../foundation/mixin/RenderHooksMixin.java | 4 +- .../foundation/mixin/TileWorldHookMixin.java | 4 +- .../foundation/render/AllProgramSpecs.java | 65 +++------------- .../foundation/render/KineticRenderer.java | 22 ------ .../flywheel/shaders/contraption/builtin.frag | 2 + .../create/flywheel/shaders/std/builtin.frag | 5 -- .../create/flywheel/shaders/std/builtin.vert | 4 - 28 files changed, 349 insertions(+), 230 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/ResourceUtil.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/EffectsContext.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialFactory.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index b66b67bf6..6bad69303 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -8,9 +8,10 @@ import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; +import com.jozufozu.flywheel.backend.core.ContraptionContext; +import com.jozufozu.flywheel.backend.core.EffectsContext; +import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.effects.EffectsHandler; -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; -import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; @@ -38,28 +39,41 @@ public class Backend { private static boolean instancingAvailable; private static boolean enabled; - static final Map> registry = new HashMap<>(); - static final Map, IMultiProgram> programs = new HashMap<>(); + static final Map> contexts = new HashMap<>(); + static final Map specRegistry = new HashMap<>(); + + static { + register(WorldContext.INSTANCE); + register(ContraptionContext.INSTANCE); + register(EffectsContext.INSTANCE); + } public Backend() { throw new IllegalStateException(); } /** - * Register a shader program. TODO: replace with forge registry? + * Register a shader program. */ - public static

> S register(S spec) { + public static ProgramSpec register(ProgramSpec spec) { ResourceLocation name = spec.name; - if (registry.containsKey(name)) { + if (specRegistry.containsKey(name)) { throw new IllegalStateException("Program spec '" + name + "' already registered."); } - registry.put(name, spec); + specRegistry.put(name, spec); return spec; } - @SuppressWarnings("unchecked") - public static

> P getProgram(S spec) { - return (P) programs.get(spec).get(); + /** + * Register a shader context. + */ + public static ShaderContext register(ShaderContext spec) { + ResourceLocation name = spec.getRoot(); + if (contexts.containsKey(name)) { + throw new IllegalStateException("Program spec '" + name + "' already registered."); + } + contexts.put(name, spec); + return spec; } public static boolean isFlywheelWorld(World world) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java b/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java index 09879ff0c..cc796f7f0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java +++ b/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java @@ -1,10 +1,21 @@ package com.jozufozu.flywheel.backend; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; +import com.jozufozu.flywheel.backend.core.OrientedModel; +import com.jozufozu.flywheel.backend.core.TransformedModel; +import com.jozufozu.flywheel.backend.instancing.MaterialFactory; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.KineticDebugger; -import com.simibubi.create.foundation.render.KineticRenderer; +import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; +import com.simibubi.create.content.contraptions.base.RotatingModel; +import com.simibubi.create.content.contraptions.components.actors.ActorModel; +import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; +import com.simibubi.create.content.logistics.block.FlapModel; +import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.utility.WorldAttached; import net.minecraft.client.Minecraft; @@ -17,8 +28,23 @@ import net.minecraft.world.World; public class FastRenderDispatcher { + public static Map, MaterialFactory> materials = new HashMap<>(); + + static { + registerMaterials(); + } + public static WorldAttached> queuedUpdates = new WorldAttached<>(ConcurrentHashMap::newKeySet); + public static void registerMaterials() { + materials.put(MaterialTypes.TRANSFORMED, new MaterialFactory(AllProgramSpecs.MODEL, TransformedModel::new)); + materials.put(MaterialTypes.ORIENTED, new MaterialFactory(AllProgramSpecs.ORIENTED, OrientedModel::new)); + materials.put(KineticRenderMaterials.BELTS, new MaterialFactory(AllProgramSpecs.BELT, BeltInstancedModel::new)); + materials.put(KineticRenderMaterials.ROTATING, new MaterialFactory(AllProgramSpecs.ROTATING, RotatingModel::new)); + materials.put(KineticRenderMaterials.FLAPS, new MaterialFactory(AllProgramSpecs.FLAPS, FlapModel::new)); + materials.put(KineticRenderMaterials.ACTORS, new MaterialFactory(AllProgramSpecs.C_ACTOR, ActorModel::new)); + } + public static void enqueueUpdate(TileEntity te) { queuedUpdates.get(te.getWorld()).add(te); } @@ -27,7 +53,7 @@ public class FastRenderDispatcher { Minecraft mc = Minecraft.getInstance(); ClientWorld world = mc.world; - KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); Entity renderViewEntity = mc.renderViewEntity; kineticRenderer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ()); @@ -61,7 +87,7 @@ public class FastRenderDispatcher { if (!Backend.canUseInstancing()) return; ClientWorld world = Minecraft.getInstance().world; - KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); layer.startDrawing(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/ResourceUtil.java b/src/main/java/com/jozufozu/flywheel/backend/ResourceUtil.java new file mode 100644 index 000000000..3a80b026e --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/ResourceUtil.java @@ -0,0 +1,10 @@ +package com.jozufozu.flywheel.backend; + +import net.minecraft.util.ResourceLocation; + +public class ResourceUtil { + + public static ResourceLocation subPath(ResourceLocation root, String subPath) { + return new ResourceLocation(root.getNamespace(), root.getPath() + subPath); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java new file mode 100644 index 000000000..b416318a9 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java @@ -0,0 +1,54 @@ +package com.jozufozu.flywheel.backend; + +import java.util.HashMap; +import java.util.Map; + +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; +import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; +import com.jozufozu.flywheel.backend.gl.shader.ShaderType; + +import net.minecraft.util.ResourceLocation; + +public abstract class ShaderContext

{ + + public final Map> programs = new HashMap<>(); + + public final ResourceLocation root; + + public ShaderContext(ResourceLocation root) { + this.root = root; + } + + public abstract ShaderSpecLoader

getLoader(); + + public void load(ShaderLoader loader) { + programs.values().forEach(IMultiProgram::delete); + programs.clear(); + + for (ProgramSpec programSpec : Backend.specRegistry.values()) { + loadProgramFromSpec(loader, programSpec); + } + } + + public void loadProgramFromSpec(ShaderLoader loader, ProgramSpec programSpec) { + + programs.put(programSpec, getLoader().create(loader, this, programSpec)); + + Backend.log.debug("Loaded program {}", programSpec.name); + } + + public String preProcess(ShaderLoader loader, String shaderSrc, ShaderType type) { + return shaderSrc; + } + + public P getProgram(ProgramSpec spec) { + return programs.get(spec).get(); + } + + public ResourceLocation getRoot() { + return root; + } + +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index d4f3085f2..fc357957e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -28,7 +28,6 @@ import com.google.common.collect.Lists; import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.GlShader; -import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; @@ -46,10 +45,9 @@ public class ShaderLoader { // #flwinclude <"valid_namespace:valid/path_to_file.glsl"> private static final Pattern includePattern = Pattern.compile("#flwinclude <\"([\\w\\d_]+:[\\w\\d_./]+)\">"); - private static final Pattern builtinPattern = Pattern.compile("#flwbuiltins"); private static boolean debugDumpFile = true; - final Map shaderSource = new HashMap<>(); + private final Map shaderSource = new HashMap<>(); void onResourceManagerReload(IResourceManager manager, Predicate predicate) { if (predicate.test(VanillaResourceType.SHADERS)) { @@ -60,9 +58,9 @@ public class ShaderLoader { shaderSource.clear(); loadShaderSources(manager); - Backend.programs.values().forEach(IMultiProgram::delete); - Backend.programs.clear(); - Backend.registry.values().forEach(this::loadProgramFromSpec); + for (ShaderContext context : Backend.contexts.values()) { + context.load(this); + } Backend.log.info("Loaded all shader programs."); @@ -72,6 +70,10 @@ public class ShaderLoader { } } + public String getShaderSource(ResourceLocation loc) { + return shaderSource.get(loc); + } + private void loadShaderSources(IResourceManager manager) { Collection allShaders = manager.getAllResourceLocations(SHADER_DIR, s -> { for (String ext : EXTENSIONS) { @@ -96,27 +98,20 @@ public class ShaderLoader { } } - private

> void loadProgramFromSpec(S programSpec) { - - Backend.programs.put(programSpec, programSpec.finalizer.create(this, programSpec)); - - Backend.log.debug("Loaded program {}", programSpec.name); + public GlProgram.Builder loadProgram(ShaderContext ctx, ProgramSpec programSpec) { + return loadProgram(ctx, programSpec, programSpec.defines); } - public GlProgram.Builder loadProgram(ProgramSpec programSpec) { - return loadProgram(programSpec, programSpec.defines); + public GlProgram.Builder loadProgram(ShaderContext ctx, ProgramSpec programSpec, ShaderConstants defines) { + return loadProgram(ctx, programSpec.name, programSpec.vert, programSpec.frag, programSpec.attributes, defines); } - public GlProgram.Builder loadProgram(ProgramSpec programSpec, ShaderConstants defines) { - return loadProgram(programSpec.name, programSpec.vert, programSpec.frag, programSpec.attributes, defines); - } - - public GlProgram.Builder loadProgram(ResourceLocation name, ResourceLocation vert, ResourceLocation frag, Collection attribs, ShaderConstants defines) { + public GlProgram.Builder loadProgram(ShaderContext ctx, ResourceLocation name, ResourceLocation vert, ResourceLocation frag, Collection attribs, ShaderConstants defines) { GlShader vsh = null; GlShader fsh = null; try { - vsh = loadShader(vert, ShaderType.VERTEX, defines); - fsh = loadShader(frag, ShaderType.FRAGMENT, defines); + vsh = loadShader(ctx, vert, ShaderType.VERTEX, defines); + fsh = loadShader(ctx, frag, ShaderType.FRAGMENT, defines); return GlProgram.builder(name) .attachShader(vsh) @@ -129,10 +124,10 @@ public class ShaderLoader { } } - public GlShader loadShader(ResourceLocation name, ShaderType type, ShaderConstants defines) { + public GlShader loadShader(ShaderContext ctx, ResourceLocation name, ShaderType type, ShaderConstants defines) { String source = shaderSource.get(name); - source = expandBuiltins(source, type); + source = ctx.preProcess(this, source, type); source = processIncludes(source, name); if (defines != null) @@ -149,33 +144,6 @@ public class ShaderLoader { return new GlShader(type, name, source); } - private String expandBuiltins(String source, ShaderType type) { - return lines(source).flatMap(line -> { - Matcher matcher = builtinPattern.matcher(line); - - if (matcher.find()) { - ResourceLocation builtins; - - switch (type) { - case FRAGMENT: - builtins = new ResourceLocation("create", "std/builtin.frag"); - break; - case VERTEX: - builtins = new ResourceLocation("create", "std/builtin.vert"); - break; - default: - builtins = null; - } - - String includeSource = shaderSource.get(builtins); - - return lines(includeSource); - } - - return Stream.of(line); - }).collect(Collectors.joining("\n")); - } - private String processIncludes(String source, ResourceLocation baseName) { HashSet seen = new HashSet<>(); seen.add(baseName); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java index dcdf7d317..2ea176ebb 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java @@ -2,11 +2,8 @@ package com.jozufozu.flywheel.backend.core; import java.util.ArrayList; -import com.jozufozu.flywheel.backend.MaterialTypes; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; -import com.jozufozu.flywheel.backend.instancing.RenderMaterial; -import com.simibubi.create.foundation.render.AllProgramSpecs; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.RenderType; @@ -20,11 +17,8 @@ public class BasicInstancedTileRenderer extends InstancedTileRenderer(this, AllProgramSpecs.MODEL, TransformedModel::new)); - materials.put(MaterialTypes.ORIENTED, new RenderMaterial<>(this, AllProgramSpecs.ORIENTED, OrientedModel::new)); + public BasicInstancedTileRenderer() { + super(WorldContext.INSTANCE); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java new file mode 100644 index 000000000..e90310d62 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java @@ -0,0 +1,17 @@ +package com.jozufozu.flywheel.backend.core; + +import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram; + +import net.minecraft.util.ResourceLocation; + +public class ContraptionContext extends WorldContext { + + public static final ContraptionContext INSTANCE = new ContraptionContext(); + + public ContraptionContext() { + super(new ResourceLocation("create", "contraption"), new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)); + } + + +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/EffectsContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/EffectsContext.java new file mode 100644 index 000000000..0075faf6d --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/EffectsContext.java @@ -0,0 +1,32 @@ +package com.jozufozu.flywheel.backend.core; + +import com.jozufozu.flywheel.backend.ShaderContext; +import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.effects.SphereFilterProgram; +import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; +import com.jozufozu.flywheel.backend.gl.shader.SingleProgram; +import com.simibubi.create.foundation.render.AllProgramSpecs; + +import net.minecraft.util.ResourceLocation; + +public class EffectsContext extends ShaderContext { + + public static final EffectsContext INSTANCE = new EffectsContext(); + + private final SingleProgram.SpecLoader loader; + + public EffectsContext() { + super(new ResourceLocation("create", "effects")); + loader = new SingleProgram.SpecLoader<>(SphereFilterProgram::new); + } + + @Override + public void load(ShaderLoader loader) { + loadProgramFromSpec(loader, AllProgramSpecs.CHROMATIC); + } + + @Override + public ShaderSpecLoader getLoader() { + return loader; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java new file mode 100644 index 000000000..74d95aa7a --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -0,0 +1,76 @@ +package com.jozufozu.flywheel.backend.core; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import com.jozufozu.flywheel.backend.ResourceUtil; +import com.jozufozu.flywheel.backend.ShaderContext; +import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; +import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; +import com.jozufozu.flywheel.backend.gl.shader.ShaderType; + +import net.minecraft.util.ResourceLocation; + +public class WorldContext

extends ShaderContext

{ + + private static final Pattern builtinPattern = Pattern.compile("#flwbuiltins"); + + public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation("create", "std"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); + + private final ShaderSpecLoader

loader; + + public final ResourceLocation frag; + public final ResourceLocation vert; + + public WorldContext(ResourceLocation root, ShaderSpecLoader

loader) { + super(root); + this.frag = ResourceUtil.subPath(root, "/builtin.frag"); + this.vert = ResourceUtil.subPath(root, "/builtin.vert"); + + this.loader = loader; + } + + @Override + public String preProcess(ShaderLoader loader, String shaderSrc, ShaderType type) { + return ShaderLoader.lines(shaderSrc).flatMap(line -> { + Matcher matcher = builtinPattern.matcher(line); + + if (matcher.find()) { + ResourceLocation builtins; + + switch (type) { + case FRAGMENT: + builtins = frag; + break; + case VERTEX: + builtins = vert; + break; + default: + builtins = null; + } + + String includeSource = loader.getShaderSource(builtins); + + return ShaderLoader.lines(includeSource); + } + + return Stream.of(line); + }).collect(Collectors.joining("\n")); + } + + public ResourceLocation getFrag() { + return frag; + } + + public ResourceLocation getVert() { + return vert; + } + + @Override + public ShaderSpecLoader

getLoader() { + return loader; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java b/src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java index 4227ed861..fd5e570ea 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java +++ b/src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java @@ -9,6 +9,7 @@ import org.lwjgl.opengl.GL30; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.RenderUtil; +import com.jozufozu.flywheel.backend.core.EffectsContext; import com.jozufozu.flywheel.backend.gl.GlBuffer; import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; import com.jozufozu.flywheel.backend.gl.GlVertexArray; @@ -95,7 +96,7 @@ public class EffectsHandler { Backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, framebuffer.framebufferObject); GL11.glClear(GL30.GL_COLOR_BUFFER_BIT); - SphereFilterProgram program = Backend.getProgram(AllProgramSpecs.CHROMATIC); + SphereFilterProgram program = EffectsContext.INSTANCE.getProgram(AllProgramSpecs.CHROMATIC); program.bind(); program.bindColorTexture(mainBuffer.getColorAttachment()); diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java index 3a04cd9f4..0ef0e509f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java @@ -3,6 +3,7 @@ package com.jozufozu.flywheel.backend.gl.shader; import java.util.EnumMap; import java.util.Map; +import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.gl.GlFog; import com.jozufozu.flywheel.backend.gl.GlFogMode; @@ -36,7 +37,7 @@ public class FogSensitiveProgram

implements IMultiProgram

create(ShaderLoader loader, ProgramSpec

spec) { + public IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { Map programs = new EnumMap<>(GlFogMode.class); for (GlFogMode fogMode : GlFogMode.values()) { @@ -44,7 +45,7 @@ public class FogSensitiveProgram

implements IMultiProgram

{ +public class ProgramSpec { public final ResourceLocation name; public final ResourceLocation vert; @@ -18,63 +17,54 @@ public class ProgramSpec

{ public final ArrayList attributes; - public final ShaderSpecLoader

finalizer; - - public static

Builder

builder(String name, ShaderSpecLoader

factory) { - return builder(new ResourceLocation(Create.ID, name), factory); + public static Builder builder(ResourceLocation name) { + return new Builder(name); } - public static

Builder

builder(ResourceLocation name, ShaderSpecLoader

factory) { - return new Builder<>(name, factory); - } - - public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag, ShaderConstants defines, ArrayList attributes, ShaderSpecLoader

finalizer) { + public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag, ShaderConstants defines, ArrayList attributes) { this.name = name; this.vert = vert; this.frag = frag; this.defines = defines; this.attributes = attributes; - this.finalizer = finalizer; } - public static class Builder

{ + public static class Builder { private ResourceLocation vert; private ResourceLocation frag; private ShaderConstants defines = ShaderConstants.EMPTY; - private final ShaderSpecLoader

loader; private final ResourceLocation name; private final ArrayList attributes; - public Builder(ResourceLocation name, ShaderSpecLoader

factory) { + public Builder(ResourceLocation name) { this.name = name; - this.loader = factory; attributes = new ArrayList<>(); } - public Builder

setVert(ResourceLocation vert) { + public Builder setVert(ResourceLocation vert) { this.vert = vert; return this; } - public Builder

setFrag(ResourceLocation frag) { + public Builder setFrag(ResourceLocation frag) { this.frag = frag; return this; } - public Builder

setDefines(ShaderConstants defines) { + public Builder setDefines(ShaderConstants defines) { this.defines = defines; return this; } - public & IVertexAttrib> Builder

addAttributes(Class attributeEnum) { + public & IVertexAttrib> Builder addAttributes(Class attributeEnum) { attributes.addAll(Arrays.asList(attributeEnum.getEnumConstants())); return this; } - public ProgramSpec

createProgramSpec() { - return new ProgramSpec<>(name, vert, frag, defines, attributes, loader); + public ProgramSpec createProgramSpec() { + return new ProgramSpec(name, vert, frag, defines, attributes); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java index a0d2d7d21..a9d635c8e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java @@ -1,7 +1,8 @@ package com.jozufozu.flywheel.backend.gl.shader; +import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; public interface ShaderSpecLoader

{ - IMultiProgram

create(ShaderLoader loader, ProgramSpec

spec); + IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java index b4fff4541..d5bfbb539 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java @@ -1,5 +1,6 @@ package com.jozufozu.flywheel.backend.gl.shader; +import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; import net.minecraft.util.ResourceLocation; @@ -29,8 +30,8 @@ public class SingleProgram

implements IMultiProgram

{ } @Override - public IMultiProgram

create(ShaderLoader loader, ProgramSpec

spec) { - GlProgram.Builder builder = loader.loadProgram(spec); + public IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { + GlProgram.Builder builder = loader.loadProgram(ctx, spec); return new SingleProgram<>(factory.create(builder.name, builder.program)); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java index 2bc2049d8..514549550 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java @@ -7,8 +7,10 @@ import java.util.Map; import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.jozufozu.flywheel.backend.MaterialType; import com.jozufozu.flywheel.backend.MaterialTypes; +import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.ModelData; import com.jozufozu.flywheel.backend.core.OrientedData; @@ -32,19 +34,21 @@ public abstract class InstancedTileRenderer

{ protected Map tickableInstances = new HashMap<>(); protected Map dynamicInstances = new HashMap<>(); + public final ShaderContext

context; + protected Map, RenderMaterial> materials = new HashMap<>(); protected int frame; protected int tick; - protected InstancedTileRenderer() { - registerMaterials(); + protected InstancedTileRenderer(ShaderContext

context) { + this.context = context; + + FastRenderDispatcher.materials.forEach((key, value) -> materials.put(key, value.create(this))); } public abstract BlockPos getOriginCoordinate(); - public abstract void registerMaterials(); - public void tick(double cameraX, double cameraY, double cameraZ) { tick++; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialFactory.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialFactory.java new file mode 100644 index 000000000..ab6e4cd47 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialFactory.java @@ -0,0 +1,19 @@ +package com.jozufozu.flywheel.backend.instancing; + +import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; + +public class MaterialFactory { + + ProgramSpec programSpec; + ModelFactory modelFactory; + + public MaterialFactory(ProgramSpec programSpec, ModelFactory modelFactory) { + this.programSpec = programSpec; + this.modelFactory = modelFactory; + } + + public

RenderMaterial create(InstancedTileRenderer

renderer) { + return new RenderMaterial<>(renderer, programSpec, modelFactory); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index e29a9d5dd..cfbe4affc 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -9,7 +9,6 @@ import org.apache.commons.lang3.tuple.Pair; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.jozufozu.flywheel.backend.RenderUtil; import com.jozufozu.flywheel.backend.core.BasicProgram; @@ -30,20 +29,20 @@ import net.minecraft.util.math.vector.Matrix4f; public class RenderMaterial

> { - protected final InstancedTileRenderer renderer; + protected final InstancedTileRenderer

renderer; protected final Cache models; protected final ModelFactory factory; - protected final ProgramSpec

programSpec; + protected final ProgramSpec programSpec; protected final Predicate layerPredicate; /** * Creates a material that renders in the default layer (CUTOUT_MIPPED) */ - public RenderMaterial(InstancedTileRenderer renderer, ProgramSpec

programSpec, ModelFactory factory) { + public RenderMaterial(InstancedTileRenderer

renderer, ProgramSpec programSpec, ModelFactory factory) { this(renderer, programSpec, factory, type -> type == RenderType.getCutoutMipped()); } - public RenderMaterial(InstancedTileRenderer renderer, ProgramSpec

programSpec, ModelFactory factory, Predicate layerPredicate) { + public RenderMaterial(InstancedTileRenderer

renderer, ProgramSpec programSpec, ModelFactory factory, Predicate layerPredicate) { this.renderer = renderer; this.models = CacheBuilder.newBuilder() .removalListener(notification -> ((InstancedModel) notification.getValue()).delete()) @@ -62,7 +61,7 @@ public class RenderMaterial

setup) { - P program = Backend.getProgram(programSpec); + P program = renderer.context.getProgram(programSpec); program.bind(viewProjection, camX, camY, camZ, FastRenderDispatcher.getDebugMode()); if (setup != null) setup.call(program); diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 4b38736f7..d73a79237 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -9,6 +9,7 @@ import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.OptifineHandler; +import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.jozufozu.flywheel.backend.core.PartialModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -27,7 +28,6 @@ import com.simibubi.create.foundation.item.CustomRenderedItems; import com.simibubi.create.foundation.ponder.content.PonderIndex; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.render.AllProgramSpecs; -import com.simibubi.create.foundation.render.KineticRenderer; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.utility.WorldAttached; import com.simibubi.create.foundation.utility.ghost.GhostBlocks; @@ -65,7 +65,7 @@ public class CreateClient { public static SchematicHandler schematicHandler; public static SchematicAndQuillHandler schematicAndQuillHandler; public static SuperByteBufferCache bufferCache; - public static WorldAttached kineticRenderer; + public static WorldAttached kineticRenderer; public static final Outliner outliner = new Outliner(); public static GhostBlocks ghostBlocks; @@ -88,7 +88,7 @@ public class CreateClient { public static void clientInit(FMLClientSetupEvent event) { AllProgramSpecs.init(); - kineticRenderer = new WorldAttached<>(KineticRenderer::new); + kineticRenderer = new WorldAttached<>(BasicInstancedTileRenderer::new); schematicSender = new ClientSchematicLoader(); schematicHandler = new SchematicHandler(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java index 986ad162e..514aa3b41 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java @@ -7,22 +7,15 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; -import com.jozufozu.flywheel.backend.MaterialTypes; -import com.jozufozu.flywheel.backend.core.OrientedModel; -import com.jozufozu.flywheel.backend.core.TransformedModel; +import com.jozufozu.flywheel.backend.core.ContraptionContext; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; -import com.simibubi.create.content.contraptions.base.RotatingModel; import com.simibubi.create.content.contraptions.components.actors.ActorData; -import com.simibubi.create.content.contraptions.components.actors.ActorModel; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; -import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; -import com.simibubi.create.content.logistics.block.FlapModel; -import com.simibubi.create.foundation.render.AllProgramSpecs; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.util.math.BlockPos; @@ -35,19 +28,9 @@ public class ContraptionKineticRenderer extends InstancedTileRenderer contraption; ContraptionKineticRenderer(RenderedContraption contraption) { - this.contraption = new WeakReference<>(contraption); - } - - @Override - public void registerMaterials() { - materials.put(MaterialTypes.TRANSFORMED, new RenderMaterial<>(this, AllProgramSpecs.C_MODEL, TransformedModel::new)); - materials.put(MaterialTypes.ORIENTED, new RenderMaterial<>(this, AllProgramSpecs.C_ORIENTED, OrientedModel::new)); - - materials.put(KineticRenderMaterials.BELTS, new RenderMaterial<>(this, AllProgramSpecs.C_BELT, BeltInstancedModel::new)); - materials.put(KineticRenderMaterials.ROTATING, new RenderMaterial<>(this, AllProgramSpecs.C_ROTATING, RotatingModel::new)); - materials.put(KineticRenderMaterials.FLAPS, new RenderMaterial<>(this, AllProgramSpecs.C_FLAPS, FlapModel::new)); - materials.put(KineticRenderMaterials.ACTORS, new RenderMaterial<>(this, AllProgramSpecs.C_ACTOR, ActorModel::new)); - } + super(ContraptionContext.INSTANCE); + this.contraption = new WeakReference<>(contraption); + } public void tick() { actors.forEach(ActorInstance::tick); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index b7624b37a..e99f883cf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -10,6 +10,7 @@ import org.lwjgl.opengl.GL40; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.core.ContraptionContext; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.CreateClient; @@ -81,12 +82,12 @@ public class ContraptionRenderDispatcher { GL13.glActiveTexture(GL40.GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 if (Backend.canUseVBOs()) { - ContraptionProgram structureShader = Backend.getProgram(AllProgramSpecs.C_STRUCTURE); - structureShader.bind(viewProjection, camX, camY, camZ, FastRenderDispatcher.getDebugMode()); - for (RenderedContraption renderer : renderers.values()) { - renderer.doRenderLayer(layer, structureShader); - } - } + ContraptionProgram structureShader = ContraptionContext.INSTANCE.getProgram(AllProgramSpecs.C_STRUCTURE); + structureShader.bind(viewProjection, camX, camY, camZ, FastRenderDispatcher.getDebugMode()); + for (RenderedContraption renderer : renderers.values()) { + renderer.doRenderLayer(layer, structureShader); + } + } if (Backend.canUseInstancing()) { for (RenderedContraption renderer : renderers.values()) { diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 7d0528748..fd010406e 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -5,6 +5,7 @@ import java.util.List; import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.jozufozu.flywheel.backend.RenderWork; +import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllFluids; @@ -36,7 +37,6 @@ import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.LeftClickPacket; import com.simibubi.create.foundation.ponder.PonderTooltipHandler; -import com.simibubi.create.foundation.render.KineticRenderer; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.sound.SoundScapes; import com.simibubi.create.foundation.tileEntity.behaviour.edgeInteraction.EdgeInteractionRenderer; @@ -144,7 +144,7 @@ public class ClientEvents { if (world.isRemote() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) { CreateClient.invalidateRenderers(world); AnimationTickHolder.reset(); - KineticRenderer renderer = CreateClient.kineticRenderer.get(world); + BasicInstancedTileRenderer renderer = CreateClient.kineticRenderer.get(world); renderer.invalidate(); ((ClientWorld) world).loadedTileEntityList.forEach(renderer::add); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index 3ac8541a1..f97ba920d 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -10,11 +10,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.jozufozu.flywheel.backend.OptifineHandler; +import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; -import com.simibubi.create.foundation.render.KineticRenderer; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.ActiveRenderInfo; @@ -96,7 +96,7 @@ public class RenderHooksMixin { Backend.refresh(); if (Backend.canUseInstancing() && world != null) { - KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); kineticRenderer.invalidate(); world.loadedTileEntityList.forEach(kineticRenderer::add); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java index a50fbc6ec..77b504956 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java @@ -10,8 +10,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.simibubi.create.CreateClient; -import com.simibubi.create.foundation.render.KineticRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -46,7 +46,7 @@ public class TileWorldHookMixin { @Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities") private void onChunkUnload(CallbackInfo ci) { if (isRemote) { - KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(self); + BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(self); for (TileEntity tile : tileEntitiesToBeRemoved) { kineticRenderer.remove(tile); } diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index 72fc21f90..af8ab05b6 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -3,21 +3,16 @@ package com.simibubi.create.foundation.render; import static com.jozufozu.flywheel.backend.Backend.register; import com.jozufozu.flywheel.backend.core.BasicAttributes; -import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.ModelAttributes; import com.jozufozu.flywheel.backend.core.OrientedAttributes; import com.jozufozu.flywheel.backend.core.TransformAttributes; -import com.jozufozu.flywheel.backend.effects.SphereFilterProgram; -import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; -import com.jozufozu.flywheel.backend.gl.shader.SingleProgram; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.KineticAttributes; import com.simibubi.create.content.contraptions.base.RotatingAttributes; import com.simibubi.create.content.contraptions.components.actors.ActorVertexAttributes; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionAttributes; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram; import com.simibubi.create.content.contraptions.relays.belt.BeltAttributes; import com.simibubi.create.content.logistics.block.FlapAttributes; @@ -28,7 +23,7 @@ public class AllProgramSpecs { // noop, make sure the static field are loaded. } - public static final ProgramSpec CHROMATIC = register(ProgramSpec.builder("chromatic", new SingleProgram.SpecLoader<>(SphereFilterProgram::new)) + public static final ProgramSpec CHROMATIC = register(builder("chromatic") .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(TransformAttributes.class) @@ -36,7 +31,7 @@ public class AllProgramSpecs { .setFrag(Locations.EFFECT_FRAG) .createProgramSpec()); - public static final ProgramSpec MODEL = register(ProgramSpec.builder("model", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) + public static final ProgramSpec MODEL = register(builder("model") .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(TransformAttributes.class) @@ -44,7 +39,7 @@ public class AllProgramSpecs { .setFrag(Locations.BLOCK) .createProgramSpec()); - public static final ProgramSpec ORIENTED = register(ProgramSpec.builder("oriented", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) + public static final ProgramSpec ORIENTED = register(builder("oriented") .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(OrientedAttributes.class) @@ -52,7 +47,7 @@ public class AllProgramSpecs { .setFrag(Locations.BLOCK) .createProgramSpec()); - public static final ProgramSpec ROTATING = register(ProgramSpec.builder("rotating", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) + public static final ProgramSpec ROTATING = register(builder("rotating") .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(KineticAttributes.class) @@ -61,7 +56,7 @@ public class AllProgramSpecs { .setFrag(Locations.BLOCK) .createProgramSpec()); - public static final ProgramSpec BELT = register(ProgramSpec.builder("belt", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) + public static final ProgramSpec BELT = register(builder("belt") .addAttributes(ModelAttributes.class) .addAttributes(BasicAttributes.class) .addAttributes(KineticAttributes.class) @@ -70,60 +65,19 @@ public class AllProgramSpecs { .setFrag(Locations.BLOCK) .createProgramSpec()); - public static final ProgramSpec FLAPS = register(ProgramSpec.builder("flap", new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)) + public static final ProgramSpec FLAPS = register(builder("flap") .addAttributes(ModelAttributes.class) .addAttributes(FlapAttributes.class) .setVert(Locations.FLAP) .setFrag(Locations.BLOCK) .createProgramSpec()); - public static final ProgramSpec C_STRUCTURE = register(ProgramSpec.builder("contraption_structure", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) + public static final ProgramSpec C_STRUCTURE = register(builder("contraption_structure") .addAttributes(ContraptionAttributes.class) .setVert(Locations.CONTRAPTION_STRUCTURE) .setFrag(Locations.BLOCK) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); - public static final ProgramSpec C_MODEL = register(ProgramSpec.builder("contraption_model", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) - .addAttributes(ModelAttributes.class) - .addAttributes(BasicAttributes.class) - .addAttributes(TransformAttributes.class) - .setVert(Locations.MODEL_VERT) - .setFrag(Locations.BLOCK) - .setDefines(ShaderConstants.define("CONTRAPTION")) - .createProgramSpec()); - public static final ProgramSpec C_ORIENTED = register(ProgramSpec.builder("contraption_oriented", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) - .addAttributes(ModelAttributes.class) - .addAttributes(BasicAttributes.class) - .addAttributes(OrientedAttributes.class) - .setVert(Locations.ORIENTED) - .setFrag(Locations.BLOCK) - .setDefines(ShaderConstants.define("CONTRAPTION")) - .createProgramSpec()); - public static final ProgramSpec C_ROTATING = register(ProgramSpec.builder("contraption_rotating", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) - .addAttributes(ModelAttributes.class) - .addAttributes(BasicAttributes.class) - .addAttributes(KineticAttributes.class) - .addAttributes(RotatingAttributes.class) - .setVert(Locations.ROTATING) - .setFrag(Locations.BLOCK) - .setDefines(ShaderConstants.define("CONTRAPTION")) - .createProgramSpec()); - public static final ProgramSpec C_BELT = register(ProgramSpec.builder("contraption_belt", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) - .addAttributes(ModelAttributes.class) - .addAttributes(BasicAttributes.class) - .addAttributes(KineticAttributes.class) - .addAttributes(BeltAttributes.class) - .setVert(Locations.BELT) - .setFrag(Locations.BLOCK) - .setDefines(ShaderConstants.define("CONTRAPTION")) - .createProgramSpec()); - public static final ProgramSpec C_FLAPS = register(ProgramSpec.builder("contraption_flap", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) - .addAttributes(ModelAttributes.class) - .addAttributes(FlapAttributes.class) - .setVert(Locations.FLAP) - .setFrag(Locations.BLOCK) - .setDefines(ShaderConstants.define("CONTRAPTION")) - .createProgramSpec()); - public static final ProgramSpec C_ACTOR = register(ProgramSpec.builder("contraption_actor", new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)) + public static final ProgramSpec C_ACTOR = register(builder("contraption_actor") .addAttributes(ModelAttributes.class) .addAttributes(ActorVertexAttributes.class) .setVert(Locations.CONTRAPTION_ACTOR) @@ -131,6 +85,9 @@ public class AllProgramSpecs { .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); + public static ProgramSpec.Builder builder(String name) { + return ProgramSpec.builder(new ResourceLocation(Create.ID, name)); + } public static class Locations { public static final ResourceLocation BLOCK = loc("block.frag"); diff --git a/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java b/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java deleted file mode 100644 index 93cc288bd..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/KineticRenderer.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.simibubi.create.foundation.render; - -import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; -import com.jozufozu.flywheel.backend.instancing.RenderMaterial; -import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; -import com.simibubi.create.content.contraptions.base.RotatingModel; -import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; -import com.simibubi.create.content.logistics.block.FlapModel; - -public class KineticRenderer extends BasicInstancedTileRenderer { - - @Override - public void registerMaterials() { - super.registerMaterials(); - - materials.put(KineticRenderMaterials.BELTS, - new RenderMaterial<>(this, AllProgramSpecs.BELT, BeltInstancedModel::new)); - materials.put(KineticRenderMaterials.ROTATING, - new RenderMaterial<>(this, AllProgramSpecs.ROTATING, RotatingModel::new)); - materials.put(KineticRenderMaterials.FLAPS, new RenderMaterial<>(this, AllProgramSpecs.FLAPS, FlapModel::new)); - } -} diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag index f1562aad4..09918fb48 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag @@ -1,3 +1,5 @@ +#flwinclude <"create:std/fog.glsl"> + varying vec3 BoxCoord; uniform sampler3D uLightVolume; diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag index 347537366..e89cfaf00 100644 --- a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag @@ -1,9 +1,5 @@ #flwinclude <"create:std/fog.glsl"> -#if defined(CONTRAPTION) -#flwinclude <"create:contraption/builtin.frag"> -#else - void FLWFinalizeColor(vec4 color) { #if defined(USE_FOG) float a = color.a; @@ -18,4 +14,3 @@ vec4 FLWLight(vec2 lightCoords, sampler2D lightMap) { vec2 lm = lightCoords * 0.9375 + 0.03125; return texture2D(lightMap, lm); } - #endif diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert index 5c542b77f..c5279bf75 100644 --- a/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert +++ b/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert @@ -1,6 +1,3 @@ -#if defined(CONTRAPTION) -#flwinclude <"create:contraption/builtin.vert"> -#else #if defined(USE_FOG) varying float FragDistance; @@ -15,4 +12,3 @@ void FLWFinalizeWorldPos(inout vec4 worldPos, vec3 cameraPos) { void FLWFinalizeNormal(inout vec3 normal) { // noop } - #endif From b6f13aa7ff1d25d23c06831cfe0281f5fea4d1ad Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 4 May 2021 16:22:27 -0700 Subject: [PATCH 024/198] More granularity for shader context loading --- .../backend/FastRenderDispatcher.java | 16 ++--- .../flywheel/backend/ShaderContext.java | 9 +-- .../backend/core/ContraptionContext.java | 7 +++ .../flywheel/backend/core/WorldContext.java | 61 +++++++------------ ...MaterialFactory.java => MaterialSpec.java} | 16 +++-- .../render/ContraptionRenderDispatcher.java | 2 +- .../foundation/render/AllProgramSpecs.java | 4 +- 7 files changed, 54 insertions(+), 61 deletions(-) rename src/main/java/com/jozufozu/flywheel/backend/instancing/{MaterialFactory.java => MaterialSpec.java} (55%) diff --git a/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java b/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java index cc796f7f0..4f936d889 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java +++ b/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java @@ -7,7 +7,7 @@ import java.util.concurrent.ConcurrentHashMap; import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.jozufozu.flywheel.backend.core.OrientedModel; import com.jozufozu.flywheel.backend.core.TransformedModel; -import com.jozufozu.flywheel.backend.instancing.MaterialFactory; +import com.jozufozu.flywheel.backend.instancing.MaterialSpec; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; @@ -28,7 +28,7 @@ import net.minecraft.world.World; public class FastRenderDispatcher { - public static Map, MaterialFactory> materials = new HashMap<>(); + public static Map, MaterialSpec> materials = new HashMap<>(); static { registerMaterials(); @@ -37,12 +37,12 @@ public class FastRenderDispatcher { public static WorldAttached> queuedUpdates = new WorldAttached<>(ConcurrentHashMap::newKeySet); public static void registerMaterials() { - materials.put(MaterialTypes.TRANSFORMED, new MaterialFactory(AllProgramSpecs.MODEL, TransformedModel::new)); - materials.put(MaterialTypes.ORIENTED, new MaterialFactory(AllProgramSpecs.ORIENTED, OrientedModel::new)); - materials.put(KineticRenderMaterials.BELTS, new MaterialFactory(AllProgramSpecs.BELT, BeltInstancedModel::new)); - materials.put(KineticRenderMaterials.ROTATING, new MaterialFactory(AllProgramSpecs.ROTATING, RotatingModel::new)); - materials.put(KineticRenderMaterials.FLAPS, new MaterialFactory(AllProgramSpecs.FLAPS, FlapModel::new)); - materials.put(KineticRenderMaterials.ACTORS, new MaterialFactory(AllProgramSpecs.C_ACTOR, ActorModel::new)); + materials.put(MaterialTypes.TRANSFORMED, new MaterialSpec(AllProgramSpecs.MODEL, TransformedModel::new)); + materials.put(MaterialTypes.ORIENTED, new MaterialSpec(AllProgramSpecs.ORIENTED, OrientedModel::new)); + materials.put(KineticRenderMaterials.BELTS, new MaterialSpec(AllProgramSpecs.BELT, BeltInstancedModel::new)); + materials.put(KineticRenderMaterials.ROTATING, new MaterialSpec(AllProgramSpecs.ROTATING, RotatingModel::new)); + materials.put(KineticRenderMaterials.FLAPS, new MaterialSpec(AllProgramSpecs.FLAPS, FlapModel::new)); + materials.put(KineticRenderMaterials.ACTORS, new MaterialSpec(AllProgramSpecs.ACTOR, ActorModel::new)); } public static void enqueueUpdate(TileEntity te) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java index b416318a9..c72614242 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java @@ -23,14 +23,7 @@ public abstract class ShaderContext

{ public abstract ShaderSpecLoader

getLoader(); - public void load(ShaderLoader loader) { - programs.values().forEach(IMultiProgram::delete); - programs.clear(); - - for (ProgramSpec programSpec : Backend.specRegistry.values()) { - loadProgramFromSpec(loader, programSpec); - } - } + public abstract void load(ShaderLoader loader); public void loadProgramFromSpec(ShaderLoader loader, ProgramSpec programSpec) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java index e90310d62..c08f37516 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java @@ -1,7 +1,9 @@ package com.jozufozu.flywheel.backend.core; +import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram; +import com.simibubi.create.foundation.render.AllProgramSpecs; import net.minecraft.util.ResourceLocation; @@ -13,5 +15,10 @@ public class ContraptionContext extends WorldContext { super(new ResourceLocation("create", "contraption"), new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)); } + @Override + public void load(ShaderLoader loader) { + super.load(loader); + loadProgramFromSpec(loader, AllProgramSpecs.STRUCTURE); + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index 74d95aa7a..1d354bf00 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -1,16 +1,18 @@ package com.jozufozu.flywheel.backend.core; -import java.util.regex.Matcher; +import java.util.EnumMap; +import java.util.Map; import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; +import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.jozufozu.flywheel.backend.ResourceUtil; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; +import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; +import com.jozufozu.flywheel.backend.instancing.MaterialSpec; import net.minecraft.util.ResourceLocation; @@ -22,51 +24,34 @@ public class WorldContext

extends ShaderContext

{ private final ShaderSpecLoader

loader; - public final ResourceLocation frag; - public final ResourceLocation vert; + final Map builtins; public WorldContext(ResourceLocation root, ShaderSpecLoader

loader) { super(root); - this.frag = ResourceUtil.subPath(root, "/builtin.frag"); - this.vert = ResourceUtil.subPath(root, "/builtin.vert"); + builtins = new EnumMap<>(ShaderType.class); + builtins.put(ShaderType.FRAGMENT, ResourceUtil.subPath(root, "/builtin.frag")); + builtins.put(ShaderType.VERTEX, ResourceUtil.subPath(root, "/builtin.vert")); this.loader = loader; } + @Override + public void load(ShaderLoader loader) { + programs.values().forEach(IMultiProgram::delete); + programs.clear(); + + FastRenderDispatcher.materials.values() + .stream() + .map(MaterialSpec::getProgramSpec) + .forEach(spec -> loadProgramFromSpec(loader, spec)); + } + @Override public String preProcess(ShaderLoader loader, String shaderSrc, ShaderType type) { - return ShaderLoader.lines(shaderSrc).flatMap(line -> { - Matcher matcher = builtinPattern.matcher(line); + String builtinSrc = loader.getShaderSource(builtins.get(type)); - if (matcher.find()) { - ResourceLocation builtins; - - switch (type) { - case FRAGMENT: - builtins = frag; - break; - case VERTEX: - builtins = vert; - break; - default: - builtins = null; - } - - String includeSource = loader.getShaderSource(builtins); - - return ShaderLoader.lines(includeSource); - } - - return Stream.of(line); - }).collect(Collectors.joining("\n")); - } - - public ResourceLocation getFrag() { - return frag; - } - - public ResourceLocation getVert() { - return vert; + return builtinPattern.matcher(shaderSrc) + .replaceFirst(builtinSrc); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialFactory.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java similarity index 55% rename from src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialFactory.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java index ab6e4cd47..17f357531 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialFactory.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java @@ -3,16 +3,24 @@ package com.jozufozu.flywheel.backend.instancing; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; -public class MaterialFactory { +public class MaterialSpec { - ProgramSpec programSpec; - ModelFactory modelFactory; + private final ProgramSpec programSpec; + private final ModelFactory modelFactory; - public MaterialFactory(ProgramSpec programSpec, ModelFactory modelFactory) { + public MaterialSpec(ProgramSpec programSpec, ModelFactory modelFactory) { this.programSpec = programSpec; this.modelFactory = modelFactory; } + public ProgramSpec getProgramSpec() { + return programSpec; + } + + public ModelFactory getModelFactory() { + return modelFactory; + } + public

RenderMaterial create(InstancedTileRenderer

renderer) { return new RenderMaterial<>(renderer, programSpec, modelFactory); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index e99f883cf..295bf70b9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -82,7 +82,7 @@ public class ContraptionRenderDispatcher { GL13.glActiveTexture(GL40.GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 if (Backend.canUseVBOs()) { - ContraptionProgram structureShader = ContraptionContext.INSTANCE.getProgram(AllProgramSpecs.C_STRUCTURE); + ContraptionProgram structureShader = ContraptionContext.INSTANCE.getProgram(AllProgramSpecs.STRUCTURE); structureShader.bind(viewProjection, camX, camY, camZ, FastRenderDispatcher.getDebugMode()); for (RenderedContraption renderer : renderers.values()) { renderer.doRenderLayer(layer, structureShader); diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index af8ab05b6..3756d453e 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -71,13 +71,13 @@ public class AllProgramSpecs { .setVert(Locations.FLAP) .setFrag(Locations.BLOCK) .createProgramSpec()); - public static final ProgramSpec C_STRUCTURE = register(builder("contraption_structure") + public static final ProgramSpec STRUCTURE = register(builder("contraption_structure") .addAttributes(ContraptionAttributes.class) .setVert(Locations.CONTRAPTION_STRUCTURE) .setFrag(Locations.BLOCK) .setDefines(ShaderConstants.define("CONTRAPTION")) .createProgramSpec()); - public static final ProgramSpec C_ACTOR = register(builder("contraption_actor") + public static final ProgramSpec ACTOR = register(builder("contraption_actor") .addAttributes(ModelAttributes.class) .addAttributes(ActorVertexAttributes.class) .setVert(Locations.CONTRAPTION_ACTOR) From 55e3f50f64ee7f9c2cce2fb2165bec337471783b Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 4 May 2021 21:00:55 -0700 Subject: [PATCH 025/198] MaterialSpecs act alone - No more awkward MaterialType/MaterialSpec business - MaterialTypes are registered directly - FastRenderDispatcher merged with backend --- .../jozufozu/flywheel/backend/Backend.java | 94 +++++++++++++++++- .../backend/FastRenderDispatcher.java | 98 ------------------- .../flywheel/backend/MaterialType.java | 11 --- .../flywheel/backend/MaterialTypes.java | 10 -- .../flywheel/backend/core/WorldContext.java | 4 +- .../instancing/InstancedTileRenderer.java | 22 ++--- .../backend/instancing/MaterialSpec.java | 15 ++- .../backend/instancing/RenderMaterial.java | 4 +- .../com/simibubi/create/CreateClient.java | 2 + .../base/KineticRenderMaterials.java | 16 --- .../contraptions/base/KineticTileEntity.java | 6 +- .../base/KineticTileEntityRenderer.java | 4 +- .../base/KineticTileInstance.java | 3 +- .../base/ShaftlessCogInstance.java | 3 +- .../actors/DrillMovementBehaviour.java | 4 +- .../actors/HarvesterMovementBehaviour.java | 4 +- .../crafter/MechanicalCrafterRenderer.java | 4 +- .../components/crank/HandCrankRenderer.java | 4 +- .../deployer/DeployerActorInstance.java | 8 +- .../deployer/DeployerMovementBehaviour.java | 4 +- .../components/deployer/DeployerRenderer.java | 6 +- .../components/fan/EncasedFanRenderer.java | 4 +- .../components/flywheel/FlywheelRenderer.java | 4 +- .../flywheel/engine/EngineRenderer.java | 6 +- .../mixer/MechanicalMixerRenderer.java | 4 +- .../press/MechanicalPressRenderer.java | 4 +- .../components/saw/SawRenderer.java | 4 +- .../bearing/BearingRenderer.java | 4 +- .../StabilizedBearingMovementBehaviour.java | 4 +- .../chassis/StickerRenderer.java | 4 +- .../chassis/StickerTileEntity.java | 4 +- .../gantry/GantryCarriageRenderer.java | 6 +- .../pulley/AbstractPulleyRenderer.java | 4 +- .../render/ContraptionKineticRenderer.java | 4 +- .../render/ContraptionRenderDispatcher.java | 3 +- .../fluids/pipes/FluidValveRenderer.java | 4 +- .../advanced/SpeedControllerRenderer.java | 4 +- .../relays/belt/BeltInstance.java | 4 +- .../relays/belt/BeltRenderer.java | 4 +- .../relays/belt/BeltTileEntity.java | 4 +- .../relays/encased/SplitShaftRenderer.java | 4 +- .../relays/gauge/GaugeRenderer.java | 4 +- .../relays/gearbox/GearboxRenderer.java | 4 +- .../belts/tunnel/BeltTunnelInstance.java | 6 +- .../belts/tunnel/BeltTunnelRenderer.java | 4 +- .../belts/tunnel/BeltTunnelTileEntity.java | 4 +- .../block/depot/EjectorRenderer.java | 6 +- .../block/funnel/FunnelInstance.java | 10 +- .../block/funnel/FunnelRenderer.java | 4 +- .../block/funnel/FunnelTileEntity.java | 4 +- .../block/mechanicalArm/ArmRenderer.java | 6 +- .../block/redstone/AnalogLeverRenderer.java | 4 +- .../block/SchematicannonRenderer.java | 4 +- .../simibubi/create/events/ClientEvents.java | 4 +- .../command/ConfigureConfigPacket.java | 8 +- .../mixin/CancelTileEntityRenderMixin.java | 4 +- .../foundation/mixin/RenderHooksMixin.java | 3 +- .../foundation/render/AllMaterialSpecs.java | 45 +++++++++ .../ColoredOverlayTileEntityRenderer.java | 4 +- 59 files changed, 270 insertions(+), 267 deletions(-) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/MaterialType.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/MaterialTypes.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/base/KineticRenderMaterials.java create mode 100644 src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index 6bad69303..b406c55d0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -1,25 +1,38 @@ package com.jozufozu.flywheel.backend; +import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; +import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.jozufozu.flywheel.backend.core.ContraptionContext; import com.jozufozu.flywheel.backend.core.EffectsContext; import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.effects.EffectsHandler; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.MaterialSpec; +import com.simibubi.create.CreateClient; +import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.utility.WorldAttached; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.resources.IResourceManager; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.world.World; @@ -35,12 +48,14 @@ public class Backend { public static GLCapabilities capabilities; public static GlCompat compat; + public static WorldAttached> queuedUpdates = new WorldAttached<>(ConcurrentHashMap::newKeySet); private static boolean instancingAvailable; private static boolean enabled; + static Map> materialRegistry = new HashMap<>(); static final Map> contexts = new HashMap<>(); - static final Map specRegistry = new HashMap<>(); + static final Map programSpecRegistry = new HashMap<>(); static { register(WorldContext.INSTANCE); @@ -57,17 +72,17 @@ public class Backend { */ public static ProgramSpec register(ProgramSpec spec) { ResourceLocation name = spec.name; - if (specRegistry.containsKey(name)) { + if (programSpecRegistry.containsKey(name)) { throw new IllegalStateException("Program spec '" + name + "' already registered."); } - specRegistry.put(name, spec); + programSpecRegistry.put(name, spec); return spec; } /** * Register a shader context. */ - public static ShaderContext register(ShaderContext spec) { + public static

ShaderContext

register(ShaderContext

spec) { ResourceLocation name = spec.getRoot(); if (contexts.containsKey(name)) { throw new IllegalStateException("Program spec '" + name + "' already registered."); @@ -76,6 +91,18 @@ public class Backend { return spec; } + /** + * Register an instancing material. + */ + public static > MaterialSpec register(MaterialSpec spec) { + ResourceLocation name = spec.name; + if (materialRegistry.containsKey(name)) { + throw new IllegalStateException("Material spec '" + name + "' already registered."); + } + materialRegistry.put(name, spec); + return spec; + } + public static boolean isFlywheelWorld(World world) { return world == Minecraft.getInstance().world || (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()); } @@ -129,4 +156,63 @@ public class Backend { effects = new EffectsHandler(); } } + + public static void tick() { + Minecraft mc = Minecraft.getInstance(); + ClientWorld world = mc.world; + + BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + + Entity renderViewEntity = mc.renderViewEntity; + kineticRenderer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ()); + + ConcurrentHashMap.KeySetView map = queuedUpdates.get(world); + map + .forEach(te -> { + map.remove(te); + + kineticRenderer.update(te); + }); + } + + public static void renderLayer(RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { + if (!canUseInstancing()) return; + + ClientWorld world = Minecraft.getInstance().world; + BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + + layer.startDrawing(); + + kineticRenderer.render(layer, viewProjection, cameraX, cameraY, cameraZ); + + layer.endDrawing(); + } + + public static void enqueueUpdate(TileEntity te) { + queuedUpdates.get(te.getWorld()).add(te); + } + + public static void reloadWorldRenderers() { + RenderWork.enqueue(Minecraft.getInstance().worldRenderer::loadRenderers); + } + + public static boolean canUseInstancing(World world) { + return canUseInstancing() && isFlywheelWorld(world); + } + + /** + * TODO: Remove in favor of separate debug programs specified by the SpecLoader/IMultiProgram + */ + @Deprecated + public static int getDebugMode() { + return KineticDebugger.isActive() ? 1 : 0; + } + + public static Collection> allMaterials() { + return materialRegistry.values(); + } + + public static Collection allPrograms() { + return programSpecRegistry.values(); + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java b/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java deleted file mode 100644 index 4f936d889..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/FastRenderDispatcher.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.jozufozu.flywheel.backend; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; -import com.jozufozu.flywheel.backend.core.OrientedModel; -import com.jozufozu.flywheel.backend.core.TransformedModel; -import com.jozufozu.flywheel.backend.instancing.MaterialSpec; -import com.simibubi.create.CreateClient; -import com.simibubi.create.content.contraptions.KineticDebugger; -import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; -import com.simibubi.create.content.contraptions.base.RotatingModel; -import com.simibubi.create.content.contraptions.components.actors.ActorModel; -import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; -import com.simibubi.create.content.logistics.block.FlapModel; -import com.simibubi.create.foundation.render.AllProgramSpecs; -import com.simibubi.create.foundation.utility.WorldAttached; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.world.World; - -public class FastRenderDispatcher { - - public static Map, MaterialSpec> materials = new HashMap<>(); - - static { - registerMaterials(); - } - - public static WorldAttached> queuedUpdates = new WorldAttached<>(ConcurrentHashMap::newKeySet); - - public static void registerMaterials() { - materials.put(MaterialTypes.TRANSFORMED, new MaterialSpec(AllProgramSpecs.MODEL, TransformedModel::new)); - materials.put(MaterialTypes.ORIENTED, new MaterialSpec(AllProgramSpecs.ORIENTED, OrientedModel::new)); - materials.put(KineticRenderMaterials.BELTS, new MaterialSpec(AllProgramSpecs.BELT, BeltInstancedModel::new)); - materials.put(KineticRenderMaterials.ROTATING, new MaterialSpec(AllProgramSpecs.ROTATING, RotatingModel::new)); - materials.put(KineticRenderMaterials.FLAPS, new MaterialSpec(AllProgramSpecs.FLAPS, FlapModel::new)); - materials.put(KineticRenderMaterials.ACTORS, new MaterialSpec(AllProgramSpecs.ACTOR, ActorModel::new)); - } - - public static void enqueueUpdate(TileEntity te) { - queuedUpdates.get(te.getWorld()).add(te); - } - - public static void tick() { - Minecraft mc = Minecraft.getInstance(); - ClientWorld world = mc.world; - - BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); - - Entity renderViewEntity = mc.renderViewEntity; - kineticRenderer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ()); - - ConcurrentHashMap.KeySetView map = queuedUpdates.get(world); - map - .forEach(te -> { - map.remove(te); - - kineticRenderer.update(te); - }); - } - - public static boolean available() { - return Backend.canUseInstancing(); - } - - public static boolean available(World world) { - return Backend.canUseInstancing() && Backend.isFlywheelWorld(world); - } - - public static int getDebugMode() { - return KineticDebugger.isActive() ? 1 : 0; - } - - public static void refresh() { - RenderWork.enqueue(Minecraft.getInstance().worldRenderer::loadRenderers); - } - - public static void renderLayer(RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { - if (!Backend.canUseInstancing()) return; - - ClientWorld world = Minecraft.getInstance().world; - BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); - - layer.startDrawing(); - - kineticRenderer.render(layer, viewProjection, cameraX, cameraY, cameraZ); - - layer.endDrawing(); - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/MaterialType.java b/src/main/java/com/jozufozu/flywheel/backend/MaterialType.java deleted file mode 100644 index 7e55c49d6..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/MaterialType.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.jozufozu.flywheel.backend; - -import com.jozufozu.flywheel.backend.instancing.InstancedModel; - -public class MaterialType> { - - @Override - public int hashCode() { - return super.hashCode() * 31 * 493286711; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/MaterialTypes.java b/src/main/java/com/jozufozu/flywheel/backend/MaterialTypes.java deleted file mode 100644 index 2ac7fe4d1..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/MaterialTypes.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.jozufozu.flywheel.backend; - -import com.jozufozu.flywheel.backend.core.ModelData; -import com.jozufozu.flywheel.backend.core.OrientedData; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; - -public class MaterialTypes { - public static final MaterialType> TRANSFORMED = new MaterialType<>(); - public static final MaterialType> ORIENTED = new MaterialType<>(); -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index 1d354bf00..360d602aa 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -4,7 +4,7 @@ import java.util.EnumMap; import java.util.Map; import java.util.regex.Pattern; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.ResourceUtil; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; @@ -40,7 +40,7 @@ public class WorldContext

extends ShaderContext

{ programs.values().forEach(IMultiProgram::delete); programs.clear(); - FastRenderDispatcher.materials.values() + Backend.allMaterials() .stream() .map(MaterialSpec::getProgramSpec) .forEach(spec -> loadProgramFromSpec(loader, spec)); diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java index 514549550..b02958d26 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java @@ -7,14 +7,12 @@ import java.util.Map; import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; -import com.jozufozu.flywheel.backend.MaterialType; -import com.jozufozu.flywheel.backend.MaterialTypes; -import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.ModelData; import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; +import com.simibubi.create.foundation.render.AllMaterialSpecs; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; @@ -34,17 +32,19 @@ public abstract class InstancedTileRenderer

{ protected Map tickableInstances = new HashMap<>(); protected Map dynamicInstances = new HashMap<>(); - public final ShaderContext

context; + public final WorldContext

context; - protected Map, RenderMaterial> materials = new HashMap<>(); + protected Map, RenderMaterial> materials = new HashMap<>(); protected int frame; protected int tick; - protected InstancedTileRenderer(ShaderContext

context) { + protected InstancedTileRenderer(WorldContext

context) { this.context = context; - FastRenderDispatcher.materials.forEach((key, value) -> materials.put(key, value.create(this))); + for (MaterialSpec spec : Backend.allMaterials()) { + materials.put(spec, spec.create(this)); + } } public abstract BlockPos getOriginCoordinate(); @@ -115,16 +115,16 @@ public abstract class InstancedTileRenderer

{ } @SuppressWarnings("unchecked") - public > RenderMaterial getMaterial(MaterialType materialType) { + public > RenderMaterial getMaterial(MaterialSpec materialType) { return (RenderMaterial) materials.get(materialType); } public RenderMaterial> getTransformMaterial() { - return getMaterial(MaterialTypes.TRANSFORMED); + return getMaterial(AllMaterialSpecs.TRANSFORMED); } public RenderMaterial> getOrientedMaterial() { - return getMaterial(MaterialTypes.ORIENTED); + return getMaterial(AllMaterialSpecs.ORIENTED); } @SuppressWarnings("unchecked") diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java index 17f357531..8e319f98d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java @@ -3,12 +3,17 @@ package com.jozufozu.flywheel.backend.instancing; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; -public class MaterialSpec { +import net.minecraft.util.ResourceLocation; + +public class MaterialSpec> { + + public final ResourceLocation name; private final ProgramSpec programSpec; - private final ModelFactory modelFactory; + private final ModelFactory modelFactory; - public MaterialSpec(ProgramSpec programSpec, ModelFactory modelFactory) { + public MaterialSpec(ResourceLocation name, ProgramSpec programSpec, ModelFactory modelFactory) { + this.name = name; this.programSpec = programSpec; this.modelFactory = modelFactory; } @@ -17,11 +22,11 @@ public class MaterialSpec { return programSpec; } - public ModelFactory getModelFactory() { + public ModelFactory getModelFactory() { return modelFactory; } - public

RenderMaterial create(InstancedTileRenderer

renderer) { + public

RenderMaterial create(InstancedTileRenderer

renderer) { return new RenderMaterial<>(renderer, programSpec, modelFactory); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index cfbe4affc..7f1e95405 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -9,7 +9,7 @@ import org.apache.commons.lang3.tuple.Pair; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.RenderUtil; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.PartialModel; @@ -62,7 +62,7 @@ public class RenderMaterial

setup) { P program = renderer.context.getProgram(programSpec); - program.bind(viewProjection, camX, camY, camZ, FastRenderDispatcher.getDebugMode()); + program.bind(viewProjection, camX, camY, camZ, Backend.getDebugMode()); if (setup != null) setup.call(program); diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index d73a79237..fe230c877 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -27,6 +27,7 @@ import com.simibubi.create.foundation.item.CustomItemModels; import com.simibubi.create.foundation.item.CustomRenderedItems; import com.simibubi.create.foundation.ponder.content.PonderIndex; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; +import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.utility.WorldAttached; @@ -88,6 +89,7 @@ public class CreateClient { public static void clientInit(FMLClientSetupEvent event) { AllProgramSpecs.init(); + AllMaterialSpecs.init(); kineticRenderer = new WorldAttached<>(BasicInstancedTileRenderer::new); schematicSender = new ClientSchematicLoader(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticRenderMaterials.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticRenderMaterials.java deleted file mode 100644 index d71c65ee6..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticRenderMaterials.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.simibubi.create.content.contraptions.base; - -import com.jozufozu.flywheel.backend.MaterialType; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; -import com.simibubi.create.content.contraptions.components.actors.ActorData; -import com.simibubi.create.content.contraptions.relays.belt.BeltData; -import com.simibubi.create.content.logistics.block.FlapData; - -public class KineticRenderMaterials { - public static final MaterialType> ROTATING = new MaterialType<>(); - public static final MaterialType> BELTS = new MaterialType<>(); - - public static final MaterialType> ACTORS = new MaterialType<>(); - - public static final MaterialType> FLAPS = new MaterialType<>(); -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java index 653240307..a3e7dad01 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java @@ -7,7 +7,7 @@ import java.util.List; import javax.annotation.Nullable; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.KineticNetwork; @@ -257,7 +257,7 @@ public abstract class KineticTileEntity extends SmartTileEntity effects.triggerOverStressedEffect(); if (clientPacket) - FastRenderDispatcher.enqueueUpdate(this); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Backend.enqueueUpdate(this)); } public float getGeneratedSpeed() { @@ -552,7 +552,7 @@ public abstract class KineticTileEntity extends SmartTileEntity public void requestModelDataUpdate() { super.requestModelDataUpdate(); if (!this.removed) { - FastRenderDispatcher.enqueueUpdate(this); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Backend.enqueueUpdate(this)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java index e86972c03..707679a35 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.base; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlocks; @@ -39,7 +39,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer extends T } protected final RenderMaterial> getRotatingMaterial() { - return renderer.getMaterial(KineticRenderMaterials.ROTATING); + return renderer.getMaterial(AllMaterialSpecs.ROTATING); } public static BlockState shaft(Direction.Axis axis) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessCogInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessCogInstance.java index 733c23a01..533b95ece 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessCogInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessCogInstance.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.foundation.render.AllMaterialSpecs; public class ShaftlessCogInstance extends SingleRotatingInstance { @@ -12,6 +13,6 @@ public class ShaftlessCogInstance extends SingleRotatingInstance { @Override protected InstancedModel getModel() { - return renderer.getMaterial(KineticRenderMaterials.ROTATING).getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, tile.getBlockState()); + return renderer.getMaterial(AllMaterialSpecs.ROTATING).getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, tile.getBlockState()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java index 3eeb3f58b..5ebac5064 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors; import javax.annotation.Nullable; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; @@ -36,7 +36,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour { @OnlyIn(value = Dist.CLIENT) public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - if (!FastRenderDispatcher.available()) + if (!Backend.canUseInstancing()) DrillRenderer.renderInContraption(context, ms, msLocal, buffer); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java index 83b6a4bcc..88433f8e8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -6,7 +6,7 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.mutable.MutableBoolean; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; @@ -54,7 +54,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { @Override public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffers) { - if (!FastRenderDispatcher.available()) + if (!Backend.canUseInstancing()) HarvesterRenderer.renderInContraption(context, ms, msLocal, buffers); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java index b30da5db0..8aa4b126e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.crafter; import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING; import static com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer.standardKineticRotationTransform; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; @@ -156,7 +156,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer renderItem(te, partialTicks, ms, buffer, light, overlay); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; renderComponents(te, partialTicks, ms, buffer, light, overlay); } @@ -111,7 +111,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer protected void renderComponents(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); - if (!FastRenderDispatcher.available(te.getWorld())) { + if (!Backend.canUseInstancing(te.getWorld())) { KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java index ec49792ae..86bc2274c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.fan; import static net.minecraft.state.properties.BlockStateProperties.FACING; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -28,7 +28,7 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; Direction direction = te.getBlockState() .get(FACING); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java index edbe2baae..b4b0370b6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.flywheel; import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -36,7 +36,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; BlockState blockState = te.getBlockState(); FlywheelTileEntity wte = (FlywheelTileEntity) te; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java index a47c32400..017dd5e10 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.render.PartialBufferer; @@ -24,10 +24,10 @@ public class EngineRenderer extends SafeTileEntityRe protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; Block block = te.getBlockState() - .getBlock(); + .getBlock(); if (block instanceof EngineBlock) { EngineBlock engineBlock = (EngineBlock) block; PartialModel frame = engineBlock.getFrameModel(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java index da872236b..e0ab0cbae 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.mixer; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -33,7 +33,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; BlockState blockState = te.getBlockState(); MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java index 9ce1c3d8c..04a61fecf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.press; import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; @@ -33,7 +33,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; BlockPos pos = te.getPos(); BlockState blockState = te.getBlockState(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index 5b267707e..81a646166 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.saw; import static net.minecraft.state.properties.BlockStateProperties.FACING; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; @@ -47,7 +47,7 @@ public class SawRenderer extends SafeTileEntityRenderer { renderItems(te, partialTicks, ms, buffer, light, overlay); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; renderShaft(te, ms, buffer, light, overlay); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java index 647a3423b..02fd58228 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.bearing; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; @@ -26,7 +26,7 @@ public class BearingRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java index ba09371d2..91b0cf846 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be import javax.annotation.Nullable; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; @@ -33,7 +33,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - if (FastRenderDispatcher.available()) return; + if (Backend.canUseInstancing()) return; Direction facing = context.state.get(BlockStateProperties.FACING); PartialModel top = AllBlockPartials.BEARING_TOP; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java index d100d7e9d..d15365d66 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.chassis; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; @@ -26,7 +26,7 @@ public class StickerRenderer extends SafeTileEntityRenderer { protected void renderSafe(StickerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; BlockState state = te.getBlockState(); SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.STICKER_HEAD, state); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java index 0dcb89f85..1b6da372e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerTileEntity.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch import java.util.List; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllSoundEvents; @@ -70,7 +70,7 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> playSound(false)); piston.chase(target, .4f, Chaser.LINEAR); - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> FastRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Backend.enqueueUpdate(this)); } public boolean isAttachedToBlock() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java index cfdeb46b1..a081357f3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.gantry; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; @@ -32,14 +32,14 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; BlockState state = te.getBlockState(); Direction facing = state.get(GantryCarriageBlock.FACING); Boolean alongFirst = state.get(GantryCarriageBlock.AXIS_ALONG_FIRST_COORDINATE); Axis rotationAxis = getRotationAxisOf(te); BlockPos visualPos = facing.getAxisDirection() == AxisDirection.POSITIVE ? te.getPos() - : te.getPos() + : te.getPos() .offset(facing.getOpposite()); float angleForTe = getAngleForTe(te, visualPos, rotationAxis); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java index f1fa89220..13c77dca6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; @@ -44,7 +44,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); float offset = getOffset(te, partialTicks); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java index 514aa3b41..ae766a36c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java @@ -12,10 +12,10 @@ import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.AllMovementBehaviours; -import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.contraptions.components.actors.ActorData; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.foundation.render.AllMaterialSpecs; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.util.math.BlockPos; @@ -67,7 +67,7 @@ public class ContraptionKineticRenderer extends InstancedTileRenderer> getActorMaterial() { - return getMaterial(KineticRenderMaterials.ACTORS); + return getMaterial(AllMaterialSpecs.ACTORS); } public RenderedContraption getContraption() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 295bf70b9..e87a6d9ab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -9,7 +9,6 @@ import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL40; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.jozufozu.flywheel.backend.core.ContraptionContext; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllMovementBehaviours; @@ -83,7 +82,7 @@ public class ContraptionRenderDispatcher { if (Backend.canUseVBOs()) { ContraptionProgram structureShader = ContraptionContext.INSTANCE.getProgram(AllProgramSpecs.STRUCTURE); - structureShader.bind(viewProjection, camX, camY, camZ, FastRenderDispatcher.getDebugMode()); + structureShader.bind(viewProjection, camX, camY, camZ, Backend.getDebugMode()); for (RenderedContraption renderer : renderers.values()) { renderer.doRenderLayer(layer, structureShader); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java index 5ea1d6dc5..af24a5362 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.fluids.pipes; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; @@ -28,7 +28,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer { protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); BlockState blockState = te.getBlockState(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java index b3a66b92e..d8bac663e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.relays.advanced; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -32,7 +32,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer { PartialModel beltPartial = BeltRenderer.getBeltPartial(diagonal, start, end, bottom); SpriteShiftEntry spriteShift = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom); - InstancedModel beltModel = modelManager.getMaterial(KineticRenderMaterials.BELTS).getModel(beltPartial, blockState); + InstancedModel beltModel = modelManager.getMaterial(AllMaterialSpecs.BELTS).getModel(beltPartial, blockState); keys.add(setup(beltModel.createInstance(), bottom, spriteShift)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java index 076fa64d2..0857cfe60 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.relays.belt; import java.util.Random; import java.util.function.Supplier; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; @@ -57,7 +57,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { protected void renderSafe(BeltTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (!FastRenderDispatcher.available(te.getWorld())) { + if (!Backend.canUseInstancing(te.getWorld())) { BlockState blockState = te.getBlockState(); if (!AllBlocks.BELT.has(blockState)) return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java index ed7028eec..9dbf9e00c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java @@ -12,7 +12,7 @@ import java.util.Map; import java.util.Optional; import java.util.function.Function; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.jozufozu.flywheel.backend.light.LightUpdateListener; import com.jozufozu.flywheel.backend.light.LightUpdater; @@ -267,7 +267,7 @@ public class BeltTileEntity extends KineticTileEntity implements LightUpdateList belt.color = Optional.ofNullable(colorIn); belt.markDirty(); belt.sendData(); - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> FastRenderDispatcher.enqueueUpdate(belt)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Backend.enqueueUpdate(belt)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java index c8016ed47..3997ce182 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.relays.encased; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.IRotate; @@ -28,7 +28,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; Block block = te.getBlockState().getBlock(); final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java index 1588b1c77..01a5a7e7f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.relays.gauge; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; @@ -40,7 +40,7 @@ public class GaugeRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; super.renderSafe(te, partialTicks, ms, buffer, light, overlay); BlockState gaugeState = te.getBlockState(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java index f0e0c5e5b..fec1c431f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.relays.gearbox; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; @@ -27,7 +27,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS); final BlockPos pos = te.getPos(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java index b238d2084..9abe8e68c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java @@ -11,9 +11,9 @@ import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.logistics.block.FlapData; import com.simibubi.create.foundation.gui.widgets.InterpolatedValue; +import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.Direction; @@ -28,8 +28,8 @@ public class BeltTunnelInstance extends TileEntityInstance tunnelFlaps = new EnumMap<>(Direction.class); - InstancedModel model = modelManager.getMaterial(KineticRenderMaterials.FLAPS) - .getModel(AllBlockPartials.BELT_TUNNEL_FLAP, blockState); + InstancedModel model = modelManager.getMaterial(AllMaterialSpecs.FLAPS) + .getModel(AllBlockPartials.BELT_TUNNEL_FLAP, blockState); int blockLight = world.getLightLevel(LightType.BLOCK, pos); int skyLight = world.getLightLevel(LightType.SKY, pos); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java index 14f7a8ceb..95c00bd70 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.belts.tunnel; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -31,7 +31,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer () -> FastRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Backend.enqueueUpdate(this)); } public void updateTunnelConnections() { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java index 3b993fe6b..f6cc74cf3 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.depot; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -45,7 +45,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer { float lidProgress = ((EjectorTileEntity) te).getLidProgress(partialTicks); float angle = lidProgress * 70; - if (!FastRenderDispatcher.available(te.getWorld())) { + if (!Backend.canUseInstancing(te.getWorld())) { SuperByteBuffer model = PartialBufferer.get(AllBlockPartials.EJECTOR_TOP, te.getBlockState()); applyLidAngle(te, angle, model.matrixStacker()); model.light(light) @@ -55,7 +55,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer { MatrixStacker msr = MatrixStacker.of(ms); float maxTime = - (float) (ejector.earlyTarget != null ? ejector.earlyTargetTime : ejector.launcher.getTotalFlyingTicks()); + (float) (ejector.earlyTarget != null ? ejector.earlyTargetTime : ejector.launcher.getTotalFlyingTicks()); for (IntAttached intAttached : ejector.launchedItems) { float time = intAttached.getFirst() + partialTicks; if (time > maxTime) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java index 4c378f3d7..ef501a549 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java @@ -9,8 +9,8 @@ import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.logistics.block.FlapData; +import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.Direction; @@ -27,10 +27,10 @@ public class FunnelInstance extends TileEntityInstance impleme if (!tile.hasFlap()) return; - PartialModel flapPartial = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP - : AllBlockPartials.BELT_FUNNEL_FLAP); - InstancedModel model = modelManager.getMaterial(KineticRenderMaterials.FLAPS) - .getModel(flapPartial, blockState); + PartialModel flapPartial = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP + : AllBlockPartials.BELT_FUNNEL_FLAP); + InstancedModel model = modelManager.getMaterial(AllMaterialSpecs.FLAPS) + .getModel(flapPartial, blockState); int blockLight = world.getLightLevel(LightType.BLOCK, pos); int skyLight = world.getLightLevel(LightType.SKY, pos); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java index 735749775..1c5a468d6 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.funnel; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; @@ -30,7 +30,7 @@ public class FunnelRenderer extends SmartTileEntityRenderer { int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); - if (!te.hasFlap() || FastRenderDispatcher.available(te.getWorld())) + if (!te.hasFlap() || Backend.canUseInstancing(te.getWorld())) return; BlockState blockState = te.getBlockState(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java index ddf7fd424..10cba6b83 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.logistics.block.funnel; import java.lang.ref.WeakReference; import java.util.List; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllSoundEvents; @@ -327,7 +327,7 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn extractionCooldown = compound.getInt("TransferCooldown"); if (clientPacket) - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> FastRenderDispatcher.enqueueUpdate(this)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> Backend.enqueueUpdate(this)); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java index 82294a44f..711565bbe 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.mechanicalArm; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -42,7 +42,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { super.renderSafe(te, pt, ms, buffer, light, overlay); ArmTileEntity arm = (ArmTileEntity) te; - boolean usingFlywheel = FastRenderDispatcher.available(te.getWorld()); + boolean usingFlywheel = Backend.canUseInstancing(te.getWorld()); ItemStack item = arm.heldItem; boolean hasItem = !item.isEmpty(); @@ -50,7 +50,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { if (usingFlywheel && !hasItem) return; ItemRenderer itemRenderer = Minecraft.getInstance() - .getItemRenderer(); + .getItemRenderer(); boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) && itemRenderer.getItemModelWithOverrides(item, Minecraft.getInstance().world, null) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java index 991560762..50d13a86d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.redstone; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -28,7 +28,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer> cir) { - if (FastRenderDispatcher.available()) { + if (Backend.canUseInstancing()) { List tiles = cir.getReturnValue(); tiles.removeIf(tile -> tile instanceof IInstanceRendered && !((IInstanceRendered) tile).shouldRenderAsTE()); diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index f97ba920d..0f44aefa3 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -8,7 +8,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; import com.jozufozu.flywheel.backend.OptifineHandler; import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; @@ -52,7 +51,7 @@ public class RenderHooksMixin { Matrix4f viewProjection = view.copy(); viewProjection.multiplyBackward(Backend.projectionMatrix); - FastRenderDispatcher.renderLayer(type, viewProjection, camX, camY, camZ); + Backend.renderLayer(type, viewProjection, camX, camY, camZ); ContraptionRenderDispatcher.renderLayer(type, viewProjection, camX, camY, camZ); diff --git a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java new file mode 100644 index 000000000..6f0ba694e --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java @@ -0,0 +1,45 @@ +package com.simibubi.create.foundation.render; + +import static com.jozufozu.flywheel.backend.Backend.register; + +import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.OrientedModel; +import com.jozufozu.flywheel.backend.core.TransformedModel; +import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.MaterialSpec; +import com.simibubi.create.Create; +import com.simibubi.create.content.contraptions.base.RotatingData; +import com.simibubi.create.content.contraptions.base.RotatingModel; +import com.simibubi.create.content.contraptions.components.actors.ActorData; +import com.simibubi.create.content.contraptions.components.actors.ActorModel; +import com.simibubi.create.content.contraptions.relays.belt.BeltData; +import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; +import com.simibubi.create.content.logistics.block.FlapData; +import com.simibubi.create.content.logistics.block.FlapModel; + +import net.minecraft.util.ResourceLocation; + +public class AllMaterialSpecs { + public static void init() { + // noop, make sure the static field are loaded. + } + + + public static final MaterialSpec> TRANSFORMED = register(new MaterialSpec<>(Locations.MODEL, AllProgramSpecs.MODEL, TransformedModel::new)); + public static final MaterialSpec> ORIENTED = register(new MaterialSpec<>(Locations.ORIENTED, AllProgramSpecs.ORIENTED, OrientedModel::new)); + + public static final MaterialSpec> ROTATING = register(new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, RotatingModel::new)); + public static final MaterialSpec> BELTS = register(new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, BeltInstancedModel::new)); + public static final MaterialSpec> ACTORS = register(new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, ActorModel::new)); + public static final MaterialSpec> FLAPS = register(new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, FlapModel::new)); + + public static class Locations { + public static final ResourceLocation MODEL = new ResourceLocation("create", "model"); + public static final ResourceLocation ORIENTED = new ResourceLocation("create", "oriented"); + public static final ResourceLocation ROTATING = new ResourceLocation(Create.ID, "rotating"); + public static final ResourceLocation BELTS = new ResourceLocation(Create.ID, "belts"); + public static final ResourceLocation ACTORS = new ResourceLocation(Create.ID, "actors"); + public static final ResourceLocation FLAPS = new ResourceLocation(Create.ID, "flaps"); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java index e64b8fcda..e0b204bc8 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.tileEntity.renderer; -import com.jozufozu.flywheel.backend.FastRenderDispatcher; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -19,7 +19,7 @@ public abstract class ColoredOverlayTileEntityRenderer ext protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { - if (FastRenderDispatcher.available(te.getWorld())) return; + if (Backend.canUseInstancing(te.getWorld())) return; SuperByteBuffer render = render(getOverlayBuffer(te), getColor(te, partialTicks), light); render.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); From 9736ba19b5ae2aa9803249273be7b1df2f9c38f3 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 4 May 2021 23:56:50 -0700 Subject: [PATCH 026/198] Things here and there - Move CreateClient.kineticRenderer to Backend - InstancedTileRenderers keep track of their own queuedUpdates - Sort of a listener system for some render events --- .../jozufozu/flywheel/backend/Backend.java | 63 ++++++++++-------- .../flywheel/backend/FlywheelListeners.java | 65 +++++++++++++++++++ .../core/BasicInstancedTileRenderer.java | 10 +-- .../instancing/InstancedTileRenderer.java | 43 ++++++++---- .../com/simibubi/create/CreateClient.java | 11 ++-- .../render/ContraptionKineticRenderer.java | 8 +-- .../render/ContraptionRenderDispatcher.java | 28 +++++--- .../render/RenderedContraption.java | 2 +- .../simibubi/create/events/ClientEvents.java | 2 +- .../foundation/mixin/LightUpdateMixin.java | 6 +- .../mixin/NetworkLightUpdateMixin.java | 6 +- .../foundation/mixin/RenderHooksMixin.java | 55 ++++++---------- .../mixin/StoreProjectionMatrixMixin.java | 2 +- .../foundation/mixin/TileRemoveMixin.java | 6 +- .../foundation/mixin/TileWorldHookMixin.java | 8 +-- .../flywheel/shaders/contraption/builtin.frag | 2 +- .../create/flywheel/shaders/std/builtin.frag | 2 +- .../create/flywheel/shaders/std/fog.glsl | 8 +-- 18 files changed, 208 insertions(+), 119 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/FlywheelListeners.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index b406c55d0..5c7e52f22 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -3,7 +3,6 @@ package com.jozufozu.flywheel.backend; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -11,7 +10,6 @@ import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; -import com.jozufozu.flywheel.backend.core.ContraptionContext; import com.jozufozu.flywheel.backend.core.EffectsContext; import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.effects.EffectsHandler; @@ -21,7 +19,6 @@ import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; -import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.WorldAttached; @@ -42,25 +39,41 @@ public class Backend { public static final Logger log = LogManager.getLogger(Backend.class); public static final ShaderLoader shaderLoader = new ShaderLoader(); - public static EffectsHandler effects; - - public static Matrix4f projectionMatrix = new Matrix4f(); + public static final FlywheelListeners listeners = new FlywheelListeners(); public static GLCapabilities capabilities; public static GlCompat compat; - public static WorldAttached> queuedUpdates = new WorldAttached<>(ConcurrentHashMap::newKeySet); + public static EffectsHandler effects; + public static WorldAttached tileRenderer = new WorldAttached<>(BasicInstancedTileRenderer::new); + + private static Matrix4f projectionMatrix = new Matrix4f(); private static boolean instancingAvailable; private static boolean enabled; - static Map> materialRegistry = new HashMap<>(); + static final Map> materialRegistry = new HashMap<>(); static final Map> contexts = new HashMap<>(); static final Map programSpecRegistry = new HashMap<>(); static { register(WorldContext.INSTANCE); - register(ContraptionContext.INSTANCE); register(EffectsContext.INSTANCE); + + listeners.refreshListener(world -> { + if (canUseInstancing() && world != null) { + BasicInstancedTileRenderer tileRenderer = Backend.tileRenderer.get(world); + tileRenderer.invalidate(); + world.loadedTileEntityList.forEach(tileRenderer::add); + } + }); + + listeners.setupFrameListener((world, stack, info, gameRenderer, lightTexture) -> { + + Backend.tileRenderer.get(world) + .beginFrame(info); + }); + + listeners.renderLayerListener(Backend::renderLayer); } public Backend() { @@ -161,35 +174,25 @@ public class Backend { Minecraft mc = Minecraft.getInstance(); ClientWorld world = mc.world; - BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + BasicInstancedTileRenderer instancer = tileRenderer.get(world); Entity renderViewEntity = mc.renderViewEntity; - kineticRenderer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ()); - - ConcurrentHashMap.KeySetView map = queuedUpdates.get(world); - map - .forEach(te -> { - map.remove(te); - - kineticRenderer.update(te); - }); + instancer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ()); } - public static void renderLayer(RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { - if (!canUseInstancing()) return; - - ClientWorld world = Minecraft.getInstance().world; - BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + public static void renderLayer(ClientWorld world, RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { + if (!canUseInstancing(world)) return; layer.startDrawing(); - kineticRenderer.render(layer, viewProjection, cameraX, cameraY, cameraZ); + tileRenderer.get(world) + .render(layer, viewProjection, cameraX, cameraY, cameraZ); layer.endDrawing(); } public static void enqueueUpdate(TileEntity te) { - queuedUpdates.get(te.getWorld()).add(te); + tileRenderer.get(te.getWorld()).queueUpdate(te); } public static void reloadWorldRenderers() { @@ -215,4 +218,12 @@ public class Backend { public static Collection allPrograms() { return programSpecRegistry.values(); } + + public static Matrix4f getProjectionMatrix() { + return projectionMatrix; + } + + public static void setProjectionMatrix(Matrix4f projectionMatrix) { + Backend.projectionMatrix = projectionMatrix; + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/FlywheelListeners.java b/src/main/java/com/jozufozu/flywheel/backend/FlywheelListeners.java new file mode 100644 index 000000000..f0f86b5a8 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/FlywheelListeners.java @@ -0,0 +1,65 @@ +package com.jozufozu.flywheel.backend; + +import java.util.ArrayList; +import java.util.List; + +import com.mojang.blaze3d.matrix.MatrixStack; + +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.util.math.vector.Matrix4f; + +public class FlywheelListeners { + + private final List setupFrameListeners = new ArrayList<>(); + private final List renderLayerListeners = new ArrayList<>(); + private final List refreshListeners = new ArrayList<>(); + + public void setupFrameListener(SetupFrame setupFrame) { + setupFrameListeners.add(setupFrame); + } + + public void renderLayerListener(RenderLayer renderLayer) { + renderLayerListeners.add(renderLayer); + } + + public void refreshListener(Refresh refresh) { + refreshListeners.add(refresh); + } + + public void setupFrame(ClientWorld world, MatrixStack stack, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture) { + for (SetupFrame listener : setupFrameListeners) { + listener.setupFrame(world, stack, info, gameRenderer, lightTexture); + } + } + + public void renderLayer(ClientWorld world, RenderType type, Matrix4f stack, double camX, double camY, double camZ) { + for (RenderLayer listener : renderLayerListeners) { + listener.renderLayer(world, type, stack, camX, camY, camZ); + } + } + + public void refresh(ClientWorld world) { + for (Refresh listener : refreshListeners) { + listener.refresh(world); + } + } + + @FunctionalInterface + public interface SetupFrame { + void setupFrame(ClientWorld world, MatrixStack stack, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture); + } + + @FunctionalInterface + public interface RenderLayer { + void renderLayer(ClientWorld world, RenderType type, Matrix4f viewProjection, double camX, double camY, double camZ); + } + + @FunctionalInterface + public interface Refresh { + void refresh(ClientWorld world); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java index 2ea176ebb..0f41acf2e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java @@ -27,10 +27,10 @@ public class BasicInstancedTileRenderer extends InstancedTileRenderer { - protected ArrayList queuedAdditions = new ArrayList<>(64); - - protected Map> instances = new HashMap<>(); - - protected Map tickableInstances = new HashMap<>(); - protected Map dynamicInstances = new HashMap<>(); public final WorldContext

context; - protected Map, RenderMaterial> materials = new HashMap<>(); + protected final Map, RenderMaterial> materials; + + protected final ArrayList queuedAdditions; + protected final ConcurrentHashMap.KeySetView queuedUpdates; + + protected final Map> instances; + protected final Map tickableInstances; + protected final Map dynamicInstances; protected int frame; protected int tick; @@ -42,9 +44,16 @@ public abstract class InstancedTileRenderer

{ protected InstancedTileRenderer(WorldContext

context) { this.context = context; + materials = new HashMap<>(); for (MaterialSpec spec : Backend.allMaterials()) { materials.put(spec, spec.create(this)); } + + queuedUpdates = ConcurrentHashMap.newKeySet(64); + queuedAdditions = new ArrayList<>(64); + dynamicInstances = new HashMap<>(); + tickableInstances = new HashMap<>(); + instances = new HashMap<>(); } public abstract BlockPos getOriginCoordinate(); @@ -74,9 +83,15 @@ public abstract class InstancedTileRenderer

{ instance.tick(); } } + + queuedUpdates.forEach(te -> { + queuedUpdates.remove(te); + + update(te); + }); } - public void beginFrame(ActiveRenderInfo info, double cameraX, double cameraY, double cameraZ) { + public void beginFrame(ActiveRenderInfo info) { frame++; processQueuedAdditions(); @@ -86,9 +101,9 @@ public abstract class InstancedTileRenderer

{ float lookZ = look.getZ(); // integer camera pos - int cX = (int) cameraX; - int cY = (int) cameraY; - int cZ = (int) cameraZ; + int cX = (int) info.getProjectedView().x; + int cY = (int) info.getProjectedView().y; + int cZ = (int) info.getProjectedView().z; if (dynamicInstances.size() > 0) { for (IDynamicInstance dyn : dynamicInstances.values()) { @@ -195,6 +210,12 @@ public abstract class InstancedTileRenderer

{ queuedAdditions.add(tile); } + public synchronized void queueUpdate(T tile) { + if (!Backend.canUseInstancing()) return; + + queuedUpdates.add(tile); + } + protected synchronized void processQueuedAdditions() { if (queuedAdditions.size() > 0) { queuedAdditions.forEach(this::addInternal); diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index fe230c877..825d900cc 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -9,7 +9,6 @@ import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.OptifineHandler; -import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.jozufozu.flywheel.backend.core.PartialModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -30,7 +29,6 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.render.SuperByteBufferCache; -import com.simibubi.create.foundation.utility.WorldAttached; import com.simibubi.create.foundation.utility.ghost.GhostBlocks; import com.simibubi.create.foundation.utility.outliner.Outliner; @@ -66,7 +64,6 @@ public class CreateClient { public static SchematicHandler schematicHandler; public static SchematicAndQuillHandler schematicAndQuillHandler; public static SuperByteBufferCache bufferCache; - public static WorldAttached kineticRenderer; public static final Outliner outliner = new Outliner(); public static GhostBlocks ghostBlocks; @@ -84,13 +81,13 @@ public class CreateClient { modEventBus.addListener(AllParticleTypes::registerFactories); Backend.init(); + ContraptionRenderDispatcher.init(); OptifineHandler.init(); } public static void clientInit(FMLClientSetupEvent event) { AllProgramSpecs.init(); AllMaterialSpecs.init(); - kineticRenderer = new WorldAttached<>(BasicInstancedTileRenderer::new); schematicSender = new ClientSchematicLoader(); schematicHandler = new SchematicHandler(); @@ -221,10 +218,10 @@ public class CreateClient { bufferCache.invalidate(); if (world != null) { - kineticRenderer.get(world) - .invalidate(); + Backend.tileRenderer.get(world) + .invalidate(); } else { - kineticRenderer.forEach(InstancedTileRenderer::invalidate); + Backend.tileRenderer.forEach(InstancedTileRenderer::invalidate); } ContraptionRenderDispatcher.invalidateAll(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java index ae766a36c..2d4723fb8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java @@ -37,11 +37,11 @@ public class ContraptionKineticRenderer extends InstancedTileRenderer> CONTRAPTION = new Compartment<>(); protected static PlacementSimulationWorld renderWorld; + public static void init() { + Backend.register(ContraptionContext.INSTANCE); + Backend.listeners.renderLayerListener(ContraptionRenderDispatcher::renderLayer); + Backend.listeners.setupFrameListener(ContraptionRenderDispatcher::beginFrame); + Backend.listeners.refreshListener($ -> ContraptionRenderDispatcher.invalidateAll()); + } + public static void tick() { if (Minecraft.getInstance().isGamePaused()) return; @@ -65,22 +74,25 @@ public class ContraptionRenderDispatcher { } } - public static void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) { + public static void beginFrame(ClientWorld world, MatrixStack stack, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture) { + double camX = info.getProjectedView().x; + double camY = info.getProjectedView().y; + double camZ = info.getProjectedView().z; for (RenderedContraption renderer : renderers.values()) { renderer.beginFrame(info, camX, camY, camZ); } } - public static void renderLayer(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ) { - removeDeadContraptions(); + public static void renderLayer(ClientWorld world, RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ) { + removeDeadContraptions(); - if (renderers.isEmpty()) return; + if (renderers.isEmpty()) return; - layer.startDrawing(); - GL11.glEnable(GL13.GL_TEXTURE_3D); - GL13.glActiveTexture(GL40.GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 + layer.startDrawing(); + GL11.glEnable(GL13.GL_TEXTURE_3D); + GL13.glActiveTexture(GL40.GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 - if (Backend.canUseVBOs()) { + if (Backend.canUseVBOs()) { ContraptionProgram structureShader = ContraptionContext.INSTANCE.getProgram(AllProgramSpecs.STRUCTURE); structureShader.bind(viewProjection, camX, camY, camZ, Backend.getDebugMode()); for (RenderedContraption renderer : renderers.values()) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index 16b079aa8..b7db073c9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -89,7 +89,7 @@ public class RenderedContraption { } public void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) { - kinetics.beginFrame(info, camX, camY, camZ); + kinetics.beginFrame(info); AbstractContraptionEntity entity = contraption.entity; float pt = AnimationTickHolder.getPartialTicks(); diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index b71847356..0c9400ae5 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -144,7 +144,7 @@ public class ClientEvents { if (world.isRemote() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) { CreateClient.invalidateRenderers(world); AnimationTickHolder.reset(); - BasicInstancedTileRenderer renderer = CreateClient.kineticRenderer.get(world); + BasicInstancedTileRenderer renderer = Backend.tileRenderer.get(world); renderer.invalidate(); ((ClientWorld) world).loadedTileEntityList.forEach(renderer::add); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java index 4b8e08f41..1d1c99757 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java @@ -7,8 +7,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.light.LightUpdater; -import com.simibubi.create.CreateClient; import net.minecraft.client.multiplayer.ClientChunkProvider; import net.minecraft.client.world.ClientWorld; @@ -46,8 +46,8 @@ public abstract class LightUpdateMixin extends AbstractChunkProvider { .getY()) == sectionY) .map(Map.Entry::getValue) .forEach(tile -> { - CreateClient.kineticRenderer.get(world) - .onLightUpdate(tile); + Backend.tileRenderer.get(world) + .onLightUpdate(tile); }); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java index effe19da5..4b1d899a8 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java @@ -5,9 +5,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.RenderWork; import com.jozufozu.flywheel.backend.light.LightUpdater; -import com.simibubi.create.CreateClient; import net.minecraft.client.Minecraft; import net.minecraft.client.network.play.ClientPlayNetHandler; @@ -36,8 +36,8 @@ public class NetworkLightUpdateMixin { chunk.getTileEntityMap() .values() .forEach(tile -> { - CreateClient.kineticRenderer.get(world) - .onLightUpdate(tile); + Backend.tileRenderer.get(world) + .onLightUpdate(tile); }); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index 0f44aefa3..203ea1b8a 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -9,11 +9,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.OptifineHandler; -import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; -import com.simibubi.create.CreateClient; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.ActiveRenderInfo; @@ -24,7 +21,6 @@ import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.world.ClientWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; -import net.minecraft.util.math.vector.Vector3d; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -35,6 +31,13 @@ public class RenderHooksMixin { @Shadow private ClientWorld world; + @Inject(at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.updateChunks(J)V"), method = "render") + private void setupFrame(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, + ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_, + CallbackInfo ci) { + Backend.listeners.setupFrame(world, stack, info, gameRenderer, lightTexture); + } + /** * JUSTIFICATION: This method is called once per layer per frame. It allows us to perform * layer-correct custom rendering. RenderWorldLast is not refined enough for rendering world objects. @@ -42,36 +45,29 @@ public class RenderHooksMixin { */ @Inject(at = @At("TAIL"), method = "renderLayer") private void renderLayer(RenderType type, MatrixStack stack, double camX, double camY, double camZ, - CallbackInfo ci) { + CallbackInfo ci) { if (!Backend.available()) return; Matrix4f view = stack.peek() .getModel(); Matrix4f viewProjection = view.copy(); - viewProjection.multiplyBackward(Backend.projectionMatrix); - - Backend.renderLayer(type, viewProjection, camX, camY, camZ); - - ContraptionRenderDispatcher.renderLayer(type, viewProjection, camX, camY, camZ); + viewProjection.multiplyBackward(Backend.getProjectionMatrix()); + Backend.listeners.renderLayer(world, type, viewProjection, camX, camY, camZ); GL20.glUseProgram(0); } - @Inject(at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.updateChunks(J)V"), method = "render") - private void setupFrame(MatrixStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, - ActiveRenderInfo info, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, - CallbackInfo ci) { - Vector3d cameraPos = info.getProjectedView(); - double camX = cameraPos.getX(); - double camY = cameraPos.getY(); - double camZ = cameraPos.getZ(); + @Inject(at = @At("TAIL"), method = "loadRenderers") + private void refresh(CallbackInfo ci) { + OptifineHandler.refresh(); + Backend.refresh(); - CreateClient.kineticRenderer.get(world) - .beginFrame(info, camX, camY, camZ); - ContraptionRenderDispatcher.beginFrame(info, camX, camY, camZ); + Backend.listeners.refresh(world); } + // Effects system + @Inject(method = "render", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;render(F)V")) private void disableTransparencyShaderDepth(MatrixStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) { GlStateManager.depthMask(false); @@ -82,22 +78,11 @@ public class RenderHooksMixin { Backend.effects.render(stack.peek().getModel()); } + // Instancing + @Inject(at = @At("TAIL"), method = "scheduleBlockRerenderIfNeeded") private void checkUpdate(BlockPos pos, BlockState lastState, BlockState newState, CallbackInfo ci) { - CreateClient.kineticRenderer.get(world) + Backend.tileRenderer.get(world) .update(world.getTileEntity(pos)); } - - @Inject(at = @At("TAIL"), method = "loadRenderers") - private void refresh(CallbackInfo ci) { - ContraptionRenderDispatcher.invalidateAll(); - OptifineHandler.refresh(); - Backend.refresh(); - - if (Backend.canUseInstancing() && world != null) { - BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); - kineticRenderer.invalidate(); - world.loadedTileEntityList.forEach(kineticRenderer::add); - } - } } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java index 822e05bd8..eef158e20 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java @@ -52,7 +52,7 @@ public abstract class StoreProjectionMatrixMixin { @Inject(method = "loadProjectionMatrix", at = @At("TAIL")) private void onProjectionMatrixLoad(Matrix4f projection, CallbackInfo ci) { if (shouldCopy) { - Backend.projectionMatrix = projection.copy(); + Backend.setProjectionMatrix(projection.copy()); shouldCopy = false; } } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java index b2907a127..4de24590a 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.simibubi.create.CreateClient; +import com.jozufozu.flywheel.backend.Backend; import net.minecraft.client.world.ClientWorld; import net.minecraft.tileentity.TileEntity; @@ -24,7 +24,7 @@ public class TileRemoveMixin { @Inject(at = @At("TAIL"), method = "remove") private void onRemove(CallbackInfo ci) { if (world instanceof ClientWorld) - CreateClient.kineticRenderer.get(this.world) - .remove((TileEntity) (Object) this); + Backend.tileRenderer.get(this.world) + .remove((TileEntity) (Object) this); } } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java index 77b504956..59427ef6c 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java @@ -10,8 +10,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; -import com.simibubi.create.CreateClient; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -35,8 +35,8 @@ public class TileWorldHookMixin { @Inject(at = @At("TAIL"), method = "addTileEntity") private void onAddTile(TileEntity te, CallbackInfoReturnable cir) { if (isRemote) { - CreateClient.kineticRenderer.get(self) - .queueAdd(te); + Backend.tileRenderer.get(self) + .queueAdd(te); } } @@ -46,7 +46,7 @@ public class TileWorldHookMixin { @Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities") private void onChunkUnload(CallbackInfo ci) { if (isRemote) { - BasicInstancedTileRenderer kineticRenderer = CreateClient.kineticRenderer.get(self); + BasicInstancedTileRenderer kineticRenderer = Backend.tileRenderer.get(self); for (TileEntity tile : tileEntitiesToBeRemoved) { kineticRenderer.remove(tile); } diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag index 09918fb48..ac2690e87 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag @@ -3,7 +3,7 @@ varying vec3 BoxCoord; uniform sampler3D uLightVolume; -void FLWFinalizeColor(vec4 color) { +void FLWFinalizeColor(inout vec4 color) { #if defined(USE_FOG) float a = color.a; float fog = clamp(FLWFogFactor(), 0., 1.); diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag index e89cfaf00..4e08fae38 100644 --- a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag @@ -1,6 +1,6 @@ #flwinclude <"create:std/fog.glsl"> -void FLWFinalizeColor(vec4 color) { +void FLWFinalizeColor(inout vec4 color) { #if defined(USE_FOG) float a = color.a; float fog = clamp(FLWFogFactor(), 0., 1.); diff --git a/src/main/resources/assets/create/flywheel/shaders/std/fog.glsl b/src/main/resources/assets/create/flywheel/shaders/std/fog.glsl index 09cc7af18..75a68d176 100644 --- a/src/main/resources/assets/create/flywheel/shaders/std/fog.glsl +++ b/src/main/resources/assets/create/flywheel/shaders/std/fog.glsl @@ -9,15 +9,13 @@ uniform vec2 uFogRange; float FLWFogFactor() { return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x); } - #elif defined(USE_FOG_EXP2) + #endif + + #if defined(USE_FOG_EXP2) uniform float uFogDensity; float FLWFogFactor() { float dist = FragDistance * uFogDensity; return 1. / exp2(dist * dist); -} - #else -float FLWFogFactor() { - return 0.; } #endif From 4ed97b36556201585b18435156435496c912cb02 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Thu, 6 May 2021 14:10:12 -0700 Subject: [PATCH 027/198] Fix super glue rendering - Fix super glue normals, rotation, and reflection. - Move render check to appropriate method. - Minor optimizations. --- .../glue/SuperGlueRenderer.java | 79 +++++++++++-------- .../foundation/utility/AngleHelper.java | 16 ++++ 2 files changed, 64 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java index cd73d52ff..34bfa5f3b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java @@ -13,6 +13,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.culling.ClippingHelper; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.texture.OverlayTexture; @@ -31,10 +32,8 @@ public class SuperGlueRenderer extends EntityRenderer { private ResourceLocation regular = new ResourceLocation(Create.ID, "textures/entity/super_glue/slime.png"); - private Vector3d[] quad1; - private Vector3d[] quad2; - private float[] u = { 0, 1, 1, 0 }; - private float[] v = { 0, 0, 1, 1 }; + private float[] insideQuad; + private float[] outsideQuad; public SuperGlueRenderer(EntityRendererManager renderManager) { super(renderManager); @@ -47,17 +46,23 @@ public class SuperGlueRenderer extends EntityRenderer { } @Override - public void render(SuperGlueEntity entity, float p_225623_2_, float p_225623_3_, MatrixStack ms, + public boolean shouldRender(SuperGlueEntity entity, ClippingHelper frustum, double x, double y, double z) { + if (super.shouldRender(entity, frustum, x, y, z)) { + PlayerEntity player = Minecraft.getInstance().player; + boolean visible = entity.isVisible(); + boolean holdingGlue = AllItems.SUPER_GLUE.isIn(player.getHeldItemMainhand()) + || AllItems.SUPER_GLUE.isIn(player.getHeldItemOffhand()); + + if (visible || holdingGlue) + return true; + } + return false; + } + + @Override + public void render(SuperGlueEntity entity, float yaw, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light) { - super.render(entity, p_225623_2_, p_225623_3_, ms, buffer, light); - - PlayerEntity player = Minecraft.getInstance().player; - boolean visible = entity.isVisible(); - boolean holdingGlue = AllItems.SUPER_GLUE.isIn(player.getHeldItemMainhand()) - || AllItems.SUPER_GLUE.isIn(player.getHeldItemOffhand()); - - if (!visible && !holdingGlue) - return; + super.render(entity, yaw, partialTicks, ms, buffer, light); IVertexBuilder builder = buffer.getBuffer(RenderType.getEntityCutout(getEntityTexture(entity))); light = getBrightnessForRender(entity); @@ -65,24 +70,13 @@ public class SuperGlueRenderer extends EntityRenderer { ms.push(); MatrixStacker.of(ms) - .rotateY(AngleHelper.horizontalAngle(face)) + .rotateY(AngleHelper.horizontalAngleNew(face)) .rotateX(AngleHelper.verticalAngle(face)); Entry peek = ms.peek(); - Vector3d[][] quads = { quad1, quad2 }; - for (Vector3d[] quad : quads) { - for (int i = 0; i < 4; i++) { - Vector3d vertex = quad[i]; - builder.vertex(peek.getModel(), (float) vertex.x, (float) vertex.y, (float) vertex.z) - .color(255, 255, 255, 255) - .texture(u[i], v[i]) - .overlay(OverlayTexture.DEFAULT_UV) - .light(light) - .normal(peek.getNormal(), face.getXOffset(), face.getYOffset(), face.getZOffset()) - .endVertex(); - } - face = face.getOpposite(); - } + renderQuad(builder, peek, insideQuad, light, -1); + renderQuad(builder, peek, outsideQuad, light, 1); + ms.pop(); } @@ -111,8 +105,18 @@ public class SuperGlueRenderer extends EntityRenderer { Vector3d a4 = plane.add(start); Vector3d b4 = plane.add(end); - quad1 = new Vector3d[] { a2, a3, a4, a1 }; - quad2 = new Vector3d[] { b3, b2, b1, b4 }; + insideQuad = new float[] { + (float) a1.x, (float) a1.y, (float) a1.z, 1, 0, + (float) a2.x, (float) a2.y, (float) a2.z, 1, 1, + (float) a3.x, (float) a3.y, (float) a3.z, 0, 1, + (float) a4.x, (float) a4.y, (float) a4.z, 0, 0, + }; + outsideQuad = new float[] { + (float) b4.x, (float) b4.y, (float) b4.z, 0, 0, + (float) b3.x, (float) b3.y, (float) b3.z, 0, 1, + (float) b2.x, (float) b2.y, (float) b2.z, 1, 1, + (float) b1.x, (float) b1.y, (float) b1.z, 1, 0, + }; } private int getBrightnessForRender(SuperGlueEntity entity) { @@ -126,4 +130,17 @@ public class SuperGlueRenderer extends EntityRenderer { return Math.max(light, light2); } + // Vertex format: pos x, pos y, pos z, u, v + private void renderQuad(IVertexBuilder builder, Entry matrix, float[] data, int light, float normalZ) { + for (int i = 0; i < 4; i++) { + builder.vertex(matrix.getModel(), data[5 * i], data[5 * i + 1], data[5 * i + 2]) + .color(255, 255, 255, 255) + .texture(data[5 * i + 3], data[5 * i + 4]) + .overlay(OverlayTexture.DEFAULT_UV) + .light(light) + .normal(matrix.getNormal(), 0.0f, 0.0f, normalZ) + .endVertex(); + } + } + } diff --git a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java index 9884e71c4..3f8723672 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java @@ -5,6 +5,9 @@ import net.minecraft.util.Direction.Axis; public class AngleHelper { + /** + * Legacy method. See {@link #horizontalAngleNew(Direction)} for new method. + */ public static float horizontalAngle(Direction facing) { float angle = facing.getHorizontalAngle(); if (facing.getAxis() == Axis.X) @@ -12,6 +15,19 @@ public class AngleHelper { return angle; } + /** + * Same as {@link #horizontalAngle(Direction)}, but returns 0 instead of -90 for vertical directions. + */ + public static float horizontalAngleNew(Direction facing) { + if (facing.getAxis().isVertical()) { + return 0; + } + float angle = facing.getHorizontalAngle(); + if (facing.getAxis() == Axis.X) + angle = -angle; + return angle; + } + public static float verticalAngle(Direction facing) { return facing == Direction.UP ? -90 : facing == Direction.DOWN ? 90 : 0; } From 970a5c2f536dda14d7faafa61f91c223766bbbb7 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Thu, 6 May 2021 14:14:31 -0700 Subject: [PATCH 028/198] Fix JEI Scene Lighting - Fix sudden light transitions in JEI scenes - Allow block GuiGameElements to set custom lighting - Remove deprecated GuiGameElement methods --- .../animations/AnimatedCrushingWheels.java | 7 +- .../create/foundation/gui/GuiGameElement.java | 92 +++++++++++-------- .../create/foundation/gui/UIRenderHelper.java | 11 +++ .../foundation/mixin/FixInverseCbrtMixin.java | 32 +++++++ .../create/foundation/utility/VecHelper.java | 1 + src/main/resources/create.mixins.json | 1 + 6 files changed, 103 insertions(+), 41 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/mixin/FixInverseCbrtMixin.java 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 0459efd33..263add564 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 @@ -1,7 +1,6 @@ package com.simibubi.create.compat.jei.category.animations; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.gui.GuiGameElement; @@ -14,11 +13,11 @@ public class AnimatedCrushingWheels extends AnimatedKinetics { @Override public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { - RenderSystem.enableDepthTest(); + matrixStack.push(); matrixStack.translate(xOffset, yOffset, 100); matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-22.5f)); int scale = 22; - + BlockState wheel = AllBlocks.CRUSHING_WHEEL.get() .getDefaultState() .with(BlockStateProperties.AXIS, Axis.X); @@ -33,6 +32,8 @@ public class AnimatedCrushingWheels extends AnimatedKinetics { .atLocal(2, 0, 0) .scale(scale) .render(matrixStack); + + matrixStack.pop(); } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java index 79405d4c4..b39dc489c 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java @@ -35,12 +35,15 @@ 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.vector.Vector2f; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3f; import net.minecraftforge.fluids.FluidStack; public class GuiGameElement { + public static Vector2f defaultBlockLighting = new Vector2f(30.0f, 7.5f); + public static GuiRenderBuilder of(ItemStack stack) { return new GuiItemRenderBuilder(stack); } @@ -64,11 +67,13 @@ public class GuiGameElement { } public static abstract class GuiRenderBuilder extends RenderElement { - double xLocal, yLocal, zLocal; - double xRot, yRot, zRot; - double scale = 1; - int color = 0xFFFFFF; - Vector3d rotationOffset = Vector3d.ZERO; + protected double xLocal, yLocal, zLocal; + protected double xRot, yRot, zRot; + protected double scale = 1; + protected int color = 0xFFFFFF; + protected Vector3d rotationOffset = Vector3d.ZERO; + protected boolean hasCustomLighting = false; + protected float lightingXRot, lightingYRot; public GuiRenderBuilder atLocal(double x, double y, double z) { this.xLocal = x; @@ -104,33 +109,25 @@ public class GuiGameElement { return this; } - public abstract void render(MatrixStack matrixStack); + public GuiRenderBuilder lighting(float xRot, float yRot) { + hasCustomLighting = true; + lightingXRot = xRot; + lightingYRot = yRot; + return this; + } - @Deprecated - protected void prepare() {} + public abstract void render(MatrixStack matrixStack); protected void prepareMatrix(MatrixStack matrixStack) { matrixStack.push(); - 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); - } - - @Deprecated - protected void transform() { - RenderSystem.translated(x, y, 0); - RenderSystem.scaled(scale, scale, scale); - RenderSystem.translated(xLocal, yLocal, zLocal); - RenderSystem.scaled(1, -1, 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); + RenderSystem.alphaFunc(516, 0.1F); + RenderSystem.enableAlphaTest(); + RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); + RenderSystem.enableBlend(); + RenderSystem.enableDepthTest(); + RenderSystem.enableRescaleNormal(); + prepareLighting(matrixStack); } protected void transformMatrix(MatrixStack matrixStack) { @@ -145,13 +142,18 @@ public class GuiGameElement { matrixStack.translate(-rotationOffset.x, -rotationOffset.y, -rotationOffset.z); } - @Deprecated - protected void cleanUp() {} - protected void cleanUpMatrix(MatrixStack matrixStack) { matrixStack.pop(); - RenderSystem.disableAlphaTest(); RenderSystem.disableRescaleNormal(); + RenderSystem.disableAlphaTest(); + cleanUpLighting(matrixStack); + } + + protected void prepareLighting(MatrixStack matrixStack) { + RenderHelper.enableGuiDepthLighting(); + } + + protected void cleanUpLighting(MatrixStack matrixStack) { } } @@ -197,6 +199,20 @@ public class GuiGameElement { 0xF000F0, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); buffer.draw(); } + + @Override + protected void prepareLighting(MatrixStack matrixStack) { + if (hasCustomLighting) { + UIRenderHelper.setupSimpleCustomLighting(lightingXRot, lightingYRot); + } else { + UIRenderHelper.setupSimpleCustomLighting(defaultBlockLighting.x, defaultBlockLighting.y); + } + } + + @Override + protected void cleanUpLighting(MatrixStack matrixStack) { + RenderHelper.enableGuiDepthLighting(); + } } public static class GuiBlockStateRenderBuilder extends GuiBlockModelRenderBuilder { @@ -214,8 +230,8 @@ public class GuiGameElement { RenderHelper.disableGuiDepthLighting(); blockRenderer.renderBlock(blockState, ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); - RenderHelper.enable(); buffer.draw(); + RenderHelper.enableGuiDepthLighting(); return; } @@ -281,19 +297,19 @@ public class GuiGameElement { matrixStack.translate((float) 0, (float) 0, 100.0F + renderer.zLevel); matrixStack.translate(8.0F, -8.0F, 0.0F); matrixStack.scale(16.0F, 16.0F, 16.0F); - IRenderTypeBuffer.Impl irendertypebuffer$impl = Minecraft.getInstance() + IRenderTypeBuffer.Impl buffer = Minecraft.getInstance() .getBufferBuilders() .getEntityVertexConsumers(); - boolean flag = !bakedModel.isSideLit(); - if (flag) { + boolean flatLighting = !bakedModel.isSideLit(); + if (flatLighting) { RenderHelper.disableGuiDepthLighting(); } renderer.renderItem(stack, ItemCameraTransforms.TransformType.GUI, false, matrixStack, - irendertypebuffer$impl, 15728880, OverlayTexture.DEFAULT_UV, bakedModel); - irendertypebuffer$impl.draw(); + buffer, 0xF000F0, OverlayTexture.DEFAULT_UV, bakedModel); + buffer.draw(); RenderSystem.enableDepthTest(); - if (flag) { + if (flatLighting) { RenderHelper.enableGuiDepthLighting(); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java b/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java index be3e6b11c..fee8e48c6 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java @@ -10,6 +10,7 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.Couple; +import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; @@ -257,4 +258,14 @@ public class UIRenderHelper { RenderSystem.enableAlphaTest(); WorldVertexBufferUploader.draw(bufferbuilder); } + + public static void setupSimpleCustomLighting(float xRot, float yRot) { + Matrix4f lightingMatrix = new Matrix4f(); + lightingMatrix.loadIdentity(); + lightingMatrix.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yRot)); + lightingMatrix.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(xRot)); + lightingMatrix.multiply(Matrix4f.translate(0, 0, 1)); + RenderSystem.setupLevelDiffuseLighting(VecHelper.ZERO_3F, VecHelper.ZERO_3F, lightingMatrix); + } + } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/FixInverseCbrtMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/FixInverseCbrtMixin.java new file mode 100644 index 000000000..f4b7b1f87 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/FixInverseCbrtMixin.java @@ -0,0 +1,32 @@ +package com.simibubi.create.foundation.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import net.minecraft.util.math.MathHelper; + +/** + * Vanilla's fast inverse cube root function returns nonsensical results for negative + * numbers, which results in incorrect vertex normal scaling. By negating the input + * and output accordingly, this issue can be prevented. + */ +@Mixin(MathHelper.class) +public class FixInverseCbrtMixin { + @ModifyVariable(at = @At("HEAD"), method = "fastInverseCbrt(F)F") + private static float negateAtHead(float input) { + if (input < 0) { + input *= -1; + } + return input; + } + + @Inject(at = @At("TAIL"), method = "fastInverseCbrt(F)F", cancellable = true) + private static void negateAtTail(float input, CallbackInfoReturnable cir) { + if (input < 0) { + cir.setReturnValue(cir.getReturnValueF() * -1); + } + } +} diff --git a/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java b/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java index 665ed1796..2809bf0b6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/VecHelper.java @@ -21,6 +21,7 @@ import net.minecraft.util.math.vector.Vector3i; public class VecHelper { + public static final Vector3f ZERO_3F = new Vector3f(0, 0, 0); public static final Vector3d CENTER_OF_ORIGIN = new Vector3d(.5, .5, .5); public static Vector3d rotate(Vector3d vec, Vector3d rotationVec) { diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index 0938f8534..49a8c2376 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -9,6 +9,7 @@ "client": [ "CancelTileEntityRenderMixin", "EntityContraptionInteractionMixin", + "FixInverseCbrtMixin", "FogColorTrackerMixin", "HeavyBootsOnPlayerMixin", "LightUpdateMixin", From 3171a0b7e574dc3508dc51d87c5fc616d64a5662 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 6 May 2021 18:38:05 -0700 Subject: [PATCH 029/198] Block breaking animations for arbitrary flywheel tiles. - Kinda jank so far, but it's great progress. - This is also a really good showcase for how flexible the ShaderContext system is. --- .../jozufozu/flywheel/backend/Backend.java | 101 ++++++++++++++++-- .../flywheel/backend/core/BasicProgram.java | 10 +- .../backend/core/CrumblingProgram.java | 22 ++++ .../flywheel/backend/core/WorldContext.java | 1 + ...leRenderer.java => WorldTileRenderer.java} | 8 +- .../flywheel/backend/gl/shader/GlProgram.java | 42 +++++--- .../simibubi/create/events/ClientEvents.java | 5 +- .../foundation/mixin/RenderHooksMixin.java | 18 ++++ .../foundation/mixin/TileWorldHookMixin.java | 5 +- .../resources/META-INF/accesstransformer.cfg | 2 + .../assets/create/flywheel/shaders/block.frag | 7 +- .../flywheel/shaders/contraption/builtin.frag | 11 +- .../flywheel/shaders/crumbling/builtin.frag | 23 ++++ .../flywheel/shaders/crumbling/builtin.vert | 1 + .../create/flywheel/shaders/std/builtin.frag | 11 +- 15 files changed, 224 insertions(+), 43 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java rename src/main/java/com/jozufozu/flywheel/backend/core/{BasicInstancedTileRenderer.java => WorldTileRenderer.java} (89%) create mode 100644 src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.frag create mode 100644 src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.vert diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index 5c7e52f22..9be7ca63e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -1,17 +1,29 @@ package com.jozufozu.flywheel.backend; +import static org.lwjgl.opengl.GL11.GL_REPEAT; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_S; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_T; +import static org.lwjgl.opengl.GL11.glBindTexture; +import static org.lwjgl.opengl.GL11.glTexParameteri; +import static org.lwjgl.opengl.GL13.GL_TEXTURE0; +import static org.lwjgl.opengl.GL13.glActiveTexture; + import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.SortedSet; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; -import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; +import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.core.CrumblingProgram; import com.jozufozu.flywheel.backend.core.EffectsContext; import com.jozufozu.flywheel.backend.core.WorldContext; +import com.jozufozu.flywheel.backend.core.WorldTileRenderer; import com.jozufozu.flywheel.backend.effects.EffectsHandler; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; @@ -19,18 +31,28 @@ import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; +import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.WorldAttached; +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.DestroyBlockProgress; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.model.ModelBakery; +import net.minecraft.client.renderer.texture.Texture; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; +import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.resources.IResourceManager; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.world.World; import net.minecraftforge.resource.ISelectiveResourceReloadListener; @@ -45,7 +67,8 @@ public class Backend { public static GlCompat compat; public static EffectsHandler effects; - public static WorldAttached tileRenderer = new WorldAttached<>(BasicInstancedTileRenderer::new); + public static WorldAttached> tileRenderer = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.INSTANCE)); + public static WorldAttached> blockBreaking = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.CRUMBLING)); private static Matrix4f projectionMatrix = new Matrix4f(); private static boolean instancingAvailable; @@ -57,18 +80,18 @@ public class Backend { static { register(WorldContext.INSTANCE); + register(WorldContext.CRUMBLING); register(EffectsContext.INSTANCE); listeners.refreshListener(world -> { if (canUseInstancing() && world != null) { - BasicInstancedTileRenderer tileRenderer = Backend.tileRenderer.get(world); + WorldTileRenderer tileRenderer = Backend.tileRenderer.get(world); tileRenderer.invalidate(); world.loadedTileEntityList.forEach(tileRenderer::add); } }); listeners.setupFrameListener((world, stack, info, gameRenderer, lightTexture) -> { - Backend.tileRenderer.get(world) .beginFrame(info); }); @@ -174,7 +197,7 @@ public class Backend { Minecraft mc = Minecraft.getInstance(); ClientWorld world = mc.world; - BasicInstancedTileRenderer instancer = tileRenderer.get(world); + WorldTileRenderer instancer = tileRenderer.get(world); Entity renderViewEntity = mc.renderViewEntity; instancer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ()); @@ -182,15 +205,79 @@ public class Backend { public static void renderLayer(ClientWorld world, RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { if (!canUseInstancing(world)) return; + WorldTileRenderer renderer = tileRenderer.get(world); + if (renderer == null) return; layer.startDrawing(); - tileRenderer.get(world) - .render(layer, viewProjection, cameraX, cameraY, cameraZ); + renderer.render(layer, viewProjection, cameraX, cameraY, cameraZ); layer.endDrawing(); } + public static void renderBreaking(ClientWorld world, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { + if (!canUseInstancing(world)) return; + WorldTileRenderer renderer = blockBreaking.get(world); + if (renderer == null) return; + + WorldRenderer worldRenderer = Minecraft.getInstance().worldRenderer; + Long2ObjectMap> breakingProgressions = worldRenderer.blockBreakingProgressions; + + if (breakingProgressions.isEmpty()) return; + + for (Long2ObjectMap.Entry> entry : breakingProgressions.long2ObjectEntrySet()) { + BlockPos breakingPos = BlockPos.fromLong(entry.getLongKey()); + + SortedSet sortedset1 = entry.getValue(); + if (sortedset1 != null && !sortedset1.isEmpty()) { + renderer.add(world.getTileEntity(breakingPos)); + } + } + + renderer.beginFrame(Minecraft.getInstance().gameRenderer.getActiveRenderInfo()); + + RenderType layer = RenderType.getCutoutMipped(); + + layer.startDrawing(); + + glActiveTexture(GL_TEXTURE0); + + TextureManager textureManager = Minecraft.getInstance().textureManager; + Texture breaking = textureManager.getTexture(ModelBakery.BLOCK_DESTRUCTION_STAGE_TEXTURES.get(5)); + + if (breaking != null) { + + glBindTexture(GL_TEXTURE_2D, breaking.getGlTextureId()); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + + RenderSystem.enableBlend(); + RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.DST_COLOR, GlStateManager.DestFactor.SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + + RenderSystem.enableAlphaTest(); + RenderSystem.alphaFunc(516, 0.003921569F); + + RenderSystem.polygonOffset(-1.0F, -10.0F); + RenderSystem.enablePolygonOffset(); + } + + renderer.render(layer, viewProjection, cameraX, cameraY, cameraZ, program -> program.setTextureScale(64, 64)); + + if (breaking != null) { + glBindTexture(GL_TEXTURE_2D, textureManager.getTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE).getGlTextureId()); + + RenderSystem.disableBlend(); + RenderSystem.defaultBlendFunc(); + + RenderSystem.polygonOffset(0.0F, 0.0F); + RenderSystem.disablePolygonOffset(); + } + + layer.endDrawing(); + + renderer.invalidate(); + } + public static void enqueueUpdate(TileEntity te) { tileRenderer.get(te.getWorld()).queueUpdate(te); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java index cb8edd2b6..064dfd3d4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java @@ -1,6 +1,8 @@ package com.jozufozu.flywheel.backend.core; -import org.lwjgl.opengl.GL20; +import static org.lwjgl.opengl.GL20.glUniform1f; +import static org.lwjgl.opengl.GL20.glUniform1i; +import static org.lwjgl.opengl.GL20.glUniform3f; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; @@ -42,11 +44,11 @@ public class BasicProgram extends GlProgram { public void bind(Matrix4f viewProjection, double camX, double camY, double camZ, int debugMode) { super.bind(); - GL20.glUniform1i(uDebug, debugMode); - GL20.glUniform1f(uTime, AnimationTickHolder.getRenderTime()); + glUniform1i(uDebug, debugMode); + glUniform1f(uTime, AnimationTickHolder.getRenderTime()); uploadMatrixUniform(uViewProjection, viewProjection); - GL20.glUniform3f(uCameraPos, (float) camX, (float) camY, (float) camZ); + glUniform3f(uCameraPos, (float) camX, (float) camY, (float) camZ); fogMode.bind(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java new file mode 100644 index 000000000..e254a54d2 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java @@ -0,0 +1,22 @@ +package com.jozufozu.flywheel.backend.core; + +import static org.lwjgl.opengl.GL20.glUniform2f; + +import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; + +import net.minecraft.util.ResourceLocation; + +public class CrumblingProgram extends BasicProgram { + protected final int uTextureScale; + + public CrumblingProgram(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory) { + super(name, handle, fogFactory); + + uTextureScale = getUniformLocation("uTextureScale"); + } + + public void setTextureScale(float x, float y) { + glUniform2f(uTextureScale, x, y); + } + +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index 360d602aa..3febc5b2b 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -21,6 +21,7 @@ public class WorldContext

extends ShaderContext

{ private static final Pattern builtinPattern = Pattern.compile("#flwbuiltins"); public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation("create", "std"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); + public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation("create", "crumbling"), new FogSensitiveProgram.SpecLoader<>(CrumblingProgram::new)); private final ShaderSpecLoader

loader; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java similarity index 89% rename from src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java rename to src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java index 0f41acf2e..3ad0efec9 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicInstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java @@ -12,13 +12,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Matrix4f; -public class BasicInstancedTileRenderer extends InstancedTileRenderer { +public class WorldTileRenderer

extends InstancedTileRenderer

{ public static int MAX_ORIGIN_DISTANCE = 100; public BlockPos originCoordinate = BlockPos.ZERO; - public BasicInstancedTileRenderer() { - super(WorldContext.INSTANCE); + public WorldTileRenderer(WorldContext

context) { + super(context); } @Override @@ -50,7 +50,7 @@ public class BasicInstancedTileRenderer extends InstancedTileRenderer callback) { + ShaderCallback

callback) { BlockPos originCoordinate = getOriginCoordinate(); camX -= originCoordinate.getX(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java index cea898c4f..6ad43ad9d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java @@ -1,8 +1,20 @@ package com.jozufozu.flywheel.backend.gl.shader; -import java.util.Collection; +import static org.lwjgl.opengl.GL20.GL_LINK_STATUS; +import static org.lwjgl.opengl.GL20.GL_TRUE; +import static org.lwjgl.opengl.GL20.glAttachShader; +import static org.lwjgl.opengl.GL20.glBindAttribLocation; +import static org.lwjgl.opengl.GL20.glCreateProgram; +import static org.lwjgl.opengl.GL20.glDeleteProgram; +import static org.lwjgl.opengl.GL20.glGetProgramInfoLog; +import static org.lwjgl.opengl.GL20.glGetProgrami; +import static org.lwjgl.opengl.GL20.glGetUniformLocation; +import static org.lwjgl.opengl.GL20.glLinkProgram; +import static org.lwjgl.opengl.GL20.glUniform1i; +import static org.lwjgl.opengl.GL20.glUniformMatrix4fv; +import static org.lwjgl.opengl.GL20.glUseProgram; -import org.lwjgl.opengl.GL20; +import java.util.Collection; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.RenderUtil; @@ -26,11 +38,11 @@ public abstract class GlProgram extends GlObject { } public void bind() { - GL20.glUseProgram(handle()); + glUseProgram(handle()); } public void unbind() { - GL20.glUseProgram(0); + glUseProgram(0); } /** @@ -40,7 +52,7 @@ public abstract class GlProgram extends GlObject { * @return The uniform's index */ public int getUniformLocation(String uniform) { - int index = GL20.glGetUniformLocation(this.handle(), uniform); + int index = glGetUniformLocation(this.handle(), uniform); if (index < 0) { Backend.log.debug("No active uniform '{}' exists in program '{}'. Could be unused.", uniform, this.name); @@ -61,19 +73,19 @@ public abstract class GlProgram extends GlObject { int samplerUniform = getUniformLocation(name); if (samplerUniform >= 0) { - GL20.glUniform1i(samplerUniform, binding); + glUniform1i(samplerUniform, binding); } return samplerUniform; } protected static void uploadMatrixUniform(int uniform, Matrix4f mat) { - GL20.glUniformMatrix4fv(uniform, false, RenderUtil.writeMatrix(mat)); + glUniformMatrix4fv(uniform, false, RenderUtil.writeMatrix(mat)); } @Override protected void deleteInternal(int handle) { - GL20.glDeleteProgram(handle); + glDeleteProgram(handle); } public static class Builder { @@ -84,11 +96,11 @@ public abstract class GlProgram extends GlObject { public Builder(ResourceLocation name) { this.name = name; - this.program = GL20.glCreateProgram(); + this.program = glCreateProgram(); } public Builder attachShader(GlShader shader) { - GL20.glAttachShader(this.program, shader.handle()); + glAttachShader(this.program, shader.handle()); return this; } @@ -99,7 +111,7 @@ public abstract class GlProgram extends GlObject { } public Builder addAttribute(A attrib) { - GL20.glBindAttribLocation(this.program, attributeIndex, attrib.attribName()); + glBindAttribLocation(this.program, attributeIndex, attrib.attribName()); attributeIndex += attrib.attribSpec().getAttributeCount(); return this; } @@ -108,17 +120,17 @@ public abstract class GlProgram extends GlObject { * Links the attached shaders to this program. */ public Builder link() { - GL20.glLinkProgram(this.program); + glLinkProgram(this.program); - String log = GL20.glGetProgramInfoLog(this.program); + String log = glGetProgramInfoLog(this.program); if (!log.isEmpty()) { Backend.log.debug("Program link log for " + this.name + ": " + log); } - int result = GL20.glGetProgrami(this.program, GL20.GL_LINK_STATUS); + int result = glGetProgrami(this.program, GL_LINK_STATUS); - if (result != GL20.GL_TRUE) { + if (result != GL_TRUE) { throw new RuntimeException("Shader program linking failed, see log for details"); } diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 0c9400ae5..f42d9431e 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -5,7 +5,8 @@ import java.util.List; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.RenderWork; -import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; +import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.core.WorldTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllFluids; @@ -144,7 +145,7 @@ public class ClientEvents { if (world.isRemote() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) { CreateClient.invalidateRenderers(world); AnimationTickHolder.reset(); - BasicInstancedTileRenderer renderer = Backend.tileRenderer.get(world); + WorldTileRenderer renderer = Backend.tileRenderer.get(world); renderer.invalidate(); ((ClientWorld) world).loadedTileEntityList.forEach(renderer::add); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index 203ea1b8a..416352b46 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -21,6 +21,7 @@ import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.world.ClientWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3d; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -66,6 +67,23 @@ public class RenderHooksMixin { Backend.listeners.refresh(world); } + @Inject(at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;long2ObjectEntrySet()Lit/unimi/dsi/fastutil/objects/ObjectSet;"), method = "render") + private void renderBlockBreaking(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, + ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_, + CallbackInfo ci) { + if (!Backend.available()) + return; + + Matrix4f view = stack.peek() + .getModel(); + Matrix4f viewProjection = view.copy(); + viewProjection.multiplyBackward(Backend.getProjectionMatrix()); + + Vector3d cameraPos = info.getProjectedView(); + Backend.renderBreaking(world, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z); + GL20.glUseProgram(0); + } + // Effects system @Inject(method = "render", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;render(F)V")) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java index 59427ef6c..b39f512ea 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java @@ -11,7 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.core.BasicInstancedTileRenderer; +import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.core.WorldTileRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -46,7 +47,7 @@ public class TileWorldHookMixin { @Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities") private void onChunkUnload(CallbackInfo ci) { if (isRemote) { - BasicInstancedTileRenderer kineticRenderer = Backend.tileRenderer.get(self); + WorldTileRenderer kineticRenderer = Backend.tileRenderer.get(self); for (TileEntity tile : tileEntitiesToBeRemoved) { kineticRenderer.remove(tile); } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index f5b2f4588..b99640057 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -89,3 +89,5 @@ public net.minecraft.util.math.vector.Matrix4f field_226587_m_ #a30 public net.minecraft.util.math.vector.Matrix4f field_226588_n_ #a31 public net.minecraft.util.math.vector.Matrix4f field_226589_o_ #a32 public net.minecraft.util.math.vector.Matrix4f field_226590_p_ #a33 + +public net.minecraft.client.renderer.WorldRenderer field_228407_B_ #blockBreakingProgressions diff --git a/src/main/resources/assets/create/flywheel/shaders/block.frag b/src/main/resources/assets/create/flywheel/shaders/block.frag index ccac8b02b..625fc9ea5 100644 --- a/src/main/resources/assets/create/flywheel/shaders/block.frag +++ b/src/main/resources/assets/create/flywheel/shaders/block.frag @@ -7,13 +7,10 @@ varying vec2 Light; varying float Diffuse; varying vec4 Color; -uniform sampler2D uBlockAtlas; -uniform sampler2D uLightMap; - void main() { - vec4 tex = texture2D(uBlockAtlas, TexCoords); + vec4 tex = FLWBlockTexture(TexCoords); - vec4 color = vec4(tex.rgb * FLWLight(Light, uLightMap).rgb * Diffuse, tex.a) * Color; + vec4 color = vec4(tex.rgb * FLWLight(Light).rgb * Diffuse, tex.a) * Color; FLWFinalizeColor(color); diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag index ac2690e87..5091e0ae3 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag @@ -3,6 +3,13 @@ varying vec3 BoxCoord; uniform sampler3D uLightVolume; +uniform sampler2D uBlockAtlas; +uniform sampler2D uLightMap; + +vec4 FLWBlockTexture(vec2 texCoords) { + return texture2D(uBlockAtlas, texCoords); +} + void FLWFinalizeColor(inout vec4 color) { #if defined(USE_FOG) float a = color.a; @@ -13,7 +20,7 @@ void FLWFinalizeColor(inout vec4 color) { #endif } -vec4 FLWLight(vec2 lightCoords, sampler2D lightMap) { +vec4 FLWLight(vec2 lightCoords) { vec2 lm = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg); - return texture2D(lightMap, lm * 0.9375 + 0.03125); + return texture2D(uLightMap, lm * 0.9375 + 0.03125); } diff --git a/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.frag new file mode 100644 index 000000000..d5dda65a2 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.frag @@ -0,0 +1,23 @@ +#flwinclude <"create:std/fog.glsl"> + +uniform vec2 uTextureScale; +uniform sampler2D uBlockAtlas; +uniform sampler2D uLightMap; + +vec4 FLWBlockTexture(vec2 texCoords) { + return texture2D(uBlockAtlas, texCoords * uTextureScale); +} + +void FLWFinalizeColor(inout vec4 color) { + #if defined(USE_FOG) + float a = color.a; + float fog = clamp(FLWFogFactor(), 0., 1.); + + color = mix(uFogColor, color, fog); + color.a = a; + #endif +} + +vec4 FLWLight(vec2 lightCoords) { + return vec4(1.); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.vert new file mode 100644 index 000000000..694f2920e --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.vert @@ -0,0 +1 @@ +#flwinclude <"create:std/builtin.vert"> diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag index 4e08fae38..42be74ede 100644 --- a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag @@ -1,5 +1,12 @@ #flwinclude <"create:std/fog.glsl"> +uniform sampler2D uBlockAtlas; +uniform sampler2D uLightMap; + +vec4 FLWBlockTexture(vec2 texCoords) { + return texture2D(uBlockAtlas, texCoords); +} + void FLWFinalizeColor(inout vec4 color) { #if defined(USE_FOG) float a = color.a; @@ -10,7 +17,7 @@ void FLWFinalizeColor(inout vec4 color) { #endif } -vec4 FLWLight(vec2 lightCoords, sampler2D lightMap) { +vec4 FLWLight(vec2 lightCoords) { vec2 lm = lightCoords * 0.9375 + 0.03125; - return texture2D(lightMap, lm); + return texture2D(uLightMap, lm); } From 17676822cf0f27f0126023b526ffffa4d21f9366 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 7 May 2021 18:18:32 +1000 Subject: [PATCH 030/198] Remove Podzol from the grass pressing recipe and add a compatibility recipe for Environmental's Podzol Path --- .../data/recipe/PressingRecipeGen.java | 2 +- .../environmental/pressing/podzol_path.json | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/data/create/recipes/compat/environmental/pressing/podzol_path.json diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/PressingRecipeGen.java b/src/main/java/com/simibubi/create/foundation/data/recipe/PressingRecipeGen.java index ca9740ab9..a42bd4893 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/PressingRecipeGen.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/PressingRecipeGen.java @@ -14,7 +14,7 @@ public class PressingRecipeGen extends ProcessingRecipeGen { SUGAR_CANE = create(() -> Items.SUGAR_CANE, b -> b.output(Items.PAPER)), - PATH = create("path", b -> b.require(Ingredient.fromItems(Items.GRASS_BLOCK, Items.DIRT, Items.PODZOL)) + PATH = create("path", b -> b.require(Ingredient.fromItems(Items.GRASS_BLOCK, Items.DIRT)) .output(Items.GRASS_PATH)), IRON = create("iron_ingot", b -> b.require(I.iron()) diff --git a/src/main/resources/data/create/recipes/compat/environmental/pressing/podzol_path.json b/src/main/resources/data/create/recipes/compat/environmental/pressing/podzol_path.json new file mode 100644 index 000000000..a75ed6119 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/environmental/pressing/podzol_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "environmental" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "minecraft:podzol" + } + ] + ], + "results": [ + { + "item": "environmental:podzol_path" + } + ] +} \ No newline at end of file From 25f9095b251117001fb34fa972ae33bd7cedaaba Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 7 May 2021 18:20:15 +1000 Subject: [PATCH 031/198] Add a milling recipe for Necrotic Bone from Tinker's Construct --- .../tconstruct/milling/necrotic_bone.json | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/resources/data/create/recipes/compat/tconstruct/milling/necrotic_bone.json diff --git a/src/main/resources/data/create/recipes/compat/tconstruct/milling/necrotic_bone.json b/src/main/resources/data/create/recipes/compat/tconstruct/milling/necrotic_bone.json new file mode 100644 index 000000000..bf66d163f --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/tconstruct/milling/necrotic_bone.json @@ -0,0 +1,30 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "tconstruct" + } + ], + "type": "create:milling", + "ingredients": [ + { + "item": "tconstruct:necrotic_bone" + } + ], + "results": [ + { + "item": "minecraft:bone_meal", + "count": 3 + }, + { + "item": "minecraft:black_dye", + "chance": 0.25 + }, + { + "item": "minecraft:bone_meal", + "count": 3, + "chance": 0.25 + } + ], + "processingTime": 100 +} \ No newline at end of file From 64baf8216c032c89aacc463c490fd25bdd535295 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 7 May 2021 18:20:53 +1000 Subject: [PATCH 032/198] Fix Buzzier Bees compatibility and move the old flowers to Environmental compatibility --- .../buzzier_bees/milling/buttercup.json | 26 +++++++++++++++++++ .../buzzier_bees/milling/pink_clover.json | 4 +-- .../buzzier_bees/milling/white_clover.json | 4 +-- .../milling/bird_of_paradise.json | 4 +-- .../milling/blue_delphinium.json | 26 +++++++++++++++++++ .../milling/bluebell.json | 4 +-- .../milling/cartwheel.json | 4 +-- .../milling/dianthus.json | 4 +-- .../milling/magenta_hibiscus.json | 4 +-- .../milling/orange_hibiscus.json | 4 +-- .../milling/pink_delphinium.json | 26 +++++++++++++++++++ .../milling/pink_hibiscus.json | 4 +-- .../milling/purple_delphinium.json | 26 +++++++++++++++++++ .../milling/purple_hibiscus.json | 4 +-- .../milling/red_hibiscus.json | 4 +-- .../milling/red_lotus_flower.json | 26 +++++++++++++++++++ .../milling/violet.json | 4 +-- .../milling/white_delphinium.json | 26 +++++++++++++++++++ .../milling/white_lotus_flower.json} | 8 +++--- .../milling/yellow_hibiscus.json | 4 +-- 20 files changed, 186 insertions(+), 30 deletions(-) create mode 100644 src/main/resources/data/create/recipes/compat/buzzier_bees/milling/buttercup.json rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/bird_of_paradise.json (84%) create mode 100644 src/main/resources/data/create/recipes/compat/environmental/milling/blue_delphinium.json rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/bluebell.json (77%) rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/cartwheel.json (82%) rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/dianthus.json (82%) rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/magenta_hibiscus.json (81%) rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/orange_hibiscus.json (81%) create mode 100644 src/main/resources/data/create/recipes/compat/environmental/milling/pink_delphinium.json rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/pink_hibiscus.json (81%) create mode 100644 src/main/resources/data/create/recipes/compat/environmental/milling/purple_delphinium.json rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/purple_hibiscus.json (81%) rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/red_hibiscus.json (81%) create mode 100644 src/main/resources/data/create/recipes/compat/environmental/milling/red_lotus_flower.json rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/violet.json (83%) create mode 100644 src/main/resources/data/create/recipes/compat/environmental/milling/white_delphinium.json rename src/main/resources/data/create/recipes/compat/{buzzier_bees/milling/columbine.json => environmental/milling/white_lotus_flower.json} (71%) rename src/main/resources/data/create/recipes/compat/{buzzier_bees => environmental}/milling/yellow_hibiscus.json (81%) diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/buttercup.json b/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/buttercup.json new file mode 100644 index 000000000..daf89729b --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/buttercup.json @@ -0,0 +1,26 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "buzzier_bees" + } + ], + "type": "create:milling", + "ingredients": [ + { + "item": "buzzier_bees:buttercup" + } + ], + "results": [ + { + "item": "minecraft:yellow_dye", + "count": 2 + }, + { + "item": "minecraft:lime_dye", + "count": 1, + "chance": 0.1 + } + ], + "processingTime": 50 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/pink_clover.json b/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/pink_clover.json index c8753a417..f52886520 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/pink_clover.json +++ b/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/pink_clover.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "buzzier_bees" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:pink_clover" + "item": "buzzier_bees:pink_clover" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/white_clover.json b/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/white_clover.json index 7c9a228b2..1542d6ddb 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/white_clover.json +++ b/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/white_clover.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "buzzier_bees" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:white_clover" + "item": "buzzier_bees:white_clover" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/bird_of_paradise.json b/src/main/resources/data/create/recipes/compat/environmental/milling/bird_of_paradise.json similarity index 84% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/bird_of_paradise.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/bird_of_paradise.json index 5edf6abea..0128172cc 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/bird_of_paradise.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/bird_of_paradise.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:bird_of_paradise" + "item": "environmental:bird_of_paradise" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/environmental/milling/blue_delphinium.json b/src/main/resources/data/create/recipes/compat/environmental/milling/blue_delphinium.json new file mode 100644 index 000000000..c37ac70bb --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/blue_delphinium.json @@ -0,0 +1,26 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "environmental" + } + ], + "type": "create:milling", + "ingredients": [ + { + "item": "environmental:blue_delphinium" + } + ], + "results": [ + { + "item": "minecraft:blue_dye", + "count": 3 + }, + { + "item": "minecraft:blue_dye", + "count": 1, + "chance": 0.1 + } + ], + "processingTime": 50 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/bluebell.json b/src/main/resources/data/create/recipes/compat/environmental/milling/bluebell.json similarity index 77% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/bluebell.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/bluebell.json index b049cbc96..b56eb9e8c 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/bluebell.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/bluebell.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:bluebell" + "item": "environmental:bluebell" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/cartwheel.json b/src/main/resources/data/create/recipes/compat/environmental/milling/cartwheel.json similarity index 82% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/cartwheel.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/cartwheel.json index 169193092..2659d0528 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/cartwheel.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/cartwheel.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:cartwheel" + "item": "environmental:cartwheel" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/dianthus.json b/src/main/resources/data/create/recipes/compat/environmental/milling/dianthus.json similarity index 82% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/dianthus.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/dianthus.json index 48c05d143..646c2c6ee 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/dianthus.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/dianthus.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:jolyce" + "item": "environmental:dianthus" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/magenta_hibiscus.json b/src/main/resources/data/create/recipes/compat/environmental/milling/magenta_hibiscus.json similarity index 81% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/magenta_hibiscus.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/magenta_hibiscus.json index 9e00cf80c..f33e7bda3 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/magenta_hibiscus.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/magenta_hibiscus.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:magenta_hibiscus" + "item": "environmental:magenta_hibiscus" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/orange_hibiscus.json b/src/main/resources/data/create/recipes/compat/environmental/milling/orange_hibiscus.json similarity index 81% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/orange_hibiscus.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/orange_hibiscus.json index 6cc0c4ac3..ab7f0b6e9 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/orange_hibiscus.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/orange_hibiscus.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:orange_hibiscus" + "item": "environmental:orange_hibiscus" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/environmental/milling/pink_delphinium.json b/src/main/resources/data/create/recipes/compat/environmental/milling/pink_delphinium.json new file mode 100644 index 000000000..9c2e2591c --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/pink_delphinium.json @@ -0,0 +1,26 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "environmental" + } + ], + "type": "create:milling", + "ingredients": [ + { + "item": "environmental:pink_delphinium" + } + ], + "results": [ + { + "item": "minecraft:pink_dye", + "count": 3 + }, + { + "item": "minecraft:pink_dye", + "count": 1, + "chance": 0.1 + } + ], + "processingTime": 50 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/pink_hibiscus.json b/src/main/resources/data/create/recipes/compat/environmental/milling/pink_hibiscus.json similarity index 81% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/pink_hibiscus.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/pink_hibiscus.json index fa8c4c473..a85f2e64b 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/pink_hibiscus.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/pink_hibiscus.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:pink_hibiscus" + "item": "environmental:pink_hibiscus" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/environmental/milling/purple_delphinium.json b/src/main/resources/data/create/recipes/compat/environmental/milling/purple_delphinium.json new file mode 100644 index 000000000..b99812be8 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/purple_delphinium.json @@ -0,0 +1,26 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "environmental" + } + ], + "type": "create:milling", + "ingredients": [ + { + "item": "environmental:purple_delphinium" + } + ], + "results": [ + { + "item": "minecraft:purple_dye", + "count": 3 + }, + { + "item": "minecraft:purple_dye", + "count": 1, + "chance": 0.1 + } + ], + "processingTime": 50 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/purple_hibiscus.json b/src/main/resources/data/create/recipes/compat/environmental/milling/purple_hibiscus.json similarity index 81% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/purple_hibiscus.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/purple_hibiscus.json index 91ac754a7..2615523eb 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/purple_hibiscus.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/purple_hibiscus.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:purple_hibiscus" + "item": "environmental:purple_hibiscus" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/red_hibiscus.json b/src/main/resources/data/create/recipes/compat/environmental/milling/red_hibiscus.json similarity index 81% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/red_hibiscus.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/red_hibiscus.json index 5b50d8189..6424ad955 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/red_hibiscus.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/red_hibiscus.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:red_hibiscus" + "item": "environmental:red_hibiscus" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/environmental/milling/red_lotus_flower.json b/src/main/resources/data/create/recipes/compat/environmental/milling/red_lotus_flower.json new file mode 100644 index 000000000..7e3f96013 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/red_lotus_flower.json @@ -0,0 +1,26 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "environmental" + } + ], + "type": "create:milling", + "ingredients": [ + { + "item": "environmental:red_lotus_flower" + } + ], + "results": [ + { + "item": "minecraft:red_dye", + "count": 2 + }, + { + "item": "minecraft:red_dye", + "count": 1, + "chance": 0.1 + } + ], + "processingTime": 50 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/violet.json b/src/main/resources/data/create/recipes/compat/environmental/milling/violet.json similarity index 83% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/violet.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/violet.json index fea46a464..b9be9005f 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/violet.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/violet.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:violet" + "item": "environmental:violet" } ], "results": [ diff --git a/src/main/resources/data/create/recipes/compat/environmental/milling/white_delphinium.json b/src/main/resources/data/create/recipes/compat/environmental/milling/white_delphinium.json new file mode 100644 index 000000000..9f49ca4d4 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/white_delphinium.json @@ -0,0 +1,26 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "environmental" + } + ], + "type": "create:milling", + "ingredients": [ + { + "item": "environmental:white_delphinium" + } + ], + "results": [ + { + "item": "minecraft:white_dye", + "count": 3 + }, + { + "item": "minecraft:white_dye", + "count": 1, + "chance": 0.1 + } + ], + "processingTime": 50 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/columbine.json b/src/main/resources/data/create/recipes/compat/environmental/milling/white_lotus_flower.json similarity index 71% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/columbine.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/white_lotus_flower.json index f5988729e..e024f73c5 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/columbine.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/white_lotus_flower.json @@ -2,22 +2,22 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:columbine" + "item": "environmental:white_lotus_flower" } ], "results": [ { - "item": "minecraft:purple_dye", + "item": "minecraft:white_dye", "count": 2 }, { - "item": "minecraft:white_dye", + "item": "minecraft:lime_dye", "count": 1, "chance": 0.1 } diff --git a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/yellow_hibiscus.json b/src/main/resources/data/create/recipes/compat/environmental/milling/yellow_hibiscus.json similarity index 81% rename from src/main/resources/data/create/recipes/compat/buzzier_bees/milling/yellow_hibiscus.json rename to src/main/resources/data/create/recipes/compat/environmental/milling/yellow_hibiscus.json index f2ce4cead..bd9b8453c 100644 --- a/src/main/resources/data/create/recipes/compat/buzzier_bees/milling/yellow_hibiscus.json +++ b/src/main/resources/data/create/recipes/compat/environmental/milling/yellow_hibiscus.json @@ -2,13 +2,13 @@ "conditions": [ { "type": "forge:mod_loaded", - "modid": "buzzierbees" + "modid": "environmental" } ], "type": "create:milling", "ingredients": [ { - "item": "buzzierbees:daybloom" + "item": "environmental:yellow_hibiscus" } ], "results": [ From 0b72781e077954e36fe8a0262c108f9c774134cd Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 7 May 2021 18:28:57 +1000 Subject: [PATCH 033/198] Add a crushing recipe for ice to obtain ice cubes when Neapolitan is present --- .../compat/neapolitan/crushing/ice.json | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/resources/data/create/recipes/compat/neapolitan/crushing/ice.json diff --git a/src/main/resources/data/create/recipes/compat/neapolitan/crushing/ice.json b/src/main/resources/data/create/recipes/compat/neapolitan/crushing/ice.json new file mode 100644 index 000000000..cc093968a --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/neapolitan/crushing/ice.json @@ -0,0 +1,26 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "neapolitan" + } + ], + "type": "create:crushing", + "ingredients": [ + { + "item": "minecraft:ice" + } + ], + "results": [ + { + "item": "neapolitan:ice_cubes", + "count": 3 + }, + { + "item": "neapolitan:ice_cubes", + "count": 3, + "chance": 0.25 + } + ], + "processingTime": 100 +} \ No newline at end of file From 14e6db837b287506f834a817f78def9c2df9a3ac Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 7 May 2021 18:32:10 +1000 Subject: [PATCH 034/198] Add filling and emptying recipes for Neapolitan's milk bottle --- .../neapolitan/emptying/milk_bottle.json | 23 +++++++++++++++++++ .../neapolitan/filling/milk_bottle.json | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/main/resources/data/create/recipes/compat/neapolitan/emptying/milk_bottle.json create mode 100644 src/main/resources/data/create/recipes/compat/neapolitan/filling/milk_bottle.json diff --git a/src/main/resources/data/create/recipes/compat/neapolitan/emptying/milk_bottle.json b/src/main/resources/data/create/recipes/compat/neapolitan/emptying/milk_bottle.json new file mode 100644 index 000000000..f4785b681 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/neapolitan/emptying/milk_bottle.json @@ -0,0 +1,23 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "neapolitan" + } + ], + "type": "create:emptying", + "ingredients": [ + { + "item": "neapolitan:milk_bottle" + } + ], + "results": [ + { + "item": "minecraft:glass_bottle" + }, + { + "fluid": "create:milk", + "amount": 250 + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/neapolitan/filling/milk_bottle.json b/src/main/resources/data/create/recipes/compat/neapolitan/filling/milk_bottle.json new file mode 100644 index 000000000..42ed87174 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/neapolitan/filling/milk_bottle.json @@ -0,0 +1,23 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "neapolitan" + } + ], + "type": "create:filling", + "ingredients": [ + { + "item": "minecraft:glass_bottle" + }, + { + "fluidTag": "forge:milk", + "amount": 250 + } + ], + "results": [ + { + "item": "neapolitan:milk_bottle" + } + ] +} \ No newline at end of file From f6150ce1c73d996acf52bc6bad2338bc802d83f8 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 7 May 2021 18:35:34 +1000 Subject: [PATCH 035/198] Add pressing recipes for path blocks from Environmental, Atmospheric and BetterEnd (Forge) --- .../atmospheric/pressing/crustose_path.json | 21 +++++++++++++++++++ .../pressing/amber_moss_path.json | 21 +++++++++++++++++++ .../pressing/cave_moss_path.json | 21 +++++++++++++++++++ .../pressing/chorus_nylium_path.json | 21 +++++++++++++++++++ .../pressing/crystal_moss_path.json | 21 +++++++++++++++++++ .../pressing/end_moss_path.json | 21 +++++++++++++++++++ .../pressing/end_myclium_path.json | 21 +++++++++++++++++++ .../pressing/jungle_moss_path.json | 21 +++++++++++++++++++ .../pressing/pink_moss_path.json | 21 +++++++++++++++++++ .../pressing/shadow_grass_path.json | 21 +++++++++++++++++++ .../environmental/pressing/mycelium_path.json | 21 +++++++++++++++++++ 11 files changed, 231 insertions(+) create mode 100644 src/main/resources/data/create/recipes/compat/atmospheric/pressing/crustose_path.json create mode 100644 src/main/resources/data/create/recipes/compat/betterendforge/pressing/amber_moss_path.json create mode 100644 src/main/resources/data/create/recipes/compat/betterendforge/pressing/cave_moss_path.json create mode 100644 src/main/resources/data/create/recipes/compat/betterendforge/pressing/chorus_nylium_path.json create mode 100644 src/main/resources/data/create/recipes/compat/betterendforge/pressing/crystal_moss_path.json create mode 100644 src/main/resources/data/create/recipes/compat/betterendforge/pressing/end_moss_path.json create mode 100644 src/main/resources/data/create/recipes/compat/betterendforge/pressing/end_myclium_path.json create mode 100644 src/main/resources/data/create/recipes/compat/betterendforge/pressing/jungle_moss_path.json create mode 100644 src/main/resources/data/create/recipes/compat/betterendforge/pressing/pink_moss_path.json create mode 100644 src/main/resources/data/create/recipes/compat/betterendforge/pressing/shadow_grass_path.json create mode 100644 src/main/resources/data/create/recipes/compat/environmental/pressing/mycelium_path.json diff --git a/src/main/resources/data/create/recipes/compat/atmospheric/pressing/crustose_path.json b/src/main/resources/data/create/recipes/compat/atmospheric/pressing/crustose_path.json new file mode 100644 index 000000000..d46e53cd2 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/atmospheric/pressing/crustose_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "atmospheric" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "atmospheric:crustose" + } + ] + ], + "results": [ + { + "item": "atmospheric:crustose_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/betterendforge/pressing/amber_moss_path.json b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/amber_moss_path.json new file mode 100644 index 000000000..4a580ce1d --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/amber_moss_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "betterendforge" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "betterendforge:amber_moss" + } + ] + ], + "results": [ + { + "item": "betterendforge:amber_moss_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/betterendforge/pressing/cave_moss_path.json b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/cave_moss_path.json new file mode 100644 index 000000000..ee93ce6f5 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/cave_moss_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "betterendforge" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "betterendforge:cave_moss" + } + ] + ], + "results": [ + { + "item": "betterendforge:cave_moss_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/betterendforge/pressing/chorus_nylium_path.json b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/chorus_nylium_path.json new file mode 100644 index 000000000..96c02b035 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/chorus_nylium_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "betterendforge" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "betterendforge:chorus_nylium" + } + ] + ], + "results": [ + { + "item": "betterendforge:chorus_nylium_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/betterendforge/pressing/crystal_moss_path.json b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/crystal_moss_path.json new file mode 100644 index 000000000..40e7bb3f5 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/crystal_moss_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "betterendforge" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "betterendforge:crystal_moss" + } + ] + ], + "results": [ + { + "item": "betterendforge:crystal_moss_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/betterendforge/pressing/end_moss_path.json b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/end_moss_path.json new file mode 100644 index 000000000..48d9d7991 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/end_moss_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "betterendforge" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "betterendforge:end_moss" + } + ] + ], + "results": [ + { + "item": "betterendforge:end_moss_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/betterendforge/pressing/end_myclium_path.json b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/end_myclium_path.json new file mode 100644 index 000000000..d117d9df6 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/end_myclium_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "betterendforge" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "betterendforge:end_mycelium" + } + ] + ], + "results": [ + { + "item": "betterendforge:end_mycelium_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/betterendforge/pressing/jungle_moss_path.json b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/jungle_moss_path.json new file mode 100644 index 000000000..36fc2aa30 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/jungle_moss_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "betterendforge" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "betterendforge:jungle_moss" + } + ] + ], + "results": [ + { + "item": "betterendforge:jungle_moss_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/betterendforge/pressing/pink_moss_path.json b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/pink_moss_path.json new file mode 100644 index 000000000..f41bcf66c --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/pink_moss_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "betterendforge" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "betterendforge:pink_moss" + } + ] + ], + "results": [ + { + "item": "betterendforge:pink_moss_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/betterendforge/pressing/shadow_grass_path.json b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/shadow_grass_path.json new file mode 100644 index 000000000..2194ae013 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/betterendforge/pressing/shadow_grass_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "betterendforge" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "betterendforge:shadow_grass" + } + ] + ], + "results": [ + { + "item": "betterendforge:shadow_grass_path" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/environmental/pressing/mycelium_path.json b/src/main/resources/data/create/recipes/compat/environmental/pressing/mycelium_path.json new file mode 100644 index 000000000..452fcc3ab --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/environmental/pressing/mycelium_path.json @@ -0,0 +1,21 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "environmental" + } + ], + "type": "create:pressing", + "ingredients": [ + [ + { + "item": "minecraft:mycelium" + } + ] + ], + "results": [ + { + "item": "environmental:mycelium_path" + } + ] +} \ No newline at end of file From e05db3cd76db531e41f8e3a48a4c4894792e7a6e Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Fri, 7 May 2021 13:33:18 -0700 Subject: [PATCH 036/198] Check for incorrect FluidBucketWrapper usage Items that use FluidBucketWrapper incorrectly: - Will not get filling recipes - Cannot be filled with the spout --- .../compat/jei/category/SpoutCategory.java | 3 ++ .../fluids/actors/GenericItemFilling.java | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java index 9bc30ce82..0c965b5c6 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java @@ -12,6 +12,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.Create; import com.simibubi.create.compat.jei.category.animations.AnimatedSpout; import com.simibubi.create.content.contraptions.fluids.actors.FillingRecipe; +import com.simibubi.create.content.contraptions.fluids.actors.GenericItemFilling; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder; import com.simibubi.create.foundation.fluid.FluidIngredient; @@ -71,6 +72,8 @@ public class SpoutCategory extends CreateRecipeCategory { ItemStack copy = stack.copy(); copy.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) .ifPresent(fhi -> { + if (!GenericItemFilling.isFluidHandlerValid(copy, fhi)) + return; FluidStack fluidCopy = fluidStack.copy(); fluidCopy.setAmount(1000); fhi.fill(fluidCopy, FluidAction.EXECUTE); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java index 801f45fd1..271378b4d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/GenericItemFilling.java @@ -5,9 +5,11 @@ import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler import com.simibubi.create.foundation.fluid.FluidHelper; import net.minecraft.fluid.Fluids; +import net.minecraft.item.BucketItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.item.MilkBucketItem; import net.minecraft.potion.PotionUtils; import net.minecraft.potion.Potions; import net.minecraft.world.World; @@ -20,6 +22,33 @@ import net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper; public class GenericItemFilling { + /** + * Checks if an ItemStack's IFluidHandlerItem is valid. Ideally, this check would + * not be necessary. Unfortunately, some mods that copy the functionality of the + * MilkBucketItem copy the FluidBucketWrapper capability that is patched in by + * Forge without looking into what it actually does. In all cases this is + * incorrect because having a non-bucket item turn into a bucket item does not + * make sense. + * + *

This check is only necessary for filling since a FluidBucketWrapper will be + * empty if it is initialized with a non-bucket item. + * + * @param stack The ItemStack. + * @param fluidHandler The IFluidHandlerItem instance retrieved from the ItemStack. + * @return If the IFluidHandlerItem is valid for the passed ItemStack. + */ + public static boolean isFluidHandlerValid(ItemStack stack, IFluidHandlerItem fluidHandler) { + // Not instanceof in case a correct subclass is made + if (fluidHandler.getClass() == FluidBucketWrapper.class) { + Item item = stack.getItem(); + // Forge does not patch the FluidBucketWrapper onto subclasses of BucketItem + if (item.getClass() != BucketItem.class && !(item instanceof MilkBucketItem)) { + return false; + } + } + return true; + } + public static boolean canItemBeFilled(World world, ItemStack stack) { if (stack.getItem() == Items.GLASS_BOTTLE) return true; @@ -31,6 +60,8 @@ public class GenericItemFilling { IFluidHandlerItem tank = capability.orElse(null); if (tank == null) return false; + if (!isFluidHandlerValid(stack, tank)) + return false; for (int i = 0; i < tank.getTanks(); i++) { if (tank.getFluidInTank(i) .getAmount() < tank.getTankCapacity(i)) From aa1a45f16493b53dbc4093c84bb17e5c151a6c02 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Fri, 7 May 2021 21:24:07 -0700 Subject: [PATCH 037/198] Block breaking overlay is animated now --- .../jozufozu/flywheel/backend/Backend.java | 87 ++++++++----------- .../backend/core/CrumblingRenderer.java | 14 +++ .../core/{ => materials}/BasicAttributes.java | 2 +- .../core/{ => materials}/BasicData.java | 2 +- .../core/{ => materials}/IFlatLight.java | 2 +- .../core/{ => materials}/ModelAttributes.java | 2 +- .../core/{ => materials}/ModelData.java | 2 +- .../{ => materials}/OrientedAttributes.java | 2 +- .../core/{ => materials}/OrientedData.java | 2 +- .../core/{ => materials}/OrientedModel.java | 2 +- .../{ => materials}/TransformAttributes.java | 2 +- .../{ => materials}/TransformedModel.java | 2 +- .../backend/instancing/InstancedModel.java | 2 +- .../instancing/InstancedTileRenderer.java | 24 +++-- .../instancing/TileEntityInstance.java | 6 +- .../contraptions/base/KineticData.java | 2 +- .../contraptions/base/RotatingModel.java | 2 +- .../actors/HarvesterActorInstance.java | 2 +- .../components/crank/HandCrankInstance.java | 2 +- .../deployer/DeployerActorInstance.java | 2 +- .../components/deployer/DeployerInstance.java | 2 +- .../components/flywheel/FlyWheelInstance.java | 2 +- .../flywheel/engine/EngineInstance.java | 2 +- .../components/mixer/MixerInstance.java | 2 +- .../components/press/PressInstance.java | 2 +- .../bearing/BearingInstance.java | 2 +- .../bearing/StabilizedBearingInstance.java | 2 +- .../chassis/StickerInstance.java | 2 +- .../gantry/GantryCarriageInstance.java | 2 +- .../pulley/AbstractPulleyInstance.java | 16 ++-- .../pulley/HosePulleyInstance.java | 2 +- .../pulley/RopePulleyInstance.java | 2 +- .../fluids/pipes/FluidValveInstance.java | 2 +- .../relays/belt/BeltInstancedModel.java | 2 +- .../relays/gauge/GaugeInstance.java | 2 +- .../content/logistics/block/FlapData.java | 2 +- .../block/depot/EjectorInstance.java | 2 +- .../diodes/AdjustableRepeaterInstance.java | 2 +- .../block/mechanicalArm/ArmInstance.java | 2 +- .../block/redstone/AnalogLeverInstance.java | 2 +- .../block/SchematicannonInstance.java | 2 +- .../foundation/mixin/RenderHooksMixin.java | 9 +- .../foundation/render/AllMaterialSpecs.java | 8 +- .../foundation/render/AllProgramSpecs.java | 8 +- 44 files changed, 129 insertions(+), 115 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/CrumblingRenderer.java rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/BasicAttributes.java (93%) rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/BasicData.java (96%) rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/IFlatLight.java (94%) rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/ModelAttributes.java (94%) rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/ModelData.java (92%) rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/OrientedAttributes.java (93%) rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/OrientedData.java (97%) rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/OrientedModel.java (93%) rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/TransformAttributes.java (93%) rename src/main/java/com/jozufozu/flywheel/backend/core/{ => materials}/TransformedModel.java (93%) diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index 9be7ca63e..ade41072b 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -1,18 +1,16 @@ package com.jozufozu.flywheel.backend; -import static org.lwjgl.opengl.GL11.GL_REPEAT; import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D; -import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_S; -import static org.lwjgl.opengl.GL11.GL_TEXTURE_WRAP_T; import static org.lwjgl.opengl.GL11.glBindTexture; -import static org.lwjgl.opengl.GL11.glTexParameteri; import static org.lwjgl.opengl.GL13.GL_TEXTURE0; import static org.lwjgl.opengl.GL13.glActiveTexture; +import java.util.BitSet; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.SortedSet; +import java.util.Vector; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -20,7 +18,7 @@ import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; import com.jozufozu.flywheel.backend.core.BasicProgram; -import com.jozufozu.flywheel.backend.core.CrumblingProgram; +import com.jozufozu.flywheel.backend.core.CrumblingRenderer; import com.jozufozu.flywheel.backend.core.EffectsContext; import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.core.WorldTileRenderer; @@ -31,14 +29,13 @@ import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.WorldAttached; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.DestroyBlockProgress; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.WorldRenderer; @@ -47,10 +44,10 @@ import net.minecraft.client.renderer.texture.Texture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; -import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.resources.IResourceManager; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.LazyValue; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; @@ -68,7 +65,13 @@ public class Backend { public static EffectsHandler effects; public static WorldAttached> tileRenderer = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.INSTANCE)); - public static WorldAttached> blockBreaking = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.CRUMBLING)); + public static LazyValue> blockBreaking = new LazyValue<>(() -> { + Vector renderers = new Vector<>(10); + for (int i = 0; i < 10; i++) { + renderers.add(new CrumblingRenderer()); + } + return renderers; + }); private static Matrix4f projectionMatrix = new Matrix4f(); private static boolean instancingAvailable; @@ -215,67 +218,49 @@ public class Backend { layer.endDrawing(); } + private static final RenderType CRUMBLING = ModelBakery.BLOCK_DESTRUCTION_RENDER_LAYERS.get(0); + public static void renderBreaking(ClientWorld world, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { if (!canUseInstancing(world)) return; - WorldTileRenderer renderer = blockBreaking.get(world); - if (renderer == null) return; WorldRenderer worldRenderer = Minecraft.getInstance().worldRenderer; Long2ObjectMap> breakingProgressions = worldRenderer.blockBreakingProgressions; if (breakingProgressions.isEmpty()) return; + Vector renderers = blockBreaking.getValue(); + + BitSet bitSet = new BitSet(10); for (Long2ObjectMap.Entry> entry : breakingProgressions.long2ObjectEntrySet()) { BlockPos breakingPos = BlockPos.fromLong(entry.getLongKey()); - SortedSet sortedset1 = entry.getValue(); - if (sortedset1 != null && !sortedset1.isEmpty()) { - renderer.add(world.getTileEntity(breakingPos)); + SortedSet progresses = entry.getValue(); + if (progresses != null && !progresses.isEmpty()) { + int blockDamage = progresses.last().getPartialBlockDamage(); + bitSet.set(blockDamage); + renderers.get(blockDamage).add(world.getTileEntity(breakingPos)); } } - renderer.beginFrame(Minecraft.getInstance().gameRenderer.getActiveRenderInfo()); - - RenderType layer = RenderType.getCutoutMipped(); - - layer.startDrawing(); + TextureManager textureManager = Minecraft.getInstance().textureManager; + ActiveRenderInfo info = Minecraft.getInstance().gameRenderer.getActiveRenderInfo(); glActiveTexture(GL_TEXTURE0); - TextureManager textureManager = Minecraft.getInstance().textureManager; - Texture breaking = textureManager.getTexture(ModelBakery.BLOCK_DESTRUCTION_STAGE_TEXTURES.get(5)); + CRUMBLING.startDrawing(); + bitSet.stream().forEach(i -> { + Texture breaking = textureManager.getTexture(ModelBakery.BLOCK_DESTRUCTION_STAGE_TEXTURES.get(i)); + CrumblingRenderer renderer = renderers.get(i); + renderer.beginFrame(info); - if (breaking != null) { + if (breaking != null) { + glBindTexture(GL_TEXTURE_2D, breaking.getGlTextureId()); + renderer.render(RenderType.getCutoutMipped(), viewProjection, cameraX, cameraY, cameraZ, program -> program.setTextureScale(64, 64)); + } - glBindTexture(GL_TEXTURE_2D, breaking.getGlTextureId()); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - - RenderSystem.enableBlend(); - RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.DST_COLOR, GlStateManager.DestFactor.SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); - - RenderSystem.enableAlphaTest(); - RenderSystem.alphaFunc(516, 0.003921569F); - - RenderSystem.polygonOffset(-1.0F, -10.0F); - RenderSystem.enablePolygonOffset(); - } - - renderer.render(layer, viewProjection, cameraX, cameraY, cameraZ, program -> program.setTextureScale(64, 64)); - - if (breaking != null) { - glBindTexture(GL_TEXTURE_2D, textureManager.getTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE).getGlTextureId()); - - RenderSystem.disableBlend(); - RenderSystem.defaultBlendFunc(); - - RenderSystem.polygonOffset(0.0F, 0.0F); - RenderSystem.disablePolygonOffset(); - } - - layer.endDrawing(); - - renderer.invalidate(); + renderer.invalidate(); + }); + CRUMBLING.endDrawing(); } public static void enqueueUpdate(TileEntity te) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingRenderer.java new file mode 100644 index 000000000..f1be59600 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingRenderer.java @@ -0,0 +1,14 @@ +package com.jozufozu.flywheel.backend.core; + +import net.minecraft.util.math.BlockPos; + +public class CrumblingRenderer extends WorldTileRenderer { + public CrumblingRenderer() { + super(WorldContext.CRUMBLING); + } + + @Override + protected boolean shouldTick(BlockPos worldPos, float lookX, float lookY, float lookZ, int cX, int cY, int cZ) { + return true; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicAttributes.java similarity index 93% rename from src/main/java/com/jozufozu/flywheel/backend/core/BasicAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicAttributes.java index 1592e99fd..4309c1365 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicAttributes.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java similarity index 96% rename from src/main/java/com/jozufozu/flywheel/backend/core/BasicData.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java index 2f910eff4..3759ba6e2 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import java.nio.ByteBuffer; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/IFlatLight.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/IFlatLight.java similarity index 94% rename from src/main/java/com/jozufozu/flywheel/backend/core/IFlatLight.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/IFlatLight.java index 7b6885c12..250ffda90 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/IFlatLight.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/IFlatLight.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import com.jozufozu.flywheel.backend.instancing.InstanceData; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/ModelAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelAttributes.java similarity index 94% rename from src/main/java/com/jozufozu/flywheel/backend/core/ModelAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelAttributes.java index c5ba5e858..16ed122dd 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/ModelAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelAttributes.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/ModelData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java similarity index 92% rename from src/main/java/com/jozufozu/flywheel/backend/core/ModelData.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java index cef67d359..3ae82a855 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/ModelData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import java.nio.ByteBuffer; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/OrientedAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedAttributes.java similarity index 93% rename from src/main/java/com/jozufozu/flywheel/backend/core/OrientedAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedAttributes.java index a92ed42ac..9d74baef4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/OrientedAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedAttributes.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/OrientedData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java similarity index 97% rename from src/main/java/com/jozufozu/flywheel/backend/core/OrientedData.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java index 209458c17..a7f30a96c 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/OrientedData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import java.nio.ByteBuffer; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/OrientedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedModel.java similarity index 93% rename from src/main/java/com/jozufozu/flywheel/backend/core/OrientedModel.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedModel.java index 76ed0baac..6c5ca0544 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/OrientedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedModel.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.InstancedModel; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/TransformAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformAttributes.java similarity index 93% rename from src/main/java/com/jozufozu/flywheel/backend/core/TransformAttributes.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformAttributes.java index a94064541..48c85b185 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/TransformAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformAttributes.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/TransformedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformedModel.java similarity index 93% rename from src/main/java/com/jozufozu/flywheel/backend/core/TransformedModel.java rename to src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformedModel.java index 04436dc0b..4d848b2e9 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/TransformedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformedModel.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.materials; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.InstancedModel; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java index 53a21c878..d58b20a16 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java @@ -11,7 +11,7 @@ import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.BufferedModel; -import com.jozufozu.flywheel.backend.core.ModelAttributes; +import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; import com.jozufozu.flywheel.backend.gl.GlBuffer; import com.jozufozu.flywheel.backend.gl.GlVertexArray; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java index 4b6bcee9a..2f038c01d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java @@ -9,9 +9,9 @@ import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.BasicProgram; -import com.jozufozu.flywheel.backend.core.ModelData; -import com.jozufozu.flywheel.backend.core.OrientedData; import com.jozufozu.flywheel.backend.core.WorldContext; +import com.jozufozu.flywheel.backend.core.materials.ModelData; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.simibubi.create.foundation.render.AllMaterialSpecs; @@ -107,21 +107,29 @@ public abstract class InstancedTileRenderer

{ if (dynamicInstances.size() > 0) { for (IDynamicInstance dyn : dynamicInstances.values()) { - if (!dyn.decreaseFramerateWithDistance()) { - dyn.beginFrame(); - continue; - } - - if (shouldTick(dyn.getWorldPosition(), lookX, lookY, lookZ, cX, cY, cZ)) + if (!dyn.decreaseFramerateWithDistance() || shouldTick(dyn.getWorldPosition(), lookX, lookY, lookZ, cX, cY, cZ)) dyn.beginFrame(); } } } + /** + * Render every model for every material. + * + * @param layer Which vanilla {@link RenderType} is being drawn? + * @param viewProjection How do we get from camera space to clip space? + */ public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ) { render(layer, viewProjection, camX, camY, camZ, null); } + /** + * Render every model for every material. + * + * @param layer Which vanilla {@link RenderType} is being drawn? + * @param viewProjection How do we get from camera space to clip space? + * @param callback Provide additional uniforms or state here. + */ public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, ShaderCallback

callback) { for (RenderMaterial material : materials.values()) { if (material.canRenderInLayer(layer)) diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java index 292021e48..bec358be7 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java @@ -3,9 +3,9 @@ package com.jozufozu.flywheel.backend.instancing; import java.util.Arrays; import java.util.stream.Stream; -import com.jozufozu.flywheel.backend.core.IFlatLight; -import com.jozufozu.flywheel.backend.core.ModelData; -import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.materials.IFlatLight; +import com.jozufozu.flywheel.backend.core.materials.ModelData; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java index 69d8d61b7..e813cc7f2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.base; import java.nio.ByteBuffer; -import com.jozufozu.flywheel.backend.core.BasicData; +import com.jozufozu.flywheel.backend.core.materials.BasicData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.simibubi.create.foundation.utility.ColorHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java index 4cc26671f..5eaadbc5a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.base; -import com.jozufozu.flywheel.backend.core.BasicAttributes; +import com.jozufozu.flywheel.backend.core.materials.BasicAttributes; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java index 2f5810e9d..60dfede9b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors; import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.mojang.blaze3d.matrix.MatrixStack; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java index a1ed191ee..8cd33f08d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.crank; -import com.jozufozu.flywheel.backend.core.ModelData; import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java index 7a97e0b98..544fbf41f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java @@ -3,8 +3,8 @@ package com.simibubi.create.content.contraptions.components.deployer; import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING; -import com.jozufozu.flywheel.backend.core.ModelData; import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.mojang.blaze3d.matrix.MatrixStack; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java index ad3fcd28f..e638631ea 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java @@ -3,8 +3,8 @@ package com.simibubi.create.content.contraptions.components.deployer; import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING; -import com.jozufozu.flywheel.backend.core.OrientedData; import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.ITickableInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java index e085391c2..96627328b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java @@ -6,7 +6,7 @@ import java.util.Collections; import java.util.List; import com.google.common.collect.Lists; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java index eb5c2cb2b..f435111ae 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; -import com.jozufozu.flywheel.backend.core.ModelData; import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; import com.mojang.blaze3d.matrix.MatrixStack; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java index a930a77e6..b49dd5432 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MixerInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.mixer; -import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java index b0e78648e..86b386dfc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/PressInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.press; -import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java index f5b8a1169..7ca1af20f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.bearing; -import com.jozufozu.flywheel.backend.core.OrientedData; import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java index ecb98bee6..aea9824bc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.bearing; -import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java index cabddfe5b..9f595e99f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.chassis; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java index 860923dc4..c9be46e89 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.gantry; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java index 3c09ecf5b..d7b2f4886 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java @@ -1,8 +1,15 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.vector.Vector3f; +import net.minecraft.world.IBlockDisplayReader; +import net.minecraft.world.LightType; + import java.util.Arrays; -import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; @@ -15,13 +22,6 @@ import com.jozufozu.flywheel.backend.light.LightUpdater; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.world.IBlockDisplayReader; -import net.minecraft.world.LightType; - public abstract class AbstractPulleyInstance extends ShaftInstance implements IDynamicInstance, LightUpdateListener { final OrientedData coil; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/HosePulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/HosePulleyInstance.java index 2c574c770..18ed0ed05 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/HosePulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/HosePulleyInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; -import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java index 036c91ed1..5e90df5fd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/RopePulleyInstance.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pulley; -import com.jozufozu.flywheel.backend.core.OrientedData; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.simibubi.create.AllBlockPartials; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java index 6c2d1a278..f3785b232 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.fluids.pipes; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java index 10d68db54..58dc8e651 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.relays.belt; -import com.jozufozu.flywheel.backend.core.BasicAttributes; +import com.jozufozu.flywheel.backend.core.materials.BasicAttributes; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java index 94178337b..684d14396 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeInstance.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.relays.gauge; import java.util.ArrayList; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java index 2eed76a0f..d0cfacc4e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.logistics.block; import java.nio.ByteBuffer; -import com.jozufozu.flywheel.backend.core.IFlatLight; +import com.jozufozu.flywheel.backend.core.materials.IFlatLight; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java index 53b1db9ab..7b2f66191 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.depot; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.mojang.blaze3d.matrix.MatrixStack; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java index 2c27676d0..e6abc4765 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/AdjustableRepeaterInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.diodes; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.ITickableInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java index a33af9b12..455659db6 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.logistics.block.mechanicalArm; import java.util.ArrayList; import com.google.common.collect.Lists; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java index 8c2aaacac..995952c78 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.logistics.block.redstone; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java index a64f62969..0a011f316 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.schematics.block; -import com.jozufozu.flywheel.backend.core.ModelData; +import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index 416352b46..f61c3b175 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -67,7 +67,14 @@ public class RenderHooksMixin { Backend.listeners.refresh(world); } - @Inject(at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;long2ObjectEntrySet()Lit/unimi/dsi/fastutil/objects/ObjectSet;"), method = "render") + + @Inject(at = + @At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/WorldRenderer;checkEmpty(Lcom/mojang/blaze3d/matrix/MatrixStack;)V", + ordinal = 2 // after the game renders the breaking overlay normally + ), + method = "render") private void renderBlockBreaking(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_, CallbackInfo ci) { diff --git a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java index 6f0ba694e..662fb707b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java @@ -2,10 +2,10 @@ package com.simibubi.create.foundation.render; import static com.jozufozu.flywheel.backend.Backend.register; -import com.jozufozu.flywheel.backend.core.ModelData; -import com.jozufozu.flywheel.backend.core.OrientedData; -import com.jozufozu.flywheel.backend.core.OrientedModel; -import com.jozufozu.flywheel.backend.core.TransformedModel; +import com.jozufozu.flywheel.backend.core.materials.ModelData; +import com.jozufozu.flywheel.backend.core.materials.OrientedData; +import com.jozufozu.flywheel.backend.core.materials.OrientedModel; +import com.jozufozu.flywheel.backend.core.materials.TransformedModel; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; import com.simibubi.create.Create; diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index 3756d453e..a4b8fbccb 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -2,10 +2,10 @@ package com.simibubi.create.foundation.render; import static com.jozufozu.flywheel.backend.Backend.register; -import com.jozufozu.flywheel.backend.core.BasicAttributes; -import com.jozufozu.flywheel.backend.core.ModelAttributes; -import com.jozufozu.flywheel.backend.core.OrientedAttributes; -import com.jozufozu.flywheel.backend.core.TransformAttributes; +import com.jozufozu.flywheel.backend.core.materials.BasicAttributes; +import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; +import com.jozufozu.flywheel.backend.core.materials.OrientedAttributes; +import com.jozufozu.flywheel.backend.core.materials.TransformAttributes; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; import com.simibubi.create.Create; From 05b56b9b5e12f71e0d1f73d54ec08c0e2104730d Mon Sep 17 00:00:00 2001 From: JozsefA Date: Fri, 7 May 2021 22:15:07 -0700 Subject: [PATCH 038/198] Error when missing #flwbuiltins in WorldContext --- .../jozufozu/flywheel/backend/ShaderContext.java | 2 +- .../jozufozu/flywheel/backend/ShaderLoader.java | 2 +- .../flywheel/backend/core/WorldContext.java | 14 ++++++++++---- .../flywheel/backend/gl/shader/ShaderType.java | 8 +++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java index c72614242..65344a93d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java @@ -32,7 +32,7 @@ public abstract class ShaderContext

{ Backend.log.debug("Loaded program {}", programSpec.name); } - public String preProcess(ShaderLoader loader, String shaderSrc, ShaderType type) { + public String preProcess(ShaderLoader loader, ShaderType type, ResourceLocation shader, String shaderSrc) { return shaderSrc; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index fc357957e..bb1ed25c0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -127,7 +127,7 @@ public class ShaderLoader { public GlShader loadShader(ShaderContext ctx, ResourceLocation name, ShaderType type, ShaderConstants defines) { String source = shaderSource.get(name); - source = ctx.preProcess(this, source, type); + source = ctx.preProcess(this, type, name, source); source = processIncludes(source, name); if (defines != null) diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index 3febc5b2b..54797de14 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -2,6 +2,7 @@ package com.jozufozu.flywheel.backend.core; import java.util.EnumMap; import java.util.Map; +import java.util.regex.Matcher; import java.util.regex.Pattern; import com.jozufozu.flywheel.backend.Backend; @@ -18,7 +19,8 @@ import net.minecraft.util.ResourceLocation; public class WorldContext

extends ShaderContext

{ - private static final Pattern builtinPattern = Pattern.compile("#flwbuiltins"); + private static final String declaration = "#flwbuiltins"; + private static final Pattern builtinPattern = Pattern.compile(declaration); public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation("create", "std"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation("create", "crumbling"), new FogSensitiveProgram.SpecLoader<>(CrumblingProgram::new)); @@ -48,11 +50,15 @@ public class WorldContext

extends ShaderContext

{ } @Override - public String preProcess(ShaderLoader loader, String shaderSrc, ShaderType type) { + public String preProcess(ShaderLoader loader, ShaderType type, ResourceLocation shader, String shaderSrc) { String builtinSrc = loader.getShaderSource(builtins.get(type)); - return builtinPattern.matcher(shaderSrc) - .replaceFirst(builtinSrc); + Matcher matcher = builtinPattern.matcher(shaderSrc); + + if (matcher.find()) + return matcher.replaceFirst(builtinSrc); + + throw new RuntimeException(String.format("%s shader '%s' is missing %s, cannot use in World Context", type.name, shader, declaration)); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderType.java index 8f6ec6801..2ac5a3721 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderType.java @@ -3,13 +3,15 @@ package com.jozufozu.flywheel.backend.gl.shader; import org.lwjgl.opengl.GL20; public enum ShaderType { - VERTEX(GL20.GL_VERTEX_SHADER), - FRAGMENT(GL20.GL_FRAGMENT_SHADER), + VERTEX("vertex", GL20.GL_VERTEX_SHADER), + FRAGMENT("fragment", GL20.GL_FRAGMENT_SHADER), ; + public final String name; public final int glEnum; - ShaderType(int glEnum) { + ShaderType(String name, int glEnum) { + this.name = name; this.glEnum = glEnum; } } From 4111680755d1378a76b983052d9b7c43a01a42bf Mon Sep 17 00:00:00 2001 From: JozsefA Date: Fri, 7 May 2021 23:22:40 -0700 Subject: [PATCH 039/198] FLWFinalizeWorld takes care of assigning gl_Position --- .../assets/create/flywheel/shaders/belt.vert | 9 +----- .../flywheel/shaders/contraption/builtin.vert | 9 +++++- .../flywheel/shaders/contraption_actor.vert | 30 +++--------------- .../shaders/contraption_structure.vert | 31 ++++--------------- .../assets/create/flywheel/shaders/flap.vert | 9 +----- .../assets/create/flywheel/shaders/model.vert | 9 +----- .../create/flywheel/shaders/oriented.vert | 9 +----- .../create/flywheel/shaders/rotating.vert | 9 +----- .../create/flywheel/shaders/std/builtin.vert | 10 ++++-- 9 files changed, 32 insertions(+), 93 deletions(-) diff --git a/src/main/resources/assets/create/flywheel/shaders/belt.vert b/src/main/resources/assets/create/flywheel/shaders/belt.vert index 78937f401..052520d2d 100644 --- a/src/main/resources/assets/create/flywheel/shaders/belt.vert +++ b/src/main/resources/assets/create/flywheel/shaders/belt.vert @@ -25,12 +25,6 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -uniform float uTime; -uniform mat4 uViewProjection; -uniform int uDebug; - -uniform vec3 uCameraPos; - void main() { vec3 rotated = rotateVertexByQuat(aPos - .5, aInstanceRot) + aInstancePos + .5; @@ -38,7 +32,7 @@ void main() { vec3 norm = rotateVertexByQuat(aNormal, aInstanceRot); - FLWFinalizeWorldPos(worldPos, uCameraPos); + FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); float scrollSize = aScrollTexture.w - aScrollTexture.y; @@ -47,7 +41,6 @@ void main() { Diffuse = diffuse(norm); TexCoords = aTexCoords - aSourceTexture + aScrollTexture.xy + vec2(0, scroll); Light = aLight; - gl_Position = uViewProjection * worldPos; #ifdef CONTRAPTION if (uDebug == 2) { diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert index 63aafdbda..2b044c280 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert @@ -8,7 +8,12 @@ uniform vec3 uLightBoxSize; uniform vec3 uLightBoxMin; uniform mat4 uModel; -void FLWFinalizeWorldPos(inout vec4 worldPos, vec3 cameraPos) { +uniform float uTime; +uniform mat4 uViewProjection; +uniform int uDebug; +uniform vec3 uCameraPos; + +void FLWFinalizeWorldPos(inout vec4 worldPos) { worldPos = uModel * worldPos; BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; @@ -16,6 +21,8 @@ void FLWFinalizeWorldPos(inout vec4 worldPos, vec3 cameraPos) { #if defined(USE_FOG) FragDistance = length(worldPos.xyz); #endif + + gl_Position = uViewProjection * worldPos; } void FLWFinalizeNormal(inout vec3 normal) { diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert index 4de728759..96d516359 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert @@ -1,6 +1,7 @@ #version 110 #define PI 3.1415926538 +#flwbuiltins #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/quaternion.glsl"> #flwinclude <"create:core/diffuse.glsl"> @@ -22,45 +23,24 @@ attribute float aSpeed; varying float Diffuse; varying vec2 TexCoords; varying vec4 Color; -varying vec3 BoxCoord; varying vec2 Light; -uniform vec3 uLightBoxSize; -uniform vec3 uLightBoxMin; -uniform mat4 uModel; - -uniform float uTime; -uniform mat4 uViewProjection; -uniform int uDebug; - -uniform vec3 uCameraPos; - -#if defined(USE_FOG) -varying float FragDistance; -#endif - void main() { float degrees = aOffset + uTime * aSpeed / 20.; //float angle = fract(degrees / 360.) * PI * 2.; vec4 kineticRot = quat(aAxis, degrees); vec3 rotated = rotateVertexByQuat(aPos - aRotationCenter, kineticRot) + aRotationCenter; - vec3 localPos = rotateVertexByQuat(rotated - .5, aInstanceRot) + aInstancePos + .5; - - vec4 worldPos = uModel * vec4(localPos, 1.); + vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, aInstanceRot) + aInstancePos + .5, 1.); vec3 norm = rotateVertexByQuat(rotateVertexByQuat(aNormal, kineticRot), aInstanceRot); - norm = modelToNormal(uModel) * norm; - BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize; + FLWFinalizeWorldPos(worldPos); + FLWFinalizeNormal(norm); + Diffuse = diffuse(norm); TexCoords = aTexCoords; Light = aModelLight; - gl_Position = uViewProjection * worldPos; - - #if defined(USE_FOG) - FragDistance = length(worldPos.xyz); - #endif if (uDebug == 2) { Color = vec4(norm, 1.); diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert index dbcf4a595..8cec957bc 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert @@ -1,6 +1,7 @@ #version 110 #define PI 3.1415926538 +#flwbuiltins #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/diffuse.glsl"> @@ -13,41 +14,21 @@ attribute vec2 aModelLight; varying float Diffuse; varying vec2 TexCoords; varying vec4 Color; -varying vec3 BoxCoord; varying vec2 Light; -uniform vec3 uLightBoxSize; -uniform vec3 uLightBoxMin; -uniform mat4 uModel; - -uniform float uTime; -uniform mat4 uViewProjection; -uniform int uDebug; - -uniform vec3 uCameraPos; - -#if defined(USE_FOG) -varying float FragDistance; -#endif - void main() { - vec4 viewPos = uModel * vec4(aPos, 1.); + vec4 worldPos = vec4(aPos, 1.); + vec3 norm = aNormal; - vec3 norm = (uModel * vec4(aNormal, 0.)).xyz; + FLWFinalizeWorldPos(worldPos); + FLWFinalizeNormal(norm); - BoxCoord = (viewPos.xyz - uLightBoxMin) / uLightBoxSize; Diffuse = diffuse(norm); - Color = aColor / diffuse(aNormal); + Color = aColor / diffuse(norm); TexCoords = aTexCoords; Light = aModelLight; - gl_Position = uViewProjection * viewPos; - #if defined(USE_FOG) - FragDistance = length(viewPos.xyz); - #endif if (uDebug == 2) { Color = vec4(norm, 1.); - } else { - Color = aColor / diffuse(aNormal); } } diff --git a/src/main/resources/assets/create/flywheel/shaders/flap.vert b/src/main/resources/assets/create/flywheel/shaders/flap.vert index 8b79964c1..cb4eba652 100644 --- a/src/main/resources/assets/create/flywheel/shaders/flap.vert +++ b/src/main/resources/assets/create/flywheel/shaders/flap.vert @@ -27,12 +27,6 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -uniform float uTime; -uniform mat4 uViewProjection; -uniform int uDebug; - -uniform vec3 uCameraPos; - float toRad(float degrees) { return fract(degrees / 360.) * PI * 2.; } @@ -62,13 +56,12 @@ void main() { vec4 worldPos = vec4(rotated, 1.); vec3 norm = rotateVertexByQuat(rotateVertexByQuat(aNormal, flapRotation), orientation); - FLWFinalizeWorldPos(worldPos, uCameraPos); + FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); Diffuse = diffuse(norm); TexCoords = aTexCoords; Light = aLight; - gl_Position = uViewProjection * worldPos; Color = vec4(1.); } diff --git a/src/main/resources/assets/create/flywheel/shaders/model.vert b/src/main/resources/assets/create/flywheel/shaders/model.vert index a6c5e3ec1..7336bd064 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model.vert +++ b/src/main/resources/assets/create/flywheel/shaders/model.vert @@ -18,18 +18,12 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -uniform float uTime; -uniform mat4 uViewProjection; -uniform int uDebug; - -uniform vec3 uCameraPos; - void main() { vec4 worldPos = aTransform * vec4(aPos, 1.); vec3 norm = aNormalMat * aNormal; - FLWFinalizeWorldPos(worldPos, uCameraPos); + FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); norm = normalize(norm); @@ -37,7 +31,6 @@ void main() { Diffuse = diffuse(norm); TexCoords = aTexCoords; Light = aLight; - gl_Position = uViewProjection * worldPos; Color = aColor; } diff --git a/src/main/resources/assets/create/flywheel/shaders/oriented.vert b/src/main/resources/assets/create/flywheel/shaders/oriented.vert index 8c94ecd04..d9f6f5cc5 100644 --- a/src/main/resources/assets/create/flywheel/shaders/oriented.vert +++ b/src/main/resources/assets/create/flywheel/shaders/oriented.vert @@ -20,24 +20,17 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -uniform float uTime; -uniform mat4 uViewProjection; -uniform int uDebug; - -uniform vec3 uCameraPos; - void main() { vec4 worldPos = vec4(rotateVertexByQuat(aPos - aPivot, aRotation) + aPivot + aInstancePos, 1.); vec3 norm = rotateVertexByQuat(aNormal, aRotation); - FLWFinalizeWorldPos(worldPos, uCameraPos); + FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); Diffuse = diffuse(norm); TexCoords = aTexCoords; Light = aLight; - gl_Position = uViewProjection * worldPos; Color = aColor; } diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/shaders/rotating.vert index 770ef4ccc..9d20b6480 100644 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ b/src/main/resources/assets/create/flywheel/shaders/rotating.vert @@ -22,12 +22,6 @@ varying vec4 Color; varying float Diffuse; varying vec2 Light; -uniform float uTime; -uniform mat4 uViewProjection; -uniform int uDebug; - -uniform vec3 uCameraPos; - mat4 kineticRotation() { float degrees = aOffset + uTime * aSpeed * 3./10.; float angle = fract(degrees / 360.) * PI * 2.; @@ -41,13 +35,12 @@ void main() { vec3 norm = modelToNormal(kineticRotation) * aNormal; - FLWFinalizeWorldPos(worldPos, uCameraPos); + FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); Diffuse = diffuse(norm); TexCoords = aTexCoords; Light = aLight; - gl_Position = uViewProjection * worldPos; #ifdef CONTRAPTION if (uDebug == 2) { diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert index c5279bf75..bcf38154a 100644 --- a/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert +++ b/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert @@ -1,12 +1,18 @@ +uniform float uTime; +uniform mat4 uViewProjection; +uniform int uDebug; +uniform vec3 uCameraPos; #if defined(USE_FOG) varying float FragDistance; #endif -void FLWFinalizeWorldPos(inout vec4 worldPos, vec3 cameraPos) { +void FLWFinalizeWorldPos(inout vec4 worldPos) { #if defined(USE_FOG) - FragDistance = length(worldPos.xyz - cameraPos); + FragDistance = length(worldPos.xyz - uCameraPos); #endif + + gl_Position = uViewProjection * worldPos; } void FLWFinalizeNormal(inout vec3 normal) { From b10ceaf63d4774a4749d8bc73d1b22da0f33a76f Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 8 May 2021 20:02:32 -0700 Subject: [PATCH 040/198] Improve normal scaling fix --- .../foundation/mixin/FixInverseCbrtMixin.java | 32 ----------------- .../mixin/FixNormalScalingMixin.java | 36 +++++++++++++++++++ src/main/resources/create.mixins.json | 2 +- 3 files changed, 37 insertions(+), 33 deletions(-) delete mode 100644 src/main/java/com/simibubi/create/foundation/mixin/FixInverseCbrtMixin.java create mode 100644 src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java diff --git a/src/main/java/com/simibubi/create/foundation/mixin/FixInverseCbrtMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/FixInverseCbrtMixin.java deleted file mode 100644 index f4b7b1f87..000000000 --- a/src/main/java/com/simibubi/create/foundation/mixin/FixInverseCbrtMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.simibubi.create.foundation.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.util.math.MathHelper; - -/** - * Vanilla's fast inverse cube root function returns nonsensical results for negative - * numbers, which results in incorrect vertex normal scaling. By negating the input - * and output accordingly, this issue can be prevented. - */ -@Mixin(MathHelper.class) -public class FixInverseCbrtMixin { - @ModifyVariable(at = @At("HEAD"), method = "fastInverseCbrt(F)F") - private static float negateAtHead(float input) { - if (input < 0) { - input *= -1; - } - return input; - } - - @Inject(at = @At("TAIL"), method = "fastInverseCbrt(F)F", cancellable = true) - private static void negateAtTail(float input, CallbackInfoReturnable cir) { - if (input < 0) { - cir.setReturnValue(cir.getReturnValueF() * -1); - } - } -} diff --git a/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java new file mode 100644 index 000000000..46b35d6e3 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/FixNormalScalingMixin.java @@ -0,0 +1,36 @@ +package com.simibubi.create.foundation.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.At.Shift; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.mojang.blaze3d.matrix.MatrixStack; + +@Mixin(MatrixStack.class) +public class FixNormalScalingMixin { + /** + * Minecraft negates the normal matrix if all scales are equal and negative, but + * does not return afterward. This allows the rest of the method's logic to be + * applied, which negates the matrix again, resulting in the matrix being the + * same as in the beginning. + */ + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/vector/Matrix3f;multiply(F)V", shift = Shift.AFTER), method = "scale(FFF)V", cancellable = true) + private void returnAfterNegate(float x, float y, float z, CallbackInfo ci) { + ci.cancel(); + } + + /** + * Minecraft takes the inverse cube root of the product of all scales to provide a + * rough estimate for normalization so that it does not need to be done later. It + * does not make sense for this "normalization factor" to be negative though, as + * that would invert all normals. Additionally, Minecraft's fastInverseCbrt method + * does not work for negative numbers. + */ + @ModifyArg(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;fastInverseCbrt(F)F"), method = "scale(FFF)V") + private float absInvCbrtInput(float input) { + return Math.abs(input); + } +} diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index 49a8c2376..3bc4de366 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -9,7 +9,7 @@ "client": [ "CancelTileEntityRenderMixin", "EntityContraptionInteractionMixin", - "FixInverseCbrtMixin", + "FixNormalScalingMixin", "FogColorTrackerMixin", "HeavyBootsOnPlayerMixin", "LightUpdateMixin", From 70401e4ac4a5bab619bb6cb560db68fdac856084 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sat, 8 May 2021 23:29:02 -0700 Subject: [PATCH 041/198] More tweaking - FLWFinalizeColor takes care of assigning gl_FragColor - Multiply crumbling alpha with diffuse alpha --- .../com/jozufozu/flywheel/backend/Backend.java | 18 ++++++++++++++---- .../backend/core/ContraptionContext.java | 2 +- .../backend/core/CrumblingProgram.java | 7 +++++++ .../flywheel/backend/core/WorldContext.java | 4 ++-- .../assets/create/flywheel/shaders/block.frag | 2 -- .../{ => context}/contraption/builtin.frag | 6 ++++-- .../{ => context}/contraption/builtin.vert | 0 .../{ => context}/crumbling/builtin.frag | 12 +++++++++--- .../shaders/context/crumbling/builtin.vert | 1 + .../shaders/{ => context}/std/builtin.frag | 6 ++++-- .../shaders/{ => context}/std/builtin.vert | 0 .../shaders/{ => context}/std/fog.glsl | 0 .../flywheel/shaders/crumbling/builtin.vert | 1 - 13 files changed, 42 insertions(+), 17 deletions(-) rename src/main/resources/assets/create/flywheel/shaders/{ => context}/contraption/builtin.frag (83%) rename src/main/resources/assets/create/flywheel/shaders/{ => context}/contraption/builtin.vert (100%) rename src/main/resources/assets/create/flywheel/shaders/{ => context}/crumbling/builtin.frag (53%) create mode 100644 src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert rename src/main/resources/assets/create/flywheel/shaders/{ => context}/std/builtin.frag (80%) rename src/main/resources/assets/create/flywheel/shaders/{ => context}/std/builtin.vert (100%) rename src/main/resources/assets/create/flywheel/shaders/{ => context}/std/fog.glsl (100%) delete mode 100644 src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.vert diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index ade41072b..d22f9e634 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -1,9 +1,10 @@ package com.jozufozu.flywheel.backend; -import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D; -import static org.lwjgl.opengl.GL11.glBindTexture; -import static org.lwjgl.opengl.GL13.GL_TEXTURE0; -import static org.lwjgl.opengl.GL13.glActiveTexture; +import static org.lwjgl.opengl.GL20.GL_TEXTURE0; +import static org.lwjgl.opengl.GL20.GL_TEXTURE4; +import static org.lwjgl.opengl.GL20.GL_TEXTURE_2D; +import static org.lwjgl.opengl.GL20.glActiveTexture; +import static org.lwjgl.opengl.GL20.glBindTexture; import java.util.BitSet; import java.util.Collection; @@ -44,6 +45,7 @@ import net.minecraft.client.renderer.texture.Texture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; +import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.resources.IResourceManager; import net.minecraft.tileentity.TileEntity; @@ -246,6 +248,9 @@ public class Backend { ActiveRenderInfo info = Minecraft.getInstance().gameRenderer.getActiveRenderInfo(); glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, textureManager.getTexture(PlayerContainer.BLOCK_ATLAS_TEXTURE).getGlTextureId()); + + glActiveTexture(GL_TEXTURE4); CRUMBLING.startDrawing(); bitSet.stream().forEach(i -> { @@ -261,6 +266,11 @@ public class Backend { renderer.invalidate(); }); CRUMBLING.endDrawing(); + + glActiveTexture(GL_TEXTURE0); + Texture breaking = textureManager.getTexture(ModelBakery.BLOCK_DESTRUCTION_STAGE_TEXTURES.get(0)); + if (breaking != null) + glBindTexture(GL_TEXTURE_2D, breaking.getGlTextureId()); } public static void enqueueUpdate(TileEntity te) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java index c08f37516..de84fd268 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java @@ -12,7 +12,7 @@ public class ContraptionContext extends WorldContext { public static final ContraptionContext INSTANCE = new ContraptionContext(); public ContraptionContext() { - super(new ResourceLocation("create", "contraption"), new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)); + super(new ResourceLocation("create", "context/contraption"), new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java index e254a54d2..e25feeee4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java @@ -8,6 +8,7 @@ import net.minecraft.util.ResourceLocation; public class CrumblingProgram extends BasicProgram { protected final int uTextureScale; + protected int uCrumbling; public CrumblingProgram(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory) { super(name, handle, fogFactory); @@ -15,6 +16,12 @@ public class CrumblingProgram extends BasicProgram { uTextureScale = getUniformLocation("uTextureScale"); } + @Override + protected void registerSamplers() { + super.registerSamplers(); + uCrumbling = setSamplerBinding("uCrumbling", 4); + } + public void setTextureScale(float x, float y) { glUniform2f(uTextureScale, x, y); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index 54797de14..693150665 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -22,8 +22,8 @@ public class WorldContext

extends ShaderContext

{ private static final String declaration = "#flwbuiltins"; private static final Pattern builtinPattern = Pattern.compile(declaration); - public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation("create", "std"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); - public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation("create", "crumbling"), new FogSensitiveProgram.SpecLoader<>(CrumblingProgram::new)); + public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation("create", "context/std"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); + public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation("create", "context/crumbling"), new FogSensitiveProgram.SpecLoader<>(CrumblingProgram::new)); private final ShaderSpecLoader

loader; diff --git a/src/main/resources/assets/create/flywheel/shaders/block.frag b/src/main/resources/assets/create/flywheel/shaders/block.frag index 625fc9ea5..2f26044ac 100644 --- a/src/main/resources/assets/create/flywheel/shaders/block.frag +++ b/src/main/resources/assets/create/flywheel/shaders/block.frag @@ -13,6 +13,4 @@ void main() { vec4 color = vec4(tex.rgb * FLWLight(Light).rgb * Diffuse, tex.a) * Color; FLWFinalizeColor(color); - - gl_FragColor = color; } diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag similarity index 83% rename from src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag rename to src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag index 5091e0ae3..c7463793f 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag @@ -1,4 +1,4 @@ -#flwinclude <"create:std/fog.glsl"> +#flwinclude <"create:context/std/fog.glsl"> varying vec3 BoxCoord; uniform sampler3D uLightVolume; @@ -10,7 +10,7 @@ vec4 FLWBlockTexture(vec2 texCoords) { return texture2D(uBlockAtlas, texCoords); } -void FLWFinalizeColor(inout vec4 color) { +void FLWFinalizeColor(vec4 color) { #if defined(USE_FOG) float a = color.a; float fog = clamp(FLWFogFactor(), 0., 1.); @@ -18,6 +18,8 @@ void FLWFinalizeColor(inout vec4 color) { color = mix(uFogColor, color, fog); color.a = a; #endif + + gl_FragColor = color; } vec4 FLWLight(vec2 lightCoords) { diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.vert similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/contraption/builtin.vert rename to src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.vert diff --git a/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag similarity index 53% rename from src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.frag rename to src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag index d5dda65a2..40bcfbdc4 100644 --- a/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag @@ -1,14 +1,18 @@ -#flwinclude <"create:std/fog.glsl"> +#flwinclude <"create:context/std/fog.glsl"> uniform vec2 uTextureScale; uniform sampler2D uBlockAtlas; uniform sampler2D uLightMap; +uniform sampler2D uCrumbling; vec4 FLWBlockTexture(vec2 texCoords) { - return texture2D(uBlockAtlas, texCoords * uTextureScale); + vec4 cr = texture2D(uCrumbling, texCoords * uTextureScale); + float diffuseAlpha = texture2D(uBlockAtlas, texCoords).a; + cr.a = cr.a * diffuseAlpha; + return cr; } -void FLWFinalizeColor(inout vec4 color) { +void FLWFinalizeColor(vec4 color) { #if defined(USE_FOG) float a = color.a; float fog = clamp(FLWFogFactor(), 0., 1.); @@ -16,6 +20,8 @@ void FLWFinalizeColor(inout vec4 color) { color = mix(uFogColor, color, fog); color.a = a; #endif + + gl_FragColor = color; } vec4 FLWLight(vec2 lightCoords) { diff --git a/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert new file mode 100644 index 000000000..3ca685f97 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert @@ -0,0 +1 @@ +#flwinclude <"create:context/std/builtin.vert"> diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag similarity index 80% rename from src/main/resources/assets/create/flywheel/shaders/std/builtin.frag rename to src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag index 42be74ede..d8f079be6 100644 --- a/src/main/resources/assets/create/flywheel/shaders/std/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag @@ -1,4 +1,4 @@ -#flwinclude <"create:std/fog.glsl"> +#flwinclude <"create:context/std/fog.glsl"> uniform sampler2D uBlockAtlas; uniform sampler2D uLightMap; @@ -7,7 +7,7 @@ vec4 FLWBlockTexture(vec2 texCoords) { return texture2D(uBlockAtlas, texCoords); } -void FLWFinalizeColor(inout vec4 color) { +void FLWFinalizeColor(vec4 color) { #if defined(USE_FOG) float a = color.a; float fog = clamp(FLWFogFactor(), 0., 1.); @@ -15,6 +15,8 @@ void FLWFinalizeColor(inout vec4 color) { color = mix(uFogColor, color, fog); color.a = a; #endif + + gl_FragColor = color; } vec4 FLWLight(vec2 lightCoords) { diff --git a/src/main/resources/assets/create/flywheel/shaders/std/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.vert similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/std/builtin.vert rename to src/main/resources/assets/create/flywheel/shaders/context/std/builtin.vert diff --git a/src/main/resources/assets/create/flywheel/shaders/std/fog.glsl b/src/main/resources/assets/create/flywheel/shaders/context/std/fog.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/std/fog.glsl rename to src/main/resources/assets/create/flywheel/shaders/context/std/fog.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.vert deleted file mode 100644 index 694f2920e..000000000 --- a/src/main/resources/assets/create/flywheel/shaders/crumbling/builtin.vert +++ /dev/null @@ -1 +0,0 @@ -#flwinclude <"create:std/builtin.vert"> From 3ebf1d6c64154c26cf62717b711d924d7abb0204 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 11 May 2021 23:16:09 +1000 Subject: [PATCH 042/198] Add filling and emptying recipes for Alex's Mobs' lava bottles --- .../alexsmobs/emptying/lava_bottle.json | 23 +++++++++++++++++++ .../compat/alexsmobs/filling/lava_bottle.json | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/main/resources/data/create/recipes/compat/alexsmobs/emptying/lava_bottle.json create mode 100644 src/main/resources/data/create/recipes/compat/alexsmobs/filling/lava_bottle.json diff --git a/src/main/resources/data/create/recipes/compat/alexsmobs/emptying/lava_bottle.json b/src/main/resources/data/create/recipes/compat/alexsmobs/emptying/lava_bottle.json new file mode 100644 index 000000000..bf3ed681e --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/alexsmobs/emptying/lava_bottle.json @@ -0,0 +1,23 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "alexsmobs" + } + ], + "type": "create:emptying", + "ingredients": [ + { + "item": "alexsmobs:lava_bottle" + } + ], + "results": [ + { + "item": "minecraft:glass_bottle" + }, + { + "fluid": "minecraft:lava", + "amount": 250 + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/alexsmobs/filling/lava_bottle.json b/src/main/resources/data/create/recipes/compat/alexsmobs/filling/lava_bottle.json new file mode 100644 index 000000000..a32b4262b --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/alexsmobs/filling/lava_bottle.json @@ -0,0 +1,23 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "alexsmobs" + } + ], + "type": "create:filling", + "ingredients": [ + { + "item": "minecraft:glass_bottle" + }, + { + "fluid": "minecraft:lava", + "amount": 250 + } + ], + "results": [ + { + "item": "alexsmobs:lava_bottle" + } + ] +} \ No newline at end of file From f6937ffb0c08c7f4c49013aaec862537ca4ec327 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 11 May 2021 11:02:43 -0700 Subject: [PATCH 043/198] Only a few moves left - flywheel stuff only barely depends on create - start drafting what multiple backends could look like --- .../jozufozu/flywheel/backend/Backend.java | 12 +- .../backend/core/materials/ModelData.java | 2 +- .../flywheel/backend/gl/shader/GlProgram.java | 2 +- .../backend/instancing/RenderMaterial.java | 45 +++- .../flywheel/backend/light/GridAlignedBB.java | 4 +- .../flywheel/backend/light/LightUpdater.java | 2 +- .../flywheel/util/BakedQuadWrapper.java | 216 ++++++++++++++++++ .../{backend => util}/RenderUtil.java | 18 +- .../flywheel/util}/VirtualEmptyModelData.java | 2 +- .../flywheel/util}/WeakHashSet.java | 2 +- .../jozufozu/flywheel/util/WorldAttached.java | 41 ++++ .../com/simibubi/create/CreateClient.java | 3 +- .../structureMovement/Contraption.java | 2 +- .../ControlledContraptionEntity.java | 2 +- .../DirectionalExtenderScrollOptionSlot.java | 2 +- .../render}/ContraptionContext.java | 4 +- .../render/ContraptionKineticRenderer.java | 1 - .../render/ContraptionRenderDispatcher.java | 8 - .../render}/EmptyLighter.java | 3 +- .../render}/LightVolumeDebugger.java | 4 +- .../processing/BasinRenderer.java | 10 +- .../BracketedKineticBlockModel.java | 2 +- .../projector/ChromaticProjectorInstance.java | 4 +- .../ChromaticProjectorTileEntity.java | 2 +- .../curiosities/projector/ColorEffect.java | 2 +- .../curiosities/projector/FilterStep.java | 2 +- .../client/SchematicTransformation.java | 2 +- .../create/foundation/gui/GuiGameElement.java | 2 +- .../foundation/mixin/RenderHooksMixin.java | 5 +- .../mixin/StoreProjectionMatrixMixin.java | 2 +- .../create/foundation/ponder/PonderScene.java | 2 +- .../ponder/elements/WorldSectionElement.java | 2 +- .../render/CreateFlywheelHandler.java | 16 ++ .../render/SuperByteBufferCache.java | 2 +- .../foundation/render/TemplateBuffer.java | 8 +- .../render}/effects/ColorMatrices.java | 2 +- .../render/effects}/EffectsContext.java | 3 +- .../render}/effects/EffectsHandler.java | 23 +- .../render}/effects/FilterSphere.java | 4 +- .../render}/effects/ScreenQuadAttributes.java | 2 +- .../render}/effects/SphereFilterProgram.java | 2 +- .../foundation/utility/WorldAttached.java | 6 - .../utility/ghost/GhostBlockRenderer.java | 2 +- .../foundation/utility/outliner/Outline.java | 2 +- .../shaders/skeleton/instanced/instanced.vert | 17 ++ .../shaders/skeleton/meshlet/meshlet.glsl | 43 ++++ 46 files changed, 460 insertions(+), 84 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/util/BakedQuadWrapper.java rename src/main/java/com/jozufozu/flywheel/{backend => util}/RenderUtil.java (77%) rename src/main/java/com/{simibubi/create/foundation/utility => jozufozu/flywheel/util}/VirtualEmptyModelData.java (93%) rename src/main/java/com/{simibubi/create/foundation/utility => jozufozu/flywheel/util}/WeakHashSet.java (98%) create mode 100644 src/main/java/com/jozufozu/flywheel/util/WorldAttached.java rename src/main/java/com/{jozufozu/flywheel/backend/core => simibubi/create/content/contraptions/components/structureMovement/render}/ContraptionContext.java (82%) rename src/main/java/com/{jozufozu/flywheel/backend/light => simibubi/create/content/contraptions/components/structureMovement/render}/EmptyLighter.java (77%) rename src/main/java/com/{jozufozu/flywheel/backend/light => simibubi/create/content/contraptions/components/structureMovement/render}/LightVolumeDebugger.java (87%) create mode 100644 src/main/java/com/simibubi/create/foundation/render/CreateFlywheelHandler.java rename src/main/java/com/{jozufozu/flywheel/backend => simibubi/create/foundation/render}/effects/ColorMatrices.java (98%) rename src/main/java/com/{jozufozu/flywheel/backend/core => simibubi/create/foundation/render/effects}/EffectsContext.java (89%) rename src/main/java/com/{jozufozu/flywheel/backend => simibubi/create/foundation/render}/effects/EffectsHandler.java (91%) rename src/main/java/com/{jozufozu/flywheel/backend => simibubi/create/foundation/render}/effects/FilterSphere.java (89%) rename src/main/java/com/{jozufozu/flywheel/backend => simibubi/create/foundation/render}/effects/ScreenQuadAttributes.java (92%) rename src/main/java/com/{jozufozu/flywheel/backend => simibubi/create/foundation/render}/effects/SphereFilterProgram.java (98%) create mode 100644 src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert create mode 100644 src/main/resources/assets/create/flywheel/shaders/skeleton/meshlet/meshlet.glsl diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index d22f9e634..83acbe955 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -20,19 +20,17 @@ import org.lwjgl.opengl.GLCapabilities; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.CrumblingRenderer; -import com.jozufozu.flywheel.backend.core.EffectsContext; import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.core.WorldTileRenderer; -import com.jozufozu.flywheel.backend.effects.EffectsHandler; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; +import com.jozufozu.flywheel.util.WorldAttached; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.config.AllConfigs; -import com.simibubi.create.foundation.utility.WorldAttached; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import net.minecraft.client.Minecraft; @@ -65,7 +63,6 @@ public class Backend { public static GLCapabilities capabilities; public static GlCompat compat; - public static EffectsHandler effects; public static WorldAttached> tileRenderer = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.INSTANCE)); public static LazyValue> blockBreaking = new LazyValue<>(() -> { Vector renderers = new Vector<>(10); @@ -86,7 +83,6 @@ public class Backend { static { register(WorldContext.INSTANCE); register(WorldContext.CRUMBLING); - register(EffectsContext.INSTANCE); listeners.refreshListener(world -> { if (canUseInstancing() && world != null) { @@ -191,11 +187,6 @@ public class Backend { compat.instancedArraysSupported(); enabled = AllConfigs.CLIENT.experimentalRendering.get() && !OptifineHandler.usingShaders(); - - if (enabled) { - if (effects != null) effects.delete(); - effects = new EffectsHandler(); - } } public static void tick() { @@ -211,7 +202,6 @@ public class Backend { public static void renderLayer(ClientWorld world, RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { if (!canUseInstancing(world)) return; WorldTileRenderer renderer = tileRenderer.get(world); - if (renderer == null) return; layer.startDrawing(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java index 3ae82a855..d8e711bf7 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java @@ -2,8 +2,8 @@ package com.jozufozu.flywheel.backend.core.materials; import java.nio.ByteBuffer; -import com.jozufozu.flywheel.backend.RenderUtil; import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.util.RenderUtil; import com.mojang.blaze3d.matrix.MatrixStack; public class ModelData extends BasicData { diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java index 6ad43ad9d..af6727a95 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java @@ -17,9 +17,9 @@ import static org.lwjgl.opengl.GL20.glUseProgram; import java.util.Collection; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.RenderUtil; import com.jozufozu.flywheel.backend.gl.GlObject; import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.util.RenderUtil; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Matrix4f; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index 7f1e95405..eb90b410d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -1,31 +1,42 @@ package com.jozufozu.flywheel.backend.instancing; +import java.util.Arrays; +import java.util.List; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; +import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.opengl.GL11; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.RenderUtil; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.PartialModel; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; +import com.jozufozu.flywheel.util.BakedQuadWrapper; +import com.jozufozu.flywheel.util.RenderUtil; +import com.jozufozu.flywheel.util.VirtualEmptyModelData; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.render.SuperByteBufferCache; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BlockModelRenderer; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; +import net.minecraftforge.client.model.data.IModelData; public class RenderMaterial

> { @@ -120,9 +131,37 @@ public class RenderMaterial

quads = Arrays.stream(dirs) + .flatMap(dir -> model.getQuads(referenceState, dir, mc.world.rand, modelData).stream()) + .collect(Collectors.toList()); + + builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + blockRenderer.renderModel(mc.world, model, referenceState, BlockPos.ZERO.up(255), ms, builder, true, + mc.world.rand, 42, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); + builder.finishDrawing(); + return builder; + } + } diff --git a/src/main/java/com/jozufozu/flywheel/backend/light/GridAlignedBB.java b/src/main/java/com/jozufozu/flywheel/backend/light/GridAlignedBB.java index d8f90f90b..f5c63e564 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/light/GridAlignedBB.java +++ b/src/main/java/com/jozufozu/flywheel/backend/light/GridAlignedBB.java @@ -1,8 +1,8 @@ package com.jozufozu.flywheel.backend.light; -import static com.jozufozu.flywheel.backend.RenderUtil.isPowerOf2; +import static com.jozufozu.flywheel.util.RenderUtil.isPowerOf2; -import com.jozufozu.flywheel.backend.RenderUtil; +import com.jozufozu.flywheel.util.RenderUtil; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; diff --git a/src/main/java/com/jozufozu/flywheel/backend/light/LightUpdater.java b/src/main/java/com/jozufozu/flywheel/backend/light/LightUpdater.java index 5210d02c8..7aaaeb892 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/light/LightUpdater.java +++ b/src/main/java/com/jozufozu/flywheel/backend/light/LightUpdater.java @@ -3,7 +3,7 @@ package com.jozufozu.flywheel.backend.light; import java.util.WeakHashMap; import java.util.function.LongConsumer; -import com.simibubi.create.foundation.utility.WeakHashSet; +import com.jozufozu.flywheel.util.WeakHashSet; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; diff --git a/src/main/java/com/jozufozu/flywheel/util/BakedQuadWrapper.java b/src/main/java/com/jozufozu/flywheel/util/BakedQuadWrapper.java new file mode 100644 index 000000000..87b9fdd99 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/util/BakedQuadWrapper.java @@ -0,0 +1,216 @@ +package com.jozufozu.flywheel.util; + +import net.minecraft.client.renderer.model.BakedQuad; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.renderer.vertex.VertexFormatElement; +import net.minecraft.util.math.vector.Vector2f; +import net.minecraft.util.math.vector.Vector3f; + +public class BakedQuadWrapper { + private final FormatCache formatCache = new FormatCache(); + private BakedQuad quad; + private int[] vertexData; + + public BakedQuadWrapper() { + } + + public BakedQuadWrapper(BakedQuad quad) { + this.quad = quad; + this.vertexData = quad.getVertexData(); + } + + public void setQuad(BakedQuad quad) { + this.quad = quad; + this.vertexData = this.quad.getVertexData(); + } + + public static BakedQuadWrapper of(BakedQuad quad) { + return new BakedQuadWrapper(quad); + } + + public void refreshFormat() { + formatCache.refresh(); + } + + public BakedQuad getQuad() { + return quad; + } + + public void clear() { + quad = null; + vertexData = null; + } + + // Getters + + public float getPosX(int vertexIndex) { + return Float.intBitsToFloat(vertexData[vertexIndex * formatCache.vertexSize + formatCache.position]); + } + + public float getPosY(int vertexIndex) { + return Float.intBitsToFloat(vertexData[vertexIndex * formatCache.vertexSize + formatCache.position + 1]); + } + + public float getPosZ(int vertexIndex) { + return Float.intBitsToFloat(vertexData[vertexIndex * formatCache.vertexSize + formatCache.position + 2]); + } + + public Vector3f getPos(int vertexIndex) { + return new Vector3f(getPosX(vertexIndex), getPosY(vertexIndex), getPosZ(vertexIndex)); + } + + public void copyPos(int vertexIndex, Vector3f pos) { + pos.set(getPosX(vertexIndex), getPosY(vertexIndex), getPosZ(vertexIndex)); + } + + public int getColor(int vertexIndex) { + return vertexData[vertexIndex * formatCache.vertexSize + formatCache.color]; + } + + public float getTexU(int vertexIndex) { + return Float.intBitsToFloat(vertexData[vertexIndex * formatCache.vertexSize + formatCache.texture]); + } + + public float getTexV(int vertexIndex) { + return Float.intBitsToFloat(vertexData[vertexIndex * formatCache.vertexSize + formatCache.texture + 1]); + } + + public Vector2f getTex(int vertexIndex) { + return new Vector2f(getTexU(vertexIndex), getTexV(vertexIndex)); + } + + public int getLight(int vertexIndex) { + return vertexData[vertexIndex * formatCache.vertexSize + formatCache.light]; + } + + public float getNormalX(int vertexIndex) { + return Float.intBitsToFloat(vertexData[vertexIndex * formatCache.vertexSize + formatCache.normal]); + } + + public float getNormalY(int vertexIndex) { + return Float.intBitsToFloat(vertexData[vertexIndex * formatCache.vertexSize + formatCache.normal + 1]); + } + + public float getNormalZ(int vertexIndex) { + return Float.intBitsToFloat(vertexData[vertexIndex * formatCache.vertexSize + formatCache.normal + 2]); + } + + public Vector3f getNormal(int vertexIndex) { + return new Vector3f(getNormalX(vertexIndex), getNormalY(vertexIndex), getNormalZ(vertexIndex)); + } + + public void copyNormal(int vertexIndex, Vector3f normal) { + normal.set(getNormalX(vertexIndex), getNormalY(vertexIndex), getNormalZ(vertexIndex)); + } + + // Setters + + public void setPosX(int vertexIndex, float x) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.position] = Float.floatToRawIntBits(x); + } + + public void setPosY(int vertexIndex, float y) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.position + 1] = Float.floatToRawIntBits(y); + } + + public void setPosZ(int vertexIndex, float z) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.position + 2] = Float.floatToRawIntBits(z); + } + + public void setPos(int vertexIndex, float x, float y, float z) { + setPosX(vertexIndex, x); + setPosY(vertexIndex, y); + setPosZ(vertexIndex, z); + } + + public void setPos(int vertexIndex, Vector3f pos) { + setPos(vertexIndex, pos.getX(), pos.getY(), pos.getZ()); + } + + public void setColor(int vertexIndex, int color) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.color] = color; + } + + public void setTexU(int vertexIndex, float u) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.texture] = Float.floatToRawIntBits(u); + } + + public void setTexV(int vertexIndex, float v) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.texture + 1] = Float.floatToRawIntBits(v); + } + + public void setTex(int vertexIndex, float u, float v) { + setTexU(vertexIndex, u); + setTexV(vertexIndex, v); + } + + public void setTex(int vertexIndex, Vector2f tex) { + setTex(vertexIndex, tex.x, tex.y); + } + + public void setLight(int vertexIndex, int light) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.light] = light; + } + + public void setNormalX(int vertexIndex, float normalX) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.normal] = Float.floatToRawIntBits(normalX); + } + + public void setNormalY(int vertexIndex, float normalY) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.normal + 1] = Float.floatToRawIntBits(normalY); + } + + public void setNormalZ(int vertexIndex, float normalZ) { + vertexData[vertexIndex * formatCache.vertexSize + formatCache.normal + 2] = Float.floatToRawIntBits(normalZ); + } + + public void setNormal(int vertexIndex, float normalX, float normalY, float normalZ) { + setNormalX(vertexIndex, normalX); + setNormalY(vertexIndex, normalY); + setNormalZ(vertexIndex, normalZ); + } + + public void setNormal(int vertexIndex, Vector3f normal) { + setNormal(vertexIndex, normal.getX(), normal.getY(), normal.getZ()); + } + + private static class FormatCache { + private static final VertexFormat FORMAT = DefaultVertexFormats.BLOCK; + + public FormatCache() { + refresh(); + } + + // Integer size + public int vertexSize; + + // Element integer offsets + public int position; + public int color; + public int texture; + public int light; + public int normal; + + public void refresh() { + vertexSize = FORMAT.getIntegerSize(); + for (int elementId = 0; elementId < FORMAT.getElements().size(); elementId++) { + VertexFormatElement element = FORMAT.getElements().get(elementId); + int intOffset = FORMAT.getOffset(elementId) / Integer.BYTES; + if (element.getUsage() == VertexFormatElement.Usage.POSITION) { + position = intOffset; + } else if (element.getUsage() == VertexFormatElement.Usage.COLOR) { + color = intOffset; + } else if (element.getUsage() == VertexFormatElement.Usage.UV) { + if (element.getIndex() == 0) { + texture = intOffset; + } else if (element.getIndex() == 2) { + light = intOffset; + } + } else if (element.getUsage() == VertexFormatElement.Usage.NORMAL) { + normal = intOffset; + } + } + } + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/RenderUtil.java b/src/main/java/com/jozufozu/flywheel/util/RenderUtil.java similarity index 77% rename from src/main/java/com/jozufozu/flywheel/backend/RenderUtil.java rename to src/main/java/com/jozufozu/flywheel/util/RenderUtil.java index 9fd6d2897..e60410c85 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/RenderUtil.java +++ b/src/main/java/com/jozufozu/flywheel/util/RenderUtil.java @@ -1,14 +1,14 @@ -package com.jozufozu.flywheel.backend; +package com.jozufozu.flywheel.util; import java.util.function.Supplier; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.utility.AngleHelper; -import com.simibubi.create.foundation.utility.MatrixStacker; import net.minecraft.util.Direction; import net.minecraft.util.math.vector.Matrix3f; import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Vector3f; public class RenderUtil { public static int nextPowerOf2(int a) { @@ -88,11 +88,15 @@ public class RenderUtil { public static Supplier rotateToFace(Direction facing) { return () -> { MatrixStack stack = new MatrixStack(); - MatrixStacker.of(stack) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing)) - .unCentre(); +// MatrixStacker.of(stack) +// .centre() +// .rotateY(AngleHelper.horizontalAngle(facing)) +// .rotateX(AngleHelper.verticalAngle(facing)) +// .unCentre(); + stack.peek().getModel().setTranslation(0.5f, 0.5f, 0.5f); + stack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AngleHelper.horizontalAngle(facing))); + stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(AngleHelper.verticalAngle(facing))); + stack.translate(-0.5f, -0.5f, -0.5f); return stack; }; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/VirtualEmptyModelData.java b/src/main/java/com/jozufozu/flywheel/util/VirtualEmptyModelData.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/utility/VirtualEmptyModelData.java rename to src/main/java/com/jozufozu/flywheel/util/VirtualEmptyModelData.java index 1c9b35287..e61807f85 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/VirtualEmptyModelData.java +++ b/src/main/java/com/jozufozu/flywheel/util/VirtualEmptyModelData.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.utility; +package com.jozufozu.flywheel.util; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelProperty; diff --git a/src/main/java/com/simibubi/create/foundation/utility/WeakHashSet.java b/src/main/java/com/jozufozu/flywheel/util/WeakHashSet.java similarity index 98% rename from src/main/java/com/simibubi/create/foundation/utility/WeakHashSet.java rename to src/main/java/com/jozufozu/flywheel/util/WeakHashSet.java index 61e4c7818..d0fdd7207 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/WeakHashSet.java +++ b/src/main/java/com/jozufozu/flywheel/util/WeakHashSet.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.utility; +package com.jozufozu.flywheel.util; import java.util.AbstractSet; import java.util.Collection; diff --git a/src/main/java/com/jozufozu/flywheel/util/WorldAttached.java b/src/main/java/com/jozufozu/flywheel/util/WorldAttached.java new file mode 100644 index 000000000..7a8e620ab --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/util/WorldAttached.java @@ -0,0 +1,41 @@ +package com.jozufozu.flywheel.util; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +import javax.annotation.Nonnull; + +import net.minecraft.world.IWorld; +import net.minecraftforge.common.util.NonNullSupplier; + +public class WorldAttached { + + Map attached; + private final NonNullSupplier factory; + + public WorldAttached(NonNullSupplier factory) { + this.factory = factory; + attached = new HashMap<>(); + } + + @Nonnull + public T get(IWorld world) { + T t = attached.get(world); + if (t != null) + return t; + T entry = factory.get(); + put(world, entry); + return entry; + } + + public void put(IWorld world, T entry) { + attached.put(world, entry); + } + + public void forEach(Consumer consumer) { + attached.values() + .forEach(consumer); + } + +} diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 825d900cc..d9ccf1f64 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -28,6 +28,7 @@ import com.simibubi.create.foundation.ponder.content.PonderIndex; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.render.AllProgramSpecs; +import com.simibubi.create.foundation.render.CreateFlywheelHandler; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.utility.ghost.GhostBlocks; import com.simibubi.create.foundation.utility.outliner.Outliner; @@ -81,7 +82,7 @@ public class CreateClient { modEventBus.addListener(AllParticleTypes::registerFactories); Backend.init(); - ContraptionRenderDispatcher.init(); + CreateFlywheelHandler.init(); OptifineHandler.init(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index 0a3d995b0..fa7b49062 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -26,7 +26,6 @@ import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; -import com.jozufozu.flywheel.backend.light.EmptyLighter; import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllMovementBehaviours; @@ -50,6 +49,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.pul import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyBlock.MagnetBlock; import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyBlock.RopeBlock; import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyTileEntity; +import com.simibubi.create.content.contraptions.components.structureMovement.render.EmptyLighter; import com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity; import com.simibubi.create.content.contraptions.relays.advanced.GantryShaftBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java index 4d70938b2..aa67d094f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java @@ -132,7 +132,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { protected void tickContraption() { prevAngle = angle; tickActors(); - + if (controllerPos == null) return; if (!world.isBlockPresent(controllerPos)) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/DirectionalExtenderScrollOptionSlot.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/DirectionalExtenderScrollOptionSlot.java index bb0a20b5e..2bf9f5db0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/DirectionalExtenderScrollOptionSlot.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/DirectionalExtenderScrollOptionSlot.java @@ -30,4 +30,4 @@ public class DirectionalExtenderScrollOptionSlot extends CenteredSideValueBoxTra MatrixStacker.of(ms).rotateY(AngleHelper.horizontalAngle(state.get(BlockStateProperties.FACING)) - 90); super.rotate(state, ms); } -} \ No newline at end of file +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionContext.java similarity index 82% rename from src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java rename to src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionContext.java index de84fd268..e3bf437dd 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/ContraptionContext.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionContext.java @@ -1,8 +1,8 @@ -package com.jozufozu.flywheel.backend.core; +package com.simibubi.create.content.contraptions.components.structureMovement.render; import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram; import com.simibubi.create.foundation.render.AllProgramSpecs; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java index 2d4723fb8..821cce83e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java @@ -7,7 +7,6 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; -import com.jozufozu.flywheel.backend.core.ContraptionContext; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 12c102b5b..03a039a45 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -9,7 +9,6 @@ import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL40; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.core.ContraptionContext; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.CreateClient; @@ -57,13 +56,6 @@ public class ContraptionRenderDispatcher { public static final Compartment> CONTRAPTION = new Compartment<>(); protected static PlacementSimulationWorld renderWorld; - public static void init() { - Backend.register(ContraptionContext.INSTANCE); - Backend.listeners.renderLayerListener(ContraptionRenderDispatcher::renderLayer); - Backend.listeners.setupFrameListener(ContraptionRenderDispatcher::beginFrame); - Backend.listeners.refreshListener($ -> ContraptionRenderDispatcher.invalidateAll()); - } - public static void tick() { if (Minecraft.getInstance().isGamePaused()) return; diff --git a/src/main/java/com/jozufozu/flywheel/backend/light/EmptyLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/EmptyLighter.java similarity index 77% rename from src/main/java/com/jozufozu/flywheel/backend/light/EmptyLighter.java rename to src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/EmptyLighter.java index 660e80d11..b46e9e1fb 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/light/EmptyLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/EmptyLighter.java @@ -1,5 +1,6 @@ -package com.jozufozu.flywheel.backend.light; +package com.simibubi.create.content.contraptions.components.structureMovement.render; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; diff --git a/src/main/java/com/jozufozu/flywheel/backend/light/LightVolumeDebugger.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java similarity index 87% rename from src/main/java/com/jozufozu/flywheel/backend/light/LightVolumeDebugger.java rename to src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java index 6fbcd4d5b..e2a3cc684 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/light/LightVolumeDebugger.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java @@ -1,9 +1,9 @@ -package com.jozufozu.flywheel.backend.light; +package com.simibubi.create.content.contraptions.components.structureMovement.render; import java.util.ArrayList; +import com.jozufozu.flywheel.backend.light.GridAlignedBB; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Pair; diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java index fbc1b9a00..c19142761 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java @@ -86,9 +86,9 @@ public class BasinRenderer extends SmartTileEntityRenderer { for (int i = 0; i <= stack.getCount() / 8; i++) { ms.push(); - + Vector3d vec = VecHelper.offsetRandomly(Vector3d.ZERO, r, 1 / 16f); - + ms.translate(vec.x, vec.y, vec.z); renderItem(ms, buffer, light, overlay, stack); ms.pop(); @@ -114,13 +114,13 @@ public class BasinRenderer extends SmartTileEntityRenderer { .getBlockState(basin.getPos() .offset(direction)) .getBlock() instanceof BasinBlock; - + for (IntAttached intAttached : basin.visualizedOutputItems) { float progress = 1 - (intAttached.getFirst() - partialTicks) / BasinTileEntity.OUTPUT_ANIMATION_TIME; - + if (!outToBasin && progress > .35f) continue; - + ms.push(); MatrixStacker.of(ms) .translate(outVec) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java index 28b3c46a6..065e85d81 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java @@ -4,8 +4,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import com.jozufozu.flywheel.util.VirtualEmptyModelData; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import com.simibubi.create.foundation.utility.VirtualEmptyModelData; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java index e0b1edd59..b280b10c3 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java +++ b/src/main/java/com/simibubi/create/content/curiosities/projector/ChromaticProjectorInstance.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.curiosities.projector; -import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; +import com.simibubi.create.foundation.render.effects.EffectsHandler; public class ChromaticProjectorInstance extends TileEntityInstance implements IDynamicInstance { @@ -13,7 +13,7 @@ public class ChromaticProjectorInstance extends TileEntityInstance ContraptionRenderDispatcher.invalidateAll()); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java index d0208773c..1fbebb0aa 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java @@ -12,8 +12,8 @@ import org.lwjgl.opengl.GL11; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.util.VirtualEmptyModelData; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.utility.VirtualEmptyModelData; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/simibubi/create/foundation/render/TemplateBuffer.java b/src/main/java/com/simibubi/create/foundation/render/TemplateBuffer.java index 858fad8a8..5f3eef7b5 100644 --- a/src/main/java/com/simibubi/create/foundation/render/TemplateBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/TemplateBuffer.java @@ -13,15 +13,19 @@ public class TemplateBuffer { protected int formatSize; protected int vertexCount; + public TemplateBuffer() { + + } + public TemplateBuffer(BufferBuilder buf) { Pair state = buf.popData(); ByteBuffer rendered = state.getSecond(); rendered.order(ByteOrder.nativeOrder()); // Vanilla bug, endianness does not carry over into sliced buffers formatSize = buf.getVertexFormat() - .getSize(); + .getSize(); vertexCount = state.getFirst() - .getCount(); + .getCount(); int size = vertexCount * formatSize; template = ByteBuffer.allocate(size); diff --git a/src/main/java/com/jozufozu/flywheel/backend/effects/ColorMatrices.java b/src/main/java/com/simibubi/create/foundation/render/effects/ColorMatrices.java similarity index 98% rename from src/main/java/com/jozufozu/flywheel/backend/effects/ColorMatrices.java rename to src/main/java/com/simibubi/create/foundation/render/effects/ColorMatrices.java index fc78551d8..07a683d16 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/effects/ColorMatrices.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/ColorMatrices.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.effects; +package com.simibubi.create.foundation.render.effects; import com.simibubi.create.foundation.utility.AngleHelper; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/EffectsContext.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java similarity index 89% rename from src/main/java/com/jozufozu/flywheel/backend/core/EffectsContext.java rename to src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java index 0075faf6d..00f47c505 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/EffectsContext.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java @@ -1,8 +1,7 @@ -package com.jozufozu.flywheel.backend.core; +package com.simibubi.create.foundation.render.effects; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.effects.SphereFilterProgram; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.gl.shader.SingleProgram; import com.simibubi.create.foundation.render.AllProgramSpecs; diff --git a/src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java similarity index 91% rename from src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java rename to src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java index fd5e570ea..3035fd99c 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java @@ -1,18 +1,19 @@ -package com.jozufozu.flywheel.backend.effects; +package com.simibubi.create.foundation.render.effects; import java.util.ArrayList; +import javax.annotation.Nullable; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.RenderUtil; -import com.jozufozu.flywheel.backend.core.EffectsContext; import com.jozufozu.flywheel.backend.gl.GlBuffer; import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; import com.jozufozu.flywheel.backend.gl.GlVertexArray; +import com.jozufozu.flywheel.util.RenderUtil; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -27,6 +28,22 @@ import net.minecraft.util.math.vector.Vector3d; public class EffectsHandler { + private static EffectsHandler instance; + + @Nullable + public static EffectsHandler getInstance() { + if (Backend.available() && instance == null) { + instance = new EffectsHandler(); + } + + if (!Backend.available() && instance != null) { + instance.delete(); + instance = null; + } + + return instance; + } + public static float getNearPlane() { return 0.05f; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/effects/FilterSphere.java b/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java similarity index 89% rename from src/main/java/com/jozufozu/flywheel/backend/effects/FilterSphere.java rename to src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java index e7485a705..45cd8226a 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/effects/FilterSphere.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java @@ -1,8 +1,8 @@ -package com.jozufozu.flywheel.backend.effects; +package com.simibubi.create.foundation.render.effects; import java.nio.FloatBuffer; -import com.jozufozu.flywheel.backend.RenderUtil; +import com.jozufozu.flywheel.util.RenderUtil; import net.minecraft.util.math.vector.Matrix4f; diff --git a/src/main/java/com/jozufozu/flywheel/backend/effects/ScreenQuadAttributes.java b/src/main/java/com/simibubi/create/foundation/render/effects/ScreenQuadAttributes.java similarity index 92% rename from src/main/java/com/jozufozu/flywheel/backend/effects/ScreenQuadAttributes.java rename to src/main/java/com/simibubi/create/foundation/render/effects/ScreenQuadAttributes.java index 40fd47ac8..0c7833527 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/effects/ScreenQuadAttributes.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/ScreenQuadAttributes.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.effects; +package com.simibubi.create.foundation.render.effects; import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; diff --git a/src/main/java/com/jozufozu/flywheel/backend/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java similarity index 98% rename from src/main/java/com/jozufozu/flywheel/backend/effects/SphereFilterProgram.java rename to src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java index f0aae1390..8f7612613 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.effects; +package com.simibubi.create.foundation.render.effects; import java.nio.FloatBuffer; import java.util.ArrayList; diff --git a/src/main/java/com/simibubi/create/foundation/utility/WorldAttached.java b/src/main/java/com/simibubi/create/foundation/utility/WorldAttached.java index 337ab826b..ee9022165 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/WorldAttached.java +++ b/src/main/java/com/simibubi/create/foundation/utility/WorldAttached.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.function.Consumer; import java.util.function.Supplier; import javax.annotation.Nullable; @@ -41,9 +40,4 @@ public class WorldAttached { attached.put(world, entry); } - public void forEach(Consumer consumer) { - attached.values() - .forEach(consumer); - } - } diff --git a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java index 93309a030..6878acf40 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java @@ -10,10 +10,10 @@ import javax.annotation.Nullable; import org.lwjgl.system.MemoryStack; +import com.jozufozu.flywheel.util.VirtualEmptyModelData; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; -import com.simibubi.create.foundation.utility.VirtualEmptyModelData; import com.simibubi.create.foundation.utility.placement.PlacementHelpers; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java index 605d47dfa..e23c179fc 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java @@ -51,7 +51,7 @@ public abstract class Outline { float lineWidth = params.getLineWidth(); if (lineWidth == 0) return; - + IVertexBuilder builder = buffer.getBuffer(RenderTypes.getOutlineSolid()); Vector3d diff = end.subtract(start); diff --git a/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert b/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert new file mode 100644 index 000000000..abb8d8487 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert @@ -0,0 +1,17 @@ +#version 110 +#FLWPrefixFields(FLWVertexData, attribute __a_) +#FLWPrefixFields(FLWInstanceData, attribute __a_) + +#FLWPrefixFields(FLWOut, varying __v2f_) + +void main() { + FLWVertexData v; + #FLWAssignToFields(FLWVertexData, v, a_) + + FLWInstanceData i; + #FLWAssignToFields(FLWInstanceData, i, a_) + + FLWOut o = FLWMain(v, i); + + #FLWAssignFromFields(FLWOut, o, v2f_) +} diff --git a/src/main/resources/assets/create/flywheel/shaders/skeleton/meshlet/meshlet.glsl b/src/main/resources/assets/create/flywheel/shaders/skeleton/meshlet/meshlet.glsl new file mode 100644 index 000000000..c1c3f8328 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/skeleton/meshlet/meshlet.glsl @@ -0,0 +1,43 @@ +#version 450 +#extension GL_NV_mesh_shader : require + +layout(local_size_x=32) in; + +layout(max_vertices=64, max_primitives=32) out; + +layout (std430, binding = 1) buffer _vertices { + FLWVertexData vertices[]; +} vb; + +struct s_meshlet { + uint vertices[64]; + uint indices[96]; + uint vertex_count; + uint index_count; +}; + +layout (std430, binding = 2) buffer _meshlets { + s_meshlet meshlets[]; +} mbuf; + +layout (location = 0) out PerVertexData { + vec4 color; +} v_out[];// [max_vertices] + +void main() { + uint mi = gl_WorkGroupID.x; + uint thread_id = gl_LocalInvocationID.x; + + uint primIdx = thread_id * 3; + uint vertStartIdx = thread_id * 2; + + gl_MeshVerticesNV[vertStartIdx + 0].gl_Position; + gl_MeshVerticesNV[vertStartIdx + 1].gl_Position; + + gl_PrimitiveIndicesNV[primIdx + 0] = mbuf.meshlets[mi].indices[primIdx + 0]; + gl_PrimitiveIndicesNV[primIdx + 1] = mbuf.meshlets[mi].indices[primIdx + 1]; + gl_PrimitiveIndicesNV[primIdx + 2] = mbuf.meshlets[mi].indices[primIdx + 2]; + + gl_PrimitiveCountNV = mbuf.meshlets[mi].vertex_count / 2; + +} From 916b187aa8cc6dbd9663e728ec19b4675795163e Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 11 May 2021 11:39:13 -0700 Subject: [PATCH 044/198] Better belt breaking --- .../contraptions/relays/belt/BeltBlock.java | 3 ++- .../create/foundation/BreakProgressHook.java | 22 +++++++++++++++ .../foundation/mixin/BreakProgressMixin.java | 27 +++++++++++++++++++ src/main/resources/create.mixins.json | 21 ++++++++------- 4 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/BreakProgressHook.java create mode 100644 src/main/java/com/simibubi/create/foundation/mixin/BreakProgressMixin.java diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java index 444c963cf..f8a518fa7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java @@ -126,7 +126,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE Date: Tue, 11 May 2021 12:34:38 -0700 Subject: [PATCH 045/198] Organize the mixins --- .../mixin/ChromaticProjectorHooksMixin.java | 35 +++++++++ .../mixin/StoreProjectionMatrixMixin.java | 74 ------------------- .../CancelTileEntityRenderMixin.java | 2 +- .../{ => flywheel}/FogColorTrackerMixin.java | 2 +- .../{ => flywheel}/RenderHooksMixin.java | 18 +---- .../{ => flywheel}/ShaderCloseMixin.java | 2 +- .../flywheel/StoreProjectionMatrixMixin.java | 37 ++++++++++ .../mixin/{ => flywheel}/TileRemoveMixin.java | 2 +- .../{ => flywheel}/TileWorldHookMixin.java | 2 +- .../light}/LightUpdateMixin.java | 2 +- .../light}/NetworkLightUpdateMixin.java | 2 +- src/main/resources/create.mixins.json | 19 ++--- 12 files changed, 90 insertions(+), 107 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/mixin/ChromaticProjectorHooksMixin.java delete mode 100644 src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java rename src/main/java/com/simibubi/create/foundation/mixin/{ => flywheel}/CancelTileEntityRenderMixin.java (96%) rename src/main/java/com/simibubi/create/foundation/mixin/{ => flywheel}/FogColorTrackerMixin.java (91%) rename src/main/java/com/simibubi/create/foundation/mixin/{ => flywheel}/RenderHooksMixin.java (75%) rename src/main/java/com/simibubi/create/foundation/mixin/{ => flywheel}/ShaderCloseMixin.java (94%) create mode 100644 src/main/java/com/simibubi/create/foundation/mixin/flywheel/StoreProjectionMatrixMixin.java rename src/main/java/com/simibubi/create/foundation/mixin/{ => flywheel}/TileRemoveMixin.java (93%) rename src/main/java/com/simibubi/create/foundation/mixin/{ => flywheel}/TileWorldHookMixin.java (96%) rename src/main/java/com/simibubi/create/foundation/mixin/{ => flywheel/light}/LightUpdateMixin.java (96%) rename src/main/java/com/simibubi/create/foundation/mixin/{ => flywheel/light}/NetworkLightUpdateMixin.java (95%) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/ChromaticProjectorHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/ChromaticProjectorHooksMixin.java new file mode 100644 index 000000000..0d9669855 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/ChromaticProjectorHooksMixin.java @@ -0,0 +1,35 @@ +package com.simibubi.create.foundation.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.platform.GlStateManager; +import com.simibubi.create.foundation.render.effects.EffectsHandler; + +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +@Mixin(WorldRenderer.class) +public class ChromaticProjectorHooksMixin { + + @Inject(method = "render", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;render(F)V")) + private void disableTransparencyShaderDepth(MatrixStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) { + GlStateManager.depthMask(false); + } + + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/renderer/ActiveRenderInfo;)V")) + private void applyFilters(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) { + EffectsHandler instance = EffectsHandler.getInstance(); + if (instance != null) + instance.render(stack.peek().getModel()); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java deleted file mode 100644 index 40c1b607c..000000000 --- a/src/main/java/com/simibubi/create/foundation/mixin/StoreProjectionMatrixMixin.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.simibubi.create.foundation.mixin; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.foundation.render.effects.EffectsHandler; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.util.math.vector.Matrix4f; - -@Mixin(GameRenderer.class) -public abstract class StoreProjectionMatrixMixin { - - @Shadow - private float cameraZoom; - @Shadow - private float zoomX; - @Shadow - private float zoomY; - - @Shadow - public abstract double getFOVModifier(ActiveRenderInfo p_215311_1_, float p_215311_2_, boolean p_215311_3_); - - @Shadow - @Final - private Minecraft mc; - @Shadow - private float farPlaneDistance; - - @Unique - private boolean shouldCopy = false; - - /** - * We only want to copy the projection matrix if it is going to be used to render the world. - * We don't care about the mat for your hand. - */ - @Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;loadProjectionMatrix(Lnet/minecraft/util/math/vector/Matrix4f;)V")) - private void projectionMatrixReady(float p_228378_1_, long p_228378_2_, MatrixStack p_228378_4_, CallbackInfo ci) { - shouldCopy = true; - } - - @Inject(method = "loadProjectionMatrix", at = @At("TAIL")) - private void onProjectionMatrixLoad(Matrix4f projection, CallbackInfo ci) { - if (shouldCopy) { - Backend.setProjectionMatrix(projection.copy()); - shouldCopy = false; - } - } - - @Inject(method = "getBasicProjectionMatrix", - at = @At("HEAD"), - cancellable = true) - private void overrideNearPlane(ActiveRenderInfo p_228382_1_, float p_228382_2_, boolean p_228382_3_, CallbackInfoReturnable cir) { - MatrixStack matrixstack = new MatrixStack(); - matrixstack.peek().getModel().loadIdentity(); - if (this.cameraZoom != 1.0F) { - matrixstack.translate((double) this.zoomX, (double) (-this.zoomY), 0.0D); - matrixstack.scale(this.cameraZoom, this.cameraZoom, 1.0F); - } - - matrixstack.peek().getModel().multiply(Matrix4f.perspective(this.getFOVModifier(p_228382_1_, p_228382_2_, p_228382_3_), (float) this.mc.getWindow().getFramebufferWidth() / (float) this.mc.getWindow().getFramebufferHeight(), EffectsHandler.getNearPlane(), EffectsHandler.getFarPlane())); - cir.setReturnValue(matrixstack.peek().getModel()); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/mixin/CancelTileEntityRenderMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/CancelTileEntityRenderMixin.java similarity index 96% rename from src/main/java/com/simibubi/create/foundation/mixin/CancelTileEntityRenderMixin.java rename to src/main/java/com/simibubi/create/foundation/mixin/flywheel/CancelTileEntityRenderMixin.java index d1efec013..4f1c95202 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/CancelTileEntityRenderMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/CancelTileEntityRenderMixin.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.mixin; +package com.simibubi.create.foundation.mixin.flywheel; import java.util.List; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/FogColorTrackerMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/FogColorTrackerMixin.java similarity index 91% rename from src/main/java/com/simibubi/create/foundation/mixin/FogColorTrackerMixin.java rename to src/main/java/com/simibubi/create/foundation/mixin/flywheel/FogColorTrackerMixin.java index d3e69ecf1..87682d8f4 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/FogColorTrackerMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/FogColorTrackerMixin.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.mixin; +package com.simibubi.create.foundation.mixin.flywheel; import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/RenderHooksMixin.java similarity index 75% rename from src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java rename to src/main/java/com/simibubi/create/foundation/mixin/flywheel/RenderHooksMixin.java index c1be3a2eb..e115f833e 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/RenderHooksMixin.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.mixin; +package com.simibubi.create.foundation.mixin.flywheel; import org.lwjgl.opengl.GL20; import org.spongepowered.asm.mixin.Mixin; @@ -10,8 +10,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.OptifineHandler; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; -import com.simibubi.create.foundation.render.effects.EffectsHandler; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.ActiveRenderInfo; @@ -92,20 +90,6 @@ public class RenderHooksMixin { GL20.glUseProgram(0); } - // Effects system - - @Inject(method = "render", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/shader/ShaderGroup;render(F)V")) - private void disableTransparencyShaderDepth(MatrixStack p_228426_1_, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) { - GlStateManager.depthMask(false); - } - - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/renderer/ActiveRenderInfo;)V")) - private void applyFilters(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo p_228426_6_, GameRenderer p_228426_7_, LightTexture p_228426_8_, Matrix4f p_228426_9_, CallbackInfo ci) { - EffectsHandler instance = EffectsHandler.getInstance(); - if (instance != null) - instance.render(stack.peek().getModel()); - } - // Instancing @Inject(at = @At("TAIL"), method = "scheduleBlockRerenderIfNeeded") diff --git a/src/main/java/com/simibubi/create/foundation/mixin/ShaderCloseMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/ShaderCloseMixin.java similarity index 94% rename from src/main/java/com/simibubi/create/foundation/mixin/ShaderCloseMixin.java rename to src/main/java/com/simibubi/create/foundation/mixin/flywheel/ShaderCloseMixin.java index 8da970608..cb4f05aa1 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/ShaderCloseMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/ShaderCloseMixin.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.mixin; +package com.simibubi.create.foundation.mixin.flywheel; import javax.annotation.Nullable; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/flywheel/StoreProjectionMatrixMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/StoreProjectionMatrixMixin.java new file mode 100644 index 000000000..cbe203a74 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/StoreProjectionMatrixMixin.java @@ -0,0 +1,37 @@ +package com.simibubi.create.foundation.mixin.flywheel; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.jozufozu.flywheel.backend.Backend; +import com.mojang.blaze3d.matrix.MatrixStack; + +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.util.math.vector.Matrix4f; + +@Mixin(GameRenderer.class) +public abstract class StoreProjectionMatrixMixin { + + @Unique + private boolean shouldCopy = false; + + /** + * We only want to copy the projection matrix if it is going to be used to render the world. + * We don't care about the mat for your hand. + */ + @Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;loadProjectionMatrix(Lnet/minecraft/util/math/vector/Matrix4f;)V")) + private void projectionMatrixReady(float p_228378_1_, long p_228378_2_, MatrixStack p_228378_4_, CallbackInfo ci) { + shouldCopy = true; + } + + @Inject(method = "loadProjectionMatrix", at = @At("TAIL")) + private void onProjectionMatrixLoad(Matrix4f projection, CallbackInfo ci) { + if (shouldCopy) { + Backend.setProjectionMatrix(projection.copy()); + shouldCopy = false; + } + } +} diff --git a/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileRemoveMixin.java similarity index 93% rename from src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java rename to src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileRemoveMixin.java index 4de24590a..66a6960ae 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileRemoveMixin.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.mixin; +package com.simibubi.create.foundation.mixin.flywheel; import javax.annotation.Nullable; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileWorldHookMixin.java similarity index 96% rename from src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java rename to src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileWorldHookMixin.java index b39f512ea..fdf4a4705 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileWorldHookMixin.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.mixin; +package com.simibubi.create.foundation.mixin.flywheel; import java.util.Set; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/light/LightUpdateMixin.java similarity index 96% rename from src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java rename to src/main/java/com/simibubi/create/foundation/mixin/flywheel/light/LightUpdateMixin.java index 1d1c99757..7319e0a96 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/light/LightUpdateMixin.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.mixin; +package com.simibubi.create.foundation.mixin.flywheel.light; import java.util.Map; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/light/NetworkLightUpdateMixin.java similarity index 95% rename from src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java rename to src/main/java/com/simibubi/create/foundation/mixin/flywheel/light/NetworkLightUpdateMixin.java index 4b1d899a8..2f65f4ae9 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/light/NetworkLightUpdateMixin.java @@ -1,4 +1,4 @@ -package com.simibubi.create.foundation.mixin; +package com.simibubi.create.foundation.mixin.flywheel.light; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index 3aae131af..c6a6b7881 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -6,16 +6,17 @@ "refmap": "create.refmap.json", "client": [ "BreakProgressMixin", - "CancelTileEntityRenderMixin", + "ChromaticProjectorHooksMixin", "EntityContraptionInteractionMixin", - "FogColorTrackerMixin", - "LightUpdateMixin", - "NetworkLightUpdateMixin", - "RenderHooksMixin", - "ShaderCloseMixin", - "StoreProjectionMatrixMixin", - "TileRemoveMixin", - "TileWorldHookMixin" + "flywheel.CancelTileEntityRenderMixin", + "flywheel.FogColorTrackerMixin", + "flywheel.RenderHooksMixin", + "flywheel.ShaderCloseMixin", + "flywheel.StoreProjectionMatrixMixin", + "flywheel.TileRemoveMixin", + "flywheel.TileWorldHookMixin", + "flywheel.light.LightUpdateMixin", + "flywheel.light.NetworkLightUpdateMixin" ], "injectors": { "defaultRequire": 1 From c1b7a1c19d43b4f2e4b0db226792bc61dbc8ad5b Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 11 May 2021 18:24:12 -0700 Subject: [PATCH 046/198] Extremely fancy shader templating - Nothing is properly hooked up yet. - A single shader file will be able to be compiled with different opengl targets. - I plan on using this to implement meshlet rendering as an alternate backend-backend that will be used when available. - It could also be used to enable compatibility with opengl 3.0 or potentially even 2.0. --- .../flywheel/backend/ShaderLoader.java | 24 ++++- .../InstancedArraysShaderTemplate.java | 102 ++++++++++++++++++ .../backend/loading/ParsedShader.java | 42 ++++++++ .../backend/loading/TaggedStruct.java | 36 +++++++ .../create/flywheel/shaders/block_new.frag | 19 ++++ .../create/flywheel/shaders/model_new.vert | 45 ++++++++ .../shaders/skeleton/instanced/instanced.frag | 12 +++ .../shaders/skeleton/instanced/instanced.vert | 12 ++- 8 files changed, 282 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysShaderTemplate.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/TaggedStruct.java create mode 100644 src/main/resources/assets/create/flywheel/shaders/block_new.frag create mode 100644 src/main/resources/assets/create/flywheel/shaders/model_new.vert create mode 100644 src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.frag diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index bb1ed25c0..65497611b 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -58,6 +58,16 @@ public class ShaderLoader { shaderSource.clear(); loadShaderSources(manager); +// ResourceLocation test = new ResourceLocation("create", "model_new.vert"); +// ResourceLocation vert = new ResourceLocation("create", "skeleton/instanced/instanced.vert"); +// +// InstancedArraysShaderTemplate template = new InstancedArraysShaderTemplate(getShaderSource(vert)); +// ParsedShader parsedShader = new ParsedShader(getShaderSource(test)); +// +// String apply = template.apply(parsedShader); +// +// printSource(test, apply); + for (ShaderContext context : Backend.contexts.values()) { context.load(this); } @@ -134,16 +144,20 @@ public class ShaderLoader { source = defines.process(source); if (debugDumpFile) { - Backend.log.debug("Finished processing '" + name + "':"); - int i = 1; - for (String s : source.split("\n")) { - Backend.log.debug(String.format("%1$4s: ", i++) + s); - } + printSource(name, source); } return new GlShader(type, name, source); } + private void printSource(ResourceLocation name, String source) { + Backend.log.debug("Finished processing '" + name + "':"); + int i = 1; + for (String s : source.split("\n")) { + Backend.log.debug(String.format("%1$4s: ", i++) + s); + } + } + private String processIncludes(String source, ResourceLocation baseName) { HashSet seen = new HashSet<>(); seen.add(baseName); diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysShaderTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysShaderTemplate.java new file mode 100644 index 000000000..ce6eb5db2 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysShaderTemplate.java @@ -0,0 +1,102 @@ +package com.jozufozu.flywheel.backend.loading; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class InstancedArraysShaderTemplate { + + private static final String delimiter = "#flwbeginbody"; + private static final Pattern headerFinder = Pattern.compile(delimiter); + + private static final Pattern prefixer = Pattern.compile("#FLWPrefixFields\\((\\S+),\\s*([^\\n]+)\\)"); + private static final Pattern assigner = Pattern.compile("#FLWAssignFields\\(([\\w\\d_]+),\\s*([\\w\\d_.]+),\\s*([\\w\\d_.]+)\\)"); + + public static final String[] required = {"FLWInstanceData", "FLWVertexData", "FLWFragment"}; + + final String header; + final String body; + + public InstancedArraysShaderTemplate(String templateSrc) { + Matcher matcher = headerFinder.matcher(templateSrc); + + if (!matcher.find()) { + throw new RuntimeException("Shader template must have a header and footer delimited by '" + delimiter + "'"); + } + + this.header = templateSrc.substring(0, matcher.start()); + this.body = templateSrc.substring(matcher.end()); + + } + + public String apply(ParsedShader shader) { + + return header + + shader.src + + processBody(shader); + } + + public String processBody(ParsedShader shader) { + String s = body; + + for (String name : required) { + TaggedStruct struct = shader.getTag(name); + + s = s.replace(name, struct.name); + } + + s = fillPrefixes(shader, s); + s = fillAssigns(shader, s); + + return s; + } + + private String fillPrefixes(ParsedShader shader, String s) { + Matcher prefixMatches = prefixer.matcher(s); + + StringBuffer out = new StringBuffer(); + while (prefixMatches.find()) { + String structName = prefixMatches.group(1); + String prefix = prefixMatches.group(2); + + TaggedStruct struct = shader.getStruct(structName); + + StringBuilder builder = new StringBuilder(); + for (String field : struct.fields.keySet()) { + builder.append(prefix); + builder.append(field); + builder.append(";\n"); + } + + prefixMatches.appendReplacement(out, builder.toString()); + } + prefixMatches.appendTail(out); + return out.toString(); + } + + private String fillAssigns(ParsedShader shader, String s) { + Matcher assignMatches = assigner.matcher(s); + + StringBuffer out = new StringBuffer(); + while (assignMatches.find()) { + String structName = assignMatches.group(1); + String lhs = assignMatches.group(2); + String rhs = assignMatches.group(3); + + TaggedStruct struct = shader.getStruct(structName); + + StringBuilder builder = new StringBuilder(); + for (String field : struct.fields.keySet()) { + builder.append(lhs); + builder.append(field); + builder.append(" = "); + builder.append(rhs); + builder.append(field); + builder.append(";\n"); + } + + assignMatches.appendReplacement(out, builder.toString()); + } + assignMatches.appendTail(out); + return out.toString(); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java new file mode 100644 index 000000000..aa76253a1 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java @@ -0,0 +1,42 @@ +package com.jozufozu.flywheel.backend.loading; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ParsedShader { + private static final Pattern decorator = Pattern.compile("#\\[([\\w_]*)]"); + private static final Pattern taggedStruct = Pattern.compile("#\\[([\\w_]*)]\\s*struct\\s+([\\w\\d_]*)\\s*\\{(\\s*(?:.*;\\s*\\n)+\\s*)}\\s*;"); + + final String src; + + final Map tag2Struct = new HashMap<>(); + final Map name2Struct = new HashMap<>(); + + public ParsedShader(String src) { + + Matcher structs = taggedStruct.matcher(src); + + StringBuffer strippedSrc = new StringBuffer(); + while (structs.find()) { + TaggedStruct struct = new TaggedStruct(structs); + + structs.appendReplacement(strippedSrc, decorator.matcher(struct.source).replaceFirst("")); + + tag2Struct.put(struct.tag, struct); + name2Struct.put(struct.name, struct); + } + structs.appendTail(strippedSrc); + + this.src = strippedSrc.toString(); + } + + public TaggedStruct getTag(String tag) { + return tag2Struct.get(tag); + } + + public TaggedStruct getStruct(String name) { + return name2Struct.get(name); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedStruct.java b/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedStruct.java new file mode 100644 index 000000000..4249047c9 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedStruct.java @@ -0,0 +1,36 @@ +package com.jozufozu.flywheel.backend.loading; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TaggedStruct { + + public static final Pattern fieldPattern = Pattern.compile("(\\S+)\\s*(\\S+);"); + + int srcStart, srcEnd; + String source; + String tag; + String name; + String body; + + Map fields = new HashMap<>(); + + public TaggedStruct(Matcher foundMatcher) { + this.source = foundMatcher.group(); + + srcStart = foundMatcher.start(); + srcEnd = foundMatcher.end(); + + tag = foundMatcher.group(1); + name = foundMatcher.group(2); + body = foundMatcher.group(3); + + Matcher fielder = fieldPattern.matcher(body); + + while (fielder.find()) { + fields.put(fielder.group(2), fielder.group(1)); + } + } +} diff --git a/src/main/resources/assets/create/flywheel/shaders/block_new.frag b/src/main/resources/assets/create/flywheel/shaders/block_new.frag new file mode 100644 index 000000000..11ed8ac31 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/block_new.frag @@ -0,0 +1,19 @@ +#version 110 + +#flwbuiltins + +#[FLWFragment] +struct Raster { + vec2 texCoords; + vec4 color; + float diffuse; + vec2 light; +}; + +void FLWMain(Raster r) { + vec4 tex = FLWBlockTexture(r.texCoords); + + vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color; + + FLWFinalizeColor(color); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/model_new.vert b/src/main/resources/assets/create/flywheel/shaders/model_new.vert new file mode 100644 index 000000000..29df494d8 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/model_new.vert @@ -0,0 +1,45 @@ +#flwbuiltins +#flwinclude <"create:core/matutils.glsl"> +#flwinclude <"create:core/diffuse.glsl"> + +#[FLWVertexData] +struct Vertex { + vec3 pos; + vec3 normal; + vec2 texCoords; +}; + +#[FLWInstanceData] +struct Instance { + vec2 light; + vec4 color; + mat4 transform; + mat3 normalMat; +}; + +#[FLWFragment] +struct Raster { + vec2 texCoords; + vec4 color; + float diffuse; + vec2 light; +}; + +Raster FLWMain(Vertex v, Instance i) { + vec4 worldPos = i.transform * vec4(v.pos, 1.); + + vec3 norm = i.normalMat * v.normal; + + FLWFinalizeWorldPos(worldPos); + FLWFinalizeNormal(norm); + + norm = normalize(norm); + + Raster r; + r.diffuse = diffuse(norm); + r.texCoords = v.texCoords; + r.light = i.light; + r.color = i.color; + + return r; +} diff --git a/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.frag b/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.frag new file mode 100644 index 000000000..fde45d306 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.frag @@ -0,0 +1,12 @@ +#version 110 + +#flwbeginbody + +#FLWPrefixFields(FLWFragment, varying __v2f_) + +void main() { + FLWFragment f; + #FLWAssignFields(FLWFragment, f., __v2f_) + + FLWMain(f); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert b/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert index abb8d8487..b364babd7 100644 --- a/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert +++ b/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert @@ -1,17 +1,19 @@ #version 110 + +#flwbeginbody #FLWPrefixFields(FLWVertexData, attribute __a_) #FLWPrefixFields(FLWInstanceData, attribute __a_) -#FLWPrefixFields(FLWOut, varying __v2f_) +#FLWPrefixFields(FLWFragment, varying __v2f_) void main() { FLWVertexData v; - #FLWAssignToFields(FLWVertexData, v, a_) + #FLWAssignFields(FLWVertexData, v., __a_) FLWInstanceData i; - #FLWAssignToFields(FLWInstanceData, i, a_) + #FLWAssignFields(FLWInstanceData, i., __a_) - FLWOut o = FLWMain(v, i); + FLWFragment o = FLWMain(v, i); - #FLWAssignFromFields(FLWOut, o, v2f_) + #FLWAssignFields(FLWFragment, __v2f_, o.) } From ee480a7f46eede6ee304763d0157eefd9fd85db5 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 12 May 2021 19:48:40 +1000 Subject: [PATCH 047/198] Add Supplementaries support for milling flax and washing blackboards --- .../compat/supplementaries/milling/flax.json | 29 +++++++++++++++++++ .../supplementaries/splashing/blackboard.json | 19 ++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/main/resources/data/create/recipes/compat/supplementaries/milling/flax.json create mode 100644 src/main/resources/data/create/recipes/compat/supplementaries/splashing/blackboard.json diff --git a/src/main/resources/data/create/recipes/compat/supplementaries/milling/flax.json b/src/main/resources/data/create/recipes/compat/supplementaries/milling/flax.json new file mode 100644 index 000000000..178dfd21d --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/supplementaries/milling/flax.json @@ -0,0 +1,29 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "supplementaries" + } + ], + "type": "create:milling", + "ingredients": [ + { + "item": "supplementaries:flax" + } + ], + "results": [ + { + "item": "minecraft:string" + }, + { + "item": "minecraft:string", + "count": 2, + "chance": 0.25 + }, + { + "item": "supplementaries:flax_seeds", + "chance": 0.25 + } + ], + "processingTime": 150 +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/supplementaries/splashing/blackboard.json b/src/main/resources/data/create/recipes/compat/supplementaries/splashing/blackboard.json new file mode 100644 index 000000000..badf6115d --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/supplementaries/splashing/blackboard.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "supplementaries" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "supplementaries:blackboard" + } + ], + "results": [ + { + "item": "supplementaries:blackboard" + } + ] +} \ No newline at end of file From a54107baf10d91aa1859f67df93cf405eb2892d3 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 12 May 2021 19:49:27 +1000 Subject: [PATCH 048/198] Add washing recipes for Endergetic Expansion's petrified items --- .../splashing/petrified_end_corrock.json | 19 +++++++++++++++++++ .../petrified_end_corrock_block.json | 19 +++++++++++++++++++ .../petrified_end_corrock_crown.json | 19 +++++++++++++++++++ .../splashing/petrified_nether_corrock.json | 19 +++++++++++++++++++ .../petrified_nether_corrock_block.json | 19 +++++++++++++++++++ .../petrified_nether_corrock_crown.json | 19 +++++++++++++++++++ .../petrified_overworld_corrock.json | 19 +++++++++++++++++++ .../petrified_overworld_corrock_block.json | 19 +++++++++++++++++++ .../petrified_overworld_corrock_crown.json | 19 +++++++++++++++++++ 9 files changed, 171 insertions(+) create mode 100644 src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock.json create mode 100644 src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock_block.json create mode 100644 src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock_crown.json create mode 100644 src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock.json create mode 100644 src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock_block.json create mode 100644 src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock_crown.json create mode 100644 src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock.json create mode 100644 src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock_block.json create mode 100644 src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock_crown.json diff --git a/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock.json b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock.json new file mode 100644 index 000000000..922cd9445 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "endergetic" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "endergetic:end_corrock" + } + ], + "results": [ + { + "item": "endergetic:petrified_end_corrock" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock_block.json b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock_block.json new file mode 100644 index 000000000..33f3e4598 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock_block.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "endergetic" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "endergetic:end_corrock_block" + } + ], + "results": [ + { + "item": "endergetic:petrified_end_corrock_block" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock_crown.json b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock_crown.json new file mode 100644 index 000000000..f0bdfc6e1 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_end_corrock_crown.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "endergetic" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "endergetic:end_corrock_crown" + } + ], + "results": [ + { + "item": "endergetic:petrified_end_corrock_crown" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock.json b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock.json new file mode 100644 index 000000000..5f0e48f9f --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "endergetic" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "endergetic:nether_corrock" + } + ], + "results": [ + { + "item": "endergetic:petrified_nether_corrock" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock_block.json b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock_block.json new file mode 100644 index 000000000..5a28a9723 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock_block.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "endergetic" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "endergetic:nether_corrock_block" + } + ], + "results": [ + { + "item": "endergetic:petrified_nether_corrock_block" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock_crown.json b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock_crown.json new file mode 100644 index 000000000..6613d9bb4 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_nether_corrock_crown.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "endergetic" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "endergetic:nether_corrock_crown" + } + ], + "results": [ + { + "item": "endergetic:petrified_nether_corrock_crown" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock.json b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock.json new file mode 100644 index 000000000..82cd86c81 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "endergetic" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "endergetic:overworld_corrock" + } + ], + "results": [ + { + "item": "endergetic:petrified_overworld_corrock" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock_block.json b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock_block.json new file mode 100644 index 000000000..8f451fa5f --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock_block.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "endergetic" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "endergetic:overworld_corrock_block" + } + ], + "results": [ + { + "item": "endergetic:petrified_overworld_corrock_block" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock_crown.json b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock_crown.json new file mode 100644 index 000000000..840b884a0 --- /dev/null +++ b/src/main/resources/data/create/recipes/compat/endergetic/splashing/petrified_overworld_corrock_crown.json @@ -0,0 +1,19 @@ +{ + "conditions": [ + { + "type": "forge:mod_loaded", + "modid": "endergetic" + } + ], + "type": "create:splashing", + "ingredients": [ + { + "item": "endergetic:overworld_corrock_crown" + } + ], + "results": [ + { + "item": "endergetic:petrified_overworld_corrock_crown" + } + ] +} \ No newline at end of file From 56b2046957ba5db624e3d81b4fa4a845e80621cf Mon Sep 17 00:00:00 2001 From: JozsefA Date: Wed, 12 May 2021 15:14:33 -0700 Subject: [PATCH 049/198] It can actually load and link something - Lots of refactoring in the shader loading code. - Abstract all the different shader source transformations into ProcessingStage. - An ordered list of ProcessingStages is called a ShaderTransformer. - When you acquire sources, a Shader now keeps track of the source location, shader type, and source code all together. --- .../flywheel/backend/ShaderContext.java | 10 +- .../flywheel/backend/ShaderLoader.java | 92 ++++++++++--------- .../flywheel/backend/core/BasicProgram.java | 4 + .../flywheel/backend/core/WorldContext.java | 13 +-- .../gl/shader/FogSensitiveProgram.java | 2 +- .../flywheel/backend/gl/shader/GlShader.java | 14 +-- .../backend/gl/shader/ProgramSpec.java | 23 +++++ .../backend/gl/shader/ShaderConstants.java | 10 +- .../backend/gl/shader/SingleProgram.java | 2 +- .../loading/InstancedArraysTemplate.java | 21 +++++ .../backend/loading/ParsedShader.java | 7 +- .../backend/loading/ProcessingStage.java | 7 ++ .../backend/loading/ProgramTemplate.java | 28 ++++++ .../flywheel/backend/loading/Shader.java | 33 +++++++ ...haderTemplate.java => ShaderTemplate.java} | 38 ++++++-- .../backend/loading/ShaderTransformer.java | 33 +++++++ .../create/flywheel/shaders/block_new.frag | 2 - .../create/flywheel/shaders/model_new.vert | 3 +- .../shaders/skeleton/instanced/instanced.frag | 12 --- .../shaders/skeleton/instanced/instanced.vert | 19 ---- .../shaders/template/instanced/instanced.frag | 12 +++ .../shaders/template/instanced/instanced.vert | 19 ++++ .../meshlet/meshlet.glsl | 0 23 files changed, 290 insertions(+), 114 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/ProcessingStage.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/ProgramTemplate.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java rename src/main/java/com/jozufozu/flywheel/backend/loading/{InstancedArraysShaderTemplate.java => ShaderTemplate.java} (71%) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTransformer.java delete mode 100644 src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.frag delete mode 100644 src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert create mode 100644 src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag create mode 100644 src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert rename src/main/resources/assets/create/flywheel/shaders/{skeleton => template}/meshlet/meshlet.glsl (100%) diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java index 65344a93d..b4318d18c 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java @@ -7,7 +7,8 @@ import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; -import com.jozufozu.flywheel.backend.gl.shader.ShaderType; +import com.jozufozu.flywheel.backend.loading.ProcessingStage; +import com.jozufozu.flywheel.backend.loading.Shader; import net.minecraft.util.ResourceLocation; @@ -32,8 +33,11 @@ public abstract class ShaderContext

{ Backend.log.debug("Loaded program {}", programSpec.name); } - public String preProcess(ShaderLoader loader, ShaderType type, ResourceLocation shader, String shaderSrc) { - return shaderSrc; + public void preProcess(ShaderLoader loader, Shader shader) { + } + + public ProcessingStage loadingStage(ShaderLoader loader) { + return shader -> this.preProcess(loader, shader); } public P getProgram(ProgramSpec spec) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index 65497611b..a786efefb 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Predicate; @@ -25,12 +26,12 @@ import java.util.stream.Stream; import org.lwjgl.system.MemoryUtil; import com.google.common.collect.Lists; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.gl.GlObject; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.GlShader; -import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; -import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; +import com.jozufozu.flywheel.backend.loading.Shader; +import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.resources.IResource; @@ -58,15 +59,24 @@ public class ShaderLoader { shaderSource.clear(); loadShaderSources(manager); -// ResourceLocation test = new ResourceLocation("create", "model_new.vert"); -// ResourceLocation vert = new ResourceLocation("create", "skeleton/instanced/instanced.vert"); +// InstancedArraysTemplate template = new InstancedArraysTemplate(this); // -// InstancedArraysShaderTemplate template = new InstancedArraysShaderTemplate(getShaderSource(vert)); -// ParsedShader parsedShader = new ParsedShader(getShaderSource(test)); +// ResourceLocation name = new ResourceLocation("create", "test"); +// ResourceLocation vert = new ResourceLocation("create", "model_new.vert"); +// ResourceLocation frag = new ResourceLocation("create", "block_new.frag"); // -// String apply = template.apply(parsedShader); +// ShaderTransformer transformer = new ShaderTransformer() +// .pushStage(WorldContext.INSTANCE.loadingStage(this)) +// .pushStage(this::processIncludes) +// .pushStage(template) +// .pushStage(this::processIncludes); // -// printSource(test, apply); +// Shader vertexFile = this.source(vert, ShaderType.VERTEX); +// Shader fragmentFile = this.source(frag, ShaderType.FRAGMENT); +// +// GlProgram.Builder builder = loadProgram(name, transformer, vertexFile, fragmentFile); +// +// BasicProgram program = new BasicProgram(builder, GlFogMode.NONE.getFogFactory()); for (ShaderContext context : Backend.contexts.values()) { context.load(this); @@ -108,48 +118,41 @@ public class ShaderLoader { } } - public GlProgram.Builder loadProgram(ShaderContext ctx, ProgramSpec programSpec) { - return loadProgram(ctx, programSpec, programSpec.defines); + public Shader source(ResourceLocation name, ShaderType type) { + return new Shader(type, name, getShaderSource(name)); } - public GlProgram.Builder loadProgram(ShaderContext ctx, ProgramSpec programSpec, ShaderConstants defines) { - return loadProgram(ctx, programSpec.name, programSpec.vert, programSpec.frag, programSpec.attributes, defines); + public GlProgram.Builder loadProgram(ResourceLocation name, ShaderTransformer transformer, Shader... shaders) { + return loadProgram(name, transformer, Lists.newArrayList(shaders)); } - public GlProgram.Builder loadProgram(ShaderContext ctx, ResourceLocation name, ResourceLocation vert, ResourceLocation frag, Collection attribs, ShaderConstants defines) { - GlShader vsh = null; - GlShader fsh = null; + /** + * Ingests the given shaders, compiling them and linking them together after applying the transformer to the source. + * + * @param name What should we call this program if something goes wrong? + * @param transformer What should we do to the sources before compilation? + * @param shaders What are the different shader stages that should be linked together? + * @return A linked program builder. + */ + public GlProgram.Builder loadProgram(ResourceLocation name, ShaderTransformer transformer, Collection shaders) { + List compiled = new ArrayList<>(shaders.size()); try { - vsh = loadShader(ctx, vert, ShaderType.VERTEX, defines); - fsh = loadShader(ctx, frag, ShaderType.FRAGMENT, defines); + GlProgram.Builder builder = GlProgram.builder(name); - return GlProgram.builder(name) - .attachShader(vsh) - .attachShader(fsh) - .addAttributes(attribs) - .link(); + for (Shader shader : shaders) { + transformer.transformSource(shader); + GlShader sh = new GlShader(shader); + compiled.add(sh); + + builder.attachShader(sh); + } + + return builder.link(); } finally { - if (vsh != null) vsh.delete(); - if (fsh != null) fsh.delete(); + compiled.forEach(GlObject::delete); } } - public GlShader loadShader(ShaderContext ctx, ResourceLocation name, ShaderType type, ShaderConstants defines) { - String source = shaderSource.get(name); - - source = ctx.preProcess(this, type, name, source); - source = processIncludes(source, name); - - if (defines != null) - source = defines.process(source); - - if (debugDumpFile) { - printSource(name, source); - } - - return new GlShader(type, name, source); - } - private void printSource(ResourceLocation name, String source) { Backend.log.debug("Finished processing '" + name + "':"); int i = 1; @@ -158,11 +161,12 @@ public class ShaderLoader { } } - private String processIncludes(String source, ResourceLocation baseName) { + public void processIncludes(Shader shader) { HashSet seen = new HashSet<>(); - seen.add(baseName); + seen.add(shader.name); - return includeRecursive(source, seen).collect(Collectors.joining("\n")); + String includesInjected = includeRecursive(shader.getSource(), seen).collect(Collectors.joining("\n")); + shader.setSource(includesInjected); } private Stream includeRecursive(String source, Set seen) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java index 064dfd3d4..829e2eaf2 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java @@ -22,6 +22,10 @@ public class BasicProgram extends GlProgram { protected int uBlockAtlas; protected int uLightMap; + public BasicProgram(GlProgram.Builder builder, ProgramFogMode.Factory fogFactory) { + this(builder.name, builder.program, fogFactory); + } + public BasicProgram(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory) { super(name, handle); uTime = getUniformLocation("uTime"); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index 693150665..c0ee56f44 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -14,6 +14,7 @@ import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; +import com.jozufozu.flywheel.backend.loading.Shader; import net.minecraft.util.ResourceLocation; @@ -50,15 +51,15 @@ public class WorldContext

extends ShaderContext

{ } @Override - public String preProcess(ShaderLoader loader, ShaderType type, ResourceLocation shader, String shaderSrc) { - String builtinSrc = loader.getShaderSource(builtins.get(type)); + public void preProcess(ShaderLoader loader, Shader shader) { + String builtinSrc = loader.getShaderSource(builtins.get(shader.type)); - Matcher matcher = builtinPattern.matcher(shaderSrc); + Matcher matcher = builtinPattern.matcher(shader.getSource()); if (matcher.find()) - return matcher.replaceFirst(builtinSrc); - - throw new RuntimeException(String.format("%s shader '%s' is missing %s, cannot use in World Context", type.name, shader, declaration)); + shader.setSource(matcher.replaceFirst(builtinSrc)); + else + throw new RuntimeException(String.format("%s shader '%s' is missing %s, cannot use in World Context", shader.type.name, shader.name, declaration)); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java index 0ef0e509f..ac158da54 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java @@ -45,7 +45,7 @@ public class FogSensitiveProgram

implements IMultiProgram

that.process(this.process(source)); - } - } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java index 21754dd6f..4f1cfa0ae 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java @@ -3,7 +3,12 @@ package com.jozufozu.flywheel.backend.gl.shader; import java.util.ArrayList; import java.util.Arrays; +import com.jozufozu.flywheel.backend.ShaderContext; +import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; +import com.jozufozu.flywheel.backend.loading.InstancedArraysTemplate; +import com.jozufozu.flywheel.backend.loading.Shader; +import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import net.minecraft.util.ResourceLocation; @@ -30,6 +35,24 @@ public class ProgramSpec { this.attributes = attributes; } + public GlProgram.Builder loadProgram(ShaderContext ctx, ShaderConstants defines, ShaderLoader loader) { + InstancedArraysTemplate template = new InstancedArraysTemplate(loader); + + ShaderTransformer transformer = new ShaderTransformer() + .pushStage(ctx.loadingStage(loader)) +// .pushStage(loader::processIncludes) +// .pushStage(template) + .pushStage(loader::processIncludes); + + if (defines != null) + transformer.pushStage(defines); + + Shader vertexFile = loader.source(vert, ShaderType.VERTEX); + Shader fragmentFile = loader.source(frag, ShaderType.FRAGMENT); + return loader.loadProgram(name, transformer, vertexFile, fragmentFile) + .addAttributes(attributes); + } + public static class Builder { private ResourceLocation vert; private ResourceLocation frag; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java index 7822c3553..5119310f7 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java @@ -8,8 +8,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import com.google.common.collect.Lists; +import com.jozufozu.flywheel.backend.loading.ProcessingStage; +import com.jozufozu.flywheel.backend.loading.Shader; -public class ShaderConstants implements GlShader.PreProcessor { +public class ShaderConstants implements ProcessingStage { public static final ShaderConstants EMPTY = new ShaderConstants(); private final ArrayList defines; @@ -45,8 +47,8 @@ public class ShaderConstants implements GlShader.PreProcessor { } @Override - public String process(String source) { - return new BufferedReader(new StringReader(source)).lines().flatMap(line -> { + public void process(Shader shader) { + shader.setSource(new BufferedReader(new StringReader(shader.getSource())).lines().flatMap(line -> { Stream map = Stream.of(line); if (line.startsWith("#version")) { @@ -54,6 +56,6 @@ public class ShaderConstants implements GlShader.PreProcessor { } return map; - }).collect(Collectors.joining("\n")); + }).collect(Collectors.joining("\n"))); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java index d5bfbb539..844052880 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java @@ -31,7 +31,7 @@ public class SingleProgram

implements IMultiProgram

{ @Override public IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { - GlProgram.Builder builder = loader.loadProgram(ctx, spec); + GlProgram.Builder builder = spec.loadProgram(ctx, spec.defines, loader); return new SingleProgram<>(factory.create(builder.name, builder.program)); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java new file mode 100644 index 000000000..66135e832 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java @@ -0,0 +1,21 @@ +package com.jozufozu.flywheel.backend.loading; + +import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.gl.shader.ShaderType; + +import net.minecraft.util.ResourceLocation; + +public class InstancedArraysTemplate extends ProgramTemplate { + public static final String[] requiredVert = {"FLWInstanceData", "FLWVertexData", "FLWFragment"}; + public static final String[] requiredFrag = {"FLWFragment"}; + + public static final ResourceLocation vert = new ResourceLocation("create", "template/instanced/instanced.vert"); + public static final ResourceLocation frag = new ResourceLocation("create", "template/instanced/instanced.frag"); + + public InstancedArraysTemplate(ShaderLoader loader) { + super(loader); + + templates.put(ShaderType.VERTEX, new ShaderTemplate(requiredVert, loader.getShaderSource(vert))); + templates.put(ShaderType.FRAGMENT, new ShaderTemplate(requiredFrag, loader.getShaderSource(frag))); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java index aa76253a1..a1f050cc5 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java @@ -5,17 +5,20 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import net.minecraft.util.ResourceLocation; + public class ParsedShader { private static final Pattern decorator = Pattern.compile("#\\[([\\w_]*)]"); private static final Pattern taggedStruct = Pattern.compile("#\\[([\\w_]*)]\\s*struct\\s+([\\w\\d_]*)\\s*\\{(\\s*(?:.*;\\s*\\n)+\\s*)}\\s*;"); + final ResourceLocation loc; final String src; final Map tag2Struct = new HashMap<>(); final Map name2Struct = new HashMap<>(); - public ParsedShader(String src) { - + public ParsedShader(ResourceLocation loc, String src) { + this.loc = loc; Matcher structs = taggedStruct.matcher(src); StringBuffer strippedSrc = new StringBuffer(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ProcessingStage.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ProcessingStage.java new file mode 100644 index 000000000..df4d44ba6 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ProcessingStage.java @@ -0,0 +1,7 @@ +package com.jozufozu.flywheel.backend.loading; + +@FunctionalInterface +public interface ProcessingStage { + + void process(Shader shader); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ProgramTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ProgramTemplate.java new file mode 100644 index 000000000..ea9378607 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ProgramTemplate.java @@ -0,0 +1,28 @@ +package com.jozufozu.flywheel.backend.loading; + +import java.util.EnumMap; +import java.util.Map; + +import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.gl.shader.ShaderType; + +public class ProgramTemplate implements ProcessingStage { + + protected final ShaderLoader loader; + protected Map templates = new EnumMap<>(ShaderType.class); + + public ProgramTemplate(ShaderLoader loader) { + this.loader = loader; + } + + @Override + public void process(Shader shader) { + ShaderTemplate template = templates.get(shader.type); + + if (template == null) return; + + ParsedShader parsedShader = new ParsedShader(shader.name, shader.getSource()); + + shader.setSource(template.apply(parsedShader)); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java b/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java new file mode 100644 index 000000000..769e1ab5a --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java @@ -0,0 +1,33 @@ +package com.jozufozu.flywheel.backend.loading; + +import com.jozufozu.flywheel.backend.gl.shader.ShaderType; + +import net.minecraft.util.ResourceLocation; + +public class Shader { + public ShaderType type; + public ResourceLocation name; + private String source; + + public Shader(ShaderType type, ResourceLocation name, String source) { + this.type = type; + this.name = name; + this.setSource(source); + } + + public static Shader vert(ResourceLocation fileLoc, String source) { + return new Shader(ShaderType.VERTEX, fileLoc, source); + } + + public static Shader frag(ResourceLocation fileLoc, String source) { + return new Shader(ShaderType.FRAGMENT, fileLoc, source); + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysShaderTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTemplate.java similarity index 71% rename from src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysShaderTemplate.java rename to src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTemplate.java index ce6eb5db2..cee98d09e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysShaderTemplate.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTemplate.java @@ -1,22 +1,26 @@ package com.jozufozu.flywheel.backend.loading; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -public class InstancedArraysShaderTemplate { +public class ShaderTemplate { private static final String delimiter = "#flwbeginbody"; private static final Pattern headerFinder = Pattern.compile(delimiter); - private static final Pattern prefixer = Pattern.compile("#FLWPrefixFields\\((\\S+),\\s*([^\\n]+)\\)"); + private static final Pattern prefixer = Pattern.compile("#FLWPrefixFields\\((\\w+),\\s*(\\w+),\\s*([\\w\\d]+)\\)"); private static final Pattern assigner = Pattern.compile("#FLWAssignFields\\(([\\w\\d_]+),\\s*([\\w\\d_.]+),\\s*([\\w\\d_.]+)\\)"); - public static final String[] required = {"FLWInstanceData", "FLWVertexData", "FLWFragment"}; + final String[] requiredStructs; final String header; final String body; - public InstancedArraysShaderTemplate(String templateSrc) { + public ShaderTemplate(String[] requiredStructs, String templateSrc) { + this.requiredStructs = requiredStructs; Matcher matcher = headerFinder.matcher(templateSrc); if (!matcher.find()) { @@ -38,10 +42,21 @@ public class InstancedArraysShaderTemplate { public String processBody(ParsedShader shader) { String s = body; - for (String name : required) { + List missing = new ArrayList<>(); + + for (String name : requiredStructs) { TaggedStruct struct = shader.getTag(name); - s = s.replace(name, struct.name); + if (struct != null) { + s = s.replace(name, struct.name); + } else { + missing.add(name); + } + } + + if (!missing.isEmpty()) { + String err = shader.loc + " is missing: " + String.join(", ", missing); + throw new RuntimeException(err); } s = fillPrefixes(shader, s); @@ -56,14 +71,19 @@ public class InstancedArraysShaderTemplate { StringBuffer out = new StringBuffer(); while (prefixMatches.find()) { String structName = prefixMatches.group(1); - String prefix = prefixMatches.group(2); + String modifier = prefixMatches.group(2); + String prefix = prefixMatches.group(3); TaggedStruct struct = shader.getStruct(structName); StringBuilder builder = new StringBuilder(); - for (String field : struct.fields.keySet()) { + for (Map.Entry field : struct.fields.entrySet()) { + builder.append(modifier); + builder.append(' '); + builder.append(field.getValue()); + builder.append(' '); builder.append(prefix); - builder.append(field); + builder.append(field.getKey()); builder.append(";\n"); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTransformer.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTransformer.java new file mode 100644 index 000000000..ddd50c601 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTransformer.java @@ -0,0 +1,33 @@ +package com.jozufozu.flywheel.backend.loading; + +import java.util.LinkedList; + +public class ShaderTransformer { + + private final LinkedList stages = new LinkedList<>(); + + public ShaderTransformer() { + } + + public ShaderTransformer pushStage(ProcessingStage stage) { + if (stage != null) { + stages.addLast(stage); + } + return this; + } + + public ShaderTransformer prependStage(ProcessingStage stage) { + if (stage != null) { + stages.addFirst(stage); + } + return this; + } + + public void transformSource(Shader shader) { + + for (ProcessingStage stage : this.stages) { + stage.process(shader); + } + } + +} diff --git a/src/main/resources/assets/create/flywheel/shaders/block_new.frag b/src/main/resources/assets/create/flywheel/shaders/block_new.frag index 11ed8ac31..0319b49c8 100644 --- a/src/main/resources/assets/create/flywheel/shaders/block_new.frag +++ b/src/main/resources/assets/create/flywheel/shaders/block_new.frag @@ -1,5 +1,3 @@ -#version 110 - #flwbuiltins #[FLWFragment] diff --git a/src/main/resources/assets/create/flywheel/shaders/model_new.vert b/src/main/resources/assets/create/flywheel/shaders/model_new.vert index 29df494d8..7051e3063 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model_new.vert +++ b/src/main/resources/assets/create/flywheel/shaders/model_new.vert @@ -29,12 +29,11 @@ Raster FLWMain(Vertex v, Instance i) { vec4 worldPos = i.transform * vec4(v.pos, 1.); vec3 norm = i.normalMat * v.normal; + norm = normalize(norm); FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); - norm = normalize(norm); - Raster r; r.diffuse = diffuse(norm); r.texCoords = v.texCoords; diff --git a/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.frag b/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.frag deleted file mode 100644 index fde45d306..000000000 --- a/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 110 - -#flwbeginbody - -#FLWPrefixFields(FLWFragment, varying __v2f_) - -void main() { - FLWFragment f; - #FLWAssignFields(FLWFragment, f., __v2f_) - - FLWMain(f); -} diff --git a/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert b/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert deleted file mode 100644 index b364babd7..000000000 --- a/src/main/resources/assets/create/flywheel/shaders/skeleton/instanced/instanced.vert +++ /dev/null @@ -1,19 +0,0 @@ -#version 110 - -#flwbeginbody -#FLWPrefixFields(FLWVertexData, attribute __a_) -#FLWPrefixFields(FLWInstanceData, attribute __a_) - -#FLWPrefixFields(FLWFragment, varying __v2f_) - -void main() { - FLWVertexData v; - #FLWAssignFields(FLWVertexData, v., __a_) - - FLWInstanceData i; - #FLWAssignFields(FLWInstanceData, i., __a_) - - FLWFragment o = FLWMain(v, i); - - #FLWAssignFields(FLWFragment, __v2f_, o.) -} diff --git a/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag b/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag new file mode 100644 index 000000000..c8cc0eefa --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag @@ -0,0 +1,12 @@ +#version 110 + +#flwbeginbody + +#FLWPrefixFields(FLWFragment, varying, v2f_) + +void main() { + FLWFragment f; + #FLWAssignFields(FLWFragment, f., v2f_) + + FLWMain(f); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert b/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert new file mode 100644 index 000000000..85b415465 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert @@ -0,0 +1,19 @@ +#version 110 + +#flwbeginbody +#FLWPrefixFields(FLWVertexData, attribute, a_v_) +#FLWPrefixFields(FLWInstanceData, attribute, a_i_) + +#FLWPrefixFields(FLWFragment, varying, v2f_) + +void main() { + FLWVertexData v; + #FLWAssignFields(FLWVertexData, v., a_v_) + + FLWInstanceData i; + #FLWAssignFields(FLWInstanceData, i., a_i_) + + FLWFragment o = FLWMain(v, i); + + #FLWAssignFields(FLWFragment, v2f_, o.) +} diff --git a/src/main/resources/assets/create/flywheel/shaders/skeleton/meshlet/meshlet.glsl b/src/main/resources/assets/create/flywheel/shaders/template/meshlet/meshlet.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/skeleton/meshlet/meshlet.glsl rename to src/main/resources/assets/create/flywheel/shaders/template/meshlet/meshlet.glsl From 7abc8608099698e8227d05ef3cd710704dcc6649 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 13 May 2021 11:37:04 -0700 Subject: [PATCH 050/198] Fix fluid rendering in tanks and pipes on fabulous graphics --- .../foundation/fluid/FluidRenderer.java | 53 ++++++++++++++----- .../render/CreateFlywheelHandler.java | 2 + 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java index 23d8a0624..540c4ffee 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java @@ -11,9 +11,11 @@ import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.MatrixStacker; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.world.ClientWorld; import net.minecraft.fluid.Fluid; import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.util.Direction; @@ -21,6 +23,7 @@ import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3i; import net.minecraftforge.fluids.FluidAttributes; @@ -28,17 +31,41 @@ import net.minecraftforge.fluids.FluidStack; public class FluidRenderer { + // If we draw to BufferBuilder that minecraft provides for RenderType.getTranslucent(), minecraft draws the contents + // to the wrong framebuffer. If we tried to inject a custom RenderType into RenderTypeBuffers, we'd have the same + // issue. This is because minecraft calls IRenderTypeBuffer.Impl::draw just before clearing the transparency + // framebuffer, so anything we put into the normal RenderTypeBuffers will never be seen. By using our own + // BufferBuilder, we can avoid getting our contents wiped. Then, using Flywheel's renderLayer hook, we can draw our + // buffer at the same time the transparent world layer is drawn. + private static final BufferBuilder _builder = new BufferBuilder(RenderType.getTranslucent().getExpectedBufferSize()); + + private static BufferBuilder getBuilder() { + if (!_builder.isBuilding()) { + RenderType type = RenderType.getTranslucent(); + + _builder.begin(type.getDrawMode(), type.getVertexFormat()); + } + + return _builder; + } + + public static void renderLayer(ClientWorld world, RenderType type, Matrix4f viewProjection, double camX, double camY, double camZ) { + if (type == RenderType.getTranslucent()) { + type.draw(_builder, 0, 0, 0); + } + } + public static void renderFluidStream(FluidStack fluidStack, Direction direction, float radius, float progress, - boolean inbound, IRenderTypeBuffer buffer, MatrixStack ms, int light) { + boolean inbound, IRenderTypeBuffer buffer, MatrixStack ms, int light) { Fluid fluid = fluidStack.getFluid(); FluidAttributes fluidAttributes = fluid.getAttributes(); Function spriteAtlas = Minecraft.getInstance() - .getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE); + .getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE); TextureAtlasSprite flowTexture = spriteAtlas.apply(fluidAttributes.getFlowingTexture(fluidStack)); TextureAtlasSprite stillTexture = spriteAtlas.apply(fluidAttributes.getStillTexture(fluidStack)); int color = fluidAttributes.getColor(fluidStack); - IVertexBuilder builder = buffer.getBuffer(RenderType.getTranslucent()); + IVertexBuilder builder = getBuilder(); MatrixStacker msr = MatrixStacker.of(ms); int blockLightIn = (light >> 4) & 0xf; int luminosity = Math.max(blockLightIn, fluidAttributes.getLuminosity(fluidStack)); @@ -82,11 +109,11 @@ public class FluidRenderer { Fluid fluid = fluidStack.getFluid(); FluidAttributes fluidAttributes = fluid.getAttributes(); TextureAtlasSprite fluidTexture = Minecraft.getInstance() - .getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE) - .apply(fluidAttributes.getStillTexture(fluidStack)); + .getSpriteAtlas(PlayerContainer.BLOCK_ATLAS_TEXTURE) + .apply(fluidAttributes.getStillTexture(fluidStack)); int color = fluidAttributes.getColor(fluidStack); - IVertexBuilder builder = buffer.getBuffer(RenderType.getTranslucent()); + IVertexBuilder builder = getBuilder(); MatrixStacker msr = MatrixStacker.of(ms); Vector3d center = new Vector3d(xMin + (xMax - xMin) / 2, yMin + (yMax - yMin) / 2, zMin + (zMax - zMin) / 2); @@ -96,7 +123,7 @@ public class FluidRenderer { ms.push(); if (fluidStack.getFluid() - .getAttributes() + .getAttributes() .isLighterThanAir()) MatrixStacker.of(ms) .translate(center) @@ -113,20 +140,20 @@ public class FluidRenderer { if (side.getAxisDirection() == AxisDirection.NEGATIVE) msr.translate(center) - .rotateY(180) - .translateBack(center); + .rotateY(180) + .translateBack(center); boolean X = side.getAxis() == Axis.X; int darkColor = ColorHelper.mixColors(color, 0xff000011, 1 / 4f); - renderTiledHorizontalFace(X ? xMax : zMax, side, X ? zMin : xMin, yMin, X ? zMax : xMax, yMax, builder, - ms, light, darkColor, fluidTexture); + renderTiledHorizontalFace(X ? xMax : zMax, side, X ? zMin : xMin, yMin, X ? zMax : xMax, yMax, _builder, + ms, light, darkColor, fluidTexture); ms.pop(); continue; } - renderTiledVerticalFace(side == Direction.UP ? yMax : yMin, side, xMin, zMin, xMax, zMax, builder, ms, - light, color, fluidTexture); + renderTiledVerticalFace(side == Direction.UP ? yMax : yMin, side, xMin, zMin, xMax, zMax, _builder, ms, + light, color, fluidTexture); } ms.pop(); diff --git a/src/main/java/com/simibubi/create/foundation/render/CreateFlywheelHandler.java b/src/main/java/com/simibubi/create/foundation/render/CreateFlywheelHandler.java index d50697529..7f3d4a05f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/CreateFlywheelHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/CreateFlywheelHandler.java @@ -3,6 +3,7 @@ package com.simibubi.create.foundation.render; import com.jozufozu.flywheel.backend.Backend; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; +import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.render.effects.EffectsContext; public class CreateFlywheelHandler { @@ -10,6 +11,7 @@ public class CreateFlywheelHandler { Backend.register(ContraptionContext.INSTANCE); Backend.register(EffectsContext.INSTANCE); Backend.listeners.renderLayerListener(ContraptionRenderDispatcher::renderLayer); + Backend.listeners.renderLayerListener(FluidRenderer::renderLayer); Backend.listeners.setupFrameListener(ContraptionRenderDispatcher::beginFrame); Backend.listeners.refreshListener($ -> ContraptionRenderDispatcher.invalidateAll()); } From 6c1c7a10d9b4f8fea3367bda122c637b99949972 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Fri, 14 May 2021 16:34:35 -0700 Subject: [PATCH 051/198] Fix darker contraptions Also - Partially fix incorrect vertex lighting (make sure to not sure Forge's lighting calculator) - Reorder some lighting to make it more efficient - Cleanup some things --- .../render/ContraptionModel.java | 2 +- .../render/RenderedContraption.java | 42 ++++++++----------- .../PlacementSimulationWorld.java | 30 ++++++++----- .../shaders/context/contraption/builtin.frag | 2 +- .../shaders/contraption_structure.vert | 8 ++-- 5 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java index 1b1343135..ed102f26b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java @@ -87,8 +87,8 @@ public class ContraptionModel extends BufferedModel { int light = getLight(template, vertex); - byte sky = (byte) (LightTexture.getSkyLightCoordinates(light) << 4); byte block = (byte) (LightTexture.getBlockLightCoordinates(light) << 4); + byte sky = (byte) (LightTexture.getSkyLightCoordinates(light) << 4); to.put(block); to.put(sky); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index b7db073c9..6dd2d59c0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.re import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Random; import org.lwjgl.opengl.GL11; @@ -22,11 +23,10 @@ import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.BlockModelRenderer; -import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.BufferBuilder; 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.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.tileentity.TileEntity; @@ -36,20 +36,19 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.world.World; import net.minecraft.world.gen.feature.template.Template; -import net.minecraft.world.lighting.WorldLightManager; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.model.data.EmptyModelData; public class RenderedContraption { - private final HashMap renderLayers = new HashMap<>(); - - public final PlacementSimulationWorld renderWorld; - - private final ContraptionLighter lighter; - - public final ContraptionKineticRenderer kinetics; + private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); + private static final BlockModelShapes BLOCK_MODELS = Minecraft.getInstance().getModelManager().getBlockModelShapes(); public Contraption contraption; + private final ContraptionLighter lighter; + public final ContraptionKineticRenderer kinetics; + public final PlacementSimulationWorld renderWorld; + + private final Map renderLayers = new HashMap<>(); private Matrix4f model; private AxisAlignedBB lightBox; @@ -178,42 +177,37 @@ public class RenderedContraption { .values()) renderWorld.setBlockState(info.pos, info.state); - WorldLightManager lighter = renderWorld.lighter; - - renderWorld.chunkProvider.getLightSources().forEach((pos) -> lighter.func_215573_a(pos, renderWorld.getLightValue(pos))); - - lighter.tick(Integer.MAX_VALUE, true, false); + renderWorld.lighter.tick(Integer.MAX_VALUE, false, false); return renderWorld; } private static BufferBuilder buildStructure(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { - ForgeHooksClient.setRenderLayer(layer); MatrixStack ms = new MatrixStack(); - BlockRendererDispatcher dispatcher = Minecraft.getInstance() - .getBlockRendererDispatcher(); - BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer(); Random random = new Random(); BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + BlockModelRenderer.enableCache(); for (Template.BlockInfo info : c.getBlocks() .values()) { BlockState state = info.state; - if (state.getRenderType() == BlockRenderType.ENTITYBLOCK_ANIMATED) + if (state.getRenderType() != BlockRenderType.MODEL) continue; if (!RenderTypeLookup.canRenderInLayer(state, layer)) continue; - IBakedModel originalModel = dispatcher.getModelForState(state); + BlockPos pos = info.pos; + ms.push(); - ms.translate(info.pos.getX(), info.pos.getY(), info.pos.getZ()); - blockRenderer.renderModel(renderWorld, originalModel, state, info.pos, ms, builder, true, random, 42, - OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); + ms.translate(pos.getX(), pos.getY(), pos.getZ()); + MODEL_RENDERER.renderModel(renderWorld, BLOCK_MODELS.getModel(state), state, pos, ms, builder, true, + random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); ms.pop(); } + BlockModelRenderer.disableCache(); builder.finishDrawing(); return builder; diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java index ae127670b..b6c768810 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java @@ -3,6 +3,8 @@ package com.simibubi.create.foundation.utility.worldWrappers; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.Map; +import java.util.Set; import java.util.function.Predicate; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; @@ -16,10 +18,10 @@ import net.minecraft.world.World; import net.minecraft.world.lighting.WorldLightManager; public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelWorld { - public HashMap blocksAdded; - public HashMap tesAdded; + public Map blocksAdded; + public Map tesAdded; - public HashSet spannedChunks; + public Set spannedSections; public WorldLightManager lighter; public WrappedChunkProvider chunkProvider; private final BlockPos.Mutable scratch = new BlockPos.Mutable(); @@ -31,7 +33,7 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW public PlacementSimulationWorld(World wrapped, WrappedChunkProvider chunkProvider) { super(wrapped, chunkProvider); this.chunkProvider = chunkProvider.setWorld(this); - spannedChunks = new HashSet<>(); + spannedSections = new HashSet<>(); lighter = new WorldLightManager(chunkProvider, true, false); // blockLight, skyLight blocksAdded = new HashMap<>(); tesAdded = new HashMap<>(); @@ -42,6 +44,17 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW return lighter; } + public void updateLightSources() { + for (Map.Entry entry : blocksAdded.entrySet()) { + BlockPos pos = entry.getKey(); + BlockState state = entry.getValue(); + int light = state.getLightValue(this, pos); + if (light > 0) { + lighter.func_215573_a(pos, light); + } + } + } + public void setTileEntities(Collection tileEntities) { tesAdded.clear(); tileEntities.forEach(te -> tesAdded.put(te.getPos(), te)); @@ -53,16 +66,15 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW @Override public boolean setBlockState(BlockPos pos, BlockState newState, int flags) { + blocksAdded.put(pos, newState); SectionPos sectionPos = SectionPos.from(pos); - - if (spannedChunks.add(sectionPos)) { + if (spannedSections.add(sectionPos)) { lighter.updateSectionStatus(sectionPos, false); } lighter.checkBlock(pos); - blocksAdded.put(pos, newState); return true; } @@ -100,8 +112,6 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW BlockState state = blocksAdded.get(pos); if (state != null) return state; - else - return Blocks.AIR.getDefaultState(); + return Blocks.AIR.getDefaultState(); } - } diff --git a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag index c7463793f..8f43ae7f6 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag @@ -24,5 +24,5 @@ void FLWFinalizeColor(vec4 color) { vec4 FLWLight(vec2 lightCoords) { vec2 lm = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg); - return texture2D(uLightMap, lm * 0.9375 + 0.03125); + return texture2D(uLightMap, lm * 0.99609375 + 0.03125); // * 255/256 + 1/32 } diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert index 8cec957bc..e3bc37b5a 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert @@ -24,11 +24,11 @@ void main() { FLWFinalizeNormal(norm); Diffuse = diffuse(norm); - Color = aColor / diffuse(norm); - TexCoords = aTexCoords; - Light = aModelLight; - if (uDebug == 2) { Color = vec4(norm, 1.); + } else { + Color = aColor / diffuse(aNormal); } + TexCoords = aTexCoords; + Light = aModelLight; } From dac9010f20fd89452cc6f08e9bc453d50eb66ef4 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Fri, 14 May 2021 17:23:10 -0700 Subject: [PATCH 052/198] Optimize lighting checks Also - Set null layer after rendering contraption --- .../structureMovement/render/RenderedContraption.java | 7 +++++-- .../utility/worldWrappers/PlacementSimulationWorld.java | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index 6dd2d59c0..d847b9cd8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -175,20 +175,22 @@ public class RenderedContraption { for (Template.BlockInfo info : c.getBlocks() .values()) - renderWorld.setBlockState(info.pos, info.state); + // Skip individual lighting updates to prevent lag with large contraptions + renderWorld.setBlockState(info.pos, info.state, 128); + renderWorld.updateLightSources(); renderWorld.lighter.tick(Integer.MAX_VALUE, false, false); return renderWorld; } private static BufferBuilder buildStructure(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { - ForgeHooksClient.setRenderLayer(layer); MatrixStack ms = new MatrixStack(); Random random = new Random(); BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + ForgeHooksClient.setRenderLayer(layer); BlockModelRenderer.enableCache(); for (Template.BlockInfo info : c.getBlocks() .values()) { @@ -208,6 +210,7 @@ public class RenderedContraption { ms.pop(); } BlockModelRenderer.disableCache(); + ForgeHooksClient.setRenderLayer(null); builder.finishDrawing(); return builder; diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java index b6c768810..733b8fd60 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java @@ -73,7 +73,9 @@ public class PlacementSimulationWorld extends WrappedWorld implements IFlywheelW lighter.updateSectionStatus(sectionPos, false); } - lighter.checkBlock(pos); + if ((flags & 128) == 0) { + lighter.checkBlock(pos); + } return true; } From a9cdb1ab6b804bb4b0adcb44ec643874ec4277ab Mon Sep 17 00:00:00 2001 From: JozsefA Date: Fri, 14 May 2021 18:04:25 -0700 Subject: [PATCH 053/198] Begin buffer rework --- .../flywheel/backend/BufferedModel.java | 22 ++--- .../flywheel/backend/core/BasicProgram.java | 24 ++++-- .../backend/core/materials/BasicData.java | 7 +- .../backend/core/materials/ModelData.java | 8 +- .../backend/core/materials/OrientedData.java | 9 +- .../flywheel/backend/gl/GlBuffer.java | 58 +++++-------- .../flywheel/backend/gl/GlBufferType.java | 32 +++++++ .../flywheel/backend/gl/GlBufferUsage.java | 22 +++++ .../flywheel/backend/gl/GlVertexArray.java | 8 -- .../flywheel/backend/gl/MappedBuffer.java | 84 +++++++++++++++++++ .../backend/gl/MappedBufferRange.java | 31 +++++++ .../backend/gl/versioned/MapBuffer.java | 41 ++++++--- .../backend/instancing/InstanceData.java | 40 +-------- .../backend/instancing/InstancedModel.java | 53 ++++++------ .../instancing/InstancedTileRenderer.java | 3 +- .../backend/instancing/RenderMaterial.java | 24 +++--- .../contraptions/base/KineticData.java | 41 +++++---- .../contraptions/base/RotatingData.java | 29 ++++--- .../components/actors/ActorData.java | 39 +++++---- .../render/ContraptionModel.java | 63 +++++++------- .../render/ContraptionRenderDispatcher.java | 61 ++++++++------ .../contraptions/relays/belt/BeltData.java | 35 ++++---- .../content/logistics/block/FlapData.java | 21 +++-- .../render/effects/EffectsHandler.java | 11 ++- .../render/effects/FilterSphere.java | 9 +- .../render/effects/SphereFilterProgram.java | 26 +++--- .../create/flywheel/shaders/block_new.frag | 2 +- .../assets/create/flywheel/shaders/model.vert | 1 - .../create/flywheel/shaders/model_new.vert | 10 ++- .../shaders/template/instanced/instanced.frag | 6 +- .../shaders/template/instanced/instanced.vert | 18 ++-- 31 files changed, 487 insertions(+), 351 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferType.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferUsage.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/MappedBuffer.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/MappedBufferRange.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java b/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java index ae076ea0b..d23d9fdd7 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java @@ -1,11 +1,11 @@ package com.jozufozu.flywheel.backend; -import java.nio.ByteBuffer; - import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.GlBufferType; +import com.jozufozu.flywheel.backend.gl.MappedBufferRange; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.simibubi.create.foundation.render.TemplateBuffer; @@ -23,9 +23,11 @@ public abstract class BufferedModel extends TemplateBuffer { protected void init() { - modelVBO = new GlBuffer(GL20.GL_ARRAY_BUFFER); + modelVBO = new GlBuffer(GlBufferType.ARRAY_BUFFER); - modelVBO.with(vbo -> initModel()); + modelVBO.bind(); + initModel(); + modelVBO.unbind(); } protected void initModel() { @@ -36,14 +38,14 @@ public abstract class BufferedModel extends TemplateBuffer { GL15.glBufferData(GL15.GL_ARRAY_BUFFER, invariantSize, GL15.GL_STATIC_DRAW); // mirror it in system memory so we can write to it - modelVBO.map(invariantSize, buffer -> { - for (int i = 0; i < vertexCount; i++) { - copyVertex(buffer, i); - } - }); + MappedBufferRange buffer = modelVBO.getBuffer(0, invariantSize); + for (int i = 0; i < vertexCount; i++) { + copyVertex(buffer, i); + } + buffer.unmap(); } - protected abstract void copyVertex(ByteBuffer to, int index); + protected abstract void copyVertex(MappedBufferRange to, int index); protected abstract VertexFormat getModelFormat(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java index 829e2eaf2..5d61e5924 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java @@ -1,7 +1,6 @@ package com.jozufozu.flywheel.backend.core; import static org.lwjgl.opengl.GL20.glUniform1f; -import static org.lwjgl.opengl.GL20.glUniform1i; import static org.lwjgl.opengl.GL20.glUniform3f; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; @@ -14,7 +13,6 @@ import net.minecraft.util.math.vector.Matrix4f; public class BasicProgram extends GlProgram { protected final int uTime; protected final int uViewProjection; - protected final int uDebug; protected final int uCameraPos; protected final ProgramFogMode fogMode; @@ -30,7 +28,6 @@ public class BasicProgram extends GlProgram { super(name, handle); uTime = getUniformLocation("uTime"); uViewProjection = getUniformLocation("uViewProjection"); - uDebug = getUniformLocation("uDebug"); uCameraPos = getUniformLocation("uCameraPos"); fogMode = fogFactory.create(this); @@ -45,14 +42,23 @@ public class BasicProgram extends GlProgram { uLightMap = setSamplerBinding("uLightMap", 2); } - public void bind(Matrix4f viewProjection, double camX, double camY, double camZ, int debugMode) { + public void uploadViewProjection(Matrix4f viewProjection) { + uploadMatrixUniform(uViewProjection, viewProjection); + } + + public void uploadCameraPos(double camX, double camY, double camZ) { + glUniform3f(uCameraPos, (float) camX, (float) camY, (float) camZ); + } + + public void uploadTime(float renderTime) { + glUniform1f(uTime, renderTime); + } + + @Override + public void bind() { super.bind(); - glUniform1i(uDebug, debugMode); - glUniform1f(uTime, AnimationTickHolder.getRenderTime()); - - uploadMatrixUniform(uViewProjection, viewProjection); - glUniform3f(uCameraPos, (float) camX, (float) camY, (float) camZ); + uploadTime(AnimationTickHolder.getRenderTime()); fogMode.bind(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java index 3759ba6e2..8900db4e1 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java @@ -1,7 +1,6 @@ package com.jozufozu.flywheel.backend.core.materials; -import java.nio.ByteBuffer; - +import com.jozufozu.flywheel.backend.gl.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; @@ -72,7 +71,7 @@ public class BasicData extends InstanceData implements IFlatLight { } @Override - public void write(ByteBuffer buf) { - buf.put(new byte[]{blockLight, skyLight, r, g, b, a}); + public void write(MappedBuffer buf) { + buf.putByteArray(new byte[]{blockLight, skyLight, r, g, b, a}); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java index d8e711bf7..42e9afbfb 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java @@ -1,7 +1,6 @@ package com.jozufozu.flywheel.backend.core.materials; -import java.nio.ByteBuffer; - +import com.jozufozu.flywheel.backend.gl.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.util.RenderUtil; import com.mojang.blaze3d.matrix.MatrixStack; @@ -22,9 +21,8 @@ public class ModelData extends BasicData { } @Override - public void write(ByteBuffer buf) { + public void write(MappedBuffer buf) { super.write(buf); - buf.asFloatBuffer().put(matrices); - buf.position(buf.position() + matrices.length * 4); + buf.putFloatArray(matrices); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java index a7f30a96c..187e4f3c2 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java @@ -1,7 +1,6 @@ package com.jozufozu.flywheel.backend.core.materials; -import java.nio.ByteBuffer; - +import com.jozufozu.flywheel.backend.gl.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import net.minecraft.util.math.BlockPos; @@ -82,10 +81,10 @@ public class OrientedData extends BasicData { } @Override - public void write(ByteBuffer buf) { + public void write(MappedBuffer buf) { super.write(buf); - buf.asFloatBuffer().put(new float[]{ + buf.putFloatArray(new float[]{ posX, posY, posZ, @@ -97,8 +96,6 @@ public class OrientedData extends BasicData { qZ, qW }); - - buf.position(buf.position() + 10 * 4); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java index 7a70c600d..6ded39c5d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java @@ -1,62 +1,50 @@ package com.jozufozu.flywheel.backend.gl; -import java.nio.ByteBuffer; -import java.util.function.Consumer; - import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; - -import com.jozufozu.flywheel.backend.Backend; +import org.lwjgl.opengl.GL30; public class GlBuffer extends GlObject { - protected final int bufferType; + protected final GlBufferType type; + protected final GlBufferUsage usage; - public GlBuffer(int bufferType) { - setHandle(GL20.glGenBuffers()); - this.bufferType = bufferType; + public GlBuffer(GlBufferType type) { + this(type, GlBufferUsage.STATIC_DRAW); } - public int getBufferType() { - return bufferType; + public GlBuffer(GlBufferType type, GlBufferUsage usage) { + setHandle(GL20.glGenBuffers()); + this.type = type; + this.usage = usage; + } + + public GlBufferType getBufferTarget() { + return type; } public void bind() { - bind(bufferType); + bind(type); } - public void bind(int type) { - GL20.glBindBuffer(type, handle()); + public void bind(GlBufferType type) { + GL20.glBindBuffer(type.glEnum, handle()); } public void unbind() { - unbind(bufferType); + unbind(type); } - public void unbind(int bufferType) { - GL20.glBindBuffer(bufferType, 0); + public void unbind(GlBufferType bufferType) { + GL20.glBindBuffer(bufferType.glEnum, 0); } - public void alloc(int size, int usage) { - GL15.glBufferData(bufferType, size, usage); + public void alloc(int size) { + GL15.glBufferData(type.glEnum, size, usage.glEnum); } - public void with(Consumer action) { - bind(); - action.accept(this); - unbind(); - } - - public void map(int length, Consumer upload) { - Backend.compat.mapBuffer.mapBuffer(bufferType, 0, length, upload); - } - - public void map(int offset, int length, Consumer upload) { - Backend.compat.mapBuffer.mapBuffer(bufferType, offset, length, upload); - } - - public void map(int type, int offset, int length, Consumer upload) { - Backend.compat.mapBuffer.mapBuffer(type, offset, length, upload); + public MappedBufferRange getBuffer(int offset, int length) { + return MappedBufferRange.create(this, offset, length, GL30.GL_MAP_WRITE_BIT); } protected void deleteInternal(int handle) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferType.java new file mode 100644 index 000000000..f64caa6c3 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferType.java @@ -0,0 +1,32 @@ +package com.jozufozu.flywheel.backend.gl; + +import org.lwjgl.opengl.GL15C; +import org.lwjgl.opengl.GL21; +import org.lwjgl.opengl.GL30; +import org.lwjgl.opengl.GL31; +import org.lwjgl.opengl.GL40; +import org.lwjgl.opengl.GL42; +import org.lwjgl.opengl.GL43; + +public enum GlBufferType { + ARRAY_BUFFER(GL15C.GL_ARRAY_BUFFER), + ELEMENT_ARRAY_BUFFER(GL15C.GL_ELEMENT_ARRAY_BUFFER), + PIXEL_PACK_BUFFER(GL21.GL_PIXEL_PACK_BUFFER), + PIXEL_UNPACK_BUFFER(GL21.GL_PIXEL_UNPACK_BUFFER), + TRANSFORM_FEEDBACK_BUFFER(GL30.GL_TRANSFORM_FEEDBACK_BUFFER), + UNIFORM_BUFFER(GL31.GL_UNIFORM_BUFFER), + TEXTURE_BUFFER(GL31.GL_TEXTURE_BUFFER), + COPY_READ_BUFFER(GL31.GL_COPY_READ_BUFFER), + COPY_WRITE_BUFFER(GL31.GL_COPY_WRITE_BUFFER), + DRAW_INDIRECT_BUFFER(GL40.GL_DRAW_INDIRECT_BUFFER), + ATOMIC_COUNTER_BUFFER(GL42.GL_ATOMIC_COUNTER_BUFFER), + DISPATCH_INDIRECT_BUFFER(GL43.GL_DISPATCH_INDIRECT_BUFFER), + SHADER_STORAGE_BUFFER(GL43.GL_SHADER_STORAGE_BUFFER), + ; + + public final int glEnum; + + GlBufferType(int glEnum) { + this.glEnum = glEnum; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferUsage.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferUsage.java new file mode 100644 index 000000000..a2f69461c --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferUsage.java @@ -0,0 +1,22 @@ +package com.jozufozu.flywheel.backend.gl; + +import org.lwjgl.opengl.GL15; + +public enum GlBufferUsage { + STREAM_DRAW(GL15.GL_STREAM_DRAW), + STREAM_READ(GL15.GL_STREAM_READ), + STREAM_COPY(GL15.GL_STREAM_COPY), + STATIC_DRAW(GL15.GL_STATIC_DRAW), + STATIC_READ(GL15.GL_STATIC_READ), + STATIC_COPY(GL15.GL_STATIC_COPY), + DYNAMIC_DRAW(GL15.GL_DYNAMIC_DRAW), + DYNAMIC_READ(GL15.GL_DYNAMIC_READ), + DYNAMIC_COPY(GL15.GL_DYNAMIC_COPY), + ; + + public final int glEnum; + + GlBufferUsage(int glEnum) { + this.glEnum = glEnum; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlVertexArray.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlVertexArray.java index 4cfb770d9..db7c45634 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/GlVertexArray.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlVertexArray.java @@ -1,7 +1,5 @@ package com.jozufozu.flywheel.backend.gl; -import java.util.function.Consumer; - import com.jozufozu.flywheel.backend.Backend; public class GlVertexArray extends GlObject { @@ -17,12 +15,6 @@ public class GlVertexArray extends GlObject { Backend.compat.vao.bindVertexArray(0); } - public void with(Consumer action) { - bind(); - action.accept(this); - unbind(); - } - protected void deleteInternal(int handle) { Backend.compat.vao.deleteVertexArrays(handle); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBuffer.java new file mode 100644 index 000000000..7c01fbf8e --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBuffer.java @@ -0,0 +1,84 @@ +package com.jozufozu.flywheel.backend.gl; + +import java.nio.ByteBuffer; + +public abstract class MappedBuffer implements AutoCloseable { + + private final ByteBuffer internal; + + public MappedBuffer(ByteBuffer internal) { + this.internal = internal; + } + + public MappedBuffer putFloatArray(float[] floats) { + internal.asFloatBuffer().put(floats); + internal.position(internal.position() + floats.length * 4); + + return this; + } + + public MappedBuffer putByteArray(byte[] bytes) { + internal.put(bytes); + + return this; + } + + public MappedBuffer position(int p) { + internal.position(p); + return this; + } + + public MappedBuffer putFloat(float f) { + internal.putFloat(f); + return this; + } + + public MappedBuffer putInt(int i) { + internal.putInt(i); + return this; + } + + public MappedBuffer put(byte b) { + internal.put(b); + return this; + } + + public MappedBuffer putVec4(float x, float y, float z, float w) { + internal.putFloat(x); + internal.putFloat(y); + internal.putFloat(z); + internal.putFloat(w); + + return this; + } + + public MappedBuffer putVec3(float x, float y, float z) { + internal.putFloat(x); + internal.putFloat(y); + internal.putFloat(z); + + return this; + } + + public MappedBuffer putVec2(float x, float y) { + internal.putFloat(x); + internal.putFloat(y); + + return this; + } + + public MappedBuffer putVec3(byte x, byte y, byte z) { + internal.put(x); + internal.put(y); + internal.put(z); + + return this; + } + + public MappedBuffer putVec2(byte x, byte y) { + internal.put(x); + internal.put(y); + + return this; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBufferRange.java b/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBufferRange.java new file mode 100644 index 000000000..6a28dfce6 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBufferRange.java @@ -0,0 +1,31 @@ +package com.jozufozu.flywheel.backend.gl; + +import java.nio.ByteBuffer; + +import org.lwjgl.opengl.GL30; + +public class MappedBufferRange extends MappedBuffer { + + GlBuffer owner; + + public MappedBufferRange(GlBuffer buffer, ByteBuffer internal) { + super(internal); + this.owner = buffer; + } + + public static MappedBufferRange create(GlBuffer buffer, long offset, long length, int access) { + ByteBuffer byteBuffer = GL30.glMapBufferRange(buffer.type.glEnum, offset, length, access); + + return new MappedBufferRange(buffer, byteBuffer); + } + + public MappedBuffer unmap() { + GL30.glUnmapBuffer(owner.type.glEnum); + return this; + } + + @Override + public void close() throws Exception { + unmap(); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java index 27636f949..db775f7e9 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java @@ -8,6 +8,8 @@ import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL30; import org.lwjgl.opengl.GLCapabilities; +import com.jozufozu.flywheel.backend.gl.GlBufferType; + public enum MapBuffer implements GlVersioned { GL30_RANGE { @@ -16,14 +18,18 @@ public enum MapBuffer implements GlVersioned { return caps.OpenGL30; } + public ByteBuffer mapBuffer(GlBufferType target, long offset, long length, int access) { + return GL30.glMapBufferRange(target.glEnum, offset, length, access); + } + @Override - public void mapBuffer(int target, int offset, int length, Consumer upload) { - ByteBuffer buffer = GL30.glMapBufferRange(target, offset, length, GL30.GL_MAP_WRITE_BIT); + public void mapBuffer(GlBufferType target, int offset, int length, Consumer upload) { + ByteBuffer buffer = mapBuffer(target, offset, length, GL30.GL_MAP_WRITE_BIT); upload.accept(buffer); buffer.rewind(); - GL30.glUnmapBuffer(target); + GL30.glUnmapBuffer(target.glEnum); } }, ARB_RANGE { @@ -32,14 +38,18 @@ public enum MapBuffer implements GlVersioned { return caps.GL_ARB_map_buffer_range; } + public ByteBuffer mapBuffer(GlBufferType target, long offset, long length, int access) { + return ARBMapBufferRange.glMapBufferRange(target.glEnum, offset, length, access); + } + @Override - public void mapBuffer(int target, int offset, int length, Consumer upload) { - ByteBuffer buffer = ARBMapBufferRange.glMapBufferRange(target, offset, length, GL30.GL_MAP_WRITE_BIT); + public void mapBuffer(GlBufferType target, int offset, int length, Consumer upload) { + ByteBuffer buffer = ARBMapBufferRange.glMapBufferRange(target.glEnum, offset, length, GL30.GL_MAP_WRITE_BIT); upload.accept(buffer); buffer.rewind(); - GL30.glUnmapBuffer(target); + GL30.glUnmapBuffer(target.glEnum); } }, GL15_MAP { @@ -49,13 +59,13 @@ public enum MapBuffer implements GlVersioned { } @Override - public void mapBuffer(int target, int offset, int length, Consumer upload) { - ByteBuffer buffer = GL15.glMapBuffer(target, GL15.GL_WRITE_ONLY); + public void mapBuffer(GlBufferType target, int offset, int length, Consumer upload) { + ByteBuffer buffer = GL15.glMapBuffer(target.glEnum, GL15.GL_WRITE_ONLY); buffer.position(offset); upload.accept(buffer); buffer.rewind(); - GL15.glUnmapBuffer(target); + GL15.glUnmapBuffer(target.glEnum); } }, UNSUPPORTED { @@ -65,11 +75,20 @@ public enum MapBuffer implements GlVersioned { } @Override - public void mapBuffer(int target, int offset, int length, Consumer upload) { + public void mapBuffer(GlBufferType target, int offset, int length, Consumer upload) { + throw new UnsupportedOperationException("glMapBuffer not supported"); + } + + @Override + public void unmapBuffer(int target) { throw new UnsupportedOperationException("glMapBuffer not supported"); } }; - public abstract void mapBuffer(int target, int offset, int length, Consumer upload); + public void unmapBuffer(int target) { + GL15.glUnmapBuffer(target); + } + + public abstract void mapBuffer(GlBufferType target, int offset, int length, Consumer upload); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java index 320432890..725e023f0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.backend.instancing; -import java.nio.ByteBuffer; +import com.jozufozu.flywheel.backend.gl.MappedBuffer; public abstract class InstanceData { @@ -13,7 +13,7 @@ public abstract class InstanceData { this.owner = owner; } - public abstract void write(ByteBuffer buf); + public abstract void write(MappedBuffer buf); public void markDirty() { owner.anyToUpdate = true; @@ -25,40 +25,4 @@ public abstract class InstanceData { removed = true; } - public void putVec4(ByteBuffer buf, float x, float y, float z, float w) { - put(buf, x); - put(buf, y); - put(buf, z); - put(buf, w); - } - - public void putVec3(ByteBuffer buf, float x, float y, float z) { - put(buf, x); - put(buf, y); - put(buf, z); - } - - public void putVec2(ByteBuffer buf, float x, float y) { - put(buf, x); - put(buf, y); - } - - public void putVec3(ByteBuffer buf, byte x, byte y, byte z) { - put(buf, x); - put(buf, y); - put(buf, z); - } - - public void putVec2(ByteBuffer buf, byte x, byte y) { - put(buf, x); - put(buf, y); - } - - public void put(ByteBuffer buf, byte b) { - buf.put(b); - } - - public void put(ByteBuffer buf, float f) { - buf.putFloat(f); - } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java index d58b20a16..0d6f970d4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java @@ -1,19 +1,18 @@ package com.jozufozu.flywheel.backend.instancing; -import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.BitSet; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL15; -import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.BufferedModel; import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.GlBufferType; import com.jozufozu.flywheel.backend.gl.GlVertexArray; +import com.jozufozu.flywheel.backend.gl.MappedBufferRange; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import net.minecraft.client.renderer.BufferBuilder; @@ -41,9 +40,11 @@ public abstract class InstancedModel extends BufferedMod @Override protected void init() { vao = new GlVertexArray(); - instanceVBO = new GlBuffer(GL20.GL_ARRAY_BUFFER); + instanceVBO = new GlBuffer(GlBufferType.ARRAY_BUFFER); - vao.with(vao -> super.init()); + vao.bind(); + super.init(); + vao.unbind(); } @Override @@ -79,12 +80,12 @@ public abstract class InstancedModel extends BufferedMod protected abstract D newInstance(); protected void doRender() { - vao.with(vao -> { - renderSetup(); + vao.bind(); + renderSetup(); - if (glInstanceCount > 0) - Backend.compat.drawInstanced.drawArraysInstanced(GL11.GL_QUADS, 0, vertexCount, glInstanceCount); - }); + if (glInstanceCount > 0) + Backend.compat.drawInstanced.drawArraysInstanced(GL11.GL_QUADS, 0, vertexCount, glInstanceCount); + vao.unbind(); } protected void renderSetup() { @@ -127,9 +128,9 @@ public abstract class InstancedModel extends BufferedMod final int offset = size * getInstanceFormat().getStride(); final int length = glBufferSize - offset; if (length > 0) { - instanceVBO.map(offset, length, buffer -> { - buffer.put(new byte[length]); - }); + MappedBufferRange buffer = instanceVBO.getBuffer(offset, length); + buffer.putByteArray(new byte[length]); + buffer.unmap(); } } @@ -150,14 +151,14 @@ public abstract class InstancedModel extends BufferedMod final int length = (1 + lastDirty - firstDirty) * stride; if (length > 0) { - instanceVBO.map(offset, length, buffer -> { - dirtySet.stream().forEach(i -> { - final D d = data.get(i); + MappedBufferRange mapped = instanceVBO.getBuffer(offset, length); + dirtySet.stream().forEach(i -> { + final D d = data.get(i); - buffer.position(i * stride - offset); - d.write(buffer); - }); + mapped.position(i * stride - offset); + d.write(mapped); }); + mapped.unmap(); } } @@ -182,13 +183,13 @@ public abstract class InstancedModel extends BufferedMod int requiredSize = size * stride; if (requiredSize > glBufferSize) { glBufferSize = requiredSize + stride * 16; - instanceVBO.alloc(glBufferSize, GL15.GL_STATIC_DRAW); + instanceVBO.alloc(glBufferSize); - instanceVBO.map(glBufferSize, buffer -> { - for (D datum : data) { - datum.write(buffer); - } - }); + MappedBufferRange buffer = instanceVBO.getBuffer(0, glBufferSize); + for (D datum : data) { + datum.write(buffer); + } + buffer.unmap(); glInstanceCount = size; return true; @@ -231,7 +232,7 @@ public abstract class InstancedModel extends BufferedMod } @Override - protected void copyVertex(ByteBuffer constant, int i) { + protected void copyVertex(MappedBufferRange constant, int i) { constant.putFloat(getX(template, i)); constant.putFloat(getY(template, i)); constant.putFloat(getZ(template, i)); diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java index 2f038c01d..61183820e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java @@ -132,8 +132,7 @@ public abstract class InstancedTileRenderer

{ */ public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, ShaderCallback

callback) { for (RenderMaterial material : materials.values()) { - if (material.canRenderInLayer(layer)) - material.render(layer, viewProjection, camX, camY, camZ, callback); + material.render(layer, viewProjection, camX, camY, camZ, callback); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index eb90b410d..f3994d105 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -1,24 +1,20 @@ package com.jozufozu.flywheel.backend.instancing; import java.util.Arrays; -import java.util.List; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; -import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.opengl.GL11; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.PartialModel; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; -import com.jozufozu.flywheel.util.BakedQuadWrapper; import com.jozufozu.flywheel.util.RenderUtil; import com.jozufozu.flywheel.util.VirtualEmptyModelData; import com.mojang.blaze3d.matrix.MatrixStack; @@ -29,14 +25,12 @@ import net.minecraft.client.renderer.BlockModelRenderer; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; -import net.minecraftforge.client.model.data.IModelData; public class RenderMaterial

> { @@ -72,8 +66,12 @@ public class RenderMaterial

setup) { + if (!canRenderInLayer(layer)) return; + P program = renderer.context.getProgram(programSpec); - program.bind(viewProjection, camX, camY, camZ, Backend.getDebugMode()); + program.bind(); + program.uploadViewProjection(viewProjection); + program.uploadCameraPos(camX, camY, camZ); if (setup != null) setup.call(program); @@ -150,12 +148,12 @@ public class RenderMaterial

quads = Arrays.stream(dirs) - .flatMap(dir -> model.getQuads(referenceState, dir, mc.world.rand, modelData).stream()) - .collect(Collectors.toList()); +// BakedQuadWrapper quadReader = new BakedQuadWrapper(); +// +// IModelData modelData = model.getModelData(mc.world, BlockPos.ZERO.up(255), referenceState, VirtualEmptyModelData.INSTANCE); +// List quads = Arrays.stream(dirs) +// .flatMap(dir -> model.getQuads(referenceState, dir, mc.world.rand, modelData).stream()) +// .collect(Collectors.toList()); builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); blockRenderer.renderModel(mc.world, model, referenceState, BlockPos.ZERO.up(255), ms, builder, true, diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java index e813cc7f2..1e57ff19b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java @@ -1,8 +1,7 @@ package com.simibubi.create.content.contraptions.base; -import java.nio.ByteBuffer; - import com.jozufozu.flywheel.backend.core.materials.BasicData; +import com.jozufozu.flywheel.backend.gl.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.simibubi.create.foundation.utility.ColorHelper; @@ -73,28 +72,26 @@ public class KineticData extends BasicData { } public KineticData setRotationalSpeed(float rotationalSpeed) { - this.rotationalSpeed = rotationalSpeed; - return this; - } + this.rotationalSpeed = rotationalSpeed; + return this; + } - public KineticData setRotationOffset(float rotationOffset) { - this.rotationOffset = rotationOffset; - return this; - } + public KineticData setRotationOffset(float rotationOffset) { + this.rotationOffset = rotationOffset; + return this; + } - @Override - public void write(ByteBuffer buf) { - super.write(buf); + @Override + public void write(MappedBuffer buf) { + super.write(buf); - buf.asFloatBuffer().put(new float[] { - x, - y, - z, - rotationalSpeed, - rotationOffset - }); - - buf.position(buf.position() + 5 * 4); - } + buf.putFloatArray(new float[]{ + x, + y, + z, + rotationalSpeed, + rotationOffset + }); + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java index e40d3cf07..044bcd5ca 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java @@ -1,7 +1,6 @@ package com.simibubi.create.content.contraptions.base; -import java.nio.ByteBuffer; - +import com.jozufozu.flywheel.backend.gl.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import net.minecraft.util.Direction; @@ -25,20 +24,20 @@ public class RotatingData extends KineticData { public RotatingData setRotationAxis(Vector3f axis) { setRotationAxis(axis.getX(), axis.getY(), axis.getZ()); return this; - } + } - public RotatingData setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) { - this.rotationAxisX = (byte) (rotationAxisX * 127); - this.rotationAxisY = (byte) (rotationAxisY * 127); - this.rotationAxisZ = (byte) (rotationAxisZ * 127); - markDirty(); - return this; - } + public RotatingData setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) { + this.rotationAxisX = (byte) (rotationAxisX * 127); + this.rotationAxisY = (byte) (rotationAxisY * 127); + this.rotationAxisZ = (byte) (rotationAxisZ * 127); + markDirty(); + return this; + } - @Override - public void write(ByteBuffer buf) { - super.write(buf); + @Override + public void write(MappedBuffer buf) { + super.write(buf); - putVec3(buf, rotationAxisX, rotationAxisY, rotationAxisZ); - } + buf.putVec3(rotationAxisX, rotationAxisY, rotationAxisZ); + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java index 42bd732c2..fb542eb6f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java @@ -1,7 +1,6 @@ package com.simibubi.create.content.contraptions.components.actors; -import java.nio.ByteBuffer; - +import com.jozufozu.flywheel.backend.gl.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; @@ -92,24 +91,24 @@ public class ActorData extends InstanceData { return this; } - public ActorData setLocalRotation(Quaternion q) { - this.qX = q.getX(); - this.qY = q.getY(); - this.qZ = q.getZ(); - this.qW = q.getW(); - markDirty(); - return this; - } + public ActorData setLocalRotation(Quaternion q) { + this.qX = q.getX(); + this.qY = q.getY(); + this.qZ = q.getZ(); + this.qW = q.getW(); + markDirty(); + return this; + } - @Override - public void write(ByteBuffer buf) { - putVec3(buf, x, y, z); - putVec2(buf, blockLight, skyLight); - put(buf, rotationOffset); - putVec3(buf, rotationAxisX, rotationAxisY, rotationAxisZ); - putVec4(buf, qX, qY, qZ, qW); - putVec3(buf, rotationCenterX, rotationCenterY, rotationCenterZ); - put(buf, speed); + @Override + public void write(MappedBuffer buf) { + buf.putVec3(x, y, z); + buf.putVec2(blockLight, skyLight); + buf.putFloat(rotationOffset); + buf.putVec3(rotationAxisX, rotationAxisY, rotationAxisZ); + buf.putVec4(qX, qY, qZ, qW); + buf.putVec3(rotationCenterX, rotationCenterY, rotationCenterZ); + buf.putFloat(speed); - } + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java index 1b1343135..8d04d41f7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java @@ -1,13 +1,12 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; -import java.nio.ByteBuffer; - -import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.backend.BufferedModel; import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.GlBufferType; import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.MappedBufferRange; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import net.minecraft.client.renderer.BufferBuilder; @@ -50,45 +49,45 @@ public class ContraptionModel extends BufferedModel { } protected final void createEBO() { - ebo = new GlBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER); - eboIndexType = GlPrimitiveType.UINT; // TODO: choose this based on the number of vertices + ebo = new GlBuffer(GlBufferType.ELEMENT_ARRAY_BUFFER); + eboIndexType = GlPrimitiveType.UINT; // TODO: choose this based on the number of vertices - int indicesSize = vertexCount * eboIndexType.getSize(); + int indicesSize = vertexCount * eboIndexType.getSize(); - ebo.bind(); + ebo.bind(); - GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesSize, GL15.GL_STATIC_DRAW); - ebo.map(indicesSize, indices -> { - for (int i = 0; i < vertexCount; i++) { - indices.putInt(i); - } - }); + ebo.alloc(indicesSize); + MappedBufferRange indices = ebo.getBuffer(0, indicesSize); + for (int i = 0; i < vertexCount; i++) { + indices.putInt(i); + } + indices.unmap(); - ebo.unbind(); - } + ebo.unbind(); + } - @Override - protected void copyVertex(ByteBuffer to, int vertex) { - to.putFloat(getX(template, vertex)); - to.putFloat(getY(template, vertex)); - to.putFloat(getZ(template, vertex)); + @Override + protected void copyVertex(MappedBufferRange to, int vertex) { + to.putFloat(getX(template, vertex)); + to.putFloat(getY(template, vertex)); + to.putFloat(getZ(template, vertex)); - to.put(getNX(template, vertex)); - to.put(getNY(template, vertex)); - to.put(getNZ(template, vertex)); + to.put(getNX(template, vertex)); + to.put(getNY(template, vertex)); + to.put(getNZ(template, vertex)); - to.putFloat(getU(template, vertex)); - to.putFloat(getV(template, vertex)); + to.putFloat(getU(template, vertex)); + to.putFloat(getV(template, vertex)); - to.put(getR(template, vertex)); - to.put(getG(template, vertex)); - to.put(getB(template, vertex)); - to.put(getA(template, vertex)); + to.put(getR(template, vertex)); + to.put(getG(template, vertex)); + to.put(getB(template, vertex)); + to.put(getA(template, vertex)); - int light = getLight(template, vertex); + int light = getLight(template, vertex); - byte sky = (byte) (LightTexture.getSkyLightCoordinates(light) << 4); - byte block = (byte) (LightTexture.getBlockLightCoordinates(light) << 4); + byte sky = (byte) (LightTexture.getSkyLightCoordinates(light) << 4); + byte block = (byte) (LightTexture.getBlockLightCoordinates(light) << 4); to.put(block); to.put(sky); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 03a039a45..d98369b87 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -1,12 +1,17 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; +import static org.lwjgl.opengl.GL13.GL_QUADS; +import static org.lwjgl.opengl.GL13.GL_TEXTURE0; +import static org.lwjgl.opengl.GL13.GL_TEXTURE4; +import static org.lwjgl.opengl.GL13.GL_TEXTURE_3D; +import static org.lwjgl.opengl.GL13.glActiveTexture; +import static org.lwjgl.opengl.GL13.glDisable; +import static org.lwjgl.opengl.GL13.glEnable; + import java.util.List; import java.util.Random; import org.apache.commons.lang3.tuple.Pair; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL13; -import org.lwjgl.opengl.GL40; import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; @@ -81,27 +86,31 @@ public class ContraptionRenderDispatcher { if (renderers.isEmpty()) return; layer.startDrawing(); - GL11.glEnable(GL13.GL_TEXTURE_3D); - GL13.glActiveTexture(GL40.GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 + glEnable(GL_TEXTURE_3D); + glActiveTexture(GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 if (Backend.canUseVBOs()) { ContraptionProgram structureShader = ContraptionContext.INSTANCE.getProgram(AllProgramSpecs.STRUCTURE); - structureShader.bind(viewProjection, camX, camY, camZ, Backend.getDebugMode()); + + structureShader.bind(); + structureShader.uploadViewProjection(viewProjection); + structureShader.uploadCameraPos(camX, camY, camZ); + for (RenderedContraption renderer : renderers.values()) { renderer.doRenderLayer(layer, structureShader); } } - if (Backend.canUseInstancing()) { - for (RenderedContraption renderer : renderers.values()) { + if (Backend.canUseInstancing()) { + for (RenderedContraption renderer : renderers.values()) { renderer.kinetics.render(layer, viewProjection, camX, camY, camZ, renderer::setup); renderer.teardown(); } } layer.endDrawing(); - GL11.glDisable(GL13.GL_TEXTURE_3D); - GL13.glActiveTexture(GL40.GL_TEXTURE0); + glDisable(GL_TEXTURE_3D); + glActiveTexture(GL_TEXTURE0); } private static RenderedContraption getRenderer(World world, Contraption c) { @@ -199,25 +208,25 @@ public class ContraptionRenderDispatcher { if (renderWorld == null || renderWorld.getWorld() != Minecraft.getInstance().world) renderWorld = new PlacementSimulationWorld(Minecraft.getInstance().world); - ForgeHooksClient.setRenderLayer(layer); - MatrixStack ms = new MatrixStack(); - BlockRendererDispatcher dispatcher = Minecraft.getInstance() - .getBlockRendererDispatcher(); - BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer(); - Random random = new Random(); - BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); - builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - renderWorld.setTileEntities(c.presentTileEntities.values()); + ForgeHooksClient.setRenderLayer(layer); + MatrixStack ms = new MatrixStack(); + BlockRendererDispatcher dispatcher = Minecraft.getInstance() + .getBlockRendererDispatcher(); + BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer(); + Random random = new Random(); + BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); + builder.begin(GL_QUADS, DefaultVertexFormats.BLOCK); + renderWorld.setTileEntities(c.presentTileEntities.values()); - for (Template.BlockInfo info : c.getBlocks() - .values()) - renderWorld.setBlockState(info.pos, info.state); + for (Template.BlockInfo info : c.getBlocks() + .values()) + renderWorld.setBlockState(info.pos, info.state); - for (Template.BlockInfo info : c.getBlocks() - .values()) { - BlockState state = info.state; + for (Template.BlockInfo info : c.getBlocks() + .values()) { + BlockState state = info.state; - if (state.getRenderType() == BlockRenderType.ENTITYBLOCK_ANIMATED) + if (state.getRenderType() == BlockRenderType.ENTITYBLOCK_ANIMATED) continue; if (!RenderTypeLookup.canRenderInLayer(state, layer)) continue; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java index 81d59d97b..cc444d47b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java @@ -1,7 +1,6 @@ package com.simibubi.create.content.contraptions.relays.belt; -import java.nio.ByteBuffer; - +import com.jozufozu.flywheel.backend.gl.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.simibubi.create.content.contraptions.base.KineticData; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; @@ -47,24 +46,22 @@ public class BeltData extends KineticData { this.maxV = target.getMaxV(); markDirty(); - return this; - } + return this; + } - public BeltData setScrollMult(float scrollMult) { - this.scrollMult = (byte) (scrollMult * 127); - markDirty(); - return this; - } + public BeltData setScrollMult(float scrollMult) { + this.scrollMult = (byte) (scrollMult * 127); + markDirty(); + return this; + } - @Override - public void write(ByteBuffer buf) { - super.write(buf); + @Override + public void write(MappedBuffer buf) { + super.write(buf); - putVec4(buf, qX, qY, qZ, qW); - - putVec2(buf, sourceU, sourceV); - putVec4(buf, minU, minV, maxU, maxV); - - put(buf, scrollMult); - } + buf.putVec4(qX, qY, qZ, qW); + buf.putVec2(sourceU, sourceV); + buf.putVec4(minU, minV, maxU, maxV); + buf.put(scrollMult); + } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java index d0cfacc4e..e75a9578e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java @@ -1,8 +1,7 @@ package com.simibubi.create.content.logistics.block; -import java.nio.ByteBuffer; - import com.jozufozu.flywheel.backend.core.materials.IFlatLight; +import com.jozufozu.flywheel.backend.gl.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; @@ -114,17 +113,17 @@ public class FlapData extends InstanceData implements IFlatLight { } @Override - public void write(ByteBuffer buf) { - putVec3(buf, x, y, z); - putVec2(buf, blockLight, skyLight); + public void write(MappedBuffer buf) { + buf.putVec3(x, y, z); + buf.putVec2(blockLight, skyLight); - putVec3(buf, segmentOffsetX, segmentOffsetY, segmentOffsetZ); - putVec3(buf, pivotX, pivotY, pivotZ); + buf.putVec3(segmentOffsetX, segmentOffsetY, segmentOffsetZ); + buf.putVec3(pivotX, pivotY, pivotZ); - put(buf, horizontalAngle); - put(buf, intensity); - put(buf, flapScale); + buf.putFloat(horizontalAngle); + buf.putFloat(intensity); + buf.putFloat(flapScale); - put(buf, flapness); + buf.putFloat(flapness); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java index 3035fd99c..c3bf3c446 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java @@ -5,14 +5,15 @@ import java.util.ArrayList; import javax.annotation.Nullable; import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.GlBufferType; import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; import com.jozufozu.flywheel.backend.gl.GlVertexArray; +import com.jozufozu.flywheel.backend.gl.MappedBufferRange; import com.jozufozu.flywheel.util.RenderUtil; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -68,7 +69,7 @@ public class EffectsHandler { private final Framebuffer framebuffer; private final GlVertexArray vao = new GlVertexArray(); - private final GlBuffer vbo = new GlBuffer(GL20.GL_ARRAY_BUFFER); + private final GlBuffer vbo = new GlBuffer(GlBufferType.ARRAY_BUFFER); private final ArrayList spheres; @@ -79,8 +80,10 @@ public class EffectsHandler { framebuffer = new Framebuffer(render.framebufferWidth, render.framebufferHeight, false, Minecraft.IS_RUNNING_ON_MAC); vbo.bind(); - vbo.alloc(bufferSize, GL15.GL_STATIC_DRAW); - vbo.map(bufferSize, buf -> buf.asFloatBuffer().put(vertices)); + vbo.alloc(bufferSize); + MappedBufferRange buffer = vbo.getBuffer(0, bufferSize); + buffer.putFloatArray(vertices); + buffer.unmap(); vao.bind(); diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java b/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java index 45cd8226a..30cacab69 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java @@ -1,7 +1,6 @@ package com.simibubi.create.foundation.render.effects; -import java.nio.FloatBuffer; - +import com.jozufozu.flywheel.backend.gl.MappedBuffer; import com.jozufozu.flywheel.util.RenderUtil; import net.minecraft.util.math.vector.Matrix4f; @@ -27,8 +26,8 @@ public class FilterSphere { public Matrix4f filter; - public void write(FloatBuffer buf) { - buf.put(new float[]{ + public void write(MappedBuffer buf) { + buf.putFloatArray(new float[]{ x, y, z, @@ -50,6 +49,6 @@ public class FilterSphere { 0, // padding }); - buf.put(RenderUtil.writeMatrix(filter)); + buf.putFloatArray(RenderUtil.writeMatrix(filter)); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java index 8f7612613..6986182a0 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java @@ -1,12 +1,13 @@ package com.simibubi.create.foundation.render.effects; -import java.nio.FloatBuffer; import java.util.ArrayList; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL31; import com.jozufozu.flywheel.backend.gl.GlBuffer; +import com.jozufozu.flywheel.backend.gl.GlBufferType; +import com.jozufozu.flywheel.backend.gl.MappedBufferRange; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import net.minecraft.util.ResourceLocation; @@ -43,15 +44,15 @@ public class SphereFilterProgram extends GlProgram { public SphereFilterProgram(ResourceLocation name, int handle) { super(name, handle); - effectsUBO = new GlBuffer(GL31.GL_UNIFORM_BUFFER); + effectsUBO = new GlBuffer(GlBufferType.UNIFORM_BUFFER); uniformBlock = GL31.glGetUniformBlockIndex(handle, "Filters"); GL31.glUniformBlockBinding(handle, uniformBlock, UBO_BINDING); effectsUBO.bind(); - effectsUBO.alloc(BUFFER_SIZE, GL20.GL_STATIC_DRAW); - GL31.glBindBufferBase(effectsUBO.getBufferType(), UBO_BINDING, effectsUBO.handle()); + effectsUBO.alloc(BUFFER_SIZE); + GL31.glBindBufferBase(effectsUBO.getBufferTarget().glEnum, UBO_BINDING, effectsUBO.handle()); effectsUBO.unbind(); uInverseProjection = getUniformLocation("uInverseProjection"); @@ -79,15 +80,16 @@ public class SphereFilterProgram extends GlProgram { } public void uploadFilters(ArrayList filters) { - effectsUBO.bind(GL20.GL_ARRAY_BUFFER); - effectsUBO.map(GL20.GL_ARRAY_BUFFER, 0, BUFFER_SIZE, buf -> { - buf.putInt(filters.size()); - buf.position(16); - FloatBuffer floatBuffer = buf.asFloatBuffer(); + effectsUBO.bind(GlBufferType.ARRAY_BUFFER); + MappedBufferRange buffer = effectsUBO.getBuffer(0, BUFFER_SIZE); + buffer.putInt(filters.size()) + .position(16); - filters.forEach(it -> it.write(floatBuffer)); - }); - effectsUBO.unbind(GL20.GL_ARRAY_BUFFER); + filters.forEach(it -> it.write(buffer)); + + buffer.unmap(); + + effectsUBO.unbind(GlBufferType.ARRAY_BUFFER); } public void bindInverseProjection(Matrix4f mat) { diff --git a/src/main/resources/assets/create/flywheel/shaders/block_new.frag b/src/main/resources/assets/create/flywheel/shaders/block_new.frag index 0319b49c8..fe96f0c84 100644 --- a/src/main/resources/assets/create/flywheel/shaders/block_new.frag +++ b/src/main/resources/assets/create/flywheel/shaders/block_new.frag @@ -1,6 +1,6 @@ #flwbuiltins -#[FLWFragment] +#[Fragment] struct Raster { vec2 texCoords; vec4 color; diff --git a/src/main/resources/assets/create/flywheel/shaders/model.vert b/src/main/resources/assets/create/flywheel/shaders/model.vert index 7336bd064..4e0c76ec5 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model.vert +++ b/src/main/resources/assets/create/flywheel/shaders/model.vert @@ -1,7 +1,6 @@ #version 110 #flwbuiltins -#flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/diffuse.glsl"> attribute vec3 aPos; diff --git a/src/main/resources/assets/create/flywheel/shaders/model_new.vert b/src/main/resources/assets/create/flywheel/shaders/model_new.vert index 7051e3063..755d09361 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model_new.vert +++ b/src/main/resources/assets/create/flywheel/shaders/model_new.vert @@ -1,23 +1,25 @@ #flwbuiltins -#flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/diffuse.glsl"> -#[FLWVertexData] +#[VertexData] struct Vertex { +#[Layout(float)] vec3 pos; vec3 normal; vec2 texCoords; }; -#[FLWInstanceData] +#[InstanceData] struct Instance { +#[Normalized(ushort)] vec2 light; + #[Normalized(ubyte)] vec4 color; mat4 transform; mat3 normalMat; }; -#[FLWFragment] +#[Fragment] struct Raster { vec2 texCoords; vec4 color; diff --git a/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag b/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag index c8cc0eefa..fb9620d7d 100644 --- a/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag +++ b/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag @@ -2,11 +2,11 @@ #flwbeginbody -#FLWPrefixFields(FLWFragment, varying, v2f_) +#FLWPrefixFields(Fragment, varying, v2f_) void main() { - FLWFragment f; - #FLWAssignFields(FLWFragment, f., v2f_) + Fragment f; + #FLWAssignFields(Fragment, f., v2f_) FLWMain(f); } diff --git a/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert b/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert index 85b415465..83cc28e2b 100644 --- a/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert +++ b/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert @@ -1,19 +1,19 @@ #version 110 #flwbeginbody -#FLWPrefixFields(FLWVertexData, attribute, a_v_) -#FLWPrefixFields(FLWInstanceData, attribute, a_i_) +#FLWPrefixFields(VertexData, attribute, a_v_) +#FLWPrefixFields(InstanceData, attribute, a_i_) -#FLWPrefixFields(FLWFragment, varying, v2f_) +#FLWPrefixFields(Fragment, varying, v2f_) void main() { - FLWVertexData v; - #FLWAssignFields(FLWVertexData, v., a_v_) + VertexData v; + #FLWAssignFields(VertexData, v., a_v_) - FLWInstanceData i; - #FLWAssignFields(FLWInstanceData, i., a_i_) + InstanceData i; + #FLWAssignFields(InstanceData, i., a_i_) - FLWFragment o = FLWMain(v, i); + Fragment o = FLWMain(v, i); - #FLWAssignFields(FLWFragment, v2f_, o.) + #FLWAssignFields(Fragment, v2f_, o.) } From 8efe8ed01e53354c832a5daa4db3caa7f54fe9ad Mon Sep 17 00:00:00 2001 From: JozsefA Date: Fri, 14 May 2021 18:32:27 -0700 Subject: [PATCH 054/198] Port the fixed lightmap shift to WorldContext --- .../flywheel/shaders/context/contraption/builtin.frag | 6 ++++-- .../assets/create/flywheel/shaders/context/std/builtin.frag | 4 ++-- .../assets/create/flywheel/shaders/core/lightutil.glsl | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/assets/create/flywheel/shaders/core/lightutil.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag index 8f43ae7f6..054697141 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag @@ -1,4 +1,5 @@ #flwinclude <"create:context/std/fog.glsl"> +#flwinclude <"create:core/lightutil.glsl"> varying vec3 BoxCoord; uniform sampler3D uLightVolume; @@ -23,6 +24,7 @@ void FLWFinalizeColor(vec4 color) { } vec4 FLWLight(vec2 lightCoords) { - vec2 lm = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg); - return texture2D(uLightMap, lm * 0.99609375 + 0.03125); // * 255/256 + 1/32 + lightCoords = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg); + + return texture2D(uLightMap, shiftLight(lightCoords)); } diff --git a/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag index d8f079be6..8a30001a6 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag @@ -1,4 +1,5 @@ #flwinclude <"create:context/std/fog.glsl"> +#flwinclude <"create:core/lightutil.glsl"> uniform sampler2D uBlockAtlas; uniform sampler2D uLightMap; @@ -20,6 +21,5 @@ void FLWFinalizeColor(vec4 color) { } vec4 FLWLight(vec2 lightCoords) { - vec2 lm = lightCoords * 0.9375 + 0.03125; - return texture2D(uLightMap, lm); + return texture2D(uLightMap, shiftLight(lightCoords)); } diff --git a/src/main/resources/assets/create/flywheel/shaders/core/lightutil.glsl b/src/main/resources/assets/create/flywheel/shaders/core/lightutil.glsl new file mode 100644 index 000000000..9967c4f51 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/core/lightutil.glsl @@ -0,0 +1,4 @@ +// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap +vec2 shiftLight(vec2 lm) { + return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32 +} From 79977aee1443fe29d4febcb51cbf437c691c3a86 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Fri, 14 May 2021 22:51:14 -0700 Subject: [PATCH 055/198] Choose between 2 different implementations of a mapped buffer - MappedBufferRange (GL30) and MappedFullBuffer (GL15) so far - Persistent mapping (optionally?) would be nice --- .../flywheel/backend/BufferedModel.java | 12 +-- .../backend/core/materials/BasicData.java | 2 +- .../backend/core/materials/ModelData.java | 2 +- .../backend/core/materials/OrientedData.java | 2 +- .../backend/gl/MappedBufferRange.java | 31 ------ .../backend/gl/{ => buffer}/GlBuffer.java | 16 +++- .../backend/gl/{ => buffer}/GlBufferType.java | 2 +- .../gl/{ => buffer}/GlBufferUsage.java | 2 +- .../backend/gl/{ => buffer}/MappedBuffer.java | 46 ++++++++- .../backend/gl/buffer/MappedBufferRange.java | 33 +++++++ .../backend/gl/buffer/MappedBufferUsage.java | 16 ++++ .../backend/gl/buffer/MappedFullBuffer.java | 21 +++++ .../backend/gl/versioned/GlCompat.java | 4 +- .../backend/gl/versioned/MapBuffer.java | 94 ------------------- .../backend/gl/versioned/MapBufferRange.java | 49 ++++++++++ .../backend/instancing/InstanceData.java | 2 +- .../backend/instancing/InstancedModel.java | 23 ++--- .../contraptions/base/KineticData.java | 2 +- .../contraptions/base/RotatingData.java | 2 +- .../components/actors/ActorData.java | 2 +- .../render/ContraptionModel.java | 12 +-- .../contraptions/relays/belt/BeltData.java | 2 +- .../content/logistics/block/FlapData.java | 2 +- .../render/effects/EffectsHandler.java | 10 +- .../render/effects/FilterSphere.java | 2 +- .../render/effects/SphereFilterProgram.java | 10 +- 26 files changed, 223 insertions(+), 178 deletions(-) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/MappedBufferRange.java rename src/main/java/com/jozufozu/flywheel/backend/gl/{ => buffer}/GlBuffer.java (61%) rename src/main/java/com/jozufozu/flywheel/backend/gl/{ => buffer}/GlBufferType.java (95%) rename src/main/java/com/jozufozu/flywheel/backend/gl/{ => buffer}/GlBufferUsage.java (90%) rename src/main/java/com/jozufozu/flywheel/backend/gl/{ => buffer}/MappedBuffer.java (62%) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBufferRange.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBufferUsage.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedFullBuffer.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBufferRange.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java b/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java index d23d9fdd7..3f2f959a0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java @@ -3,10 +3,10 @@ package com.jozufozu.flywheel.backend; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; -import com.jozufozu.flywheel.backend.gl.GlBuffer; -import com.jozufozu.flywheel.backend.gl.GlBufferType; -import com.jozufozu.flywheel.backend.gl.MappedBufferRange; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.simibubi.create.foundation.render.TemplateBuffer; import net.minecraft.client.renderer.BufferBuilder; @@ -38,14 +38,14 @@ public abstract class BufferedModel extends TemplateBuffer { GL15.glBufferData(GL15.GL_ARRAY_BUFFER, invariantSize, GL15.GL_STATIC_DRAW); // mirror it in system memory so we can write to it - MappedBufferRange buffer = modelVBO.getBuffer(0, invariantSize); + MappedBuffer buffer = modelVBO.getBuffer(0, invariantSize); for (int i = 0; i < vertexCount; i++) { copyVertex(buffer, i); } - buffer.unmap(); + buffer.flush(); } - protected abstract void copyVertex(MappedBufferRange to, int index); + protected abstract void copyVertex(MappedBuffer to, int index); protected abstract VertexFormat getModelFormat(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java index 8900db4e1..9097d9ee7 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicData.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.backend.core.materials; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java index 42e9afbfb..88475d478 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelData.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.backend.core.materials; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.util.RenderUtil; import com.mojang.blaze3d.matrix.MatrixStack; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java index 187e4f3c2..0132537c7 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedData.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.backend.core.materials; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBufferRange.java b/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBufferRange.java deleted file mode 100644 index 6a28dfce6..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBufferRange.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.jozufozu.flywheel.backend.gl; - -import java.nio.ByteBuffer; - -import org.lwjgl.opengl.GL30; - -public class MappedBufferRange extends MappedBuffer { - - GlBuffer owner; - - public MappedBufferRange(GlBuffer buffer, ByteBuffer internal) { - super(internal); - this.owner = buffer; - } - - public static MappedBufferRange create(GlBuffer buffer, long offset, long length, int access) { - ByteBuffer byteBuffer = GL30.glMapBufferRange(buffer.type.glEnum, offset, length, access); - - return new MappedBufferRange(buffer, byteBuffer); - } - - public MappedBuffer unmap() { - GL30.glUnmapBuffer(owner.type.glEnum); - return this; - } - - @Override - public void close() throws Exception { - unmap(); - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBuffer.java similarity index 61% rename from src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBuffer.java index 6ded39c5d..c3c2da51a 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBuffer.java @@ -1,9 +1,13 @@ -package com.jozufozu.flywheel.backend.gl; +package com.jozufozu.flywheel.backend.gl.buffer; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.gl.GlObject; +import com.jozufozu.flywheel.backend.gl.versioned.MapBufferRange; + public class GlBuffer extends GlObject { protected final GlBufferType type; @@ -43,8 +47,14 @@ public class GlBuffer extends GlObject { GL15.glBufferData(type.glEnum, size, usage.glEnum); } - public MappedBufferRange getBuffer(int offset, int length) { - return MappedBufferRange.create(this, offset, length, GL30.GL_MAP_WRITE_BIT); + public MappedBuffer getBuffer(int offset, int length) { + if (Backend.compat.mapBufferRange == MapBufferRange.UNSUPPORTED) { + return new MappedBufferRange(this, offset, length, GL30.GL_MAP_WRITE_BIT); + } else { + MappedFullBuffer fullBuffer = new MappedFullBuffer(this, MappedBufferUsage.WRITE_ONLY); + fullBuffer.position(offset); + return fullBuffer; + } } protected void deleteInternal(int handle) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferType.java similarity index 95% rename from src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferType.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferType.java index f64caa6c3..7ba9d0073 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferType.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.gl; +package com.jozufozu.flywheel.backend.gl.buffer; import org.lwjgl.opengl.GL15C; import org.lwjgl.opengl.GL21; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferUsage.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferUsage.java similarity index 90% rename from src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferUsage.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferUsage.java index a2f69461c..e01f28afe 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/GlBufferUsage.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferUsage.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.gl; +package com.jozufozu.flywheel.backend.gl.buffer; import org.lwjgl.opengl.GL15; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java similarity index 62% rename from src/main/java/com/jozufozu/flywheel/backend/gl/MappedBuffer.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java index 7c01fbf8e..eace56477 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/MappedBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java @@ -1,16 +1,40 @@ -package com.jozufozu.flywheel.backend.gl; +package com.jozufozu.flywheel.backend.gl.buffer; import java.nio.ByteBuffer; +import org.lwjgl.opengl.GL15; + public abstract class MappedBuffer implements AutoCloseable { - private final ByteBuffer internal; + protected boolean mapped; + protected final GlBuffer owner; + protected ByteBuffer internal; - public MappedBuffer(ByteBuffer internal) { + public MappedBuffer(GlBuffer owner) { + this.owner = owner; + } + + public void setInternal(ByteBuffer internal) { this.internal = internal; } + protected abstract void checkAndMap(); + + public void flush() { + if (mapped) { + GL15.glUnmapBuffer(owner.type.glEnum); + mapped = false; + setInternal(null); + } + } + + @Override + public void close() throws Exception { + flush(); + } + public MappedBuffer putFloatArray(float[] floats) { + checkAndMap(); internal.asFloatBuffer().put(floats); internal.position(internal.position() + floats.length * 4); @@ -18,32 +42,44 @@ public abstract class MappedBuffer implements AutoCloseable { } public MappedBuffer putByteArray(byte[] bytes) { + checkAndMap(); internal.put(bytes); return this; } + /** + * Position this buffer relative to the 0-index in GPU memory. + * + * @param p + * @return This buffer. + */ public MappedBuffer position(int p) { + checkAndMap(); internal.position(p); return this; } public MappedBuffer putFloat(float f) { + checkAndMap(); internal.putFloat(f); return this; } public MappedBuffer putInt(int i) { + checkAndMap(); internal.putInt(i); return this; } public MappedBuffer put(byte b) { + checkAndMap(); internal.put(b); return this; } public MappedBuffer putVec4(float x, float y, float z, float w) { + checkAndMap(); internal.putFloat(x); internal.putFloat(y); internal.putFloat(z); @@ -53,6 +89,7 @@ public abstract class MappedBuffer implements AutoCloseable { } public MappedBuffer putVec3(float x, float y, float z) { + checkAndMap(); internal.putFloat(x); internal.putFloat(y); internal.putFloat(z); @@ -61,6 +98,7 @@ public abstract class MappedBuffer implements AutoCloseable { } public MappedBuffer putVec2(float x, float y) { + checkAndMap(); internal.putFloat(x); internal.putFloat(y); @@ -68,6 +106,7 @@ public abstract class MappedBuffer implements AutoCloseable { } public MappedBuffer putVec3(byte x, byte y, byte z) { + checkAndMap(); internal.put(x); internal.put(y); internal.put(z); @@ -76,6 +115,7 @@ public abstract class MappedBuffer implements AutoCloseable { } public MappedBuffer putVec2(byte x, byte y) { + checkAndMap(); internal.put(x); internal.put(y); diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBufferRange.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBufferRange.java new file mode 100644 index 000000000..1ce8cdc6c --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBufferRange.java @@ -0,0 +1,33 @@ +package com.jozufozu.flywheel.backend.gl.buffer; + +import com.jozufozu.flywheel.backend.Backend; + +public class MappedBufferRange extends MappedBuffer { + + long offset, length; + int access; + + public MappedBufferRange(GlBuffer buffer, long offset, long length, int access) { + super(buffer); + this.offset = offset; + this.length = length; + this.access = access; + } + + + @Override + public MappedBuffer position(int p) { + if (p < offset || p >= offset + length) { + throw new IndexOutOfBoundsException("Index " + p + " is not mapped"); + } + return super.position(p - (int) offset); + } + + @Override + protected void checkAndMap() { + if (!mapped) { + setInternal(Backend.compat.mapBufferRange.mapBuffer(owner.type, offset, length, access)); + mapped = true; + } + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBufferUsage.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBufferUsage.java new file mode 100644 index 000000000..30e60a348 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBufferUsage.java @@ -0,0 +1,16 @@ +package com.jozufozu.flywheel.backend.gl.buffer; + +import org.lwjgl.opengl.GL15C; + +public enum MappedBufferUsage { + READ_ONLY(GL15C.GL_READ_ONLY), + WRITE_ONLY(GL15C.GL_WRITE_ONLY), + READ_WRITE(GL15C.GL_READ_WRITE), + ; + + int glEnum; + + MappedBufferUsage(int glEnum) { + this.glEnum = glEnum; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedFullBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedFullBuffer.java new file mode 100644 index 000000000..36ebb41d2 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedFullBuffer.java @@ -0,0 +1,21 @@ +package com.jozufozu.flywheel.backend.gl.buffer; + +import org.lwjgl.opengl.GL15; + +public class MappedFullBuffer extends MappedBuffer { + + MappedBufferUsage usage; + + public MappedFullBuffer(GlBuffer buffer, MappedBufferUsage usage) { + super(buffer); + this.usage = usage; + } + + @Override + protected void checkAndMap() { + if (!mapped) { + setInternal(GL15.glMapBuffer(owner.type.glEnum, usage.glEnum)); + mapped = true; + } + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlCompat.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlCompat.java index 17eeecef4..fdeaa93ff 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlCompat.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/GlCompat.java @@ -23,7 +23,7 @@ import com.jozufozu.flywheel.backend.gl.versioned.instancing.VertexArrayObject; * most appropriate version of a feature for the current system. */ public class GlCompat { - public final MapBuffer mapBuffer; + public final MapBufferRange mapBufferRange; public final VertexArrayObject vao; public final InstancedArrays instancedArrays; @@ -34,7 +34,7 @@ public class GlCompat { public final RGPixelFormat pixelFormat; public GlCompat(GLCapabilities caps) { - mapBuffer = getLatest(MapBuffer.class, caps); + mapBufferRange = getLatest(MapBufferRange.class, caps); vao = getLatest(VertexArrayObject.class, caps); instancedArrays = getLatest(InstancedArrays.class, caps); diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java deleted file mode 100644 index db775f7e9..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBuffer.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.jozufozu.flywheel.backend.gl.versioned; - -import java.nio.ByteBuffer; -import java.util.function.Consumer; - -import org.lwjgl.opengl.ARBMapBufferRange; -import org.lwjgl.opengl.GL15; -import org.lwjgl.opengl.GL30; -import org.lwjgl.opengl.GLCapabilities; - -import com.jozufozu.flywheel.backend.gl.GlBufferType; - -public enum MapBuffer implements GlVersioned { - - GL30_RANGE { - @Override - public boolean supported(GLCapabilities caps) { - return caps.OpenGL30; - } - - public ByteBuffer mapBuffer(GlBufferType target, long offset, long length, int access) { - return GL30.glMapBufferRange(target.glEnum, offset, length, access); - } - - @Override - public void mapBuffer(GlBufferType target, int offset, int length, Consumer upload) { - ByteBuffer buffer = mapBuffer(target, offset, length, GL30.GL_MAP_WRITE_BIT); - - upload.accept(buffer); - buffer.rewind(); - - GL30.glUnmapBuffer(target.glEnum); - } - }, - ARB_RANGE { - @Override - public boolean supported(GLCapabilities caps) { - return caps.GL_ARB_map_buffer_range; - } - - public ByteBuffer mapBuffer(GlBufferType target, long offset, long length, int access) { - return ARBMapBufferRange.glMapBufferRange(target.glEnum, offset, length, access); - } - - @Override - public void mapBuffer(GlBufferType target, int offset, int length, Consumer upload) { - ByteBuffer buffer = ARBMapBufferRange.glMapBufferRange(target.glEnum, offset, length, GL30.GL_MAP_WRITE_BIT); - - upload.accept(buffer); - buffer.rewind(); - - GL30.glUnmapBuffer(target.glEnum); - } - }, - GL15_MAP { - @Override - public boolean supported(GLCapabilities caps) { - return caps.OpenGL15; - } - - @Override - public void mapBuffer(GlBufferType target, int offset, int length, Consumer upload) { - ByteBuffer buffer = GL15.glMapBuffer(target.glEnum, GL15.GL_WRITE_ONLY); - - buffer.position(offset); - upload.accept(buffer); - buffer.rewind(); - GL15.glUnmapBuffer(target.glEnum); - } - }, - UNSUPPORTED { - @Override - public boolean supported(GLCapabilities caps) { - return true; - } - - @Override - public void mapBuffer(GlBufferType target, int offset, int length, Consumer upload) { - throw new UnsupportedOperationException("glMapBuffer not supported"); - } - - @Override - public void unmapBuffer(int target) { - throw new UnsupportedOperationException("glMapBuffer not supported"); - } - }; - - - public void unmapBuffer(int target) { - GL15.glUnmapBuffer(target); - } - - public abstract void mapBuffer(GlBufferType target, int offset, int length, Consumer upload); -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBufferRange.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBufferRange.java new file mode 100644 index 000000000..85f75bc2c --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/MapBufferRange.java @@ -0,0 +1,49 @@ +package com.jozufozu.flywheel.backend.gl.versioned; + +import java.nio.ByteBuffer; + +import org.lwjgl.opengl.ARBMapBufferRange; +import org.lwjgl.opengl.GL30; +import org.lwjgl.opengl.GLCapabilities; + +import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; + +public enum MapBufferRange implements GlVersioned { + + GL30_RANGE { + @Override + public boolean supported(GLCapabilities caps) { + return caps.OpenGL30; + } + + @Override + public ByteBuffer mapBuffer(GlBufferType target, long offset, long length, int access) { + return GL30.glMapBufferRange(target.glEnum, offset, length, access); + } + }, + ARB_RANGE { + @Override + public boolean supported(GLCapabilities caps) { + return caps.GL_ARB_map_buffer_range; + } + + @Override + public ByteBuffer mapBuffer(GlBufferType target, long offset, long length, int access) { + return ARBMapBufferRange.glMapBufferRange(target.glEnum, offset, length, access); + } + }, + UNSUPPORTED { + @Override + public boolean supported(GLCapabilities caps) { + return true; + } + + @Override + public ByteBuffer mapBuffer(GlBufferType target, long offset, long length, int access) { + throw new UnsupportedOperationException("glMapBuffer not supported"); + } + }; + + + public abstract ByteBuffer mapBuffer(GlBufferType target, long offset, long length, int access); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java index 725e023f0..6776c6f56 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceData.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.backend.instancing; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; public abstract class InstanceData { diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java index 0d6f970d4..57789e637 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java @@ -9,11 +9,11 @@ import org.lwjgl.opengl.GL11; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.BufferedModel; import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; -import com.jozufozu.flywheel.backend.gl.GlBuffer; -import com.jozufozu.flywheel.backend.gl.GlBufferType; import com.jozufozu.flywheel.backend.gl.GlVertexArray; -import com.jozufozu.flywheel.backend.gl.MappedBufferRange; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import net.minecraft.client.renderer.BufferBuilder; @@ -128,9 +128,9 @@ public abstract class InstancedModel extends BufferedMod final int offset = size * getInstanceFormat().getStride(); final int length = glBufferSize - offset; if (length > 0) { - MappedBufferRange buffer = instanceVBO.getBuffer(offset, length); + MappedBuffer buffer = instanceVBO.getBuffer(offset, length); buffer.putByteArray(new byte[length]); - buffer.unmap(); + buffer.flush(); } } @@ -151,14 +151,15 @@ public abstract class InstancedModel extends BufferedMod final int length = (1 + lastDirty - firstDirty) * stride; if (length > 0) { - MappedBufferRange mapped = instanceVBO.getBuffer(offset, length); + MappedBuffer mapped = instanceVBO.getBuffer(offset, length); + dirtySet.stream().forEach(i -> { final D d = data.get(i); - mapped.position(i * stride - offset); + mapped.position(i * stride); d.write(mapped); }); - mapped.unmap(); + mapped.flush(); } } @@ -185,11 +186,11 @@ public abstract class InstancedModel extends BufferedMod glBufferSize = requiredSize + stride * 16; instanceVBO.alloc(glBufferSize); - MappedBufferRange buffer = instanceVBO.getBuffer(0, glBufferSize); + MappedBuffer buffer = instanceVBO.getBuffer(0, glBufferSize); for (D datum : data) { datum.write(buffer); } - buffer.unmap(); + buffer.flush(); glInstanceCount = size; return true; @@ -232,7 +233,7 @@ public abstract class InstancedModel extends BufferedMod } @Override - protected void copyVertex(MappedBufferRange constant, int i) { + protected void copyVertex(MappedBuffer constant, int i) { constant.putFloat(getX(template, i)); constant.putFloat(getY(template, i)); constant.putFloat(getZ(template, i)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java index 1e57ff19b..6d30b973e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.core.materials.BasicData; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.simibubi.create.foundation.utility.ColorHelper; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java index 044bcd5ca..e75eec62c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.base; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import net.minecraft.util.Direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java index fb542eb6f..3d44c51ba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.components.actors; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java index 8ae5ff8f9..6c4d90485 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java @@ -3,11 +3,11 @@ package com.simibubi.create.content.contraptions.components.structureMovement.re import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.backend.BufferedModel; -import com.jozufozu.flywheel.backend.gl.GlBuffer; -import com.jozufozu.flywheel.backend.gl.GlBufferType; import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; -import com.jozufozu.flywheel.backend.gl.MappedBufferRange; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.LightTexture; @@ -57,17 +57,17 @@ public class ContraptionModel extends BufferedModel { ebo.bind(); ebo.alloc(indicesSize); - MappedBufferRange indices = ebo.getBuffer(0, indicesSize); + MappedBuffer indices = ebo.getBuffer(0, indicesSize); for (int i = 0; i < vertexCount; i++) { indices.putInt(i); } - indices.unmap(); + indices.flush(); ebo.unbind(); } @Override - protected void copyVertex(MappedBufferRange to, int vertex) { + protected void copyVertex(MappedBuffer to, int vertex) { to.putFloat(getX(template, vertex)); to.putFloat(getY(template, vertex)); to.putFloat(getZ(template, vertex)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java index cc444d47b..1d4025831 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.contraptions.relays.belt; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.simibubi.create.content.contraptions.base.KineticData; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java index e75a9578e..8b51aca11 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java @@ -1,7 +1,7 @@ package com.simibubi.create.content.logistics.block; import com.jozufozu.flywheel.backend.core.materials.IFlatLight; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstancedModel; diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java index c3bf3c446..a2ce90c60 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java @@ -9,11 +9,11 @@ import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.gl.GlBuffer; -import com.jozufozu.flywheel.backend.gl.GlBufferType; import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; import com.jozufozu.flywheel.backend.gl.GlVertexArray; -import com.jozufozu.flywheel.backend.gl.MappedBufferRange; +import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.util.RenderUtil; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -81,9 +81,9 @@ public class EffectsHandler { vbo.bind(); vbo.alloc(bufferSize); - MappedBufferRange buffer = vbo.getBuffer(0, bufferSize); + MappedBuffer buffer = vbo.getBuffer(0, bufferSize); buffer.putFloatArray(vertices); - buffer.unmap(); + buffer.flush(); vao.bind(); diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java b/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java index 30cacab69..6c9546aef 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/FilterSphere.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.render.effects; -import com.jozufozu.flywheel.backend.gl.MappedBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.util.RenderUtil; import net.minecraft.util.math.vector.Matrix4f; diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java index 6986182a0..c04c61c36 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java @@ -5,9 +5,9 @@ import java.util.ArrayList; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL31; -import com.jozufozu.flywheel.backend.gl.GlBuffer; -import com.jozufozu.flywheel.backend.gl.GlBufferType; -import com.jozufozu.flywheel.backend.gl.MappedBufferRange; +import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import net.minecraft.util.ResourceLocation; @@ -81,13 +81,13 @@ public class SphereFilterProgram extends GlProgram { public void uploadFilters(ArrayList filters) { effectsUBO.bind(GlBufferType.ARRAY_BUFFER); - MappedBufferRange buffer = effectsUBO.getBuffer(0, BUFFER_SIZE); + MappedBuffer buffer = effectsUBO.getBuffer(0, BUFFER_SIZE); buffer.putInt(filters.size()) .position(16); filters.forEach(it -> it.write(buffer)); - buffer.unmap(); + buffer.flush(); effectsUBO.unbind(GlBufferType.ARRAY_BUFFER); } From 67052fd00cc0967c90aefa818d0ef34e1c597e6d Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 15 May 2021 00:21:20 -0700 Subject: [PATCH 056/198] Add lighting to non-Flywheel contraptions - Pass contraption world to movement behavior rendering - Add hybrid lighting option to SuperByteBuffer (takes max of world light and vertex light) - Create ContraptionWorldHolder for caching contraption worlds for contraptions that are not rendered with Flywheel - Refactor some parts of contraption rendering --- .../actors/DrillMovementBehaviour.java | 7 +- .../components/actors/DrillRenderer.java | 10 +- .../actors/HarvesterMovementBehaviour.java | 7 +- .../components/actors/HarvesterRenderer.java | 10 +- .../PortableStorageInterfaceMovement.java | 7 +- .../PortableStorageInterfaceRenderer.java | 7 +- .../actors/SawMovementBehaviour.java | 8 +- .../deployer/DeployerMovementBehaviour.java | 7 +- .../components/deployer/DeployerRenderer.java | 9 +- .../components/saw/SawRenderer.java | 9 +- .../structureMovement/MovementBehaviour.java | 5 +- .../StabilizedBearingMovementBehaviour.java | 12 +- .../render/ContraptionRenderDispatcher.java | 292 ++++++++++-------- .../render/ContraptionWorldHolder.java | 22 ++ .../render/LightVolumeDebugger.java | 2 +- .../render/RenderedContraption.java | 84 +---- .../foundation/render/SuperByteBuffer.java | 34 +- .../render/TileEntityRenderHelper.java | 2 +- 18 files changed, 266 insertions(+), 268 deletions(-) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionWorldHolder.java diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java index 5ebac5064..e6bc4a8e4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java @@ -8,6 +8,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -34,10 +35,10 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour { @Override @OnlyIn(value = Dist.CLIENT) - public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { + public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { if (!Backend.canUseInstancing()) - DrillRenderer.renderInContraption(context, ms, msLocal, buffer); + DrillRenderer.renderInContraption(context, renderWorld, ms, msLocal, buffer); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java index 3734c3509..127a29185 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java @@ -5,12 +5,14 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -29,8 +31,8 @@ public class DrillRenderer extends KineticTileEntityRenderer { return PartialBufferer.getFacing(AllBlockPartials.DRILL_HEAD, te.getBlockState()); } - public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { + public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal}; BlockState state = context.state; SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.DRILL_HEAD, state); @@ -51,8 +53,8 @@ public class DrillRenderer extends KineticTileEntityRenderer { .unCentre(); superBuffer - .light(msLocal.peek() - .getModel()) + .light(msLocal.peek().getModel(), + ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java index 88433f8e8..440ce6051 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -14,6 +14,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -52,10 +53,10 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { } @Override - public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffers) { + public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffers) { if (!Backend.canUseInstancing()) - HarvesterRenderer.renderInContraption(context, ms, msLocal, buffers); + HarvesterRenderer.renderInContraption(context, renderWorld, ms, msLocal, buffers); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java index 44cf29765..316c48364 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java @@ -12,6 +12,7 @@ import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -39,8 +40,8 @@ public class HarvesterRenderer extends SafeTileEntityRenderer sbb.light(msLocal.peek() - .getModel(), ContraptionRenderDispatcher.getLightOnContraption(context)) + .getModel(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) .renderInto(ms, vb), ms, msLocal); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index e8ec8a692..1ae52e6c7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.contraptions.components.actors; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.saw.SawBlock; import com.simibubi.create.content.contraptions.components.saw.SawRenderer; @@ -7,6 +8,7 @@ import com.simibubi.create.content.contraptions.components.saw.SawTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.foundation.utility.TreeCutter; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -75,9 +77,9 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { @Override @OnlyIn(value = Dist.CLIENT) - public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { - SawRenderer.renderInContraption(context, ms, msLocal, buffer); + public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { + SawRenderer.renderInContraption(context, renderWorld, ms, msLocal, buffer); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java index e7d38b5e1..d8220145b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -27,6 +27,7 @@ import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTProcessors; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -254,10 +255,10 @@ public class DeployerMovementBehaviour extends MovementBehaviour { } @Override - public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffers) { + public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffers) { if (!Backend.canUseInstancing()) - DeployerRenderer.renderInContraption(context, ms, msLocal, buffers); + DeployerRenderer.renderInContraption(context, renderWorld, ms, msLocal, buffers); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java index 75cd6f14b..17fc3d8fa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java @@ -21,6 +21,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -154,8 +155,8 @@ public class DeployerRenderer extends SafeTileEntityRenderer return buffer; } - public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { + public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal}; IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid()); BlockState blockState = context.state; @@ -187,9 +188,9 @@ public class DeployerRenderer extends SafeTileEntityRenderer .getModel(); for (MatrixStack m : matrixStacks) m.translate(offset.x, offset.y, offset.z); - pole.light(lighting, ContraptionRenderDispatcher.getLightOnContraption(context)) + pole.light(lighting, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) .renderInto(ms, builder); - hand.light(lighting, ContraptionRenderDispatcher.getLightOnContraption(context)) + hand.light(lighting, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) .renderInto(ms, builder); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index 81a646166..be13853e1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -18,6 +18,7 @@ import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -151,8 +152,8 @@ public class SawRenderer extends SafeTileEntityRenderer { return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te)); } - public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { + public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal }; BlockState state = context.state; SuperByteBuffer superBuffer; @@ -196,8 +197,8 @@ public class SawRenderer extends SafeTileEntityRenderer { } superBuffer - .light(msLocal.peek() - .getModel(), ContraptionRenderDispatcher.getLightOnContraption(context)) + .light(msLocal.peek().getModel(), + ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) .renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java index 9b17ea7f5..a796eea93 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java @@ -5,6 +5,7 @@ import javax.annotation.Nullable; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.entity.item.ItemEntity; @@ -60,8 +61,8 @@ public abstract class MovementBehaviour { } @OnlyIn(Dist.CLIENT) - public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) {} + public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) {} @OnlyIn(Dist.CLIENT) @Nullable diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java index 91b0cf846..47a8ee094 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java @@ -17,6 +17,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; @@ -31,8 +32,8 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { @Override @OnlyIn(Dist.CLIENT) - public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { + public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { if (Backend.canUseInstancing()) return; Direction facing = context.state.get(BlockStateProperties.FACING); @@ -55,9 +56,10 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { superBuffer.rotateCentered(orientation); // render - superBuffer.light(msLocal.peek() - .getModel(), ContraptionRenderDispatcher.getLightOnContraption(context)); - superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + superBuffer + .light(msLocal.peek().getModel(), + ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index d98369b87..e0d475f9d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -1,17 +1,17 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; -import static org.lwjgl.opengl.GL13.GL_QUADS; +import static org.lwjgl.opengl.GL11.glDisable; +import static org.lwjgl.opengl.GL11.glEnable; +import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D; import static org.lwjgl.opengl.GL13.GL_TEXTURE0; import static org.lwjgl.opengl.GL13.GL_TEXTURE4; -import static org.lwjgl.opengl.GL13.GL_TEXTURE_3D; import static org.lwjgl.opengl.GL13.glActiveTexture; -import static org.lwjgl.opengl.GL13.glDisable; -import static org.lwjgl.opengl.GL13.glEnable; import java.util.List; import java.util.Random; import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.opengl.GL11; import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; @@ -36,7 +36,7 @@ import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.BlockModelRenderer; -import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -44,7 +44,6 @@ import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.world.ClientWorld; @@ -57,25 +56,34 @@ import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.model.data.EmptyModelData; public class ContraptionRenderDispatcher { - public static final Int2ObjectMap renderers = new Int2ObjectOpenHashMap<>(); + private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); + private static final BlockModelShapes BLOCK_MODELS = Minecraft.getInstance().getModelManager().getBlockModelShapes(); + private static int ticksUntilHolderRefresh; + + public static final Int2ObjectMap RENDERERS = new Int2ObjectOpenHashMap<>(); + public static final Int2ObjectMap WORLD_HOLDERS = new Int2ObjectOpenHashMap<>(); public static final Compartment> CONTRAPTION = new Compartment<>(); - protected static PlacementSimulationWorld renderWorld; public static void tick() { if (Minecraft.getInstance().isGamePaused()) return; - for (RenderedContraption contraption : renderers.values()) { + for (RenderedContraption contraption : RENDERERS.values()) { contraption.getLighter().tick(contraption); contraption.kinetics.tick(); } + + if (ticksUntilHolderRefresh <= 0) { + removeDeadHolders(); + ticksUntilHolderRefresh = 20; + } } public static void beginFrame(ClientWorld world, MatrixStack stack, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture) { double camX = info.getProjectedView().x; double camY = info.getProjectedView().y; double camZ = info.getProjectedView().z; - for (RenderedContraption renderer : renderers.values()) { + for (RenderedContraption renderer : RENDERERS.values()) { renderer.beginFrame(info, camX, camY, camZ); } } @@ -83,7 +91,7 @@ public class ContraptionRenderDispatcher { public static void renderLayer(ClientWorld world, RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ) { removeDeadContraptions(); - if (renderers.isEmpty()) return; + if (RENDERERS.isEmpty()) return; layer.startDrawing(); glEnable(GL_TEXTURE_3D); @@ -96,13 +104,13 @@ public class ContraptionRenderDispatcher { structureShader.uploadViewProjection(viewProjection); structureShader.uploadCameraPos(camX, camY, camZ); - for (RenderedContraption renderer : renderers.values()) { + for (RenderedContraption renderer : RENDERERS.values()) { renderer.doRenderLayer(layer, structureShader); } } if (Backend.canUseInstancing()) { - for (RenderedContraption renderer : renderers.values()) { + for (RenderedContraption renderer : RENDERERS.values()) { renderer.kinetics.render(layer, viewProjection, camX, camY, camZ, renderer::setup); renderer.teardown(); } @@ -113,70 +121,81 @@ public class ContraptionRenderDispatcher { glActiveTexture(GL_TEXTURE0); } + public static void render(AbstractContraptionEntity entity, MatrixStack ms, IRenderTypeBuffer buffers, + MatrixStack msLocal, Contraption contraption) { + World world = entity.world; + if (Backend.canUseVBOs() && Backend.isFlywheelWorld(world)) { + RenderedContraption renderer = getRenderer(world, contraption); + PlacementSimulationWorld renderWorld = renderer.renderWorld; + + ContraptionRenderDispatcher.renderDynamic(world, renderWorld, contraption, ms, msLocal, buffers); + } else { + ContraptionWorldHolder holder = getWorldHolder(world, contraption); + PlacementSimulationWorld renderWorld = holder.renderWorld; + + ContraptionRenderDispatcher.renderDynamic(world, renderWorld, contraption, ms, msLocal, buffers); + ContraptionRenderDispatcher.renderStructure(world, renderWorld, contraption, ms, msLocal, buffers); + } + } + private static RenderedContraption getRenderer(World world, Contraption c) { int entityId = c.entity.getEntityId(); - RenderedContraption contraption = renderers.get(entityId); + RenderedContraption contraption = RENDERERS.get(entityId); if (contraption == null) { - contraption = new RenderedContraption(world, c); - renderers.put(entityId, contraption); + PlacementSimulationWorld renderWorld = setupRenderWorld(world, c); + contraption = new RenderedContraption(world, renderWorld, c); + RENDERERS.put(entityId, contraption); } return contraption; } - public static void render(AbstractContraptionEntity entity, MatrixStack ms, IRenderTypeBuffer buffers, - MatrixStack msLocal, Contraption contraption) { - if (Backend.canUseVBOs() && Backend.isFlywheelWorld(entity.world)) { - ContraptionRenderDispatcher.renderDynamic(entity.world, contraption, ms, msLocal, buffers); - } else { - ContraptionRenderDispatcher.renderDynamic(entity.world, contraption, ms, msLocal, buffers); - ContraptionRenderDispatcher.renderStructure(entity.world, contraption, ms, msLocal, buffers); + private static ContraptionWorldHolder getWorldHolder(World world, Contraption c) { + int entityId = c.entity.getEntityId(); + ContraptionWorldHolder holder = WORLD_HOLDERS.get(entityId); + + if (holder == null) { + PlacementSimulationWorld renderWorld = setupRenderWorld(world, c); + holder = new ContraptionWorldHolder(c, renderWorld); + WORLD_HOLDERS.put(entityId, holder); } + + return holder; } - public static void renderStructure(World world, Contraption c, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { - SuperByteBufferCache bufferCache = CreateClient.bufferCache; - List blockLayers = RenderType.getBlockLayers(); + public static PlacementSimulationWorld setupRenderWorld(World world, Contraption c) { + PlacementSimulationWorld renderWorld = new PlacementSimulationWorld(world); - buffer.getBuffer(RenderType.getSolid()); - for (int i = 0; i < blockLayers.size(); i++) { - RenderType layer = blockLayers.get(i); - Pair key = Pair.of(c, i); - SuperByteBuffer contraptionBuffer = bufferCache.get(CONTRAPTION, key, () -> buildStructureBuffer(c, layer)); - if (contraptionBuffer.isEmpty()) - continue; - Matrix4f model = msLocal.peek() - .getModel(); - contraptionBuffer.light(model) - .renderInto(ms, buffer.getBuffer(layer)); - } + renderWorld.setTileEntities(c.presentTileEntities.values()); + + for (Template.BlockInfo info : c.getBlocks() + .values()) + // Skip individual lighting updates to prevent lag with large contraptions + renderWorld.setBlockState(info.pos, info.state, 128); + + renderWorld.updateLightSources(); + renderWorld.lighter.tick(Integer.MAX_VALUE, false, false); + + return renderWorld; } - public static void renderDynamic(World world, Contraption c, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { - renderTileEntities(world, c, ms, msLocal, buffer); + public static void renderDynamic(World world, PlacementSimulationWorld renderWorld, Contraption c, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { + renderTileEntities(world, renderWorld, c, ms, msLocal, buffer); if (buffer instanceof IRenderTypeBuffer.Impl) ((IRenderTypeBuffer.Impl) buffer).draw(); - renderActors(world, c, ms, msLocal, buffer); + renderActors(world, renderWorld, c, ms, msLocal, buffer); } - public static void renderTileEntities(World world, Contraption c, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { - PlacementSimulationWorld renderWorld = null; - if (Backend.canUseVBOs() && Backend.isFlywheelWorld(world)) { - RenderedContraption renderer = getRenderer(world, c); - - renderWorld = renderer.renderWorld; - } + public static void renderTileEntities(World world, PlacementSimulationWorld renderWorld, Contraption c, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities, ms, msLocal, buffer); - } - protected static void renderActors(World world, Contraption c, MatrixStack ms, MatrixStack msLocal, - IRenderTypeBuffer buffer) { - MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal}; + protected static void renderActors(World world, PlacementSimulationWorld renderWorld, Contraption c, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { + MatrixStack[] matrixStacks = new MatrixStack[] {ms, msLocal}; for (Pair actor : c.getActors()) { MovementContext context = actor.getRight(); if (context == null) @@ -192,115 +211,112 @@ public class ContraptionRenderDispatcher { MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state); if (movementBehaviour != null) - movementBehaviour.renderInContraption(context, ms, msLocal, buffer); + movementBehaviour.renderInContraption(context, renderWorld, ms, msLocal, buffer); for (MatrixStack m : matrixStacks) m.pop(); } } - private static SuperByteBuffer buildStructureBuffer(Contraption c, RenderType layer) { - BufferBuilder builder = buildStructure(c, layer); + public static void renderStructure(World world, PlacementSimulationWorld renderWorld, Contraption c, + MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { + SuperByteBufferCache bufferCache = CreateClient.bufferCache; + List blockLayers = RenderType.getBlockLayers(); + + buffer.getBuffer(RenderType.getSolid()); + for (int i = 0; i < blockLayers.size(); i++) { + RenderType layer = blockLayers.get(i); + Pair key = Pair.of(c, i); + SuperByteBuffer contraptionBuffer = bufferCache.get(CONTRAPTION, key, () -> buildStructureBuffer(renderWorld, c, layer)); + if (contraptionBuffer.isEmpty()) + continue; + Matrix4f model = msLocal.peek() + .getModel(); + contraptionBuffer.light(model) + .hybridLight() + .renderInto(ms, buffer.getBuffer(layer)); + } + } + + private static SuperByteBuffer buildStructureBuffer(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { + BufferBuilder builder = buildStructure(renderWorld, c, layer); return new SuperByteBuffer(builder); } - public static BufferBuilder buildStructure(Contraption c, RenderType layer) { - if (renderWorld == null || renderWorld.getWorld() != Minecraft.getInstance().world) - renderWorld = new PlacementSimulationWorld(Minecraft.getInstance().world); - - ForgeHooksClient.setRenderLayer(layer); + public static BufferBuilder buildStructure(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { MatrixStack ms = new MatrixStack(); - BlockRendererDispatcher dispatcher = Minecraft.getInstance() - .getBlockRendererDispatcher(); - BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer(); Random random = new Random(); BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); - builder.begin(GL_QUADS, DefaultVertexFormats.BLOCK); - renderWorld.setTileEntities(c.presentTileEntities.values()); + builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + ForgeHooksClient.setRenderLayer(layer); + BlockModelRenderer.enableCache(); for (Template.BlockInfo info : c.getBlocks() - .values()) - renderWorld.setBlockState(info.pos, info.state); - - for (Template.BlockInfo info : c.getBlocks() - .values()) { + .values()) { BlockState state = info.state; - if (state.getRenderType() == BlockRenderType.ENTITYBLOCK_ANIMATED) - continue; - if (!RenderTypeLookup.canRenderInLayer(state, layer)) - continue; + if (state.getRenderType() != BlockRenderType.MODEL) + continue; + if (!RenderTypeLookup.canRenderInLayer(state, layer)) + continue; - IBakedModel originalModel = dispatcher.getModelForState(state); - ms.push(); - ms.translate(info.pos.getX(), info.pos.getY(), info.pos.getZ()); - blockRenderer.renderModel(renderWorld, originalModel, state, info.pos, ms, builder, true, random, 42, - OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); - ms.pop(); - } + BlockPos pos = info.pos; - builder.finishDrawing(); - renderWorld.clear(); - renderWorld = null; - return builder; - } - - public static int getLight(World world, float lx, float ly, float lz) { - BlockPos.Mutable pos = new BlockPos.Mutable(); - float sky = 0, block = 0; - float offset = 1 / 8f; - - for (float zOffset = offset; zOffset >= -offset; zOffset -= 2 * offset) - for (float yOffset = offset; yOffset >= -offset; yOffset -= 2 * offset) - for (float xOffset = offset; xOffset >= -offset; xOffset -= 2 * offset) { - pos.setPos(lx + xOffset, ly + yOffset, lz + zOffset); - sky += world.getLightLevel(LightType.SKY, pos) / 8f; - block += world.getLightLevel(LightType.BLOCK, pos) / 8f; - } - - return ((int) sky) << 20 | ((int) block) << 4; - } - - public static int getLightOnContraption(World world, PlacementSimulationWorld renderWorld, BlockPos pos, BlockPos lightPos) { - int worldLight = WorldRenderer.getLightmapCoordinates(world, lightPos); - - if (renderWorld != null) - return getMaxBlockLight(worldLight, renderWorld.getLightLevel(LightType.BLOCK, pos)); - - return worldLight; - } - - public static int getMaxBlockLight(int packedLight, int blockLightValue) { - int unpackedBlockLight = LightTexture.getBlockLightCoordinates(packedLight); - - if (blockLightValue > unpackedBlockLight) { - packedLight = (packedLight & 0xFFFF0000) | (blockLightValue << 4); - } - - return packedLight; - } - - public static int getLightOnContraption(MovementContext context) { - int entityId = context.contraption.entity.getEntityId(); - - RenderedContraption renderedContraption = renderers.get(entityId); - if (renderedContraption != null) { - return renderedContraption.renderWorld.getLightLevel(LightType.BLOCK, context.localPos); - } else { - return -1; + ms.push(); + ms.translate(pos.getX(), pos.getY(), pos.getZ()); + MODEL_RENDERER.renderModel(renderWorld, BLOCK_MODELS.getModel(state), state, pos, ms, builder, true, + random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); + ms.pop(); } + BlockModelRenderer.disableCache(); + ForgeHooksClient.setRenderLayer(null); + + builder.finishDrawing(); + return builder; + } + + public static int getLight(World world, float lx, float ly, float lz) { + BlockPos.Mutable pos = new BlockPos.Mutable(); + float sky = 0, block = 0; + float offset = 1 / 8f; + + for (float zOffset = offset; zOffset >= -offset; zOffset -= 2 * offset) + for (float yOffset = offset; yOffset >= -offset; yOffset -= 2 * offset) + for (float xOffset = offset; xOffset >= -offset; xOffset -= 2 * offset) { + pos.setPos(lx + xOffset, ly + yOffset, lz + zOffset); + sky += world.getLightLevel(LightType.SKY, pos) / 8f; + block += world.getLightLevel(LightType.BLOCK, pos) / 8f; + } + + return ((int) sky) << 20 | ((int) block) << 4; + } + + public static int getContraptionLightAt(World world, PlacementSimulationWorld renderWorld, BlockPos pos, BlockPos lightPos) { + int worldLight = WorldRenderer.getLightmapCoordinates(world, lightPos); + + if (renderWorld != null) { + int renderWorldLight = WorldRenderer.getLightmapCoordinates(renderWorld, pos); + return SuperByteBuffer.maxLight(worldLight, renderWorldLight); + } + + return worldLight; + } + + public static int getContraptionWorldLight(MovementContext context, PlacementSimulationWorld renderWorld) { + return WorldRenderer.getLightmapCoordinates(renderWorld, context.localPos); } public static void invalidateAll() { - for (RenderedContraption renderer : renderers.values()) { + for (RenderedContraption renderer : RENDERERS.values()) { renderer.invalidate(); } - renderers.clear(); + RENDERERS.clear(); + WORLD_HOLDERS.clear(); } public static void removeDeadContraptions() { - renderers.values().removeIf(renderer -> { + RENDERERS.values().removeIf(renderer -> { if (renderer.isDead()) { renderer.invalidate(); return true; @@ -308,4 +324,8 @@ public class ContraptionRenderDispatcher { return false; }); } + + public static void removeDeadHolders() { + WORLD_HOLDERS.values().removeIf(ContraptionWorldHolder::isDead); + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionWorldHolder.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionWorldHolder.java new file mode 100644 index 000000000..4ae414016 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionWorldHolder.java @@ -0,0 +1,22 @@ +package com.simibubi.create.content.contraptions.components.structureMovement.render; + +import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; +import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; + +public class ContraptionWorldHolder { + public final Contraption contraption; + public final PlacementSimulationWorld renderWorld; + + public ContraptionWorldHolder(Contraption contraption, PlacementSimulationWorld renderWorld) { + this.contraption = contraption; + this.renderWorld = renderWorld; + } + + public int getEntityId() { + return contraption.entity.getEntityId(); + } + + public boolean isDead() { + return !contraption.entity.isAlive(); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java index e2a3cc684..c8d78bcf0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/LightVolumeDebugger.java @@ -11,7 +11,7 @@ import com.simibubi.create.foundation.utility.outliner.AABBOutline; public class LightVolumeDebugger { public static void render(MatrixStack ms, SuperRenderTypeBuffer buffer) { - ContraptionRenderDispatcher.renderers.values() + ContraptionRenderDispatcher.RENDERERS.values() .stream() .flatMap(r -> { GridAlignedBB texture = r.getLighter().lightVolume.getTextureVolume(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index d847b9cd8..11bf71ee2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -4,9 +4,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Random; - -import org.lwjgl.opengl.GL11; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; @@ -18,46 +15,29 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; -import net.minecraft.block.BlockRenderType; -import net.minecraft.block.BlockState; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.BlockModelRenderer; -import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.world.World; -import net.minecraft.world.gen.feature.template.Template; -import net.minecraftforge.client.ForgeHooksClient; -import net.minecraftforge.client.model.data.EmptyModelData; -public class RenderedContraption { - private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); - private static final BlockModelShapes BLOCK_MODELS = Minecraft.getInstance().getModelManager().getBlockModelShapes(); - - public Contraption contraption; +public class RenderedContraption extends ContraptionWorldHolder { private final ContraptionLighter lighter; public final ContraptionKineticRenderer kinetics; - public final PlacementSimulationWorld renderWorld; private final Map renderLayers = new HashMap<>(); private Matrix4f model; private AxisAlignedBB lightBox; - public RenderedContraption(World world, Contraption contraption) { - this.contraption = contraption; + public RenderedContraption(World world, PlacementSimulationWorld renderWorld, Contraption contraption) { + super(contraption, renderWorld); this.lighter = contraption.makeLighter(); this.kinetics = new ContraptionKineticRenderer(this); - this.renderWorld = setupRenderWorld(world, contraption); buildLayers(); if (Backend.canUseInstancing()) { @@ -66,14 +46,6 @@ public class RenderedContraption { } } - public int getEntityId() { - return contraption.entity.getEntityId(); - } - - public boolean isDead() { - return !contraption.entity.isAlive(); - } - public ContraptionLighter getLighter() { return lighter; } @@ -164,55 +136,7 @@ public class RenderedContraption { } private static ContraptionModel buildStructureModel(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { - BufferBuilder builder = buildStructure(renderWorld, c, layer); + BufferBuilder builder = ContraptionRenderDispatcher.buildStructure(renderWorld, c, layer); return new ContraptionModel(builder); } - - private static PlacementSimulationWorld setupRenderWorld(World world, Contraption c) { - PlacementSimulationWorld renderWorld = new PlacementSimulationWorld(world); - - renderWorld.setTileEntities(c.presentTileEntities.values()); - - for (Template.BlockInfo info : c.getBlocks() - .values()) - // Skip individual lighting updates to prevent lag with large contraptions - renderWorld.setBlockState(info.pos, info.state, 128); - - renderWorld.updateLightSources(); - renderWorld.lighter.tick(Integer.MAX_VALUE, false, false); - - return renderWorld; - } - - private static BufferBuilder buildStructure(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { - MatrixStack ms = new MatrixStack(); - Random random = new Random(); - BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); - builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - - ForgeHooksClient.setRenderLayer(layer); - BlockModelRenderer.enableCache(); - for (Template.BlockInfo info : c.getBlocks() - .values()) { - BlockState state = info.state; - - if (state.getRenderType() != BlockRenderType.MODEL) - continue; - if (!RenderTypeLookup.canRenderInLayer(state, layer)) - continue; - - BlockPos pos = info.pos; - - ms.push(); - ms.translate(pos.getX(), pos.getY(), pos.getZ()); - MODEL_RENDERER.renderModel(renderWorld, BLOCK_MODELS.getModel(state), state, pos, ms, builder, true, - random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); - ms.pop(); - } - BlockModelRenderer.disableCache(); - ForgeHooksClient.setRenderLayer(null); - - builder.finishDrawing(); - return builder; - } } diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index f3ff7ef80..b8c422172 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -5,7 +5,6 @@ import java.nio.ByteBuffer; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.utility.MatrixStacker; @@ -13,6 +12,7 @@ import it.unimi.dsi.fastutil.longs.Long2DoubleMap; import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; @@ -40,8 +40,8 @@ public class SuperByteBuffer extends TemplateBuffer { // Vertex Lighting private boolean shouldLight; + private boolean hybridLight; private int packedLightCoords; - private int otherBlockLight; private Matrix4f lightTransform; // Vertex Coloring @@ -149,12 +149,15 @@ public class SuperByteBuffer extends TemplateBuffer { lightPos.transform(localTransforms); lightPos.transform(lightTransform); - light = getLight(Minecraft.getInstance().world, lightPos); - if (otherBlockLight >= 0) { - light = ContraptionRenderDispatcher.getMaxBlockLight(light, otherBlockLight); + int worldLight = getLight(Minecraft.getInstance().world, lightPos); + if (light >= 0) { + light = maxLight(worldLight, light); } } - builder.light(light); + if (hybridLight) + builder.light(maxLight(light, getLight(buffer, i))); + else + builder.light(light); } else builder.light(getLight(buffer, i)); @@ -167,7 +170,7 @@ public class SuperByteBuffer extends TemplateBuffer { spriteShiftFunc = null; shouldColor = false; shouldLight = false; - otherBlockLight = -1; + hybridLight = false; } public MatrixStacker matrixStacker() { @@ -271,10 +274,15 @@ public class SuperByteBuffer extends TemplateBuffer { return this; } - public SuperByteBuffer light(Matrix4f lightTransform, int otherBlockLight) { + public SuperByteBuffer light(Matrix4f lightTransform, int packedLightCoords) { shouldLight = true; this.lightTransform = lightTransform; - this.otherBlockLight = otherBlockLight; + this.packedLightCoords = packedLightCoords; + return this; + } + + public SuperByteBuffer hybridLight() { + hybridLight = true; return this; } @@ -287,6 +295,14 @@ public class SuperByteBuffer extends TemplateBuffer { return this; } + public static int maxLight(int packedLight1, int packedLight2) { + int blockLight1 = LightTexture.getBlockLightCoordinates(packedLight1); + int skyLight1 = LightTexture.getSkyLightCoordinates(packedLight1); + int blockLight2 = LightTexture.getBlockLightCoordinates(packedLight2); + int skyLight2 = LightTexture.getSkyLightCoordinates(packedLight2); + return LightTexture.pack(Math.max(blockLight1, blockLight2), Math.max(skyLight1, skyLight2)); + } + private static int getLight(World world, Vector4f lightPos) { BlockPos.Mutable pos = new BlockPos.Mutable(); double sky = 0, block = 0; diff --git a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java index efbf65cff..f54a5725f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java @@ -63,7 +63,7 @@ public class TileEntityRenderHelper { Vector4f vec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1); vec.transform(matrix); BlockPos lightPos = new BlockPos(vec.getX(), vec.getY(), vec.getZ()); - int worldLight = ContraptionRenderDispatcher.getLightOnContraption(world, renderWorld, pos, lightPos); + int worldLight = ContraptionRenderDispatcher.getContraptionLightAt(world, renderWorld, pos, lightPos); renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.DEFAULT_UV); } catch (Exception e) { From f33b08d99627302871793cd06e90876c1856ec36 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 15 May 2021 12:15:06 -0700 Subject: [PATCH 057/198] Minor fixes - Fix holder refresh - Fix SuperByteBuffer light calculation - Remove unused import --- .../actors/SawMovementBehaviour.java | 1 - .../render/ContraptionRenderDispatcher.java | 7 ++++--- .../foundation/render/SuperByteBuffer.java | 20 +++++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index 1ae52e6c7..494b8c183 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.contraptions.components.actors; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.saw.SawBlock; import com.simibubi.create.content.contraptions.components.saw.SawRenderer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index e0d475f9d..9c5d2665a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -58,7 +58,7 @@ import net.minecraftforge.client.model.data.EmptyModelData; public class ContraptionRenderDispatcher { private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); private static final BlockModelShapes BLOCK_MODELS = Minecraft.getInstance().getModelManager().getBlockModelShapes(); - private static int ticksUntilHolderRefresh; + private static int worldHolderRefreshCounter; public static final Int2ObjectMap RENDERERS = new Int2ObjectOpenHashMap<>(); public static final Int2ObjectMap WORLD_HOLDERS = new Int2ObjectOpenHashMap<>(); @@ -73,9 +73,10 @@ public class ContraptionRenderDispatcher { contraption.kinetics.tick(); } - if (ticksUntilHolderRefresh <= 0) { + worldHolderRefreshCounter++; + if (worldHolderRefreshCounter >= 20) { removeDeadHolders(); - ticksUntilHolderRefresh = 20; + worldHolderRefreshCounter = 0; } } diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index b8c422172..1a6c81b39 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -150,10 +150,9 @@ public class SuperByteBuffer extends TemplateBuffer { lightPos.transform(lightTransform); int worldLight = getLight(Minecraft.getInstance().world, lightPos); - if (light >= 0) { - light = maxLight(worldLight, light); - } + light = maxLight(worldLight, light); } + if (hybridLight) builder.light(maxLight(light, getLight(buffer, i))); else @@ -165,12 +164,22 @@ public class SuperByteBuffer extends TemplateBuffer { .endVertex(); } - transforms = new MatrixStack(); + reset(); + } + public SuperByteBuffer reset() { + transforms = new MatrixStack(); spriteShiftFunc = null; - shouldColor = false; shouldLight = false; hybridLight = false; + packedLightCoords = 0; + lightTransform = null; + shouldColor = false; + r = 0; + g = 0; + b = 0; + a = 0; + return this; } public MatrixStacker matrixStacker() { @@ -263,7 +272,6 @@ public class SuperByteBuffer extends TemplateBuffer { public SuperByteBuffer light(int packedLightCoords) { shouldLight = true; - lightTransform = null; this.packedLightCoords = packedLightCoords; return this; } From 9ff193946cb268df192db29ef28cf373ba06d83c Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sat, 15 May 2021 16:41:56 -0700 Subject: [PATCH 058/198] Refactor InstancedModel to not rely on inheritance - Instead, MaterialSpecs store the information - RenderMaterials are now generic on InstanceData instead of InstancedModel - RenderMaterials are directly constructed with and store a MaterialSpec --- .../jozufozu/flywheel/backend/Backend.java | 13 +--- .../flywheel/backend/BufferedModel.java | 66 +++++++++-------- .../backend/core/materials/OrientedModel.java | 28 -------- .../core/materials/TransformedModel.java | 28 -------- .../backend/gl/buffer/MappedBuffer.java | 4 +- .../backend/instancing/InstanceFactory.java | 5 ++ .../backend/instancing/InstancedModel.java | 70 ++++++++----------- .../instancing/InstancedTileRenderer.java | 10 +-- .../backend/instancing/MaterialSpec.java | 21 +++--- .../backend/instancing/ModelFactory.java | 8 --- .../backend/instancing/RenderMaterial.java | 54 +++++--------- .../instancing/TileEntityInstance.java | 4 +- .../base/KineticTileInstance.java | 5 +- .../contraptions/base/RotatingData.java | 6 +- .../contraptions/base/RotatingModel.java | 31 -------- .../components/actors/ActorData.java | 6 +- .../components/actors/ActorModel.java | 27 ------- .../components/actors/DrillActorInstance.java | 3 +- .../actors/HarvesterActorInstance.java | 3 +- .../deployer/DeployerActorInstance.java | 3 +- .../components/flywheel/FlyWheelInstance.java | 14 ++-- .../render/ContraptionKineticRenderer.java | 5 +- .../render/ContraptionModel.java | 7 +- .../contraptions/relays/belt/BeltData.java | 6 +- .../relays/belt/BeltInstancedModel.java | 32 --------- .../relays/encased/SplitShaftInstance.java | 2 +- .../relays/gearbox/GearboxInstance.java | 2 +- .../content/logistics/block/FlapModel.java | 27 ------- .../block/mechanicalArm/ArmInstance.java | 2 +- .../block/redstone/AnalogLeverInstance.java | 3 +- .../block/SchematicannonInstance.java | 3 +- .../foundation/render/AllInstanceFormats.java | 39 +++++++++++ .../foundation/render/AllMaterialSpecs.java | 20 ++---- .../render/effects/EffectsHandler.java | 13 ++-- .../render/effects/SphereFilterProgram.java | 4 +- 35 files changed, 195 insertions(+), 379 deletions(-) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedModel.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformedModel.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceFactory.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/instancing/ModelFactory.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorModel.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java delete mode 100644 src/main/java/com/simibubi/create/content/logistics/block/FlapModel.java create mode 100644 src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index 83acbe955..beab8e28e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -26,10 +26,9 @@ import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; +import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; import com.jozufozu.flywheel.util.WorldAttached; -import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.config.AllConfigs; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; @@ -131,7 +130,7 @@ public class Backend { /** * Register an instancing material. */ - public static > MaterialSpec register(MaterialSpec spec) { + public static MaterialSpec register(MaterialSpec spec) { ResourceLocation name = spec.name; if (materialRegistry.containsKey(name)) { throw new IllegalStateException("Material spec '" + name + "' already registered."); @@ -275,14 +274,6 @@ public class Backend { return canUseInstancing() && isFlywheelWorld(world); } - /** - * TODO: Remove in favor of separate debug programs specified by the SpecLoader/IMultiProgram - */ - @Deprecated - public static int getDebugMode() { - return KineticDebugger.isActive() ? 1 : 0; - } - public static Collection> allMaterials() { return materialRegistry.values(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java b/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java index 3f2f959a0..934ba2722 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java @@ -13,16 +13,45 @@ import net.minecraft.client.renderer.BufferBuilder; public abstract class BufferedModel extends TemplateBuffer { + protected final VertexFormat modelFormat; protected GlBuffer modelVBO; - protected boolean removed; + private boolean initialized; // lazy init + private boolean removed; - protected BufferedModel(BufferBuilder buf) { + protected BufferedModel(VertexFormat modelFormat, BufferBuilder buf) { super(buf); - if (vertexCount > 0) init(); + this.modelFormat = modelFormat; + } + + /** + * Renders this model, checking first if there is anything to render. + */ + public final void render() { + if (vertexCount == 0 || removed) return; + + if (!initialized) { + // Lazily acquire resources in order to get around initialization order, as #getTotalShaderAttributeCount + // might depend on fields in subclasses. + init(); + initialized = true; + } + + doRender(); + } + + /** + * Set up any state and make the draw calls. + */ + protected abstract void doRender(); + + public final void delete() { + removed = true; + if (initialized) { + RenderWork.enqueue(this::deleteInternal); + } } protected void init() { - modelVBO = new GlBuffer(GlBufferType.ARRAY_BUFFER); modelVBO.bind(); @@ -31,7 +60,7 @@ public abstract class BufferedModel extends TemplateBuffer { } protected void initModel() { - int stride = getModelFormat().getStride(); + int stride = modelFormat.getStride(); int invariantSize = vertexCount * stride; // allocate the buffer on the gpu @@ -47,40 +76,17 @@ public abstract class BufferedModel extends TemplateBuffer { protected abstract void copyVertex(MappedBuffer to, int index); - protected abstract VertexFormat getModelFormat(); - protected int getTotalShaderAttributeCount() { - return getModelFormat().getShaderAttributeCount(); + return modelFormat.getShaderAttributeCount(); } - /** - * Renders this model, checking first if there is anything to render. - */ - public final void render() { - if (vertexCount == 0 || removed) return; - - doRender(); - } - - /** - * Set up any state and make the draw calls. - */ - protected abstract void doRender(); - protected void setupAttributes() { int numAttributes = getTotalShaderAttributeCount(); for (int i = 0; i <= numAttributes; i++) { GL20.glEnableVertexAttribArray(i); } - getModelFormat().vertexAttribPointers(0); - } - - public final void delete() { - removed = true; - if (vertexCount > 0) { - RenderWork.enqueue(this::deleteInternal); - } + modelFormat.vertexAttribPointers(0); } protected void deleteInternal() { diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedModel.java deleted file mode 100644 index 6c5ca0544..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedModel.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.jozufozu.flywheel.backend.core.materials; - -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; -import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; - -import net.minecraft.client.renderer.BufferBuilder; - -public class OrientedModel extends InstancedModel { - public static final VertexFormat INSTANCE_FORMAT = VertexFormat.builder() - .addAttributes(BasicAttributes.class) - .addAttributes(OrientedAttributes.class) - .build(); - - public OrientedModel(InstancedTileRenderer renderer, BufferBuilder buf) { - super(renderer, buf); - } - - @Override - protected OrientedData newInstance() { - return new OrientedData(this); - } - - @Override - protected VertexFormat getInstanceFormat() { - return INSTANCE_FORMAT; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformedModel.java deleted file mode 100644 index 4d848b2e9..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformedModel.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.jozufozu.flywheel.backend.core.materials; - -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; -import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; - -import net.minecraft.client.renderer.BufferBuilder; - -public class TransformedModel extends InstancedModel { - public static final VertexFormat INSTANCE_FORMAT = VertexFormat.builder() - .addAttributes(BasicAttributes.class) - .addAttributes(TransformAttributes.class) - .build(); - - public TransformedModel(InstancedTileRenderer renderer, BufferBuilder buf) { - super(renderer, buf); - } - - @Override - protected ModelData newInstance() { - return new ModelData(this); - } - - @Override - protected VertexFormat getInstanceFormat() { - return INSTANCE_FORMAT; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java index eace56477..16de2eb1e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java @@ -20,6 +20,9 @@ public abstract class MappedBuffer implements AutoCloseable { protected abstract void checkAndMap(); + /** + * Make the changes in client memory available to the GPU. + */ public void flush() { if (mapped) { GL15.glUnmapBuffer(owner.type.glEnum); @@ -51,7 +54,6 @@ public abstract class MappedBuffer implements AutoCloseable { /** * Position this buffer relative to the 0-index in GPU memory. * - * @param p * @return This buffer. */ public MappedBuffer position(int p) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceFactory.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceFactory.java new file mode 100644 index 000000000..533b63af9 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceFactory.java @@ -0,0 +1,5 @@ +package com.jozufozu.flywheel.backend.instancing; + +public interface InstanceFactory { + D create(InstancedModel owner); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java index 57789e637..9409e4edf 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java @@ -17,11 +17,13 @@ import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import net.minecraft.client.renderer.BufferBuilder; -public abstract class InstancedModel extends BufferedModel { +public class InstancedModel extends BufferedModel { public static final VertexFormat FORMAT = VertexFormat.builder().addAttributes(ModelAttributes.class).build(); public final InstancedTileRenderer renderer; + protected final VertexFormat instanceFormat; + protected final InstanceFactory factory; protected GlVertexArray vao; protected GlBuffer instanceVBO; protected int glBufferSize = -1; @@ -32,11 +34,22 @@ public abstract class InstancedModel extends BufferedMod boolean anyToRemove; boolean anyToUpdate; - public InstancedModel(InstancedTileRenderer renderer, BufferBuilder buf) { - super(buf); + public InstancedModel(InstancedTileRenderer renderer, VertexFormat instanceFormat, InstanceFactory factory, BufferBuilder buf) { + super(FORMAT, buf); + this.factory = factory; + this.instanceFormat = instanceFormat; this.renderer = renderer; } + public synchronized D createInstance() { + D instanceData = factory.create(this); + instanceData.dirty = true; + anyToUpdate = true; + data.add(instanceData); + + return instanceData; + } + @Override protected void init() { vao = new GlVertexArray(); @@ -53,14 +66,6 @@ public abstract class InstancedModel extends BufferedMod setupAttributes(); } - public int instanceCount() { - return data.size(); - } - - public boolean isEmpty() { - return instanceCount() == 0; - } - protected void deleteInternal() { super.deleteInternal(); @@ -68,23 +73,13 @@ public abstract class InstancedModel extends BufferedMod vao.delete(); } - public synchronized D createInstance() { - D instanceData = newInstance(); - instanceData.dirty = true; - anyToUpdate = true; - data.add(instanceData); - - return instanceData; - } - - protected abstract D newInstance(); - protected void doRender() { vao.bind(); renderSetup(); if (glInstanceCount > 0) Backend.compat.drawInstanced.drawArraysInstanced(GL11.GL_QUADS, 0, vertexCount, glInstanceCount); + vao.unbind(); } @@ -115,22 +110,22 @@ public abstract class InstancedModel extends BufferedMod } private void informAttribDivisors() { - int staticAttributes = getModelFormat().getShaderAttributeCount(); - getInstanceFormat().vertexAttribPointers(staticAttributes); + int staticAttributes = modelFormat.getShaderAttributeCount(); + instanceFormat.vertexAttribPointers(staticAttributes); - for (int i = 0; i < getInstanceFormat().getShaderAttributeCount(); i++) { + for (int i = 0; i < instanceFormat.getShaderAttributeCount(); i++) { Backend.compat.instancedArrays.vertexAttribDivisor(i + staticAttributes, 1); } } private void clearBufferTail() { int size = data.size(); - final int offset = size * getInstanceFormat().getStride(); + final int offset = size * instanceFormat.getStride(); final int length = glBufferSize - offset; if (length > 0) { - MappedBuffer buffer = instanceVBO.getBuffer(offset, length); - buffer.putByteArray(new byte[length]); - buffer.flush(); + instanceVBO.getBuffer(offset, length) + .putByteArray(new byte[length]) + .flush(); } } @@ -139,7 +134,7 @@ public abstract class InstancedModel extends BufferedMod if (size <= 0) return; - final int stride = getInstanceFormat().getStride(); + final int stride = instanceFormat.getStride(); final BitSet dirtySet = getDirtyBitSet(); if (dirtySet.isEmpty()) return; @@ -180,7 +175,7 @@ public abstract class InstancedModel extends BufferedMod private boolean realloc() { int size = this.data.size(); - int stride = getInstanceFormat().getStride(); + int stride = instanceFormat.getStride(); int requiredSize = size * stride; if (requiredSize > glBufferSize) { glBufferSize = requiredSize + stride * 16; @@ -199,9 +194,7 @@ public abstract class InstancedModel extends BufferedMod } private void removeDeletedInstances() { - // figure out which elements are to be removed - // any exception thrown from the filter predicate at this stage - // will leave the collection unmodified + // Figure out which elements are to be removed. final int oldSize = this.data.size(); int removeCount = 0; final BitSet removeSet = new BitSet(oldSize); @@ -246,14 +239,7 @@ public abstract class InstancedModel extends BufferedMod constant.putFloat(getV(template, i)); } - @Override - protected VertexFormat getModelFormat() { - return FORMAT; - } - - protected abstract VertexFormat getInstanceFormat(); - protected int getTotalShaderAttributeCount() { - return getInstanceFormat().getShaderAttributeCount() + super.getTotalShaderAttributeCount(); + return instanceFormat.getShaderAttributeCount() + super.getTotalShaderAttributeCount(); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java index 61183820e..04a3646fc 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java @@ -46,7 +46,7 @@ public abstract class InstancedTileRenderer

{ materials = new HashMap<>(); for (MaterialSpec spec : Backend.allMaterials()) { - materials.put(spec, spec.create(this)); + materials.put(spec, new RenderMaterial<>(this, spec)); } queuedUpdates = ConcurrentHashMap.newKeySet(64); @@ -137,15 +137,15 @@ public abstract class InstancedTileRenderer

{ } @SuppressWarnings("unchecked") - public > RenderMaterial getMaterial(MaterialSpec materialType) { - return (RenderMaterial) materials.get(materialType); + public RenderMaterial getMaterial(MaterialSpec materialType) { + return (RenderMaterial) materials.get(materialType); } - public RenderMaterial> getTransformMaterial() { + public RenderMaterial getTransformMaterial() { return getMaterial(AllMaterialSpecs.TRANSFORMED); } - public RenderMaterial> getOrientedMaterial() { + public RenderMaterial getOrientedMaterial() { return getMaterial(AllMaterialSpecs.ORIENTED); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java index 8e319f98d..565cf5d41 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java @@ -1,32 +1,35 @@ package com.jozufozu.flywheel.backend.instancing; -import com.jozufozu.flywheel.backend.core.BasicProgram; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import net.minecraft.util.ResourceLocation; -public class MaterialSpec> { +public class MaterialSpec { public final ResourceLocation name; private final ProgramSpec programSpec; - private final ModelFactory modelFactory; + private final VertexFormat instanceFormat; + private final InstanceFactory instanceFactory; - public MaterialSpec(ResourceLocation name, ProgramSpec programSpec, ModelFactory modelFactory) { + public MaterialSpec(ResourceLocation name, ProgramSpec programSpec, VertexFormat instanceFormat, InstanceFactory instanceFactory) { this.name = name; this.programSpec = programSpec; - this.modelFactory = modelFactory; + this.instanceFormat = instanceFormat; + this.instanceFactory = instanceFactory; } public ProgramSpec getProgramSpec() { return programSpec; } - public ModelFactory getModelFactory() { - return modelFactory; + public VertexFormat getInstanceFormat() { + return instanceFormat; } - public

RenderMaterial create(InstancedTileRenderer

renderer) { - return new RenderMaterial<>(renderer, programSpec, modelFactory); + public InstanceFactory getInstanceFactory() { + return instanceFactory; } + } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/ModelFactory.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/ModelFactory.java deleted file mode 100644 index 74edfc7b4..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/ModelFactory.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.jozufozu.flywheel.backend.instancing; - -import net.minecraft.client.renderer.BufferBuilder; - -@FunctionalInterface -public interface ModelFactory> { - B makeModel(InstancedTileRenderer renderer, BufferBuilder buf); -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index f3994d105..7ce543169 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -3,7 +3,6 @@ package com.jozufozu.flywheel.backend.instancing; import java.util.Arrays; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.function.Supplier; import org.apache.commons.lang3.tuple.Pair; @@ -13,7 +12,6 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.PartialModel; -import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.jozufozu.flywheel.util.RenderUtil; import com.jozufozu.flywheel.util.VirtualEmptyModelData; @@ -32,33 +30,19 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; -public class RenderMaterial

> { +public class RenderMaterial

{ protected final InstancedTileRenderer

renderer; - protected final Cache models; - protected final ModelFactory factory; - protected final ProgramSpec programSpec; - protected final Predicate layerPredicate; + protected final Cache> models; + protected final MaterialSpec spec; - /** - * Creates a material that renders in the default layer (CUTOUT_MIPPED) - */ - public RenderMaterial(InstancedTileRenderer

renderer, ProgramSpec programSpec, ModelFactory factory) { - this(renderer, programSpec, factory, type -> type == RenderType.getCutoutMipped()); - } - - public RenderMaterial(InstancedTileRenderer

renderer, ProgramSpec programSpec, ModelFactory factory, Predicate layerPredicate) { + public RenderMaterial(InstancedTileRenderer

renderer, MaterialSpec spec) { this.renderer = renderer; + this.spec = spec; + this.models = CacheBuilder.newBuilder() .removalListener(notification -> ((InstancedModel) notification.getValue()).delete()) .build(); - this.factory = factory; - this.programSpec = programSpec; - this.layerPredicate = layerPredicate; - } - - public boolean canRenderInLayer(RenderType layer) { - return layerPredicate.test(layer); } public void render(RenderType layer, Matrix4f projection, double camX, double camY, double camZ) { @@ -66,9 +50,9 @@ public class RenderMaterial

setup) { - if (!canRenderInLayer(layer)) return; + if (!(layer == RenderType.getCutoutMipped())) return; - P program = renderer.context.getProgram(programSpec); + P program = renderer.context.getProgram(this.spec.getProgramSpec()); program.bind(); program.uploadViewProjection(viewProjection); program.uploadCameraPos(camX, camY, camZ); @@ -87,30 +71,30 @@ public class RenderMaterial

f) { - for (MODEL model : models.asMap().values()) { + public void runOnAll(Consumer> f) { + for (InstancedModel model : models.asMap().values()) { f.accept(model); } } - public MODEL getModel(PartialModel partial, BlockState referenceState) { + public InstancedModel getModel(PartialModel partial, BlockState referenceState) { return get(partial, () -> buildModel(partial.get(), referenceState)); } - public MODEL getModel(PartialModel partial, BlockState referenceState, Direction dir) { + public InstancedModel getModel(PartialModel partial, BlockState referenceState, Direction dir) { return getModel(partial, referenceState, dir, RenderUtil.rotateToFace(dir)); } - public MODEL getModel(PartialModel partial, BlockState referenceState, Direction dir, Supplier modelTransform) { + public InstancedModel getModel(PartialModel partial, BlockState referenceState, Direction dir, Supplier modelTransform) { return get(Pair.of(dir, partial), () -> buildModel(partial.get(), referenceState, modelTransform.get())); } - public MODEL getModel(BlockState toRender) { + public InstancedModel getModel(BlockState toRender) { return get(toRender, () -> buildModel(toRender)); } - public MODEL get(Object key, Supplier supplier) { + public InstancedModel get(Object key, Supplier> supplier) { try { return models.get(key, supplier::get); } catch (ExecutionException e) { @@ -119,19 +103,19 @@ public class RenderMaterial

buildModel(BlockState renderedState) { BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); return buildModel(dispatcher.getModelForState(renderedState), renderedState); } - private MODEL buildModel(IBakedModel model, BlockState renderedState) { + private InstancedModel buildModel(IBakedModel model, BlockState renderedState) { return buildModel(model, renderedState, new MatrixStack()); } - private MODEL buildModel(IBakedModel model, BlockState referenceState, MatrixStack ms) { + private InstancedModel buildModel(IBakedModel model, BlockState referenceState, MatrixStack ms) { BufferBuilder builder = getBufferBuilder(model, referenceState, ms); - return factory.makeModel(renderer, builder); + return new InstancedModel<>(renderer, spec.getInstanceFormat(), spec.getInstanceFactory(), builder); } private static final Direction[] dirs; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java index bec358be7..bc7e8f4d2 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/TileEntityInstance.java @@ -117,11 +117,11 @@ public abstract class TileEntityInstance implements IInsta models.forEach(model -> model.setBlockLight(block).setSkyLight(sky)); } - protected RenderMaterial> getTransformMaterial() { + protected RenderMaterial getTransformMaterial() { return renderer.getTransformMaterial(); } - protected RenderMaterial> getOrientedMaterial() { + protected RenderMaterial getOrientedMaterial() { return renderer.getOrientedMaterial(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java index 5bf761651..3525e9417 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.contraptions.base; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; @@ -85,9 +84,9 @@ public abstract class KineticTileInstance extends T return shaft(getRotationAxis()); } - protected final RenderMaterial> getRotatingMaterial() { + protected final RenderMaterial getRotatingMaterial() { return renderer.getMaterial(AllMaterialSpecs.ROTATING); - } + } public static BlockState shaft(Direction.Axis axis) { return AllBlocks.SHAFT.getDefaultState() diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java index e75eec62c..ef59d938e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java @@ -11,9 +11,9 @@ public class RotatingData extends KineticData { private byte rotationAxisY; private byte rotationAxisZ; - protected RotatingData(InstancedModel owner) { - super(owner); - } + public RotatingData(InstancedModel owner) { + super(owner); + } public RotatingData setRotationAxis(Direction.Axis axis) { Direction orientation = Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java deleted file mode 100644 index 5eaadbc5a..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingModel.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.simibubi.create.content.contraptions.base; - -import com.jozufozu.flywheel.backend.core.materials.BasicAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; -import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; - -import net.minecraft.client.renderer.BufferBuilder; - -public class RotatingModel extends InstancedModel { - public static VertexFormat FORMAT = VertexFormat.builder() - .addAttributes(BasicAttributes.class) - .addAttributes(KineticAttributes.class) - .addAttributes(RotatingAttributes.class) - .build(); - - public RotatingModel(InstancedTileRenderer renderer, BufferBuilder buf) { - super(renderer, buf); - } - - @Override - protected RotatingData newInstance() { - return new RotatingData(this); - } - - @Override - protected VertexFormat getInstanceFormat() { - return FORMAT; - } - -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java index 3d44c51ba..0d993e316 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java @@ -28,9 +28,9 @@ public class ActorData extends InstanceData { private float speed; - protected ActorData(InstancedModel owner) { - super(owner); - } + public ActorData(InstancedModel owner) { + super(owner); + } public ActorData setPosition(BlockPos pos) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorModel.java deleted file mode 100644 index 9010ba9ca..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorModel.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.simibubi.create.content.contraptions.components.actors; - -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; -import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; - -import net.minecraft.client.renderer.BufferBuilder; - -public class ActorModel extends InstancedModel { - public static VertexFormat FORMAT = VertexFormat.builder() - .addAttributes(ActorVertexAttributes.class) - .build(); - - public ActorModel(InstancedTileRenderer renderer, BufferBuilder buf) { - super(renderer, buf); - } - - @Override - protected VertexFormat getInstanceFormat() { - return FORMAT; - } - - @Override - protected ActorData newInstance() { - return new ActorData(this); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java index 517e4fcdb..e0dd37923 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.contraptions.components.actors; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; @@ -21,7 +20,7 @@ public class DrillActorInstance extends ActorInstance { public DrillActorInstance(ContraptionKineticRenderer modelManager, MovementContext context) { super(modelManager, context); - RenderMaterial> renderMaterial = modelManager.getActorMaterial(); + RenderMaterial renderMaterial = modelManager.getActorMaterial(); BlockState state = context.state; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java index 60dfede9b..e04fa94a8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java @@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.components.actors; import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; import com.jozufozu.flywheel.backend.core.materials.ModelData; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; @@ -36,7 +35,7 @@ public class HarvesterActorInstance extends ActorInstance { public HarvesterActorInstance(ContraptionKineticRenderer modelManager, MovementContext context) { super(modelManager, context); - RenderMaterial> renderMaterial = modelManager.getTransformMaterial(); + RenderMaterial renderMaterial = modelManager.getTransformMaterial(); BlockState state = context.state; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java index 544fbf41f..94b874fca 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java @@ -5,7 +5,6 @@ import static com.simibubi.create.content.contraptions.base.DirectionalKineticBl import com.jozufozu.flywheel.backend.core.PartialModel; import com.jozufozu.flywheel.backend.core.materials.ModelData; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; @@ -45,7 +44,7 @@ public class DeployerActorInstance extends ActorInstance { public DeployerActorInstance(ContraptionKineticRenderer modelManager, MovementContext context) { super(modelManager, context); - RenderMaterial> mat = modelManager.getTransformMaterial(); + RenderMaterial mat = modelManager.getTransformMaterial(); BlockState state = context.state; DeployerTileEntity.Mode mode = NBTHelper.readEnum(context.tileData, "Mode", DeployerTileEntity.Mode.class); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java index 96627328b..ef6f69d5b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlyWheelInstance.java @@ -63,15 +63,15 @@ public class FlyWheelInstance extends KineticTileInstance im connectorAngleMult = flipAngle ? -1 : 1; - RenderMaterial> mat = getTransformMaterial(); + RenderMaterial mat = getTransformMaterial(); - upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState).createInstance(); - lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState).createInstance(); - upperSliding = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_SLIDING, blockState).createInstance(); - lowerSliding = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_SLIDING, blockState).createInstance(); + upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState).createInstance(); + lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState).createInstance(); + upperSliding = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_SLIDING, blockState).createInstance(); + lowerSliding = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_SLIDING, blockState).createInstance(); - connectors = Lists.newArrayList(upperRotating, lowerRotating, upperSliding, lowerSliding); - } else { + connectors = Lists.newArrayList(upperRotating, lowerRotating, upperSliding, lowerSliding); + } else { connectors = Collections.emptyList(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java index 821cce83e..a65f178fa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java @@ -7,7 +7,6 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.simibubi.create.AllMovementBehaviours; @@ -65,9 +64,9 @@ public class ContraptionKineticRenderer extends InstancedTileRenderer> getActorMaterial() { + public RenderMaterial getActorMaterial() { return getMaterial(AllMaterialSpecs.ACTORS); - } + } public RenderedContraption getContraption() { return contraption.get(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java index 6c4d90485..acdca2f9f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java @@ -21,7 +21,7 @@ public class ContraptionModel extends BufferedModel { protected GlBuffer ebo; public ContraptionModel(BufferBuilder buf) { - super(buf); + super(FORMAT, buf); } @Override @@ -93,11 +93,6 @@ public class ContraptionModel extends BufferedModel { to.put(sky); } - @Override - protected VertexFormat getModelFormat() { - return FORMAT; - } - @Override protected void deleteInternal() { super.deleteInternal(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java index 1d4025831..29264554a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java @@ -21,9 +21,9 @@ public class BeltData extends KineticData { private float maxV; private byte scrollMult; - protected BeltData(InstancedModel owner) { - super(owner); - } + public BeltData(InstancedModel owner) { + super(owner); + } public BeltData setRotation(Quaternion q) { this.qX = q.getX(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java deleted file mode 100644 index 58dc8e651..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstancedModel.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.simibubi.create.content.contraptions.relays.belt; - -import com.jozufozu.flywheel.backend.core.materials.BasicAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; -import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; -import com.simibubi.create.content.contraptions.base.KineticAttributes; - -import net.minecraft.client.renderer.BufferBuilder; - -public class BeltInstancedModel extends InstancedModel { - public static VertexFormat FORMAT = VertexFormat.builder() - .addAttributes(BasicAttributes.class) - .addAttributes(KineticAttributes.class) - .addAttributes(BeltAttributes.class) - .build(); - - public BeltInstancedModel(InstancedTileRenderer renderer, BufferBuilder buf) { - super(renderer, buf); - } - - @Override - protected BeltData newInstance() { - return new BeltData(this); - } - - @Override - protected VertexFormat getInstanceFormat() { - return FORMAT; - } - -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java index a2847452d..39596f241 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java @@ -26,7 +26,7 @@ public class SplitShaftInstance extends KineticTileInstance> rotatingMaterial = getRotatingMaterial(); + RenderMaterial rotatingMaterial = getRotatingMaterial(); for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java index 747c6a9ec..cf85386ac 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java @@ -33,7 +33,7 @@ public class GearboxInstance extends KineticTileInstance { int skyLight = world.getLightLevel(LightType.SKY, pos); updateSourceFacing(); - RenderMaterial> rotatingMaterial = getRotatingMaterial(); + RenderMaterial rotatingMaterial = getRotatingMaterial(); for (Direction direction : Iterate.directions) { final Direction.Axis axis = direction.getAxis(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapModel.java b/src/main/java/com/simibubi/create/content/logistics/block/FlapModel.java deleted file mode 100644 index 42aeb46f5..000000000 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapModel.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.simibubi.create.content.logistics.block; - -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; -import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; - -import net.minecraft.client.renderer.BufferBuilder; - -public class FlapModel extends InstancedModel { - public static VertexFormat FORMAT = VertexFormat.builder() - .addAttributes(FlapAttributes.class) - .build(); - - public FlapModel(InstancedTileRenderer renderer, BufferBuilder buf) { - super(renderer, buf); - } - - @Override - protected FlapData newInstance() { - return new FlapData(this); - } - - @Override - protected VertexFormat getInstanceFormat() { - return FORMAT; - } -} diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java index 455659db6..42912a6a2 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java @@ -47,7 +47,7 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta public ArmInstance(InstancedTileRenderer modelManager, ArmTileEntity tile) { super(modelManager, tile); - RenderMaterial> mat = getTransformMaterial(); + RenderMaterial mat = getTransformMaterial(); base = mat.getModel(AllBlockPartials.ARM_BASE, blockState).createInstance(); lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState).createInstance(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java index 995952c78..705fde20f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverInstance.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.logistics.block.redstone; import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; @@ -27,7 +26,7 @@ public class AnalogLeverInstance extends TileEntityInstance modelManager, AnalogLeverTileEntity tile) { super(modelManager, tile); - RenderMaterial> mat = getTransformMaterial(); + RenderMaterial mat = getTransformMaterial(); handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState).createInstance(); indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState).createInstance(); diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java index 0a011f316..9568583db 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonInstance.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.schematics.block; import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import com.jozufozu.flywheel.backend.instancing.RenderMaterial; import com.jozufozu.flywheel.backend.instancing.TileEntityInstance; @@ -21,7 +20,7 @@ public class SchematicannonInstance extends TileEntityInstance modelManager, SchematicannonTileEntity tile) { super(modelManager, tile); - RenderMaterial> mat = getTransformMaterial(); + RenderMaterial mat = getTransformMaterial(); connector = mat.getModel(AllBlockPartials.SCHEMATICANNON_CONNECTOR, blockState).createInstance(); pipe = mat.getModel(AllBlockPartials.SCHEMATICANNON_PIPE, blockState).createInstance(); diff --git a/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java b/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java new file mode 100644 index 000000000..70c2bf3e6 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java @@ -0,0 +1,39 @@ +package com.simibubi.create.foundation.render; + +import com.jozufozu.flywheel.backend.core.materials.BasicAttributes; +import com.jozufozu.flywheel.backend.core.materials.OrientedAttributes; +import com.jozufozu.flywheel.backend.core.materials.TransformAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.simibubi.create.content.contraptions.base.KineticAttributes; +import com.simibubi.create.content.contraptions.base.RotatingAttributes; +import com.simibubi.create.content.contraptions.components.actors.ActorVertexAttributes; +import com.simibubi.create.content.contraptions.relays.belt.BeltAttributes; +import com.simibubi.create.content.logistics.block.FlapAttributes; + +public class AllInstanceFormats { + + public static final VertexFormat MODEL = VertexFormat.builder() + .addAttributes(BasicAttributes.class) + .addAttributes(TransformAttributes.class) + .build(); + public static final VertexFormat ORIENTED = VertexFormat.builder() + .addAttributes(BasicAttributes.class) + .addAttributes(OrientedAttributes.class) + .build(); + public static VertexFormat ROTATING = VertexFormat.builder() + .addAttributes(BasicAttributes.class) + .addAttributes(KineticAttributes.class) + .addAttributes(RotatingAttributes.class) + .build(); + public static VertexFormat ACTOR = VertexFormat.builder() + .addAttributes(ActorVertexAttributes.class) + .build(); + public static VertexFormat BELT = VertexFormat.builder() + .addAttributes(BasicAttributes.class) + .addAttributes(KineticAttributes.class) + .addAttributes(BeltAttributes.class) + .build(); + public static VertexFormat FLAP = VertexFormat.builder() + .addAttributes(FlapAttributes.class) + .build(); +} diff --git a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java index 662fb707b..a26402155 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java @@ -4,19 +4,12 @@ import static com.jozufozu.flywheel.backend.Backend.register; import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.core.materials.OrientedData; -import com.jozufozu.flywheel.backend.core.materials.OrientedModel; -import com.jozufozu.flywheel.backend.core.materials.TransformedModel; -import com.jozufozu.flywheel.backend.instancing.InstancedModel; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.RotatingData; -import com.simibubi.create.content.contraptions.base.RotatingModel; import com.simibubi.create.content.contraptions.components.actors.ActorData; -import com.simibubi.create.content.contraptions.components.actors.ActorModel; import com.simibubi.create.content.contraptions.relays.belt.BeltData; -import com.simibubi.create.content.contraptions.relays.belt.BeltInstancedModel; import com.simibubi.create.content.logistics.block.FlapData; -import com.simibubi.create.content.logistics.block.FlapModel; import net.minecraft.util.ResourceLocation; @@ -25,14 +18,13 @@ public class AllMaterialSpecs { // noop, make sure the static field are loaded. } + public static final MaterialSpec TRANSFORMED = register(new MaterialSpec<>(Locations.MODEL, AllProgramSpecs.MODEL, AllInstanceFormats.MODEL, ModelData::new)); + public static final MaterialSpec ORIENTED = register(new MaterialSpec<>(Locations.ORIENTED, AllProgramSpecs.ORIENTED, AllInstanceFormats.ORIENTED, OrientedData::new)); - public static final MaterialSpec> TRANSFORMED = register(new MaterialSpec<>(Locations.MODEL, AllProgramSpecs.MODEL, TransformedModel::new)); - public static final MaterialSpec> ORIENTED = register(new MaterialSpec<>(Locations.ORIENTED, AllProgramSpecs.ORIENTED, OrientedModel::new)); - - public static final MaterialSpec> ROTATING = register(new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, RotatingModel::new)); - public static final MaterialSpec> BELTS = register(new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, BeltInstancedModel::new)); - public static final MaterialSpec> ACTORS = register(new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, ActorModel::new)); - public static final MaterialSpec> FLAPS = register(new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, FlapModel::new)); + public static final MaterialSpec ROTATING = register(new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, AllInstanceFormats.ROTATING, RotatingData::new)); + public static final MaterialSpec BELTS = register(new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, AllInstanceFormats.BELT, BeltData::new)); + public static final MaterialSpec ACTORS = register(new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, AllInstanceFormats.ACTOR, ActorData::new)); + public static final MaterialSpec FLAPS = register(new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, AllInstanceFormats.FLAP, FlapData::new)); public static class Locations { public static final ResourceLocation MODEL = new ResourceLocation("create", "model"); diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java index a2ce90c60..eae45b987 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java @@ -13,7 +13,6 @@ import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; import com.jozufozu.flywheel.backend.gl.GlVertexArray; import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; -import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.util.RenderUtil; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -67,9 +66,9 @@ public class EffectsHandler { private static final int bufferSize = vertices.length * 4; private final Framebuffer framebuffer; - private final GlVertexArray vao = new GlVertexArray(); + private final GlVertexArray vao; - private final GlBuffer vbo = new GlBuffer(GlBufferType.ARRAY_BUFFER); + private final GlBuffer vbo; private final ArrayList spheres; @@ -79,12 +78,14 @@ public class EffectsHandler { Framebuffer render = Minecraft.getInstance().getFramebuffer(); framebuffer = new Framebuffer(render.framebufferWidth, render.framebufferHeight, false, Minecraft.IS_RUNNING_ON_MAC); + vbo = new GlBuffer(GlBufferType.ARRAY_BUFFER); vbo.bind(); vbo.alloc(bufferSize); - MappedBuffer buffer = vbo.getBuffer(0, bufferSize); - buffer.putFloatArray(vertices); - buffer.flush(); + vbo.getBuffer(0, bufferSize) + .putFloatArray(vertices) + .flush(); + vao = new GlVertexArray(); vao.bind(); GL20.glEnableVertexAttribArray(0); diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java index c04c61c36..a431579b2 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java @@ -81,8 +81,8 @@ public class SphereFilterProgram extends GlProgram { public void uploadFilters(ArrayList filters) { effectsUBO.bind(GlBufferType.ARRAY_BUFFER); - MappedBuffer buffer = effectsUBO.getBuffer(0, BUFFER_SIZE); - buffer.putInt(filters.size()) + MappedBuffer buffer = effectsUBO.getBuffer(0, BUFFER_SIZE) + .putInt(filters.size()) .position(16); filters.forEach(it -> it.write(buffer)); From 6227e81066630f77c4699bc0d691b57dce4e0600 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sun, 16 May 2021 15:39:52 -0700 Subject: [PATCH 059/198] TemplateBuffer is no more - Instead, BufferBuilderReader can decode parts of a BufferBuilder. - BufferedModel and its subclasses are now created directly with a ByteBuffer. - ContraptionModel renamed to IndexedModel. - InstancedModel and IndexedModel both now take model formats as arguments. - All of this allows for better abstraction, composition, and control of models rendered with Flywheel. --- .../backend/{ => core}/BufferedModel.java | 33 ++--- .../flywheel/backend/core/IndexedModel.java | 69 ++++++++++ .../flywheel/backend/gl/buffer/GlBuffer.java | 2 +- .../backend/gl/buffer/MappedBuffer.java | 6 + .../backend/instancing/InstancedModel.java | 25 +--- .../backend/instancing/RenderMaterial.java | 31 ++++- .../flywheel/util/BufferBuilderReader.java | 106 +++++++++++++++ .../render/ContraptionModel.java | 101 --------------- .../render/RenderedContraption.java | 121 +++++++++++++----- .../foundation/render/SuperByteBuffer.java | 57 ++++----- .../foundation/render/TemplateBuffer.java | 101 --------------- 11 files changed, 340 insertions(+), 312 deletions(-) rename src/main/java/com/jozufozu/flywheel/backend/{ => core}/BufferedModel.java (69%) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java create mode 100644 src/main/java/com/jozufozu/flywheel/util/BufferBuilderReader.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/TemplateBuffer.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java similarity index 69% rename from src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java rename to src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java index 934ba2722..28825202c 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/BufferedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java @@ -1,33 +1,35 @@ -package com.jozufozu.flywheel.backend; +package com.jozufozu.flywheel.backend.core; + +import java.nio.ByteBuffer; -import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; +import com.jozufozu.flywheel.backend.RenderWork; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; -import com.simibubi.create.foundation.render.TemplateBuffer; -import net.minecraft.client.renderer.BufferBuilder; - -public abstract class BufferedModel extends TemplateBuffer { +public abstract class BufferedModel { + protected final ByteBuffer data; protected final VertexFormat modelFormat; + protected final int vertexCount; protected GlBuffer modelVBO; private boolean initialized; // lazy init private boolean removed; - protected BufferedModel(VertexFormat modelFormat, BufferBuilder buf) { - super(buf); + protected BufferedModel(VertexFormat modelFormat, ByteBuffer data, int vertices) { + this.data = data; this.modelFormat = modelFormat; + this.vertexCount = vertices; } /** * Renders this model, checking first if there is anything to render. */ public final void render() { - if (vertexCount == 0 || removed) return; + if (vertexCount <= 0 || removed) return; if (!initialized) { // Lazily acquire resources in order to get around initialization order, as #getTotalShaderAttributeCount @@ -60,22 +62,15 @@ public abstract class BufferedModel extends TemplateBuffer { } protected void initModel() { - int stride = modelFormat.getStride(); - int invariantSize = vertexCount * stride; - // allocate the buffer on the gpu - GL15.glBufferData(GL15.GL_ARRAY_BUFFER, invariantSize, GL15.GL_STATIC_DRAW); + modelVBO.alloc(data.capacity()); // mirror it in system memory so we can write to it - MappedBuffer buffer = modelVBO.getBuffer(0, invariantSize); - for (int i = 0; i < vertexCount; i++) { - copyVertex(buffer, i); - } + MappedBuffer buffer = modelVBO.getBuffer(0, data.capacity()); + buffer.put(data); buffer.flush(); } - protected abstract void copyVertex(MappedBuffer to, int index); - protected int getTotalShaderAttributeCount() { return modelFormat.getShaderAttributeCount(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java new file mode 100644 index 000000000..1372a13ca --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java @@ -0,0 +1,69 @@ +package com.jozufozu.flywheel.backend.core; + +import java.nio.ByteBuffer; + +import org.lwjgl.opengl.GL20; + +import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; +import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; + +public class IndexedModel extends BufferedModel { + + protected GlPrimitiveType eboIndexType; + protected GlBuffer ebo; + + public IndexedModel(VertexFormat modelFormat, ByteBuffer buf, int vertices) { + super(modelFormat, buf, vertices); + } + + @Override + protected void init() { + super.init(); + + createEBO(); + } + + @Override + protected void doRender() { + modelVBO.bind(); + ebo.bind(); + + setupAttributes(); + GL20.glDrawElements(GL20.GL_QUADS, vertexCount, eboIndexType.getGlConstant(), 0); + + int numAttributes = getTotalShaderAttributeCount(); + for (int i = 0; i <= numAttributes; i++) { + GL20.glDisableVertexAttribArray(i); + } + + ebo.unbind(); + modelVBO.unbind(); + } + + protected final void createEBO() { + ebo = new GlBuffer(GlBufferType.ELEMENT_ARRAY_BUFFER); + eboIndexType = GlPrimitiveType.UINT; // TODO: choose this based on the number of vertices + + int indicesSize = vertexCount * eboIndexType.getSize(); + + ebo.bind(); + + ebo.alloc(indicesSize); + MappedBuffer indices = ebo.getBuffer(0, indicesSize); + for (int i = 0; i < vertexCount; i++) { + indices.putInt(i); + } + indices.flush(); + + ebo.unbind(); + } + + @Override + protected void deleteInternal() { + super.deleteInternal(); + ebo.delete(); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBuffer.java index c3c2da51a..4430fa76d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBuffer.java @@ -48,7 +48,7 @@ public class GlBuffer extends GlObject { } public MappedBuffer getBuffer(int offset, int length) { - if (Backend.compat.mapBufferRange == MapBufferRange.UNSUPPORTED) { + if (Backend.compat.mapBufferRange != MapBufferRange.UNSUPPORTED) { return new MappedBufferRange(this, offset, length, GL30.GL_MAP_WRITE_BIT); } else { MappedFullBuffer fullBuffer = new MappedFullBuffer(this, MappedBufferUsage.WRITE_ONLY); diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java index 16de2eb1e..f8ee93fdc 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java @@ -80,6 +80,12 @@ public abstract class MappedBuffer implements AutoCloseable { return this; } + public MappedBuffer put(ByteBuffer b) { + checkAndMap(); + internal.put(b); + return this; + } + public MappedBuffer putVec4(float x, float y, float z, float w) { checkAndMap(); internal.putFloat(x); diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java index 9409e4edf..a70108cbe 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java @@ -1,24 +1,21 @@ package com.jozufozu.flywheel.backend.instancing; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.BitSet; import org.lwjgl.opengl.GL11; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.BufferedModel; -import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; +import com.jozufozu.flywheel.backend.core.BufferedModel; import com.jozufozu.flywheel.backend.gl.GlVertexArray; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; -import net.minecraft.client.renderer.BufferBuilder; - public class InstancedModel extends BufferedModel { - public static final VertexFormat FORMAT = VertexFormat.builder().addAttributes(ModelAttributes.class).build(); public final InstancedTileRenderer renderer; @@ -34,8 +31,8 @@ public class InstancedModel extends BufferedModel { boolean anyToRemove; boolean anyToUpdate; - public InstancedModel(InstancedTileRenderer renderer, VertexFormat instanceFormat, InstanceFactory factory, BufferBuilder buf) { - super(FORMAT, buf); + public InstancedModel(VertexFormat modelFormat, ByteBuffer buf, int vertices, InstancedTileRenderer renderer, VertexFormat instanceFormat, InstanceFactory factory) { + super(modelFormat, buf, vertices); this.factory = factory; this.instanceFormat = instanceFormat; this.renderer = renderer; @@ -225,20 +222,6 @@ public class InstancedModel extends BufferedModel { } - @Override - protected void copyVertex(MappedBuffer constant, int i) { - constant.putFloat(getX(template, i)); - constant.putFloat(getY(template, i)); - constant.putFloat(getZ(template, i)); - - constant.put(getNX(template, i)); - constant.put(getNY(template, i)); - constant.put(getNZ(template, i)); - - constant.putFloat(getU(template, i)); - constant.putFloat(getV(template, i)); - } - protected int getTotalShaderAttributeCount() { return instanceFormat.getShaderAttributeCount() + super.getTotalShaderAttributeCount(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index 7ce543169..19f0c8fcb 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -1,5 +1,7 @@ package com.jozufozu.flywheel.backend.instancing; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.util.Arrays; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; @@ -12,7 +14,10 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; +import com.jozufozu.flywheel.util.BufferBuilderReader; import com.jozufozu.flywheel.util.RenderUtil; import com.jozufozu.flywheel.util.VirtualEmptyModelData; import com.mojang.blaze3d.matrix.MatrixStack; @@ -31,6 +36,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; public class RenderMaterial

{ + public static final VertexFormat MODEL_FORMAT = VertexFormat.builder().addAttributes(ModelAttributes.class).build(); protected final InstancedTileRenderer

renderer; protected final Cache> models; @@ -113,9 +119,30 @@ public class RenderMaterial

{ } private InstancedModel buildModel(IBakedModel model, BlockState referenceState, MatrixStack ms) { - BufferBuilder builder = getBufferBuilder(model, referenceState, ms); + BufferBuilderReader reader = new BufferBuilderReader(getBufferBuilder(model, referenceState, ms)); - return new InstancedModel<>(renderer, spec.getInstanceFormat(), spec.getInstanceFactory(), builder); + VertexFormat format = MODEL_FORMAT; + int vertexCount = reader.getVertexCount(); + + ByteBuffer to = ByteBuffer.allocate(vertexCount * format.getStride()); + to.order(ByteOrder.nativeOrder()); + + for (int i = 0; i < vertexCount; i++) { + to.putFloat(reader.getX(i)); + to.putFloat(reader.getY(i)); + to.putFloat(reader.getZ(i)); + + to.put(reader.getNX(i)); + to.put(reader.getNY(i)); + to.put(reader.getNZ(i)); + + to.putFloat(reader.getU(i)); + to.putFloat(reader.getV(i)); + } + + to.rewind(); + + return new InstancedModel<>(format, to, vertexCount, renderer, spec.getInstanceFormat(), spec.getInstanceFactory()); } private static final Direction[] dirs; diff --git a/src/main/java/com/jozufozu/flywheel/util/BufferBuilderReader.java b/src/main/java/com/jozufozu/flywheel/util/BufferBuilderReader.java new file mode 100644 index 000000000..15a6e1390 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/util/BufferBuilderReader.java @@ -0,0 +1,106 @@ +package com.jozufozu.flywheel.util; + +import java.nio.ByteBuffer; + +import com.mojang.datafixers.util.Pair; + +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.vertex.VertexFormat; + +public class BufferBuilderReader { + + private final ByteBuffer buffer; + private final int vertexCount; + private final int formatSize; + private final int size; + + public BufferBuilderReader(BufferBuilder builder) { + VertexFormat vertexFormat = builder.getVertexFormat(); + Pair data = builder.popData(); + buffer = data.getSecond(); + + formatSize = vertexFormat.getSize(); + + vertexCount = data.getFirst() + .getCount(); + + size = vertexCount * formatSize; + + // TODO: adjust the getters based on the input format +// ImmutableList elements = vertexFormat.getElements(); +// for (int i = 0, size = elements.size(); i < size; i++) { +// VertexFormatElement element = elements.get(i); +// int offset = vertexFormat.getOffset(i); +// +// element.getUsage() +// } + } + + public boolean isEmpty() { + return vertexCount == 0; + } + + public int vertIdx(int vertexIndex) { + return vertexIndex * formatSize; + } + + public float getX(int index) { + return buffer.getFloat(vertIdx(index)); + } + + public float getY(int index) { + return buffer.getFloat(vertIdx(index) + 4); + } + + public float getZ(int index) { + return buffer.getFloat(vertIdx(index) + 8); + } + + public byte getR(int index) { + return buffer.get(vertIdx(index) + 12); + } + + public byte getG(int index) { + return buffer.get(vertIdx(index) + 13); + } + + public byte getB(int index) { + return buffer.get(vertIdx(index) + 14); + } + + public byte getA(int index) { + return buffer.get(vertIdx(index) + 15); + } + + public float getU(int index) { + return buffer.getFloat(vertIdx(index) + 16); + } + + public float getV(int index) { + return buffer.getFloat(vertIdx(index) + 20); + } + + public int getLight(int index) { + return buffer.getInt(vertIdx(index) + 24); + } + + public byte getNX(int index) { + return buffer.get(vertIdx(index) + 28); + } + + public byte getNY(int index) { + return buffer.get(vertIdx(index) + 29); + } + + public byte getNZ(int index) { + return buffer.get(vertIdx(index) + 30); + } + + public int getVertexCount() { + return vertexCount; + } + + public int getSize() { + return size; + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java deleted file mode 100644 index acdca2f9f..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionModel.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.simibubi.create.content.contraptions.components.structureMovement.render; - -import org.lwjgl.opengl.GL20; - -import com.jozufozu.flywheel.backend.BufferedModel; -import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; -import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; -import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; - -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.LightTexture; - -public class ContraptionModel extends BufferedModel { - public static final VertexFormat FORMAT = VertexFormat.builder() - .addAttributes(ContraptionAttributes.class) - .build(); - - protected GlPrimitiveType eboIndexType; - protected GlBuffer ebo; - - public ContraptionModel(BufferBuilder buf) { - super(FORMAT, buf); - } - - @Override - protected void init() { - super.init(); - - createEBO(); - } - - @Override - protected void doRender() { - modelVBO.bind(); - ebo.bind(); - - setupAttributes(); - GL20.glDrawElements(GL20.GL_QUADS, vertexCount, eboIndexType.getGlConstant(), 0); - - int numAttributes = getTotalShaderAttributeCount(); - for (int i = 0; i <= numAttributes; i++) { - GL20.glDisableVertexAttribArray(i); - } - - ebo.unbind(); - modelVBO.unbind(); - } - - protected final void createEBO() { - ebo = new GlBuffer(GlBufferType.ELEMENT_ARRAY_BUFFER); - eboIndexType = GlPrimitiveType.UINT; // TODO: choose this based on the number of vertices - - int indicesSize = vertexCount * eboIndexType.getSize(); - - ebo.bind(); - - ebo.alloc(indicesSize); - MappedBuffer indices = ebo.getBuffer(0, indicesSize); - for (int i = 0; i < vertexCount; i++) { - indices.putInt(i); - } - indices.flush(); - - ebo.unbind(); - } - - @Override - protected void copyVertex(MappedBuffer to, int vertex) { - to.putFloat(getX(template, vertex)); - to.putFloat(getY(template, vertex)); - to.putFloat(getZ(template, vertex)); - - to.put(getNX(template, vertex)); - to.put(getNY(template, vertex)); - to.put(getNZ(template, vertex)); - - to.putFloat(getU(template, vertex)); - to.putFloat(getV(template, vertex)); - - to.put(getR(template, vertex)); - to.put(getG(template, vertex)); - to.put(getB(template, vertex)); - to.put(getA(template, vertex)); - - int light = getLight(template, vertex); - - byte block = (byte) (LightTexture.getBlockLightCoordinates(light) << 4); - byte sky = (byte) (LightTexture.getSkyLightCoordinates(light) << 4); - - to.put(block); - to.put(sky); - } - - @Override - protected void deleteInternal() { - super.deleteInternal(); - ebo.delete(); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index d847b9cd8..079ae0524 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -1,16 +1,23 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; +import javax.annotation.Nullable; + import org.lwjgl.opengl.GL11; import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.core.IndexedModel; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.jozufozu.flywheel.backend.light.GridAlignedBB; +import com.jozufozu.flywheel.util.BufferBuilderReader; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; @@ -25,6 +32,7 @@ import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.BlockModelRenderer; import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.texture.OverlayTexture; @@ -40,17 +48,21 @@ import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.model.data.EmptyModelData; public class RenderedContraption { - private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); - private static final BlockModelShapes BLOCK_MODELS = Minecraft.getInstance().getModelManager().getBlockModelShapes(); + public static final VertexFormat FORMAT = VertexFormat.builder() + .addAttributes(ContraptionAttributes.class) + .build(); - public Contraption contraption; - private final ContraptionLighter lighter; - public final ContraptionKineticRenderer kinetics; - public final PlacementSimulationWorld renderWorld; + private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); + private static final BlockModelShapes BLOCK_MODELS = Minecraft.getInstance().getModelManager().getBlockModelShapes(); - private final Map renderLayers = new HashMap<>(); + public Contraption contraption; + private final ContraptionLighter lighter; + public final ContraptionKineticRenderer kinetics; + public final PlacementSimulationWorld renderWorld; - private Matrix4f model; + private final Map renderLayers = new HashMap<>(); + + private Matrix4f model; private AxisAlignedBB lightBox; public RenderedContraption(World world, Contraption contraption) { @@ -79,7 +91,7 @@ public class RenderedContraption { } public void doRenderLayer(RenderType layer, ContraptionProgram shader) { - ContraptionModel structure = renderLayers.get(layer); + IndexedModel structure = renderLayers.get(layer); if (structure != null) { setup(shader); structure.render(); @@ -120,9 +132,9 @@ public class RenderedContraption { } void invalidate() { - for (ContraptionModel buffer : renderLayers.values()) { - buffer.delete(); - } + for (IndexedModel buffer : renderLayers.values()) { + buffer.delete(); + } renderLayers.clear(); lighter.lightVolume.delete(); @@ -131,17 +143,18 @@ public class RenderedContraption { } private void buildLayers() { - for (ContraptionModel buffer : renderLayers.values()) { - buffer.delete(); - } + for (IndexedModel buffer : renderLayers.values()) { + buffer.delete(); + } renderLayers.clear(); List blockLayers = RenderType.getBlockLayers(); for (RenderType layer : blockLayers) { - renderLayers.put(layer, buildStructureModel(renderWorld, contraption, layer)); - } + IndexedModel layerModel = buildStructureModel(renderWorld, contraption, layer); + if (layerModel != null) renderLayers.put(layer, layerModel); + } } private void buildInstancedTiles() { @@ -153,29 +166,67 @@ public class RenderedContraption { BlockPos pos = te.getPos(); te.setLocation(renderWorld, pos); kinetics.add(te); - te.setLocation(world, pos); - } - } - } - } + te.setLocation(world, pos); + } + } + } + } - private void buildActors() { - contraption.getActors().forEach(kinetics::createActor); - } + private void buildActors() { + contraption.getActors().forEach(kinetics::createActor); + } - private static ContraptionModel buildStructureModel(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { - BufferBuilder builder = buildStructure(renderWorld, c, layer); - return new ContraptionModel(builder); - } + @Nullable + private static IndexedModel buildStructureModel(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { + BufferBuilderReader reader = new BufferBuilderReader(buildStructure(renderWorld, c, layer)); - private static PlacementSimulationWorld setupRenderWorld(World world, Contraption c) { - PlacementSimulationWorld renderWorld = new PlacementSimulationWorld(world); + int vertexCount = reader.getVertexCount(); + if (vertexCount == 0) return null; - renderWorld.setTileEntities(c.presentTileEntities.values()); + VertexFormat format = FORMAT; - for (Template.BlockInfo info : c.getBlocks() - .values()) - // Skip individual lighting updates to prevent lag with large contraptions + ByteBuffer to = ByteBuffer.allocate(format.getStride() * vertexCount); + to.order(ByteOrder.nativeOrder()); + + for (int i = 0; i < vertexCount; i++) { + to.putFloat(reader.getX(i)); + to.putFloat(reader.getY(i)); + to.putFloat(reader.getZ(i)); + + to.put(reader.getNX(i)); + to.put(reader.getNY(i)); + to.put(reader.getNZ(i)); + + to.putFloat(reader.getU(i)); + to.putFloat(reader.getV(i)); + + to.put(reader.getR(i)); + to.put(reader.getG(i)); + to.put(reader.getB(i)); + to.put(reader.getA(i)); + + int light = reader.getLight(i); + + byte block = (byte) (LightTexture.getBlockLightCoordinates(light) << 4); + byte sky = (byte) (LightTexture.getSkyLightCoordinates(light) << 4); + + to.put(block); + to.put(sky); + } + + to.rewind(); + + return new IndexedModel(format, to, vertexCount); + } + + private static PlacementSimulationWorld setupRenderWorld(World world, Contraption c) { + PlacementSimulationWorld renderWorld = new PlacementSimulationWorld(world); + + renderWorld.setTileEntities(c.presentTileEntities.values()); + + for (Template.BlockInfo info : c.getBlocks() + .values()) + // Skip individual lighting updates to prevent lag with large contraptions renderWorld.setBlockState(info.pos, info.state, 128); renderWorld.updateLightSources(); diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index f3ff7ef80..94fbde2ab 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -1,8 +1,6 @@ package com.simibubi.create.foundation.render; -import java.nio.Buffer; -import java.nio.ByteBuffer; - +import com.jozufozu.flywheel.util.BufferBuilderReader; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; @@ -26,12 +24,9 @@ import net.minecraft.world.LightType; import net.minecraft.world.World; import net.minecraftforge.client.model.pipeline.LightUtil; -public class SuperByteBuffer extends TemplateBuffer { - - public interface IVertexLighter { - public int getPackedLight(float x, float y, float z); - } +public class SuperByteBuffer { + private final BufferBuilderReader template; // Vertex Position private MatrixStack transforms; @@ -49,7 +44,7 @@ public class SuperByteBuffer extends TemplateBuffer { private int r, g, b, a; public SuperByteBuffer(BufferBuilder buf) { - super(buf); + template = new BufferBuilderReader(buf); transforms = new MatrixStack(); } @@ -70,22 +65,20 @@ public class SuperByteBuffer extends TemplateBuffer { Vector4f lightPos = new Vector4f(); public void renderInto(MatrixStack input, IVertexBuilder builder) { - ByteBuffer buffer = template; - if (((Buffer) buffer).limit() == 0) + if (isEmpty()) return; - ((Buffer) buffer).rewind(); Matrix3f normalMat = transforms.peek() - .getNormal() - .copy(); + .getNormal() + .copy(); // normalMat.multiply(transforms.peek().getNormal()); Matrix4f modelMat = input.peek() - .getModel() - .copy(); + .getModel() + .copy(); Matrix4f localTransforms = transforms.peek() - .getModel(); + .getModel(); modelMat.multiply(localTransforms); if (shouldLight && lightTransform != null) { @@ -94,18 +87,18 @@ public class SuperByteBuffer extends TemplateBuffer { } float f = .5f; - int vertexCount = vertexCount(buffer); + int vertexCount = template.getVertexCount(); for (int i = 0; i < vertexCount; i++) { - float x = getX(buffer, i); - float y = getY(buffer, i); - float z = getZ(buffer, i); - byte r = getR(buffer, i); - byte g = getG(buffer, i); - byte b = getB(buffer, i); - byte a = getA(buffer, i); - float normalX = getNX(buffer, i) / 127f; - float normalY = getNY(buffer, i) / 127f; - float normalZ = getNZ(buffer, i) / 127f; + float x = template.getX(i); + float y = template.getY(i); + float z = template.getZ(i); + byte r = template.getR(i); + byte g = template.getG(i); + byte b = template.getB(i); + byte a = template.getA(i); + float normalX = template.getNX(i) / 127f; + float normalY = template.getNY(i) / 127f; + float normalZ = template.getNZ(i) / 127f; float staticDiffuse = LightUtil.diffuseLight(normalX, normalY, normalZ); normal.set(normalX, normalY, normalZ); @@ -134,8 +127,8 @@ public class SuperByteBuffer extends TemplateBuffer { builder.color(colorR, colorG, colorB, a); } - float u = getU(buffer, i); - float v = getV(buffer, i); + float u = template.getU(i); + float v = template.getV(i); if (spriteShiftFunc != null) { spriteShiftFunc.shift(builder, u, v); @@ -156,7 +149,7 @@ public class SuperByteBuffer extends TemplateBuffer { } builder.light(light); } else - builder.light(getLight(buffer, i)); + builder.light(template.getLight(i)); builder.normal(nx, ny, nz) .endVertex(); @@ -297,7 +290,7 @@ public class SuperByteBuffer extends TemplateBuffer { } public boolean isEmpty() { - return ((Buffer) template).limit() == 0; + return template.isEmpty(); } @FunctionalInterface diff --git a/src/main/java/com/simibubi/create/foundation/render/TemplateBuffer.java b/src/main/java/com/simibubi/create/foundation/render/TemplateBuffer.java deleted file mode 100644 index 5f3eef7b5..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/TemplateBuffer.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.simibubi.create.foundation.render; - -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import com.mojang.datafixers.util.Pair; - -import net.minecraft.client.renderer.BufferBuilder; - -public class TemplateBuffer { - protected ByteBuffer template; - protected int formatSize; - protected int vertexCount; - - public TemplateBuffer() { - - } - - public TemplateBuffer(BufferBuilder buf) { - Pair state = buf.popData(); - ByteBuffer rendered = state.getSecond(); - rendered.order(ByteOrder.nativeOrder()); // Vanilla bug, endianness does not carry over into sliced buffers - - formatSize = buf.getVertexFormat() - .getSize(); - vertexCount = state.getFirst() - .getCount(); - int size = vertexCount * formatSize; - - template = ByteBuffer.allocate(size); - template.order(rendered.order()); - ((Buffer) template).limit(((Buffer) rendered).limit()); - template.put(rendered); - ((Buffer) template).rewind(); - } - - public boolean isEmpty() { - return ((Buffer) template).limit() == 0; - } - - protected int vertexCount(ByteBuffer buffer) { - return ((Buffer) buffer).limit() / formatSize; - } - - protected int getBufferPosition(int vertexIndex) { - return vertexIndex * formatSize; - } - - protected float getX(ByteBuffer buffer, int index) { - return buffer.getFloat(getBufferPosition(index)); - } - - protected float getY(ByteBuffer buffer, int index) { - return buffer.getFloat(getBufferPosition(index) + 4); - } - - protected float getZ(ByteBuffer buffer, int index) { - return buffer.getFloat(getBufferPosition(index) + 8); - } - - protected byte getR(ByteBuffer buffer, int index) { - return buffer.get(getBufferPosition(index) + 12); - } - - protected byte getG(ByteBuffer buffer, int index) { - return buffer.get(getBufferPosition(index) + 13); - } - - protected byte getB(ByteBuffer buffer, int index) { - return buffer.get(getBufferPosition(index) + 14); - } - - protected byte getA(ByteBuffer buffer, int index) { - return buffer.get(getBufferPosition(index) + 15); - } - - protected float getU(ByteBuffer buffer, int index) { - return buffer.getFloat(getBufferPosition(index) + 16); - } - - protected float getV(ByteBuffer buffer, int index) { - return buffer.getFloat(getBufferPosition(index) + 20); - } - - protected int getLight(ByteBuffer buffer, int index) { - return buffer.getInt(getBufferPosition(index) + 24); - } - - protected byte getNX(ByteBuffer buffer, int index) { - return buffer.get(getBufferPosition(index) + 28); - } - - protected byte getNY(ByteBuffer buffer, int index) { - return buffer.get(getBufferPosition(index) + 29); - } - - protected byte getNZ(ByteBuffer buffer, int index) { - return buffer.get(getBufferPosition(index) + 30); - } -} From 61b101f0c6c4ae203464d52d82af6ecc93be8f81 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sun, 16 May 2021 18:42:56 -0700 Subject: [PATCH 060/198] Refactor contraption matrices - Create ContraptionMatrices class for better management of matrices during the contraption rendering process - Fix diffuse lighting when rendering contraptions without Flywheel - Clean up TileEntityRenderHelper - Add disableDiffuseTransform to SuperByteBuffer and fix light calculation logic --- .../actors/DrillMovementBehaviour.java | 6 +- .../components/actors/DrillRenderer.java | 26 ++-- .../actors/HarvesterMovementBehaviour.java | 6 +- .../components/actors/HarvesterRenderer.java | 8 +- .../PortableStorageInterfaceMovement.java | 6 +- .../PortableStorageInterfaceRenderer.java | 44 +++--- .../actors/SawMovementBehaviour.java | 6 +- .../deployer/DeployerMovementBehaviour.java | 6 +- .../components/deployer/DeployerRenderer.java | 30 ++-- .../components/saw/SawRenderer.java | 36 ++--- .../AbstractContraptionEntity.java | 2 +- .../ContraptionEntityRenderer.java | 35 ++--- .../structureMovement/MovementBehaviour.java | 4 +- .../StabilizedBearingMovementBehaviour.java | 9 +- .../render/ContraptionMatrices.java | 65 +++++++++ .../render/ContraptionRenderDispatcher.java | 66 ++++----- .../render/RenderedContraption.java | 2 +- .../schematics/client/SchematicRenderer.java | 3 +- .../ponder/elements/WorldSectionElement.java | 2 +- .../foundation/render/SuperByteBuffer.java | 131 ++++++++++-------- .../render/TileEntityRenderHelper.java | 55 +++++--- 21 files changed, 314 insertions(+), 234 deletions(-) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionMatrices.java diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java index e6bc4a8e4..34ab5045f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java @@ -3,10 +3,10 @@ package com.simibubi.create.content.contraptions.components.actors; import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; @@ -36,9 +36,9 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour { @Override @OnlyIn(value = Dist.CLIENT) public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { if (!Backend.canUseInstancing()) - DrillRenderer.renderInContraption(context, renderWorld, ms, msLocal, buffer); + DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java index 127a29185..83b472863 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java @@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -32,8 +33,7 @@ public class DrillRenderer extends KineticTileEntityRenderer { } public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal}; + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { BlockState state = context.state; SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.DRILL_HEAD, state); Direction facing = state.get(DrillBlock.FACING); @@ -44,18 +44,22 @@ public class DrillRenderer extends KineticTileEntityRenderer { float time = AnimationTickHolder.getRenderTime() / 20; float angle = (float) (((time * speed) % 360)); - for (MatrixStack m : matrixStacks) - MatrixStacker.of(m) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing)) - .rotateZ(angle) - .unCentre(); + MatrixStack m = matrices.contraptionStack; + m.push(); + MatrixStacker.of(m) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(AngleHelper.verticalAngle(facing)) + .rotateZ(angle) + .unCentre(); superBuffer - .light(msLocal.peek().getModel(), + .transform(matrices.contraptionStack) + .light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getSolid())); + + m.pop(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java index 440ce6051..a0a993c24 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -7,11 +7,11 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.mutable.MutableBoolean; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; @@ -54,9 +54,9 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { @Override public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffers) { + ContraptionMatrices matrices, IRenderTypeBuffer buffers) { if (!Backend.canUseInstancing()) - HarvesterRenderer.renderInContraption(context, renderWorld, ms, msLocal, buffers); + HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java index 316c48364..3ab34b532 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java @@ -5,6 +5,7 @@ import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FAC import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -41,7 +42,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer sbb.light(msLocal.peek() - .getModel(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) - .renderInto(ms, vb), ms, msLocal); + render(blockState, progress, lit, sbb -> sbb.transform(matrices.contraptionStack) + .disableDiffuseTransform() + .light(matrices.entityMatrix, + ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + .renderInto(matrices.entityStack, vb), matrices.contraptionStack); } private static void render(BlockState blockState, float progress, boolean lit, - Consumer drawCallback, MatrixStack... matrixStacks) { - for (MatrixStack ms : matrixStacks) - ms.push(); + Consumer drawCallback, MatrixStack ms) { + ms.push(); SuperByteBuffer middle = PartialBufferer.get(getMiddleForState(blockState, lit), blockState); SuperByteBuffer top = PartialBufferer.get(getTopForState(blockState), blockState); Direction facing = blockState.get(PortableStorageInterfaceBlock.FACING); - for (MatrixStack ms : matrixStacks) - MatrixStacker.of(ms) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) - .unCentre(); + MatrixStacker.of(ms) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) + .unCentre(); - for (MatrixStack ms : matrixStacks) { - ms.translate(0, progress / 2f, 0); - ms.push(); - ms.translate(0, 6 / 16f, 0); - } + ms.translate(0, progress / 2f, 0); + ms.push(); + ms.translate(0, 6 / 16f, 0); drawCallback.accept(middle); - for (MatrixStack ms : matrixStacks) { - ms.pop(); - ms.translate(0, progress / 2f, 0); - } + ms.pop(); + ms.translate(0, progress / 2f, 0); drawCallback.accept(top); - for (MatrixStack ms : matrixStacks) - ms.pop(); + ms.pop(); } protected static PortableStorageInterfaceTileEntity getTargetPSI(MovementContext context) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index 494b8c183..375445b5f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.components.actors; -import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.saw.SawBlock; import com.simibubi.create.content.contraptions.components.saw.SawRenderer; import com.simibubi.create.content.contraptions.components.saw.SawTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.foundation.utility.TreeCutter; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; @@ -77,8 +77,8 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { @Override @OnlyIn(value = Dist.CLIENT) public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - SawRenderer.renderInContraption(context, renderWorld, ms, msLocal, buffer); + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { + SawRenderer.renderInContraption(context, renderWorld, matrices, buffer); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java index d8220145b..a8d81c209 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -8,7 +8,6 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.backend.Backend; -import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllTags.AllBlockTags; @@ -18,6 +17,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.logistics.item.filter.FilterItem; import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.SchematicWorld; @@ -256,9 +256,9 @@ public class DeployerMovementBehaviour extends MovementBehaviour { @Override public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffers) { + ContraptionMatrices matrices, IRenderTypeBuffer buffers) { if (!Backend.canUseInstancing()) - DeployerRenderer.renderInContraption(context, renderWorld, ms, msLocal, buffers); + DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java index 17fc3d8fa..ccac8329a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java @@ -12,6 +12,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -36,7 +37,6 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3f; import net.minecraft.world.World; @@ -156,8 +156,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer } public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal}; + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid()); BlockState blockState = context.state; BlockPos pos = BlockPos.ZERO; @@ -167,8 +166,6 @@ public class DeployerRenderer extends SafeTileEntityRenderer SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); SuperByteBuffer hand = PartialBufferer.get(handPose, blockState); - pole = transform(world, pole, blockState, pos, true); - hand = transform(world, hand, blockState, pos, false); double factor; if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) { @@ -184,14 +181,21 @@ public class DeployerRenderer extends SafeTileEntityRenderer Vector3d offset = Vector3d.of(blockState.get(FACING) .getDirectionVec()).scale(factor); - Matrix4f lighting = msLocal.peek() - .getModel(); - for (MatrixStack m : matrixStacks) - m.translate(offset.x, offset.y, offset.z); - pole.light(lighting, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) - .renderInto(ms, builder); - hand.light(lighting, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) - .renderInto(ms, builder); + MatrixStack m = matrices.contraptionStack; + m.push(); + m.translate(offset.x, offset.y, offset.z); + + pole.transform(m); + hand.transform(m); + pole = transform(world, pole, blockState, pos, true); + hand = transform(world, hand, blockState, pos, false); + + pole.light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + .renderInto(matrices.entityStack, builder); + hand.light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + .renderInto(matrices.entityStack, builder); + + m.pop(); } static PartialModel getHandPose(DeployerTileEntity.Mode mode) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index be13853e1..bba81950a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -10,6 +10,7 @@ import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -153,10 +154,8 @@ public class SawRenderer extends SafeTileEntityRenderer { } public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal }; + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { BlockState state = context.state; - SuperByteBuffer superBuffer; Direction facing = state.get(SawBlock.FACING); Vector3d facingVec = Vector3d.of(context.state.get(SawBlock.FACING) @@ -172,6 +171,7 @@ public class SawRenderer extends SafeTileEntityRenderer { boolean shouldAnimate = (context.contraption.stalled && horizontal) || (!context.contraption.stalled && !backwards && moving); + SuperByteBuffer superBuffer; if (SawBlock.isHorizontal(state)) { if (shouldAnimate) superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state); @@ -184,22 +184,26 @@ public class SawRenderer extends SafeTileEntityRenderer { superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state); } - for (MatrixStack m : matrixStacks) { + MatrixStack m = matrices.contraptionStack; + m.push(); + MatrixStacker.of(m) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(AngleHelper.verticalAngle(facing)); + if (!SawBlock.isHorizontal(state)) MatrixStacker.of(m) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing)); - if (!SawBlock.isHorizontal(state)) - MatrixStacker.of(m) - .rotateZ(state.get(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 0 : 90); - MatrixStacker.of(m) - .unCentre(); - } + .rotateZ(state.get(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 0 : 90); + MatrixStacker.of(m) + .unCentre(); superBuffer - .light(msLocal.peek().getModel(), - ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) - .renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); + .transform(m) + .disableDiffuseTransform() + .light(matrices.entityMatrix, + ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getCutoutMipped())); + + m.pop(); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java index 5c651529a..3f442ccfd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java @@ -641,7 +641,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } @OnlyIn(Dist.CLIENT) - public abstract void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks); + public abstract void doLocalTransforms(float partialTicks, MatrixStack[] matrixStack); public static class ContraptionRotationState { public static final ContraptionRotationState NONE = new ContraptionRotationState(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionEntityRenderer.java index 271319b91..8d8ed3b62 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionEntityRenderer.java @@ -1,20 +1,19 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; -import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.culling.ClippingHelper; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; public class ContraptionEntityRenderer extends EntityRenderer { - public ContraptionEntityRenderer(EntityRendererManager p_i46179_1_) { - super(p_i46179_1_); + public ContraptionEntityRenderer(EntityRendererManager manager) { + super(manager); } @Override @@ -23,42 +22,26 @@ public class ContraptionEntityRenderer exte } @Override - public boolean shouldRender(C entity, ClippingHelper clippingHelper, double p_225626_3_, double p_225626_5_, - double p_225626_7_) { + public boolean shouldRender(C entity, ClippingHelper clippingHelper, double cameraX, double cameraY, + double cameraZ) { if (entity.getContraption() == null) return false; if (!entity.isAlive()) return false; - return super.shouldRender(entity, clippingHelper, p_225626_3_, p_225626_5_, p_225626_7_); + return super.shouldRender(entity, clippingHelper, cameraX, cameraY, cameraZ); } - + @Override public void render(C entity, float yaw, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int overlay) { super.render(entity, yaw, partialTicks, ms, buffers, overlay); - // Keep a copy of the transforms in order to determine correct lighting - MatrixStack msLocal = translateTo(entity, AnimationTickHolder.getPartialTicks()); - MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal }; - - ms.push(); - entity.doLocalTransforms(partialTicks, matrixStacks); + ContraptionMatrices matrices = new ContraptionMatrices(ms, entity); Contraption contraption = entity.getContraption(); if (contraption != null) { - ContraptionRenderDispatcher.render(entity, ms, buffers, msLocal, contraption); + ContraptionRenderDispatcher.render(entity, contraption, matrices, buffers); } - ms.pop(); - - } - - protected MatrixStack translateTo(AbstractContraptionEntity entity, float pt) { - MatrixStack matrixStack = new MatrixStack(); - double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()); - double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()); - double z = MathHelper.lerp(pt, entity.lastTickPosZ, entity.getZ()); - matrixStack.translate(x, y, z); - return matrixStack; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java index a796eea93..5c33522eb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java @@ -2,9 +2,9 @@ package com.simibubi.create.content.contraptions.components.structureMovement; import javax.annotation.Nullable; -import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -62,7 +62,7 @@ public abstract class MovementBehaviour { @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) {} + ContraptionMatrices matrices, IRenderTypeBuffer buffer) {} @OnlyIn(Dist.CLIENT) @Nullable diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java index 47a8ee094..8afaa8bcc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java @@ -4,7 +4,6 @@ import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.PartialModel; -import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity; @@ -13,6 +12,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; +import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; @@ -33,7 +33,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { @Override @OnlyIn(Dist.CLIENT) public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { if (Backend.canUseInstancing()) return; Direction facing = context.state.get(BlockStateProperties.FACING); @@ -53,13 +53,14 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { orientation = rotation; + superBuffer.transform(matrices.contraptionStack); superBuffer.rotateCentered(orientation); // render superBuffer - .light(msLocal.peek().getModel(), + .light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) - .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); + .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getSolid())); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionMatrices.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionMatrices.java new file mode 100644 index 000000000..d6e82d17d --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionMatrices.java @@ -0,0 +1,65 @@ +package com.simibubi.create.content.contraptions.components.structureMovement.render; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; +import com.simibubi.create.foundation.utility.AnimationTickHolder; + +import net.minecraft.entity.Entity; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.vector.Matrix3f; +import net.minecraft.util.math.vector.Matrix4f; + +public class ContraptionMatrices { + public final MatrixStack entityStack; + public final MatrixStack contraptionStack; + public final Matrix4f entityMatrix; + + public ContraptionMatrices(MatrixStack entityStack, AbstractContraptionEntity entity) { + this.entityStack = entityStack; + this.contraptionStack = new MatrixStack(); + float partialTicks = AnimationTickHolder.getPartialTicks(); + entity.doLocalTransforms(partialTicks, new MatrixStack[] { this.contraptionStack }); + entityMatrix = translateTo(entity, partialTicks); + } + + public MatrixStack getFinalStack() { + MatrixStack finalStack = new MatrixStack(); + transform(finalStack, entityStack); + transform(finalStack, contraptionStack); + return finalStack; + } + + public Matrix4f getFinalModel() { + Matrix4f finalModel = entityStack.peek().getModel().copy(); + finalModel.multiply(contraptionStack.peek().getModel()); + return finalModel; + } + + public Matrix3f getFinalNormal() { + Matrix3f finalNormal = entityStack.peek().getNormal().copy(); + finalNormal.multiply(contraptionStack.peek().getNormal()); + return finalNormal; + } + + public Matrix4f getFinalLight() { + Matrix4f lightTransform = entityMatrix.copy(); + lightTransform.multiply(contraptionStack.peek().getModel()); + return lightTransform; + } + + public static Matrix4f translateTo(Entity entity, float partialTicks) { + double x = MathHelper.lerp(partialTicks, entity.lastTickPosX, entity.getX()); + double y = MathHelper.lerp(partialTicks, entity.lastTickPosY, entity.getY()); + double z = MathHelper.lerp(partialTicks, entity.lastTickPosZ, entity.getZ()); + return Matrix4f.translate((float) x, (float) y, (float) z); + } + + public static void transform(MatrixStack ms, MatrixStack transform) { + ms.peek().getModel() + .multiply(transform.peek() + .getModel()); + ms.peek().getNormal() + .multiply(transform.peek() + .getNormal()); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 9c5d2665a..f098d58b8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -122,20 +122,20 @@ public class ContraptionRenderDispatcher { glActiveTexture(GL_TEXTURE0); } - public static void render(AbstractContraptionEntity entity, MatrixStack ms, IRenderTypeBuffer buffers, - MatrixStack msLocal, Contraption contraption) { + public static void render(AbstractContraptionEntity entity, Contraption contraption, + ContraptionMatrices matrices, IRenderTypeBuffer buffers) { World world = entity.world; if (Backend.canUseVBOs() && Backend.isFlywheelWorld(world)) { RenderedContraption renderer = getRenderer(world, contraption); PlacementSimulationWorld renderWorld = renderer.renderWorld; - ContraptionRenderDispatcher.renderDynamic(world, renderWorld, contraption, ms, msLocal, buffers); + ContraptionRenderDispatcher.renderDynamic(world, renderWorld, contraption, matrices, buffers); } else { ContraptionWorldHolder holder = getWorldHolder(world, contraption); PlacementSimulationWorld renderWorld = holder.renderWorld; - ContraptionRenderDispatcher.renderDynamic(world, renderWorld, contraption, ms, msLocal, buffers); - ContraptionRenderDispatcher.renderStructure(world, renderWorld, contraption, ms, msLocal, buffers); + ContraptionRenderDispatcher.renderDynamic(world, renderWorld, contraption, matrices, buffers); + ContraptionRenderDispatcher.renderStructure(world, renderWorld, contraption, matrices, buffers); } } @@ -182,21 +182,21 @@ public class ContraptionRenderDispatcher { } public static void renderDynamic(World world, PlacementSimulationWorld renderWorld, Contraption c, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - renderTileEntities(world, renderWorld, c, ms, msLocal, buffer); + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { + renderTileEntities(world, renderWorld, c, matrices, buffer); if (buffer instanceof IRenderTypeBuffer.Impl) ((IRenderTypeBuffer.Impl) buffer).draw(); - renderActors(world, renderWorld, c, ms, msLocal, buffer); + renderActors(world, renderWorld, c, matrices, buffer); } public static void renderTileEntities(World world, PlacementSimulationWorld renderWorld, Contraption c, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities, ms, msLocal, buffer); + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { + TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities, + matrices.getFinalStack(), matrices.getFinalLight(), buffer); } protected static void renderActors(World world, PlacementSimulationWorld renderWorld, Contraption c, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - MatrixStack[] matrixStacks = new MatrixStack[] {ms, msLocal}; + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { for (Pair actor : c.getActors()) { MovementContext context = actor.getRight(); if (context == null) @@ -204,23 +204,22 @@ public class ContraptionRenderDispatcher { if (context.world == null) context.world = world; Template.BlockInfo blockInfo = actor.getLeft(); - for (MatrixStack m : matrixStacks) { - m.push(); - MatrixStacker.of(m) - .translate(blockInfo.pos); - } + + MatrixStack m = matrices.contraptionStack; + m.push(); + MatrixStacker.of(m) + .translate(blockInfo.pos); MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state); if (movementBehaviour != null) - movementBehaviour.renderInContraption(context, renderWorld, ms, msLocal, buffer); + movementBehaviour.renderInContraption(context, renderWorld, matrices, buffer); - for (MatrixStack m : matrixStacks) - m.pop(); + m.pop(); } } public static void renderStructure(World world, PlacementSimulationWorld renderWorld, Contraption c, - MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { + ContraptionMatrices matrices, IRenderTypeBuffer buffer) { SuperByteBufferCache bufferCache = CreateClient.bufferCache; List blockLayers = RenderType.getBlockLayers(); @@ -231,11 +230,11 @@ public class ContraptionRenderDispatcher { SuperByteBuffer contraptionBuffer = bufferCache.get(CONTRAPTION, key, () -> buildStructureBuffer(renderWorld, c, layer)); if (contraptionBuffer.isEmpty()) continue; - Matrix4f model = msLocal.peek() - .getModel(); - contraptionBuffer.light(model) + contraptionBuffer + .transform(matrices.contraptionStack) + .light(matrices.entityMatrix) .hybridLight() - .renderInto(ms, buffer.getBuffer(layer)); + .renderInto(matrices.entityStack, buffer.getBuffer(layer)); } } @@ -278,29 +277,18 @@ public class ContraptionRenderDispatcher { public static int getLight(World world, float lx, float ly, float lz) { BlockPos.Mutable pos = new BlockPos.Mutable(); - float sky = 0, block = 0; + float block = 0, sky = 0; float offset = 1 / 8f; for (float zOffset = offset; zOffset >= -offset; zOffset -= 2 * offset) for (float yOffset = offset; yOffset >= -offset; yOffset -= 2 * offset) for (float xOffset = offset; xOffset >= -offset; xOffset -= 2 * offset) { pos.setPos(lx + xOffset, ly + yOffset, lz + zOffset); - sky += world.getLightLevel(LightType.SKY, pos) / 8f; block += world.getLightLevel(LightType.BLOCK, pos) / 8f; + sky += world.getLightLevel(LightType.SKY, pos) / 8f; } - return ((int) sky) << 20 | ((int) block) << 4; - } - - public static int getContraptionLightAt(World world, PlacementSimulationWorld renderWorld, BlockPos pos, BlockPos lightPos) { - int worldLight = WorldRenderer.getLightmapCoordinates(world, lightPos); - - if (renderWorld != null) { - int renderWorldLight = WorldRenderer.getLightmapCoordinates(renderWorld, pos); - return SuperByteBuffer.maxLight(worldLight, renderWorldLight); - } - - return worldLight; + return LightTexture.pack((int) block, (int) sky); } public static int getContraptionWorldLight(MovementContext context, PlacementSimulationWorld renderWorld) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index 11bf71ee2..b618896f3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -72,7 +72,7 @@ public class RenderedContraption extends ContraptionWorldHolder { double z = MathHelper.lerp(pt, entity.lastTickPosZ, entity.getZ()) - camZ; stack.translate(x, y, z); - entity.doLocalTransforms(pt, new MatrixStack[]{ stack }); + entity.doLocalTransforms(pt, new MatrixStack[] { stack }); model = stack.peek().getModel(); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java index a585b429d..75f55c7ba 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java @@ -78,8 +78,7 @@ public class SchematicRenderer { SuperByteBuffer superByteBuffer = bufferCache.get(layer); superByteBuffer.renderInto(ms, buffer.getBuffer(layer)); } - TileEntityRenderHelper.renderTileEntities(schematic, schematic.getRenderedTileEntities(), ms, new MatrixStack(), - buffer); + TileEntityRenderHelper.renderTileEntities(schematic, schematic.getRenderedTileEntities(), ms, buffer); } protected void redraw(Minecraft minecraft) { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java index 40e7d49b0..8cac03a46 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java @@ -369,7 +369,7 @@ public class WorldSectionElement extends AnimatedSceneElement { private void renderTileEntities(PonderWorld world, MatrixStack ms, IRenderTypeBuffer buffer, float pt) { loadTEsIfMissing(world); - TileEntityRenderHelper.renderTileEntities(world, renderedTileEntities, ms, new MatrixStack(), buffer, pt); + TileEntityRenderHelper.renderTileEntities(world, renderedTileEntities, ms, buffer, pt); } private SuperByteBuffer buildStructureBuffer(PonderWorld world, RenderType layer) { diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index 1a6c81b39..e56ec5234 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -8,11 +8,12 @@ import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.utility.MatrixStacker; -import it.unimi.dsi.fastutil.longs.Long2DoubleMap; -import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; +import it.unimi.dsi.fastutil.longs.Long2IntMap; +import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; @@ -22,31 +23,27 @@ import net.minecraft.util.math.vector.Quaternion; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3f; import net.minecraft.util.math.vector.Vector4f; -import net.minecraft.world.LightType; import net.minecraft.world.World; import net.minecraftforge.client.model.pipeline.LightUtil; public class SuperByteBuffer extends TemplateBuffer { - public interface IVertexLighter { - public int getPackedLight(float x, float y, float z); - } - // Vertex Position private MatrixStack transforms; // Vertex Texture Coords private SpriteShiftFunc spriteShiftFunc; - // Vertex Lighting - private boolean shouldLight; - private boolean hybridLight; - private int packedLightCoords; - private Matrix4f lightTransform; - // Vertex Coloring private boolean shouldColor; private int r, g, b, a; + private boolean disableDiffuseTransform; + + // Vertex Lighting + private boolean useWorldLight; + private boolean hybridLight; + private int packedLightCoords; + private Matrix4f lightTransform; public SuperByteBuffer(BufferBuilder buf) { super(buf); @@ -63,8 +60,7 @@ public class SuperByteBuffer extends TemplateBuffer { return (v - sprite.getMinV()) / f * 16.0F; } - private static final Long2DoubleMap skyLightCache = new Long2DoubleOpenHashMap(); - private static final Long2DoubleMap blockLightCache = new Long2DoubleOpenHashMap(); + private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap(); Vector4f pos = new Vector4f(); Vector3f normal = new Vector3f(); Vector4f lightPos = new Vector4f(); @@ -78,7 +74,6 @@ public class SuperByteBuffer extends TemplateBuffer { Matrix3f normalMat = transforms.peek() .getNormal() .copy(); - // normalMat.multiply(transforms.peek().getNormal()); Matrix4f modelMat = input.peek() .getModel() @@ -88,11 +83,11 @@ public class SuperByteBuffer extends TemplateBuffer { .getModel(); modelMat.multiply(localTransforms); - if (shouldLight && lightTransform != null) { - skyLightCache.clear(); - blockLightCache.clear(); + if (useWorldLight) { + WORLD_LIGHT_CACHE.clear(); } + boolean hasDefaultLight = packedLightCoords != 0; float f = .5f; int vertexCount = vertexCount(buffer); for (int i = 0; i < vertexCount; i++) { @@ -127,7 +122,12 @@ public class SuperByteBuffer extends TemplateBuffer { int colorB = Math.min(255, (int) (((float) this.b) * instanceDiffuse)); builder.color(colorR, colorG, colorB, this.a); } else { - float diffuseMult = instanceDiffuse / staticDiffuse; + float diffuseMult; + if (disableDiffuseTransform) { + diffuseMult = 1.0f; + } else { + diffuseMult = instanceDiffuse / staticDiffuse; + } int colorR = Math.min(255, (int) (((float) Byte.toUnsignedInt(r)) * diffuseMult)); int colorG = Math.min(255, (int) (((float) Byte.toUnsignedInt(g)) * diffuseMult)); int colorB = Math.min(255, (int) (((float) Byte.toUnsignedInt(b)) * diffuseMult)); @@ -142,23 +142,29 @@ public class SuperByteBuffer extends TemplateBuffer { } else builder.texture(u, v); - if (shouldLight) { - int light = packedLightCoords; + int light; + if (useWorldLight) { + lightPos.set(((x - f) * 15 / 16f) + f, (y - f) * 15 / 16f + f, (z - f) * 15 / 16f + f, 1F); + lightPos.transform(localTransforms); if (lightTransform != null) { - lightPos.set(((x - f) * 15 / 16f) + f, (y - f) * 15 / 16f + f, (z - f) * 15 / 16f + f, 1F); - lightPos.transform(localTransforms); lightPos.transform(lightTransform); - - int worldLight = getLight(Minecraft.getInstance().world, lightPos); - light = maxLight(worldLight, light); } - if (hybridLight) - builder.light(maxLight(light, getLight(buffer, i))); - else - builder.light(light); - } else - builder.light(getLight(buffer, i)); + light = getLight(Minecraft.getInstance().world, lightPos); + if (hasDefaultLight) { + light = maxLight(light, packedLightCoords); + } + } else if (hasDefaultLight) { + light = packedLightCoords; + } else { + light = getLight(buffer, i); + } + + if (hybridLight) { + builder.light(maxLight(light, getLight(buffer, i))); + } else { + builder.light(light); + } builder.normal(nx, ny, nz) .endVertex(); @@ -170,15 +176,16 @@ public class SuperByteBuffer extends TemplateBuffer { public SuperByteBuffer reset() { transforms = new MatrixStack(); spriteShiftFunc = null; - shouldLight = false; - hybridLight = false; - packedLightCoords = 0; - lightTransform = null; shouldColor = false; r = 0; g = 0; b = 0; a = 0; + disableDiffuseTransform = false; + useWorldLight = false; + hybridLight = false; + packedLightCoords = 0; + lightTransform = null; return this; } @@ -234,6 +241,20 @@ public class SuperByteBuffer extends TemplateBuffer { .translate(-.5f, -.5f, -.5f); } + public SuperByteBuffer color(int color) { + shouldColor = true; + r = ((color >> 16) & 0xFF); + g = ((color >> 8) & 0xFF); + b = (color & 0xFF); + a = 255; + return this; + } + + public SuperByteBuffer disableDiffuseTransform() { + disableDiffuseTransform = true; + return this; + } + public SuperByteBuffer shiftUV(SpriteShiftEntry entry) { this.spriteShiftFunc = (builder, u, v) -> { float targetU = entry.getTarget() @@ -270,20 +291,24 @@ public class SuperByteBuffer extends TemplateBuffer { return this; } - public SuperByteBuffer light(int packedLightCoords) { - shouldLight = true; - this.packedLightCoords = packedLightCoords; + public SuperByteBuffer light() { + useWorldLight = true; return this; } public SuperByteBuffer light(Matrix4f lightTransform) { - shouldLight = true; + useWorldLight = true; this.lightTransform = lightTransform; return this; } + public SuperByteBuffer light(int packedLightCoords) { + this.packedLightCoords = packedLightCoords; + return this; + } + public SuperByteBuffer light(Matrix4f lightTransform, int packedLightCoords) { - shouldLight = true; + useWorldLight = true; this.lightTransform = lightTransform; this.packedLightCoords = packedLightCoords; return this; @@ -294,15 +319,6 @@ public class SuperByteBuffer extends TemplateBuffer { return this; } - public SuperByteBuffer color(int color) { - shouldColor = true; - r = ((color >> 16) & 0xFF); - g = ((color >> 8) & 0xFF); - b = (color & 0xFF); - a = 255; - return this; - } - public static int maxLight(int packedLight1, int packedLight2) { int blockLight1 = LightTexture.getBlockLightCoordinates(packedLight1); int skyLight1 = LightTexture.getSkyLightCoordinates(packedLight1); @@ -312,12 +328,8 @@ public class SuperByteBuffer extends TemplateBuffer { } private static int getLight(World world, Vector4f lightPos) { - BlockPos.Mutable pos = new BlockPos.Mutable(); - double sky = 0, block = 0; - pos.setPos(lightPos.getX() + 0, lightPos.getY() + 0, lightPos.getZ() + 0); - sky += skyLightCache.computeIfAbsent(pos.toLong(), $ -> world.getLightLevel(LightType.SKY, pos)); - block += blockLightCache.computeIfAbsent(pos.toLong(), $ -> world.getLightLevel(LightType.BLOCK, pos)); - return ((int) sky) << 20 | ((int) block) << 4; + BlockPos pos = new BlockPos(lightPos.getX(), lightPos.getY(), lightPos.getZ()); + return WORLD_LIGHT_CACHE.computeIfAbsent(pos.toLong(), $ -> WorldRenderer.getLightmapCoordinates(world, pos)); } public boolean isEmpty() { @@ -329,4 +341,9 @@ public class SuperByteBuffer extends TemplateBuffer { void shift(IVertexBuilder builder, float u, float v); } + @FunctionalInterface + public interface IVertexLighter { + public int getPackedLight(float x, float y, float z); + } + } diff --git a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java index f54a5725f..f00dc81b1 100644 --- a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java @@ -2,15 +2,17 @@ package com.simibubi.create.foundation.render; import java.util.Iterator; +import javax.annotation.Nullable; + import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.Create; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; @@ -23,28 +25,26 @@ import net.minecraft.world.World; public class TileEntityRenderHelper { public static void renderTileEntities(World world, Iterable customRenderTEs, MatrixStack ms, - MatrixStack localTransform, IRenderTypeBuffer buffer) { - renderTileEntities(world, null, customRenderTEs, ms, localTransform, buffer); + IRenderTypeBuffer buffer) { + renderTileEntities(world, null, customRenderTEs, ms, null, buffer); } public static void renderTileEntities(World world, Iterable customRenderTEs, MatrixStack ms, - MatrixStack localTransform, IRenderTypeBuffer buffer, float pt) { - renderTileEntities(world, null, customRenderTEs, ms, localTransform, buffer, pt); + IRenderTypeBuffer buffer, float pt) { + renderTileEntities(world, null, customRenderTEs, ms, null, buffer, pt); } - public static void renderTileEntities(World world, PlacementSimulationWorld renderWorld, - Iterable customRenderTEs, MatrixStack ms, MatrixStack localTransform, IRenderTypeBuffer buffer) { - renderTileEntities(world, renderWorld, customRenderTEs, ms, localTransform, buffer, + public static void renderTileEntities(World world, @Nullable PlacementSimulationWorld renderWorld, + Iterable customRenderTEs, MatrixStack ms, @Nullable Matrix4f lightTransform, IRenderTypeBuffer buffer) { + renderTileEntities(world, renderWorld, customRenderTEs, ms, lightTransform, buffer, AnimationTickHolder.getPartialTicks()); } - public static void renderTileEntities(World world, PlacementSimulationWorld renderWorld, - Iterable customRenderTEs, MatrixStack ms, MatrixStack localTransform, IRenderTypeBuffer buffer, - float pt) { - Matrix4f matrix = localTransform.peek() - .getModel(); - - for (Iterator iterator = customRenderTEs.iterator(); iterator.hasNext();) { + public static void renderTileEntities(World world, @Nullable PlacementSimulationWorld renderWorld, + Iterable customRenderTEs, MatrixStack ms, @Nullable Matrix4f lightTransform, IRenderTypeBuffer buffer, + float pt) { + Iterator iterator = customRenderTEs.iterator(); + while (iterator.hasNext()) { TileEntity tileEntity = iterator.next(); // if (tileEntity instanceof IInstanceRendered) continue; // TODO: some things still need to render @@ -60,10 +60,15 @@ public class TileEntityRenderHelper { .translate(pos); try { - Vector4f vec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1); - vec.transform(matrix); - BlockPos lightPos = new BlockPos(vec.getX(), vec.getY(), vec.getZ()); - int worldLight = ContraptionRenderDispatcher.getContraptionLightAt(world, renderWorld, pos, lightPos); + BlockPos lightPos; + if (lightTransform != null) { + Vector4f lightVec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1); + lightVec.transform(lightTransform); + lightPos = new BlockPos(lightVec.getX(), lightVec.getY(), lightVec.getZ()); + } else { + lightPos = pos; + } + int worldLight = getCombinedLight(world, lightPos, renderWorld, pos); renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.DEFAULT_UV); } catch (Exception e) { @@ -82,4 +87,16 @@ public class TileEntityRenderHelper { } } + public static int getCombinedLight(World world, BlockPos worldPos, @Nullable PlacementSimulationWorld renderWorld, + BlockPos renderWorldPos) { + int worldLight = WorldRenderer.getLightmapCoordinates(world, worldPos); + + if (renderWorld != null) { + int renderWorldLight = WorldRenderer.getLightmapCoordinates(renderWorld, renderWorldPos); + return SuperByteBuffer.maxLight(worldLight, renderWorldLight); + } + + return worldLight; + } + } From 695fe98d289d5e6033f539ff565f1f4a1a61d9bb Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sun, 16 May 2021 20:37:26 -0700 Subject: [PATCH 061/198] MaterialSpecs choose their model formats --- .../backend/instancing/MaterialSpec.java | 8 +++++++- .../backend/instancing/RenderMaterial.java | 4 +--- .../foundation/render/AllMaterialSpecs.java | 16 ++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java index 565cf5d41..2cfcfa435 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java @@ -10,12 +10,14 @@ public class MaterialSpec { public final ResourceLocation name; private final ProgramSpec programSpec; + private final VertexFormat modelFormat; private final VertexFormat instanceFormat; private final InstanceFactory instanceFactory; - public MaterialSpec(ResourceLocation name, ProgramSpec programSpec, VertexFormat instanceFormat, InstanceFactory instanceFactory) { + public MaterialSpec(ResourceLocation name, ProgramSpec programSpec, VertexFormat modelFormat, VertexFormat instanceFormat, InstanceFactory instanceFactory) { this.name = name; this.programSpec = programSpec; + this.modelFormat = modelFormat; this.instanceFormat = instanceFormat; this.instanceFactory = instanceFactory; } @@ -24,6 +26,10 @@ public class MaterialSpec { return programSpec; } + public VertexFormat getModelFormat() { + return modelFormat; + } + public VertexFormat getInstanceFormat() { return instanceFormat; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index 19f0c8fcb..c5a1b4e11 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -14,7 +14,6 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.PartialModel; -import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.jozufozu.flywheel.util.BufferBuilderReader; @@ -36,7 +35,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; public class RenderMaterial

{ - public static final VertexFormat MODEL_FORMAT = VertexFormat.builder().addAttributes(ModelAttributes.class).build(); protected final InstancedTileRenderer

renderer; protected final Cache> models; @@ -121,7 +119,7 @@ public class RenderMaterial

{ private InstancedModel buildModel(IBakedModel model, BlockState referenceState, MatrixStack ms) { BufferBuilderReader reader = new BufferBuilderReader(getBufferBuilder(model, referenceState, ms)); - VertexFormat format = MODEL_FORMAT; + VertexFormat format = spec.getModelFormat(); int vertexCount = reader.getVertexCount(); ByteBuffer to = ByteBuffer.allocate(vertexCount * format.getStride()); diff --git a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java index a26402155..374bcb368 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java @@ -2,8 +2,10 @@ package com.simibubi.create.foundation.render; import static com.jozufozu.flywheel.backend.Backend.register; +import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.core.materials.OrientedData; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.RotatingData; @@ -18,13 +20,15 @@ public class AllMaterialSpecs { // noop, make sure the static field are loaded. } - public static final MaterialSpec TRANSFORMED = register(new MaterialSpec<>(Locations.MODEL, AllProgramSpecs.MODEL, AllInstanceFormats.MODEL, ModelData::new)); - public static final MaterialSpec ORIENTED = register(new MaterialSpec<>(Locations.ORIENTED, AllProgramSpecs.ORIENTED, AllInstanceFormats.ORIENTED, OrientedData::new)); + public static final VertexFormat UNLIT_MODEL = VertexFormat.builder().addAttributes(ModelAttributes.class).build(); - public static final MaterialSpec ROTATING = register(new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, AllInstanceFormats.ROTATING, RotatingData::new)); - public static final MaterialSpec BELTS = register(new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, AllInstanceFormats.BELT, BeltData::new)); - public static final MaterialSpec ACTORS = register(new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, AllInstanceFormats.ACTOR, ActorData::new)); - public static final MaterialSpec FLAPS = register(new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, AllInstanceFormats.FLAP, FlapData::new)); + public static final MaterialSpec TRANSFORMED = register(new MaterialSpec<>(Locations.MODEL, AllProgramSpecs.MODEL, UNLIT_MODEL, AllInstanceFormats.MODEL, ModelData::new)); + public static final MaterialSpec ORIENTED = register(new MaterialSpec<>(Locations.ORIENTED, AllProgramSpecs.ORIENTED, UNLIT_MODEL, AllInstanceFormats.ORIENTED, OrientedData::new)); + + public static final MaterialSpec ROTATING = register(new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, UNLIT_MODEL, AllInstanceFormats.ROTATING, RotatingData::new)); + public static final MaterialSpec BELTS = register(new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, UNLIT_MODEL, AllInstanceFormats.BELT, BeltData::new)); + public static final MaterialSpec ACTORS = register(new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, UNLIT_MODEL, AllInstanceFormats.ACTOR, ActorData::new)); + public static final MaterialSpec FLAPS = register(new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, UNLIT_MODEL, AllInstanceFormats.FLAP, FlapData::new)); public static class Locations { public static final ResourceLocation MODEL = new ResourceLocation("create", "model"); From a74c8127f33fe58135aae65e35af60c06f953798 Mon Sep 17 00:00:00 2001 From: joker876 <42680429+joker876@users.noreply.github.com> Date: Mon, 17 May 2021 10:59:39 +0200 Subject: [PATCH 062/198] Update pl_pl.json --- .../resources/assets/create/lang/pl_pl.json | 69 ++++++++++++++----- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/src/main/resources/assets/create/lang/pl_pl.json b/src/main/resources/assets/create/lang/pl_pl.json index aa77c039a..72e6c341d 100644 --- a/src/main/resources/assets/create/lang/pl_pl.json +++ b/src/main/resources/assets/create/lang/pl_pl.json @@ -57,6 +57,7 @@ "block.create.cogwheel": "Koło zębate", "block.create.content_observer": "Detektor zawartości", "block.create.controller_rail": "Tory sterujące", + "block.create.copper_backtank": "Miedziany zbiornik w plecaku", "block.create.copper_block": "Blok miedzi", "block.create.copper_casing": "Miedziana Obudowa", "block.create.copper_ore": "Ruda miedzi", @@ -437,6 +438,7 @@ "item.create.chocolate_glazed_berries": "Jagody w czekoladzie", "item.create.chromatic_compound": "Związek chromatyczny", "item.create.cinder_flour": "Rozżarzona mąka", + "item.create.copper_backtank": "Miedziany zbiornik w plecaku", "item.create.copper_ingot": "Sztabka miedzi", "item.create.copper_nugget": "Bryłka miedzi", "item.create.copper_sheet": "Arkusz miedzi", @@ -455,6 +457,8 @@ "item.create.crushed_tin_ore": "Rozkruszona ruda cyny", "item.create.crushed_uranium_ore": "Rozkruszona ruda uranu", "item.create.crushed_zinc_ore": "Rozkruszona ruda cynku", + "item.create.diving_boots": "Buty do nurkowania", + "item.create.diving_helmet": "Hełm do nurkowania", "item.create.deforester": "Wylesiacz", "item.create.dough": "Ciasto", "item.create.electron_tube": "Lampa elektronowa", @@ -685,6 +689,7 @@ "create.recipe.fan_blasting.fan": "Wiatrak za lawą", "create.recipe.pressing": "Tłoczenie", "create.recipe.mixing": "Mieszanie", + "create.recipe.deploying": "Aplikowanie", "create.recipe.automatic_shapeless": "Zautomatyzowanie nieokreślone konstruowanie", "create.recipe.automatic_brewing": "Zautomatyzowane warzenie", "create.recipe.packing": "Prasowanie", @@ -760,11 +765,20 @@ "create.gui.blockzapper.patternSection": "Wzór", "create.gui.blockzapper.pattern.solid": "Ciągły", "create.gui.blockzapper.pattern.checkered": "Szachownica", - "create.gui.blockzapper.pattern.inversecheckered": "Odwrócona Szachownica", + "create.gui.blockzapper.pattern.inversecheckered": "Odwrócona szachownica", "create.gui.blockzapper.pattern.chance25": "Obrót o 25%", "create.gui.blockzapper.pattern.chance50": "Obrót o 50%", "create.gui.blockzapper.pattern.chance75": "Obrót o 75%", "create.gui.terrainzapper.title": "Ręczny kształter", + "create.gui.terrainzapper.searchDiagonal": "Wzdłuż linii ukośnych", + "create.gui.terrainzapper.searchFuzzy": "Ignoruj krawędzie materiałów", + "create.gui.terrainzapper.patternSection": "Wzór", + "create.gui.terrainzapper.pattern.solid": "Ciągły", + "create.gui.terrainzapper.pattern.checkered": "Szachownica", + "create.gui.terrainzapper.pattern.inversecheckered": "Odrócona szachownica", + "create.gui.terrainzapper.pattern.chance25": "Obrót o 25%", + "create.gui.terrainzapper.pattern.chance50": "Obrót o 50%", + "create.gui.terrainzapper.pattern.chance75": "Obrót o 75%", "create.gui.terrainzapper.placement": "Położenie", "create.gui.terrainzapper.placement.merged": "Połączony", "create.gui.terrainzapper.placement.attached": "Przyłączony", @@ -773,6 +787,8 @@ "create.gui.terrainzapper.brush.cuboid": "Prostopadłościan", "create.gui.terrainzapper.brush.sphere": "Kula", "create.gui.terrainzapper.brush.cylinder": "Walec", + "create.gui.terrainzapper.brush.surface": "Powierzchnia", + "create.gui.terrainzapper.brush.cluster": "Grupa", "create.gui.terrainzapper.tool": "Narzędzie", "create.gui.terrainzapper.tool.fill": "Wypełnianie", "create.gui.terrainzapper.tool.place": "Stawianie", @@ -782,6 +798,8 @@ "create.gui.terrainzapper.tool.flatten": "Wypłaszczanie", "create.terrainzapper.shiftRightClickToSet": "Shift+Prawe kliknięcie, aby wybrać kształt", + "create.terrainzapper.usingBlock": "Używając: %1$s", + "create.terrainzapper.leftClickToSet": "Kliknij LPM na blok aby ustawić materiał", "create.blockzapper.usingBlock": "Używając: %1$s", "create.blockzapper.componentUpgrades": "Ulepszenia komponentów:", @@ -1147,16 +1165,35 @@ "create.command.killTPSCommand.status.usage.1": "[Create]: Użyj \"/killtps start\", aby sztucznie spowolnić serwer\n", "create.command.killTPSCommand.argument.tickTime": "tickTime", - "create.subtitle.schematicannon_launch_block": "Schematoarmata strzela", - "create.subtitle.schematicannon_finish": "Schematoarmata skończyła", - "create.subtitle.slime_added": "Szlam plaska", - "create.subtitle.mechanical_press_activation": "Mechaniczna prasa się uruchamia", - "create.subtitle.mechanical_press_item_break": "Metal brzęczy", - "create.subtitle.blockzapper_place": "Bloki lecą na miejsce", - "create.subtitle.blockzapper_confirm": "Potwierdzający sygnał", - "create.subtitle.blockzapper_deny": "Odrzucający sygnał", - "create.subtitle.block_funnel_eat": "Lejek zjada", - "create.subtitle.blaze_munch": "Płomyk szczęśliwie przeżuwa", + "create.contraption.minecart_contraption_too_big": "Ta maszyna w wagoniku jest zbyt duża, aby ją podnieść", + + + "_": "->------------------------] Napisy dla niesłyszących [------------------------<-", + + "create.subtitle.cogs": "Koła zębate terkoczą", + "create.subtitle.slime_added": "Szlam plaska", + "create.subtitle.contraption_disassemble": "Maszyna staje", + "create.subtitle.wrench_rotate": "Klucz skrzypi", + "create.subtitle.mixing": "Dźwięki mieszania", + "create.subtitle.mechanical_press_activation_belt": "Mechaniczna prasa stuka", + "create.subtitle.worldshaper_place": "Kształter strzela", + "create.subtitle.deployer_polish": "Aplikator poleruje", + "create.subtitle.depot_slide": "Przedmiot ślizga się", + "create.subtitle.deny": "Dźwięk odmowy", + "create.subtitle.blaze_munch": "Płomyk szczęśliwie przeżuwa", + "create.subtitle.schematicannon_launch_block": "Schematoarmata strzela", + "create.subtitle.funnel_flap": "Lejek trzepocze", + "create.subtitle.copper_armor_equip": "Sprzęt do nurkowania pobrzękuje", + "create.subtitle.schematicannon_finish": "Schematoarmata skończyła", + "create.subtitle.scroll_value": "Kliknięcie", + "create.subtitle.mechanical_press_activation": "Mechaniczna prasa się uruchamia", + "create.subtitle.contraption_assemble": "Maszyna przesuwa się", + "create.subtitle.crafter_craft": "Mechaniczny stół rzemieślniczy konstruuje", + "create.subtitle.cranking": "Ręczna korba obraca się", + "create.subtitle.crafter_click": "Mechaniczny stół rzemieślniczy stuka", + "create.subtitle.wrench_remove": "Komponent niszczy się", + "create.subtitle.depot_plop": "Przedmiot ląduje", + "create.subtitle.confirm": "Dźwięk potwierdzenia", "_": "->------------------------] Opisy Przedmiotów [------------------------<-", @@ -1547,11 +1584,11 @@ "create.ponder.blaze_burner.text_3": "Z użyciem płomiennego ciasta, palnik może uzyskać szczególnie wysoką temperaturę", "create.ponder.blaze_burner.text_4": "Dostarczanie płomykowi przedmiotów może zostać zautomatyzowane z użyciem aplikatorów lub mechanicznych ramion", - "create.ponder.brass_funnel.header": "Mosiężny lejek", - "create.ponder.brass_funnel.text_1": "Andezytowe lejki mogą pobierać jedynie pojedyncze przedmioty", - "create.ponder.brass_funnel.text_2": "Mosiężne lejki mogą pobierać nawet pełne stosy", + "create.ponder.brass_funnel.header": "Mosiężny lej", + "create.ponder.brass_funnel.text_1": "Andezytowe leje mogą pobierać jedynie pojedyncze przedmioty", + "create.ponder.brass_funnel.text_2": "Mosiężne leje mogą pobierać nawet pełne stosy", "create.ponder.brass_funnel.text_3": "Przewijanie na slocie filtrującym pozwala na precyzyjną kontrolę nad maksymalną wielkością stosu", - "create.ponder.brass_funnel.text_4": "Użycie przedmiotów patrząc na slot filtrujący spowoduje, że lejek będzie przesyłał tylko pasujące przedmioty", + "create.ponder.brass_funnel.text_4": "Użycie przedmiotu patrząc na slot filtrujący spowoduje, że lej będzie przesyłał tylko pasujące przedmioty", "create.ponder.brass_tunnel.header": "Używanie mosiężnych tuneli", "create.ponder.brass_tunnel.text_1": "Mosiężne tunele mogą być użyte do przykrycia Twoich taśmociągów", @@ -2114,4 +2151,4 @@ "create.ponder.windmill_structure.header": "Wiatraki", "create.ponder.windmill_structure.text_1": "Każda struktura jest uznawana za wiatrak w momencie, kiedy ma w sobie co najmniej 8 żaglo-podobnych bloków" -} \ No newline at end of file +} From 18977da884a0c90768e993c825b7e7a9613a05f6 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Mon, 17 May 2021 12:07:45 -0700 Subject: [PATCH 063/198] Minor fixes part 2 --- .../components/actors/DrillRenderer.java | 2 +- .../AbstractContraptionEntity.java | 2 +- .../render/ContraptionRenderDispatcher.java | 4 +- .../render/RenderedContraption.java | 128 +++++++++--------- 4 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java index 83b472863..df1e668d9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java @@ -54,7 +54,7 @@ public class DrillRenderer extends KineticTileEntityRenderer { .unCentre(); superBuffer - .transform(matrices.contraptionStack) + .transform(m) .light(matrices.entityMatrix, ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) .renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getSolid())); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java index 3f442ccfd..5c651529a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java @@ -641,7 +641,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit } @OnlyIn(Dist.CLIENT) - public abstract void doLocalTransforms(float partialTicks, MatrixStack[] matrixStack); + public abstract void doLocalTransforms(float partialTicks, MatrixStack[] matrixStacks); public static class ContraptionRotationState { public static final ContraptionRotationState NONE = new ContraptionRotationState(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index f098d58b8..8f0a922e3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; +import static org.lwjgl.opengl.GL11.GL_QUADS; import static org.lwjgl.opengl.GL11.glDisable; import static org.lwjgl.opengl.GL11.glEnable; import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D; @@ -11,7 +12,6 @@ import java.util.List; import java.util.Random; import org.apache.commons.lang3.tuple.Pair; -import org.lwjgl.opengl.GL11; import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; @@ -247,7 +247,7 @@ public class ContraptionRenderDispatcher { MatrixStack ms = new MatrixStack(); Random random = new Random(); BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); - builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + builder.begin(GL_QUADS, DefaultVertexFormats.BLOCK); ForgeHooksClient.setRenderLayer(layer); BlockModelRenderer.enableCache(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index 6a8349688..f47a90de5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -37,106 +37,106 @@ public class RenderedContraption extends ContraptionWorldHolder { .addAttributes(ContraptionAttributes.class) .build(); - private final ContraptionLighter lighter; - public final ContraptionKineticRenderer kinetics; + private final ContraptionLighter lighter; + public final ContraptionKineticRenderer kinetics; private final Map renderLayers = new HashMap<>(); private Matrix4f model; - private AxisAlignedBB lightBox; + private AxisAlignedBB lightBox; - public RenderedContraption(World world, PlacementSimulationWorld renderWorld, Contraption contraption) { - super(contraption, renderWorld); - this.lighter = contraption.makeLighter(); - this.kinetics = new ContraptionKineticRenderer(this); + public RenderedContraption(World world, PlacementSimulationWorld renderWorld, Contraption contraption) { + super(contraption, renderWorld); + this.lighter = contraption.makeLighter(); + this.kinetics = new ContraptionKineticRenderer(this); - buildLayers(); - if (Backend.canUseInstancing()) { - buildInstancedTiles(); - buildActors(); - } - } + buildLayers(); + if (Backend.canUseInstancing()) { + buildInstancedTiles(); + buildActors(); + } + } - public ContraptionLighter getLighter() { - return lighter; - } + public ContraptionLighter getLighter() { + return lighter; + } - public void doRenderLayer(RenderType layer, ContraptionProgram shader) { + public void doRenderLayer(RenderType layer, ContraptionProgram shader) { IndexedModel structure = renderLayers.get(layer); - if (structure != null) { - setup(shader); - structure.render(); - teardown(); - } - } + if (structure != null) { + setup(shader); + structure.render(); + teardown(); + } + } - public void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) { - kinetics.beginFrame(info); + public void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) { + kinetics.beginFrame(info); - AbstractContraptionEntity entity = contraption.entity; - float pt = AnimationTickHolder.getPartialTicks(); + AbstractContraptionEntity entity = contraption.entity; + float pt = AnimationTickHolder.getPartialTicks(); - MatrixStack stack = new MatrixStack(); + MatrixStack stack = new MatrixStack(); - double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()) - camX; - double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()) - camY; - double z = MathHelper.lerp(pt, entity.lastTickPosZ, entity.getZ()) - camZ; - stack.translate(x, y, z); + double x = MathHelper.lerp(pt, entity.lastTickPosX, entity.getX()) - camX; + double y = MathHelper.lerp(pt, entity.lastTickPosY, entity.getY()) - camY; + double z = MathHelper.lerp(pt, entity.lastTickPosZ, entity.getZ()) - camZ; + stack.translate(x, y, z); - entity.doLocalTransforms(pt, new MatrixStack[] { stack }); + entity.doLocalTransforms(pt, new MatrixStack[] { stack }); - model = stack.peek().getModel(); + model = stack.peek().getModel(); - AxisAlignedBB lightBox = GridAlignedBB.toAABB(lighter.lightVolume.getTextureVolume()); + AxisAlignedBB lightBox = GridAlignedBB.toAABB(lighter.lightVolume.getTextureVolume()); - this.lightBox = lightBox.offset(-camX, -camY, -camZ); - } + this.lightBox = lightBox.offset(-camX, -camY, -camZ); + } - void setup(ContraptionProgram shader) { - if (model == null || lightBox == null) return; - shader.bind(model, lightBox); - lighter.lightVolume.bind(); - } + void setup(ContraptionProgram shader) { + if (model == null || lightBox == null) return; + shader.bind(model, lightBox); + lighter.lightVolume.bind(); + } - void teardown() { - lighter.lightVolume.unbind(); - } + void teardown() { + lighter.lightVolume.unbind(); + } - void invalidate() { + void invalidate() { for (IndexedModel buffer : renderLayers.values()) { buffer.delete(); } - renderLayers.clear(); + renderLayers.clear(); - lighter.lightVolume.delete(); + lighter.lightVolume.delete(); - kinetics.invalidate(); - } + kinetics.invalidate(); + } - private void buildLayers() { + private void buildLayers() { for (IndexedModel buffer : renderLayers.values()) { buffer.delete(); } - renderLayers.clear(); + renderLayers.clear(); - List blockLayers = RenderType.getBlockLayers(); + List blockLayers = RenderType.getBlockLayers(); - for (RenderType layer : blockLayers) { + for (RenderType layer : blockLayers) { IndexedModel layerModel = buildStructureModel(renderWorld, contraption, layer); if (layerModel != null) renderLayers.put(layer, layerModel); } - } + } - private void buildInstancedTiles() { - Collection tileEntities = contraption.maybeInstancedTileEntities; - if (!tileEntities.isEmpty()) { - for (TileEntity te : tileEntities) { - if (te instanceof IInstanceRendered) { - World world = te.getWorld(); - BlockPos pos = te.getPos(); - te.setLocation(renderWorld, pos); - kinetics.add(te); + private void buildInstancedTiles() { + Collection tileEntities = contraption.maybeInstancedTileEntities; + if (!tileEntities.isEmpty()) { + for (TileEntity te : tileEntities) { + if (te instanceof IInstanceRendered) { + World world = te.getWorld(); + BlockPos pos = te.getPos(); + te.setLocation(renderWorld, pos); + kinetics.add(te); te.setLocation(world, pos); } } From 55703d88389274d55dd9a169dac654d18084fc64 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 18 May 2021 14:05:52 -0700 Subject: [PATCH 064/198] Move to the template system and overhaul instance attributes - All material shaders now use the template system. - Because of the template system, we can know what attributes a material has, along with how they're formatted. - All of the *Attribute enums are effectively inlined, as the context they used to provide is no longer needed. --- .../jozufozu/flywheel/backend/Backend.java | 10 ++- .../flywheel/backend/ShaderContext.java | 39 +++++++++-- .../flywheel/backend/ShaderLoader.java | 46 ++++--------- .../flywheel/backend/core/BasicProgram.java | 3 +- .../flywheel/backend/core/WorldContext.java | 60 +++++++++++----- .../core/materials/BasicAttributes.java | 39 ----------- .../core/materials/ModelAttributes.java | 41 ----------- .../core/materials/OrientedAttributes.java | 40 ----------- .../core/materials/TransformAttributes.java | 39 ----------- .../flywheel/backend/gl/GlPrimitiveType.java | 16 +++++ .../backend/gl/attrib/IVertexAttrib.java | 12 ---- .../backend/gl/attrib/VertexFormat.java | 20 +++--- .../backend/gl/buffer/MappedBuffer.java | 8 ++- .../gl/shader/FogSensitiveProgram.java | 3 +- .../flywheel/backend/gl/shader/GlProgram.java | 64 ----------------- .../backend/gl/shader/ProgramSpec.java | 45 +----------- .../backend/gl/shader/ShaderSpecLoader.java | 7 ++ .../backend/gl/shader/SingleProgram.java | 3 +- .../loading/InstancedArraysTemplate.java | 21 +++++- .../flywheel/backend/loading/LayoutTag.java | 19 +++++ .../backend/loading/ModelTemplate.java | 34 +++++++++ .../backend/loading/ParsedShader.java | 45 ------------ .../flywheel/backend/loading/Program.java | 69 +++++++++++++++++++ .../backend/loading/ProgramTemplate.java | 8 ++- .../flywheel/backend/loading/Shader.java | 63 ++++++++++++++--- .../backend/loading/ShaderTemplate.java | 25 ++++--- .../backend/loading/ShaderTransformer.java | 5 ++ .../flywheel/backend/loading/TaggedField.java | 48 +++++++++++++ .../backend/loading/TaggedStruct.java | 21 ++++-- .../flywheel/backend/loading/TypeHelper.java | 37 ++++++++++ .../contraptions/base/KineticAttributes.java | 41 ----------- .../contraptions/base/RotatingAttributes.java | 39 ----------- .../actors/ActorVertexAttributes.java | 45 ------------ .../render/ContraptionAttributes.java | 43 ------------ .../render/ContraptionContext.java | 24 ------- .../render/ContraptionKineticRenderer.java | 2 +- .../render/ContraptionRenderDispatcher.java | 10 ++- .../render/RenderedContraption.java | 7 +- .../relays/belt/BeltAttributes.java | 42 ----------- .../logistics/block/FlapAttributes.java | 46 ------------- .../foundation/render/AllInstanceFormats.java | 58 +++++++++------- .../foundation/render/AllMaterialSpecs.java | 6 +- .../foundation/render/AllProgramSpecs.java | 48 +++---------- .../render/CreateFlywheelHandler.java | 4 +- .../render/effects/EffectsContext.java | 14 ++-- .../render/effects/ScreenQuadAttributes.java | 38 ---------- .../assets/create/flywheel/shaders/belt.vert | 67 ++++++++---------- .../assets/create/flywheel/shaders/block.frag | 13 ++-- .../create/flywheel/shaders/block_new.frag | 17 ----- .../shaders/context/contraption/builtin.frag | 2 +- .../shaders/context/contraption/builtin.vert | 1 - .../shaders/context/crumbling/builtin.frag | 2 +- .../shaders/context/crumbling/builtin.vert | 2 +- .../context/{std => world}/builtin.frag | 2 +- .../context/{std => world}/builtin.vert | 1 - .../shaders/context/{std => world}/fog.glsl | 0 .../flywheel/shaders/contraption_actor.vert | 56 +++++++-------- .../shaders/contraption_structure.vert | 40 +++++------ .../flywheel/shaders/data/blockfragment.glsl | 7 ++ .../flywheel/shaders/data/modelvertex.glsl | 6 ++ .../assets/create/flywheel/shaders/flap.vert | 65 ++++++++--------- .../assets/create/flywheel/shaders/model.vert | 40 +++++------ .../create/flywheel/shaders/model_new.vert | 46 ------------- .../create/flywheel/shaders/oriented.vert | 42 +++++------ .../create/flywheel/shaders/rotating.vert | 69 ++++++++----------- .../shaders/template/model/model.frag | 12 ++++ .../shaders/template/model/model.vert | 15 ++++ 67 files changed, 739 insertions(+), 1123 deletions(-) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicAttributes.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelAttributes.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedAttributes.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformAttributes.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IVertexAttrib.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/LayoutTag.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/ModelTemplate.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/Program.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/TaggedField.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/TypeHelper.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/base/KineticAttributes.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/base/RotatingAttributes.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorVertexAttributes.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionAttributes.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionContext.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltAttributes.java delete mode 100644 src/main/java/com/simibubi/create/content/logistics/block/FlapAttributes.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/effects/ScreenQuadAttributes.java delete mode 100644 src/main/resources/assets/create/flywheel/shaders/block_new.frag rename src/main/resources/assets/create/flywheel/shaders/context/{std => world}/builtin.frag (91%) rename src/main/resources/assets/create/flywheel/shaders/context/{std => world}/builtin.vert (95%) rename src/main/resources/assets/create/flywheel/shaders/context/{std => world}/fog.glsl (100%) create mode 100644 src/main/resources/assets/create/flywheel/shaders/data/blockfragment.glsl create mode 100644 src/main/resources/assets/create/flywheel/shaders/data/modelvertex.glsl delete mode 100644 src/main/resources/assets/create/flywheel/shaders/model_new.vert create mode 100644 src/main/resources/assets/create/flywheel/shaders/template/model/model.frag create mode 100644 src/main/resources/assets/create/flywheel/shaders/template/model/model.vert diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index beab8e28e..62a8c0cd7 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -6,9 +6,11 @@ import static org.lwjgl.opengl.GL20.GL_TEXTURE_2D; import static org.lwjgl.opengl.GL20.glActiveTexture; import static org.lwjgl.opengl.GL20.glBindTexture; +import java.util.ArrayList; import java.util.BitSet; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.SortedSet; import java.util.Vector; @@ -76,7 +78,7 @@ public class Backend { private static boolean enabled; static final Map> materialRegistry = new HashMap<>(); - static final Map> contexts = new HashMap<>(); + static final List> contexts = new ArrayList<>(); static final Map programSpecRegistry = new HashMap<>(); static { @@ -119,11 +121,7 @@ public class Backend { * Register a shader context. */ public static

ShaderContext

register(ShaderContext

spec) { - ResourceLocation name = spec.getRoot(); - if (contexts.containsKey(name)) { - throw new IllegalStateException("Program spec '" + name + "' already registered."); - } - contexts.put(name, spec); + contexts.add(spec); return spec; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java index b4318d18c..dd4e6a5a3 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java @@ -6,9 +6,12 @@ import java.util.Map; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; -import com.jozufozu.flywheel.backend.loading.ProcessingStage; +import com.jozufozu.flywheel.backend.gl.shader.ShaderType; +import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.backend.loading.Shader; +import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import net.minecraft.util.ResourceLocation; @@ -17,27 +20,49 @@ public abstract class ShaderContext

{ public final Map> programs = new HashMap<>(); public final ResourceLocation root; + protected final ShaderSpecLoader

specLoader; + protected ShaderTransformer transformer = new ShaderTransformer(); - public ShaderContext(ResourceLocation root) { + public ShaderContext(ResourceLocation root, ShaderSpecLoader

specLoader) { this.root = root; + this.specLoader = specLoader; } - public abstract ShaderSpecLoader

getLoader(); + // TODO: Untangle the loading functions + /** + * Load all programs associated with this context. This might be just one, if the context is very specialized. + */ public abstract void load(ShaderLoader loader); public void loadProgramFromSpec(ShaderLoader loader, ProgramSpec programSpec) { - programs.put(programSpec, getLoader().create(loader, this, programSpec)); + programs.put(programSpec, specLoader.create(loader, this, programSpec)); Backend.log.debug("Loaded program {}", programSpec.name); } - public void preProcess(ShaderLoader loader, Shader shader) { + public Program loadProgram(ProgramSpec spec, ShaderConstants defines, ShaderLoader loader) { + if (defines != null) + transformer.pushStage(defines); + + Shader vertexFile = loader.source(spec.vert, ShaderType.VERTEX); + Shader fragmentFile = loader.source(spec.frag, ShaderType.FRAGMENT); + + transformer.transformSource(vertexFile); + transformer.transformSource(fragmentFile); + + Program program = loader.loadProgram(spec.name, vertexFile, fragmentFile); + if (defines != null) + transformer.popStage(); + + preLink(program); + + return program.link(); } - public ProcessingStage loadingStage(ShaderLoader loader) { - return shader -> this.preProcess(loader, shader); + protected void preLink(Program program) { + } public P getProgram(ProgramSpec spec) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index a786efefb..569e2f3f4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -27,11 +27,10 @@ import org.lwjgl.system.MemoryUtil; import com.google.common.collect.Lists; import com.jozufozu.flywheel.backend.gl.GlObject; -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.GlShader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; +import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.backend.loading.Shader; -import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.resources.IResource; @@ -59,26 +58,7 @@ public class ShaderLoader { shaderSource.clear(); loadShaderSources(manager); -// InstancedArraysTemplate template = new InstancedArraysTemplate(this); -// -// ResourceLocation name = new ResourceLocation("create", "test"); -// ResourceLocation vert = new ResourceLocation("create", "model_new.vert"); -// ResourceLocation frag = new ResourceLocation("create", "block_new.frag"); -// -// ShaderTransformer transformer = new ShaderTransformer() -// .pushStage(WorldContext.INSTANCE.loadingStage(this)) -// .pushStage(this::processIncludes) -// .pushStage(template) -// .pushStage(this::processIncludes); -// -// Shader vertexFile = this.source(vert, ShaderType.VERTEX); -// Shader fragmentFile = this.source(frag, ShaderType.FRAGMENT); -// -// GlProgram.Builder builder = loadProgram(name, transformer, vertexFile, fragmentFile); -// -// BasicProgram program = new BasicProgram(builder, GlFogMode.NONE.getFogFactory()); - - for (ShaderContext context : Backend.contexts.values()) { + for (ShaderContext context : Backend.contexts) { context.load(this); } @@ -122,32 +102,30 @@ public class ShaderLoader { return new Shader(type, name, getShaderSource(name)); } - public GlProgram.Builder loadProgram(ResourceLocation name, ShaderTransformer transformer, Shader... shaders) { - return loadProgram(name, transformer, Lists.newArrayList(shaders)); + public Program loadProgram(ResourceLocation name, Shader... shaders) { + return loadProgram(name, Lists.newArrayList(shaders)); } /** * Ingests the given shaders, compiling them and linking them together after applying the transformer to the source. * - * @param name What should we call this program if something goes wrong? - * @param transformer What should we do to the sources before compilation? - * @param shaders What are the different shader stages that should be linked together? - * @return A linked program builder. + * @param name What should we call this program if something goes wrong? + * @param shaders What are the different shader stages that should be linked together? + * @return A program with all provided shaders attached */ - public GlProgram.Builder loadProgram(ResourceLocation name, ShaderTransformer transformer, Collection shaders) { + public Program loadProgram(ResourceLocation name, Collection shaders) { List compiled = new ArrayList<>(shaders.size()); try { - GlProgram.Builder builder = GlProgram.builder(name); + Program builder = new Program(name); for (Shader shader : shaders) { - transformer.transformSource(shader); GlShader sh = new GlShader(shader); compiled.add(sh); - builder.attachShader(sh); + builder.attachShader(shader, sh); } - return builder.link(); + return builder; } finally { compiled.forEach(GlObject::delete); } @@ -180,7 +158,7 @@ public class ShaderLoader { ResourceLocation include = new ResourceLocation(includeName); if (seen.add(include)) { - String includeSource = shaderSource.get(include); + String includeSource = getShaderSource(include); if (includeSource != null) { return includeRecursive(includeSource, seen); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java index 5d61e5924..80e554f39 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java @@ -5,6 +5,7 @@ import static org.lwjgl.opengl.GL20.glUniform3f; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; +import com.jozufozu.flywheel.backend.loading.Program; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.ResourceLocation; @@ -20,7 +21,7 @@ public class BasicProgram extends GlProgram { protected int uBlockAtlas; protected int uLightMap; - public BasicProgram(GlProgram.Builder builder, ProgramFogMode.Factory fogFactory) { + public BasicProgram(Program builder, ProgramFogMode.Factory fogFactory) { this(builder.name, builder.program, fogFactory); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index c0ee56f44..c2fbdcdbb 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -2,8 +2,10 @@ package com.jozufozu.flywheel.backend.core; import java.util.EnumMap; import java.util.Map; +import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Stream; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.ResourceUtil; @@ -11,10 +13,15 @@ import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; +import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; +import com.jozufozu.flywheel.backend.loading.InstancedArraysTemplate; +import com.jozufozu.flywheel.backend.loading.Program; +import com.jozufozu.flywheel.backend.loading.ProgramTemplate; import com.jozufozu.flywheel.backend.loading.Shader; +import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import net.minecraft.util.ResourceLocation; @@ -23,20 +30,30 @@ public class WorldContext

extends ShaderContext

{ private static final String declaration = "#flwbuiltins"; private static final Pattern builtinPattern = Pattern.compile(declaration); - public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation("create", "context/std"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); + public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation("create", "context/world"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation("create", "context/crumbling"), new FogSensitiveProgram.SpecLoader<>(CrumblingProgram::new)); - private final ShaderSpecLoader

loader; - final Map builtins; + final Map builtinSources; + + protected ProgramTemplate template; + protected final Supplier> specStream; + protected final TemplateFactory templateFactory; public WorldContext(ResourceLocation root, ShaderSpecLoader

loader) { - super(root); + this(root, loader, () -> Backend.allMaterials() + .stream() + .map(MaterialSpec::getProgramSpec), InstancedArraysTemplate::new); + } + + public WorldContext(ResourceLocation root, ShaderSpecLoader

loader, Supplier> specStream, TemplateFactory templateFactory) { + super(root, loader); + this.specStream = specStream; + this.templateFactory = templateFactory; builtins = new EnumMap<>(ShaderType.class); + builtinSources = new EnumMap<>(ShaderType.class); builtins.put(ShaderType.FRAGMENT, ResourceUtil.subPath(root, "/builtin.frag")); builtins.put(ShaderType.VERTEX, ResourceUtil.subPath(root, "/builtin.vert")); - - this.loader = loader; } @Override @@ -44,26 +61,37 @@ public class WorldContext

extends ShaderContext

{ programs.values().forEach(IMultiProgram::delete); programs.clear(); - Backend.allMaterials() - .stream() - .map(MaterialSpec::getProgramSpec) - .forEach(spec -> loadProgramFromSpec(loader, spec)); + builtins.forEach((type, resourceLocation) -> builtinSources.put(type, loader.getShaderSource(resourceLocation))); + + template = templateFactory.create(loader); + transformer = new ShaderTransformer() + .pushStage(this::injectBuiltins) + .pushStage(loader::processIncludes) + .pushStage(Shader::parseStructs) + .pushStage(template) + .pushStage(loader::processIncludes); + + specStream.get().forEach(spec -> loadProgramFromSpec(loader, spec)); } @Override - public void preProcess(ShaderLoader loader, Shader shader) { - String builtinSrc = loader.getShaderSource(builtins.get(shader.type)); + protected void preLink(Program program) { + template.attachAttributes(program); + } + /** + * Replace #flwbuiltins with whatever expansion this context provides for the given shader. + */ + public void injectBuiltins(Shader shader) { Matcher matcher = builtinPattern.matcher(shader.getSource()); if (matcher.find()) - shader.setSource(matcher.replaceFirst(builtinSrc)); + shader.setSource(matcher.replaceFirst(builtinSources.get(shader.type))); else throw new RuntimeException(String.format("%s shader '%s' is missing %s, cannot use in World Context", shader.type.name, shader.name, declaration)); } - @Override - public ShaderSpecLoader

getLoader() { - return loader; + public interface TemplateFactory { + ProgramTemplate create(ShaderLoader loader); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicAttributes.java deleted file mode 100644 index 4309c1365..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/BasicAttributes.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.jozufozu.flywheel.backend.core.materials; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; - -public enum BasicAttributes implements IVertexAttrib { - LIGHT("aLight", CommonAttributes.LIGHT), - COLOR("aColor", CommonAttributes.RGBA), - ; - - private final String name; - private final IAttribSpec spec; - - BasicAttributes(String name, IAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 0; - } - - @Override - public int getBufferIndex() { - return 0; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelAttributes.java deleted file mode 100644 index 16ed122dd..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/ModelAttributes.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jozufozu.flywheel.backend.core.materials; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; -import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; - -public enum ModelAttributes implements IVertexAttrib { - VERTEX_POSITION("aPos", CommonAttributes.VEC3), - NORMAL("aNormal", CommonAttributes.NORMAL), - TEXTURE("aTexCoords", CommonAttributes.UV), - ; - - private final String name; - private final VertexAttribSpec spec; - - ModelAttributes(String name, VertexAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 0; - } - - @Override - public int getBufferIndex() { - return 0; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedAttributes.java deleted file mode 100644 index 9d74baef4..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/OrientedAttributes.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jozufozu.flywheel.backend.core.materials; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; - -public enum OrientedAttributes implements IVertexAttrib { - INSTANCE_POS("aInstancePos", CommonAttributes.VEC3), - PIVOT("aPivot", CommonAttributes.VEC3), - ROTATION("aRotation", CommonAttributes.QUATERNION), - ; - - private final String name; - private final IAttribSpec spec; - - OrientedAttributes(String name, IAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 0; - } - - @Override - public int getBufferIndex() { - return 0; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformAttributes.java deleted file mode 100644 index 48c85b185..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/materials/TransformAttributes.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.jozufozu.flywheel.backend.core.materials; - -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; -import com.jozufozu.flywheel.backend.gl.attrib.MatrixAttributes; - -public enum TransformAttributes implements IVertexAttrib { - TRANSFORM("aTransform", MatrixAttributes.MAT4), - NORMAL_MAT("aNormalMat", MatrixAttributes.MAT3), - ; - - private final String name; - private final IAttribSpec spec; - - TransformAttributes(String name, IAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 0; - } - - @Override - public int getBufferIndex() { - return 0; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java index 3a143e3cf..1737c6bd4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java @@ -1,5 +1,12 @@ package com.jozufozu.flywheel.backend.gl; +import java.util.Arrays; +import java.util.Locale; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.annotation.Nullable; + import org.lwjgl.opengl.GL11; import net.minecraftforge.api.distmarker.Dist; @@ -15,6 +22,10 @@ public enum GlPrimitiveType { UINT(4, "uint", GL11.GL_UNSIGNED_INT), INT(4, "int", GL11.GL_INT); + private static final GlPrimitiveType[] VALUES = values(); + private static final Map NAME_LOOKUP = Arrays.stream(VALUES) + .collect(Collectors.toMap(GlPrimitiveType::getDisplayName, type -> type)); + private final int size; private final String displayName; private final int glConstant; @@ -36,4 +47,9 @@ public enum GlPrimitiveType { public int getGlConstant() { return this.glConstant; } + + @Nullable + public static GlPrimitiveType byName(String name) { + return name == null ? null : NAME_LOOKUP.get(name.toLowerCase(Locale.ROOT)); + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IVertexAttrib.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IVertexAttrib.java deleted file mode 100644 index 5775962d8..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IVertexAttrib.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.jozufozu.flywheel.backend.gl.attrib; - -public interface IVertexAttrib { - - String attribName(); - - IAttribSpec attribSpec(); - - int getDivisor(); - - int getBufferIndex(); -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java index 714c7e677..9b325e6ed 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java @@ -1,21 +1,20 @@ package com.jozufozu.flywheel.backend.gl.attrib; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; public class VertexFormat { - private final ArrayList allAttributes; + private final ArrayList allAttributes; private final int numAttributes; private final int stride; - public VertexFormat(ArrayList allAttributes) { + public VertexFormat(ArrayList allAttributes) { this.allAttributes = allAttributes; int numAttributes = 0, stride = 0; - for (IVertexAttrib attrib : allAttributes) { - IAttribSpec spec = attrib.attribSpec(); + for (IAttribSpec spec : allAttributes) { numAttributes += spec.getAttributeCount(); stride += spec.getSize(); } @@ -33,8 +32,7 @@ public class VertexFormat { public void vertexAttribPointers(int index) { int offset = 0; - for (IVertexAttrib attrib : this.allAttributes) { - IAttribSpec spec = attrib.attribSpec(); + for (IAttribSpec spec : this.allAttributes) { spec.vertexAttribPointer(stride, index, offset); index += spec.getAttributeCount(); offset += spec.getSize(); @@ -45,16 +43,14 @@ public class VertexFormat { return new Builder(); } - public static class Builder { - private final ArrayList allAttributes; + private final ArrayList allAttributes = new ArrayList<>(); public Builder() { - allAttributes = new ArrayList<>(); } - public & IVertexAttrib> Builder addAttributes(Class attribEnum) { - allAttributes.addAll(Arrays.asList(attribEnum.getEnumConstants())); + public Builder addAttributes(IAttribSpec... attributes) { + Collections.addAll(allAttributes, attributes); return this; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java index f8ee93fdc..8d6878dd1 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/MappedBuffer.java @@ -38,8 +38,12 @@ public abstract class MappedBuffer implements AutoCloseable { public MappedBuffer putFloatArray(float[] floats) { checkAndMap(); - internal.asFloatBuffer().put(floats); - internal.position(internal.position() + floats.length * 4); + + for (float f : floats) { + internal.putFloat(f); + } +// internal.asFloatBuffer().put(floats); +// internal.position(internal.position() + floats.length * 4); return this; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java index ac158da54..7aa8ef21d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java @@ -7,6 +7,7 @@ import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.gl.GlFog; import com.jozufozu.flywheel.backend.gl.GlFogMode; +import com.jozufozu.flywheel.backend.loading.Program; import net.minecraft.util.ResourceLocation; @@ -45,7 +46,7 @@ public class FogSensitiveProgram

implements IMultiProgram

Builder addAttributes(Collection attributes) { - attributes.forEach(this::addAttribute); - return this; - } - - public Builder addAttribute(A attrib) { - glBindAttribLocation(this.program, attributeIndex, attrib.attribName()); - attributeIndex += attrib.attribSpec().getAttributeCount(); - return this; - } - - /** - * Links the attached shaders to this program. - */ - public Builder link() { - glLinkProgram(this.program); - - String log = glGetProgramInfoLog(this.program); - - if (!log.isEmpty()) { - Backend.log.debug("Program link log for " + this.name + ": " + log); - } - - int result = glGetProgrami(this.program, GL_LINK_STATUS); - - if (result != GL_TRUE) { - throw new RuntimeException("Shader program linking failed, see log for details"); - } - - return this; - } - } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java index 4f1cfa0ae..247662d22 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java @@ -1,15 +1,5 @@ package com.jozufozu.flywheel.backend.gl.shader; -import java.util.ArrayList; -import java.util.Arrays; - -import com.jozufozu.flywheel.backend.ShaderContext; -import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; -import com.jozufozu.flywheel.backend.loading.InstancedArraysTemplate; -import com.jozufozu.flywheel.backend.loading.Shader; -import com.jozufozu.flywheel.backend.loading.ShaderTransformer; - import net.minecraft.util.ResourceLocation; public class ProgramSpec { @@ -20,37 +10,15 @@ public class ProgramSpec { public final ShaderConstants defines; - public final ArrayList attributes; - public static Builder builder(ResourceLocation name) { return new Builder(name); } - public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag, ShaderConstants defines, ArrayList attributes) { + public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag, ShaderConstants defines) { this.name = name; this.vert = vert; this.frag = frag; this.defines = defines; - - this.attributes = attributes; - } - - public GlProgram.Builder loadProgram(ShaderContext ctx, ShaderConstants defines, ShaderLoader loader) { - InstancedArraysTemplate template = new InstancedArraysTemplate(loader); - - ShaderTransformer transformer = new ShaderTransformer() - .pushStage(ctx.loadingStage(loader)) -// .pushStage(loader::processIncludes) -// .pushStage(template) - .pushStage(loader::processIncludes); - - if (defines != null) - transformer.pushStage(defines); - - Shader vertexFile = loader.source(vert, ShaderType.VERTEX); - Shader fragmentFile = loader.source(frag, ShaderType.FRAGMENT); - return loader.loadProgram(name, transformer, vertexFile, fragmentFile) - .addAttributes(attributes); } public static class Builder { @@ -59,11 +27,9 @@ public class ProgramSpec { private ShaderConstants defines = ShaderConstants.EMPTY; private final ResourceLocation name; - private final ArrayList attributes; public Builder(ResourceLocation name) { this.name = name; - attributes = new ArrayList<>(); } public Builder setVert(ResourceLocation vert) { @@ -81,13 +47,8 @@ public class ProgramSpec { return this; } - public & IVertexAttrib> Builder addAttributes(Class attributeEnum) { - attributes.addAll(Arrays.asList(attributeEnum.getEnumConstants())); - return this; - } - - public ProgramSpec createProgramSpec() { - return new ProgramSpec(name, vert, frag, defines, attributes); + public ProgramSpec build() { + return new ProgramSpec(name, vert, frag, defines); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java index a9d635c8e..f050ac981 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java @@ -4,5 +4,12 @@ import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; public interface ShaderSpecLoader

{ + + /** + * @param loader + * @param ctx + * @param spec + * @return + */ IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java index 844052880..a957d24b6 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java @@ -2,6 +2,7 @@ package com.jozufozu.flywheel.backend.gl.shader; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.loading.Program; import net.minecraft.util.ResourceLocation; @@ -31,7 +32,7 @@ public class SingleProgram

implements IMultiProgram

{ @Override public IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { - GlProgram.Builder builder = spec.loadProgram(ctx, spec.defines, loader); + Program builder = ctx.loadProgram(spec, spec.defines, loader); return new SingleProgram<>(factory.create(builder.name, builder.program)); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java index 66135e832..1314e66b9 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java @@ -6,8 +6,17 @@ import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import net.minecraft.util.ResourceLocation; public class InstancedArraysTemplate extends ProgramTemplate { - public static final String[] requiredVert = {"FLWInstanceData", "FLWVertexData", "FLWFragment"}; - public static final String[] requiredFrag = {"FLWFragment"}; + + public static final String vertexData = "VertexData"; + public static final String instanceData = "InstanceData"; + public static final String fragment = "Fragment"; + + public static final String vertexPrefix = "a_v_"; + public static final String instancePrefix = "a_i_"; + + public static final String[] requiredVert = new String[]{instanceData, vertexData, fragment}; + + public static final String[] requiredFrag = {fragment}; public static final ResourceLocation vert = new ResourceLocation("create", "template/instanced/instanced.vert"); public static final ResourceLocation frag = new ResourceLocation("create", "template/instanced/instanced.frag"); @@ -18,4 +27,12 @@ public class InstancedArraysTemplate extends ProgramTemplate { templates.put(ShaderType.VERTEX, new ShaderTemplate(requiredVert, loader.getShaderSource(vert))); templates.put(ShaderType.FRAGMENT, new ShaderTemplate(requiredFrag, loader.getShaderSource(frag))); } + + @Override + public void attachAttributes(Program builder) { + Shader shader = builder.attached.get(ShaderType.VERTEX); + + shader.getTag(vertexData).addPrefixedAttributes(builder, vertexPrefix); + shader.getTag(instanceData).addPrefixedAttributes(builder, instancePrefix); + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/LayoutTag.java b/src/main/java/com/jozufozu/flywheel/backend/loading/LayoutTag.java new file mode 100644 index 000000000..ca6ab3445 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/LayoutTag.java @@ -0,0 +1,19 @@ +package com.jozufozu.flywheel.backend.loading; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; + +public class LayoutTag { + + public static final Pattern pattern = Pattern.compile("Layout\\((\\w+)(?:\\s*,\\s*(\\w*))?\\)"); + + final GlPrimitiveType type; + final boolean normalized; + + public LayoutTag(Matcher matcher) { + type = GlPrimitiveType.byName(matcher.group(1)); + normalized = Boolean.parseBoolean(matcher.group(2)); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ModelTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ModelTemplate.java new file mode 100644 index 000000000..ffa650c73 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ModelTemplate.java @@ -0,0 +1,34 @@ +package com.jozufozu.flywheel.backend.loading; + +import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.gl.shader.ShaderType; + +import net.minecraft.util.ResourceLocation; + +public class ModelTemplate extends ProgramTemplate { + public static final String vertexData = "VertexData"; + public static final String fragment = "Fragment"; + + public static final String vertexPrefix = "a_v_"; + + public static final String[] requiredVert = new String[]{vertexData, fragment}; + + public static final String[] requiredFrag = {fragment}; + + public static final ResourceLocation vert = new ResourceLocation("create", "template/model/model.vert"); + public static final ResourceLocation frag = new ResourceLocation("create", "template/model/model.frag"); + + public ModelTemplate(ShaderLoader loader) { + super(loader); + + templates.put(ShaderType.VERTEX, new ShaderTemplate(requiredVert, loader.getShaderSource(vert))); + templates.put(ShaderType.FRAGMENT, new ShaderTemplate(requiredFrag, loader.getShaderSource(frag))); + } + + @Override + public void attachAttributes(Program builder) { + Shader shader = builder.attached.get(ShaderType.VERTEX); + + shader.getTag(vertexData).addPrefixedAttributes(builder, vertexPrefix); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java deleted file mode 100644 index a1f050cc5..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/ParsedShader.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jozufozu.flywheel.backend.loading; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import net.minecraft.util.ResourceLocation; - -public class ParsedShader { - private static final Pattern decorator = Pattern.compile("#\\[([\\w_]*)]"); - private static final Pattern taggedStruct = Pattern.compile("#\\[([\\w_]*)]\\s*struct\\s+([\\w\\d_]*)\\s*\\{(\\s*(?:.*;\\s*\\n)+\\s*)}\\s*;"); - - final ResourceLocation loc; - final String src; - - final Map tag2Struct = new HashMap<>(); - final Map name2Struct = new HashMap<>(); - - public ParsedShader(ResourceLocation loc, String src) { - this.loc = loc; - Matcher structs = taggedStruct.matcher(src); - - StringBuffer strippedSrc = new StringBuffer(); - while (structs.find()) { - TaggedStruct struct = new TaggedStruct(structs); - - structs.appendReplacement(strippedSrc, decorator.matcher(struct.source).replaceFirst("")); - - tag2Struct.put(struct.tag, struct); - name2Struct.put(struct.name, struct); - } - structs.appendTail(strippedSrc); - - this.src = strippedSrc.toString(); - } - - public TaggedStruct getTag(String tag) { - return tag2Struct.get(tag); - } - - public TaggedStruct getStruct(String name) { - return name2Struct.get(name); - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/Program.java b/src/main/java/com/jozufozu/flywheel/backend/loading/Program.java new file mode 100644 index 000000000..43f6fefe8 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/Program.java @@ -0,0 +1,69 @@ +package com.jozufozu.flywheel.backend.loading; + +import static org.lwjgl.opengl.GL20.GL_LINK_STATUS; +import static org.lwjgl.opengl.GL20.GL_TRUE; +import static org.lwjgl.opengl.GL20.glAttachShader; +import static org.lwjgl.opengl.GL20.glBindAttribLocation; +import static org.lwjgl.opengl.GL20.glCreateProgram; +import static org.lwjgl.opengl.GL20.glGetProgramInfoLog; +import static org.lwjgl.opengl.GL20.glGetProgrami; +import static org.lwjgl.opengl.GL20.glLinkProgram; + +import java.util.EnumMap; +import java.util.Map; + +import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.gl.shader.GlShader; +import com.jozufozu.flywheel.backend.gl.shader.ShaderType; + +import net.minecraft.util.ResourceLocation; + +public class Program { + public final ResourceLocation name; + public final int program; + + private int attributeIndex; + + public final Map attached; + + public Program(ResourceLocation name) { + this.name = name; + this.program = glCreateProgram(); + attached = new EnumMap<>(ShaderType.class); + } + + public Program attachShader(Shader shader, GlShader glShader) { + glAttachShader(this.program, glShader.handle()); + + attached.put(shader.type, shader); + + return this; + } + + public Program addAttribute(String name, int attributeCount) { + glBindAttribLocation(this.program, attributeIndex, name); + attributeIndex += attributeCount; + return this; + } + + /** + * Links the attached shaders to this program. + */ + public Program link() { + glLinkProgram(this.program); + + String log = glGetProgramInfoLog(this.program); + + if (!log.isEmpty()) { + Backend.log.debug("Program link log for " + this.name + ": " + log); + } + + int result = glGetProgrami(this.program, GL_LINK_STATUS); + + if (result != GL_TRUE) { + throw new RuntimeException("Shader program linking failed, see log for details"); + } + + return this; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ProgramTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ProgramTemplate.java index ea9378607..df2859cd5 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/ProgramTemplate.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ProgramTemplate.java @@ -6,7 +6,7 @@ import java.util.Map; import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; -public class ProgramTemplate implements ProcessingStage { +public abstract class ProgramTemplate implements ProcessingStage { protected final ShaderLoader loader; protected Map templates = new EnumMap<>(ShaderType.class); @@ -21,8 +21,10 @@ public class ProgramTemplate implements ProcessingStage { if (template == null) return; - ParsedShader parsedShader = new ParsedShader(shader.name, shader.getSource()); + shader.setSource(template.apply(shader)); + } + + public void attachAttributes(Program builder) { - shader.setSource(template.apply(parsedShader)); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java b/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java index 769e1ab5a..aa70847b8 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java @@ -1,26 +1,32 @@ package com.jozufozu.flywheel.backend.loading; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import net.minecraft.util.ResourceLocation; public class Shader { + private static final Pattern decorator = Pattern.compile("#\\[([\\w_]*)]"); + + public final ResourceLocation name; public ShaderType type; - public ResourceLocation name; private String source; + private boolean parsed = false; + final List structs = new ArrayList<>(3); + final Map tag2Struct = new HashMap<>(); + final Map name2Struct = new HashMap<>(); + public Shader(ShaderType type, ResourceLocation name, String source) { this.type = type; this.name = name; - this.setSource(source); - } - - public static Shader vert(ResourceLocation fileLoc, String source) { - return new Shader(ShaderType.VERTEX, fileLoc, source); - } - - public static Shader frag(ResourceLocation fileLoc, String source) { - return new Shader(ShaderType.FRAGMENT, fileLoc, source); + this.source = source; } public String getSource() { @@ -30,4 +36,41 @@ public class Shader { public void setSource(String source) { this.source = source; } + + public TaggedStruct getTag(String tag) { + checkAndParse(); + return tag2Struct.get(tag); + } + + public TaggedStruct getStruct(String name) { + checkAndParse(); + return name2Struct.get(name); + } + + private void checkAndParse() { + if (!parsed) { + parsed = true; + parseStructs(); + } + } + + public void parseStructs() { + Matcher structMatcher = TaggedStruct.taggedStruct.matcher(source); + + StringBuffer strippedSrc = new StringBuffer(); + + while (structMatcher.find()) { + TaggedStruct struct = new TaggedStruct(structMatcher); + + structs.add(struct); + + structMatcher.appendReplacement(strippedSrc, decorator.matcher(struct.source).replaceFirst("")); + + tag2Struct.put(struct.tag, struct); + name2Struct.put(struct.name, struct); + } + structMatcher.appendTail(strippedSrc); + + this.source = strippedSrc.toString(); + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTemplate.java index cee98d09e..d2ed593f4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTemplate.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTemplate.java @@ -2,7 +2,6 @@ package com.jozufozu.flywheel.backend.loading; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -32,14 +31,14 @@ public class ShaderTemplate { } - public String apply(ParsedShader shader) { + public String apply(Shader shader) { return header + - shader.src + + shader.getSource() + processBody(shader); } - public String processBody(ParsedShader shader) { + public String processBody(Shader shader) { String s = body; List missing = new ArrayList<>(); @@ -55,7 +54,7 @@ public class ShaderTemplate { } if (!missing.isEmpty()) { - String err = shader.loc + " is missing: " + String.join(", ", missing); + String err = shader.name + " is missing: " + String.join(", ", missing); throw new RuntimeException(err); } @@ -65,7 +64,7 @@ public class ShaderTemplate { return s; } - private String fillPrefixes(ParsedShader shader, String s) { + private String fillPrefixes(Shader shader, String s) { Matcher prefixMatches = prefixer.matcher(s); StringBuffer out = new StringBuffer(); @@ -77,13 +76,13 @@ public class ShaderTemplate { TaggedStruct struct = shader.getStruct(structName); StringBuilder builder = new StringBuilder(); - for (Map.Entry field : struct.fields.entrySet()) { + for (TaggedField field : struct.fields) { builder.append(modifier); builder.append(' '); - builder.append(field.getValue()); + builder.append(field.getType()); builder.append(' '); builder.append(prefix); - builder.append(field.getKey()); + builder.append(field.getName()); builder.append(";\n"); } @@ -93,7 +92,7 @@ public class ShaderTemplate { return out.toString(); } - private String fillAssigns(ParsedShader shader, String s) { + private String fillAssigns(Shader shader, String s) { Matcher assignMatches = assigner.matcher(s); StringBuffer out = new StringBuffer(); @@ -105,12 +104,12 @@ public class ShaderTemplate { TaggedStruct struct = shader.getStruct(structName); StringBuilder builder = new StringBuilder(); - for (String field : struct.fields.keySet()) { + for (TaggedField field : struct.fields) { builder.append(lhs); - builder.append(field); + builder.append(field.getName()); builder.append(" = "); builder.append(rhs); - builder.append(field); + builder.append(field.getName()); builder.append(";\n"); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTransformer.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTransformer.java index ddd50c601..1eca0c1b3 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTransformer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderTransformer.java @@ -16,6 +16,11 @@ public class ShaderTransformer { return this; } + public ShaderTransformer popStage() { + stages.removeLast(); + return this; + } + public ShaderTransformer prependStage(ProcessingStage stage) { if (stage != null) { stages.addFirst(stage); diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedField.java b/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedField.java new file mode 100644 index 000000000..2d2cfdcdb --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedField.java @@ -0,0 +1,48 @@ +package com.jozufozu.flywheel.backend.loading; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TaggedField { + public static final Pattern fieldPattern = Pattern.compile("(?:#\\[([^\\n]*)]\\s*)?(\\S+)\\s*(\\S+);"); + + public String annotation; + public String name; + public String type; + public LayoutTag layout; + + public TaggedField(Matcher fieldMatcher) { + annotation = fieldMatcher.group(1); + type = fieldMatcher.group(2); + name = fieldMatcher.group(3); + + if (annotation != null) { + Matcher matcher = LayoutTag.pattern.matcher(annotation); + + if (matcher.find()) { + layout = new LayoutTag(matcher); + } + } + } + + public String getAnnotation() { + return annotation; + } + + public String getName() { + return name; + } + + public String getType() { + return type; + } + + + @Override + public String toString() { + return "TaggedField{" + + "name='" + name + '\'' + + ", type='" + type + '\'' + + '}'; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedStruct.java b/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedStruct.java index 4249047c9..eac1ee079 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedStruct.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/TaggedStruct.java @@ -1,13 +1,16 @@ package com.jozufozu.flywheel.backend.loading; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public class TaggedStruct { - public static final Pattern fieldPattern = Pattern.compile("(\\S+)\\s*(\\S+);"); + // https://regexr.com/5t207 + static final Pattern taggedStruct = Pattern.compile("#\\[(\\w*)]\\s*struct\\s+([\\w\\d]*)\\s*\\{([\\w\\d \\t#\\[\\](),;\\n]*)}\\s*;"); int srcStart, srcEnd; String source; @@ -15,7 +18,8 @@ public class TaggedStruct { String name; String body; - Map fields = new HashMap<>(); + List fields = new ArrayList<>(4); + Map fields2Types = new HashMap<>(); public TaggedStruct(Matcher foundMatcher) { this.source = foundMatcher.group(); @@ -27,10 +31,19 @@ public class TaggedStruct { name = foundMatcher.group(2); body = foundMatcher.group(3); - Matcher fielder = fieldPattern.matcher(body); + Matcher fielder = TaggedField.fieldPattern.matcher(body); while (fielder.find()) { - fields.put(fielder.group(2), fielder.group(1)); + fields.add(new TaggedField(fielder)); + fields2Types.put(fielder.group(2), fielder.group(1)); + } + } + + public void addPrefixedAttributes(Program builder, String prefix) { + for (TaggedField field : fields) { + int attributeCount = TypeHelper.getAttributeCount(field.type); + + builder.addAttribute(prefix + field.name, attributeCount); } } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/TypeHelper.java b/src/main/java/com/jozufozu/flywheel/backend/loading/TypeHelper.java new file mode 100644 index 000000000..2d67ff460 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/TypeHelper.java @@ -0,0 +1,37 @@ +package com.jozufozu.flywheel.backend.loading; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TypeHelper { + + public static final Pattern vecType = Pattern.compile("^[biud]?vec([234])$"); + public static final Pattern matType = Pattern.compile("^mat([234])(?:x([234]))?$"); + + public static int getElementCount(String type) { + Matcher vec = vecType.matcher(type); + if (vec.find()) return Integer.parseInt(vec.group(1)); + + Matcher mat = matType.matcher(type); + if (mat.find()) { + int n = Integer.parseInt(mat.group(1)); + + String m = mat.group(2); + + if (m != null) return Integer.parseInt(m) * n; + + return n; + } + + return 1; + } + + public static int getAttributeCount(String type) { + Matcher mat = matType.matcher(type); + if (mat.find()) { + return Integer.parseInt(mat.group(1)); + } + + return 1; + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticAttributes.java deleted file mode 100644 index 3d9f31d5f..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticAttributes.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.simibubi.create.content.contraptions.base; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; -import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; - -public enum KineticAttributes implements IVertexAttrib { - INSTANCE_POSITION("aInstancePos", CommonAttributes.VEC3), - SPEED("aSpeed", CommonAttributes.FLOAT), - OFFSET("aOffset", CommonAttributes.FLOAT), - ; - - private final String name; - private final VertexAttribSpec spec; - - KineticAttributes(String name, VertexAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 1; - } - - @Override - public int getBufferIndex() { - return 1; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/base/RotatingAttributes.java deleted file mode 100644 index 215027123..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingAttributes.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.simibubi.create.content.contraptions.base; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; -import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; - -public enum RotatingAttributes implements IVertexAttrib { - AXIS("aAxis", CommonAttributes.NORMAL), - ; - - private final String name; - private final VertexAttribSpec spec; - - RotatingAttributes(String name, VertexAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 1; - } - - @Override - public int getBufferIndex() { - return 1; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorVertexAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorVertexAttributes.java deleted file mode 100644 index 696d9279a..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorVertexAttributes.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.simibubi.create.content.contraptions.components.actors; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; -import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; - -public enum ActorVertexAttributes implements IVertexAttrib { - INSTANCE_POSITION("aInstancePos", CommonAttributes.VEC3), - LIGHT("aModelLight", CommonAttributes.LIGHT), - OFFSET("aOffset", CommonAttributes.FLOAT), - AXIS("aAxis", CommonAttributes.NORMAL), - INSTANCE_ROTATION("aInstanceRot", CommonAttributes.QUATERNION), - ROTATION_CENTER("aRotationCenter", CommonAttributes.NORMAL), - SPEED("aSpeed", CommonAttributes.FLOAT), - ; - - private final String name; - private final VertexAttribSpec spec; - - ActorVertexAttributes(String name, VertexAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 1; - } - - @Override - public int getBufferIndex() { - return 1; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionAttributes.java deleted file mode 100644 index 649f5e680..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionAttributes.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.simibubi.create.content.contraptions.components.structureMovement.render; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; -import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; - -public enum ContraptionAttributes implements IVertexAttrib { - VERTEX_POSITION("aPos", CommonAttributes.VEC3), - NORMAL("aNormal", CommonAttributes.NORMAL), - TEXTURE("aTexCoords", CommonAttributes.UV), - COLOR("aColor", CommonAttributes.RGBA), - MODEL_LIGHT("aModelLight", CommonAttributes.LIGHT), - ; - - private final String name; - private final VertexAttribSpec spec; - - ContraptionAttributes(String name, VertexAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 0; - } - - @Override - public int getBufferIndex() { - return 0; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionContext.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionContext.java deleted file mode 100644 index e3bf437dd..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionContext.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.simibubi.create.content.contraptions.components.structureMovement.render; - -import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.core.WorldContext; -import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; -import com.simibubi.create.foundation.render.AllProgramSpecs; - -import net.minecraft.util.ResourceLocation; - -public class ContraptionContext extends WorldContext { - - public static final ContraptionContext INSTANCE = new ContraptionContext(); - - public ContraptionContext() { - super(new ResourceLocation("create", "context/contraption"), new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)); - } - - @Override - public void load(ShaderLoader loader) { - super.load(loader); - - loadProgramFromSpec(loader, AllProgramSpecs.STRUCTURE); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java index a65f178fa..b10f10f2c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionKineticRenderer.java @@ -26,7 +26,7 @@ public class ContraptionKineticRenderer extends InstancedTileRenderer contraption; ContraptionKineticRenderer(RenderedContraption contraption) { - super(ContraptionContext.INSTANCE); + super(ContraptionRenderDispatcher.TILES); this.contraption = new WeakReference<>(contraption); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index d98369b87..6d0c80d0f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -10,10 +10,14 @@ import static org.lwjgl.opengl.GL13.glEnable; import java.util.List; import java.util.Random; +import java.util.stream.Stream; import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.core.WorldContext; +import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; +import com.jozufozu.flywheel.backend.loading.ModelTemplate; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.CreateClient; @@ -48,6 +52,7 @@ import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.world.ClientWorld; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.world.LightType; @@ -59,6 +64,9 @@ import net.minecraftforge.client.model.data.EmptyModelData; public class ContraptionRenderDispatcher { public static final Int2ObjectMap renderers = new Int2ObjectOpenHashMap<>(); public static final Compartment> CONTRAPTION = new Compartment<>(); + private static final ResourceLocation ctxRoot = new ResourceLocation("create", "context/contraption"); + public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); + public static final WorldContext TILES = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)); protected static PlacementSimulationWorld renderWorld; public static void tick() { @@ -90,7 +98,7 @@ public class ContraptionRenderDispatcher { glActiveTexture(GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 if (Backend.canUseVBOs()) { - ContraptionProgram structureShader = ContraptionContext.INSTANCE.getProgram(AllProgramSpecs.STRUCTURE); + ContraptionProgram structureShader = STRUCTURE.getProgram(AllProgramSpecs.STRUCTURE); structureShader.bind(); structureShader.uploadViewProjection(viewProjection); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index 079ae0524..a05c3d5be 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -14,6 +14,7 @@ import org.lwjgl.opengl.GL11; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.IndexedModel; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; import com.jozufozu.flywheel.backend.light.GridAlignedBB; @@ -49,7 +50,11 @@ import net.minecraftforge.client.model.data.EmptyModelData; public class RenderedContraption { public static final VertexFormat FORMAT = VertexFormat.builder() - .addAttributes(ContraptionAttributes.class) + .addAttributes(CommonAttributes.VEC3, + CommonAttributes.NORMAL, + CommonAttributes.UV, + CommonAttributes.RGBA, + CommonAttributes.LIGHT) .build(); private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltAttributes.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltAttributes.java deleted file mode 100644 index 6a7b20814..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltAttributes.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.simibubi.create.content.contraptions.relays.belt; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; -import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; - -public enum BeltAttributes implements IVertexAttrib { - INSTANCE_ROTATION("aInstanceRot", CommonAttributes.QUATERNION), - SOURCE_TEX("aSourceTexture", CommonAttributes.UV), - SCROLL_TEX("aScrollTexture", CommonAttributes.VEC4), - SCROLL_MULT("aScrollMult", CommonAttributes.NORMALIZED_BYTE), - ; - - private final String name; - private final VertexAttribSpec spec; - - BeltAttributes(String name, VertexAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 1; - } - - @Override - public int getBufferIndex() { - return 1; - } -} diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapAttributes.java b/src/main/java/com/simibubi/create/content/logistics/block/FlapAttributes.java deleted file mode 100644 index ad6864629..000000000 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapAttributes.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.simibubi.create.content.logistics.block; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; -import com.jozufozu.flywheel.backend.gl.attrib.VertexAttribSpec; - -public enum FlapAttributes implements IVertexAttrib { - INSTANCE_POSITION("aInstancePos",CommonAttributes.VEC3), - LIGHT("aLight", CommonAttributes.LIGHT), - SEGMENT_OFFSET("aSegmentOffset", CommonAttributes.VEC3), - PIVOT("aPivot", CommonAttributes.VEC3), - HORIZONTAL_ANGLE("aHorizontalAngle", CommonAttributes.FLOAT), - INTENSITY("aIntensity", CommonAttributes.FLOAT), - FLAP_SCALE("aFlapScale", CommonAttributes.FLOAT), - FLAPNESS("aFlapness", CommonAttributes.FLOAT), - ; - - private final String name; - private final VertexAttribSpec spec; - - FlapAttributes(String name, VertexAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 1; - } - - @Override - public int getBufferIndex() { - return 1; - } -} diff --git a/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java b/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java index 70c2bf3e6..4fb31d1b8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllInstanceFormats.java @@ -1,39 +1,47 @@ package com.simibubi.create.foundation.render; -import com.jozufozu.flywheel.backend.core.materials.BasicAttributes; -import com.jozufozu.flywheel.backend.core.materials.OrientedAttributes; -import com.jozufozu.flywheel.backend.core.materials.TransformAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; +import com.jozufozu.flywheel.backend.gl.attrib.MatrixAttributes; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.simibubi.create.content.contraptions.base.KineticAttributes; -import com.simibubi.create.content.contraptions.base.RotatingAttributes; -import com.simibubi.create.content.contraptions.components.actors.ActorVertexAttributes; -import com.simibubi.create.content.contraptions.relays.belt.BeltAttributes; -import com.simibubi.create.content.logistics.block.FlapAttributes; public class AllInstanceFormats { - public static final VertexFormat MODEL = VertexFormat.builder() - .addAttributes(BasicAttributes.class) - .addAttributes(TransformAttributes.class) + public static final VertexFormat MODEL = litInstance() + .addAttributes(MatrixAttributes.MAT4, + MatrixAttributes.MAT3) .build(); - public static final VertexFormat ORIENTED = VertexFormat.builder() - .addAttributes(BasicAttributes.class) - .addAttributes(OrientedAttributes.class) + + public static final VertexFormat ORIENTED = litInstance() + .addAttributes(CommonAttributes.VEC3, CommonAttributes.VEC3, CommonAttributes.QUATERNION) .build(); - public static VertexFormat ROTATING = VertexFormat.builder() - .addAttributes(BasicAttributes.class) - .addAttributes(KineticAttributes.class) - .addAttributes(RotatingAttributes.class) + + public static VertexFormat ROTATING = kineticInstance() + .addAttributes(CommonAttributes.NORMAL) .build(); + + public static VertexFormat BELT = kineticInstance() + .addAttributes(CommonAttributes.QUATERNION, CommonAttributes.UV, CommonAttributes.VEC4, + CommonAttributes.NORMALIZED_BYTE) + .build(); + public static VertexFormat ACTOR = VertexFormat.builder() - .addAttributes(ActorVertexAttributes.class) - .build(); - public static VertexFormat BELT = VertexFormat.builder() - .addAttributes(BasicAttributes.class) - .addAttributes(KineticAttributes.class) - .addAttributes(BeltAttributes.class) + .addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.FLOAT, + CommonAttributes.NORMAL, CommonAttributes.QUATERNION, CommonAttributes.NORMAL, + CommonAttributes.FLOAT) .build(); + public static VertexFormat FLAP = VertexFormat.builder() - .addAttributes(FlapAttributes.class) + .addAttributes(CommonAttributes.VEC3, CommonAttributes.LIGHT, CommonAttributes.VEC3, CommonAttributes.VEC3, + CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT) .build(); + + private static VertexFormat.Builder litInstance() { + return VertexFormat.builder() + .addAttributes(CommonAttributes.LIGHT, CommonAttributes.RGBA); + } + + private static VertexFormat.Builder kineticInstance() { + return litInstance() + .addAttributes(CommonAttributes.VEC3, CommonAttributes.FLOAT, CommonAttributes.FLOAT); + } } diff --git a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java index 374bcb368..4a9d1a3da 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java @@ -2,9 +2,9 @@ package com.simibubi.create.foundation.render; import static com.jozufozu.flywheel.backend.Backend.register; -import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.core.materials.OrientedData; +import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; import com.simibubi.create.Create; @@ -20,7 +20,9 @@ public class AllMaterialSpecs { // noop, make sure the static field are loaded. } - public static final VertexFormat UNLIT_MODEL = VertexFormat.builder().addAttributes(ModelAttributes.class).build(); + public static final VertexFormat UNLIT_MODEL = VertexFormat.builder() + .addAttributes(CommonAttributes.VEC3, CommonAttributes.NORMAL, CommonAttributes.UV) + .build(); public static final MaterialSpec TRANSFORMED = register(new MaterialSpec<>(Locations.MODEL, AllProgramSpecs.MODEL, UNLIT_MODEL, AllInstanceFormats.MODEL, ModelData::new)); public static final MaterialSpec ORIENTED = register(new MaterialSpec<>(Locations.ORIENTED, AllProgramSpecs.ORIENTED, UNLIT_MODEL, AllInstanceFormats.ORIENTED, OrientedData::new)); diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index a4b8fbccb..bf67269e3 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -2,19 +2,9 @@ package com.simibubi.create.foundation.render; import static com.jozufozu.flywheel.backend.Backend.register; -import com.jozufozu.flywheel.backend.core.materials.BasicAttributes; -import com.jozufozu.flywheel.backend.core.materials.ModelAttributes; -import com.jozufozu.flywheel.backend.core.materials.OrientedAttributes; -import com.jozufozu.flywheel.backend.core.materials.TransformAttributes; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; import com.simibubi.create.Create; -import com.simibubi.create.content.contraptions.base.KineticAttributes; -import com.simibubi.create.content.contraptions.base.RotatingAttributes; -import com.simibubi.create.content.contraptions.components.actors.ActorVertexAttributes; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionAttributes; -import com.simibubi.create.content.contraptions.relays.belt.BeltAttributes; -import com.simibubi.create.content.logistics.block.FlapAttributes; import net.minecraft.util.ResourceLocation; @@ -24,66 +14,44 @@ public class AllProgramSpecs { } public static final ProgramSpec CHROMATIC = register(builder("chromatic") - .addAttributes(ModelAttributes.class) - .addAttributes(BasicAttributes.class) - .addAttributes(TransformAttributes.class) .setVert(Locations.EFFECT_VERT) .setFrag(Locations.EFFECT_FRAG) - .createProgramSpec()); + .build()); public static final ProgramSpec MODEL = register(builder("model") - .addAttributes(ModelAttributes.class) - .addAttributes(BasicAttributes.class) - .addAttributes(TransformAttributes.class) .setVert(Locations.MODEL_VERT) .setFrag(Locations.BLOCK) - .createProgramSpec()); + .build()); public static final ProgramSpec ORIENTED = register(builder("oriented") - .addAttributes(ModelAttributes.class) - .addAttributes(BasicAttributes.class) - .addAttributes(OrientedAttributes.class) .setVert(Locations.ORIENTED) .setFrag(Locations.BLOCK) - .createProgramSpec()); + .build()); public static final ProgramSpec ROTATING = register(builder("rotating") - .addAttributes(ModelAttributes.class) - .addAttributes(BasicAttributes.class) - .addAttributes(KineticAttributes.class) - .addAttributes(RotatingAttributes.class) .setVert(Locations.ROTATING) .setFrag(Locations.BLOCK) - .createProgramSpec()); + .build()); public static final ProgramSpec BELT = register(builder("belt") - .addAttributes(ModelAttributes.class) - .addAttributes(BasicAttributes.class) - .addAttributes(KineticAttributes.class) - .addAttributes(BeltAttributes.class) .setVert(Locations.BELT) .setFrag(Locations.BLOCK) - .createProgramSpec()); + .build()); public static final ProgramSpec FLAPS = register(builder("flap") - .addAttributes(ModelAttributes.class) - .addAttributes(FlapAttributes.class) .setVert(Locations.FLAP) .setFrag(Locations.BLOCK) - .createProgramSpec()); + .build()); public static final ProgramSpec STRUCTURE = register(builder("contraption_structure") - .addAttributes(ContraptionAttributes.class) .setVert(Locations.CONTRAPTION_STRUCTURE) .setFrag(Locations.BLOCK) .setDefines(ShaderConstants.define("CONTRAPTION")) - .createProgramSpec()); + .build()); public static final ProgramSpec ACTOR = register(builder("contraption_actor") - .addAttributes(ModelAttributes.class) - .addAttributes(ActorVertexAttributes.class) .setVert(Locations.CONTRAPTION_ACTOR) .setFrag(Locations.BLOCK) .setDefines(ShaderConstants.define("CONTRAPTION")) - .createProgramSpec()); + .build()); public static ProgramSpec.Builder builder(String name) { return ProgramSpec.builder(new ResourceLocation(Create.ID, name)); diff --git a/src/main/java/com/simibubi/create/foundation/render/CreateFlywheelHandler.java b/src/main/java/com/simibubi/create/foundation/render/CreateFlywheelHandler.java index 7f3d4a05f..7dc49abdf 100644 --- a/src/main/java/com/simibubi/create/foundation/render/CreateFlywheelHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/CreateFlywheelHandler.java @@ -1,14 +1,14 @@ package com.simibubi.create.foundation.render; import com.jozufozu.flywheel.backend.Backend; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.render.effects.EffectsContext; public class CreateFlywheelHandler { public static void init() { - Backend.register(ContraptionContext.INSTANCE); + Backend.register(ContraptionRenderDispatcher.TILES); + Backend.register(ContraptionRenderDispatcher.STRUCTURE); Backend.register(EffectsContext.INSTANCE); Backend.listeners.renderLayerListener(ContraptionRenderDispatcher::renderLayer); Backend.listeners.renderLayerListener(FluidRenderer::renderLayer); diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java index 00f47c505..f02261b66 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java @@ -2,8 +2,8 @@ package com.simibubi.create.foundation.render.effects; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.gl.shader.SingleProgram; +import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import com.simibubi.create.foundation.render.AllProgramSpecs; import net.minecraft.util.ResourceLocation; @@ -12,20 +12,14 @@ public class EffectsContext extends ShaderContext { public static final EffectsContext INSTANCE = new EffectsContext(); - private final SingleProgram.SpecLoader loader; - public EffectsContext() { - super(new ResourceLocation("create", "effects")); - loader = new SingleProgram.SpecLoader<>(SphereFilterProgram::new); + super(new ResourceLocation("create", "effects"), new SingleProgram.SpecLoader<>(SphereFilterProgram::new)); } @Override public void load(ShaderLoader loader) { + transformer = new ShaderTransformer() + .pushStage(loader::processIncludes); loadProgramFromSpec(loader, AllProgramSpecs.CHROMATIC); } - - @Override - public ShaderSpecLoader getLoader() { - return loader; - } } diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/ScreenQuadAttributes.java b/src/main/java/com/simibubi/create/foundation/render/effects/ScreenQuadAttributes.java deleted file mode 100644 index 0c7833527..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/effects/ScreenQuadAttributes.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.simibubi.create.foundation.render.effects; - -import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; -import com.jozufozu.flywheel.backend.gl.attrib.IAttribSpec; -import com.jozufozu.flywheel.backend.gl.attrib.IVertexAttrib; - -public enum ScreenQuadAttributes implements IVertexAttrib { - INSTANCE_POS("aVertex", CommonAttributes.VEC4), - ; - - private final String name; - private final IAttribSpec spec; - - ScreenQuadAttributes(String name, IAttribSpec spec) { - this.name = name; - this.spec = spec; - } - - @Override - public String attribName() { - return name; - } - - @Override - public IAttribSpec attribSpec() { - return spec; - } - - @Override - public int getDivisor() { - return 0; - } - - @Override - public int getBufferIndex() { - return 0; - } -} diff --git a/src/main/resources/assets/create/flywheel/shaders/belt.vert b/src/main/resources/assets/create/flywheel/shaders/belt.vert index 052520d2d..5d94c0f35 100644 --- a/src/main/resources/assets/create/flywheel/shaders/belt.vert +++ b/src/main/resources/assets/create/flywheel/shaders/belt.vert @@ -1,4 +1,3 @@ -#version 110 #define PI 3.1415926538 #flwbuiltins @@ -6,55 +5,45 @@ #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/diffuse.glsl"> -attribute vec3 aPos; -attribute vec3 aNormal; -attribute vec2 aTexCoords; +#[InstanceData] +struct Belt { + vec2 light; + vec4 color; + vec3 pos; + float speed; + float offset; + vec4 rotation; + vec2 sourceTexture; + vec4 scrollTexture; + float scrollMult; +}; -attribute vec2 aLight; -attribute vec4 aColor; -attribute vec3 aInstancePos; -attribute float aSpeed; -attribute float aOffset; -attribute vec4 aInstanceRot; -attribute vec2 aSourceTexture; -attribute vec4 aScrollTexture; -attribute float aScrollMult; +#flwinclude <"create:data/modelvertex.glsl"> +#flwinclude <"create:data/blockfragment.glsl"> -varying vec2 TexCoords; -varying vec4 Color; -varying float Diffuse; -varying vec2 Light; - -void main() { - vec3 rotated = rotateVertexByQuat(aPos - .5, aInstanceRot) + aInstancePos + .5; +BlockFrag FLWMain(Vertex v, Belt instance) { + vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5; vec4 worldPos = vec4(rotated, 1.); - vec3 norm = rotateVertexByQuat(aNormal, aInstanceRot); + vec3 norm = rotateVertexByQuat(v.normal, instance.rotation); FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); - float scrollSize = aScrollTexture.w - aScrollTexture.y; - float scroll = fract(aSpeed * uTime / (31.5 * 16.) + aOffset) * scrollSize * aScrollMult; + float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y; + float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult; - Diffuse = diffuse(norm); - TexCoords = aTexCoords - aSourceTexture + aScrollTexture.xy + vec2(0, scroll); - Light = aLight; + BlockFrag b; + b.diffuse = diffuse(norm); + b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll); + b.light = instance.light; - #ifdef CONTRAPTION - if (uDebug == 2) { - Color = vec4(norm, 1.); - } else { - Color = vec4(1.); - } + #if defined(RAINBOW_DEBUG) + b.color = instance.color; #else - if (uDebug == 1) { - Color = aColor; - } else if (uDebug == 2) { - Color = vec4(norm, 1.); - } else { - Color = vec4(1.); - } + b.color = vec4(1.); #endif + + return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/block.frag b/src/main/resources/assets/create/flywheel/shaders/block.frag index 2f26044ac..e24666099 100644 --- a/src/main/resources/assets/create/flywheel/shaders/block.frag +++ b/src/main/resources/assets/create/flywheel/shaders/block.frag @@ -1,16 +1,11 @@ -#version 110 - #flwbuiltins -varying vec2 TexCoords; -varying vec2 Light; -varying float Diffuse; -varying vec4 Color; +#flwinclude <"create:data/blockfragment.glsl"> -void main() { - vec4 tex = FLWBlockTexture(TexCoords); +void FLWMain(BlockFrag r) { + vec4 tex = FLWBlockTexture(r.texCoords); - vec4 color = vec4(tex.rgb * FLWLight(Light).rgb * Diffuse, tex.a) * Color; + vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color; FLWFinalizeColor(color); } diff --git a/src/main/resources/assets/create/flywheel/shaders/block_new.frag b/src/main/resources/assets/create/flywheel/shaders/block_new.frag deleted file mode 100644 index fe96f0c84..000000000 --- a/src/main/resources/assets/create/flywheel/shaders/block_new.frag +++ /dev/null @@ -1,17 +0,0 @@ -#flwbuiltins - -#[Fragment] -struct Raster { - vec2 texCoords; - vec4 color; - float diffuse; - vec2 light; -}; - -void FLWMain(Raster r) { - vec4 tex = FLWBlockTexture(r.texCoords); - - vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color; - - FLWFinalizeColor(color); -} diff --git a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag index 054697141..6a211bc46 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag @@ -1,4 +1,4 @@ -#flwinclude <"create:context/std/fog.glsl"> +#flwinclude <"create:context/world/fog.glsl"> #flwinclude <"create:core/lightutil.glsl"> varying vec3 BoxCoord; diff --git a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.vert index 2b044c280..3d82348ea 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.vert +++ b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.vert @@ -10,7 +10,6 @@ uniform mat4 uModel; uniform float uTime; uniform mat4 uViewProjection; -uniform int uDebug; uniform vec3 uCameraPos; void FLWFinalizeWorldPos(inout vec4 worldPos) { diff --git a/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag index 40bcfbdc4..5bee49af8 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag @@ -1,4 +1,4 @@ -#flwinclude <"create:context/std/fog.glsl"> +#flwinclude <"create:context/world/fog.glsl"> uniform vec2 uTextureScale; uniform sampler2D uBlockAtlas; diff --git a/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert index 3ca685f97..8b61a3168 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert +++ b/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert @@ -1 +1 @@ -#flwinclude <"create:context/std/builtin.vert"> +#flwinclude <"create:context/world/builtin.vert"> diff --git a/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/world/builtin.frag similarity index 91% rename from src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag rename to src/main/resources/assets/create/flywheel/shaders/context/world/builtin.frag index 8a30001a6..81e9a2be9 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/world/builtin.frag @@ -1,4 +1,4 @@ -#flwinclude <"create:context/std/fog.glsl"> +#flwinclude <"create:context/world/fog.glsl"> #flwinclude <"create:core/lightutil.glsl"> uniform sampler2D uBlockAtlas; diff --git a/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/context/world/builtin.vert similarity index 95% rename from src/main/resources/assets/create/flywheel/shaders/context/std/builtin.vert rename to src/main/resources/assets/create/flywheel/shaders/context/world/builtin.vert index bcf38154a..251267397 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.vert +++ b/src/main/resources/assets/create/flywheel/shaders/context/world/builtin.vert @@ -1,6 +1,5 @@ uniform float uTime; uniform mat4 uViewProjection; -uniform int uDebug; uniform vec3 uCameraPos; #if defined(USE_FOG) diff --git a/src/main/resources/assets/create/flywheel/shaders/context/std/fog.glsl b/src/main/resources/assets/create/flywheel/shaders/context/world/fog.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/context/std/fog.glsl rename to src/main/resources/assets/create/flywheel/shaders/context/world/fog.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert index 96d516359..6fe9b3ac4 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert @@ -1,4 +1,3 @@ -#version 110 #define PI 3.1415926538 #flwbuiltins @@ -6,45 +5,38 @@ #flwinclude <"create:core/quaternion.glsl"> #flwinclude <"create:core/diffuse.glsl"> -// model data -attribute vec3 aPos; -attribute vec3 aNormal; -attribute vec2 aTexCoords; +#[InstanceData] +struct Actor { + vec3 pos; + vec2 light; + float offset; + vec3 axis; + vec4 rotation; + vec3 rotationCenter; + float speed; +}; -// instance data -attribute vec3 aInstancePos; -attribute vec2 aModelLight; -attribute float aOffset; -attribute vec3 aAxis; -attribute vec4 aInstanceRot; -attribute vec3 aRotationCenter; -attribute float aSpeed; +#flwinclude <"create:data/modelvertex.glsl"> +#flwinclude <"create:data/blockfragment.glsl"> -varying float Diffuse; -varying vec2 TexCoords; -varying vec4 Color; -varying vec2 Light; - -void main() { - float degrees = aOffset + uTime * aSpeed / 20.; +BlockFrag FLWMain(Vertex v, Actor instance) { + float degrees = instance.offset + uTime * instance.speed / 20.; //float angle = fract(degrees / 360.) * PI * 2.; - vec4 kineticRot = quat(aAxis, degrees); - vec3 rotated = rotateVertexByQuat(aPos - aRotationCenter, kineticRot) + aRotationCenter; + vec4 kineticRot = quat(instance.axis, degrees); + vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter; - vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, aInstanceRot) + aInstancePos + .5, 1.); - vec3 norm = rotateVertexByQuat(rotateVertexByQuat(aNormal, kineticRot), aInstanceRot); + vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.); + vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation); FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); - Diffuse = diffuse(norm); - TexCoords = aTexCoords; - Light = aModelLight; + BlockFrag b; + b.diffuse = diffuse(norm); + b.texCoords = v.texCoords; + b.light = instance.light; + b.color = vec4(1.); - if (uDebug == 2) { - Color = vec4(norm, 1.); - } else { - Color = vec4(1.); - } + return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert index e3bc37b5a..cac2956a0 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert @@ -1,34 +1,32 @@ -#version 110 #define PI 3.1415926538 #flwbuiltins #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/diffuse.glsl"> -attribute vec3 aPos; -attribute vec3 aNormal; -attribute vec2 aTexCoords; -attribute vec4 aColor; -attribute vec2 aModelLight; +#[VertexData] +struct Vertex { + vec3 pos; + vec3 normal; + vec2 texCoords; + vec4 color; + vec2 modelLight; +}; -varying float Diffuse; -varying vec2 TexCoords; -varying vec4 Color; -varying vec2 Light; +#flwinclude <"create:data/blockfragment.glsl"> -void main() { - vec4 worldPos = vec4(aPos, 1.); - vec3 norm = aNormal; +BlockFrag FLWMain(Vertex v) { + vec4 worldPos = vec4(v.pos, 1.); + vec3 norm = v.normal; FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); - Diffuse = diffuse(norm); - if (uDebug == 2) { - Color = vec4(norm, 1.); - } else { - Color = aColor / diffuse(aNormal); - } - TexCoords = aTexCoords; - Light = aModelLight; + BlockFrag b; + b.diffuse = diffuse(norm); + b.color = v.color / diffuse(v.normal); + b.texCoords = v.texCoords; + b.light = v.modelLight; + + return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/data/blockfragment.glsl b/src/main/resources/assets/create/flywheel/shaders/data/blockfragment.glsl new file mode 100644 index 000000000..e5d09eb16 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/data/blockfragment.glsl @@ -0,0 +1,7 @@ +#[Fragment] +struct BlockFrag { + vec2 texCoords; + vec4 color; + float diffuse; + vec2 light; +}; diff --git a/src/main/resources/assets/create/flywheel/shaders/data/modelvertex.glsl b/src/main/resources/assets/create/flywheel/shaders/data/modelvertex.glsl new file mode 100644 index 000000000..5e34d2883 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/data/modelvertex.glsl @@ -0,0 +1,6 @@ +#[VertexData] +struct Vertex { + vec3 pos; + vec3 normal; + vec2 texCoords; +}; diff --git a/src/main/resources/assets/create/flywheel/shaders/flap.vert b/src/main/resources/assets/create/flywheel/shaders/flap.vert index cb4eba652..1f5c973ad 100644 --- a/src/main/resources/assets/create/flywheel/shaders/flap.vert +++ b/src/main/resources/assets/create/flywheel/shaders/flap.vert @@ -1,4 +1,3 @@ -#version 110 #define PI 3.1415926538 #flwbuiltins @@ -6,62 +5,58 @@ #flwinclude <"create:core/quaternion.glsl"> #flwinclude <"create:core/diffuse.glsl"> -attribute vec3 aPos; -attribute vec3 aNormal; -attribute vec2 aTexCoords; +#[InstanceData] +struct Flap { + vec3 instancePos; + vec2 light; + vec3 segmentOffset; + vec3 pivot; + float horizontalAngle; + float intensity; + float flapScale; + float flapness; +}; -attribute vec3 aInstancePos; -attribute vec2 aLight; +#flwinclude <"create:data/modelvertex.glsl"> +#flwinclude <"create:data/blockfragment.glsl"> -attribute vec3 aSegmentOffset; -attribute vec3 aPivot; -attribute float aHorizontalAngle; -attribute float aIntensity; -attribute float aFlapScale; - -attribute float aFlapness; - -// outputs -varying vec2 TexCoords; -varying vec4 Color; -varying float Diffuse; -varying vec2 Light; float toRad(float degrees) { return fract(degrees / 360.) * PI * 2.; } -float getFlapAngle() { - float absFlap = abs(aFlapness); +float getFlapAngle(float flapness, float intensity, float scale) { + float absFlap = abs(flapness); - float angle = sin((1. - absFlap) * PI * aIntensity) * 30. * aFlapness * aFlapScale; + float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale; float halfAngle = angle * 0.5; - float which = step(0., aFlapness); - float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply + float which = step(0., flapness);// 0 if negative, 1 if positive + float degrees = which * halfAngle + (1. - which) * angle;// branchless conditional multiply return degrees; } -void main() { - float flapAngle = getFlapAngle(); +BlockFrag FLWMain(Vertex v, Flap flap) { + float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale); - vec4 orientation = quat(vec3(0., 1., 0.), -aHorizontalAngle); + vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle); vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle); - vec3 rotated = rotateVertexByQuat(aPos - aPivot, flapRotation) + aPivot + aSegmentOffset; - rotated = rotateVertexByQuat(rotated - .5, orientation) + aInstancePos + .5; + vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset; + rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5; vec4 worldPos = vec4(rotated, 1.); - vec3 norm = rotateVertexByQuat(rotateVertexByQuat(aNormal, flapRotation), orientation); + vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation); FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); - Diffuse = diffuse(norm); - TexCoords = aTexCoords; - Light = aLight; - - Color = vec4(1.); + BlockFrag b; + b.diffuse = diffuse(norm); + b.texCoords = v.texCoords; + b.light = flap.light; + b.color = vec4(1.); + return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/model.vert b/src/main/resources/assets/create/flywheel/shaders/model.vert index 4e0c76ec5..c9ca3fcea 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model.vert +++ b/src/main/resources/assets/create/flywheel/shaders/model.vert @@ -1,35 +1,31 @@ -#version 110 - #flwbuiltins #flwinclude <"create:core/diffuse.glsl"> -attribute vec3 aPos; -attribute vec3 aNormal; -attribute vec2 aTexCoords; +#[InstanceData] +struct Instance { + vec2 light; + vec4 color; + mat4 transform; + mat3 normalMat; +}; -attribute vec2 aLight; -attribute vec4 aColor; -attribute mat4 aTransform; -attribute mat3 aNormalMat; +#flwinclude <"create:data/modelvertex.glsl"> +#flwinclude <"create:data/blockfragment.glsl"> -varying vec2 TexCoords; -varying vec4 Color; -varying float Diffuse; -varying vec2 Light; +BlockFrag FLWMain(Vertex v, Instance i) { + vec4 worldPos = i.transform * vec4(v.pos, 1.); -void main() { - vec4 worldPos = aTransform * vec4(aPos, 1.); - - vec3 norm = aNormalMat * aNormal; + vec3 norm = i.normalMat * v.normal; FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); norm = normalize(norm); - Diffuse = diffuse(norm); - TexCoords = aTexCoords; - Light = aLight; - - Color = aColor; + BlockFrag b; + b.diffuse = diffuse(norm); + b.texCoords = v.texCoords; + b.light = i.light; + b.color = i.color; + return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/model_new.vert b/src/main/resources/assets/create/flywheel/shaders/model_new.vert deleted file mode 100644 index 755d09361..000000000 --- a/src/main/resources/assets/create/flywheel/shaders/model_new.vert +++ /dev/null @@ -1,46 +0,0 @@ -#flwbuiltins -#flwinclude <"create:core/diffuse.glsl"> - -#[VertexData] -struct Vertex { -#[Layout(float)] - vec3 pos; - vec3 normal; - vec2 texCoords; -}; - -#[InstanceData] -struct Instance { -#[Normalized(ushort)] - vec2 light; - #[Normalized(ubyte)] - vec4 color; - mat4 transform; - mat3 normalMat; -}; - -#[Fragment] -struct Raster { - vec2 texCoords; - vec4 color; - float diffuse; - vec2 light; -}; - -Raster FLWMain(Vertex v, Instance i) { - vec4 worldPos = i.transform * vec4(v.pos, 1.); - - vec3 norm = i.normalMat * v.normal; - norm = normalize(norm); - - FLWFinalizeWorldPos(worldPos); - FLWFinalizeNormal(norm); - - Raster r; - r.diffuse = diffuse(norm); - r.texCoords = v.texCoords; - r.light = i.light; - r.color = i.color; - - return r; -} diff --git a/src/main/resources/assets/create/flywheel/shaders/oriented.vert b/src/main/resources/assets/create/flywheel/shaders/oriented.vert index d9f6f5cc5..6b978c08d 100644 --- a/src/main/resources/assets/create/flywheel/shaders/oriented.vert +++ b/src/main/resources/assets/create/flywheel/shaders/oriented.vert @@ -1,36 +1,32 @@ -#version 110 - #flwbuiltins #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/quaternion.glsl"> #flwinclude <"create:core/diffuse.glsl"> -attribute vec3 aPos; -attribute vec3 aNormal; -attribute vec2 aTexCoords; +#[InstanceData] +struct Oriented { + vec2 light; + vec4 color; + vec3 pos; + vec3 pivot; + vec4 rotation; +}; -attribute vec2 aLight; -attribute vec4 aColor; -attribute vec3 aInstancePos; -attribute vec3 aPivot; -attribute vec4 aRotation; +#flwinclude <"create:data/modelvertex.glsl"> +#flwinclude <"create:data/blockfragment.glsl"> -varying vec2 TexCoords; -varying vec4 Color; -varying float Diffuse; -varying vec2 Light; +BlockFrag FLWMain(Vertex v, Oriented o) { + vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.); -void main() { - vec4 worldPos = vec4(rotateVertexByQuat(aPos - aPivot, aRotation) + aPivot + aInstancePos, 1.); - - vec3 norm = rotateVertexByQuat(aNormal, aRotation); + vec3 norm = rotateVertexByQuat(v.normal, o.rotation); FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); - Diffuse = diffuse(norm); - TexCoords = aTexCoords; - Light = aLight; - - Color = aColor; + BlockFrag b; + b.diffuse = diffuse(norm); + b.texCoords = v.texCoords; + b.light = o.light; + b.color = o.color; + return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/shaders/rotating.vert index 9d20b6480..2f12cea87 100644 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ b/src/main/resources/assets/create/flywheel/shaders/rotating.vert @@ -1,60 +1,51 @@ -#version 110 #define PI 3.1415926538 #flwbuiltins -#flwinclude <"create:core/quaternion.glsl"> #flwinclude <"create:core/matutils.glsl"> #flwinclude <"create:core/diffuse.glsl"> -attribute vec3 aPos; -attribute vec3 aNormal; -attribute vec2 aTexCoords; +#[InstanceData] +struct Rotating { + vec2 light; + vec4 color; + vec3 pos; + float speed; + float offset; + vec3 axis; +}; -attribute vec2 aLight; -attribute vec4 aColor; -attribute vec3 aInstancePos; -attribute float aSpeed; -attribute float aOffset; -attribute vec3 aAxis; +#flwinclude <"create:data/modelvertex.glsl"> +#flwinclude <"create:data/blockfragment.glsl"> -varying vec2 TexCoords; -varying vec4 Color; -varying float Diffuse; -varying vec2 Light; - -mat4 kineticRotation() { - float degrees = aOffset + uTime * aSpeed * 3./10.; +mat4 kineticRotation(float offset, float speed, vec3 axis) { + float degrees = offset + uTime * speed * 3./10.; float angle = fract(degrees / 360.) * PI * 2.; - return rotate(aAxis, angle); + return rotate(axis, angle); } -void main() { - mat4 kineticRotation = kineticRotation(); - vec4 worldPos = kineticRotation * vec4(aPos - .5, 1.) + vec4(aInstancePos + .5, 0.); +BlockFrag FLWMain(Vertex v, Rotating instance) { + mat4 kineticRotation = kineticRotation(instance.offset, instance.speed, instance.axis); - vec3 norm = modelToNormal(kineticRotation) * aNormal; + vec4 worldPos = vec4(v.pos - .5, 1.); + worldPos *= kineticRotation; + worldPos += vec4(instance.pos + .5, 0.); + + vec3 norm = modelToNormal(kineticRotation) * v.normal; FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); - Diffuse = diffuse(norm); - TexCoords = aTexCoords; - Light = aLight; + BlockFrag b; + b.diffuse = diffuse(norm); + b.texCoords = v.texCoords; + b.light = instance.light; - #ifdef CONTRAPTION - if (uDebug == 2) { - Color = vec4(norm, 1.); - } else { - Color = vec4(1.); - } + #if defined(RAINBOW_DEBUG) + b.color = instance.color; #else - if (uDebug == 1) { - Color = aColor; - } else if (uDebug == 2) { - Color = vec4(norm, 1.); - } else { - Color = vec4(1.); - } + b.color = vec4(1.); #endif + + return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/template/model/model.frag b/src/main/resources/assets/create/flywheel/shaders/template/model/model.frag new file mode 100644 index 000000000..fb9620d7d --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/template/model/model.frag @@ -0,0 +1,12 @@ +#version 110 + +#flwbeginbody + +#FLWPrefixFields(Fragment, varying, v2f_) + +void main() { + Fragment f; + #FLWAssignFields(Fragment, f., v2f_) + + FLWMain(f); +} diff --git a/src/main/resources/assets/create/flywheel/shaders/template/model/model.vert b/src/main/resources/assets/create/flywheel/shaders/template/model/model.vert new file mode 100644 index 000000000..1a235e153 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/template/model/model.vert @@ -0,0 +1,15 @@ +#version 110 + +#flwbeginbody +#FLWPrefixFields(VertexData, attribute, a_v_) + +#FLWPrefixFields(Fragment, varying, v2f_) + +void main() { + VertexData v; + #FLWAssignFields(VertexData, v., a_v_) + + Fragment o = FLWMain(v); + + #FLWAssignFields(Fragment, v2f_, o.) +} From c299e84512548ab087c32a1cdb31d750cd6e1126 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 18 May 2021 14:41:16 -0700 Subject: [PATCH 065/198] Be lazy grabbing instance fields statically --- .../render/ContraptionRenderDispatcher.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 7f0e689ee..f8a2e942e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -59,15 +59,17 @@ import net.minecraft.world.World; import net.minecraft.world.gen.feature.template.Template; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.common.util.Lazy; public class ContraptionRenderDispatcher { - private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); - private static final BlockModelShapes BLOCK_MODELS = Minecraft.getInstance().getModelManager().getBlockModelShapes(); + private static final Lazy MODEL_RENDERER = Lazy.of(() -> new BlockModelRenderer(Minecraft.getInstance().getBlockColors())); + private static final Lazy BLOCK_MODELS = Lazy.of(() -> Minecraft.getInstance().getModelManager().getBlockModelShapes()); private static int worldHolderRefreshCounter; public static final Int2ObjectMap RENDERERS = new Int2ObjectOpenHashMap<>(); public static final Int2ObjectMap WORLD_HOLDERS = new Int2ObjectOpenHashMap<>(); public static final Compartment> CONTRAPTION = new Compartment<>(); + private static final ResourceLocation ctxRoot = new ResourceLocation("create", "context/contraption"); public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); public static final WorldContext TILES = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)); @@ -272,8 +274,8 @@ public class ContraptionRenderDispatcher { ms.push(); ms.translate(pos.getX(), pos.getY(), pos.getZ()); - MODEL_RENDERER.renderModel(renderWorld, BLOCK_MODELS.getModel(state), state, pos, ms, builder, true, - random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); + MODEL_RENDERER.get().renderModel(renderWorld, BLOCK_MODELS.get().getModel(state), state, pos, ms, builder, true, + random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE); ms.pop(); } BlockModelRenderer.disableCache(); From fd6e06b4875e35a9d9919607696e5c40d5b44f32 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 18 May 2021 14:46:45 -0700 Subject: [PATCH 066/198] whoops everything was spinning backwards --- src/main/resources/assets/create/flywheel/shaders/rotating.vert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/shaders/rotating.vert index 2f12cea87..5957c2752 100644 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ b/src/main/resources/assets/create/flywheel/shaders/rotating.vert @@ -18,7 +18,7 @@ struct Rotating { #flwinclude <"create:data/blockfragment.glsl"> mat4 kineticRotation(float offset, float speed, vec3 axis) { - float degrees = offset + uTime * speed * 3./10.; + float degrees = offset + uTime * speed * -3./10.; float angle = fract(degrees / 360.) * PI * 2.; return rotate(axis, angle); From 480d86c5add2feeeed15f9f47bd9cc3a0b882633 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Tue, 18 May 2021 18:50:54 -0700 Subject: [PATCH 067/198] Fix beds on contraptions - Add beds tag to brittle tag - Let contraptions know bed halves are attached to each other --- src/main/java/com/simibubi/create/AllTags.java | 1 + .../structureMovement/BlockMovementTraits.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index b42cdf120..231973559 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -209,6 +209,7 @@ public class AllTags { AllBlockTags.WINDMILL_SAILS.includeAll(BlockTags.WOOL); AllBlockTags.BRITTLE.includeAll(BlockTags.DOORS); + AllBlockTags.BRITTLE.includeAll(BlockTags.BEDS); AllBlockTags.BRITTLE.add(Blocks.FLOWER_POT, Blocks.BELL, Blocks.COCOA); AllBlockTags.FAN_TRANSPARENT.includeAll(BlockTags.FENCES); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java index 5a47573fe..a7bfd1806 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java @@ -29,6 +29,7 @@ import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkBlock; import net.minecraft.block.AbstractPressurePlateBlock; import net.minecraft.block.AbstractRailBlock; import net.minecraft.block.AbstractSignBlock; +import net.minecraft.block.BedBlock; import net.minecraft.block.BellBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -49,6 +50,7 @@ import net.minecraft.block.WallSignBlock; import net.minecraft.block.WallTorchBlock; import net.minecraft.block.material.PushReaction; import net.minecraft.state.properties.AttachFace; +import net.minecraft.state.properties.BedPart; import net.minecraft.state.properties.BellAttachment; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; @@ -163,6 +165,13 @@ public class BlockMovementTraits { return direction == Direction.DOWN; if (block instanceof DoorBlock) return direction == Direction.DOWN; + if (block instanceof BedBlock) { + Direction facing = state.get(BedBlock.HORIZONTAL_FACING); + if (state.get(BedBlock.PART) == BedPart.HEAD) { + facing = facing.getOpposite(); + } + return direction == facing; + } if (block instanceof RedstoneLinkBlock) return direction.getOpposite() == state.get(RedstoneLinkBlock.FACING); if (block instanceof FlowerPotBlock) From e916b06862e8e0df1ad1b28da91feb034f1e7843 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Tue, 18 May 2021 21:52:35 -0400 Subject: [PATCH 068/198] Added model data refresh mixin --- .../mixin/ModelDataRefreshMixin.java | 37 +++++++++++++++++++ src/main/resources/create.mixins.json | 3 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java diff --git a/src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java new file mode 100644 index 000000000..151a0a7c6 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/mixin/ModelDataRefreshMixin.java @@ -0,0 +1,37 @@ +package com.simibubi.create.foundation.mixin; + +import com.simibubi.create.content.schematics.SchematicWorld; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.client.model.ModelDataManager; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.client.Minecraft; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +@Mixin(ModelDataManager.class) +public class ModelDataRefreshMixin { + + /** + * Normally ModelDataManager will throw an exception if a tile entity tries + * to refresh its model data from a world the client isn't currently in, + * but we need that to not happen for tile entities in fake schematic + * worlds, so in those cases just do nothing instead. + */ + @Inject(at = @At("HEAD"), method = "requestModelDataRefresh", cancellable = true, remap = false) + private static void requestModelDataRefresh(TileEntity te, CallbackInfo ci) { + if (te != null) { + World world = te.getWorld(); + if (world != Minecraft.getInstance().world && world instanceof SchematicWorld) + ci.cancel(); + } + } + +} diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index 0938f8534..fbd4a5c91 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -18,7 +18,8 @@ "StoreProjectionMatrixMixin", "TileRemoveMixin", "TileWorldHookMixin", - "WindowResizeMixin" + "WindowResizeMixin", + "ModelDataRefreshMixin" ], "injectors": { "defaultRequire": 1 From a2903182b03fa9f69c8276c43c06be76750b9d80 Mon Sep 17 00:00:00 2001 From: Eivind Date: Wed, 19 May 2021 12:20:53 +0200 Subject: [PATCH 069/198] Bumping registrate version to fix incompatibility with mojmap mods --- build.gradle | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index c1cdabd3f..c1c180826 100644 --- a/build.gradle +++ b/build.gradle @@ -116,7 +116,7 @@ configurations { dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - def registrate = "com.tterrag.registrate:Registrate:MC1.16.2-${registrate_version}" + def registrate = "com.tterrag.registrate:Registrate:MC1.16.5-${registrate_version}" implementation fg.deobf(registrate) shade registrate diff --git a/gradle.properties b/gradle.properties index 6f4a1d878..b50c41fc3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ minecraft_version=1.16.5 forge_version=36.0.42 # dependency versions -registrate_version=1.0.0-beta.33 +registrate_version=1.0.4 jei_version=7.6.1.71 # curseforge information From 4d755dc506cf38b4d28faf4e32b18c0cfac27475 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Wed, 19 May 2021 16:35:37 -0700 Subject: [PATCH 070/198] More simplification - Move more stuff to the flywheel namespace - Give up on ShaderConstants, there's a better way to do it - A semblance of better crash reports --- .../java/com/jozufozu/flywheel/Flywheel.java | 6 ++ .../flywheel/backend/ShaderContext.java | 33 +++++----- .../flywheel/backend/ShaderLoader.java | 37 +++++++++-- .../flywheel/backend/core/BasicProgram.java | 9 +-- .../backend/core/CrumblingProgram.java | 7 +- .../flywheel/backend/core/WorldContext.java | 32 ++++++--- .../gl/shader/FogSensitiveProgram.java | 31 +++++---- .../flywheel/backend/gl/shader/GlProgram.java | 7 +- .../backend/gl/shader/ProgramSpec.java | 43 ++---------- .../backend/gl/shader/ShaderConstants.java | 61 ----------------- .../backend/gl/shader/SingleProgram.java | 8 +-- .../loading/InstancedArraysTemplate.java | 5 +- .../backend/loading/ModelTemplate.java | 5 +- .../flywheel/backend/loading/Shader.java | 18 +++++ .../loading/ShaderLoadingException.java | 22 +++++++ .../render/ContraptionProgram.java | 32 ++++----- .../foundation/render/AllProgramSpecs.java | 65 +++++-------------- .../render/effects/EffectsContext.java | 4 +- .../render/effects/SphereFilterProgram.java | 10 +-- .../create/flywheel/shaders/area_effect.frag | 2 +- .../assets/create/flywheel/shaders/belt.vert | 12 ++-- .../shaders/context/contraption/builtin.frag | 4 +- .../shaders/context/crumbling/builtin.vert | 1 - .../flywheel/shaders/contraption_actor.vert | 15 +++-- .../shaders/contraption_structure.vert | 13 ++-- .../assets/create/flywheel/shaders/flap.vert | 14 ++-- .../create/flywheel/shaders/rotating.vert | 19 +++--- .../flywheel/shaders/block.frag | 2 +- .../shaders/context/crumbling/builtin.frag | 2 +- .../shaders/context/crumbling/builtin.vert | 1 + .../shaders/context/world/builtin.frag | 4 +- .../shaders/context/world/builtin.vert | 0 .../flywheel/shaders/context/world/fog.glsl | 0 .../flywheel/shaders/core/color.glsl | 0 .../flywheel/shaders/core/diffuse.glsl | 0 .../flywheel/shaders/core/lightutil.glsl | 0 .../flywheel/shaders/core/matutils.glsl | 0 .../flywheel/shaders/core/quaternion.glsl | 31 +-------- .../flywheel/shaders/data/blockfragment.glsl | 0 .../flywheel/shaders/data/modelvertex.glsl | 0 .../flywheel/shaders/model.vert | 10 ++- .../flywheel/shaders/oriented.vert | 14 ++-- .../shaders/template/instanced/instanced.frag | 0 .../shaders/template/instanced/instanced.vert | 0 .../shaders/template/meshlet/meshlet.glsl | 0 .../shaders/template/model/model.frag | 0 .../shaders/template/model/model.vert | 0 47 files changed, 262 insertions(+), 317 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/Flywheel.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/loading/ShaderLoadingException.java delete mode 100644 src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/block.frag (80%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/context/crumbling/builtin.frag (92%) create mode 100644 src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling/builtin.vert rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/context/world/builtin.frag (83%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/context/world/builtin.vert (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/context/world/fog.glsl (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/core/color.glsl (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/core/diffuse.glsl (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/core/lightutil.glsl (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/core/matutils.glsl (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/core/quaternion.glsl (60%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/data/blockfragment.glsl (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/data/modelvertex.glsl (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/model.vert (69%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/oriented.vert (63%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/template/instanced/instanced.frag (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/template/instanced/instanced.vert (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/template/meshlet/meshlet.glsl (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/template/model/model.frag (100%) rename src/main/resources/assets/{create => flywheel}/flywheel/shaders/template/model/model.vert (100%) diff --git a/src/main/java/com/jozufozu/flywheel/Flywheel.java b/src/main/java/com/jozufozu/flywheel/Flywheel.java new file mode 100644 index 000000000..45cff0f46 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/Flywheel.java @@ -0,0 +1,6 @@ +package com.jozufozu.flywheel; + +public class Flywheel { + + public static final String ID = "flywheel"; +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java index dd4e6a5a3..70f774155 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java @@ -1,30 +1,26 @@ package com.jozufozu.flywheel.backend; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; -import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.backend.loading.Shader; import com.jozufozu.flywheel.backend.loading.ShaderTransformer; -import net.minecraft.util.ResourceLocation; - public abstract class ShaderContext

{ public final Map> programs = new HashMap<>(); - public final ResourceLocation root; protected final ShaderSpecLoader

specLoader; protected ShaderTransformer transformer = new ShaderTransformer(); - public ShaderContext(ResourceLocation root, ShaderSpecLoader

specLoader) { - this.root = root; + public ShaderContext(ShaderSpecLoader

specLoader) { this.specLoader = specLoader; } @@ -37,24 +33,29 @@ public abstract class ShaderContext

{ public void loadProgramFromSpec(ShaderLoader loader, ProgramSpec programSpec) { - programs.put(programSpec, specLoader.create(loader, this, programSpec)); + try { + programs.put(programSpec, specLoader.create(loader, this, programSpec)); - Backend.log.debug("Loaded program {}", programSpec.name); + Backend.log.debug("Loaded program {}", programSpec.name); + } catch (Exception e) { + Backend.log.error("program '{}': {}", programSpec.name, e.getMessage()); + loader.notifyError(); + } } - public Program loadProgram(ProgramSpec spec, ShaderConstants defines, ShaderLoader loader) { - if (defines != null) - transformer.pushStage(defines); - + public Program loadProgram(ShaderLoader loader, ProgramSpec spec, Collection defines) { Shader vertexFile = loader.source(spec.vert, ShaderType.VERTEX); Shader fragmentFile = loader.source(spec.frag, ShaderType.FRAGMENT); transformer.transformSource(vertexFile); transformer.transformSource(fragmentFile); + if (defines != null) { + vertexFile.defineAll(defines); + fragmentFile.defineAll(defines); + } + Program program = loader.loadProgram(spec.name, vertexFile, fragmentFile); - if (defines != null) - transformer.popStage(); preLink(program); @@ -69,8 +70,4 @@ public abstract class ShaderContext

{ return programs.get(spec).get(); } - public ResourceLocation getRoot() { - return root; - } - } diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index 569e2f3f4..2dbf1a100 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -5,7 +5,6 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.StringReader; -import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.FileChannel; @@ -23,6 +22,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.annotation.Nonnull; + import org.lwjgl.system.MemoryUtil; import com.google.common.collect.Lists; @@ -31,6 +32,7 @@ import com.jozufozu.flywheel.backend.gl.shader.GlShader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.backend.loading.Shader; +import com.jozufozu.flywheel.backend.loading.ShaderLoadingException; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.resources.IResource; @@ -49,6 +51,8 @@ public class ShaderLoader { private final Map shaderSource = new HashMap<>(); + private boolean shouldCrash; + void onResourceManagerReload(IResourceManager manager, Predicate predicate) { if (predicate.test(VanillaResourceType.SHADERS)) { OptifineHandler.refresh(); @@ -56,12 +60,19 @@ public class ShaderLoader { if (Backend.gl20()) { shaderSource.clear(); + + shouldCrash = false; + loadShaderSources(manager); for (ShaderContext context : Backend.contexts) { context.load(this); } + if (shouldCrash) { + throw new ShaderLoadingException("could not load all shaders, see log for details"); + } + Backend.log.info("Loaded all shader programs."); // no need to hog all that memory @@ -70,8 +81,19 @@ public class ShaderLoader { } } + public void notifyError() { + shouldCrash = true; + } + + @Nonnull public String getShaderSource(ResourceLocation loc) { - return shaderSource.get(loc); + String source = shaderSource.get(loc); + + if (source == null) { + throw new ShaderLoadingException(String.format("shader '%s' does not exist", loc)); + } + + return source; } private void loadShaderSources(IResourceManager manager) { @@ -158,12 +180,13 @@ public class ShaderLoader { ResourceLocation include = new ResourceLocation(includeName); if (seen.add(include)) { - String includeSource = getShaderSource(include); - - if (includeSource != null) { - return includeRecursive(includeSource, seen); + try { + return includeRecursive(getShaderSource(include), seen); + } catch (ShaderLoadingException e) { + throw new ShaderLoadingException("could not resolve import: " + e.getMessage()); } } + } return Stream.of(line); @@ -181,7 +204,7 @@ public class ShaderLoader { try { bytebuffer = readToBuffer(is); int i = bytebuffer.position(); - ((Buffer) bytebuffer).rewind(); + bytebuffer.rewind(); return MemoryUtil.memASCII(bytebuffer, i); } catch (IOException e) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java index 80e554f39..cae17d565 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java @@ -8,7 +8,6 @@ import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; import com.jozufozu.flywheel.backend.loading.Program; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Matrix4f; public class BasicProgram extends GlProgram { @@ -21,12 +20,8 @@ public class BasicProgram extends GlProgram { protected int uBlockAtlas; protected int uLightMap; - public BasicProgram(Program builder, ProgramFogMode.Factory fogFactory) { - this(builder.name, builder.program, fogFactory); - } - - public BasicProgram(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory) { - super(name, handle); + public BasicProgram(Program program, ProgramFogMode.Factory fogFactory) { + super(program); uTime = getUniformLocation("uTime"); uViewProjection = getUniformLocation("uViewProjection"); uCameraPos = getUniformLocation("uCameraPos"); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java index e25feeee4..417ae135c 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java @@ -3,15 +3,14 @@ package com.jozufozu.flywheel.backend.core; import static org.lwjgl.opengl.GL20.glUniform2f; import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; - -import net.minecraft.util.ResourceLocation; +import com.jozufozu.flywheel.backend.loading.Program; public class CrumblingProgram extends BasicProgram { protected final int uTextureScale; protected int uCrumbling; - public CrumblingProgram(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory) { - super(name, handle, fogFactory); + public CrumblingProgram(Program program, ProgramFogMode.Factory fogFactory) { + super(program, fogFactory); uTextureScale = getUniformLocation("uTextureScale"); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index c2fbdcdbb..f3b1dada0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -7,6 +7,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Stream; +import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.ResourceUtil; import com.jozufozu.flywheel.backend.ShaderContext; @@ -21,6 +22,7 @@ import com.jozufozu.flywheel.backend.loading.InstancedArraysTemplate; import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.backend.loading.ProgramTemplate; import com.jozufozu.flywheel.backend.loading.Shader; +import com.jozufozu.flywheel.backend.loading.ShaderLoadingException; import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import net.minecraft.util.ResourceLocation; @@ -30,16 +32,17 @@ public class WorldContext

extends ShaderContext

{ private static final String declaration = "#flwbuiltins"; private static final Pattern builtinPattern = Pattern.compile(declaration); - public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation("create", "context/world"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); - public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation("create", "context/crumbling"), new FogSensitiveProgram.SpecLoader<>(CrumblingProgram::new)); - - final Map builtins; - final Map builtinSources; + public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); + public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new FogSensitiveProgram.SpecLoader<>(CrumblingProgram::new)); protected ProgramTemplate template; + protected final ResourceLocation name; protected final Supplier> specStream; protected final TemplateFactory templateFactory; + private final Map builtins = new EnumMap<>(ShaderType.class); + private final Map builtinSources = new EnumMap<>(ShaderType.class); + public WorldContext(ResourceLocation root, ShaderSpecLoader

loader) { this(root, loader, () -> Backend.allMaterials() .stream() @@ -47,11 +50,10 @@ public class WorldContext

extends ShaderContext

{ } public WorldContext(ResourceLocation root, ShaderSpecLoader

loader, Supplier> specStream, TemplateFactory templateFactory) { - super(root, loader); + super(loader); + this.name = root; this.specStream = specStream; this.templateFactory = templateFactory; - builtins = new EnumMap<>(ShaderType.class); - builtinSources = new EnumMap<>(ShaderType.class); builtins.put(ShaderType.FRAGMENT, ResourceUtil.subPath(root, "/builtin.frag")); builtins.put(ShaderType.VERTEX, ResourceUtil.subPath(root, "/builtin.vert")); } @@ -61,7 +63,17 @@ public class WorldContext

extends ShaderContext

{ programs.values().forEach(IMultiProgram::delete); programs.clear(); - builtins.forEach((type, resourceLocation) -> builtinSources.put(type, loader.getShaderSource(resourceLocation))); + Backend.log.info("loading context '{}'", name); + + try { + builtins.forEach((type, resourceLocation) -> builtinSources.put(type, loader.getShaderSource(resourceLocation))); + } catch (ShaderLoadingException e) { + loader.notifyError(); + + Backend.log.error(String.format("could not find builtin: %s", e.getMessage())); + + return; + } template = templateFactory.create(loader); transformer = new ShaderTransformer() @@ -88,7 +100,7 @@ public class WorldContext

extends ShaderContext

{ if (matcher.find()) shader.setSource(matcher.replaceFirst(builtinSources.get(shader.type))); else - throw new RuntimeException(String.format("%s shader '%s' is missing %s, cannot use in World Context", shader.type.name, shader.name, declaration)); + throw new ShaderLoadingException(String.format("%s is missing %s, cannot use in World Context", shader.type.name, declaration)); } public interface TemplateFactory { diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java index 7aa8ef21d..f54e699cc 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java @@ -1,6 +1,9 @@ package com.jozufozu.flywheel.backend.gl.shader; +import java.util.ArrayList; +import java.util.Collections; import java.util.EnumMap; +import java.util.List; import java.util.Map; import com.jozufozu.flywheel.backend.ShaderContext; @@ -9,14 +12,14 @@ import com.jozufozu.flywheel.backend.gl.GlFog; import com.jozufozu.flywheel.backend.gl.GlFogMode; import com.jozufozu.flywheel.backend.loading.Program; -import net.minecraft.util.ResourceLocation; - public class FogSensitiveProgram

implements IMultiProgram

{ private final Map programs; + private final List

debugPrograms; - public FogSensitiveProgram(Map programs) { + public FogSensitiveProgram(Map programs, List

debugPrograms) { this.programs = programs; + this.debugPrograms = debugPrograms; } @Override @@ -39,25 +42,31 @@ public class FogSensitiveProgram

implements IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { + List

debugModes = new ArrayList<>(2); + + String[] modes = new String[]{"NORMAL_DEBUG", "RAINBOW_DEBUG"}; + + for (String mode : modes) { + Program builder = ctx.loadProgram(loader, spec, Collections.singletonList(mode)); + + debugModes.add(fogProgramLoader.create(builder, GlFogMode.NONE.getFogFactory())); + } + Map programs = new EnumMap<>(GlFogMode.class); for (GlFogMode fogMode : GlFogMode.values()) { - ShaderConstants defines = new ShaderConstants(spec.defines); + Program builder = ctx.loadProgram(loader, spec, fogMode.getDefines()); - defines.defineAll(fogMode.getDefines()); - - Program builder = ctx.loadProgram(spec, defines, loader); - - programs.put(fogMode, fogProgramLoader.create(builder.name, builder.program, fogMode.getFogFactory())); + programs.put(fogMode, fogProgramLoader.create(builder, fogMode.getFogFactory())); } - return new FogSensitiveProgram<>(programs); + return new FogSensitiveProgram<>(programs, debugModes); } } public interface FogProgramLoader

{ - P create(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory); + P create(Program program, ProgramFogMode.Factory fogFactory); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java index 65e284062..e62ba84df 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GlProgram.java @@ -8,6 +8,7 @@ import static org.lwjgl.opengl.GL20.glUseProgram; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.gl.GlObject; +import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.util.RenderUtil; import net.minecraft.util.ResourceLocation; @@ -17,9 +18,9 @@ public abstract class GlProgram extends GlObject { public final ResourceLocation name; - protected GlProgram(ResourceLocation name, int handle) { - setHandle(handle); - this.name = name; + protected GlProgram(Program program) { + setHandle(program.program); + this.name = program.name; } public void bind() { diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java index 247662d22..a7f686fff 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java @@ -1,5 +1,8 @@ package com.jozufozu.flywheel.backend.gl.shader; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.util.ResourceLocation; public class ProgramSpec { @@ -8,48 +11,12 @@ public class ProgramSpec { public final ResourceLocation vert; public final ResourceLocation frag; - public final ShaderConstants defines; + public final List debugModes = new ArrayList<>(); - public static Builder builder(ResourceLocation name) { - return new Builder(name); - } - - public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag, ShaderConstants defines) { + public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag) { this.name = name; this.vert = vert; this.frag = frag; - this.defines = defines; - } - - public static class Builder { - private ResourceLocation vert; - private ResourceLocation frag; - private ShaderConstants defines = ShaderConstants.EMPTY; - - private final ResourceLocation name; - - public Builder(ResourceLocation name) { - this.name = name; - } - - public Builder setVert(ResourceLocation vert) { - this.vert = vert; - return this; - } - - public Builder setFrag(ResourceLocation frag) { - this.frag = frag; - return this; - } - - public Builder setDefines(ShaderConstants defines) { - this.defines = defines; - return this; - } - - public ProgramSpec build() { - return new ProgramSpec(name, vert, frag, defines); - } } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java deleted file mode 100644 index 5119310f7..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderConstants.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.jozufozu.flywheel.backend.gl.shader; - -import java.io.BufferedReader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import com.google.common.collect.Lists; -import com.jozufozu.flywheel.backend.loading.ProcessingStage; -import com.jozufozu.flywheel.backend.loading.Shader; - -public class ShaderConstants implements ProcessingStage { - public static final ShaderConstants EMPTY = new ShaderConstants(); - - private final ArrayList defines; - - public ShaderConstants() { - defines = new ArrayList<>(); - } - - public ShaderConstants(ShaderConstants other) { - this.defines = Lists.newArrayList(other.defines); - } - - public static ShaderConstants define(String def) { - return new ShaderConstants().def(def); - } - - public ShaderConstants def(String def) { - defines.add(def); - return this; - } - - public ShaderConstants defineAll(Collection defines) { - this.defines.addAll(defines); - return this; - } - - public ArrayList getDefines() { - return defines; - } - - public Stream directives() { - return defines.stream().map(it -> "#define " + it); - } - - @Override - public void process(Shader shader) { - shader.setSource(new BufferedReader(new StringReader(shader.getSource())).lines().flatMap(line -> { - Stream map = Stream.of(line); - - if (line.startsWith("#version")) { - map = Stream.concat(map, directives()); - } - - return map; - }).collect(Collectors.joining("\n"))); - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java index a957d24b6..d66f10bb6 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java @@ -4,8 +4,6 @@ import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.loading.Program; -import net.minecraft.util.ResourceLocation; - public class SingleProgram

implements IMultiProgram

{ final P program; @@ -32,14 +30,12 @@ public class SingleProgram

implements IMultiProgram

{ @Override public IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { - Program builder = ctx.loadProgram(spec, spec.defines, loader); - - return new SingleProgram<>(factory.create(builder.name, builder.program)); + return new SingleProgram<>(factory.create(ctx.loadProgram(loader, spec, null))); } } @FunctionalInterface public interface ProgramFactory

{ - P create(ResourceLocation name, int handle); + P create(Program program); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java index 1314e66b9..6f3c6cd84 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/InstancedArraysTemplate.java @@ -1,5 +1,6 @@ package com.jozufozu.flywheel.backend.loading; +import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; @@ -18,8 +19,8 @@ public class InstancedArraysTemplate extends ProgramTemplate { public static final String[] requiredFrag = {fragment}; - public static final ResourceLocation vert = new ResourceLocation("create", "template/instanced/instanced.vert"); - public static final ResourceLocation frag = new ResourceLocation("create", "template/instanced/instanced.frag"); + public static final ResourceLocation vert = new ResourceLocation(Flywheel.ID, "template/instanced/instanced.vert"); + public static final ResourceLocation frag = new ResourceLocation(Flywheel.ID, "template/instanced/instanced.frag"); public InstancedArraysTemplate(ShaderLoader loader) { super(loader); diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ModelTemplate.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ModelTemplate.java index ffa650c73..5e12d8652 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/ModelTemplate.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ModelTemplate.java @@ -1,5 +1,6 @@ package com.jozufozu.flywheel.backend.loading; +import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.backend.ShaderLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; @@ -15,8 +16,8 @@ public class ModelTemplate extends ProgramTemplate { public static final String[] requiredFrag = {fragment}; - public static final ResourceLocation vert = new ResourceLocation("create", "template/model/model.vert"); - public static final ResourceLocation frag = new ResourceLocation("create", "template/model/model.frag"); + public static final ResourceLocation vert = new ResourceLocation(Flywheel.ID, "template/model/model.vert"); + public static final ResourceLocation frag = new ResourceLocation(Flywheel.ID, "template/model/model.frag"); public ModelTemplate(ShaderLoader loader) { super(loader); diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java b/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java index aa70847b8..250172968 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/Shader.java @@ -1,17 +1,20 @@ package com.jozufozu.flywheel.backend.loading; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import net.minecraft.util.ResourceLocation; public class Shader { + public static final Pattern versionDetector = Pattern.compile("#version[^\\n]*"); private static final Pattern decorator = Pattern.compile("#\\[([\\w_]*)]"); public final ResourceLocation name; @@ -54,6 +57,21 @@ public class Shader { } } + public void defineAll(Collection defines) { + Matcher matcher = versionDetector.matcher(source); + + if (matcher.find()) { + StringBuffer sourceWithDefines = new StringBuffer(); + String lines = defines.stream().map(it -> "#define " + it).collect(Collectors.joining("\n")); + + matcher.appendReplacement(sourceWithDefines, matcher.group() + '\n' + lines); + + matcher.appendTail(sourceWithDefines); + + source = sourceWithDefines.toString(); + } + } + public void parseStructs() { Matcher structMatcher = TaggedStruct.taggedStruct.matcher(source); diff --git a/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderLoadingException.java b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderLoadingException.java new file mode 100644 index 000000000..5c32c7d98 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/loading/ShaderLoadingException.java @@ -0,0 +1,22 @@ +package com.jozufozu.flywheel.backend.loading; + +public class ShaderLoadingException extends RuntimeException { + public ShaderLoadingException() { + } + + public ShaderLoadingException(String message) { + super(message); + } + + public ShaderLoadingException(String message, Throwable cause) { + super(message, cause); + } + + public ShaderLoadingException(Throwable cause) { + super(cause); + } + + public ShaderLoadingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java index 868c121ab..b5952789a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java @@ -4,30 +4,30 @@ import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; +import com.jozufozu.flywheel.backend.loading.Program; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.vector.Matrix4f; public class ContraptionProgram extends BasicProgram { - protected final int uLightBoxSize; - protected final int uLightBoxMin; - protected final int uModel; + protected final int uLightBoxSize; + protected final int uLightBoxMin; + protected final int uModel; - protected int uLightVolume; + protected int uLightVolume; - public ContraptionProgram(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory) { - super(name, handle, fogFactory); - uLightBoxSize = getUniformLocation("uLightBoxSize"); - uLightBoxMin = getUniformLocation("uLightBoxMin"); - uModel = getUniformLocation("uModel"); - } + public ContraptionProgram(Program program, ProgramFogMode.Factory fogFactory) { + super(program, fogFactory); + uLightBoxSize = getUniformLocation("uLightBoxSize"); + uLightBoxMin = getUniformLocation("uLightBoxMin"); + uModel = getUniformLocation("uModel"); + } - @Override - protected void registerSamplers() { - super.registerSamplers(); - uLightVolume = setSamplerBinding("uLightVolume", 4); - } + @Override + protected void registerSamplers() { + super.registerSamplers(); + uLightVolume = setSamplerBinding("uLightVolume", 4); + } public void bind(Matrix4f model, AxisAlignedBB lightVolume) { double sizeX = lightVolume.maxX - lightVolume.minX; diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index bf67269e3..a08553039 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -2,8 +2,8 @@ package com.simibubi.create.foundation.render; import static com.jozufozu.flywheel.backend.Backend.register; +import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; -import com.jozufozu.flywheel.backend.gl.shader.ShaderConstants; import com.simibubi.create.Create; import net.minecraft.util.ResourceLocation; @@ -13,55 +13,20 @@ public class AllProgramSpecs { // noop, make sure the static field are loaded. } - public static final ProgramSpec CHROMATIC = register(builder("chromatic") - .setVert(Locations.EFFECT_VERT) - .setFrag(Locations.EFFECT_FRAG) - .build()); - - public static final ProgramSpec MODEL = register(builder("model") - .setVert(Locations.MODEL_VERT) - .setFrag(Locations.BLOCK) - .build()); - - public static final ProgramSpec ORIENTED = register(builder("oriented") - .setVert(Locations.ORIENTED) - .setFrag(Locations.BLOCK) - .build()); - - public static final ProgramSpec ROTATING = register(builder("rotating") - .setVert(Locations.ROTATING) - .setFrag(Locations.BLOCK) - .build()); - - public static final ProgramSpec BELT = register(builder("belt") - .setVert(Locations.BELT) - .setFrag(Locations.BLOCK) - .build()); - - public static final ProgramSpec FLAPS = register(builder("flap") - .setVert(Locations.FLAP) - .setFrag(Locations.BLOCK) - .build()); - public static final ProgramSpec STRUCTURE = register(builder("contraption_structure") - .setVert(Locations.CONTRAPTION_STRUCTURE) - .setFrag(Locations.BLOCK) - .setDefines(ShaderConstants.define("CONTRAPTION")) - .build()); - public static final ProgramSpec ACTOR = register(builder("contraption_actor") - .setVert(Locations.CONTRAPTION_ACTOR) - .setFrag(Locations.BLOCK) - .setDefines(ShaderConstants.define("CONTRAPTION")) - .build()); - - public static ProgramSpec.Builder builder(String name) { - return ProgramSpec.builder(new ResourceLocation(Create.ID, name)); - } + public static final ProgramSpec CHROMATIC = register(new ProgramSpec(loc("chromatic"), Locations.EFFECT_VERT, Locations.EFFECT_FRAG)); + public static final ProgramSpec MODEL = register(new ProgramSpec(new ResourceLocation(Flywheel.ID, "model"), Locations.MODEL_VERT, Locations.BLOCK)); + public static final ProgramSpec ORIENTED = register(new ProgramSpec(new ResourceLocation(Flywheel.ID, "oriented"), Locations.ORIENTED, Locations.BLOCK)); + public static final ProgramSpec ROTATING = register(new ProgramSpec(loc("rotating"), Locations.ROTATING, Locations.BLOCK)); + public static final ProgramSpec BELT = register(new ProgramSpec(loc("belt"), Locations.BELT, Locations.BLOCK)); + public static final ProgramSpec FLAPS = register(new ProgramSpec(loc("flap"), Locations.FLAP, Locations.BLOCK)); + public static final ProgramSpec STRUCTURE = register(new ProgramSpec(loc("contraption_structure"), Locations.CONTRAPTION_STRUCTURE, Locations.BLOCK)); + public static final ProgramSpec ACTOR = register(new ProgramSpec(loc("contraption_actor"), Locations.CONTRAPTION_ACTOR, Locations.BLOCK)); public static class Locations { - public static final ResourceLocation BLOCK = loc("block.frag"); + public static final ResourceLocation BLOCK = new ResourceLocation(Flywheel.ID, "block.frag"); - public static final ResourceLocation MODEL_VERT = loc("model.vert"); - public static final ResourceLocation ORIENTED = loc("oriented.vert"); + public static final ResourceLocation MODEL_VERT = new ResourceLocation(Flywheel.ID, "model.vert"); + public static final ResourceLocation ORIENTED = new ResourceLocation(Flywheel.ID, "oriented.vert"); public static final ResourceLocation ROTATING = loc("rotating.vert"); public static final ResourceLocation BELT = loc("belt.vert"); @@ -71,9 +36,9 @@ public class AllProgramSpecs { public static final ResourceLocation EFFECT_VERT = loc("area_effect.vert"); public static final ResourceLocation EFFECT_FRAG = loc("area_effect.frag"); + } - private static ResourceLocation loc(String name) { - return new ResourceLocation(Create.ID, name); - } + private static ResourceLocation loc(String name) { + return new ResourceLocation(Create.ID, name); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java index f02261b66..5771e712e 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java @@ -6,14 +6,12 @@ import com.jozufozu.flywheel.backend.gl.shader.SingleProgram; import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import com.simibubi.create.foundation.render.AllProgramSpecs; -import net.minecraft.util.ResourceLocation; - public class EffectsContext extends ShaderContext { public static final EffectsContext INSTANCE = new EffectsContext(); public EffectsContext() { - super(new ResourceLocation("create", "effects"), new SingleProgram.SpecLoader<>(SphereFilterProgram::new)); + super(new SingleProgram.SpecLoader<>(SphereFilterProgram::new)); } @Override diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java index a431579b2..80c4b5b67 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java @@ -9,8 +9,8 @@ import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.loading.Program; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Vector3d; @@ -41,14 +41,14 @@ public class SphereFilterProgram extends GlProgram { protected final int uCameraPos; - public SphereFilterProgram(ResourceLocation name, int handle) { - super(name, handle); + public SphereFilterProgram(Program program) { + super(program); effectsUBO = new GlBuffer(GlBufferType.UNIFORM_BUFFER); - uniformBlock = GL31.glGetUniformBlockIndex(handle, "Filters"); + uniformBlock = GL31.glGetUniformBlockIndex(program.program, "Filters"); - GL31.glUniformBlockBinding(handle, uniformBlock, UBO_BINDING); + GL31.glUniformBlockBinding(program.program, uniformBlock, UBO_BINDING); effectsUBO.bind(); effectsUBO.alloc(BUFFER_SIZE); diff --git a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag index e2e99fc66..6c34704ce 100644 --- a/src/main/resources/assets/create/flywheel/shaders/area_effect.frag +++ b/src/main/resources/assets/create/flywheel/shaders/area_effect.frag @@ -1,6 +1,6 @@ #version 140 -#flwinclude <"create:core/color.glsl"> +#flwinclude <"flywheel:core/color.glsl"> in vec2 ScreenCoord; in vec3 WorldDir; diff --git a/src/main/resources/assets/create/flywheel/shaders/belt.vert b/src/main/resources/assets/create/flywheel/shaders/belt.vert index 5d94c0f35..ce8ec2d5e 100644 --- a/src/main/resources/assets/create/flywheel/shaders/belt.vert +++ b/src/main/resources/assets/create/flywheel/shaders/belt.vert @@ -1,9 +1,9 @@ #define PI 3.1415926538 #flwbuiltins -#flwinclude <"create:core/quaternion.glsl"> -#flwinclude <"create:core/matutils.glsl"> -#flwinclude <"create:core/diffuse.glsl"> +#flwinclude <"flywheel:core/quaternion.glsl"> +#flwinclude <"flywheel:core/matutils.glsl"> +#flwinclude <"flywheel:core/diffuse.glsl"> #[InstanceData] struct Belt { @@ -18,8 +18,8 @@ struct Belt { float scrollMult; }; -#flwinclude <"create:data/modelvertex.glsl"> -#flwinclude <"create:data/blockfragment.glsl"> +#flwinclude <"flywheel:data/modelvertex.glsl"> +#flwinclude <"flywheel:data/blockfragment.glsl"> BlockFrag FLWMain(Vertex v, Belt instance) { vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5; @@ -41,6 +41,8 @@ BlockFrag FLWMain(Vertex v, Belt instance) { #if defined(RAINBOW_DEBUG) b.color = instance.color; + #elif defined(NORMAL_DEBUG) + b.color = vec4(norm, 1.); #else b.color = vec4(1.); #endif diff --git a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag index 6a211bc46..43197a6c0 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag @@ -1,5 +1,5 @@ -#flwinclude <"create:context/world/fog.glsl"> -#flwinclude <"create:core/lightutil.glsl"> +#flwinclude <"flywheel:context/world/fog.glsl"> +#flwinclude <"flywheel:core/lightutil.glsl"> varying vec3 BoxCoord; uniform sampler3D uLightVolume; diff --git a/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert b/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert deleted file mode 100644 index 8b61a3168..000000000 --- a/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.vert +++ /dev/null @@ -1 +0,0 @@ -#flwinclude <"create:context/world/builtin.vert"> diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert index 6fe9b3ac4..b075730b9 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert @@ -1,9 +1,9 @@ #define PI 3.1415926538 #flwbuiltins -#flwinclude <"create:core/matutils.glsl"> -#flwinclude <"create:core/quaternion.glsl"> -#flwinclude <"create:core/diffuse.glsl"> +#flwinclude <"flywheel:core/matutils.glsl"> +#flwinclude <"flywheel:core/quaternion.glsl"> +#flwinclude <"flywheel:core/diffuse.glsl"> #[InstanceData] struct Actor { @@ -16,8 +16,8 @@ struct Actor { float speed; }; -#flwinclude <"create:data/modelvertex.glsl"> -#flwinclude <"create:data/blockfragment.glsl"> +#flwinclude <"flywheel:data/modelvertex.glsl"> +#flwinclude <"flywheel:data/blockfragment.glsl"> BlockFrag FLWMain(Vertex v, Actor instance) { float degrees = instance.offset + uTime * instance.speed / 20.; @@ -36,7 +36,12 @@ BlockFrag FLWMain(Vertex v, Actor instance) { b.diffuse = diffuse(norm); b.texCoords = v.texCoords; b.light = instance.light; + + #if defined(NORMAL_DEBUG) + b.color = vec4(norm, 1.); + #else b.color = vec4(1.); + #endif return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert index cac2956a0..fb3e66070 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert @@ -1,8 +1,8 @@ #define PI 3.1415926538 #flwbuiltins -#flwinclude <"create:core/matutils.glsl"> -#flwinclude <"create:core/diffuse.glsl"> +#flwinclude <"flywheel:core/matutils.glsl"> +#flwinclude <"flywheel:core/diffuse.glsl"> #[VertexData] struct Vertex { @@ -13,7 +13,7 @@ struct Vertex { vec2 modelLight; }; -#flwinclude <"create:data/blockfragment.glsl"> +#flwinclude <"flywheel:data/blockfragment.glsl"> BlockFrag FLWMain(Vertex v) { vec4 worldPos = vec4(v.pos, 1.); @@ -24,9 +24,14 @@ BlockFrag FLWMain(Vertex v) { BlockFrag b; b.diffuse = diffuse(norm); - b.color = v.color / diffuse(v.normal); b.texCoords = v.texCoords; b.light = v.modelLight; + #if defined(NORMAL_DEBUG) + b.color = vec4(norm, 1.); + #else + b.color = v.color / diffuse(v.normal); + #endif + return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/flap.vert b/src/main/resources/assets/create/flywheel/shaders/flap.vert index 1f5c973ad..047455554 100644 --- a/src/main/resources/assets/create/flywheel/shaders/flap.vert +++ b/src/main/resources/assets/create/flywheel/shaders/flap.vert @@ -1,9 +1,9 @@ #define PI 3.1415926538 #flwbuiltins -#flwinclude <"create:core/matutils.glsl"> -#flwinclude <"create:core/quaternion.glsl"> -#flwinclude <"create:core/diffuse.glsl"> +#flwinclude <"flywheel:core/matutils.glsl"> +#flwinclude <"flywheel:core/quaternion.glsl"> +#flwinclude <"flywheel:core/diffuse.glsl"> #[InstanceData] struct Flap { @@ -17,8 +17,8 @@ struct Flap { float flapness; }; -#flwinclude <"create:data/modelvertex.glsl"> -#flwinclude <"create:data/blockfragment.glsl"> +#flwinclude <"flywheel:data/modelvertex.glsl"> +#flwinclude <"flywheel:data/blockfragment.glsl"> float toRad(float degrees) { @@ -57,6 +57,10 @@ BlockFrag FLWMain(Vertex v, Flap flap) { b.diffuse = diffuse(norm); b.texCoords = v.texCoords; b.light = flap.light; + #if defined(NORMAL_DEBUG) + b.color = vec4(norm, 1.); + #else b.color = vec4(1.); + #endif return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/shaders/rotating.vert index 5957c2752..f5fe07bde 100644 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ b/src/main/resources/assets/create/flywheel/shaders/rotating.vert @@ -1,8 +1,8 @@ #define PI 3.1415926538 #flwbuiltins -#flwinclude <"create:core/matutils.glsl"> -#flwinclude <"create:core/diffuse.glsl"> +#flwinclude <"flywheel:core/matutils.glsl"> +#flwinclude <"flywheel:core/diffuse.glsl"> #[InstanceData] struct Rotating { @@ -14,24 +14,23 @@ struct Rotating { vec3 axis; }; -#flwinclude <"create:data/modelvertex.glsl"> -#flwinclude <"create:data/blockfragment.glsl"> +#flwinclude <"flywheel:data/modelvertex.glsl"> +#flwinclude <"flywheel:data/blockfragment.glsl"> mat4 kineticRotation(float offset, float speed, vec3 axis) { - float degrees = offset + uTime * speed * -3./10.; + float degrees = offset + uTime * speed * 3./10.; float angle = fract(degrees / 360.) * PI * 2.; return rotate(axis, angle); } BlockFrag FLWMain(Vertex v, Rotating instance) { - mat4 kineticRotation = kineticRotation(instance.offset, instance.speed, instance.axis); + mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis); - vec4 worldPos = vec4(v.pos - .5, 1.); - worldPos *= kineticRotation; + vec4 worldPos = spin * vec4(v.pos - .5, 1.); worldPos += vec4(instance.pos + .5, 0.); - vec3 norm = modelToNormal(kineticRotation) * v.normal; + vec3 norm = modelToNormal(spin) * v.normal; FLWFinalizeWorldPos(worldPos); FLWFinalizeNormal(norm); @@ -43,6 +42,8 @@ BlockFrag FLWMain(Vertex v, Rotating instance) { #if defined(RAINBOW_DEBUG) b.color = instance.color; + #elif defined(NORMAL_DEBUG) + b.color = vec4(norm, 1.); #else b.color = vec4(1.); #endif diff --git a/src/main/resources/assets/create/flywheel/shaders/block.frag b/src/main/resources/assets/flywheel/flywheel/shaders/block.frag similarity index 80% rename from src/main/resources/assets/create/flywheel/shaders/block.frag rename to src/main/resources/assets/flywheel/flywheel/shaders/block.frag index e24666099..4b350cf60 100644 --- a/src/main/resources/assets/create/flywheel/shaders/block.frag +++ b/src/main/resources/assets/flywheel/flywheel/shaders/block.frag @@ -1,6 +1,6 @@ #flwbuiltins -#flwinclude <"create:data/blockfragment.glsl"> +#flwinclude <"flywheel:data/blockfragment.glsl"> void FLWMain(BlockFrag r) { vec4 tex = FLWBlockTexture(r.texCoords); diff --git a/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag b/src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling/builtin.frag similarity index 92% rename from src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag rename to src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling/builtin.frag index 5bee49af8..3f68e588c 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/crumbling/builtin.frag +++ b/src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling/builtin.frag @@ -1,4 +1,4 @@ -#flwinclude <"create:context/world/fog.glsl"> +#flwinclude <"flywheel:context/world/fog.glsl"> uniform vec2 uTextureScale; uniform sampler2D uBlockAtlas; diff --git a/src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling/builtin.vert b/src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling/builtin.vert new file mode 100644 index 000000000..730ca3556 --- /dev/null +++ b/src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling/builtin.vert @@ -0,0 +1 @@ +#flwinclude <"flywheel:context/world/builtin.vert"> diff --git a/src/main/resources/assets/create/flywheel/shaders/context/world/builtin.frag b/src/main/resources/assets/flywheel/flywheel/shaders/context/world/builtin.frag similarity index 83% rename from src/main/resources/assets/create/flywheel/shaders/context/world/builtin.frag rename to src/main/resources/assets/flywheel/flywheel/shaders/context/world/builtin.frag index 81e9a2be9..e8b615c75 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/world/builtin.frag +++ b/src/main/resources/assets/flywheel/flywheel/shaders/context/world/builtin.frag @@ -1,5 +1,5 @@ -#flwinclude <"create:context/world/fog.glsl"> -#flwinclude <"create:core/lightutil.glsl"> +#flwinclude <"flywheel:context/world/fog.glsl"> +#flwinclude <"flywheel:core/lightutil.glsl"> uniform sampler2D uBlockAtlas; uniform sampler2D uLightMap; diff --git a/src/main/resources/assets/create/flywheel/shaders/context/world/builtin.vert b/src/main/resources/assets/flywheel/flywheel/shaders/context/world/builtin.vert similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/context/world/builtin.vert rename to src/main/resources/assets/flywheel/flywheel/shaders/context/world/builtin.vert diff --git a/src/main/resources/assets/create/flywheel/shaders/context/world/fog.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/context/world/fog.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/context/world/fog.glsl rename to src/main/resources/assets/flywheel/flywheel/shaders/context/world/fog.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/core/color.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/core/color.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/core/color.glsl rename to src/main/resources/assets/flywheel/flywheel/shaders/core/color.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/core/diffuse.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/core/diffuse.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/core/diffuse.glsl rename to src/main/resources/assets/flywheel/flywheel/shaders/core/diffuse.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/core/lightutil.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/core/lightutil.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/core/lightutil.glsl rename to src/main/resources/assets/flywheel/flywheel/shaders/core/lightutil.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/core/matutils.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/core/matutils.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/core/matutils.glsl rename to src/main/resources/assets/flywheel/flywheel/shaders/core/matutils.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/core/quaternion.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/core/quaternion.glsl similarity index 60% rename from src/main/resources/assets/create/flywheel/shaders/core/quaternion.glsl rename to src/main/resources/assets/flywheel/flywheel/shaders/core/quaternion.glsl index cbfff38ee..fb3e1ae95 100644 --- a/src/main/resources/assets/create/flywheel/shaders/core/quaternion.glsl +++ b/src/main/resources/assets/flywheel/flywheel/shaders/core/quaternion.glsl @@ -16,35 +16,6 @@ vec4 quatMult(vec4 q1, vec4 q2) { return a + b + c + d; } -// -//vec4 exp(vec4 q) { -// vec3 i = q.xyz; -// float r = sqrt(dot(i, i)); -// float et = exp(q.w); -// float s = et * sin(r) / r; -// -// vec4 qr; -// qr.w = et * cos(r); -// qr.xyz = i * s; -// -// return qr; -//} -// -//vec4 ln(vec4 q) { -// vec3 i = q.xyz; -// float r = sqrt(dot(i, i)); -// float t = atan(r, q.w) / r; -// -// vec4 qr; -// qr.w = log(dot(q, q)) * 0.5; -// qr.xyz = i * t; -// -// return qr; -//} -// -//vec4 pow(vec4 q, float n) { -// return exp(ln(q) * n); -//} vec3 rotateVertexByQuat(vec3 v, vec4 q) { vec3 i = q.xyz; @@ -53,4 +24,4 @@ vec3 rotateVertexByQuat(vec3 v, vec4 q) { vec3 rotateAbout(vec3 v, vec3 axis, float angle) { return rotateVertexByQuat(v, quat(axis, angle)); -} \ No newline at end of file +} diff --git a/src/main/resources/assets/create/flywheel/shaders/data/blockfragment.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/data/blockfragment.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/data/blockfragment.glsl rename to src/main/resources/assets/flywheel/flywheel/shaders/data/blockfragment.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/data/modelvertex.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/data/modelvertex.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/data/modelvertex.glsl rename to src/main/resources/assets/flywheel/flywheel/shaders/data/modelvertex.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/model.vert b/src/main/resources/assets/flywheel/flywheel/shaders/model.vert similarity index 69% rename from src/main/resources/assets/create/flywheel/shaders/model.vert rename to src/main/resources/assets/flywheel/flywheel/shaders/model.vert index c9ca3fcea..d475c7a3b 100644 --- a/src/main/resources/assets/create/flywheel/shaders/model.vert +++ b/src/main/resources/assets/flywheel/flywheel/shaders/model.vert @@ -1,5 +1,5 @@ #flwbuiltins -#flwinclude <"create:core/diffuse.glsl"> +#flwinclude <"flywheel:core/diffuse.glsl"> #[InstanceData] struct Instance { @@ -9,8 +9,8 @@ struct Instance { mat3 normalMat; }; -#flwinclude <"create:data/modelvertex.glsl"> -#flwinclude <"create:data/blockfragment.glsl"> +#flwinclude <"flywheel:data/modelvertex.glsl"> +#flwinclude <"flywheel:data/blockfragment.glsl"> BlockFrag FLWMain(Vertex v, Instance i) { vec4 worldPos = i.transform * vec4(v.pos, 1.); @@ -26,6 +26,10 @@ BlockFrag FLWMain(Vertex v, Instance i) { b.diffuse = diffuse(norm); b.texCoords = v.texCoords; b.light = i.light; + #if defined(NORMAL_DEBUG) + b.color = vec4(norm, 1.); + #else b.color = i.color; + #endif return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/oriented.vert b/src/main/resources/assets/flywheel/flywheel/shaders/oriented.vert similarity index 63% rename from src/main/resources/assets/create/flywheel/shaders/oriented.vert rename to src/main/resources/assets/flywheel/flywheel/shaders/oriented.vert index 6b978c08d..809e8fa92 100644 --- a/src/main/resources/assets/create/flywheel/shaders/oriented.vert +++ b/src/main/resources/assets/flywheel/flywheel/shaders/oriented.vert @@ -1,7 +1,7 @@ #flwbuiltins -#flwinclude <"create:core/matutils.glsl"> -#flwinclude <"create:core/quaternion.glsl"> -#flwinclude <"create:core/diffuse.glsl"> +#flwinclude <"flywheel:core/matutils.glsl"> +#flwinclude <"flywheel:core/quaternion.glsl"> +#flwinclude <"flywheel:core/diffuse.glsl"> #[InstanceData] struct Oriented { @@ -12,8 +12,8 @@ struct Oriented { vec4 rotation; }; -#flwinclude <"create:data/modelvertex.glsl"> -#flwinclude <"create:data/blockfragment.glsl"> +#flwinclude <"flywheel:data/modelvertex.glsl"> +#flwinclude <"flywheel:data/blockfragment.glsl"> BlockFrag FLWMain(Vertex v, Oriented o) { vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.); @@ -27,6 +27,10 @@ BlockFrag FLWMain(Vertex v, Oriented o) { b.diffuse = diffuse(norm); b.texCoords = v.texCoords; b.light = o.light; + #if defined(NORMAL_DEBUG) + b.color = vec4(norm, 1.); + #else b.color = o.color; + #endif return b; } diff --git a/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag b/src/main/resources/assets/flywheel/flywheel/shaders/template/instanced/instanced.frag similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.frag rename to src/main/resources/assets/flywheel/flywheel/shaders/template/instanced/instanced.frag diff --git a/src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert b/src/main/resources/assets/flywheel/flywheel/shaders/template/instanced/instanced.vert similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/template/instanced/instanced.vert rename to src/main/resources/assets/flywheel/flywheel/shaders/template/instanced/instanced.vert diff --git a/src/main/resources/assets/create/flywheel/shaders/template/meshlet/meshlet.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/template/meshlet/meshlet.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/template/meshlet/meshlet.glsl rename to src/main/resources/assets/flywheel/flywheel/shaders/template/meshlet/meshlet.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/template/model/model.frag b/src/main/resources/assets/flywheel/flywheel/shaders/template/model/model.frag similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/template/model/model.frag rename to src/main/resources/assets/flywheel/flywheel/shaders/template/model/model.frag diff --git a/src/main/resources/assets/create/flywheel/shaders/template/model/model.vert b/src/main/resources/assets/flywheel/flywheel/shaders/template/model/model.vert similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/template/model/model.vert rename to src/main/resources/assets/flywheel/flywheel/shaders/template/model/model.vert From 9a178ef9d82b8ecfbcbb5031fd4997b60608d0f0 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Wed, 19 May 2021 19:11:06 -0700 Subject: [PATCH 071/198] Abstract fog - WorldPrograms no longer accept an explicit fog mode. - They now inherit from a class that takes a list of arbitrary shader extensions --- .../jozufozu/flywheel/backend/Backend.java | 12 +-- .../flywheel/backend/ShaderContext.java | 2 +- .../backend/core/CrumblingProgram.java | 9 ++- .../core/FirstNonnullMultiProgram.java | 6 ++ .../flywheel/backend/core/WorldContext.java | 10 +-- .../WorldMultiProgram.java} | 31 +++---- .../backend/core/WorldTileRenderer.java | 3 +- .../core/shader/ExtensibleGlProgram.java | 62 ++++++++++++++ .../flywheel/backend/core/shader/FogMode.java | 81 +++++++++++++++++++ .../backend/{gl => core/shader}/GlFog.java | 2 +- .../backend/core/shader/GlFogMode.java | 38 +++++++++ .../core/shader/IProgramExtension.java | 17 ++++ .../backend/core/shader/ProgramExtender.java | 18 +++++ .../{gl => core}/shader/ProgramSpec.java | 2 +- .../{gl => core}/shader/SingleProgram.java | 5 +- .../WorldProgram.java} | 18 ++--- .../flywheel/backend/gl/GlFogMode.java | 37 --------- .../backend/gl/shader/ProgramFogMode.java | 58 ------------- .../backend/gl/shader/ShaderSpecLoader.java | 1 + .../instancing/InstancedTileRenderer.java | 4 +- .../backend/instancing/MaterialSpec.java | 2 +- .../backend/instancing/RenderMaterial.java | 4 +- .../render/ContraptionProgram.java | 10 ++- .../render/ContraptionRenderDispatcher.java | 6 +- .../simibubi/create/events/ClientEvents.java | 4 +- .../mixin/flywheel/FogColorTrackerMixin.java | 2 +- .../mixin/flywheel/TileWorldHookMixin.java | 4 +- .../foundation/render/AllProgramSpecs.java | 2 +- .../render/effects/EffectsContext.java | 2 +- 29 files changed, 292 insertions(+), 160 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/FirstNonnullMultiProgram.java rename src/main/java/com/jozufozu/flywheel/backend/{gl/shader/FogSensitiveProgram.java => core/WorldMultiProgram.java} (56%) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/FogMode.java rename src/main/java/com/jozufozu/flywheel/backend/{gl => core/shader}/GlFog.java (95%) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFogMode.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/IProgramExtension.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramExtender.java rename src/main/java/com/jozufozu/flywheel/backend/{gl => core}/shader/ProgramSpec.java (90%) rename src/main/java/com/jozufozu/flywheel/backend/{gl => core}/shader/SingleProgram.java (80%) rename src/main/java/com/jozufozu/flywheel/backend/core/{BasicProgram.java => shader/WorldProgram.java} (75%) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/GlFogMode.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramFogMode.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index 62a8c0cd7..a704b8273 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -20,12 +20,12 @@ import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; -import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.CrumblingRenderer; import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.core.WorldTileRenderer; +import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; -import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; import com.jozufozu.flywheel.backend.instancing.InstanceData; @@ -64,7 +64,7 @@ public class Backend { public static GLCapabilities capabilities; public static GlCompat compat; - public static WorldAttached> tileRenderer = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.INSTANCE)); + public static WorldAttached> tileRenderer = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.INSTANCE)); public static LazyValue> blockBreaking = new LazyValue<>(() -> { Vector renderers = new Vector<>(10); for (int i = 0; i < 10; i++) { @@ -87,7 +87,7 @@ public class Backend { listeners.refreshListener(world -> { if (canUseInstancing() && world != null) { - WorldTileRenderer tileRenderer = Backend.tileRenderer.get(world); + WorldTileRenderer tileRenderer = Backend.tileRenderer.get(world); tileRenderer.invalidate(); world.loadedTileEntityList.forEach(tileRenderer::add); } @@ -190,7 +190,7 @@ public class Backend { Minecraft mc = Minecraft.getInstance(); ClientWorld world = mc.world; - WorldTileRenderer instancer = tileRenderer.get(world); + WorldTileRenderer instancer = tileRenderer.get(world); Entity renderViewEntity = mc.renderViewEntity; instancer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ()); @@ -198,7 +198,7 @@ public class Backend { public static void renderLayer(ClientWorld world, RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { if (!canUseInstancing(world)) return; - WorldTileRenderer renderer = tileRenderer.get(world); + WorldTileRenderer renderer = tileRenderer.get(world); layer.startDrawing(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java index 70f774155..89ab4e48f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java @@ -4,9 +4,9 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; -import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.loading.Program; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java index 417ae135c..2c1606813 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java @@ -2,14 +2,17 @@ package com.jozufozu.flywheel.backend.core; import static org.lwjgl.opengl.GL20.glUniform2f; -import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; +import java.util.List; + +import com.jozufozu.flywheel.backend.core.shader.ProgramExtender; +import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.loading.Program; -public class CrumblingProgram extends BasicProgram { +public class CrumblingProgram extends WorldProgram { protected final int uTextureScale; protected int uCrumbling; - public CrumblingProgram(Program program, ProgramFogMode.Factory fogFactory) { + public CrumblingProgram(Program program, List fogFactory) { super(program, fogFactory); uTextureScale = getUniformLocation("uTextureScale"); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/FirstNonnullMultiProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/FirstNonnullMultiProgram.java new file mode 100644 index 000000000..1e7b441dd --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/FirstNonnullMultiProgram.java @@ -0,0 +1,6 @@ +package com.jozufozu.flywheel.backend.core; + +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; + +public class FirstNonnullMultiProgram

{ +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index f3b1dada0..a68515382 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -12,9 +12,9 @@ import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.ResourceUtil; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; +import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; -import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; @@ -27,13 +27,13 @@ import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import net.minecraft.util.ResourceLocation; -public class WorldContext

extends ShaderContext

{ +public class WorldContext

extends ShaderContext

{ private static final String declaration = "#flwbuiltins"; private static final Pattern builtinPattern = Pattern.compile(declaration); - public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new)); - public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new FogSensitiveProgram.SpecLoader<>(CrumblingProgram::new)); + public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new WorldMultiProgram.SpecLoader<>(WorldProgram::new)); + public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new WorldMultiProgram.SpecLoader<>(CrumblingProgram::new)); protected ProgramTemplate template; protected final ResourceLocation name; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldMultiProgram.java similarity index 56% rename from src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/core/WorldMultiProgram.java index f54e699cc..dfc822a9a 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/FogSensitiveProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldMultiProgram.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.gl.shader; +package com.jozufozu.flywheel.backend.core; import java.util.ArrayList; import java.util.Collections; @@ -8,16 +8,21 @@ import java.util.Map; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.gl.GlFog; -import com.jozufozu.flywheel.backend.gl.GlFogMode; +import com.jozufozu.flywheel.backend.core.shader.ExtensibleGlProgram; +import com.jozufozu.flywheel.backend.core.shader.GlFog; +import com.jozufozu.flywheel.backend.core.shader.GlFogMode; +import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; +import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.loading.Program; -public class FogSensitiveProgram

implements IMultiProgram

{ +public class WorldMultiProgram

implements IMultiProgram

{ private final Map programs; private final List

debugPrograms; - public FogSensitiveProgram(Map programs, List

debugPrograms) { + public WorldMultiProgram(Map programs, List

debugPrograms) { this.programs = programs; this.debugPrograms = debugPrograms; } @@ -34,10 +39,10 @@ public class FogSensitiveProgram

implements IMultiProgram

implements ShaderSpecLoader

{ - private final FogProgramLoader

fogProgramLoader; + private final ExtensibleGlProgram.Factory

factory; - public SpecLoader(FogProgramLoader

fogProgramLoader) { - this.fogProgramLoader = fogProgramLoader; + public SpecLoader(ExtensibleGlProgram.Factory

factory) { + this.factory = factory; } @Override @@ -49,7 +54,7 @@ public class FogSensitiveProgram

implements IMultiProgram

programs = new EnumMap<>(GlFogMode.class); @@ -57,16 +62,12 @@ public class FogSensitiveProgram

implements IMultiProgram

(programs, debugModes); + return new WorldMultiProgram<>(programs, debugModes); } } - public interface FogProgramLoader

{ - - P create(Program program, ProgramFogMode.Factory fogFactory); - } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java index 3ad0efec9..1e04b9edc 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java @@ -2,6 +2,7 @@ package com.jozufozu.flywheel.backend.core; import java.util.ArrayList; +import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; @@ -12,7 +13,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Matrix4f; -public class WorldTileRenderer

extends InstancedTileRenderer

{ +public class WorldTileRenderer

extends InstancedTileRenderer

{ public static int MAX_ORIGIN_DISTANCE = 100; public BlockPos originCoordinate = BlockPos.ZERO; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java new file mode 100644 index 000000000..f2e6423a0 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java @@ -0,0 +1,62 @@ +package com.jozufozu.flywheel.backend.core.shader; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.loading.Program; + +/** + * A shader program that be arbitrarily "extended". This class can take in any number of program extensions, and + * will initialize them and then call their {@link IProgramExtension#bind() bind} function every subsequent time this + * program is bound. An "extension" is something that interacts with the shader program in a way that is invisible to + * the caller using the program. This is used by some programs to implement the different fog modes. Other uses might + * include binding extra textures to allow for blocks to have normal maps, for example. As the extensions are + * per-program, this also allows for same extra specialization within a + * {@link com.jozufozu.flywheel.backend.ShaderContext ShaderContext}. + */ +public class ExtensibleGlProgram extends GlProgram { + + protected final List extensions; + + public ExtensibleGlProgram(Program program, @Nullable List extensions) { + super(program); + + if (extensions != null) { + this.extensions = extensions.stream() + .map(e -> e.create(this)) + .collect(Collectors.toList()); + } else { + this.extensions = Collections.emptyList(); + } + } + + @Override + public void bind() { + super.bind(); + + extensions.forEach(IProgramExtension::bind); + } + + @Override + public String toString() { + return "ExtensibleGlProgram{" + + "name=" + name + + ", extensions=" + extensions + + '}'; + } + + /** + * A factory interface to create {@link GlProgram}s parameterized by a list of extensions. This doesn't necessarily + * have to return an {@link ExtensibleGlProgram} if implementors want more flexibility for whatever reason. + */ + public interface Factory

{ + + @Nonnull + P create(Program program, @Nullable List fogFactory); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/FogMode.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/FogMode.java new file mode 100644 index 000000000..5e88019d2 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/FogMode.java @@ -0,0 +1,81 @@ +package com.jozufozu.flywheel.backend.core.shader; + +import org.lwjgl.opengl.GL20; + +import com.jozufozu.flywheel.Flywheel; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; + +import net.minecraft.util.ResourceLocation; + +public abstract class FogMode { + + public static class None implements IProgramExtension { + + public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_none"); + + public None(GlProgram program) { + + } + + @Override + public void bind() { + + } + + @Override + public ResourceLocation name() { + return NAME; + } + } + + public static class Linear implements IProgramExtension { + + public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_linear"); + + private final int uFogColor; + private final int uFogRange; + + public Linear(GlProgram program) { + this.uFogColor = program.getUniformLocation("uFogColor"); + this.uFogRange = program.getUniformLocation("uFogRange"); + } + + @Override + public void bind() { + GL20.glUniform2f(uFogRange, GlFog.getFogStart(), GlFog.getFogEnd()); + GL20.glUniform4fv(uFogColor, GlFog.FOG_COLOR); + } + + @Override + public ResourceLocation name() { + return NAME; + } + } + + public static class Exp2 implements IProgramExtension { + + public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_exp2"); + + private final int uFogColor; + private final int uFogDensity; + + public Exp2(GlProgram program) { + this.uFogColor = program.getUniformLocation("uFogColor"); + this.uFogDensity = program.getUniformLocation("uFogDensity"); + } + + @Override + public void bind() { + GL20.glUniform1f(uFogDensity, GlFog.getFogDensity()); + GL20.glUniform4fv(uFogColor, GlFog.FOG_COLOR); + } + + @Override + public ResourceLocation name() { + return NAME; + } + } + + public interface Factory extends IProgramExtension { + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlFog.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFog.java similarity index 95% rename from src/main/java/com/jozufozu/flywheel/backend/gl/GlFog.java rename to src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFog.java index 2ad61fcf2..100c1a71d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/GlFog.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFog.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.gl; +package com.jozufozu.flywheel.backend.core.shader; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFogMode.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFogMode.java new file mode 100644 index 000000000..57f1acea6 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFogMode.java @@ -0,0 +1,38 @@ +package com.jozufozu.flywheel.backend.core.shader; + +import java.util.Collections; +import java.util.List; + +import com.google.common.collect.Lists; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; + +public enum GlFogMode implements ProgramExtender { + NONE(FogMode.None::new), + LINEAR(FogMode.Linear::new, "USE_FOG_LINEAR"), + EXP2(FogMode.Exp2::new, "USE_FOG_EXP2"), + ; + + public static final String USE_FOG = "USE_FOG"; + + private final ProgramExtender fogFactory; + private final List defines; + + GlFogMode(ProgramExtender fogFactory) { + this.fogFactory = fogFactory; + this.defines = Collections.emptyList(); + } + + GlFogMode(ProgramExtender fogFactory, String name) { + this.fogFactory = fogFactory; + this.defines = Lists.newArrayList(USE_FOG, name); + } + + public List getDefines() { + return defines; + } + + @Override + public IProgramExtension create(GlProgram program) { + return fogFactory.create(program); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/IProgramExtension.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/IProgramExtension.java new file mode 100644 index 000000000..4e825fa5c --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/IProgramExtension.java @@ -0,0 +1,17 @@ +package com.jozufozu.flywheel.backend.core.shader; + +import net.minecraft.util.ResourceLocation; + +/** + * A program extension to be passed to + */ +public interface IProgramExtension { + + /** + * Bind the extra program state. It is recommended to grab the state information from global variables, + * or local variables passed through a {@link ProgramExtender} closure. + */ + void bind(); + + ResourceLocation name(); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramExtender.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramExtender.java new file mode 100644 index 000000000..b187fa7d2 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramExtender.java @@ -0,0 +1,18 @@ +package com.jozufozu.flywheel.backend.core.shader; + +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; + +/** + * A factory interface for creating {@link IProgramExtension}s. These are what end up being passed in + * during shader program construction. + */ +public interface ProgramExtender { + + /** + * Construct the extension, binding any necessary information using the provided {@link GlProgram}. + * + * @param program The program being extended. + * @return An extension object, possibly initialized using the program. + */ + IProgramExtension create(GlProgram program); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramSpec.java similarity index 90% rename from src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java rename to src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramSpec.java index a7f686fff..6474c008c 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramSpec.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.gl.shader; +package com.jozufozu.flywheel.backend.core.shader; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/SingleProgram.java similarity index 80% rename from src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/core/shader/SingleProgram.java index d66f10bb6..f4da285f3 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/SingleProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/SingleProgram.java @@ -1,7 +1,10 @@ -package com.jozufozu.flywheel.backend.gl.shader; +package com.jozufozu.flywheel.backend.core.shader; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; +import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.loading.Program; public class SingleProgram

implements IMultiProgram

{ diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldProgram.java similarity index 75% rename from src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldProgram.java index cae17d565..749be410b 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BasicProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldProgram.java @@ -1,33 +1,29 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.shader; import static org.lwjgl.opengl.GL20.glUniform1f; import static org.lwjgl.opengl.GL20.glUniform3f; -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; -import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; +import java.util.List; + import com.jozufozu.flywheel.backend.loading.Program; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.util.math.vector.Matrix4f; -public class BasicProgram extends GlProgram { +public class WorldProgram extends ExtensibleGlProgram { protected final int uTime; protected final int uViewProjection; protected final int uCameraPos; - protected final ProgramFogMode fogMode; - protected int uBlockAtlas; protected int uLightMap; - public BasicProgram(Program program, ProgramFogMode.Factory fogFactory) { - super(program); + public WorldProgram(Program program, List fogFactory) { + super(program, fogFactory); uTime = getUniformLocation("uTime"); uViewProjection = getUniformLocation("uViewProjection"); uCameraPos = getUniformLocation("uCameraPos"); - fogMode = fogFactory.create(this); - bind(); registerSamplers(); unbind(); @@ -55,7 +51,5 @@ public class BasicProgram extends GlProgram { super.bind(); uploadTime(AnimationTickHolder.getRenderTime()); - - fogMode.bind(); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlFogMode.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlFogMode.java deleted file mode 100644 index ebb2354bb..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/GlFogMode.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jozufozu.flywheel.backend.gl; - -import java.util.Collections; -import java.util.List; - -import com.google.common.collect.Lists; -import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; - -public enum GlFogMode { - NONE(ProgramFogMode.None::new), - LINEAR(ProgramFogMode.Linear::new, "USE_FOG_LINEAR"), - EXP2(ProgramFogMode.Exp2::new, "USE_FOG_EXP2"), - ; - - public static final String USE_FOG = "USE_FOG"; - - private final ProgramFogMode.Factory fogFactory; - private final List defines; - - GlFogMode(ProgramFogMode.Factory fogFactory) { - this.fogFactory = fogFactory; - this.defines = Collections.emptyList(); - } - - GlFogMode(ProgramFogMode.Factory fogFactory, String name) { - this.fogFactory = fogFactory; - this.defines = Lists.newArrayList(USE_FOG, name); - } - - public List getDefines() { - return defines; - } - - public ProgramFogMode.Factory getFogFactory() { - return fogFactory; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramFogMode.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramFogMode.java deleted file mode 100644 index ec1048f9b..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ProgramFogMode.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.jozufozu.flywheel.backend.gl.shader; - -import org.lwjgl.opengl.GL20; - -import com.jozufozu.flywheel.backend.gl.GlFog; - -public abstract class ProgramFogMode { - - public abstract void bind(); - - public static class None extends ProgramFogMode { - - public None(GlProgram program) { - - } - - @Override - public void bind() { - - } - } - - public static class Linear extends ProgramFogMode { - private final int uFogColor; - private final int uFogRange; - - public Linear(GlProgram program) { - this.uFogColor = program.getUniformLocation("uFogColor"); - this.uFogRange = program.getUniformLocation("uFogRange"); - } - - @Override - public void bind() { - GL20.glUniform2f(uFogRange, GlFog.getFogStart(), GlFog.getFogEnd()); - GL20.glUniform4fv(uFogColor, GlFog.FOG_COLOR); - } - } - - public static class Exp2 extends ProgramFogMode { - private final int uFogColor; - private final int uFogDensity; - - public Exp2(GlProgram program) { - this.uFogColor = program.getUniformLocation("uFogColor"); - this.uFogDensity = program.getUniformLocation("uFogDensity"); - } - - @Override - public void bind() { - GL20.glUniform1f(uFogDensity, GlFog.getFogDensity()); - GL20.glUniform4fv(uFogColor, GlFog.FOG_COLOR); - } - } - - public interface Factory { - ProgramFogMode create(GlProgram program); - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java index f050ac981..1fafd1346 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java @@ -2,6 +2,7 @@ package com.jozufozu.flywheel.backend.gl.shader; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; public interface ShaderSpecLoader

{ diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java index 04a3646fc..69f81f7a1 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java @@ -8,10 +8,10 @@ import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.core.materials.OrientedData; +import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.simibubi.create.foundation.render.AllMaterialSpecs; @@ -25,7 +25,7 @@ import net.minecraft.util.math.vector.Vector3f; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -public abstract class InstancedTileRenderer

{ +public abstract class InstancedTileRenderer

{ public final WorldContext

context; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java index 2cfcfa435..fc30978b2 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java @@ -1,7 +1,7 @@ package com.jozufozu.flywheel.backend.instancing; +import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index c5a1b4e11..209516f56 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -12,8 +12,8 @@ import org.lwjgl.opengl.GL11; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.jozufozu.flywheel.util.BufferBuilderReader; @@ -34,7 +34,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Matrix4f; -public class RenderMaterial

{ +public class RenderMaterial

{ protected final InstancedTileRenderer

renderer; protected final Cache> models; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java index b5952789a..203b5c0fa 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java @@ -1,22 +1,24 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; +import java.util.List; + import org.lwjgl.opengl.GL20; -import com.jozufozu.flywheel.backend.core.BasicProgram; -import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode; +import com.jozufozu.flywheel.backend.core.shader.ProgramExtender; +import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.loading.Program; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.vector.Matrix4f; -public class ContraptionProgram extends BasicProgram { +public class ContraptionProgram extends WorldProgram { protected final int uLightBoxSize; protected final int uLightBoxMin; protected final int uModel; protected int uLightVolume; - public ContraptionProgram(Program program, ProgramFogMode.Factory fogFactory) { + public ContraptionProgram(Program program, List fogFactory) { super(program, fogFactory); uLightBoxSize = getUniformLocation("uLightBoxSize"); uLightBoxMin = getUniformLocation("uLightBoxMin"); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index f8a2e942e..8add8c3b1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -16,7 +16,7 @@ import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.WorldContext; -import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram; +import com.jozufozu.flywheel.backend.core.WorldMultiProgram; import com.jozufozu.flywheel.backend.loading.ModelTemplate; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllMovementBehaviours; @@ -71,8 +71,8 @@ public class ContraptionRenderDispatcher { public static final Compartment> CONTRAPTION = new Compartment<>(); private static final ResourceLocation ctxRoot = new ResourceLocation("create", "context/contraption"); - public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); - public static final WorldContext TILES = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new)); + public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new WorldMultiProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); + public static final WorldContext TILES = new WorldContext<>(ctxRoot, new WorldMultiProgram.SpecLoader<>(ContraptionProgram::new)); public static void tick() { if (Minecraft.getInstance().isGamePaused()) return; diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index f42d9431e..4465a05e8 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -5,8 +5,8 @@ import java.util.List; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.RenderWork; -import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.WorldTileRenderer; +import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllFluids; @@ -145,7 +145,7 @@ public class ClientEvents { if (world.isRemote() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) { CreateClient.invalidateRenderers(world); AnimationTickHolder.reset(); - WorldTileRenderer renderer = Backend.tileRenderer.get(world); + WorldTileRenderer renderer = Backend.tileRenderer.get(world); renderer.invalidate(); ((ClientWorld) world).loadedTileEntityList.forEach(renderer::add); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/flywheel/FogColorTrackerMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/FogColorTrackerMixin.java index 87682d8f4..508caedc2 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/flywheel/FogColorTrackerMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/FogColorTrackerMixin.java @@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.jozufozu.flywheel.backend.gl.GlFog; +import com.jozufozu.flywheel.backend.core.shader.GlFog; import com.mojang.blaze3d.platform.GlStateManager; @Mixin(GlStateManager.class) diff --git a/src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileWorldHookMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileWorldHookMixin.java index fdf4a4705..246127c0a 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileWorldHookMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/flywheel/TileWorldHookMixin.java @@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.core.BasicProgram; import com.jozufozu.flywheel.backend.core.WorldTileRenderer; +import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -47,7 +47,7 @@ public class TileWorldHookMixin { @Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities") private void onChunkUnload(CallbackInfo ci) { if (isRemote) { - WorldTileRenderer kineticRenderer = Backend.tileRenderer.get(self); + WorldTileRenderer kineticRenderer = Backend.tileRenderer.get(self); for (TileEntity tile : tileEntitiesToBeRemoved) { kineticRenderer.remove(tile); } diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index a08553039..c6d50eebd 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -3,7 +3,7 @@ package com.simibubi.create.foundation.render; import static com.jozufozu.flywheel.backend.Backend.register; import com.jozufozu.flywheel.Flywheel; -import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; import com.simibubi.create.Create; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java index 5771e712e..0f13aa9e8 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java @@ -2,7 +2,7 @@ package com.simibubi.create.foundation.render.effects; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.gl.shader.SingleProgram; +import com.jozufozu.flywheel.backend.core.shader.SingleProgram; import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import com.simibubi.create.foundation.render.AllProgramSpecs; From 947496995a45c3079f9795eda11a0b4a4dc80a55 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Thu, 20 May 2021 00:45:51 -0400 Subject: [PATCH 072/198] Make schematics write tags for filtering behaviour --- .../block/SchematicannonTileEntity.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index 8a06c2464..e3387556e 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -28,6 +28,8 @@ import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode; import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; +import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.NBTProcessors; @@ -471,13 +473,21 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC launchBlock(target, icon, blockState, null); } else { CompoundNBT data = null; - if (AllBlockTags.SAFE_NBT.matches(blockState)) { - TileEntity tile = blockReader.getTileEntity(target); - if (tile != null) { + TileEntity tile = blockReader.getTileEntity(target); + if (tile != null) { + if (AllBlockTags.SAFE_NBT.matches(blockState)) { data = tile.write(new CompoundNBT()); data = NBTProcessors.process(tile, data, true); + } else if (tile instanceof SmartTileEntity) { + FilteringBehaviour filtering = ((SmartTileEntity)tile).getBehaviour(FilteringBehaviour.TYPE); + if (filtering != null) { + data = new CompoundNBT(); + filtering.write(data, false); + data = NBTProcessors.process(tile, data, true); + } } } + launchBlock(target, icon, blockState, data); } From 8edfa733520deaea6bfa62e31382b83fe160af4f Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Thu, 20 May 2021 13:50:42 -0400 Subject: [PATCH 073/198] Hack to prevent rails placed by cannon from updating --- .../foundation/utility/BlockHelper.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java index a70af7ca1..321c39aa3 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java @@ -1,9 +1,18 @@ package com.simibubi.create.foundation.utility; +import java.util.ArrayList; +import java.util.List; import java.util.function.Consumer; import javax.annotation.Nullable; +import net.minecraft.block.AbstractRailBlock; +import net.minecraft.block.RailBlock; + +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkSection; +import net.minecraftforge.common.util.BlockSnapshot; + import org.apache.commons.lang3.mutable.MutableInt; import com.simibubi.create.AllBlocks; @@ -234,6 +243,23 @@ public class BlockHelper { .isEmpty(); } + private static void placeRailWithoutUpdate(World world, BlockState state, BlockPos target) { + int i = target.getX() & 15; + int j = target.getY(); + int k = target.getZ() & 15; + Chunk chunk = world.getChunkAt(target); + ChunkSection chunksection = chunk.getSections()[j >> 4]; + if (chunksection == Chunk.EMPTY_SECTION) { + chunksection = new ChunkSection(j >> 4 << 4); + chunk.getSections()[j >> 4] = chunksection; + } + BlockState old = chunksection.setBlockState(i, j & 15, k, state); + chunk.markDirty(); + world.markAndNotifyBlock(target, chunk, old, state, 82, 512); + + world.setBlockState(target, state, 82); + } + public static void placeSchematicBlock(World world, BlockState state, BlockPos target, ItemStack stack, @Nullable CompoundNBT data) { // Piston @@ -268,7 +294,13 @@ public class BlockHelper { Block.spawnDrops(state, world, target); return; } - world.setBlockState(target, state, 18); + + if (BlockTags.RAILS.contains(state.getBlock())) { + placeRailWithoutUpdate(world, state, target); + } else { + world.setBlockState(target, state, 18); + } + if (data != null) { TileEntity tile = world.getTileEntity(target); if (tile != null) { From badec3aad0f1f6bfe520ab509b385d76e5228d72 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Thu, 20 May 2021 16:31:04 -0400 Subject: [PATCH 074/198] Add proper rotation and mirroring to CartAssemblerBlock --- .../mounted/CartAssemblerBlock.java | 59 ++++++++++++++----- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java index 09c2653a2..1da586170 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java @@ -54,6 +54,7 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.Hand; +import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; @@ -492,29 +493,55 @@ public class CartAssemblerBlock extends AbstractRailBlock public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } - + @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { World world = context.getWorld(); if (world.isRemote) return ActionResultType.SUCCESS; BlockPos pos = context.getPos(); - BlockState newState = state.with(RAIL_SHAPE, - state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH); - if (state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL - || state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS) { - newState = newState.with(RAIL_TYPE, AllBlocks.CONTROLLER_RAIL.get() - .rotate(AllBlocks.CONTROLLER_RAIL.getDefaultState() - .with(ControllerRailBlock.SHAPE, state.get(RAIL_SHAPE)) - .with(ControllerRailBlock.BACKWARDS, - state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS), - Rotation.CLOCKWISE_90) - .get(ControllerRailBlock.BACKWARDS) ? CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS - : CartAssembleRailType.CONTROLLER_RAIL); - } - context.getWorld() - .setBlockState(pos, newState, 3); + world.setBlockState(pos, rotate(state, Rotation.CLOCKWISE_90), 3); world.notifyNeighborsOfStateChange(pos.down(), this); return ActionResultType.SUCCESS; } + + @Override + public BlockState rotate(BlockState state, Rotation rotation) { + if (rotation == Rotation.NONE) + return state; + + boolean is_controller_rail_backwards = state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS; + boolean is_controller_rail = state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL || is_controller_rail_backwards; + BlockState base = AllBlocks.CONTROLLER_RAIL.getDefaultState() + .with(ControllerRailBlock.SHAPE, state.get(RAIL_SHAPE)) + .with(ControllerRailBlock.BACKWARDS, is_controller_rail_backwards) + .rotate(rotation); + if (is_controller_rail) { + state = state.with(RAIL_TYPE, + base.get(ControllerRailBlock.BACKWARDS) ? CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS : + CartAssembleRailType.CONTROLLER_RAIL + ); + } + return state.with(RAIL_SHAPE, base.get(ControllerRailBlock.SHAPE)); + } + + @Override + public BlockState mirror(BlockState state, Mirror mirror) { + if (mirror == Mirror.NONE) + return state; + + boolean is_controller_rail_backwards = state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS; + boolean is_controller_rail = state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL || is_controller_rail_backwards; + BlockState base = AllBlocks.CONTROLLER_RAIL.getDefaultState() + .with(ControllerRailBlock.SHAPE, state.get(RAIL_SHAPE)) + .with(ControllerRailBlock.BACKWARDS, is_controller_rail_backwards) + .mirror(mirror); + if (is_controller_rail) { + state = state.with(RAIL_TYPE, + base.get(ControllerRailBlock.BACKWARDS) ? CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS : + CartAssembleRailType.CONTROLLER_RAIL + ); + } + return state.with(RAIL_SHAPE, base.get(ControllerRailBlock.SHAPE)); + } } From d58897d59abac7e264e779062e080055a58e5c2b Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 20 May 2021 17:59:26 -0700 Subject: [PATCH 075/198] Nothing in particular --- ...MultiProgram.java => FogMultiProgram.java} | 20 +++---------------- .../flywheel/backend/core/WorldContext.java | 4 ++-- .../core/shader/ExtensibleGlProgram.java | 6 +++++- .../backend/gl/shader/ShaderSpecLoader.java | 6 ------ .../render/ContraptionRenderDispatcher.java | 6 +++--- 5 files changed, 13 insertions(+), 29 deletions(-) rename src/main/java/com/jozufozu/flywheel/backend/core/{WorldMultiProgram.java => FogMultiProgram.java} (71%) diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldMultiProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java similarity index 71% rename from src/main/java/com/jozufozu/flywheel/backend/core/WorldMultiProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java index dfc822a9a..babe5d039 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldMultiProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java @@ -1,9 +1,7 @@ package com.jozufozu.flywheel.backend.core; -import java.util.ArrayList; import java.util.Collections; import java.util.EnumMap; -import java.util.List; import java.util.Map; import com.jozufozu.flywheel.backend.ShaderContext; @@ -17,14 +15,12 @@ import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.loading.Program; -public class WorldMultiProgram

implements IMultiProgram

{ +public class FogMultiProgram

implements IMultiProgram

{ private final Map programs; - private final List

debugPrograms; - public WorldMultiProgram(Map programs, List

debugPrograms) { + public FogMultiProgram(Map programs) { this.programs = programs; - this.debugPrograms = debugPrograms; } @Override @@ -47,16 +43,6 @@ public class WorldMultiProgram

implements IMultiProgram

@Override public IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { - List

debugModes = new ArrayList<>(2); - - String[] modes = new String[]{"NORMAL_DEBUG", "RAINBOW_DEBUG"}; - - for (String mode : modes) { - Program builder = ctx.loadProgram(loader, spec, Collections.singletonList(mode)); - - debugModes.add(factory.create(builder, null)); - } - Map programs = new EnumMap<>(GlFogMode.class); for (GlFogMode fogMode : GlFogMode.values()) { @@ -65,7 +51,7 @@ public class WorldMultiProgram

implements IMultiProgram

programs.put(fogMode, factory.create(builder, Collections.singletonList(fogMode))); } - return new WorldMultiProgram<>(programs, debugModes); + return new FogMultiProgram<>(programs); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index a68515382..0bf84e0c9 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -32,8 +32,8 @@ public class WorldContext

extends ShaderContext

{ private static final String declaration = "#flwbuiltins"; private static final Pattern builtinPattern = Pattern.compile(declaration); - public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new WorldMultiProgram.SpecLoader<>(WorldProgram::new)); - public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new WorldMultiProgram.SpecLoader<>(CrumblingProgram::new)); + public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new FogMultiProgram.SpecLoader<>(WorldProgram::new)); + public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new FogMultiProgram.SpecLoader<>(CrumblingProgram::new)); protected ProgramTemplate template; protected final ResourceLocation name; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java index f2e6423a0..701122ea6 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java @@ -57,6 +57,10 @@ public class ExtensibleGlProgram extends GlProgram { public interface Factory

{ @Nonnull - P create(Program program, @Nullable List fogFactory); + P create(Program program, @Nullable List extensions); + + default P create(Program program) { + return create(program, null); + } } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java index 1fafd1346..51ed1d8c1 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java @@ -6,11 +6,5 @@ import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; public interface ShaderSpecLoader

{ - /** - * @param loader - * @param ctx - * @param spec - * @return - */ IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 8add8c3b1..5eb5331f7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -15,8 +15,8 @@ import java.util.stream.Stream; import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.core.FogMultiProgram; import com.jozufozu.flywheel.backend.core.WorldContext; -import com.jozufozu.flywheel.backend.core.WorldMultiProgram; import com.jozufozu.flywheel.backend.loading.ModelTemplate; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllMovementBehaviours; @@ -71,8 +71,8 @@ public class ContraptionRenderDispatcher { public static final Compartment> CONTRAPTION = new Compartment<>(); private static final ResourceLocation ctxRoot = new ResourceLocation("create", "context/contraption"); - public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new WorldMultiProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); - public static final WorldContext TILES = new WorldContext<>(ctxRoot, new WorldMultiProgram.SpecLoader<>(ContraptionProgram::new)); + public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new FogMultiProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); + public static final WorldContext TILES = new WorldContext<>(ctxRoot, new FogMultiProgram.SpecLoader<>(ContraptionProgram::new)); public static void tick() { if (Minecraft.getInstance().isGamePaused()) return; From 305b16fea9201ef49c72d569da601ec15f209ae5 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Thu, 20 May 2021 22:53:08 -0400 Subject: [PATCH 076/198] Store Schematicannon options in block item as NBT --- src/generated/resources/.cache/cache | 30 +++++++++---------- .../data/create/advancements/aesthetics.json | 4 +-- .../loot_tables/blocks/schematicannon.json | 13 ++++++++ .../java/com/simibubi/create/AllBlocks.java | 10 +++++++ 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 7f62cb3f8..2bff1a7b2 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -409,19 +409,19 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json a6d814f94926d88764c38862cc4ece9c367e023b assets/create/lang/en_ud.json d1838140c8383ee4537db90eb8f657d0c268fe91 assets/create/lang/en_us.json -9d6f26ca7b59d3707ce996e513358cc9b873cad1 assets/create/lang/unfinished/de_de.json -7fafb7565349aa52f4ccb829d4886a179eb547dc assets/create/lang/unfinished/es_es.json -822b912d290d40c5f02011393af44bf37684f9b4 assets/create/lang/unfinished/es_mx.json -502d761465a0de7aeb15acec4147b8ec8bee92cf assets/create/lang/unfinished/fr_fr.json -dac15c17578fb37bbdb874cee5a0a078110b7481 assets/create/lang/unfinished/it_it.json -fd270c9c8bc46d4df21aa04ecc7bf059011e4b3e assets/create/lang/unfinished/ja_jp.json -a5b002e047a2f509a8d35b9e638627f970b4810e assets/create/lang/unfinished/ko_kr.json -50f65aaba8c4fec5404ab1fc40f74b4970a55edd assets/create/lang/unfinished/nl_nl.json -ff61e567f15ded6ba127522af03860232069cdd2 assets/create/lang/unfinished/pl_pl.json -a7a28fb3896bc38e00f746e650433160f5b53c90 assets/create/lang/unfinished/pt_br.json -ffa1901b392719634403048419d29b268704bd10 assets/create/lang/unfinished/ru_ru.json -38b843c5232167876b3678328b47ec95f30cf69f assets/create/lang/unfinished/zh_cn.json -b806d1e6fe9ebee27f417a3c4d6c818124ee4cde assets/create/lang/unfinished/zh_tw.json +4fcda300efe5a2ad8695b5ae3f24a54ea109a954 assets/create/lang/unfinished/de_de.json +6a1dde57b2224d4b0287ebc705d6a75d329b5e1f assets/create/lang/unfinished/es_es.json +93ee0e30a56b405a9e766d353c36276e36a84b5c assets/create/lang/unfinished/es_mx.json +49a691320c73e09f921cd0ea97398126231e99fa assets/create/lang/unfinished/fr_fr.json +cf14b3828b6c11013f606f277d88fb63245bb2a8 assets/create/lang/unfinished/it_it.json +73c1c1489833cbcb28bb1ce90541c8c8bdf329c0 assets/create/lang/unfinished/ja_jp.json +924303b9bcf56aedbbfc46108655f71324308e12 assets/create/lang/unfinished/ko_kr.json +079aea6843e756efbfca0976983be1957863717c assets/create/lang/unfinished/nl_nl.json +b7bab15167400ee48a9728f81446e572c494fd8d assets/create/lang/unfinished/pl_pl.json +07e84cc3eee3faa1ab3d26e0c85c7f09c8573368 assets/create/lang/unfinished/pt_br.json +6ffb0cf20d712aee23a42a9ec440dd7dc92293d6 assets/create/lang/unfinished/ru_ru.json +0ae98a18e59f478da41d8c5d832737b65f6a8c8a assets/create/lang/unfinished/zh_cn.json +4c96e5a76e72368a59190b7588d389fdd2cc75e1 assets/create/lang/unfinished/zh_tw.json 487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json 3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json @@ -1652,7 +1652,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json 096382a4c025b5ffdde9c496ee9da0d5345fbe17 assets/create/sounds.json -0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json +5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json 187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json 0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json 83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json @@ -2726,7 +2726,7 @@ cecaac07bd275bb1ae9e302f0bf44b581e74105d data/create/loot_tables/blocks/rope_pul aa6af37356d65105efab2503ffe75f778cfe873b data/create/loot_tables/blocks/rotation_speed_controller.json 30de11bec82606fead9d6bff7bba0232e97f1039 data/create/loot_tables/blocks/sail_frame.json 069701cb804b6522c18624a0d4f3f949ff8b0281 data/create/loot_tables/blocks/schematic_table.json -c4a89145334addfd0dd1fedf7fa75ba07a7d3490 data/create/loot_tables/blocks/schematicannon.json +a2b172dc749176d4df34729007019605fc6dd150 data/create/loot_tables/blocks/schematicannon.json af1bbbb8236b4ab05a6a8edc6db960bc758cbdf3 data/create/loot_tables/blocks/scoria.json bb670ac5dd2fa4c743bc268cd0547926eb6cdb68 data/create/loot_tables/blocks/scoria_bricks.json a7217ea301a282d0ef52f2d8c06dd8683398408d data/create/loot_tables/blocks/scoria_bricks_slab.json diff --git a/src/generated/resources/data/create/advancements/aesthetics.json b/src/generated/resources/data/create/advancements/aesthetics.json index d723cbe38..59a86f429 100644 --- a/src/generated/resources/data/create/advancements/aesthetics.json +++ b/src/generated/resources/data/create/advancements/aesthetics.json @@ -28,8 +28,8 @@ "trigger": "create:bracket_apply", "conditions": { "accepted_entries": [ - "create:cogwheel", - "create:large_cogwheel" + "create:large_cogwheel", + "create:cogwheel" ] } }, diff --git a/src/generated/resources/data/create/loot_tables/blocks/schematicannon.json b/src/generated/resources/data/create/loot_tables/blocks/schematicannon.json index 255327042..16d2e3ed1 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/schematicannon.json +++ b/src/generated/resources/data/create/loot_tables/blocks/schematicannon.json @@ -6,6 +6,19 @@ "entries": [ { "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:copy_nbt", + "source": "block_entity", + "ops": [ + { + "source": "Options", + "target": "BlockEntityTag.Options", + "op": "replace" + } + ] + } + ], "name": "create:schematicannon" } ], diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 472b8e8a2..5ea72cd61 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -215,6 +215,16 @@ public class AllBlocks { REGISTRATE.block("schematicannon", SchematicannonBlock::new) .initialProperties(() -> Blocks.DISPENSER) .blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), AssetLookup.partialBaseModel(ctx, prov))) + .loot((lt, block) -> { + Builder builder = LootTable.builder(); + IBuilder survivesExplosion = SurvivesExplosion.builder(); + lt.registerLootTable(block, builder.addLootPool(LootPool.builder() + .acceptCondition(survivesExplosion) + .rolls(ConstantRange.of(1)) + .addEntry(ItemLootEntry.builder(AllBlocks.SCHEMATICANNON.get().asItem()) + .acceptFunction(CopyNbt.func_215881_a(CopyNbt.Source.BLOCK_ENTITY) + .func_216056_a("Options", "BlockEntityTag.Options"))))); + }) .item() .transform(customItemModel()) .register(); From d0040260d7d7677d72b00f95a4ad549489e8c451 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Fri, 21 May 2021 00:46:35 -0400 Subject: [PATCH 077/198] Assemble gantry carriage when shaft is extended --- .../relays/advanced/GantryShaftBlock.java | 13 ++++++++--- .../advanced/GantryShaftTileEntity.java | 23 +++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java index 9592b9d02..2750d05ab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java @@ -98,7 +98,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { return state; boolean connect = AllBlocks.GANTRY_SHAFT.has(neighbour) && neighbour.get(FACING) == facing; - Part part = state.get(PART); + Part part = state.get(PART), prevPart = part; if (direction.getAxisDirection() == facing.getAxisDirection()) { if (connect) { if (part == Part.END) @@ -125,6 +125,13 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } } + if (!world.isRemote() && part == Part.MIDDLE && prevPart != Part.MIDDLE) { + TileEntity te = world.getTileEntity(pos); + if (te instanceof GantryShaftTileEntity) { + ((GantryShaftTileEntity)te).checkAttachedCarriageBlocks(true); + } + } + return state.with(PART, part); } @@ -260,7 +267,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { return super.areStatesKineticallyEquivalent(oldState, newState) && oldState.get(POWERED) == newState.get(POWERED); } - + @Override public float getParticleTargetRadius() { return .35f; @@ -270,7 +277,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { public float getParticleInitialRadius() { return .25f; } - + @Override public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java index 681a01269..3b15e5992 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java @@ -19,15 +19,12 @@ public class GantryShaftTileEntity extends KineticTileEntity { super(typeIn); } - @Override - public void onSpeedChanged(float previousSpeed) { - super.onSpeedChanged(previousSpeed); - - if (!canAssembleOn()) + public void checkAttachedCarriageBlocks(boolean willBeMiddle) { + if (!canAssembleOn(willBeMiddle)) return; for (Direction d : Iterate.directions) { if (d.getAxis() == getBlockState().get(GantryShaftBlock.FACING) - .getAxis()) + .getAxis()) continue; BlockPos offset = pos.offset(d); BlockState pinionState = world.getBlockState(offset); @@ -39,7 +36,12 @@ public class GantryShaftTileEntity extends KineticTileEntity { if (tileEntity instanceof GantryCarriageTileEntity) ((GantryCarriageTileEntity) tileEntity).queueAssembly(); } + } + @Override + public void onSpeedChanged(float previousSpeed) { + super.onSpeedChanged(previousSpeed); + checkAttachedCarriageBlocks(false); } @Override @@ -73,6 +75,10 @@ public class GantryShaftTileEntity extends KineticTileEntity { } public boolean canAssembleOn() { + return canAssembleOn(false); + } + + public boolean canAssembleOn(boolean willBeMiddle) { BlockState blockState = getBlockState(); if (!AllBlocks.GANTRY_SHAFT.has(blockState)) return false; @@ -80,6 +86,9 @@ public class GantryShaftTileEntity extends KineticTileEntity { return false; float speed = getPinionMovementSpeed(); + if (willBeMiddle) + return speed != 0; + switch (blockState.get(GantryShaftBlock.PART)) { case END: return speed < 0; @@ -99,7 +108,7 @@ public class GantryShaftTileEntity extends KineticTileEntity { return 0; return MathHelper.clamp(-getSpeed() / 512f, -.49f, .49f); } - + @Override protected boolean isNoisy() { return false; From c7d3166fd1641b97a166198eb9edc827fdc88eff Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Fri, 21 May 2021 13:18:15 -0400 Subject: [PATCH 078/198] Clean up gantry fix --- .../relays/advanced/GantryShaftBlock.java | 21 ++++++++++++------- .../advanced/GantryShaftTileEntity.java | 13 +++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java index 2750d05ab..e468327dd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java @@ -125,13 +125,6 @@ public class GantryShaftBlock extends DirectionalKineticBlock { } } - if (!world.isRemote() && part == Part.MIDDLE && prevPart != Part.MIDDLE) { - TileEntity te = world.getTileEntity(pos); - if (te instanceof GantryShaftTileEntity) { - ((GantryShaftTileEntity)te).checkAttachedCarriageBlocks(true); - } - } - return state.with(PART, part); } @@ -176,6 +169,20 @@ public class GantryShaftBlock extends DirectionalKineticBlock { return onWrenched; } + @Override + public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + super.onBlockAdded(state, worldIn, pos, oldState, isMoving); + + if (!worldIn.isRemote() && oldState.getBlock().is(AllBlocks.GANTRY_SHAFT.get())) { + Part oldPart = oldState.get(PART), part = state.get(PART); + if ((oldPart != Part.MIDDLE && part == Part.MIDDLE) || (oldPart == Part.SINGLE && part != Part.SINGLE)) { + TileEntity te = worldIn.getTileEntity(pos); + if (te instanceof GantryShaftTileEntity) + ((GantryShaftTileEntity) te).checkAttachedCarriageBlocks(); + } + } + } + @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java index 3b15e5992..2f9fe658a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftTileEntity.java @@ -19,8 +19,8 @@ public class GantryShaftTileEntity extends KineticTileEntity { super(typeIn); } - public void checkAttachedCarriageBlocks(boolean willBeMiddle) { - if (!canAssembleOn(willBeMiddle)) + public void checkAttachedCarriageBlocks() { + if (!canAssembleOn()) return; for (Direction d : Iterate.directions) { if (d.getAxis() == getBlockState().get(GantryShaftBlock.FACING) @@ -41,7 +41,7 @@ public class GantryShaftTileEntity extends KineticTileEntity { @Override public void onSpeedChanged(float previousSpeed) { super.onSpeedChanged(previousSpeed); - checkAttachedCarriageBlocks(false); + checkAttachedCarriageBlocks(); } @Override @@ -75,10 +75,6 @@ public class GantryShaftTileEntity extends KineticTileEntity { } public boolean canAssembleOn() { - return canAssembleOn(false); - } - - public boolean canAssembleOn(boolean willBeMiddle) { BlockState blockState = getBlockState(); if (!AllBlocks.GANTRY_SHAFT.has(blockState)) return false; @@ -86,9 +82,6 @@ public class GantryShaftTileEntity extends KineticTileEntity { return false; float speed = getPinionMovementSpeed(); - if (willBeMiddle) - return speed != 0; - switch (blockState.get(GantryShaftBlock.PART)) { case END: return speed < 0; From e1f1b1af9fd064a9297af793881575e99fbd0206 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Fri, 21 May 2021 13:21:05 -0400 Subject: [PATCH 079/198] Clean up gantry fix --- .../content/contraptions/relays/advanced/GantryShaftBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java index e468327dd..19a563c35 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/GantryShaftBlock.java @@ -98,7 +98,7 @@ public class GantryShaftBlock extends DirectionalKineticBlock { return state; boolean connect = AllBlocks.GANTRY_SHAFT.has(neighbour) && neighbour.get(FACING) == facing; - Part part = state.get(PART), prevPart = part; + Part part = state.get(PART); if (direction.getAxisDirection() == facing.getAxisDirection()) { if (connect) { if (part == Part.END) From ff5984a48e87bc570736e1e0eeb8aec967e970b0 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Fri, 21 May 2021 13:38:13 -0400 Subject: [PATCH 080/198] Prevent rail fix from allowing floating rails --- .../java/com/simibubi/create/foundation/utility/BlockHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java index 321c39aa3..85d6baf8b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java @@ -258,6 +258,7 @@ public class BlockHelper { world.markAndNotifyBlock(target, chunk, old, state, 82, 512); world.setBlockState(target, state, 82); + world.neighborChanged(target, world.getBlockState(target.down()).getBlock(), target.down()); } public static void placeSchematicBlock(World world, BlockState state, BlockPos target, ItemStack stack, From 68b3ba7215dde3405592c602e971a689abcae403 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Fri, 21 May 2021 16:57:01 -0400 Subject: [PATCH 081/198] Allow Schematicannon to defer blocks to print at end --- .../block/SchematicannonTileEntity.java | 94 +++++++++++++------ .../foundation/utility/BlockHelper.java | 2 +- 2 files changed, 68 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index e3387556e..289408314 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -34,6 +34,8 @@ import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.NBTProcessors; +import net.minecraft.block.AbstractRailBlock; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.PistonHeadBlock; @@ -81,6 +83,10 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC STOPPED, PAUSED, RUNNING; } + public enum PrintStage { + BLOCKS, DEFERRED_BLOCKS, ENTITIES + } + // Inventory public SchematicannonInventory inventory; @@ -101,12 +107,14 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC private int skipsLeft; private boolean blockSkipped; private int printingEntityIndex; + private PrintStage printStage; public BlockPos target; public BlockPos previousTarget; public LinkedHashSet> attachedInventories; public List flyingBlocks; public MaterialChecklist checklist; + public List deferredBlocks; // Gui information public float fuelLevel; @@ -144,7 +152,9 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC inventory = new SchematicannonInventory(this); statusMsg = "idle"; state = State.STOPPED; - printingEntityIndex = -1; + printingEntityIndex = 0; + printStage = PrintStage.BLOCKS; + deferredBlocks = new LinkedList<>(); replaceMode = 2; checklist = new MaterialChecklist(); } @@ -200,8 +210,14 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC replaceTileEntities = options.getBoolean("ReplaceTileEntities"); // Printer & Flying Blocks + if (compound.contains("PrintStage")) + printStage = PrintStage.valueOf(compound.getString("PrintStage")); if (compound.contains("Target")) target = NBTUtil.readBlockPos(compound.getCompound("Target")); + if (compound.contains("DeferredBlocks")) + compound.getList("DeferredBlocks", 10).stream() + .map(p -> NBTUtil.readBlockPos((CompoundNBT) p)) + .collect(Collectors.toCollection(() -> deferredBlocks)); if (compound.contains("FlyingBlocks")) readFlyingBlocks(compound); @@ -275,12 +291,20 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC compound.put("Options", options); // Printer & Flying Blocks + compound.putString("PrintStage", printStage.name()); + if (target != null) compound.put("Target", NBTUtil.writeBlockPos(target)); - ListNBT tagBlocks = new ListNBT(); + + ListNBT tagDeferredBlocks = new ListNBT(); + for (BlockPos p : deferredBlocks) + tagDeferredBlocks.add(NBTUtil.writeBlockPos(p)); + compound.put("DeferredBlocks", tagDeferredBlocks); + + ListNBT tagFlyingBlocks = new ListNBT(); for (LaunchedItem b : flyingBlocks) - tagBlocks.add(b.serializeNBT()); - compound.put("FlyingBlocks", tagBlocks); + tagFlyingBlocks.add(b.serializeNBT()); + compound.put("FlyingBlocks", tagFlyingBlocks); super.write(compound, clientPacket); } @@ -390,7 +414,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC target = schematicAnchor.add(currentPos); } - boolean entityMode = printingEntityIndex >= 0; + boolean entityMode = printStage == PrintStage.ENTITIES; // Check block if (!getWorld().isAreaLoaded(target, 0)) { @@ -573,7 +597,9 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC schematicLoaded = true; state = State.PAUSED; statusMsg = "ready"; - printingEntityIndex = -1; + printingEntityIndex = 0; + printStage = PrintStage.BLOCKS; + deferredBlocks.clear(); updateChecklist(); sendUpdate = true; blocksToPlace += blocksPlaced; @@ -659,22 +685,33 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC protected void advanceCurrentPos() { List entities = blockReader.getEntities() .collect(Collectors.toList()); - if (printingEntityIndex != -1) { - printingEntityIndex++; - // End of entities reached - if (printingEntityIndex >= entities.size()) { - finishedPrinting(); - return; + if (printStage == PrintStage.BLOCKS) { + MutableBoundingBox bounds = blockReader.getBounds(); + while (tryAdvanceCurrentPos(bounds, entities)) { + deferredBlocks.add(currentPos); } - - currentPos = entities.get(printingEntityIndex) - .getBlockPos() - .subtract(schematicAnchor); - return; } - MutableBoundingBox bounds = blockReader.getBounds(); + if (printStage == PrintStage.DEFERRED_BLOCKS) { + if (deferredBlocks.isEmpty()) { + printStage = PrintStage.ENTITIES; + } else { + currentPos = deferredBlocks.remove(0); + } + } + + if (printStage == PrintStage.ENTITIES) { + if (printingEntityIndex < entities.size()) { + currentPos = entities.get(printingEntityIndex).getBlockPos().subtract(schematicAnchor); + printingEntityIndex++; + } else { + finishedPrinting(); + } + } + } + + protected boolean tryAdvanceCurrentPos(MutableBoundingBox bounds, List entities) { currentPos = currentPos.offset(Direction.EAST); BlockPos posInBounds = currentPos.add(-bounds.minX, -bounds.minY, -bounds.minZ); @@ -685,15 +722,16 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC // End of blocks reached if (currentPos.getY() > bounds.getYSize()) { - printingEntityIndex = 0; - if (entities.isEmpty()) { - finishedPrinting(); - return; - } - currentPos = entities.get(0) - .getBlockPos() - .subtract(schematicAnchor); + printStage = PrintStage.DEFERRED_BLOCKS; + return false; } + + return shouldDeferBlock(blockReader.getBlockState(schematicAnchor.add(currentPos))); + } + + public static boolean shouldDeferBlock(BlockState state) { + Block block = state.getBlock(); + return block instanceof AbstractRailBlock || block.is(AllBlocks.GANTRY_CARRIAGE.get()); } public void finishedPrinting() { @@ -715,10 +753,12 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC blockReader = null; missingItem = null; sendUpdate = true; - printingEntityIndex = -1; + printingEntityIndex = 0; + printStage = PrintStage.BLOCKS; schematicProgress = 0; blocksPlaced = 0; blocksToPlace = 0; + deferredBlocks.clear(); } protected boolean shouldPlace(BlockPos pos, BlockState state) { diff --git a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java index 85d6baf8b..cc76d5dbe 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java @@ -296,7 +296,7 @@ public class BlockHelper { return; } - if (BlockTags.RAILS.contains(state.getBlock())) { + if (state.getBlock() instanceof AbstractRailBlock) { placeRailWithoutUpdate(world, state, target); } else { world.setBlockState(target, state, 18); From c2cc12423920e06761038a6f644695c562252850 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Fri, 21 May 2021 20:33:28 -0400 Subject: [PATCH 082/198] Better support for partially safe NBT writing --- .../block/mechanicalArm/ArmTileEntity.java | 46 +++++++++++-------- .../block/SchematicannonTileEntity.java | 12 ++--- .../tileEntity/SmartTileEntity.java | 12 ++++- .../tileEntity/TileEntityBehaviour.java | 3 +- .../filtering/FilteringBehaviour.java | 3 ++ .../filtering/SidedFilteringBehaviour.java | 3 ++ .../behaviour/linked/LinkBehaviour.java | 3 ++ .../scrollvalue/ScrollValueBehaviour.java | 11 +++-- .../behaviour/simple/DeferralBehaviour.java | 5 +- .../foundation/utility/IPartialSafeNBT.java | 7 +++ 10 files changed, 73 insertions(+), 32 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java index ae0a584e3..0229882b3 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java @@ -122,14 +122,14 @@ public class ArmTileEntity extends KineticTileEntity { } if (world.isRemote) return; - + if (phase == Phase.MOVE_TO_INPUT) collectItem(); else if (phase == Phase.MOVE_TO_OUTPUT) depositItem(); else if (phase == Phase.SEARCH_INPUTS || phase == Phase.DANCING) searchForItem(); - + if (targetReached) lazyTick(); } @@ -142,7 +142,7 @@ public class ArmTileEntity extends KineticTileEntity { return; if (chasedPointProgress < .5f) return; - if (phase == Phase.SEARCH_INPUTS || phase == Phase.DANCING) + if (phase == Phase.SEARCH_INPUTS || phase == Phase.DANCING) checkForMusic(); if (phase == Phase.SEARCH_OUTPUTS) searchForDestination(); @@ -175,7 +175,7 @@ public class ArmTileEntity extends KineticTileEntity { } private boolean tickMovementProgress() { - boolean targetReachedPreviously = chasedPointProgress >= 1; + boolean targetReachedPreviously = chasedPointProgress >= 1; chasedPointProgress += Math.min(256, Math.abs(getSpeed())) / 1024f; if (chasedPointProgress > 1) chasedPointProgress = 1; @@ -349,7 +349,7 @@ public class ArmTileEntity extends KineticTileEntity { chasedPointIndex = -1; sendData(); markDirty(); - + if (!prevHeld.isItemEqual(heldItem)) world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, .125f, .5f + Create.random.nextFloat() * .25f); @@ -416,23 +416,26 @@ public class ArmTileEntity extends KineticTileEntity { markDirty(); } + public void writeInteractionPoints(CompoundNBT compound) { + if (updateInteractionPoints) { + compound.put("InteractionPoints", interactionPointTag); + } else { + ListNBT pointsNBT = new ListNBT(); + inputs.stream() + .map(aip -> aip.serialize(pos)) + .forEach(pointsNBT::add); + outputs.stream() + .map(aip -> aip.serialize(pos)) + .forEach(pointsNBT::add); + compound.put("InteractionPoints", pointsNBT); + } + } + @Override public void write(CompoundNBT compound, boolean clientPacket) { super.write(compound, clientPacket); - if (updateInteractionPoints) { - compound.put("InteractionPoints", interactionPointTag); - - } else { - ListNBT pointsNBT = new ListNBT(); - inputs.stream() - .map(aip -> aip.serialize(pos)) - .forEach(pointsNBT::add); - outputs.stream() - .map(aip -> aip.serialize(pos)) - .forEach(pointsNBT::add); - compound.put("InteractionPoints", pointsNBT); - } + writeInteractionPoints(compound); NBTHelper.writeEnum(compound, "Phase", phase); compound.putBoolean("Powered", redstoneLocked); @@ -441,6 +444,13 @@ public class ArmTileEntity extends KineticTileEntity { compound.putFloat("MovementProgress", chasedPointProgress); } + @Override + public void writeSafe(CompoundNBT compound, boolean clientPacket) { + super.writeSafe(compound, clientPacket); + + writeInteractionPoints(compound); + } + @Override protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { int previousIndex = chasedPointIndex; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index 289408314..ef443d62d 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -31,6 +31,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.BlockHelper; +import com.simibubi.create.foundation.utility.IPartialSafeNBT; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.NBTProcessors; @@ -502,13 +503,10 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC if (AllBlockTags.SAFE_NBT.matches(blockState)) { data = tile.write(new CompoundNBT()); data = NBTProcessors.process(tile, data, true); - } else if (tile instanceof SmartTileEntity) { - FilteringBehaviour filtering = ((SmartTileEntity)tile).getBehaviour(FilteringBehaviour.TYPE); - if (filtering != null) { - data = new CompoundNBT(); - filtering.write(data, false); - data = NBTProcessors.process(tile, data, true); - } + } else if (tile instanceof IPartialSafeNBT) { + data = new CompoundNBT(); + ((IPartialSafeNBT) tile).writeSafe(data, false); + data = NBTProcessors.process(tile, data, true); } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java b/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java index a589bc7ca..e036d7dab 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java @@ -8,6 +8,8 @@ import java.util.function.Consumer; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; +import com.simibubi.create.foundation.utility.IPartialSafeNBT; + import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; @@ -16,7 +18,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.items.CapabilityItemHandler; -public abstract class SmartTileEntity extends SyncedTileEntity implements ITickableTileEntity { +public abstract class SmartTileEntity extends SyncedTileEntity implements ITickableTileEntity, IPartialSafeNBT { private final Map, TileEntityBehaviour> behaviours; // Internally maintained to be identical to behaviorMap.values() in order to improve iteration performance. @@ -118,6 +120,14 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka behaviourList.forEach(tb -> tb.write(compound, clientPacket)); } + public void writeSafe(CompoundNBT compound, boolean clientPacket) { + super.write(compound); + behaviourList.forEach(tb -> { + if (tb.isSafeNBT()) + tb.write(compound, clientPacket); + }); + } + @Override public void remove() { forEachBehaviour(TileEntityBehaviour::remove); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java index 925677123..931b5f4bd 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java @@ -42,6 +42,8 @@ public abstract class TileEntityBehaviour { } + public boolean isSafeNBT() { return false; } + public void onBlockChanged(BlockState oldState) { } @@ -94,5 +96,4 @@ public abstract class TileEntityBehaviour { SmartTileEntity ste = (SmartTileEntity) te; return ste.getBehaviour(type); } - } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java index 803476b13..c6b7acebe 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java @@ -57,6 +57,9 @@ public class FilteringBehaviour extends TileEntityBehaviour { fluidFilter = false; } + @Override + public boolean isSafeNBT() { return true; } + @Override public void write(CompoundNBT nbt, boolean clientPacket) { nbt.put("Filter", getFilter().serializeNBT()); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/SidedFilteringBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/SidedFilteringBehaviour.java index 88097a681..9a7f0a490 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/SidedFilteringBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/SidedFilteringBehaviour.java @@ -58,6 +58,9 @@ public class SidedFilteringBehaviour extends FilteringBehaviour { removeFilter(d); } + @Override + public boolean isSafeNBT() { return true; } + @Override public void write(CompoundNBT nbt, boolean clientPacket) { nbt.put("Filters", NBTHelper.writeCompoundList(sidedFilters.entrySet(), entry -> { diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java index 3d708e8f1..27d529ca7 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java @@ -115,6 +115,9 @@ public class LinkBehaviour extends TileEntityBehaviour { getHandler().removeFromNetwork(this); } + @Override + public boolean isSafeNBT() { return true; } + @Override public void write(CompoundNBT nbt, boolean clientPacket) { super.write(nbt, clientPacket); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueBehaviour.java index c67fc80e0..d189a689d 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueBehaviour.java @@ -54,6 +54,9 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { ticksUntilScrollPacket = -1; } + @Override + public boolean isSafeNBT() { return true; } + @Override public void write(CompoundNBT nbt, boolean clientPacket) { nbt.putInt("ScrollValue", value); @@ -95,7 +98,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { clientCallback = valueCallback; return this; } - + public ScrollValueBehaviour withCallback(Consumer valueCallback) { callback = valueCallback; return this; @@ -126,7 +129,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { this.unit = unit; return this; } - + public ScrollValueBehaviour onlyActiveWhen(Supplier condition) { isActive = condition; return this; @@ -168,7 +171,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { public BehaviourType getType() { return TYPE; } - + public boolean isActive() { return isActive.get(); } @@ -182,7 +185,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour { public void setLabel(ITextComponent label) { this.label = label; } - + public static class StepContext { public int currentValue; public boolean forward; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/simple/DeferralBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/simple/DeferralBehaviour.java index 59db72bcf..3f1bb7fd9 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/simple/DeferralBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/simple/DeferralBehaviour.java @@ -20,6 +20,9 @@ public class DeferralBehaviour extends TileEntityBehaviour { this.callback = callback; } + @Override + public boolean isSafeNBT() { return true; } + @Override public void write(CompoundNBT nbt, boolean clientPacket) { nbt.putBoolean("NeedsUpdate", needsUpdate); @@ -38,7 +41,7 @@ public class DeferralBehaviour extends TileEntityBehaviour { if (needsUpdate && callback.get()) needsUpdate = false; } - + public void scheduleUpdate() { needsUpdate = true; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java b/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java new file mode 100644 index 000000000..ae1ca8a9d --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java @@ -0,0 +1,7 @@ +package com.simibubi.create.foundation.utility; + +import net.minecraft.nbt.CompoundNBT; + +public interface IPartialSafeNBT { + public void writeSafe(CompoundNBT compound, boolean clientPacket); +} From 9a935969bba294b1e1c82b564d3e3663d8cf7ccc Mon Sep 17 00:00:00 2001 From: dunois2737 <78353924+dunois2737@users.noreply.github.com> Date: Sat, 22 May 2021 16:06:26 +0900 Subject: [PATCH 083/198] update zh_tw for create 0.3.1 --- .../resources/assets/create/lang/zh_tw.json | 3917 +++++++++-------- 1 file changed, 2125 insertions(+), 1792 deletions(-) diff --git a/src/main/resources/assets/create/lang/zh_tw.json b/src/main/resources/assets/create/lang/zh_tw.json index 023f99011..e9b7b29bf 100644 --- a/src/main/resources/assets/create/lang/zh_tw.json +++ b/src/main/resources/assets/create/lang/zh_tw.json @@ -1,1792 +1,2125 @@ -{ - - "_": "->------------------------] Game Elements [------------------------<-", - - "block.create.acacia_window": "相思木窗戶", - "block.create.acacia_window_pane": "相思木窗戶片", - "block.create.adjustable_chain_gearshift": "可調式鏈式變速箱", - "block.create.adjustable_crate": "可調式板條箱", - "block.create.adjustable_pulse_repeater": "可調式脈衝中繼器", - "block.create.adjustable_repeater": "可調式中繼器", - "block.create.analog_lever": "可調式拉桿", - "block.create.andesite_belt_funnel": "安山岩輸送帶漏斗", - "block.create.andesite_bricks": "安山岩磚", - "block.create.andesite_bricks_slab": "安山岩半磚", - "block.create.andesite_bricks_stairs": "安山岩樓梯", - "block.create.andesite_bricks_wall": "安山岩牆", - "block.create.andesite_casing": "安山岩機殼", - "block.create.andesite_cobblestone": "碎安山岩", - "block.create.andesite_cobblestone_slab": "碎安山岩半磚", - "block.create.andesite_cobblestone_stairs": "碎安山岩樓梯", - "block.create.andesite_cobblestone_wall": "碎安山岩牆", - "block.create.andesite_encased_shaft": "安山傳動軸箱", - "block.create.andesite_funnel": "安山岩漏斗", - "block.create.andesite_pillar": "豎紋安山岩", - "block.create.andesite_tunnel": "安山岩物品隧道", - "block.create.basin": "作業盆", - "block.create.belt": "輸送帶", - "block.create.birch_window": "白樺木窗戶", - "block.create.birch_window_pane": "白樺木窗戶片", - "block.create.black_sail": "黑色風帆", - "block.create.black_seat": "黑色坐墊", - "block.create.black_valve_handle": "黑色閥門開關", - "block.create.blaze_burner": "烈焰使者動力爐", - "block.create.blue_sail": "藍色風帆", - "block.create.blue_seat": "藍色坐墊", - "block.create.blue_valve_handle": "藍色閥門開關", - "block.create.brass_belt_funnel": "黃銅輸送帶漏斗", - "block.create.brass_block": "黃銅磚", - "block.create.brass_casing": "黃銅機殼", - "block.create.brass_encased_shaft": "黃銅傳動軸箱", - "block.create.brass_funnel": "黃銅漏斗", - "block.create.brass_tunnel": "黃銅物品隧道", - "block.create.brown_sail": "棕色風帆", - "block.create.brown_seat": "棕色坐墊", - "block.create.brown_valve_handle": "棕色閥門開關", - "block.create.cart_assembler": "礦車裝修站", - "block.create.chiseled_dark_scoria": "鏨製黑火成岩", - "block.create.chiseled_dolomite": "鏨製白雲石", - "block.create.chiseled_gabbro": "鏨製輝長岩", - "block.create.chiseled_limestone": "鏨製石灰岩", - "block.create.chiseled_scoria": "鏨製火成岩", - "block.create.chiseled_weathered_limestone": "鏨製風化石灰岩", - "block.create.chocolate": "巧克力", - "block.create.chute": "滑道", - "block.create.clockwork_bearing": "時鐘軸承", - "block.create.clutch": "離合器", - "block.create.cogwheel": "齒輪", - "block.create.content_observer": "物品偵測器", - "block.create.controller_rail": "控制鐵軌", - "block.create.copper_block": "銅磚", - "block.create.copper_casing": "銅機殼", - "block.create.copper_ore": "銅礦石", - "block.create.copper_shingles": "塊狀銅磚", - "block.create.copper_tiles": "菱形銅磚", - "block.create.copper_valve_handle": "銅製閥門開關", - "block.create.creative_crate": "創造板條箱", - "block.create.creative_fluid_tank": "創造液體儲存罐", - "block.create.creative_motor": "創造馬達", - "block.create.crimson_window": "赤紅窗戶", - "block.create.crimson_window_pane": "赤紅窗戶片", - "block.create.crushing_wheel": "粉碎輪", - "block.create.crushing_wheel_controller": "粉碎輪控制器", - "block.create.cuckoo_clock": "布穀鳥鐘", - "block.create.cyan_sail": "藍綠色風帆", - "block.create.cyan_seat": "藍綠色坐墊", - "block.create.cyan_valve_handle": "藍綠色閥門開關", - "block.create.dark_oak_window": "黑橡木窗戶", - "block.create.dark_oak_window_pane": "黑橡木窗戶片", - "block.create.dark_scoria": "黑火成岩", - "block.create.dark_scoria_bricks": "黑火成岩磚", - "block.create.dark_scoria_bricks_slab": "黑火成岩半磚", - "block.create.dark_scoria_bricks_stairs": "黑火成岩樓梯", - "block.create.dark_scoria_bricks_wall": "黑火成岩牆", - "block.create.dark_scoria_cobblestone": "黑火成岩碎石", - "block.create.dark_scoria_cobblestone_slab": "黑火成岩碎石半磚", - "block.create.dark_scoria_cobblestone_stairs": "黑火成岩碎石樓梯", - "block.create.dark_scoria_cobblestone_wall": "黑火成岩碎石牆", - "block.create.dark_scoria_pillar": "豎紋黑火成岩", - "block.create.deployer": "機器手", - "block.create.depot": "置物臺", - "block.create.diorite_bricks": "閃長岩磚", - "block.create.diorite_bricks_slab": "閃長岩半磚", - "block.create.diorite_bricks_stairs": "閃長岩樓梯", - "block.create.diorite_bricks_wall": "閃長岩牆", - "block.create.diorite_cobblestone": "碎閃長岩", - "block.create.diorite_cobblestone_slab": "碎閃長岩半磚", - "block.create.diorite_cobblestone_stairs": "碎閃長岩樓梯", - "block.create.diorite_cobblestone_wall": "碎閃長岩牆", - "block.create.diorite_pillar": "豎紋閃長岩", - "block.create.dolomite": "白雲石", - "block.create.dolomite_bricks": "白雲石磚", - "block.create.dolomite_bricks_slab": "白雲石半磚", - "block.create.dolomite_bricks_stairs": "白雲石樓梯", - "block.create.dolomite_bricks_wall": "白雲石牆", - "block.create.dolomite_cobblestone": "碎白雲石", - "block.create.dolomite_cobblestone_slab": "碎白雲石半磚", - "block.create.dolomite_cobblestone_stairs": "碎白雲石樓梯", - "block.create.dolomite_cobblestone_wall": "碎白雲石牆", - "block.create.dolomite_pillar": "豎紋白雲石", - "block.create.encased_chain_drive": "鏈式傳動箱", - "block.create.encased_fan": "鼓風機", - "block.create.encased_fluid_pipe": "液體管道箱", - "block.create.fancy_andesite_bricks": "方紋安山岩磚", - "block.create.fancy_andesite_bricks_slab": "方紋安山岩半磚", - "block.create.fancy_andesite_bricks_stairs": "方紋安山岩樓梯", - "block.create.fancy_andesite_bricks_wall": "方紋安山岩牆", - "block.create.fancy_dark_scoria_bricks": "方紋黑火成岩", - "block.create.fancy_dark_scoria_bricks_slab": "方紋黑火成岩半磚", - "block.create.fancy_dark_scoria_bricks_stairs": "方紋黑火成岩樓梯", - "block.create.fancy_dark_scoria_bricks_wall": "方紋黑火成岩牆", - "block.create.fancy_diorite_bricks": "方紋閃長岩", - "block.create.fancy_diorite_bricks_slab": "方紋閃長岩半磚", - "block.create.fancy_diorite_bricks_stairs": "方紋閃長岩樓梯", - "block.create.fancy_diorite_bricks_wall": "方紋閃長岩牆", - "block.create.fancy_dolomite_bricks": "方紋白雲石", - "block.create.fancy_dolomite_bricks_slab": "方紋白雲石半磚", - "block.create.fancy_dolomite_bricks_stairs": "方紋白雲石樓梯", - "block.create.fancy_dolomite_bricks_wall": "方紋白雲石牆", - "block.create.fancy_gabbro_bricks": "方紋輝長岩", - "block.create.fancy_gabbro_bricks_slab": "方紋輝長岩半磚", - "block.create.fancy_gabbro_bricks_stairs": "方紋輝長岩樓梯", - "block.create.fancy_gabbro_bricks_wall": "方紋輝長岩牆", - "block.create.fancy_granite_bricks": "方紋花崗岩", - "block.create.fancy_granite_bricks_slab": "方紋花崗岩半磚", - "block.create.fancy_granite_bricks_stairs": "方紋花崗岩樓梯", - "block.create.fancy_granite_bricks_wall": "方紋花崗岩牆", - "block.create.fancy_limestone_bricks": "方紋石灰岩", - "block.create.fancy_limestone_bricks_slab": "方紋石灰岩半磚", - "block.create.fancy_limestone_bricks_stairs": "方紋石灰岩樓梯", - "block.create.fancy_limestone_bricks_wall": "方紋石灰岩牆", - "block.create.fancy_scoria_bricks": "方紋火成岩", - "block.create.fancy_scoria_bricks_slab": "方紋火成岩半磚", - "block.create.fancy_scoria_bricks_stairs": "方紋火成岩樓梯", - "block.create.fancy_scoria_bricks_wall": "方紋火成岩牆", - "block.create.fancy_weathered_limestone_bricks": "方紋風化石灰岩", - "block.create.fancy_weathered_limestone_bricks_slab": "方紋風化石灰岩半磚", - "block.create.fancy_weathered_limestone_bricks_stairs": "方紋風化石灰岩樓梯", - "block.create.fancy_weathered_limestone_bricks_wall": "方紋風化石灰岩牆", - "block.create.fluid_pipe": "液體管道", - "block.create.fluid_tank": "液體儲存罐", - "block.create.fluid_valve": "液體閥門", - "block.create.flywheel": "飛輪", - "block.create.framed_glass": "邊框玻璃", - "block.create.framed_glass_pane": "邊框玻璃片", - "block.create.furnace_engine": "熔煉引擎", - "block.create.gabbro": "輝長岩", - "block.create.gabbro_bricks": "輝長岩磚", - "block.create.gabbro_bricks_slab": "輝長岩半磚", - "block.create.gabbro_bricks_stairs": "輝長岩樓梯", - "block.create.gabbro_bricks_wall": "輝長岩牆", - "block.create.gabbro_cobblestone": "碎輝長岩", - "block.create.gabbro_cobblestone_slab": "碎輝長岩半磚", - "block.create.gabbro_cobblestone_stairs": "碎輝長岩樓梯", - "block.create.gabbro_cobblestone_wall": "碎輝長岩牆", - "block.create.gabbro_pillar": "豎紋輝長岩", - "block.create.gearbox": "齒輪箱", - "block.create.gearshift": "變速箱", - "block.create.glass_fluid_pipe": "玻璃液體管道", - "block.create.granite_bricks": "花崗岩", - "block.create.granite_bricks_slab": "花崗岩半磚", - "block.create.granite_bricks_stairs": "花崗岩樓梯", - "block.create.granite_bricks_wall": "花崗岩牆", - "block.create.granite_cobblestone": "碎花崗岩", - "block.create.granite_cobblestone_slab": "碎花崗岩半磚", - "block.create.granite_cobblestone_stairs": "碎花崗岩樓梯", - "block.create.granite_cobblestone_wall": "碎花崗岩牆", - "block.create.granite_pillar": "豎紋花崗岩", - "block.create.gray_sail": "灰色風帆", - "block.create.gray_seat": "灰色坐墊", - "block.create.gray_valve_handle": "灰色閥門開關", - "block.create.green_sail": "綠色風帆", - "block.create.green_seat": "綠色坐墊", - "block.create.green_valve_handle": "綠色閥門開關", - "block.create.hand_crank": "手搖把手", - "block.create.honey": "蜂蜜", - "block.create.horizontal_framed_glass": "豎直邊框玻璃", - "block.create.horizontal_framed_glass_pane": "豎直邊框玻璃片", - "block.create.hose_pulley": "軟管滑輪", - "block.create.item_drain": "分液池", - "block.create.jungle_window": "叢林木窗戶", - "block.create.jungle_window_pane": "叢林木窗戶片", - "block.create.large_cogwheel": "大齒輪", - "block.create.layered_andesite": "疊層安山岩", - "block.create.layered_dark_scoria": "疊層黑火成岩", - "block.create.layered_diorite": "疊層閃長岩", - "block.create.layered_dolomite": "疊層白雲石", - "block.create.layered_gabbro": "疊層輝長岩", - "block.create.layered_granite": "疊層花崗岩", - "block.create.layered_limestone": "疊層石灰岩", - "block.create.layered_scoria": "疊層火成岩", - "block.create.layered_weathered_limestone": "疊層風化石灰岩", - "block.create.light_blue_sail": "淡藍色風帆", - "block.create.light_blue_seat": "淡藍色坐墊", - "block.create.light_blue_valve_handle": "淡藍色閥門開關", - "block.create.light_gray_sail": "淡灰色風帆", - "block.create.light_gray_seat": "淡灰色坐墊", - "block.create.light_gray_valve_handle": "淡灰色閥門開關", - "block.create.lime_sail": "黃綠色風帆", - "block.create.lime_seat": "黃綠色坐墊", - "block.create.lime_valve_handle": "黃綠色閥門開關", - "block.create.limesand": "石灰沙", - "block.create.limestone": "石灰岩", - "block.create.limestone_bricks": "石灰岩", - "block.create.limestone_bricks_slab": "石灰岩半磚", - "block.create.limestone_bricks_stairs": "石灰岩樓梯", - "block.create.limestone_bricks_wall": "石灰岩牆", - "block.create.limestone_cobblestone": "碎石灰岩", - "block.create.limestone_cobblestone_slab": "碎石灰岩半磚", - "block.create.limestone_cobblestone_stairs": "碎石灰岩樓梯", - "block.create.limestone_cobblestone_wall": "碎石灰岩牆", - "block.create.limestone_pillar": "豎紋石灰岩", - "block.create.linear_chassis": "機殼底盤", - "block.create.lit_blaze_burner": "烈焰使者動力爐(已啟動)", - "block.create.magenta_sail": "洋紅色風帆", - "block.create.magenta_seat": "洋紅色坐墊", - "block.create.magenta_valve_handle": "洋紅色閥門開關", - "block.create.mechanical_arm": "機械手臂", - "block.create.mechanical_bearing": "機械軸承", - "block.create.mechanical_crafter": "機械合成器", - "block.create.mechanical_drill": "機械鑽頭", - "block.create.mechanical_harvester": "機械收割機", - "block.create.mechanical_mixer": "機械攪拌器", - "block.create.mechanical_piston": "機械活塞", - "block.create.mechanical_piston_head": "機械活塞頭", - "block.create.mechanical_plough": "機械犁", - "block.create.mechanical_press": "機械液壓機", - "block.create.mechanical_pump": "機械幫浦", - "block.create.mechanical_saw": "機械切割機", - "block.create.metal_bracket": "金屬支架", - "block.create.millstone": "石磨", - "block.create.minecart_anchor": "礦車錨", - "block.create.mossy_andesite": "青苔安山岩", - "block.create.mossy_dark_scoria": "青苔黑火成岩", - "block.create.mossy_diorite": "青苔閃長岩", - "block.create.mossy_dolomite": "青苔白雲石", - "block.create.mossy_gabbro": "青苔輝長岩", - "block.create.mossy_granite": "青苔花崗岩", - "block.create.mossy_limestone": "青苔石灰岩", - "block.create.mossy_scoria": "青苔火成岩", - "block.create.mossy_weathered_limestone": "青苔風化石灰岩", - "block.create.mysterious_cuckoo_clock": "神秘布穀鳥鐘", - "block.create.natural_scoria": "天然火成岩", - "block.create.nixie_tube": "真空管顯示器", - "block.create.nozzle": "鼓風機噴嘴", - "block.create.oak_window": "橡木窗戶", - "block.create.oak_window_pane": "橡木窗戶片", - "block.create.orange_sail": "橙色風帆", - "block.create.orange_seat": "橙色坐墊", - "block.create.orange_valve_handle": "橙色閥門開關", - "block.create.ornate_iron_window": "華麗鐵窗戶", - "block.create.ornate_iron_window_pane": "華麗鐵窗戶片", - "block.create.overgrown_andesite": "長草的安山岩", - "block.create.overgrown_dark_scoria": "長草的黑火成岩", - "block.create.overgrown_diorite": "長草的閃長岩", - "block.create.overgrown_dolomite": "長草的白雲石", - "block.create.overgrown_gabbro": "長草的輝長岩", - "block.create.overgrown_granite": "長草的花崗岩", - "block.create.overgrown_limestone": "長草的石灰岩", - "block.create.overgrown_scoria": "長草的火成岩", - "block.create.overgrown_weathered_limestone": "長草的風化石灰岩", - "block.create.paved_andesite": "安山岩鋪路石", - "block.create.paved_andesite_slab": "安山岩鋪路石半磚", - "block.create.paved_andesite_stairs": "安山岩鋪路石樓梯", - "block.create.paved_andesite_wall": "安山岩鋪路石牆", - "block.create.paved_dark_scoria": "黑火成岩鋪路石", - "block.create.paved_dark_scoria_slab": "黑火成岩鋪路石半磚", - "block.create.paved_dark_scoria_stairs": "黑火成岩鋪路石樓梯", - "block.create.paved_dark_scoria_wall": "黑火成岩鋪路石牆", - "block.create.paved_diorite": "閃長岩鋪路石", - "block.create.paved_diorite_slab": "閃長岩鋪路石半磚", - "block.create.paved_diorite_stairs": "閃長岩鋪路石樓梯", - "block.create.paved_diorite_wall": "閃長岩鋪路石牆", - "block.create.paved_dolomite": "白雲石鋪路石", - "block.create.paved_dolomite_slab": "白雲石鋪路石半磚", - "block.create.paved_dolomite_stairs": "白雲石鋪路石樓梯", - "block.create.paved_dolomite_wall": "白雲石鋪路石牆", - "block.create.paved_gabbro": "輝長岩鋪路石", - "block.create.paved_gabbro_slab": "輝長岩鋪路石半磚", - "block.create.paved_gabbro_stairs": "輝長岩鋪路石樓梯", - "block.create.paved_gabbro_wall": "輝長岩鋪路石牆", - "block.create.paved_granite": "花崗岩鋪路石", - "block.create.paved_granite_slab": "花崗岩鋪路石半磚", - "block.create.paved_granite_stairs": "花崗岩鋪路石樓梯", - "block.create.paved_granite_wall": "花崗岩鋪路石牆", - "block.create.paved_limestone": "石灰岩鋪路石", - "block.create.paved_limestone_slab": "石灰岩鋪路石半磚", - "block.create.paved_limestone_stairs": "石灰岩鋪路石樓梯", - "block.create.paved_limestone_wall": "石灰岩鋪路石牆", - "block.create.paved_scoria": "火成岩鋪路石", - "block.create.paved_scoria_slab": "火成岩鋪路石半磚", - "block.create.paved_scoria_stairs": "火成岩鋪路石樓梯", - "block.create.paved_scoria_wall": "火成岩鋪路石牆", - "block.create.paved_weathered_limestone": "風化石灰岩鋪路石", - "block.create.paved_weathered_limestone_slab": "風化石灰岩鋪路石半磚", - "block.create.paved_weathered_limestone_stairs": "風化石灰岩鋪路石樓梯", - "block.create.paved_weathered_limestone_wall": "風化石灰岩鋪路石牆", - "block.create.pink_sail": "粉紅色風帆", - "block.create.pink_seat": "粉紅色坐墊", - "block.create.pink_valve_handle": "粉紅色閥門開關", - "block.create.piston_extension_pole": "活塞桿", - "block.create.polished_dark_scoria": "磨製黑火成岩", - "block.create.polished_dark_scoria_slab": "磨製黑火成岩半磚", - "block.create.polished_dark_scoria_stairs": "磨製黑火成岩樓梯", - "block.create.polished_dark_scoria_wall": "磨製黑火成岩牆", - "block.create.polished_dolomite": "磨製白雲石", - "block.create.polished_dolomite_slab": "磨製白雲石半磚", - "block.create.polished_dolomite_stairs": "磨製白雲石樓梯", - "block.create.polished_dolomite_wall": "磨製白雲石牆", - "block.create.polished_gabbro": "磨製輝長岩", - "block.create.polished_gabbro_slab": "磨製輝長岩半磚", - "block.create.polished_gabbro_stairs": "磨製輝長岩樓梯", - "block.create.polished_gabbro_wall": "磨製輝長岩牆", - "block.create.polished_limestone": "磨製石灰岩", - "block.create.polished_limestone_slab": "磨製石灰岩半磚", - "block.create.polished_limestone_stairs": "磨製石灰岩樓梯", - "block.create.polished_limestone_wall": "磨製石灰岩牆", - "block.create.polished_scoria": "磨製火成岩", - "block.create.polished_scoria_slab": "磨製火成岩半磚", - "block.create.polished_scoria_stairs": "磨製火成岩樓梯", - "block.create.polished_scoria_wall": "磨製火成岩牆", - "block.create.polished_weathered_limestone": "磨製風化石灰岩", - "block.create.polished_weathered_limestone_slab": "磨製風化石灰岩半磚", - "block.create.polished_weathered_limestone_stairs": "磨製風化石灰岩樓梯", - "block.create.polished_weathered_limestone_wall": "磨製風化石灰岩牆", - "block.create.portable_fluid_interface": "移動式液體口", - "block.create.portable_storage_interface": "移動式物品口", - "block.create.powered_latch": "閂鎖器", - "block.create.powered_toggle_latch": "T型正反器", - "block.create.pulley_magnet": "滑輪磁鐵", - "block.create.pulse_repeater": "脈衝中繼器", - "block.create.purple_sail": "紫色風帆", - "block.create.purple_seat": "紫色坐墊", - "block.create.purple_valve_handle": "紫色閥門開關", - "block.create.radial_chassis": "旋轉底盤", - "block.create.red_sail": "紅色風帆", - "block.create.red_seat": "紅色坐墊", - "block.create.red_valve_handle": "紅色閥門開關", - "block.create.redstone_contact": "接觸式紅石訊號產生器", - "block.create.redstone_link": "無限紅石訊號機", - "block.create.refined_radiance_casing": "光輝機殼", - "block.create.reinforced_rail": "強化鐵軌", - "block.create.rope": "繩索", - "block.create.rope_pulley": "滑輪繩索", - "block.create.rotation_speed_controller": "轉速控制器", - "block.create.sail_frame": "風帆框架", - "block.create.schematic_table": "藍圖桌", - "block.create.schematicannon": "藍圖加農炮", - "block.create.scoria": "火成岩", - "block.create.scoria_bricks": "火成岩磚", - "block.create.scoria_bricks_slab": "火成岩半磚", - "block.create.scoria_bricks_stairs": "火成岩樓梯", - "block.create.scoria_bricks_wall": "火成岩牆", - "block.create.scoria_cobblestone": "碎火成岩", - "block.create.scoria_cobblestone_slab": "碎火成岩半磚", - "block.create.scoria_cobblestone_stairs": "碎火成岩樓梯", - "block.create.scoria_cobblestone_wall": "碎火成岩牆", - "block.create.scoria_pillar": "豎紋火成岩", - "block.create.secondary_linear_chassis": "機殼底盤2號", - "block.create.sequenced_gearshift": "可程式化齒輪箱", - "block.create.shadow_steel_casing": "暗影機殼", - "block.create.shaft": "傳動軸", - "block.create.smart_fluid_pipe": "智慧液體管道", - "block.create.speedometer": "速度計", - "block.create.spout": "液體灌注器", - "block.create.spruce_window": "雲杉木窗戶", - "block.create.spruce_window_pane": "雲杉木窗戶片", - "block.create.sticky_mechanical_piston": "黏性機械活塞", - "block.create.stockpile_switch": "存量檢測器", - "block.create.stressometer": "動能錶", - "block.create.tiled_glass": "十字玻璃窗", - "block.create.tiled_glass_pane": "十字玻璃窗戶片", - "block.create.turntable": "轉盤", - "block.create.vertical_framed_glass": "豎直邊框玻璃", - "block.create.vertical_framed_glass_pane": "豎直邊框玻璃片", - "block.create.warped_window": "扭曲蕈木窗戶", - "block.create.warped_window_pane": "扭曲蕈木窗戶片", - "block.create.water_wheel": "水車", - "block.create.weathered_limestone": "風化石灰岩", - "block.create.weathered_limestone_bricks": "風化石灰岩磚", - "block.create.weathered_limestone_bricks_slab": "風化石灰岩半磚", - "block.create.weathered_limestone_bricks_stairs": "風化石灰岩樓梯", - "block.create.weathered_limestone_bricks_wall": "風化石灰岩牆", - "block.create.weathered_limestone_cobblestone": "碎風化石灰岩", - "block.create.weathered_limestone_cobblestone_slab": "碎風化石灰岩半磚", - "block.create.weathered_limestone_cobblestone_stairs": "碎風化石灰岩樓梯", - "block.create.weathered_limestone_cobblestone_wall": "碎風化石灰岩牆", - "block.create.weathered_limestone_pillar": "豎紋風化石灰岩", - "block.create.white_sail": "白色風帆", - "block.create.white_seat": "白色坐墊", - "block.create.white_valve_handle": "白色閥門開關", - "block.create.windmill_bearing": "風車軸承", - "block.create.wooden_bracket": "木製支架", - "block.create.yellow_sail": "黃色風帆", - "block.create.yellow_seat": "黃色坐墊", - "block.create.yellow_valve_handle": "黃色閥門開關", - "block.create.zinc_block": "鋅磚", - "block.create.zinc_ore": "鋅礦石", - - "entity.create.contraption": "結構", - "entity.create.seat": "坐墊", - "entity.create.stationary_contraption": "固定結構", - "entity.create.super_glue": "強力膠", - - "fluid.create.chocolate": "巧克力", - "fluid.create.honey": "蜂蜜", - "fluid.create.milk": "牛奶", - "fluid.create.potion": "藥水", - "fluid.create.tea": "茶", - - "item.create.andesite_alloy": "安山合金", - "item.create.attribute_filter": "屬性過濾器", - "item.create.bar_of_chocolate": "巧克力棒", - "item.create.belt_connector": "輸送帶", - "item.create.blaze_cake": "熔岩蛋糕", - "item.create.blaze_cake_base": "熔岩蛋糕胚", - "item.create.brass_hand": "黃銅手部零件", - "item.create.brass_ingot": "黃銅錠", - "item.create.brass_nugget": "黃銅粒", - "item.create.brass_sheet": "黃銅板", - "item.create.builders_tea": "工人茶", - "item.create.chest_minecart_contraption": "裝修過的機械礦車", - "item.create.chocolate_bucket": "巧克力桶", - "item.create.chromatic_compound": "異彩化合物", - "item.create.cinder_flour": "地獄麵粉", - "item.create.copper_ingot": "銅錠", - "item.create.copper_nugget": "銅粒", - "item.create.copper_sheet": "銅板", - "item.create.crafter_slot_cover": "合成器蓋板", - "item.create.crushed_aluminum_ore": "碎狀鋁礦石", - "item.create.crushed_brass": "碎狀黃銅", - "item.create.crushed_copper_ore": "碎狀銅礦石", - "item.create.crushed_gold_ore": "碎狀金礦石", - "item.create.crushed_iron_ore": "碎狀鐵礦石", - "item.create.crushed_lead_ore": "碎狀鉛礦石", - "item.create.crushed_nickel_ore": "碎狀鎳礦石", - "item.create.crushed_osmium_ore": "碎狀鋨礦石", - "item.create.crushed_platinum_ore": "碎狀白金礦石", - "item.create.crushed_quicksilver_ore": "碎狀水銀礦石", - "item.create.crushed_silver_ore": "碎狀銀礦石", - "item.create.crushed_tin_ore": "碎狀錫礦石", - "item.create.crushed_uranium_ore": "碎狀鈾礦石", - "item.create.crushed_zinc_ore": "碎狀鋅礦石", - "item.create.deforester": "連根拔樹斧", - "item.create.dough": "麵團", - "item.create.electron_tube": "真空管", - "item.create.empty_blaze_burner": "空的烈焰使者動力爐", - "item.create.empty_schematic": "空白藍圖", - "item.create.extendo_grip": "伸縮機械手", - "item.create.filter": "過濾器", - "item.create.furnace_minecart_contraption": "裝配過的機械礦車", - "item.create.goggles": "MR護目鏡", - "item.create.golden_sheet": "金板", - "item.create.handheld_blockzapper": "方塊放置器", - "item.create.handheld_worldshaper": "地形雕塑器", - "item.create.honey_bucket": "蜂蜜桶", - "item.create.integrated_circuit": "IC板", - "item.create.iron_sheet": "鐵板", - "item.create.lapis_sheet": "青金石板", - "item.create.minecart_contraption": "裝修過的礦車", - "item.create.minecart_coupling": "礦車連結器", - "item.create.polished_rose_quartz": "磨製玫瑰石英", - "item.create.powdered_obsidian": "黑曜石粉末", - "item.create.propeller": "扇葉", - "item.create.red_sand_paper": "紅砂紙", - "item.create.refined_radiance": "光輝石", - "item.create.rose_quartz": "玫瑰石英", - "item.create.sand_paper": "砂紙", - "item.create.schematic": "藍圖", - "item.create.schematic_and_quill": "藍圖與筆", - "item.create.shadow_steel": "暗影鋼", - "item.create.super_glue": "強力膠", - "item.create.tree_fertilizer": "樹木肥料", - "item.create.vertical_gearbox": "豎直齒輪箱", - "item.create.wand_of_symmetry": "對稱杖", - "item.create.wheat_flour": "小麥粉", - "item.create.whisk": "攪拌器", - "item.create.wrench": "板手", - "item.create.zinc_ingot": "鋅錠", - "item.create.zinc_nugget": "鋅粒", - - - "_": "->------------------------] Advancements [------------------------<-", - - "advancement.create.root": "感謝你安裝機械動力模組,強烈建議您安裝JEI配合本模組遊玩", - "advancement.create.root.desc": "該來製作一些超棒的機械結構了!", - "advancement.create.andesite_alloy": "原始人類的合金替代品", - "advancement.create.andesite_alloy.desc": "機械動力有著許多的材料和合金,但受限於技術,原始的人類們暫時只能製作出安山合金", - "advancement.create.its_alive": "鮮活的機械生命", - "advancement.create.its_alive.desc": "首次使齒輪結構的旋轉。", - "advancement.create.shifting_gears": "換檔,加速,起飛!", - "advancement.create.shifting_gears.desc": "將大齒輪連接到小齒輪上,機械結構的轉速將會翻倍", - "advancement.create.overstressed": "超載", - "advancement.create.overstressed.desc": "首次使動能網路超載。", - "advancement.create.belt": "流水線作業", - "advancement.create.belt.desc": "用輸送帶連接兩個傳動軸", - "advancement.create.tunnel": "尋找掩護!", - "advancement.create.tunnel.desc": "在輸送帶上放上物品隧道。", - "advancement.create.splitter_tunnel": "分而治之", - "advancement.create.splitter_tunnel.desc": "用黃銅物品隧道設計一個分流器。", - "advancement.create.chute": "轟然倒塌", - "advancement.create.chute.desc": "放置一個滑道(垂直版本的輸送帶)。", - "advancement.create.upward_chute": "空中攔截", - "advancement.create.upward_chute.desc": "目睹拋出的物品飛入裝有風扇的滑道。", - "advancement.create.belt_funnel": "漏斗的垂簾", - "advancement.create.belt_funnel.desc": "將側向漏斗放在輸送帶或置物臺的上方。", - "advancement.create.belt_funnel_kiss": "比翼雙飛", - "advancement.create.belt_funnel_kiss.desc": "使兩個安裝在輸送帶上的漏斗相連。", - "advancement.create.fan": "機械氣槍", - "advancement.create.fan.desc": "飄浮在鼓風機吹出的氣流上", - "advancement.create.fan_lava": "空間加熱器", - "advancement.create.fan_lava.desc": "感受熔煉物品的氣流。", - "advancement.create.fan_water": "奇怪的洗滌", - "advancement.create.fan_water.desc": "被洗滌的氣流所吸引。", - "advancement.create.fan_smoke": "機械波紋管", - "advancement.create.fan_smoke.desc": "感受煙燻氣流。", - "advancement.create.wrench": "細部調整", - "advancement.create.wrench.desc": "做出一個方便調整方塊的板手", - "advancement.create.goggles": "動能,一目了然", - "advancement.create.goggles.desc": "做出一個能看到機械動能訊息的MR護目鏡", - "advancement.create.speedometer": "精密的速度控制", - "advancement.create.speedometer.desc": "放置一個速度計,並且戴上MR護目鏡來讀取數據", - "advancement.create.stressometer": "精密的動能控制", - "advancement.create.stressometer.desc": "放置一個動能計,並且戴上MR護目鏡來讀取數據", - "advancement.create.aesthetics": "繁榮與美學!", - "advancement.create.aesthetics.desc": "將支架放在傳動軸,管道和齒輪上。", - "advancement.create.reinforced": "超級加固!", - "advancement.create.reinforced.desc": "在傳動軸,管道和輸送帶上使用機殼加固。", - "advancement.create.water_wheel": "治水", - "advancement.create.water_wheel.desc": "放置一個水車並讓它開始旋轉", - "advancement.create.chocolate_wheel": "美味的動能源", - "advancement.create.chocolate_wheel.desc": "用融化的巧克力驅動水車。", - "advancement.create.lava_wheel": "風火輪", - "advancement.create.lava_wheel.desc": "它不應該有用的..。", - "advancement.create.cuckoo": "是時候了?", - "advancement.create.cuckoo.desc": "目睹布穀鳥鐘報就寢時間。", - "advancement.create.millstone": "攜帶式粉碎機", - "advancement.create.millstone.desc": "放置一個石磨並且為其供能", - "advancement.create.windmill": "微風拂過", - "advancement.create.windmill.desc": "組裝風車。", - "advancement.create.maxed_windmill": "強風襲來", - "advancement.create.maxed_windmill.desc": "組裝最大動能的風車。", - "advancement.create.andesite_casing": "安山時代", - "advancement.create.andesite_casing.desc": "使用安山合金和木頭來合成一個安山機殼", - "advancement.create.mechanical_drill": "堅若磐石", - "advancement.create.mechanical_drill.desc": "放置一個機械鑽頭並且為其供能", - "advancement.create.press": "'噹!'", - "advancement.create.press.desc": "使用液壓機來壓製一些板子", - "advancement.create.polished_rose_quartz": "粉紅鑽石", - "advancement.create.polished_rose_quartz.desc": "用砂紙將玫瑰石英磨至透明", - "advancement.create.electron_tube": "嗶~~嗶~~", - "advancement.create.electron_tube.desc": "製作一個可用來合成高級機器的真空管", - "advancement.create.mechanical_saw": "一刀兩斷", - "advancement.create.mechanical_saw.desc": "放置一個切割機並且為其供能", - "advancement.create.basin": "快到碗裡來", - "advancement.create.basin.desc": "放置一個作業盆,並且往裡面放些東西", - "advancement.create.mixer": "充分攪拌", - "advancement.create.mixer.desc": "將攪拌機放在作業盆上方,並且使其攪拌盆內的物品", - "advancement.create.blaze_burner": "活生生的壁爐", - "advancement.create.blaze_burner.desc": "獲得一個烈焰使者動力爐。", - "advancement.create.compact": "快樂壓縮", - "advancement.create.compact.desc": "使用液壓機在作業盆中壓製一些物品", - "advancement.create.brass": "真正的合金", - "advancement.create.brass.desc": "使用粉碎鋅礦石和粉碎銅礦石來製作粉碎黃銅", - "advancement.create.brass_casing": "黃銅時代", - "advancement.create.brass_casing.desc": "用黃銅和木頭製作一個黃銅機殼", - "advancement.create.copper_casing": "銅時代", - "advancement.create.copper_casing.desc": "使用銅和木頭製作一個銅製機殼", - "advancement.create.spout": "裝填!", - "advancement.create.spout.desc": "觀察注液器灌滿物品。", - "advancement.create.spout_potion": "國際級啤酒大廠", - "advancement.create.spout_potion.desc": "觀察注液器注入藥水到玻璃瓶。", - "advancement.create.chocolate": "夢裡的世界", - "advancement.create.chocolate.desc": "獲取一桶熔融巧克力。", - "advancement.create.item_drain": "滾筒洗衣機", - "advancement.create.item_drain.desc": "觀察液體物品被分液池抽空。", - "advancement.create.chained_item_drain": "讓我們一起搖滾!", - "advancement.create.chained_item_drain.desc": "看著物品穿過多個分液池。", - "advancement.create.glass_pipe": "偷窺液體", - "advancement.create.glass_pipe.desc": "透過窗戶觀察液體在管道中流動。使用板手可打開直線液體管道的窗戶。", - "advancement.create.pipe_collision": "永不交會的溪流!", - "advancement.create.pipe_collision.desc": "觀察兩種液體在您的管道中會合", - "advancement.create.pipe_spill": "漏水啦!", - "advancement.create.pipe_spill.desc": "觀察管道的末端將液體排放到到外面。", - "advancement.create.hose_pulley": "工業排放", - "advancement.create.hose_pulley.desc": "放下一個軟管滑輪,觀察它排乾或充滿液體。", - "advancement.create.infinite_water": "抽取海洋", - "advancement.create.infinite_water.desc": "從足以被認為是無限的水源中抽水。", - "advancement.create.infinite_lava": "吸取行星的核心", - "advancement.create.infinite_lava.desc": "從廣闊的岩漿湖中抽出岩漿。", - "advancement.create.infinite_chocolate": "淹沒在幻想中", - "advancement.create.infinite_chocolate.desc": "從廣闊的巧克力海中抽出巧克力。", - "advancement.create.crafter": "自動化流水作業", - "advancement.create.crafter.desc": "放置一些機械合成臺並且為其供能", - "advancement.create.clockwork_bearing": "時差", - "advancement.create.clockwork_bearing.desc": "組裝安裝在發條軸承上的結構。", - "advancement.create.nixie_tube": "風格的跡象", - "advancement.create.nixie_tube.desc": "獲得真空管顯示器並放置。", - "advancement.create.deployer": "指爽沒?", - "advancement.create.deployer.desc": "放置並且啟動一個機械手。這可是你右手完美的複製品", - "advancement.create.speed_controller": "攻城屍討厭他!", - "advancement.create.speed_controller.desc": "放置一個轉速控制器,這是換檔的終極裝置。", - "advancement.create.flywheel": "工廠之心", - "advancement.create.flywheel.desc": "將引擎成功連接到飛輪。", - "advancement.create.overstress_flywheel": "壓力過大", - "advancement.create.overstress_flywheel.desc": "超載熔爐引擎。", - "advancement.create.integrated_circuit": "複雜的運算", - "advancement.create.integrated_circuit.desc": "合成IC板。", - "advancement.create.mechanical_arm": "忙碌的手!", - "advancement.create.mechanical_arm.desc": "製作機械手臂,選擇輸入和輸出,放置並給它動能; 然後看著它完成所有你交代的工作。", - "advancement.create.musical_arm": "沒人能在我的BGM裡打敗我!", - "advancement.create.musical_arm.desc": "使用機械手臂播放唱片。", - "advancement.create.arm_many_targets": "你是要累死我?", - "advancement.create.arm_many_targets.desc": "配置一隻有十個或更多輸出位置的機械手臂。", - "advancement.create.arm_blaze_burner": "燃燒吧!烈焰使者!", - "advancement.create.arm_blaze_burner.desc": "指揮機械臂給烈焰使者動力爐投食。", - "advancement.create.fist_bump": "朋友,來碰個拳", - "advancement.create.fist_bump.desc": "使兩個機械手互相碰拳", - "advancement.create.crushing_wheel": "一對大傢伙", - "advancement.create.crushing_wheel.desc": "製作一對能更快粉碎物品的粉碎輪", - "advancement.create.blaze_cake": "糖份超標", - "advancement.create.blaze_cake.desc": "幫烈焰使者動力爐烤一份特別的蛋糕。", - "advancement.create.chromatic_compound": "兩極材料", - "advancement.create.chromatic_compound.desc": "製作一個異彩化合物", - "advancement.create.shadow_steel": "自虛空的歸來的寶石", - "advancement.create.shadow_steel.desc": "製作暗影鋼", - "advancement.create.refined_radiance": "閃耀著純白的聖光", - "advancement.create.refined_radiance.desc": "製作光輝石", - "advancement.create.chromatic_age": "繽紛時代", - "advancement.create.chromatic_age.desc": "創造出光與影的機殼。", - "advancement.create.zapper": "專業的建築師", - "advancement.create.zapper.desc": "製作一個非常方便的方塊放置器", - "advancement.create.upgraded_zapper": "來自異世界的超頻", - "advancement.create.upgraded_zapper.desc": "製作一個完全升級的方塊放置器", - "advancement.create.wand_of_symmetry": "簡單的鏡面幾何學", - "advancement.create.wand_of_symmetry.desc": "製作一個對稱杖", - "advancement.create.deforester": "超時空砍伐", - "advancement.create.deforester.desc": "製作一個連根拔樹斧,然後跟你後院的樹林道別吧", - "advancement.create.extendo_grip": "piu piu piu!", - "advancement.create.extendo_grip.desc": "拿到一個伸縮機械手", - "advancement.create.dual_extendo_grip": "piu——piu——piu——", - "advancement.create.dual_extendo_grip.desc": "雙持伸縮機械手進一步加長觸碰距離", - "advancement.create.eob": "Beta版結束", - "advancement.create.eob.desc": "期待日後的更新。", - - - "_": "->------------------------] UI & Messages [------------------------<-", - - "itemGroup.create.base": "動力機械", - "itemGroup.create.palettes": "動力機械建築與裝飾方塊", - - "death.attack.create.crush": "%1$s被壓扁了", - "death.attack.create.fan_fire": "%1$s想接受熱風的洗禮", - "death.attack.create.fan_lava": "%1$s想接受熱風的洗禮但走火入魔", - "death.attack.create.mechanical_drill": "%1$s被鑽頭鑽爆腦袋", - "death.attack.create.mechanical_saw": "%1$s被鋸切成了兩半", - "death.attack.create.cuckoo_clock_explosion": "%1$s 被布穀鳥鐘炸得粉身碎骨", - - "create.block.deployer.damage_source_name": "機械手", - "create.block.cart_assembler.invalid": "將您的礦車裝修站放在鐵軌上", - - "create.recipe.crushing": "粉碎", - "create.recipe.milling": "研磨", - "create.recipe.fan_washing": "批次洗滌", - "create.recipe.fan_washing.fan": "在水後放置鼓風機", - "create.recipe.fan_smoking": "批次煙燻", - "create.recipe.fan_smoking.fan": "在火焰後放置鼓風機", - "create.recipe.fan_blasting": "批次融煉", - "create.recipe.fan_blasting.fan": "在熔岩後放置鼓風機", - "create.recipe.pressing": "金屬壓片", - "create.recipe.mixing": "混合攪拌", - "create.recipe.automatic_shapeless": "自動攪拌", - "create.recipe.automatic_brewing": "自動釀造", - "create.recipe.packing": "壓塊塑形", - "create.recipe.automatic_packing": "自動打包", - "create.recipe.sawing": "板材切割", - "create.recipe.mechanical_crafting": "自動合成", - "create.recipe.automatic_shaped": "自動合成", - "create.recipe.block_cutting": "方塊切割", - "create.recipe.blockzapper_upgrade": "方塊放置器", - "create.recipe.sandpaper_polishing": "砂紙打磨", - "create.recipe.mystery_conversion": "神秘轉化", - "create.recipe.spout_filling": "注液", - "create.recipe.draining": "分液", - "create.recipe.processing.chance":"%1$s%%概率", - "create.recipe.heat_requirement.none": "不需加熱", - "create.recipe.heat_requirement.heated": "加熱", - "create.recipe.heat_requirement.superheated": "超級加熱", - - "create.generic.range": "範圍", - "create.generic.radius": "半徑", - "create.generic.width": "寬", - "create.generic.height": "高", - "create.generic.length": "長", - "create.generic.speed": "速度", - "create.generic.delay": "延時", - "create.generic.unit.ticks": "Ticks", - "create.generic.unit.seconds": "秒", - "create.generic.unit.minutes": "分", - "create.generic.unit.rpm": "RPM", - "create.generic.unit.stress": "SU", - "create.generic.unit.degrees": "°", - "create.generic.unit.millibuckets":"%1$smB", - "create.generic.clockwise": "順時鐘方向", - "create.generic.counter_clockwise": "逆時鐘方向", - - "create.action.scroll": "滾輪", - "create.action.confirm": "確認", - "create.action.abort": "退出", - "create.action.saveToFile": "離開", - "create.action.discard": "放棄", - - "create.keyinfo.toolmenu": "選單", - "create.keyinfo.scrollup": "(遊戲中)向上滑鼠滾輪", - "create.keyinfo.scrolldown": "(遊戲中)向下滑鼠滾輪", - - "create.gui.scrollInput.defaultTitle": "選擇一個選項:", - "create.gui.scrollInput.scrollToModify": "滾動修改", - "create.gui.scrollInput.scrollToAdjustAmount": "滾動修改數量", - "create.gui.scrollInput.scrollToSelect": "滾動選擇", - "create.gui.scrollInput.shiftScrollsFaster": "按住Shift滾動更快", - "create.gui.toolmenu.focusKey": "按住 [%1$s] 滑鼠滾輪選擇", - "create.gui.toolmenu.cycle": "[SCROLL] 循環", - "create.gui.symmetryWand.mirrorType": "鏡子類型", - "create.gui.symmetryWand.orientation": "方向", - - "create.symmetry.mirror.plane": "鏡像", - "create.symmetry.mirror.doublePlane": "矩形", - "create.symmetry.mirror.triplePlane": "八角", - - "create.orientation.orthogonal": "垂直", - "create.orientation.diagonal": "對角線", - "create.orientation.horizontal": "水平", - "create.orientation.alongZ": "以z軸對齊", - "create.orientation.alongX": "以x軸對齊", - - "create.gui.blockzapper.title": "方塊放置機", - "create.gui.blockzapper.replaceMode": "替換模式", - "create.gui.blockzapper.searchDiagonal": "對角線延伸", - "create.gui.blockzapper.searchFuzzy": "忽視種類分界", - "create.gui.blockzapper.range": "延伸範圍", - "create.gui.blockzapper.needsUpgradedAmplifier": "需要升級範圍擴大器", - "create.gui.blockzapper.patternSection": "模式", - "create.gui.blockzapper.pattern.solid": "實心", - "create.gui.blockzapper.pattern.checkered": "棋盤", - "create.gui.blockzapper.pattern.inversecheckered": "反轉棋盤", - "create.gui.blockzapper.pattern.chance25": "25% ", - "create.gui.blockzapper.pattern.chance50": "50% ", - "create.gui.blockzapper.pattern.chance75": "75% ", - "create.gui.terrainzapper.title": "地形雕塑器", - "create.gui.terrainzapper.placement": "放置模式", - "create.gui.terrainzapper.placement.merged": "結合", - "create.gui.terrainzapper.placement.attached": "依附", - "create.gui.terrainzapper.placement.inserted": "插入", - "create.gui.terrainzapper.brush": "雕塑類型", - "create.gui.terrainzapper.brush.cuboid": "矩形體", - "create.gui.terrainzapper.brush.sphere": "球體", - "create.gui.terrainzapper.brush.cylinder": "圓柱體", - "create.gui.terrainzapper.tool": "填充類型", - "create.gui.terrainzapper.tool.fill": "填充", - "create.gui.terrainzapper.tool.place": "覆寫", - "create.gui.terrainzapper.tool.replace": "替換", - "create.gui.terrainzapper.tool.clear": "清除", - "create.gui.terrainzapper.tool.overlay": "覆蓋", - "create.gui.terrainzapper.tool.flatten": "平整", - - "create.terrainzapper.shiftRightClickToSet": "Shift+滑鼠右鍵 以設定雕塑類型", - - "create.blockzapper.usingBlock": "使用:%1$s", - "create.blockzapper.componentUpgrades": "零件升級:", - "create.blockzapper.component.body": "放置器機體", - "create.blockzapper.component.amplifier": "範圍擴大器", - "create.blockzapper.component.accelerator": "射擊加速器", - "create.blockzapper.component.retriever": "物品撿回器", - "create.blockzapper.component.scope": "距離觀察鏡", - "create.blockzapper.componentTier.none": "無", - "create.blockzapper.componentTier.brass": "黃銅", - "create.blockzapper.componentTier.chromatic": "異彩化合物", - "create.blockzapper.leftClickToSet": "左鍵點擊方塊以設定方塊種類", - "create.blockzapper.empty": "方塊不足!", - - "create.minecart_coupling.two_couplings_max": "礦車無法被連接兩個以上的礦車連結器", - "create.minecart_coupling.unloaded": "有一部份礦車存在於未讀取區塊中", - "create.minecart_coupling.no_loops": "礦車連結器不能連成一個環", - "create.minecart_coupling.removed": "從礦車上移除所有礦車連結器", - "create.minecart_coupling.too_far": "礦車距離你太遠了", - - "create.contraptions.movement_mode": "運動模式", - "create.contraptions.movement_mode.move_place": "停止時實體化方塊", - "create.contraptions.movement_mode.move_place_returned": "只在初始位置實體化方塊", - "create.contraptions.movement_mode.move_never_place": "只有在機械方塊摧毀後才實體化方塊", - "create.contraptions.movement_mode.rotate_place": "停止時實體化方塊", - "create.contraptions.movement_mode.rotate_place_returned": "只在接近初始角度實體化方塊", - "create.contraptions.movement_mode.rotate_never_place": "只有在旋轉軸摧毀後才實體化方塊", - "create.contraptions.cart_movement_mode": "礦車運動模式", - "create.contraptions.cart_movement_mode.rotate": "結構與礦車保持相同方向", - "create.contraptions.cart_movement_mode.rotate_paused": "礦車轉向時機器停止工作", - "create.contraptions.cart_movement_mode.rotation_locked": "結構方向保持不變", - "create.contraptions.windmill.rotation_direction": "旋轉方向", - "create.contraptions.clockwork.clock_hands": "鐘錶指針", - "create.contraptions.clockwork.hour_first": "時針優先", - "create.contraptions.clockwork.minute_first": "分針優先", - "create.contraptions.clockwork.hour_first_24": "24小時制優先", - - "create.logistics.filter": "過濾器", - "create.logistics.recipe_filter": "配方過濾器", - "create.logistics.fluid_filter": "液體過濾器", - "create.logistics.firstFrequency": "頻道. #1", - "create.logistics.secondFrequency": "頻道. #2", - "create.logistics.filter.apply": "將過濾器應用來%1$s。", - "create.logistics.filter.apply_click_again": "將過濾器應用來%1$s,再次點擊以復制數量。", - "create.logistics.filter.apply_count": "使用提取計數過濾。", - - "create.gui.goggles.generator_stats": "產能器狀態:", - "create.gui.goggles.kinetic_stats": "機械學狀態:", - "create.gui.goggles.at_current_speed": "現在速度動能值", - "create.gui.goggles.base_value": "動能基礎值", - "create.gui.gauge.info_header": "儀表訊息:", - "create.gui.speedometer.title": "旋轉速度", - "create.gui.stressometer.title": "網路動能", - "create.gui.stressometer.capacity": "剩餘動能量", - "create.gui.stressometer.overstressed": "動能過載", - "create.gui.stressometer.no_rotation": "無旋轉", - "create.gui.contraptions.not_fast_enough": "看起來%1$s 沒有達到足夠的工作轉速。", - "create.gui.contraptions.network_overstressed": "裝置似乎過載,減少高動能消耗的裝置或者增加更多更多動能", - "create.gui.adjustable_crate.title": "板條箱", - "create.gui.adjustable_crate.storageSpace": "儲存空間", - "create.gui.stockpile_switch.title": "儲存開關", - "create.gui.stockpile_switch.invert_signal": "反轉訊號", - "create.gui.stockpile_switch.move_to_lower_at": "移至下線%1$s%%", - "create.gui.stockpile_switch.move_to_upper_at": "移至上線%1$s%%", - "create.gui.sequenced_gearshift.title": "可程式化齒輪箱", - "create.gui.sequenced_gearshift.instruction": "指令", - "create.gui.sequenced_gearshift.instruction.turn_angle": "旋轉", - "create.gui.sequenced_gearshift.instruction.turn_angle.angle": "角度", - "create.gui.sequenced_gearshift.instruction.turn_distance": "驅動活塞", - "create.gui.sequenced_gearshift.instruction.turn_distance.distance": "距離", - "create.gui.sequenced_gearshift.instruction.wait": "等待", - "create.gui.sequenced_gearshift.instruction.wait.duration": "間隔", - "create.gui.sequenced_gearshift.instruction.end": "停止", - "create.gui.sequenced_gearshift.speed": "速度,速度方向", - "create.gui.sequenced_gearshift.speed.forward": "一倍速,正向", - "create.gui.sequenced_gearshift.speed.forward_fast": "兩倍速,正向", - "create.gui.sequenced_gearshift.speed.back": "一倍速,反向", - "create.gui.sequenced_gearshift.speed.back_fast": "兩倍速,反向", - - "create.schematicAndQuill.dimensions": "藍圖尺寸:%1$sx%2$sx%3$s", - "create.schematicAndQuill.firstPos": "第一個位置。", - "create.schematicAndQuill.secondPos": "第二個位置。", - "create.schematicAndQuill.noTarget": "按住Ctrl選擇空氣方塊。", - "create.schematicAndQuill.abort": "刪除選擇。", - "create.schematicAndQuill.title": "藍圖名:", - "create.schematicAndQuill.convert": "立即存檔並發佈", - "create.schematicAndQuill.fallbackName": "我的藍圖", - "create.schematicAndQuill.saved": "另存為%1$s", - - "create.schematic.invalid":"[!] 無效的項目", - "create.schematic.position": "位置", - "create.schematic.rotation": "旋轉", - "create.schematic.rotation.none": "無", - "create.schematic.rotation.cw90": "順時鐘90", - "create.schematic.rotation.cw180": "順時鐘180", - "create.schematic.rotation.cw270": "順時鐘270", - "create.schematic.mirror": "鏡像", - "create.schematic.mirror.none": "無", - "create.schematic.mirror.frontBack": "前後", - "create.schematic.mirror.leftRight": "左右", - "create.schematic.tool.deploy": "發佈", - "create.schematic.tool.move": "移動 XZ", - "create.schematic.tool.movey": "移動 Y", - "create.schematic.tool.rotate": "旋轉", - "create.schematic.tool.print": "列印", - "create.schematic.tool.flip": "翻轉", - "create.schematic.tool.deploy.description.0": "將結構移到某個位置。", - "create.schematic.tool.deploy.description.1": "在地面上點擊滑鼠右鍵以放置。", - "create.schematic.tool.deploy.description.2": "按住Ctrl以固定距離選擇。", - "create.schematic.tool.deploy.description.3": "按住Ctrl滑鼠滾動更改距離。", - "create.schematic.tool.move.description.0": "水平移動藍圖", - "create.schematic.tool.move.description.1": "選定藍圖,然後按住Ctrl滑鼠滾動。", - "create.schematic.tool.move.description.2":"", - "create.schematic.tool.move.description.3":"", - "create.schematic.tool.movey.description.0": "垂直移動藍圖", - "create.schematic.tool.movey.description.1": "按住Ctrl滑鼠滾動上下移動", - "create.schematic.tool.movey.description.2":"", - "create.schematic.tool.movey.description.3":"", - "create.schematic.tool.rotate.description.0": "圍繞藍圖中心旋轉藍圖。", - "create.schematic.tool.rotate.description.1": "按住Ctrl滑鼠滾動旋轉90度", - "create.schematic.tool.rotate.description.2":"", - "create.schematic.tool.rotate.description.3":"", - "create.schematic.tool.print.description.0": "立即將結構放置在世界上", - "create.schematic.tool.print.description.1": "右鍵點擊確認目前位置。", - "create.schematic.tool.print.description.2": "該工具僅能用於創造模式。", - "create.schematic.tool.print.description.3":"", - "create.schematic.tool.flip.description.0": "沿你選擇的面翻轉藍圖。", - "create.schematic.tool.flip.description.1": "指向藍圖,然後按住Ctrl滑鼠滾動將其翻轉。", - "create.schematic.tool.flip.description.2":"", - "create.schematic.tool.flip.description.3":"", - - "create.schematics.synchronizing": "正在同步..", - "create.schematics.uploadTooLarge": "你的藍圖太大", - "create.schematics.maxAllowedSize": "允許的最大藍圖文件大小為:", - - "create.gui.schematicTable.refresh": "重新整理文件", - "create.gui.schematicTable.open_folder": "打開資料夾", - "create.gui.schematicTable.title": "藍圖桌", - "create.gui.schematicTable.availableSchematics": "可用藍圖", - "create.gui.schematicTable.noSchematics": "沒有存檔的藍圖", - "create.gui.schematicTable.uploading": "正在上傳...", - "create.gui.schematicTable.finished": "上傳完成!", - "create.gui.schematicannon.title": "藍圖加農炮", - "create.gui.schematicannon.listPrinter": "物品清單列印機", - "create.gui.schematicannon.gunpowderLevel": "火藥%1$s%%", - "create.gui.schematicannon.shotsRemaining": "發射進度:%1$s", - "create.gui.schematicannon.shotsRemainingWithBackup": "備份:%1$s", - "create.gui.schematicannon.optionEnabled": "目前啟用", - "create.gui.schematicannon.optionDisabled": "目前停用", - "create.gui.schematicannon.showOptions": "顯示藍圖加農炮設定", - "create.gui.schematicannon.option.dontReplaceSolid": "不要替換方塊", - "create.gui.schematicannon.option.replaceWithSolid": "用固體方塊替換工作區域內的方塊", - "create.gui.schematicannon.option.replaceWithAny": "用任何方塊替換工作區域內的方塊", - "create.gui.schematicannon.option.replaceWithEmpty": "用空氣替換工作區域內的方塊", - "create.gui.schematicannon.option.skipMissing": "繞過缺少的方塊", - "create.gui.schematicannon.option.skipTileEntities": "保護儲存方塊", - "create.gui.schematicannon.slot.gunpowder": "向藍圖加農炮添加火藥以提供動能", - "create.gui.schematicannon.slot.listPrinter": "在此處放置書以列印藍圖所需的材料清單", - "create.gui.schematicannon.slot.schematic": "在此處添加你的藍圖,務必確保其已被部放置在特定位置", - "create.gui.schematicannon.option.skipMissing.description": "如果材料不夠,藍圖大炮將忽略目前不夠的材料並且使用其他已有材料繼續工作", - "create.gui.schematicannon.option.skipTileEntities.description": "藍圖將避免更換儲存方塊,如箱子。", - "create.gui.schematicannon.option.dontReplaceSolid.description": "藍圖加農炮將不會替換工作範圍內的任何固體方塊。", - "create.gui.schematicannon.option.replaceWithSolid.description": "藍圖加農炮會使用所提供的固體方塊來替換工作區域內的其他固體方塊", - "create.gui.schematicannon.option.replaceWithAny.description": "藍圖加農炮會使用任何所提供的方塊來替換工作區域內的固體方塊", - "create.gui.schematicannon.option.replaceWithEmpty.description": "藍圖加農炮將清理和替換工作區域內所有原本的方塊。", - - "create.schematicannon.status.idle": "閒置", - "create.schematicannon.status.ready": "準備", - "create.schematicannon.status.running": "啟動", - "create.schematicannon.status.finished": "完成", - "create.schematicannon.status.paused": "已暫停", - "create.schematicannon.status.stopped": "停止", - "create.schematicannon.status.noGunpowder": "火藥消耗完畢", - "create.schematicannon.status.targetNotLoaded": "方塊未讀取", - "create.schematicannon.status.targetOutsideRange": "定位目標太遠", - "create.schematicannon.status.searching": "搜尋", - "create.schematicannon.status.skipping": "跳過", - "create.schematicannon.status.missingBlock": "缺少方塊:", - "create.schematicannon.status.placing": "建築中", - "create.schematicannon.status.clearing": "清除方塊中", - "create.schematicannon.status.schematicInvalid": "藍圖無效", - "create.schematicannon.status.schematicNotPlaced": "藍圖未發佈", - "create.schematicannon.status.schematicExpired": "藍圖文件已過期", - - "create.materialChecklist": "材料清單", - "create.materialChecklist.blocksNotLoaded": "*免責聲明* \n\n由於未讀取相關區塊,材料清單可能不正確。", - - "create.gui.filter.deny_list": "黑名單", - "create.gui.filter.deny_list.description": "只通過不在黑名單中的物品,如果黑名單為空,所有物品都可以通過", - "create.gui.filter.allow_list": "白名單", - "create.gui.filter.allow_list.description": "只通過在白名單中的物品,如果白名單為空,所有物品都無法通過", - "create.gui.filter.respect_data": "比對物品屬性", - "create.gui.filter.respect_data.description": "只有物品的耐久、附魔等其他屬性相同時才可以比對", - "create.gui.filter.ignore_data": "忽略物品屬性", - "create.gui.filter.ignore_data.description": "配對時忽略物品的耐久、附魔等其他屬性", - - "create.item_attributes.placeable": "可放置", - "create.item_attributes.placeable.inverted": "不可放置", - "create.item_attributes.consumable": "可食用", - "create.item_attributes.consumable.inverted": "不可食用", - "create.item_attributes.smeltable": "可被熔爐融煉", - "create.item_attributes.smeltable.inverted": "不可被熔爐融煉", - "create.item_attributes.washable": "可被篩洗", - "create.item_attributes.washable.inverted": "不可被篩洗", - "create.item_attributes.smokable": "可被煙熏", - "create.item_attributes.smokable.inverted": "不可被煙熏", - "create.item_attributes.crushable": "可被粉碎", - "create.item_attributes.crushable.inverted": "不可被粉碎", - "create.item_attributes.blastable": "可被高爐融煉", - "create.item_attributes.blastable.inverted": "不可被高爐融煉", - "create.item_attributes.enchanted": "已被附魔", - "create.item_attributes.enchanted.inverted": "未被附魔", - "create.item_attributes.damaged": "已損壞", - "create.item_attributes.damaged.inverted": "未損壞", - "create.item_attributes.badly_damaged": "嚴重受損", - "create.item_attributes.badly_damaged.inverted": "未嚴重受損", - "create.item_attributes.not_stackable": "無法堆疊", - "create.item_attributes.not_stackable.inverted": "可堆疊", - "create.item_attributes.equipable": "可裝備", - "create.item_attributes.equipable.inverted": "不可裝備", - "create.item_attributes.furnace_fuel": "是燃料", - "create.item_attributes.furnace_fuel.inverted": "不是燃料", - "create.item_attributes.in_tag": "標籤是%1$s", - "create.item_attributes.in_tag.inverted": "標籤不是%1$s", - "create.item_attributes.in_item_group": "屬於%1$s", - "create.item_attributes.in_item_group.inverted": "不屬於%1$s", - "create.item_attributes.added_by": "由%1$s添加", - "create.item_attributes.added_by.inverted": "不是由%1$s添加", - "create.item_attributes.has_enchant": "有附魔效果%1$s", - "create.item_attributes.has_enchant.inverted": "沒有附魔效果%1$s", - "create.item_attributes.has_fluid": "包含%1$s", - "create.item_attributes.has_fluid.inverted": "不包含%1$s", - "create.item_attributes.has_name": "有自定義名稱%1$s", - "create.item_attributes.has_name.inverted": "沒有自定義名稱%1$s", - "create.item_attributes.book_author": "由%1$s編寫", - "create.item_attributes.book_author.inverted": "未由%1$s編寫", - "create.item_attributes.book_copy_original": "是原創的", - "create.item_attributes.book_copy_original.inverted": "不是原創的", - "create.item_attributes.book_copy_first": "是第一份複製", - "create.item_attributes.book_copy_first.inverted": "不是第一份複製", - "create.item_attributes.book_copy_second": "是第二份複製", - "create.item_attributes.book_copy_second.inverted": "不是第二份複製", - "create.item_attributes.book_copy_tattered": "是第三份複製", - "create.item_attributes.book_copy_tattered.inverted": "不是第三份複製", - "create.item_attributes.astralsorcery_crystal": "具有晶體屬性%1$s", - "create.item_attributes.astralsorcery_crystal.inverted": "不具有晶體屬性%1$s", - "create.item_attributes.astralsorcery_constellation": "與%1$s調諧", - "create.item_attributes.astralsorcery_constellation.inverted": "未與%1$s調諧", - "create.item_attributes.astralsorcery_perk_gem": "具有特殊屬性%1$s", - "create.item_attributes.astralsorcery_perk_gem.inverted": "不具有特殊屬性%1$s", - "create.item_attributes.astralsorcery_amulet": "提升%1$s", - "create.item_attributes.astralsorcery_amulet.inverted": "不提升%1$s", - - "create.gui.attribute_filter.no_selected_attributes": "沒有標記任何屬性", - "create.gui.attribute_filter.selected_attributes": "已選擇的屬性:", - "create.gui.attribute_filter.add_attribute": "向列表中添加屬性", - "create.gui.attribute_filter.add_inverted_attribute": "向列表中添加相反屬性", - "create.gui.attribute_filter.allow_list_disjunctive": "任意比對白名單(任何)", - "create.gui.attribute_filter.allow_list_disjunctive.description": "只要有其中一項屬性符合,就可以通過", - "create.gui.attribute_filter.allow_list_conjunctive": "全部比對白名單(全部)", - "create.gui.attribute_filter.allow_list_conjunctive.description": "只有所有屬性都相符才可以通過", - "create.gui.attribute_filter.deny_list": "黑名單", - "create.gui.attribute_filter.deny_list.description": "只要沒有上述屬性,就可以通過", - "create.gui.attribute_filter.add_reference_item": "添加參考物品", - - "create.tooltip.holdKey": "按住 [%1$s]", - "create.tooltip.holdKeyOrKey": "按住 [%1$s] 或 [%2$s]", - "create.tooltip.keyShift": "Shift", - "create.tooltip.keyCtrl": "Ctrl", - "create.tooltip.speedRequirement": "需求速度:%1$s", - "create.tooltip.speedRequirement.none": "無", - "create.tooltip.speedRequirement.medium": "適當", - "create.tooltip.speedRequirement.high": "快", - "create.tooltip.stressImpact": "動能消耗:%1$s", - "create.tooltip.stressImpact.low": "低", - "create.tooltip.stressImpact.medium": "中", - "create.tooltip.stressImpact.high": "高", - "create.tooltip.stressImpact.overstressed": "過載", - "create.tooltip.capacityProvided": "動能生產量:%1$s", - "create.tooltip.capacityProvided.low": "小", - "create.tooltip.capacityProvided.medium": "中", - "create.tooltip.capacityProvided.high": "大", - "create.tooltip.capacityProvided.asGenerator":"(作為產生器)", - "create.tooltip.generationSpeed": "產生%1$s %2$s", - "create.tooltip.analogStrength": "調節強度:%1$s/15", - - "create.mechanical_arm.extract_from": "從%1$s 拿取物品", - "create.mechanical_arm.deposit_to": "向%1$s 儲存物品", - "create.mechanical_arm.summary": "機械手臂有%1$s 輸入以及 %2$s 輸出。", - "create.mechanical_arm.points_outside_range":"%1$s 由於距離限制,選定的交互點被移除。", - - "create.logistics.when_multiple_outputs_available": "當多個輸出可用時", - - "create.mechanical_arm.selection_mode.round_robin": "輪詢調度", - "create.mechanical_arm.selection_mode.forced_round_robin": "強制輪詢調度", - "create.mechanical_arm.selection_mode.prefer_first": "第一目標優先", - - "create.tunnel.selection_mode.split": "分攤", - "create.tunnel.selection_mode.forced_split": "強制分攤", - "create.tunnel.selection_mode.round_robin": "輪詢調度", - "create.tunnel.selection_mode.forced_round_robin": "強制輪詢調度", - "create.tunnel.selection_mode.prefer_nearest": "最近優先", - "create.tunnel.selection_mode.randomize": "隨機", - "create.tunnel.selection_mode.synchronize": "同步輸入", - - "create.tooltip.chute.header": "滑道訊息", - "create.tooltip.chute.items_move_down": "物品向下移動", - "create.tooltip.chute.items_move_up": "物品向上移動", - "create.tooltip.chute.no_fans_attached": "未安裝鼓風機", - "create.tooltip.chute.fans_push_up": "鼓風機從下方進行推動", - "create.tooltip.chute.fans_push_down": "鼓風機從上方進行推動", - "create.tooltip.chute.fans_pull_up": "鼓風機從下方進行吸引", - "create.tooltip.chute.fans_pull_down": "鼓風機從上方進行吸引", - - "create.hint.mechanical_arm_no_targets.title": "沒有目標", - "create.hint.mechanical_arm_no_targets": "看起來這個_機械手臂_沒有被分配任何_目標_。在手持機械手臂的同時,右鍵選取輸送帶、置物臺、漏斗或其他設備來設定目標。", - "create.hint.horizontal_funnel.title": "水平漏斗", - "create.hint.horizontal_funnel": "無法_直接_在兩個庫存間移動物品。試著使用輸送帶或者置物臺來從庫存中提取物品。", - "create.hint.upward_funnel.title": "漏斗向上", - "create.hint.upward_funnel": "只可以傳送由_機械手臂_,鼓風機驅動的_滑道_或者被投擲的物品。試著做一些滑道來垂直輸送物品。", - "create.hint.empty_bearing.title": "更新軸承", - "create.hint.empty_bearing": "_空手右鍵_軸承來_添加_你新建造的結構。", - "create.hint.full_deployer.title": "機械手物品溢出", - "create.hint.full_deployer": "_機械手_包含_過剩的物品_需要被_提取._使用_漏斗,__漏斗_或其他方法將溢出解決。", - - "create.gui.config.overlay1": "嗨 :)", - "create.gui.config.overlay2": "這是一個實例層", - "create.gui.config.overlay3": "點擊拖拽你的滑鼠", - "create.gui.config.overlay4": "來將它移動到前方", - "create.gui.config.overlay5": "ESC退出目前界面", - "create.gui.config.overlay6": "並儲存新的位置", - "create.gui.config.overlay7": "輸入/create overlay reset", - "create.gui.config.overlay8": "重置到預設位置", - - "create.command.killTPSCommand": "killtps", - "create.command.killTPSCommand.status.slowed_by.0": "[Create]: 伺服器每秒TICK被降為 %s ms :o", - "create.command.killTPSCommand.status.slowed_by.1": "[Create]: 伺服器現在每秒TICK被降為 >:)", - "create.command.killTPSCommand.status.slowed_by.2": "[Create]: 伺服器現在不延遲了,TPS正常 :D", - "create.command.killTPSCommand.status.usage.0": "[Create]: 用 /killtps stop 來讓伺服器的TPS速度恢復正常", - "create.command.killTPSCommand.status.usage.1": "[Create]: 用 /killtps start 來手動降低伺服器TPS", - "create.command.killTPSCommand.argument.tickTime": "tickTime", - - "create.subtitle.schematicannon_launch_block": "藍圖大炮發射", - "create.subtitle.schematicannon_finish": "藍圖大炮完成任務", - "create.subtitle.slime_added": "黏液擠壓", - "create.subtitle.mechanical_press_activation": "液壓機工作", - "create.subtitle.mechanical_press_item_break": "金屬碰撞", - "create.subtitle.blockzapper_place": "放置方塊", - "create.subtitle.blockzapper_confirm": "選擇方塊", - "create.subtitle.blockzapper_deny": "放置失敗", - "create.subtitle.block_funnel_eat": "漏斗吸收", - "create.subtitle.blaze_munch": "烈焰使者開心地吃著", - - - "_": "->------------------------] Item Descriptions [------------------------<-", - - "item.create.example_item.tooltip": "EXAMPLE ITEM (just a marker that this tooltip exists)", - "item.create.example_item.tooltip.summary": "A brief description of the item._Underscores_highlight a term.", - "item.create.example_item.tooltip.condition1": "When this", - "item.create.example_item.tooltip.behaviour1": "Then this item does this。(behaviours show on shift)", - "item.create.example_item.tooltip.condition2": "And When this", - "item.create.example_item.tooltip.behaviour2": "You can add as many behaviours as you like", - "item.create.example_item.tooltip.control1": "When Ctrl pressed", - "item.create.example_item.tooltip.action1": "These controls are displayed.", - - "block.create.andesite_encased_shaft.tooltip": "安山岩傳動軸箱", - "block.create.andesite_encased_shaft.tooltip.summary": "_創造模式_物品。用安山岩機殼包覆世界中的傳動軸,將不會消耗機殼。", - - "block.create.brass_encased_shaft.tooltip": "黃銅傳動軸箱", - "block.create.brass_encased_shaft.tooltip.summary": "_創造模式_物品。用黃銅機殼包覆世界中的傳動軸,將不會消耗機殼。", - - "block.create.wooden_bracket.tooltip": "木製支架", - "block.create.wooden_bracket.tooltip.summary": "用來裝飾_傳動軸_,_齒輪_和_管道_。", - - "block.create.metal_bracket.tooltip": "金屬支架", - "block.create.metal_bracket.tooltip.summary": "用來裝飾_傳動軸_,_齒輪_和_管道_。", - - "block.create.andesite_casing.tooltip": "安山機殼", - "block.create.andesite_casing.tooltip.summary": "具多種用途簡易機殼,可用來加固並裝飾_傳動軸_,_輸送帶_", - - "block.create.andesite_funnel.tooltip": "安山漏斗", - "block.create.andesite_funnel.tooltip.summary": "一種常用的傳輸裝置,配合各種物流結構傳輸物品,可由_紅石訊號_控制。", - "block.create.andesite_funnel.tooltip.condition1": "一般形態", - "block.create.andesite_funnel.tooltip.behaviour1": "開口的面會吸收面前的_掉落物_,並_傳輸_到它所附著的_容器_裡。", - "block.create.andesite_funnel.tooltip.condition2": "安裝在輸送帶、置物臺等結構上時,會轉為附著形態", - "block.create.andesite_funnel.tooltip.behaviour2": "從容器中向輸送帶、置物臺放置物品,或從中收集物品到容器中。", - "block.create.andesite_funnel.tooltip.condition3": "垂直放置於兩個容器之間時", - "block.create.andesite_funnel.tooltip.behaviour3": "僅向下垂直傳輸物品,類似一個沒有緩衝空間的漏斗。", - - "block.create.andesite_tunnel.tooltip": "安山物品隧道", - "block.create.andesite_tunnel.tooltip.summary": "輸送帶的保護隧道,能讓你的流水線優雅的穿過牆壁。", - "block.create.andesite_tunnel.tooltip.control1": "板手右鍵側面時", - "block.create.andesite_tunnel.tooltip.action1": "如果輸送帶隧道串連的數量達到三個或以上,可在位於中間的隧道側面上開啟或關閉百葉窗。", - - "block.create.brass_funnel.tooltip": "黃銅漏斗", - "block.create.brass_funnel.tooltip.summary": "一種常用的傳輸裝置,配合各種物流結構傳輸物品,可由_紅石訊號_控制,並附有過濾插槽", - "block.create.brass_funnel.tooltip.condition1": "一般形態", - "block.create.brass_funnel.tooltip.behaviour1": "開口的面會吸收面前的_掉落物_,並_傳輸_到它所附著的_容器_里。", - "block.create.brass_funnel.tooltip.condition2": "安裝在輸送帶、置物臺等結構上時", - "block.create.brass_funnel.tooltip.behaviour2": "從容器中向輸送帶、置物臺放置物品,或從中收集物品到容器中。", - "block.create.brass_funnel.tooltip.condition3": "垂直放置於兩個容器之間時", - "block.create.brass_funnel.tooltip.behaviour3": "向下垂直傳輸物品,類似一個沒有緩衝空間的漏斗。", - - "block.create.brass_tunnel.tooltip": "黃銅物品隧道", - "block.create.brass_tunnel.tooltip.summary": "_黃銅物品隧道_擁有_過濾_,_分流_輸送帶上物品的功能。", - "block.create.brass_tunnel.tooltip.condition1": "將它們_並排放置_時", - "block.create.brass_tunnel.tooltip.behaviour1": "相鄰的_黃銅物品隧道_可以讓輸送帶路線上穿過的物品_重定向_到與其並排的輸送帶路線上。", - "block.create.brass_tunnel.tooltip.condition2": "過濾", - "block.create.brass_tunnel.tooltip.behaviour2": "_黃銅物品隧道_的_輸入_方向和_輸出_方向都帶有過濾插槽。如果進入的物品不滿足隧道輸出端的過濾條件,則該物品會從並排的其他隧道出口傳出。", - "block.create.brass_tunnel.tooltip.condition3": "分流", - "block.create.brass_tunnel.tooltip.behaviour3": "_黃銅物品隧道_可以為並排的輸送帶路線提供多個物品分流的方案。", - "block.create.brass_tunnel.tooltip.control1": "扳手右鍵側面時", - "block.create.brass_tunnel.tooltip.action1": "如果輸送帶隧道串聯的數量達到三個或以上,可在位於中間的隧道側面上開啟關閉百葉窗。", - "block.create.brass_tunnel.tooltip.control2": "手持扳手在隧道頂部滾動滑鼠滾輪", - "block.create.brass_tunnel.tooltip.action2": "更改_隧道_的分流模式。", - - "block.create.copper_casing.tooltip": "銅製機殼", - "block.create.copper_casing.tooltip.summary": "具備多種用途的堅固機殼,也可用於裝飾。", - "block.create.copper_casing.tooltip.condition1": "對流體管道使用時", - "block.create.copper_casing.tooltip.behaviour1": "會把管道裝入機殼,裝進機殼的管道會與其他管道分開,以免它們自動相連。", - - "block.create.encased_fluid_pipe.tooltip": "流體管道箱", - "block.create.encased_fluid_pipe.tooltip.summary": "用銅機殼加固后的液體管道。", - - "block.create.copper_valve_handle.tooltip": "銅閥門開關", - "block.create.copper_valve_handle.tooltip.summary": "精確的機械來源,需要玩家手動操作。注意不要讓自己太累!", - "block.create.copper_valve_handle.tooltip.condition1": "右鍵使用時", - "block.create.copper_valve_handle.tooltip.behaviour1": "為連接的設備提供機械。潛行狀態下反向旋轉。", - - "block.create.seat.tooltip": "坐墊", - "block.create.seat.tooltip.summary": "坐下來享受旅程吧!坐墊將會把玩家固定在一個移動裝置上。也可以用來作為居家裝飾,畢竟他有許多顏色。", - "block.create.seat.tooltip.condition1": "對坐墊右鍵", - "block.create.seat.tooltip.behaviour1": "玩家將坐在_坐墊_上,Left-Shift可離開_坐墊_。", - - "block.create.chute.tooltip": "滑道", - "block.create.chute.tooltip.summary": "用來_收集_物品並_垂直運輸_它們。可以從_容器_中抽取也可向_容器_輸入。它的側面可以被_漏斗_、_裝配的安山岩漏斗_和_裝配的黃銅漏斗_等傳輸設備交互", - "block.create.chute.tooltip.condition1": "當被上方的鼓風機通風時", - "block.create.chute.tooltip.behaviour1": "由_鼓風機_驅動的_滑道_可由下向上傳輸_物品_,可以從_置物臺_或者_輸送帶_上吸取物品。", - - "block.create.depot.tooltip": "置物臺", - "block.create.depot.tooltip.summary": "一個方便的放置物品的地方。它為多臺機器提供了一個交互點", - "block.create.depot.tooltip.condition1": "右鍵置物臺", - "block.create.depot.tooltip.behaviour1": "可以在_置物臺_放置或取出物品。可以與_輸送帶_交互的方塊或裝置也可以與_置物臺_交互。", - - "item.create.blaze_cake.tooltip": "熔岩蛋糕", - "item.create.blaze_cake.tooltip.summary": "對辛苦的_烈焰使者_的美味款待。讓他們興奮起來吧!", - - "item.create.empty_blaze_burner.tooltip": "空的烈焰使者動力爐", - "item.create.empty_blaze_burner.tooltip.summary": "你火熱的朋友的一個小小的鐵質的家。我相信你會好好利用他們的!", - "item.create.empty_blaze_burner.tooltip.condition1": "當對著烈焰使者或烈焰使者刷怪籠使用時", - "item.create.empty_blaze_burner.tooltip.behaviour1": "即可_捕獲_烈焰使者", - - "block.create.fluid_pipe.tooltip": "液體管道", - "block.create.fluid_pipe.tooltip.summary": "用來傳輸_液體_。需要一個_機械泵_來提供壓強。", - "block.create.fluid_pipe.tooltip.condition1": "轉移液體", - "block.create.fluid_pipe.tooltip.behaviour1": "可以與_液體容器_如_儲存罐_或_作業盆_相連_。裸露的_管道_末端也可以排放或抽取液體。注意別漏水了!", - "block.create.fluid_pipe.tooltip.control1": "使用扳手右鍵", - "block.create.fluid_pipe.tooltip.action1": "如果可能的話,在管道側面開啟/關閉窗口。", - - "block.create.hose_pulley.tooltip": "軟管滑輪", - "block.create.hose_pulley.tooltip.summary": "用來在_世界_中放置或排放大量的液體。", - "block.create.hose_pulley.tooltip.condition1": "接入機械時", - "block.create.hose_pulley.tooltip.behaviour1": "升高或降低軟管,軟管的位置決定了抽取或填充液體的高度。", - "block.create.hose_pulley.tooltip.condition2": "當軟管滑輪抽取液體時", - "block.create.hose_pulley.tooltip.behaviour2": "開始從軟管末端將其從中取出_液體方塊_。巨大的液體湖將被認定是_無限_的", - "block.create.hose_pulley.tooltip.condition3": "當液體從軟管滑輪中排出時", - "block.create.hose_pulley.tooltip.behaviour3": "開始向世界填充液體,直到達到_軟管末端_的高度。", - - "block.create.fluid_tank.tooltip": "液體儲存罐", - "block.create.fluid_tank.tooltip.summary": "_儲存_任意_液體_", - "block.create.fluid_tank.tooltip.condition1": "使用扳手右鍵", - "block.create.fluid_tank.tooltip.behaviour1": "改變可選窗口", - - "block.create.creative_fluid_tank.tooltip": "創造液體儲存罐", - "block.create.creative_fluid_tank.tooltip.summary": "此液體儲存罐能夠_無限的復制_任何液體。", - "block.create.creative_fluid_tank.tooltip.condition1": "罐中裝有液體時", - "block.create.creative_fluid_tank.tooltip.behaviour1": "任意的_液體提取設備_能夠從中提取無窮無盡的指定液體,液體的導入功能同時也會無效。", - "block.create.creative_fluid_tank.tooltip.condition2": "扳手右擊時", - "block.create.creative_fluid_tank.tooltip.behaviour2": "打開關閉窗戶", - - "block.create.fluid_valve.tooltip": "液體閥門", - "block.create.fluid_valve.tooltip.summary": "阻止液體沿管道向前流動。", - "block.create.fluid_valve.tooltip.condition1": "控制流量", - "block.create.fluid_valve.tooltip.behaviour1": "施加的_旋轉力_將迫使閥門關閉,從而阻止液體流動。_逆轉旋轉方向_以重新打開閥門。", - - "block.create.mechanical_pump.tooltip": "機械泵", - "block.create.mechanical_pump.tooltip.summary": "_接入機械_,能迫使液體_沿管道指定方向移動_。在兩個方向上都有_最大的作用範圍_。(默認為16個方塊距離)", - "block.create.mechanical_pump.tooltip.condition1": "液體流向", - "block.create.mechanical_pump.tooltip.behaviour1": "_接入機械_后會產生壓力,迫使液體通過管道。_反轉機械_的方向以切換液體_流向_。", - "block.create.mechanical_pump.tooltip.control1": "扳手右鍵時", - "block.create.mechanical_pump.tooltip.action1": "反轉泵的方向,從而改變默認的液體流向", - - "block.create.smart_fluid_pipe.tooltip": "智慧液體管道", - "block.create.smart_fluid_pipe.tooltip.summary": "帶有過濾器的_液體管道_。可以指定通過哪個_液體_。", - "block.create.smart_fluid_pipe.tooltip.condition1": "當液體進入時", - "block.create.smart_fluid_pipe.tooltip.behaviour1": "進入的液體與_過濾器_不匹配時,智慧管道將_阻止_其通過。", - "block.create.smart_fluid_pipe.tooltip.condition2": "與_液體容器相鄰_時", - "block.create.smart_fluid_pipe.tooltip.behaviour2": "從_任何容器_開始流動的_智慧管道_只會抽取與其過濾器匹配的液體。", - - "block.create.spout.tooltip": "注液器", - "block.create.spout.tooltip.summary": "一種用來_裝罐_的機器。", - "block.create.spout.tooltip.condition1": "液體傳輸", - "block.create.spout.tooltip.behaviour1": "當下方放置類似_玻璃瓶_,_桶_這樣的液體容器物品時,注液器將試圖將自身儲存的液體注入到下方的_液體容器物品_中。", - "block.create.spout.tooltip.condition2": "液體自動化", - "block.create.spout.tooltip.behaviour2": "注液器位於_輸送帶_或者_置物臺_上方時,將自動為流水線上的_液體容器物品_進行_注入_。", - - "block.create.item_drain.tooltip": "分液池", - "block.create.item_drain.tooltip.summary": "一種用來_抽空液體容器物品_的置物臺", - "block.create.item_drain.tooltip.condition1": "液體傳輸", - "block.create.item_drain.tooltip.behaviour1": "當從側面導入諸如_桶_或_瓶子_之類的_液體容器物品_時,_分液池_將嘗試將其倒入其_自身的液體庫存_中。空的_液體容器物品_將被彈出至_另一側_。", - - "block.create.mechanical_arm.tooltip": "機械臂", - "block.create.mechanical_arm.tooltip.summary": "移動_物品_的高級裝置", - "block.create.mechanical_arm.tooltip.condition1": "轉移物品", - "block.create.mechanical_arm.tooltip.behaviour1": "可以從任意_可夠到的設備_中拿取或放置物品,比如說_輸送帶_,_置物臺_,_漏斗_以及_機械合成器_。", - "block.create.mechanical_arm.tooltip.control1": "手持時", - "block.create.mechanical_arm.tooltip.action1": "右鍵單擊一個_可獲取的容器_來將其設置為_機械臂_的_輸入端_。右鍵雙擊將其設置為_機械臂_的_輸出端_。", - "block.create.mechanical_arm.tooltip.control2": "手持扳手滾動滾輪", - "block.create.mechanical_arm.tooltip.action2": "調整_機械臂_輸出物品時的調度模式。", - - "item.create.wand_of_symmetry.tooltip": "對稱杖", - "item.create.wand_of_symmetry.tooltip.summary": "完美地鏡面復制工作區域內的方塊放置於破壞", - "item.create.wand_of_symmetry.tooltip.condition1": "當在熱鍵欄時", - "item.create.wand_of_symmetry.tooltip.behaviour1": "持續進行鏡面復制", - "item.create.wand_of_symmetry.tooltip.control1": "當右鍵地面時", - "item.create.wand_of_symmetry.tooltip.action1": "_創建_或_移動_鏡子", - "item.create.wand_of_symmetry.tooltip.control2": "當右鍵空氣時", - "item.create.wand_of_symmetry.tooltip.action2": "_刪除_鏡子", - "item.create.wand_of_symmetry.tooltip.control3": "當潛行右鍵時", - "item.create.wand_of_symmetry.tooltip.action3": "打開_gui界面_", - - "item.create.handheld_blockzapper.tooltip": "方塊放置器", - "item.create.handheld_blockzapper.tooltip.summary": "新穎的小工具,可以遠距離放置或更換方塊。", - "item.create.handheld_blockzapper.tooltip.control1": "當左鍵方塊時", - "item.create.handheld_blockzapper.tooltip.action1": "設定放置此方塊。", - "item.create.handheld_blockzapper.tooltip.control2": "當右鍵方塊時", - "item.create.handheld_blockzapper.tooltip.action2": "_放置_或_替換_目標方塊。", - "item.create.handheld_blockzapper.tooltip.control3": "當潛行右鍵時", - "item.create.handheld_blockzapper.tooltip.action3": "打開_gui界面_", - - "item.create.handheld_worldshaper.tooltip": "環境塑形器", - "item.create.handheld_worldshaper.tooltip.summary": "_大面積_更改地形的手持工具", - "item.create.handheld_worldshaper.tooltip.control1": "當左鍵方塊時", - "item.create.handheld_worldshaper.tooltip.action1": "設定放置此方塊", - "item.create.handheld_worldshaper.tooltip.control2": "當右鍵方塊時", - "item.create.handheld_worldshaper.tooltip.action2": "_放置_或_替換_目標方塊", - "item.create.handheld_worldshaper.tooltip.control3": "當潛行右鍵時", - "item.create.handheld_worldshaper.tooltip.action3": "打開工具的_gui界面_", - - "item.create.tree_fertilizer.tooltip": "樹木肥料", - "item.create.tree_fertilizer.tooltip.summary": "適用來常見樹木的快速肥料", - "item.create.tree_fertilizer.tooltip.condition1": "在樹苗上使用時", - "item.create.tree_fertilizer.tooltip.behaviour1": "無論_生長時間_多少,直接長大", - - "item.create.deforester.tooltip": "連根拔樹斧", - "item.create.deforester.tooltip.summary": "_連根拔樹斧_,從最根砍樹時,能夠瞬間連根拔起一棵樹", - - "item.create.extendo_grip.tooltip": "伸縮機械手", - "item.create.extendo_grip.tooltip.summary": "biubiubiu! 大幅度_增加了_使用者的_觸碰距離_。", - "item.create.extendo_grip.tooltip.condition1": "放置於副手欄時", - "item.create.extendo_grip.tooltip.behaviour1": "大幅增加_主手_的觸碰距離,與_主手_的伸縮機械手攜同使用,可進一步增加_觸碰距離_。", - - "item.create.filter.tooltip": "過濾器", - "item.create.filter.tooltip.summary": "將物品更精確地進行_篩選分類_,可以同時_篩選_多個物品或者將已標記的_過濾器_放在另一個_過濾器_里_嵌套_使用。", - "item.create.filter.tooltip.condition1": "放置於過濾插槽中時", - "item.create.filter.tooltip.behaviour1": "根據_過濾器_的配置,來_決定_物品是否能夠通過", - "item.create.filter.tooltip.condition2": "當右鍵時", - "item.create.filter.tooltip.behaviour2": "打開_配置面板_", - - "item.create.attribute_filter.tooltip": "屬性過濾器", - "item.create.attribute_filter.tooltip.summary": "比起普通過濾器,_屬性過濾器_可以根據不同物品的_屬性_來進行過濾", - "item.create.attribute_filter.tooltip.condition1": "放置於過濾插槽中時", - "item.create.attribute_filter.tooltip.behaviour1": "根據_過濾器_的配置,來_決定_物品是否能夠通過", - "item.create.attribute_filter.tooltip.condition2": "當右鍵時", - "item.create.attribute_filter.tooltip.behaviour2": "打開_配置面板_", - - "item.create.empty_schematic.tooltip": "空白藍圖", - "item.create.empty_schematic.tooltip.summary": "可作為合成材料或在_藍圖桌_使用", - - "item.create.schematic.tooltip": "藍圖", - "item.create.schematic.tooltip.summary": "將工程結構的_全息圖_放置於_世界中_,並使用_藍圖加農炮_進行構建。", - "item.create.schematic.tooltip.condition1": "當全息圖存在時", - "item.create.schematic.tooltip.behaviour1": "可以使用屏幕上的工具調整位置", - "item.create.schematic.tooltip.control1": "當潛行右鍵時", - "item.create.schematic.tooltip.action1": "打開一個用來輸入_精確坐標_的界面。", - - "item.create.schematic_and_quill.tooltip": "藍圖與筆", - "item.create.schematic_and_quill.tooltip.summary": "用來將世界中的結構保存到.nbt文件。", - "item.create.schematic_and_quill.tooltip.condition1": "第一步", - "item.create.schematic_and_quill.tooltip.behaviour1": "手持藍圖與右鍵旋轉兩個點", - "item.create.schematic_and_quill.tooltip.condition2": "第二步", - "item.create.schematic_and_quill.tooltip.behaviour2": "按住Ctrl滑鼠滾輪選擇選區大小,右鍵空白處保存。", - "item.create.schematic_and_quill.tooltip.control1": "右鍵", - "item.create.schematic_and_quill.tooltip.action1": "選取點/確認保存", - "item.create.schematic_and_quill.tooltip.control2": "按住Ctrl滑鼠滾輪", - "item.create.schematic_and_quill.tooltip.action2": "在_空中_選擇點滾動以調整距離。", - "item.create.schematic_and_quill.tooltip.control3": "當潛行右鍵時", - "item.create.schematic_and_quill.tooltip.action3": "_重置_並刪除選區。", - - "block.create.schematicannon.tooltip": "藍圖加農炮", - "block.create.schematicannon.tooltip.summary": "通過發射方塊以在世界中重新構建已部署的_全息圖_,使用相鄰箱子中的物品及_火藥_作為燃料。", - "block.create.schematicannon.tooltip.control1": "當右鍵時", - "block.create.schematicannon.tooltip.action1": "打開_gui界面_", - - "block.create.schematic_table.tooltip": "藍圖桌", - "block.create.schematic_table.tooltip.summary": "將保存的藍圖圖寫入_空白藍圖_", - "block.create.schematic_table.tooltip.condition1": "放入空白藍圖時", - "block.create.schematic_table.tooltip.behaviour1": "從Schematics文件夾上傳所選文件", - - "block.create.shaft.tooltip": "傳動軸", - "block.create.shaft.tooltip.summary": "將_旋轉動能_進行直線傳遞。", - - "block.create.cogwheel.tooltip": "齒輪", - "block.create.cogwheel.tooltip.summary": "將_旋轉動能_進行直線傳遞,或者傳遞到鄰近的_齒輪_上", - - "block.create.large_cogwheel.tooltip": "大齒輪", - "block.create.large_cogwheel.tooltip.summary": "大號齒輪傳動結構,連接到_小號齒輪_時改變其_轉速_。", - - "block.create.encased_shaft.tooltip": "傳動軸箱", - "block.create.encased_shaft.tooltip.summary": "將_旋轉動能_進行直線傳遞,其方塊體積使其在穿過牆體時更加_美觀_。", - - "block.create.gearbox.tooltip": "齒輪箱", - "block.create.gearbox.tooltip.summary": "十字傳動旋轉結構,同時將直線旋轉方向_反轉_。", - - "block.create.gearshift.tooltip": "換擋齒輪箱", - "block.create.gearshift.tooltip.summary": "用來反轉傳動軸_旋轉方向_的開關。", - "block.create.gearshift.tooltip.condition1": "當提供紅石訊號時", - "block.create.gearshift.tooltip.behaviour1": "_更改_旋轉方向。", - - "block.create.clutch.tooltip": "離合器", - "block.create.clutch.tooltip.summary": "傳動開關裝置。", - "block.create.clutch.tooltip.condition1": "當提供紅石訊號時", - "block.create.clutch.tooltip.behaviour1": " _停止_ 另一側的旋轉。", - - "block.create.encased_chain_drive.tooltip": "鏈式傳動箱", - "block.create.encased_chain_drive.tooltip.summary": "將動能_鏈式傳遞_給側面相貼的_鏈式傳動箱_,呈_直線_放置形成鏈式傳動箱組,它們的朝向不必一致。", - "block.create.encased_chain_drive.tooltip.condition1": "互相連接時", - "block.create.encased_chain_drive.tooltip.behaviour1": "_鏈式傳動箱組_中的_鏈式傳動箱_將以相同的速度旋轉。", - - "block.create.adjustable_chain_gearshift.tooltip": "可調節鏈式傳動箱", - "block.create.adjustable_chain_gearshift.tooltip.summary": "將動能_鏈式傳遞_給側面相貼的_鏈式傳動箱_,呈_直線_放置形成鏈式傳動箱組,可通過_紅石訊號_改變其內部主齒輪的半徑大小從而提高其耦合齒輪的_轉速_,進而提高其_連攜_的其它_鏈式傳動箱_的_轉速_。", - "block.create.adjustable_chain_gearshift.tooltip.condition1": "紅石控制", - "block.create.adjustable_chain_gearshift.tooltip.behaviour1": "沒有紅石訊號時,_鏈式傳動箱組_中的_鏈式傳動箱_將以相同的速度旋轉。紅石訊號拉滿時,_鏈式傳動箱組_中除自身以外的_鏈式傳動箱_將以兩倍的速度旋轉。介於兩者之間的任何結果都將使其速度提高1-2倍。", - - "item.create.belt_connector.tooltip": "輸送帶", - "item.create.belt_connector.tooltip.summary": "用_輸送帶_連接兩個_傳動軸_,連接的傳動軸將具有完全相同的轉速和方向。輸送帶可以_傳輸實體_和_物品_。", - "item.create.belt_connector.tooltip.control1": "當右鍵傳動軸時", - "item.create.belt_connector.tooltip.action1": "選擇傳動軸作為輸送帶的傳輸點,選定的兩個傳動軸都必須相互_垂直_,_水平_或_對角平齊_。", - "item.create.belt_connector.tooltip.control2": "當潛行右鍵時", - "item.create.belt_connector.tooltip.action2": "_重置_輸送帶的第一個選定位置", - - "item.create.goggles.tooltip": "MR護目鏡", - "item.create.goggles.tooltip.summary": "一副特殊的眼鏡,能夠讓你看見_動能_的信息。", - "item.create.goggles.tooltip.condition1": "當裝備後", - "item.create.goggles.tooltip.behaviour1": "將會展示該機械元件的_速度_、_動能_等數值", - "item.create.goggles.tooltip.condition2": "當裝備後看向儀表時", - "item.create.goggles.tooltip.behaviour2": "將會展示該儀表所連接網路的_速度_、_動能_等數值。", - - "item.create.wrench.tooltip": "板手", - "item.create.wrench.tooltip.summary": "一種常用的工具,能夠調整_動能_的_方向_、_配置_等。", - "item.create.wrench.tooltip.control1": "當右鍵點擊_動能元件_時", - "item.create.wrench.tooltip.action1": "以點擊的面為軸心_旋轉_點擊的方塊", - "item.create.wrench.tooltip.control2": "當潛行右鍵時", - "item.create.wrench.tooltip.action2": "將物品_取下_並移動到你的背包中。", - - "block.create.creative_motor.tooltip": "創造馬達", - "block.create.creative_motor.tooltip.summary": "可以獲得_無限動能_", - - "block.create.water_wheel.tooltip": "水車", - "block.create.water_wheel.tooltip.summary": "從相鄰的流水中獲得動能", - - "block.create.encased_fan.tooltip": "鼓風機", - "block.create.encased_fan.tooltip.summary": "有多種用途,主要可以將_機械_和_風力_進行互相轉換。", - "block.create.encased_fan.tooltip.condition1": "當被紅石訊號激活后", - "block.create.encased_fan.tooltip.behaviour1": "可將鼓風機下方的_熱能_(火、熔岩等)轉化成_動能_,需要將鼓風機向下擺放", - "block.create.encased_fan.tooltip.condition2": "接入機械時", - "block.create.encased_fan.tooltip.behaviour2": "根據旋轉方向_推動_或者_吸引_實體,強度和速度取決於給予的機械。", - "block.create.encased_fan.tooltip.condition3": "當氣流通過火、水、熔岩時", - "block.create.encased_fan.tooltip.behaviour3": "在_被吹出_的水,火,熔岩粒子中放置物品會獲得相應產物(_建議配合jei查看_)。", - - "block.create.nozzle.tooltip": "分散網", - "block.create.nozzle.tooltip.summary": "依附在鼓風機上,能夠將鼓風機的效果_分散_各個方向。", - - "block.create.hand_crank.tooltip": "手搖把手", - "block.create.hand_crank.tooltip.summary": "簡單的動能來源,需要_人工轉動_,不要讓自己累倒了!", - "block.create.hand_crank.tooltip.condition1": "當使用時", - "block.create.hand_crank.tooltip.behaviour1": "向依附的結構提供動能,_潛行_時將會提供_反向_的動能", - - "block.create.cuckoo_clock.tooltip": "布穀鳥鐘", - "block.create.cuckoo_clock.tooltip.summary": "精美的布穀鳥鐘,能夠報時", - "block.create.cuckoo_clock.tooltip.condition1": "連接機械時", - "block.create.cuckoo_clock.tooltip.behaviour1": "顯示_現在時間_且一天會報時_兩次_。中午一次,黃昏可以睡覺時一次 ", - - "block.create.turntable.tooltip": "轉盤", - "block.create.turntable.tooltip.summary": "讓旋轉機械給你帶來一場刺激的旋轉風車體驗。", - - "block.create.millstone.tooltip": "石磨", - "block.create.millstone.tooltip.summary": "一個能_研磨物品_的動能裝置,可以被臨近的_齒輪_供能,或者可以在底部用傳動軸供能,成品必須被提取出石磨", - "block.create.millstone.tooltip.condition1": "當旋轉運作時", - "block.create.millstone.tooltip.behaviour1": "開始根據_研磨配方_來處理物品。", - "block.create.millstone.tooltip.condition2": "當右鍵時", - "block.create.millstone.tooltip.behaviour2": "手動取出研磨后的成品。", - - "block.create.crushing_wheel.tooltip": "粉碎輪", - "block.create.crushing_wheel.tooltip.summary": "一對能夠_粉碎一切_的粉碎輪。向這對粉碎輪提供_向內_且_相反的動能_後開始工作", - "block.create.crushing_wheel.tooltip.condition1": "當兩個粉碎輪一起工作時", - "block.create.crushing_wheel.tooltip.behaviour1": "_粉碎物品_並獲得產物(請使用JEI查看對應的產物)", - - "block.create.mechanical_press.tooltip": "機械液壓機", - "block.create.mechanical_press.tooltip.summary": "一個強力的活塞式機器,壓扁其下面的物品。", - "block.create.mechanical_press.tooltip.condition1": "當輸入_紅石訊號_時", - "block.create.mechanical_press.tooltip.behaviour1": "_壓扁_其下方的物品。", - "block.create.mechanical_press.tooltip.condition2": "在輸送帶上方時", - "block.create.mechanical_press.tooltip.behaviour2": "_自動壓扁_經過輸送帶的物品。", - "block.create.mechanical_press.tooltip.condition3": "在_作業盆_上方時", - "block.create.mechanical_press.tooltip.behaviour3": "_壓縮_配方中允許壓縮的物品。", - - "block.create.basin.tooltip": "作業盆", - "block.create.basin.tooltip.summary": "一種_物品容器_,與_液壓機_和_攪拌機_配合使用,可以被_紅石比較器_檢測", - "block.create.basin.tooltip.condition1": "自動輸出", - "block.create.basin.tooltip.behaviour1": "當其他對應容器(例如輸送帶,其他的作業盆,置物臺等)在作業盆的一側下方時,它們將自動收集在作業盆中產出的任何物品/液體。自動化的好夥伴。", - - "block.create.blaze_burner.tooltip": "烈焰使者動力爐", - "block.create.blaze_burner.tooltip.summary": "一個用來加熱_作業盆_的設備,由烈焰使者來驅動。", - "block.create.blaze_burner.tooltip.condition1": "放置於作業盆下方時", - "block.create.blaze_burner.tooltip.behaviour1": "為作業盆_提供熱量_。", - "block.create.blaze_burner.tooltip.condition2": "對本爐使用可燃物時", - "block.create.blaze_burner.tooltip.behaviour2": "_消耗_可燃物,並根據該物在_熔爐中的燃燒時間_來延長_本爐的燃燒時間_,使用_熔岩蛋糕_將提供_更高的溫度_。", - - "block.create.reinforced_rail.tooltip": "強化鐵軌", - "block.create.reinforced_rail.tooltip.summary": "堅固的鐵軌,不需要_方塊的支撐_。", - - "block.create.mechanical_mixer.tooltip": "機械攪拌器", - "block.create.mechanical_mixer.tooltip.summary": "一種能夠動態進行攪拌的機器,需要穩定且足夠快的轉速,並且下方需要放置_作業盆_(中間需要一格高)", - "block.create.mechanical_mixer.tooltip.condition1": "當位於作業盆上方", - "block.create.mechanical_mixer.tooltip.behaviour1": "只要_作業盆_中有滿足配方的物品,將自動進行攪拌", - "block.create.mechanical_mixer.tooltip.control1": "被紅石激活時", - "block.create.mechanical_mixer.tooltip.action1": "停止攪拌,試用來緊急時刻!", - - "block.create.mechanical_crafter.tooltip": "機械合成器", - "block.create.mechanical_crafter.tooltip.summary": "一種依靠_動能_的_自動_合成臺。根據想要合成的物品的_合成表尺寸_來擺放_相應數量_的機械合成器,並且用扳手調整物品在合成器里的_傳動方向_以讓他們收束在一起合成並輸出", - "block.create.mechanical_crafter.tooltip.condition1": "接入機械時", - "block.create.mechanical_crafter.tooltip.behaviour1": "當機器中_所有_的物品槽有物品時,將會啟動所有的合成器來工作。", - "block.create.mechanical_crafter.tooltip.condition2": "被紅石激活時", - "block.create.mechanical_crafter.tooltip.behaviour2": "強制啟動目前網格中所有給定的_材料_的_合成_", - "block.create.mechanical_crafter.tooltip.control1": "當在機器前方使用扳手時", - "block.create.mechanical_crafter.tooltip.action1": "將會改變物品移動的方向。要合成一個物品,所有原料必須被_移動到一起_,並且在陣列的_外緣_被彈出機器", - "block.create.mechanical_crafter.tooltip.control2": "當側方或者后方使用扳手時", - "block.create.mechanical_crafter.tooltip.action2": "連接相鄰的合成器的物品欄,這樣_相同_的物品就會自動進入所有相互連接的合成器", - - "block.create.furnace_engine.tooltip": "熔爐引擎", - "block.create.furnace_engine.tooltip.summary": "一種強力的_旋轉動能_的來源,但是需要_正在工作_的_熔爐_(三種熔爐都可以)", - "block.create.furnace_engine.tooltip.condition1": "當連接正在燃燒的熔爐", - "block.create.furnace_engine.tooltip.behaviour1": "將會帶動_相連_的_飛輪_(需要間隔一格),用高爐速度更快", - - "block.create.flywheel.tooltip": "飛輪", - "block.create.flywheel.tooltip.summary": "一種大型的金屬輪,能將_熔爐引擎_提供的動能穩定化輸出,需要與_熔爐引擎_間隔一個方塊", - "block.create.flywheel.tooltip.condition1": "當連接正在輸出的_熔爐引擎_", - "block.create.flywheel.tooltip.behaviour1": "將會提供相應的_旋轉動能_。", - - "block.create.portable_storage_interface.tooltip": "移動儲存接口", - "block.create.portable_storage_interface.tooltip.summary": "為機械活塞、裝配礦車、旋轉軸承、滑輪_等移動結構_設計的_物流接口_,_移動結構_和_固定結構_之間的物品交換站,兩個接口會面時將_自動對接_,接口必須彼此面對且彼此隔開1-2個方塊。", - "block.create.portable_storage_interface.tooltip.condition1": "裝配在移動結構上時", - "block.create.portable_storage_interface.tooltip.behaviour1": "移動到能夠滿足與_固定結構_上的_移動式儲存接口_對接的條件后,移動結構會_短暫地停下_,開始對接,並直接與_移動結構上的_儲存容器_交互,進行物品的_輸入輸出_。", - "block.create.portable_storage_interface.tooltip.condition2": "被紅石激活時", - "block.create.portable_storage_interface.tooltip.behaviour2": "立即終止任何活動連接。", - - "block.create.portable_fluid_interface.tooltip": "移動液體接口", - "block.create.portable_fluid_interface.tooltip.summary": "為機械活塞、裝配礦車、旋轉軸承、滑輪_等移動結構_設計的_液體接口_,_移動結構_和_固定結構_之間的液體交換站,兩個會面的接口必須彼此面對且彼此隔開1-2個方塊。", - "block.create.portable_fluid_interface.tooltip.condition1": "裝配在移動結構上時", - "block.create.portable_fluid_interface.tooltip.behaviour1": "移動到能夠滿足與_固定結構_上的_移動式液體接口_對接的條件后,移動結構會_短暫地停下_,開始對接,並直接與_移動結構上的_液體儲存罐_交互,進行液體的_導入導出_。", - "block.create.portable_fluid_interface.tooltip.condition2": "被紅石激活時", - "block.create.portable_fluid_interface.tooltip.behaviour2": "立即終止任何活動的連接。", - - "block.create.rotation_speed_controller.tooltip": "轉速控制器", - "block.create.rotation_speed_controller.tooltip.summary": "一個可以變換所連接齒輪旋轉速度的元件", - "block.create.rotation_speed_controller.tooltip.condition1": "接入大齒輪時", - "block.create.rotation_speed_controller.tooltip.behaviour1": "通過_滑鼠滾輪_調整接入機械的_轉速_,傳遞給連接的_大齒輪_,連接的大齒輪需要放置在其上方。", - - "block.create.mechanical_piston.tooltip": "機械活塞", - "block.create.mechanical_piston.tooltip.summary": "活塞的高級版本,使用_旋轉動能_精確地移動其連接的方塊,背面可放置活塞桿延長活塞範圍,沒有活塞桿將不會工作,使用_底盤_或者_粘液塊_可以移動多行方塊。", - "block.create.mechanical_piston.tooltip.condition1": "推拉活塞時", - "block.create.mechanical_piston.tooltip.behaviour1": "活塞的_速度_和_方向_與所接受_轉速_的_大小_以及_方向_相關。", - - "block.create.piston_extension_pole.tooltip": "活塞桿", - "block.create.piston_extension_pole.tooltip.summary": "用來增加_機械活塞_的移動範圍", - "block.create.piston_extension_pole.tooltip.condition1": "當連接到機械活塞時", - "block.create.piston_extension_pole.tooltip.behaviour1": "活塞的移動範圍將擴大", - - "block.create.mechanical_bearing.tooltip": "機械軸承", - "block.create.mechanical_bearing.tooltip.summary": "由機械驅動,根據機械的方向旋轉,用來建造大型的旋轉結構。", - "block.create.mechanical_bearing.tooltip.condition1": "接入機械時", - "block.create.mechanical_bearing.tooltip.behaviour1": "前方的旋轉盤將帶動_粘液塊_或者_底盤_來驅動更多方塊一同旋轉。", - - "block.create.windmill_bearing.tooltip": "風車軸承", - "block.create.windmill_bearing.tooltip.summary": "借助_風的力量_創造_機械_。用您獨特的設計拼接它並讓它旋轉!", - "block.create.windmill_bearing.tooltip.condition1": "右鍵時", - "block.create.windmill_bearing.tooltip.behaviour1": "啟動軸承,提供由其_附加結構_的旋轉產生的機械。結構必須包括合適的_風帆_或_羊毛_。使用_機殼地盤_,_粘液塊_或_強力膠_可以帶動更多方塊旋轉。", - - "block.create.sail_frame.tooltip": "風帆框架", - "block.create.sail_frame.tooltip.summary": "可用來_組裝風車_的結構方塊,不俗的機械來源。", - - "block.create.white_sail.tooltip": "風帆", - "block.create.white_sail.tooltip.summary": "可用來_組裝風車_的結構方塊,不俗的機械來源,有多種顏色。", - "block.create.white_sail.tooltip.condition1": "使用染料右鍵時", - "block.create.white_sail.tooltip.behaviour1": "改變顏色。", - - "block.create.clockwork_bearing.tooltip": "時鐘軸承", - "block.create.clockwork_bearing.tooltip.summary": "一種高級的機械軸承,可以根據目前遊戲內時間旋轉兩個不同的指針", - "block.create.clockwork_bearing.tooltip.condition1": "接入機械時", - "block.create.clockwork_bearing.tooltip.behaviour1": "旋轉第一個連接的結構作為時針,第二個連接的結構作為分針", - - "block.create.sequenced_gearshift.tooltip": "可編程齒輪箱", - "block.create.sequenced_gearshift.tooltip.summary": "一種可編程的組件,可以根據內部的指令設計旋轉的_方向_,_速度_,以及_距離_。此組件可以有效配合活塞和軸承等使用。最高可讓其按_順序_執行_5條指令_。條高速旋轉時可能會變得不精確。", - "block.create.sequenced_gearshift.tooltip.condition1": "當給予紅石訊號時", - "block.create.sequenced_gearshift.tooltip.behaviour1": "在接入動能的情況下,執行指令。", - "block.create.sequenced_gearshift.tooltip.condition2": "當右鍵時", - "block.create.sequenced_gearshift.tooltip.behaviour2": "將打開_配置界面_", - - "block.create.cart_assembler.tooltip": "礦車裝配站", - "block.create.cart_assembler.tooltip.summary": "將連接目前方塊的結構連接在_礦車_上", - "block.create.cart_assembler.tooltip.condition1": "當被紅石訊號激活時", - "block.create.cart_assembler.tooltip.behaviour1": "將裝配站上連接的結構組裝到礦車上,並送礦車上路", - "block.create.cart_assembler.tooltip.condition2": "沒有紅石訊號時", - "block.create.cart_assembler.tooltip.behaviour2": "將經過的礦車上的結構_實體化_,並停住礦車。", - "block.create.cart_assembler.tooltip.control1": "放置於軌道上時", - "block.create.cart_assembler.tooltip.action1": "紅石激活時_裝配_經過的礦車,未激活時_卸載_經過的礦車。", - "block.create.cart_assembler.tooltip.control2": "放置於充能鐵軌上時", - "block.create.cart_assembler.tooltip.action2": "紅石激活時_裝配_並加速礦車,未激活時_卸載_並停住經過的礦車。", - "block.create.cart_assembler.tooltip.control3": "放置在探測鐵軌上時", - "block.create.cart_assembler.tooltip.action3": "_裝配_未裝配過的礦車,_卸載_裝配過的礦車。", - "block.create.cart_assembler.tooltip.control4": "放置在激活鐵軌上時", - "block.create.cart_assembler.tooltip.action4": "紅石激活時_卸載_礦車。", - - "block.create.rope_pulley.tooltip": "繩索滑輪", - "block.create.rope_pulley.tooltip.summary": "移動繩索相連的結構。使用_底盤_或者_粘液塊_來移動多行方塊", - "block.create.rope_pulley.tooltip.condition1": "接入機械時", - "block.create.rope_pulley.tooltip.behaviour1": "根據輸入的轉速的大小以及方向,移動鏈接的結構。", - - "block.create.linear_chassis.tooltip": "機殼底盤", - "block.create.linear_chassis.tooltip.summary": "一種可配置的_底盤_。這種底盤可以將多個方塊連接起來組合成_大型結構_", - "block.create.linear_chassis.tooltip.condition1": "被移動時", - "block.create.linear_chassis.tooltip.behaviour1": "移動所有_並排_的_機殼底盤_。如果底盤上涂了_粘液球_,那麼其範圍內一條直線的方塊都會被_黏附移動_(詳情見Ctrl)。", - "block.create.linear_chassis.tooltip.condition2": "當使用扳手時", - "block.create.linear_chassis.tooltip.behaviour2": "通過_滑鼠滾輪_來配置連接的方塊的範圍。按住_Ctrl_時滾動滾輪可以同時配置相連的其他底盤。", - "block.create.linear_chassis.tooltip.control1": "當用粘液球右鍵時", - "block.create.linear_chassis.tooltip.action1": "變為_粘性機殼底盤_。所有工作範圍內與其相連的方塊會與其_一同移動_", - - "block.create.secondary_linear_chassis.tooltip": "機殼底盤2號", - "block.create.secondary_linear_chassis.tooltip.summary": "第二種_機殼底盤_,不會與第一種機殼底盤互相連接。", - - "block.create.radial_chassis.tooltip": "旋轉底盤", - "block.create.radial_chassis.tooltip.summary": "一種可配置的底盤。這種底盤可以將多個方塊連接起來組合成_大型結構_", - "block.create.radial_chassis.tooltip.condition1": "當被旋轉時", - "block.create.radial_chassis.tooltip.behaviour1": "所有_豎排_的_旋轉底盤_會互相粘連移動,並且每個涂了_粘液球_的底盤都會帶動其工作半徑內的方塊(詳情見Ctrl)。", - "block.create.radial_chassis.tooltip.condition2": "當使用扳手時", - "block.create.radial_chassis.tooltip.behaviour2": "配置連接的方塊的半徑。按住_Ctrl_可以同時配置相連的其他底盤。", - "block.create.radial_chassis.tooltip.control1": "當用粘液球右鍵時", - "block.create.radial_chassis.tooltip.action1": "變為_粘性旋轉底盤_。所有工作範圍內與其相連的方塊會與其_一同移動_。", - - "block.create.mechanical_drill.tooltip": "機械鑽頭", - "block.create.mechanical_drill.tooltip.summary": "用來_破壞方塊_的裝置,可以被_機械活塞_和_機械軸承_等移動設備帶動", - "block.create.mechanical_drill.tooltip.condition1": "被供能時", - "block.create.mechanical_drill.tooltip.behaviour1": "_原地_破壞正前方的方塊,且_傷害_在一定範圍內生物及玩家。", - "block.create.mechanical_drill.tooltip.condition2": "當移動時", - "block.create.mechanical_drill.tooltip.behaviour2": "橫向或縱向沿路破壞其所_碰到_的方塊。", - - "block.create.mechanical_harvester.tooltip": "機械收割機", - "block.create.mechanical_harvester.tooltip.summary": "適用來中型作物自動化的收割機,可以被_機械活塞_和_機械軸承_等帶動。", - "block.create.mechanical_harvester.tooltip.condition1": "當移動時", - "block.create.mechanical_harvester.tooltip.behaviour1": "收割機移動至成熟作物,收割作物並將作物變為初始生長狀態。", - - "block.create.mechanical_plough.tooltip": "機械犁", - "block.create.mechanical_plough.tooltip.summary": "犁是一個非常有用的多功能方塊,它可以被_機械活塞_和_機械軸承_等帶動", - "block.create.mechanical_plough.tooltip.condition1": "當移動時", - "block.create.mechanical_plough.tooltip.behaviour1": "可以打掉無碰撞體積的一些_附著方塊_,比如火把和雪等。可以在不傷害實體的情況下移動它們。能像_鋤頭_一樣翻土耕田。", - - "block.create.mechanical_saw.tooltip": "機械切割機", - "block.create.mechanical_saw.tooltip.summary": "可以用來砍樹,也可以用來切割方塊,可以被_機械活塞_和_機械軸承_等帶動", - "block.create.mechanical_saw.tooltip.condition1": "當向上放置時", - "block.create.mechanical_saw.tooltip.behaviour1": "可以切割各種物品(建議配合jei查看)", - "block.create.mechanical_saw.tooltip.condition2": "當方向在水平面時", - "block.create.mechanical_saw.tooltip.behaviour2": "可以砍倒面前的樹木", - "block.create.mechanical_saw.tooltip.condition3": "當移動時", - "block.create.mechanical_saw.tooltip.behaviour3": "將會砍倒碰撞到的樹木", - - "block.create.stockpile_switch.tooltip": "存量檢測器", - "block.create.stockpile_switch.tooltip.summary": "根據連接的容器_儲存空間_的占用情況切換紅石訊號強度。", - "block.create.stockpile_switch.tooltip.condition1": "低於_下線_或高於_上線_時", - "block.create.stockpile_switch.tooltip.behaviour1": "提供紅石訊號", - - "block.create.content_observer.tooltip": "物品偵測器", - "block.create.content_observer.tooltip.summary": "檢測_容器_和_輸送帶_中過濾器匹配的物品。當觀察到包含匹配的物品時,此組件將發出_紅石訊號_。當觀察到的漏斗_轉移匹配的物品_時,此組件將發出_紅石脈沖_。", - - "block.create.redstone_link.tooltip": "無限紅石訊號終端", - "block.create.redstone_link.tooltip.summary": "無線紅石訊號終端,可以使用_任何物品_編輯終端_頻道_。雖然距離有限,但是也挺遠的。", - "block.create.redstone_link.tooltip.condition1": "當啟用時", - "block.create.redstone_link.tooltip.behaviour1": "接收相同_頻道_提供的_紅石訊號_。", - "block.create.redstone_link.tooltip.control1": "當手持方塊右鍵方塊時", - "block.create.redstone_link.tooltip.action1": "手持_任意物品_為其設置_頻道_,可以使用兩種物品組合設置_頻道_。", - "block.create.redstone_link.tooltip.control2": "當潛行右鍵時", - "block.create.redstone_link.tooltip.action2": "在_發射模式_和_接收模式_之間切換。", - - "block.create.nixie_tube.tooltip": "真空管顯示器", - "block.create.nixie_tube.tooltip.summary": "一個炫泡的_紅石強度_顯示器,範圍:0到15。", - "block.create.nixie_tube.tooltip.condition1": "收到紅時訊號時", - "block.create.nixie_tube.tooltip.behaviour1": "顯示現在的紅時訊號強度", - "block.create.nixie_tube.tooltip.condition2": "被命名牌命名時", - "block.create.nixie_tube.tooltip.behaviour2": "顯示_命名牌內容_,名稱太長時需_排列_多個真空管顯示器。", - - "block.create.redstone_contact.tooltip": "接觸式紅石訊號產生器", - "block.create.redstone_contact.tooltip.summary": "一種用來高級紅石裝置的設備。只能兩兩工作。可以被_機械活塞_和_機械軸承_等帶動", - "block.create.redstone_contact.tooltip.condition1": "當正對面放置也放置_相互朝向_的接觸訊號發生器時", - "block.create.redstone_contact.tooltip.behaviour1": "提供_紅石訊號_。", - "block.create.redstone_contact.tooltip.condition2": "當移動時", - "block.create.redstone_contact.tooltip.behaviour2": "如果接觸到其他訊號發生器,使其發出紅石訊號。", - - "block.create.adjustable_crate.tooltip": "可調節板條箱", - "block.create.adjustable_crate.tooltip.summary": "該箱子支持玩家對其容量進行調整,最大可以容納_16組_物品。", - "block.create.adjustable_crate.tooltip.control1": "當右鍵時", - "block.create.adjustable_crate.tooltip.action1": "打開箱子", - - "block.create.creative_crate.tooltip": "創造板條箱", - "block.create.creative_crate.tooltip.summary": "這個容器可以給臨近的_藍圖大炮_提供無限物品以及燃料 (創造專用物品)", - "block.create.creative_crate.tooltip.condition1": "當標記了物品時", - "block.create.creative_crate.tooltip.behaviour1": "容器將會從虛空中提供_無限量_的標記物品,並且任何放置到容器中的物品都會被_送入虛空_", - - "block.create.deployer.tooltip": "機械手", - "block.create.deployer.tooltip.summary": "它是一個盡可能_模仿玩家_的行為的_機械手_,自帶一個物品_緩存區_,可以由漏斗、機械臂等輸入設備為其提供物品,並帶有過濾插槽", - "block.create.deployer.tooltip.condition1": "接入動能時", - "block.create.deployer.tooltip.behaviour1": "機械手可伸長_兩個方塊_的距離,取出_緩存區_的物品並使用。", - "block.create.deployer.tooltip.condition2": "當使用扳手右鍵時", - "block.create.deployer.tooltip.behaviour2": "啟用拳頭模式,在拳頭模式之下,機械手將會試圖使用手中的物品_破壞方塊_,或者_攻擊實體_。", - "block.create.deployer.tooltip.condition3": "配有_過濾器_時", - "block.create.deployer.tooltip.behaviour3": "當_緩存區_的物品與過濾器匹配,機械手才會取出並使用,不匹配的物品_無法從外部輸入_到機械手的_緩存區_中;_緩存區_中與過濾器匹配的物品_無法被提取_。", - - "block.create.brass_casing.tooltip": "黃銅機殼", - "block.create.brass_casing.tooltip.summary": "一種堅固的機殼,有多種用途。", - - "block.create.pulse_repeater.tooltip": "可調節脈沖中繼器", - "block.create.pulse_repeater.tooltip.summary": "一個簡單的電路元件,將通過的紅石訊號變為1tick。", - - "block.create.adjustable_repeater.tooltip": "可調節中繼器", - "block.create.adjustable_repeater.tooltip.summary": "高級中繼器,最大可設置30分鐘延遲", - - "block.create.adjustable_pulse_repeater.tooltip": "可調節脈沖中繼器", - "block.create.adjustable_pulse_repeater.tooltip.summary": "一種單次1tick的紅石脈沖器,可以調節延時至30min", - - "block.create.analog_lever.tooltip": "可調節拉桿", - "block.create.analog_lever.tooltip.summary": "一種可以調節任意訊號強度的推桿。", - - "block.create.powered_toggle_latch.tooltip": "T觸發器", - "block.create.powered_toggle_latch.tooltip.summary": "一種拉桿,在紅石電路中可以用作t觸發器。", - - "block.create.powered_latch.tooltip": "鎖存器", - "block.create.powered_latch.tooltip.summary": "一種拉桿,在紅石電路中用作鎖存器,從后方輸入將會啟用這個拉桿,從側邊輸入將會重置這個拉桿。", - - "block.create.controller_rail.tooltip": "控制鐵軌", - "block.create.controller_rail.tooltip.summary": "單向電動導軌,能夠精細控制礦車的移動速度。", - "block.create.controller_rail.tooltip.condition1": "被紅石激活時", - "block.create.controller_rail.tooltip.behaviour1": "根據訊號強度_加速_或_減速_經過的礦車。將紅石強度傳播到相鄰的控制鐵軌。", - - "block.create.speedometer.tooltip": "速度計", - "block.create.speedometer.tooltip.summary": "測量並展示連接網絡的旋轉速度,支持使用紅石比較器", - "block.create.speedometer.tooltip.condition1": "接入機械時", - "block.create.speedometer.tooltip.behaviour1": "將會用顏色展示速度的大小,綠-慢、藍-中、紫-快。", - - "block.create.stressometer.tooltip": "動能錶", - "block.create.stressometer.tooltip.summary": "測量並展示連接網絡的動能值,支持紅石比較器", - "block.create.stressometer.tooltip.condition1": "接入機械時", - "block.create.stressometer.tooltip.behaviour1": "將會用顏色展示承受的動能。如果網路超載則會癱瘓,必須減少機器或者增加動能", - - "item.create.sand_paper.tooltip": "紅砂紙", - "item.create.sand_paper.tooltip.summary": "用來_打磨_物品的砂紙,可以用_機械手_來實現自動化。", - "item.create.sand_paper.tooltip.condition1": "使用時", - "item.create.sand_paper.tooltip.behaviour1": "打磨_副手_上或者_準心所指_的物品。", - - "item.create.super_glue.tooltip": "強力膠", - "item.create.super_glue.tooltip.summary": "讓兩個方塊互相_粘黏_,他們會一直因此相愛到永遠", - "item.create.super_glue.tooltip.condition1": "右鍵使用時", - "item.create.super_glue.tooltip.behaviour1": "有強力膠的方塊的_那一面_會變得有粘性。和此面相鄰的方塊在被_機械活塞_或者_機械軸承_等方塊驅動的時候會被一同帶動", - "item.create.super_glue.tooltip.condition2": "在副手上時", - "item.create.super_glue.tooltip.behaviour2": "主手放置的方塊會被_直接_黏在所放置的方塊上", - - "item.create.builders_tea.tooltip": "建造工茶飲", - "item.create.builders_tea.tooltip.summary": "神清氣爽的一天,從這杯完美茶飲開始。恢復復_饑餓值_並獲得_加速_效果。", - - "item.create.refined_radiance.tooltip": "光輝石", - "item.create.refined_radiance.tooltip.summary": "一種用_光輝_鍛造的化合物材料。", - - "item.create.shadow_steel.tooltip": "暗影鋼", - "item.create.shadow_steel.tooltip.summary": "一種用_虛空_鍛造的化合物材料。", - - "item.create.minecart_coupling.tooltip": "礦車連軸器", - "item.create.minecart_coupling.tooltip.summary": "將多個_礦車_或運輸結構鏈接在一起,構成雄偉的火車。", - "item.create.minecart_coupling.tooltip.condition1": "作用與礦車時", - "item.create.minecart_coupling.tooltip.behaviour1": "將兩個礦車耦合在一起,在移動時將它們保持_恒定的距離_。", - - "item.create.crafter_slot_cover.tooltip": "合成器蓋板", - "item.create.crafter_slot_cover.tooltip.summary": "用來標記_機械合成器_以不放入物品。在制造與桶類似的斜向合成表時非常有用。", - - "create.tooltip.wip": "半成品", - "create.tooltip.workInProgress": "尚在製作中!", - "create.tooltip.randomWipDescription0": "禁止將此物品給兒童。", - "create.tooltip.randomWipDescription1": "每~一~次~你使用此物品時,就會使一隻小熊貓死亡。", - "create.tooltip.randomWipDescription2": "使用此物請自負後果。", - "create.tooltip.randomWipDescription3": "快走開,這不是你要找的東西(搖手指", - "create.tooltip.randomWipDescription4": "啟動自爆模式,10、9、8...。", - "create.tooltip.randomWipDescription5": "你已經沒有退路了。", - "create.tooltip.randomWipDescription6": "作者我將不負任何你使用此物所造成的責任。", - "create.tooltip.randomWipDescription7": "這東西不是給你用的,再找找吧!", - "create.tooltip.randomWipDescription8": "用了就死定了。", - - "_": "Thank you for translating Create!" - -} +{ + "_": "for create 0.3.1c", + + "_": "->------------------------] Game Elements [------------------------<-", + + "block.create.acacia_window": "相思木窗戶", + "block.create.acacia_window_pane": "相思木窗戶片", + "block.create.adjustable_chain_gearshift": "可調式鏈式變速箱", + "block.create.adjustable_crate": "可調式板條箱", + "block.create.adjustable_pulse_repeater": "可調式脈衝中繼器", + "block.create.adjustable_repeater": "可調式中繼器", + "block.create.analog_lever": "可調式拉桿", + "block.create.andesite_belt_funnel": "安山岩輸送帶漏斗", + "block.create.andesite_bricks": "安山岩磚", + "block.create.andesite_bricks_slab": "安山岩半磚", + "block.create.andesite_bricks_stairs": "安山岩樓梯", + "block.create.andesite_bricks_wall": "安山岩牆", + "block.create.andesite_casing": "安山岩機殼", + "block.create.andesite_cobblestone": "碎安山岩", + "block.create.andesite_cobblestone_slab": "碎安山岩半磚", + "block.create.andesite_cobblestone_stairs": "碎安山岩樓梯", + "block.create.andesite_cobblestone_wall": "碎安山岩牆", + "block.create.andesite_encased_shaft": "安山傳動軸箱", + "block.create.andesite_funnel": "安山岩漏斗", + "block.create.andesite_pillar": "豎紋安山岩", + "block.create.andesite_tunnel": "安山岩物品隧道", + "block.create.basin": "作業盆", + "block.create.belt": "輸送帶", + "block.create.birch_window": "白樺木窗戶", + "block.create.birch_window_pane": "白樺木窗戶片", + "block.create.black_sail": "黑色風帆", + "block.create.black_seat": "黑色坐墊", + "block.create.black_valve_handle": "黑色閥門開關", + "block.create.blaze_burner": "烈焰使者動力爐", + "block.create.blue_sail": "藍色風帆", + "block.create.blue_seat": "藍色坐墊", + "block.create.blue_valve_handle": "藍色閥門開關", + "block.create.brass_belt_funnel": "黃銅輸送帶漏斗", + "block.create.brass_block": "黃銅磚", + "block.create.brass_casing": "黃銅機殼", + "block.create.brass_encased_shaft": "黃銅傳動軸箱", + "block.create.brass_funnel": "黃銅漏斗", + "block.create.brass_tunnel": "黃銅物品隧道", + "block.create.brown_sail": "棕色風帆", + "block.create.brown_seat": "棕色坐墊", + "block.create.brown_valve_handle": "棕色閥門開關", + "block.create.cart_assembler": "礦車裝修站", + "block.create.chiseled_dark_scoria": "鏨製黑火成岩", + "block.create.chiseled_dolomite": "鏨製白雲石", + "block.create.chiseled_gabbro": "鏨製輝長岩", + "block.create.chiseled_limestone": "鏨製石灰岩", + "block.create.chiseled_scoria": "鏨製火成岩", + "block.create.chiseled_weathered_limestone": "鏨製風化石灰岩", + "block.create.chocolate": "巧克力", + "block.create.chute": "滑道", + "block.create.clockwork_bearing": "時鐘軸承", + "block.create.clutch": "離合器", + "block.create.cogwheel": "齒輪", + "block.create.content_observer": "物品偵測器", + "block.create.controller_rail": "控制鐵軌", + "block.create.copper_block": "銅磚", + "block.create.copper_casing": "銅機殼", + "block.create.copper_ore": "銅礦石", + "block.create.copper_shingles": "塊狀銅磚", + "block.create.copper_tiles": "菱形銅磚", + "block.create.copper_valve_handle": "銅製閥門開關", + "block.create.creative_crate": "創造板條箱", + "block.create.creative_fluid_tank": "創造液體儲存罐", + "block.create.creative_motor": "創造馬達", + "block.create.crimson_window": "赤紅窗戶", + "block.create.crimson_window_pane": "赤紅窗戶片", + "block.create.crushing_wheel": "粉碎輪", + "block.create.crushing_wheel_controller": "粉碎輪控制器", + "block.create.cuckoo_clock": "布穀鳥鐘", + "block.create.cyan_sail": "藍綠色風帆", + "block.create.cyan_seat": "藍綠色坐墊", + "block.create.cyan_valve_handle": "藍綠色閥門開關", + "block.create.dark_oak_window": "黑橡木窗戶", + "block.create.dark_oak_window_pane": "黑橡木窗戶片", + "block.create.dark_scoria": "黑火成岩", + "block.create.dark_scoria_bricks": "黑火成岩磚", + "block.create.dark_scoria_bricks_slab": "黑火成岩半磚", + "block.create.dark_scoria_bricks_stairs": "黑火成岩樓梯", + "block.create.dark_scoria_bricks_wall": "黑火成岩牆", + "block.create.dark_scoria_cobblestone": "黑火成岩碎石", + "block.create.dark_scoria_cobblestone_slab": "黑火成岩碎石半磚", + "block.create.dark_scoria_cobblestone_stairs": "黑火成岩碎石樓梯", + "block.create.dark_scoria_cobblestone_wall": "黑火成岩碎石牆", + "block.create.dark_scoria_pillar": "豎紋黑火成岩", + "block.create.deployer": "機器手", + "block.create.depot": "置物臺", + "block.create.diorite_bricks": "閃長岩磚", + "block.create.diorite_bricks_slab": "閃長岩半磚", + "block.create.diorite_bricks_stairs": "閃長岩樓梯", + "block.create.diorite_bricks_wall": "閃長岩牆", + "block.create.diorite_cobblestone": "碎閃長岩", + "block.create.diorite_cobblestone_slab": "碎閃長岩半磚", + "block.create.diorite_cobblestone_stairs": "碎閃長岩樓梯", + "block.create.diorite_cobblestone_wall": "碎閃長岩牆", + "block.create.diorite_pillar": "豎紋閃長岩", + "block.create.dolomite": "白雲石", + "block.create.dolomite_bricks": "白雲石磚", + "block.create.dolomite_bricks_slab": "白雲石半磚", + "block.create.dolomite_bricks_stairs": "白雲石樓梯", + "block.create.dolomite_bricks_wall": "白雲石牆", + "block.create.dolomite_cobblestone": "碎白雲石", + "block.create.dolomite_cobblestone_slab": "碎白雲石半磚", + "block.create.dolomite_cobblestone_stairs": "碎白雲石樓梯", + "block.create.dolomite_cobblestone_wall": "碎白雲石牆", + "block.create.dolomite_pillar": "豎紋白雲石", + "block.create.encased_chain_drive": "鏈式傳動箱", + "block.create.encased_fan": "鼓風機", + "block.create.encased_fluid_pipe": "液體管道箱", + "block.create.fancy_andesite_bricks": "方紋安山岩磚", + "block.create.fancy_andesite_bricks_slab": "方紋安山岩半磚", + "block.create.fancy_andesite_bricks_stairs": "方紋安山岩樓梯", + "block.create.fancy_andesite_bricks_wall": "方紋安山岩牆", + "block.create.fancy_dark_scoria_bricks": "方紋黑火成岩", + "block.create.fancy_dark_scoria_bricks_slab": "方紋黑火成岩半磚", + "block.create.fancy_dark_scoria_bricks_stairs": "方紋黑火成岩樓梯", + "block.create.fancy_dark_scoria_bricks_wall": "方紋黑火成岩牆", + "block.create.fancy_diorite_bricks": "方紋閃長岩", + "block.create.fancy_diorite_bricks_slab": "方紋閃長岩半磚", + "block.create.fancy_diorite_bricks_stairs": "方紋閃長岩樓梯", + "block.create.fancy_diorite_bricks_wall": "方紋閃長岩牆", + "block.create.fancy_dolomite_bricks": "方紋白雲石", + "block.create.fancy_dolomite_bricks_slab": "方紋白雲石半磚", + "block.create.fancy_dolomite_bricks_stairs": "方紋白雲石樓梯", + "block.create.fancy_dolomite_bricks_wall": "方紋白雲石牆", + "block.create.fancy_gabbro_bricks": "方紋輝長岩", + "block.create.fancy_gabbro_bricks_slab": "方紋輝長岩半磚", + "block.create.fancy_gabbro_bricks_stairs": "方紋輝長岩樓梯", + "block.create.fancy_gabbro_bricks_wall": "方紋輝長岩牆", + "block.create.fancy_granite_bricks": "方紋花崗岩", + "block.create.fancy_granite_bricks_slab": "方紋花崗岩半磚", + "block.create.fancy_granite_bricks_stairs": "方紋花崗岩樓梯", + "block.create.fancy_granite_bricks_wall": "方紋花崗岩牆", + "block.create.fancy_limestone_bricks": "方紋石灰岩", + "block.create.fancy_limestone_bricks_slab": "方紋石灰岩半磚", + "block.create.fancy_limestone_bricks_stairs": "方紋石灰岩樓梯", + "block.create.fancy_limestone_bricks_wall": "方紋石灰岩牆", + "block.create.fancy_scoria_bricks": "方紋火成岩", + "block.create.fancy_scoria_bricks_slab": "方紋火成岩半磚", + "block.create.fancy_scoria_bricks_stairs": "方紋火成岩樓梯", + "block.create.fancy_scoria_bricks_wall": "方紋火成岩牆", + "block.create.fancy_weathered_limestone_bricks": "方紋風化石灰岩", + "block.create.fancy_weathered_limestone_bricks_slab": "方紋風化石灰岩半磚", + "block.create.fancy_weathered_limestone_bricks_stairs": "方紋風化石灰岩樓梯", + "block.create.fancy_weathered_limestone_bricks_wall": "方紋風化石灰岩牆", + "block.create.fluid_pipe": "液體管道", + "block.create.fluid_tank": "液體儲存罐", + "block.create.fluid_valve": "液體閥門", + "block.create.flywheel": "飛輪", + "block.create.framed_glass": "邊框玻璃", + "block.create.framed_glass_pane": "邊框玻璃片", + "block.create.furnace_engine": "熔煉引擎", + "block.create.gabbro": "輝長岩", + "block.create.gabbro_bricks": "輝長岩磚", + "block.create.gabbro_bricks_slab": "輝長岩半磚", + "block.create.gabbro_bricks_stairs": "輝長岩樓梯", + "block.create.gabbro_bricks_wall": "輝長岩牆", + "block.create.gabbro_cobblestone": "碎輝長岩", + "block.create.gabbro_cobblestone_slab": "碎輝長岩半磚", + "block.create.gabbro_cobblestone_stairs": "碎輝長岩樓梯", + "block.create.gabbro_cobblestone_wall": "碎輝長岩牆", + "block.create.gabbro_pillar": "豎紋輝長岩", + "block.create.gantry_carriage": "門式起重機", + "block.create.gantry_shaft": "門式起重機滑道", + "block.create.gearbox": "齒輪箱", + "block.create.gearshift": "變速箱", + "block.create.glass_fluid_pipe": "玻璃液體管道", + "block.create.granite_bricks": "花崗岩", + "block.create.granite_bricks_slab": "花崗岩半磚", + "block.create.granite_bricks_stairs": "花崗岩樓梯", + "block.create.granite_bricks_wall": "花崗岩牆", + "block.create.granite_cobblestone": "碎花崗岩", + "block.create.granite_cobblestone_slab": "碎花崗岩半磚", + "block.create.granite_cobblestone_stairs": "碎花崗岩樓梯", + "block.create.granite_cobblestone_wall": "碎花崗岩牆", + "block.create.granite_pillar": "豎紋花崗岩", + "block.create.gray_sail": "灰色風帆", + "block.create.gray_seat": "灰色坐墊", + "block.create.gray_valve_handle": "灰色閥門開關", + "block.create.green_sail": "綠色風帆", + "block.create.green_seat": "綠色坐墊", + "block.create.green_valve_handle": "綠色閥門開關", + "block.create.hand_crank": "手搖把手", + "block.create.honey": "蜂蜜", + "block.create.horizontal_framed_glass": "豎直邊框玻璃", + "block.create.horizontal_framed_glass_pane": "豎直邊框玻璃片", + "block.create.hose_pulley": "軟管滑輪", + "block.create.item_drain": "分液池", + "block.create.jungle_window": "叢林木窗戶", + "block.create.jungle_window_pane": "叢林木窗戶片", + "block.create.large_cogwheel": "大齒輪", + "block.create.layered_andesite": "疊層安山岩", + "block.create.layered_dark_scoria": "疊層黑火成岩", + "block.create.layered_diorite": "疊層閃長岩", + "block.create.layered_dolomite": "疊層白雲石", + "block.create.layered_gabbro": "疊層輝長岩", + "block.create.layered_granite": "疊層花崗岩", + "block.create.layered_limestone": "疊層石灰岩", + "block.create.layered_scoria": "疊層火成岩", + "block.create.layered_weathered_limestone": "疊層風化石灰岩", + "block.create.light_blue_sail": "淡藍色風帆", + "block.create.light_blue_seat": "淡藍色坐墊", + "block.create.light_blue_valve_handle": "淡藍色閥門開關", + "block.create.light_gray_sail": "淡灰色風帆", + "block.create.light_gray_seat": "淡灰色坐墊", + "block.create.light_gray_valve_handle": "淡灰色閥門開關", + "block.create.lime_sail": "黃綠色風帆", + "block.create.lime_seat": "黃綠色坐墊", + "block.create.lime_valve_handle": "黃綠色閥門開關", + "block.create.limesand": "石灰沙", + "block.create.limestone": "石灰岩", + "block.create.limestone_bricks": "石灰岩", + "block.create.limestone_bricks_slab": "石灰岩半磚", + "block.create.limestone_bricks_stairs": "石灰岩樓梯", + "block.create.limestone_bricks_wall": "石灰岩牆", + "block.create.limestone_cobblestone": "碎石灰岩", + "block.create.limestone_cobblestone_slab": "碎石灰岩半磚", + "block.create.limestone_cobblestone_stairs": "碎石灰岩樓梯", + "block.create.limestone_cobblestone_wall": "碎石灰岩牆", + "block.create.limestone_pillar": "豎紋石灰岩", + "block.create.linear_chassis": "機殼底盤", + "block.create.lit_blaze_burner": "烈焰使者動力爐(已啟動)", + "block.create.magenta_sail": "洋紅色風帆", + "block.create.magenta_seat": "洋紅色坐墊", + "block.create.magenta_valve_handle": "洋紅色閥門開關", + "block.create.mechanical_arm": "機械手臂", + "block.create.mechanical_bearing": "機械軸承", + "block.create.mechanical_crafter": "機械合成器", + "block.create.mechanical_drill": "機械鑽頭", + "block.create.mechanical_harvester": "機械收割機", + "block.create.mechanical_mixer": "機械攪拌器", + "block.create.mechanical_piston": "機械活塞", + "block.create.mechanical_piston_head": "機械活塞頭", + "block.create.mechanical_plough": "機械犁", + "block.create.mechanical_press": "機械液壓機", + "block.create.mechanical_pump": "機械幫浦", + "block.create.mechanical_saw": "機械切割機", + "block.create.metal_bracket": "金屬支架", + "block.create.millstone": "石磨", + "block.create.minecart_anchor": "礦車錨", + "block.create.mossy_andesite": "青苔安山岩", + "block.create.mossy_dark_scoria": "青苔黑火成岩", + "block.create.mossy_diorite": "青苔閃長岩", + "block.create.mossy_dolomite": "青苔白雲石", + "block.create.mossy_gabbro": "青苔輝長岩", + "block.create.mossy_granite": "青苔花崗岩", + "block.create.mossy_limestone": "青苔石灰岩", + "block.create.mossy_scoria": "青苔火成岩", + "block.create.mossy_weathered_limestone": "青苔風化石灰岩", + "block.create.mysterious_cuckoo_clock": "神秘布穀鳥鐘", + "block.create.natural_scoria": "天然火成岩", + "block.create.nixie_tube": "真空管顯示器", + "block.create.nozzle": "鼓風機噴嘴", + "block.create.oak_window": "橡木窗戶", + "block.create.oak_window_pane": "橡木窗戶片", + "block.create.orange_sail": "橙色風帆", + "block.create.orange_seat": "橙色坐墊", + "block.create.orange_valve_handle": "橙色閥門開關", + "block.create.ornate_iron_window": "華麗鐵窗戶", + "block.create.ornate_iron_window_pane": "華麗鐵窗戶片", + "block.create.overgrown_andesite": "長草的安山岩", + "block.create.overgrown_dark_scoria": "長草的黑火成岩", + "block.create.overgrown_diorite": "長草的閃長岩", + "block.create.overgrown_dolomite": "長草的白雲石", + "block.create.overgrown_gabbro": "長草的輝長岩", + "block.create.overgrown_granite": "長草的花崗岩", + "block.create.overgrown_limestone": "長草的石灰岩", + "block.create.overgrown_scoria": "長草的火成岩", + "block.create.overgrown_weathered_limestone": "長草的風化石灰岩", + "block.create.paved_andesite": "安山岩鋪路石", + "block.create.paved_andesite_slab": "安山岩鋪路石半磚", + "block.create.paved_andesite_stairs": "安山岩鋪路石樓梯", + "block.create.paved_andesite_wall": "安山岩鋪路石牆", + "block.create.paved_dark_scoria": "黑火成岩鋪路石", + "block.create.paved_dark_scoria_slab": "黑火成岩鋪路石半磚", + "block.create.paved_dark_scoria_stairs": "黑火成岩鋪路石樓梯", + "block.create.paved_dark_scoria_wall": "黑火成岩鋪路石牆", + "block.create.paved_diorite": "閃長岩鋪路石", + "block.create.paved_diorite_slab": "閃長岩鋪路石半磚", + "block.create.paved_diorite_stairs": "閃長岩鋪路石樓梯", + "block.create.paved_diorite_wall": "閃長岩鋪路石牆", + "block.create.paved_dolomite": "白雲石鋪路石", + "block.create.paved_dolomite_slab": "白雲石鋪路石半磚", + "block.create.paved_dolomite_stairs": "白雲石鋪路石樓梯", + "block.create.paved_dolomite_wall": "白雲石鋪路石牆", + "block.create.paved_gabbro": "輝長岩鋪路石", + "block.create.paved_gabbro_slab": "輝長岩鋪路石半磚", + "block.create.paved_gabbro_stairs": "輝長岩鋪路石樓梯", + "block.create.paved_gabbro_wall": "輝長岩鋪路石牆", + "block.create.paved_granite": "花崗岩鋪路石", + "block.create.paved_granite_slab": "花崗岩鋪路石半磚", + "block.create.paved_granite_stairs": "花崗岩鋪路石樓梯", + "block.create.paved_granite_wall": "花崗岩鋪路石牆", + "block.create.paved_limestone": "石灰岩鋪路石", + "block.create.paved_limestone_slab": "石灰岩鋪路石半磚", + "block.create.paved_limestone_stairs": "石灰岩鋪路石樓梯", + "block.create.paved_limestone_wall": "石灰岩鋪路石牆", + "block.create.paved_scoria": "火成岩鋪路石", + "block.create.paved_scoria_slab": "火成岩鋪路石半磚", + "block.create.paved_scoria_stairs": "火成岩鋪路石樓梯", + "block.create.paved_scoria_wall": "火成岩鋪路石牆", + "block.create.paved_weathered_limestone": "風化石灰岩鋪路石", + "block.create.paved_weathered_limestone_slab": "風化石灰岩鋪路石半磚", + "block.create.paved_weathered_limestone_stairs": "風化石灰岩鋪路石樓梯", + "block.create.paved_weathered_limestone_wall": "風化石灰岩鋪路石牆", + "block.create.pink_sail": "粉紅色風帆", + "block.create.pink_seat": "粉紅色坐墊", + "block.create.pink_valve_handle": "粉紅色閥門開關", + "block.create.piston_extension_pole": "活塞桿", + "block.create.polished_dark_scoria": "磨製黑火成岩", + "block.create.polished_dark_scoria_slab": "磨製黑火成岩半磚", + "block.create.polished_dark_scoria_stairs": "磨製黑火成岩樓梯", + "block.create.polished_dark_scoria_wall": "磨製黑火成岩牆", + "block.create.polished_dolomite": "磨製白雲石", + "block.create.polished_dolomite_slab": "磨製白雲石半磚", + "block.create.polished_dolomite_stairs": "磨製白雲石樓梯", + "block.create.polished_dolomite_wall": "磨製白雲石牆", + "block.create.polished_gabbro": "磨製輝長岩", + "block.create.polished_gabbro_slab": "磨製輝長岩半磚", + "block.create.polished_gabbro_stairs": "磨製輝長岩樓梯", + "block.create.polished_gabbro_wall": "磨製輝長岩牆", + "block.create.polished_limestone": "磨製石灰岩", + "block.create.polished_limestone_slab": "磨製石灰岩半磚", + "block.create.polished_limestone_stairs": "磨製石灰岩樓梯", + "block.create.polished_limestone_wall": "磨製石灰岩牆", + "block.create.polished_scoria": "磨製火成岩", + "block.create.polished_scoria_slab": "磨製火成岩半磚", + "block.create.polished_scoria_stairs": "磨製火成岩樓梯", + "block.create.polished_scoria_wall": "磨製火成岩牆", + "block.create.polished_weathered_limestone": "磨製風化石灰岩", + "block.create.polished_weathered_limestone_slab": "磨製風化石灰岩半磚", + "block.create.polished_weathered_limestone_stairs": "磨製風化石灰岩樓梯", + "block.create.polished_weathered_limestone_wall": "磨製風化石灰岩牆", + "block.create.portable_fluid_interface": "移動式液體口", + "block.create.portable_storage_interface": "移動式物品口", + "block.create.powered_latch": "閂鎖器", + "block.create.powered_toggle_latch": "T型正反器", + "block.create.pulley_magnet": "滑輪磁鐵", + "block.create.pulse_repeater": "脈衝中繼器", + "block.create.purple_sail": "紫色風帆", + "block.create.purple_seat": "紫色坐墊", + "block.create.purple_valve_handle": "紫色閥門開關", + "block.create.radial_chassis": "旋轉底盤", + "block.create.red_sail": "紅色風帆", + "block.create.red_seat": "紅色坐墊", + "block.create.red_valve_handle": "紅色閥門開關", + "block.create.redstone_contact": "接觸式紅石訊號產生器", + "block.create.redstone_link": "無限紅石訊號機", + "block.create.refined_radiance_casing": "光輝機殼", + "block.create.reinforced_rail": "強化鐵軌", + "block.create.rope": "繩索", + "block.create.rope_pulley": "滑輪繩索", + "block.create.rotation_speed_controller": "轉速控制器", + "block.create.sail_frame": "風帆框架", + "block.create.schematic_table": "藍圖桌", + "block.create.schematicannon": "藍圖加農炮", + "block.create.scoria": "火成岩", + "block.create.scoria_bricks": "火成岩磚", + "block.create.scoria_bricks_slab": "火成岩半磚", + "block.create.scoria_bricks_stairs": "火成岩樓梯", + "block.create.scoria_bricks_wall": "火成岩牆", + "block.create.scoria_cobblestone": "碎火成岩", + "block.create.scoria_cobblestone_slab": "碎火成岩半磚", + "block.create.scoria_cobblestone_stairs": "碎火成岩樓梯", + "block.create.scoria_cobblestone_wall": "碎火成岩牆", + "block.create.scoria_pillar": "豎紋火成岩", + "block.create.secondary_linear_chassis": "機殼底盤2號", + "block.create.sequenced_gearshift": "可程式化齒輪箱", + "block.create.shadow_steel_casing": "暗影機殼", + "block.create.shaft": "傳動軸", + "block.create.smart_chute": "智慧滑道", + "block.create.smart_fluid_pipe": "智慧液體管道", + "block.create.speedometer": "速度計", + "block.create.spout": "液體灌注器", + "block.create.spruce_window": "雲杉木窗戶", + "block.create.spruce_window_pane": "雲杉木窗戶片", + "block.create.sticker": "方塊黏著器", + "block.create.sticky_mechanical_piston": "黏性機械活塞", + "block.create.stockpile_switch": "存量偵測器", + "block.create.stressometer": "動能錶", + "block.create.tiled_glass": "十字玻璃窗", + "block.create.tiled_glass_pane": "十字玻璃窗戶片", + "block.create.turntable": "轉盤", + "block.create.vertical_framed_glass": "豎直邊框玻璃", + "block.create.vertical_framed_glass_pane": "豎直邊框玻璃片", + "block.create.warped_window": "扭曲蕈木窗戶", + "block.create.warped_window_pane": "扭曲蕈木窗戶片", + "block.create.water_wheel": "水車", + "block.create.weathered_limestone": "風化石灰岩", + "block.create.weathered_limestone_bricks": "風化石灰岩磚", + "block.create.weathered_limestone_bricks_slab": "風化石灰岩半磚", + "block.create.weathered_limestone_bricks_stairs": "風化石灰岩樓梯", + "block.create.weathered_limestone_bricks_wall": "風化石灰岩牆", + "block.create.weathered_limestone_cobblestone": "碎風化石灰岩", + "block.create.weathered_limestone_cobblestone_slab": "碎風化石灰岩半磚", + "block.create.weathered_limestone_cobblestone_stairs": "碎風化石灰岩樓梯", + "block.create.weathered_limestone_cobblestone_wall": "碎風化石灰岩牆", + "block.create.weathered_limestone_pillar": "豎紋風化石灰岩", + "block.create.weighted_ejector": "物品彈射器", + "block.create.white_sail": "白色風帆", + "block.create.white_seat": "白色坐墊", + "block.create.white_valve_handle": "白色閥門開關", + "block.create.windmill_bearing": "風車軸承", + "block.create.wooden_bracket": "木製支架", + "block.create.yellow_sail": "黃色風帆", + "block.create.yellow_seat": "黃色坐墊", + "block.create.yellow_valve_handle": "黃色閥門開關", + "block.create.zinc_block": "鋅磚", + "block.create.zinc_ore": "鋅礦石", + + "entity.create.contraption": "結構", + "entity.create.gantry_contraption": "門式結構", + "entity.create.seat": "坐墊", + "entity.create.stationary_contraption": "固定結構", + "entity.create.super_glue": "強力膠", + + "fluid.create.milk": "牛奶", + "fluid.create.potion": "藥水", + "fluid.create.tea": "茶", + + "item.create.andesite_alloy": "安山合金", + "item.create.attribute_filter": "屬性過濾器", + "item.create.bar_of_chocolate": "巧克力棒", + "item.create.belt_connector": "輸送帶", + "item.create.blaze_cake": "熔岩蛋糕", + "item.create.blaze_cake_base": "熔岩蛋糕胚", + "item.create.brass_hand": "黃銅手部零件", + "item.create.brass_ingot": "黃銅錠", + "item.create.brass_nugget": "黃銅粒", + "item.create.brass_sheet": "黃銅板", + "item.create.builders_tea": "工人茶", + "item.create.chest_minecart_contraption": "裝修過的機械礦車", + "item.create.chocolate_bucket": "巧克力桶", + "item.create.chocolate_glazed_berries": "巧克力甜莓", + "item.create.chromatic_compound": "異彩化合物", + "item.create.cinder_flour": "地獄麵粉", + "item.create.copper_ingot": "銅錠", + "item.create.copper_nugget": "銅粒", + "item.create.copper_sheet": "銅板", + "item.create.crafter_slot_cover": "合成器蓋板", + "item.create.crushed_aluminum_ore": "碎狀鋁礦石", + "item.create.crushed_brass": "碎狀黃銅", + "item.create.crushed_copper_ore": "碎狀銅礦石", + "item.create.crushed_gold_ore": "碎狀金礦石", + "item.create.crushed_iron_ore": "碎狀鐵礦石", + "item.create.crushed_lead_ore": "碎狀鉛礦石", + "item.create.crushed_nickel_ore": "碎狀鎳礦石", + "item.create.crushed_osmium_ore": "碎狀鋨礦石", + "item.create.crushed_platinum_ore": "碎狀白金礦石", + "item.create.crushed_quicksilver_ore": "碎狀水銀礦石", + "item.create.crushed_silver_ore": "碎狀銀礦石", + "item.create.crushed_tin_ore": "碎狀錫礦石", + "item.create.crushed_uranium_ore": "碎狀鈾礦石", + "item.create.crushed_zinc_ore": "碎狀鋅礦石", + "item.create.deforester": "連根拔樹斧", + "item.create.dough": "麵團", + "item.create.electron_tube": "真空管", + "item.create.empty_blaze_burner": "空的烈焰使者動力爐", + "item.create.empty_schematic": "空白藍圖", + "item.create.extendo_grip": "伸縮機械手", + "item.create.filter": "過濾器", + "item.create.furnace_minecart_contraption": "裝配過的機械礦車", + "item.create.goggles": "MR護目鏡", + "item.create.golden_sheet": "金板", + "item.create.handheld_blockzapper": "方塊放置器", + "item.create.handheld_worldshaper": "地形雕塑器", + "item.create.honey_bucket": "蜂蜜桶", + "item.create.honeyed_apple": "蜂蜜蘋果", + "item.create.integrated_circuit": "IC板", + "item.create.iron_sheet": "鐵板", + "item.create.lapis_sheet": "青金石板", + "item.create.minecart_contraption": "裝修過的礦車", + "item.create.minecart_coupling": "礦車連結器", + "item.create.polished_rose_quartz": "磨製玫瑰石英", + "item.create.powdered_obsidian": "黑曜石粉末", + "item.create.propeller": "扇葉", + "item.create.red_sand_paper": "紅砂紙", + "item.create.refined_radiance": "光輝石", + "item.create.rose_quartz": "玫瑰石英", + "item.create.sand_paper": "砂紙", + "item.create.schematic": "藍圖", + "item.create.schematic_and_quill": "藍圖與筆", + "item.create.shadow_steel": "暗影鋼", + "item.create.super_glue": "強力膠", + "item.create.sweet_roll": "甜捲捲", + "item.create.tree_fertilizer": "樹木肥料", + "item.create.vertical_gearbox": "豎直齒輪箱", + "item.create.wand_of_symmetry": "對稱杖", + "item.create.wheat_flour": "小麥粉", + "item.create.whisk": "攪拌器", + "item.create.wrench": "扳手", + "item.create.zinc_ingot": "鋅錠", + "item.create.zinc_nugget": "鋅粒", + + + "_": "->------------------------] Advancements [------------------------<-", + + "advancement.create.root": "感謝你安裝機械動力模組,強烈建議您安裝JEI配合本模組遊玩", + "advancement.create.root.desc": "該來製作一些超棒的機械結構了!", + "advancement.create.andesite_alloy": "原始人類的合金替代品", + "advancement.create.andesite_alloy.desc": "機械動力有著許多的材料和合金,但受限於技術,原始的人類們暫時只能製作出安山合金", + "advancement.create.its_alive": "鮮活的機械生命", + "advancement.create.its_alive.desc": "首次使齒輪結構的旋轉。", + "advancement.create.shifting_gears": "換檔,加速,起飛!", + "advancement.create.shifting_gears.desc": "將大齒輪連接到小齒輪上,機械結構的轉速將會翻倍", + "advancement.create.overstressed": "過載", + "advancement.create.overstressed.desc": "首次使動能網路過載。", + "advancement.create.belt": "流水線作業", + "advancement.create.belt.desc": "用輸送帶連接兩個傳動軸", + "advancement.create.tunnel": "尋找掩護!", + "advancement.create.tunnel.desc": "在輸送帶上放上物品隧道。", + "advancement.create.splitter_tunnel": "分而治之", + "advancement.create.splitter_tunnel.desc": "用黃銅物品隧道設計一個分流器。", + "advancement.create.chute": "轟然倒塌", + "advancement.create.chute.desc": "放置一個滑道(垂直版本的輸送帶)。", + "advancement.create.upward_chute": "空中攔截", + "advancement.create.upward_chute.desc": "目睹拋出的物品飛入裝有風扇的滑道。", + "advancement.create.belt_funnel": "漏斗的垂簾", + "advancement.create.belt_funnel.desc": "將側向漏斗放在輸送帶或置物臺的上方。", + "advancement.create.belt_funnel_kiss": "比翼雙飛", + "advancement.create.belt_funnel_kiss.desc": "使兩個安裝在輸送帶上的漏斗相連。", + "advancement.create.fan": "機械氣槍", + "advancement.create.fan.desc": "飄浮在鼓風機吹出的氣流上", + "advancement.create.fan_lava": "空間加熱器", + "advancement.create.fan_lava.desc": "感受熔煉物品的氣流。", + "advancement.create.fan_water": "奇怪的洗滌", + "advancement.create.fan_water.desc": "被洗滌的氣流所吸引。", + "advancement.create.fan_smoke": "機械波紋管", + "advancement.create.fan_smoke.desc": "感受煙燻氣流。", + "advancement.create.wrench": "細部調整", + "advancement.create.wrench.desc": "做出一個方便調整方塊的板手", + "advancement.create.goggles": "動能,一目了然", + "advancement.create.goggles.desc": "做出一個能看到機械動能訊息的MR護目鏡", + "advancement.create.speedometer": "精密的速度控制", + "advancement.create.speedometer.desc": "放置一個速度計,並且戴上MR護目鏡來讀取數據", + "advancement.create.stressometer": "精密的動能控制", + "advancement.create.stressometer.desc": "放置一個動能錶,並且戴上MR護目鏡來讀取數據", + "advancement.create.aesthetics": "繁榮與美學!", + "advancement.create.aesthetics.desc": "將支架放在傳動軸,管道和齒輪上。", + "advancement.create.reinforced": "超級加固!", + "advancement.create.reinforced.desc": "在傳動軸,管道和輸送帶上使用機殼加固。", + "advancement.create.water_wheel": "治水", + "advancement.create.water_wheel.desc": "放置一個水車並讓它開始旋轉", + "advancement.create.chocolate_wheel": "美味的動能源", + "advancement.create.chocolate_wheel.desc": "用融化的巧克力驅動水車。", + "advancement.create.lava_wheel": "風火輪", + "advancement.create.lava_wheel.desc": "它不應該有用的..。", + "advancement.create.cuckoo": "是時候了?", + "advancement.create.cuckoo.desc": "目睹布穀鳥鐘報就寢時間。", + "advancement.create.millstone": "攜帶式粉碎機", + "advancement.create.millstone.desc": "放置一個石磨並且為其供能", + "advancement.create.windmill": "微風拂過", + "advancement.create.windmill.desc": "組裝風車。", + "advancement.create.maxed_windmill": "強風襲來", + "advancement.create.maxed_windmill.desc": "組裝最大動能的風車。", + "advancement.create.andesite_casing": "安山時代", + "advancement.create.andesite_casing.desc": "使用安山合金和木頭來合成一個安山機殼", + "advancement.create.mechanical_drill": "堅若磐石", + "advancement.create.mechanical_drill.desc": "放置一個機械鑽頭並且為其供能", + "advancement.create.press": "'噹!'", + "advancement.create.press.desc": "使用液壓機來壓製一些板子", + "advancement.create.polished_rose_quartz": "粉紅鑽石", + "advancement.create.polished_rose_quartz.desc": "用砂紙將玫瑰石英磨至透明", + "advancement.create.electron_tube": "嗶~~嗶~~", + "advancement.create.electron_tube.desc": "製作一個可用來合成高級機器的真空管", + "advancement.create.mechanical_saw": "一刀兩斷", + "advancement.create.mechanical_saw.desc": "放置一個切割機並且為其供能", + "advancement.create.basin": "快到碗裡來", + "advancement.create.basin.desc": "放置一個作業盆,並且往裡面放些東西", + "advancement.create.mixer": "充分攪拌", + "advancement.create.mixer.desc": "將攪拌機放在作業盆上方,並且使其攪拌盆內的物品", + "advancement.create.blaze_burner": "活生生的壁爐", + "advancement.create.blaze_burner.desc": "獲得一個烈焰使者動力爐。", + "advancement.create.compact": "快樂壓縮", + "advancement.create.compact.desc": "使用液壓機在作業盆中壓製一些物品", + "advancement.create.brass": "真正的合金", + "advancement.create.brass.desc": "使用粉碎鋅礦石和粉碎銅礦石來製作粉碎黃銅", + "advancement.create.brass_casing": "黃銅時代", + "advancement.create.brass_casing.desc": "用黃銅和木頭製作一個黃銅機殼", + "advancement.create.copper_casing": "銅時代", + "advancement.create.copper_casing.desc": "使用銅和木頭製作一個銅製機殼", + "advancement.create.spout": "裝填!", + "advancement.create.spout.desc": "觀察注液器灌滿物品。", + "advancement.create.spout_potion": "國際級啤酒大廠", + "advancement.create.spout_potion.desc": "觀察注液器注入藥水到玻璃瓶。", + "advancement.create.chocolate": "夢裡的世界", + "advancement.create.chocolate.desc": "獲取一桶熔融巧克力。", + "advancement.create.item_drain": "滾筒洗衣機", + "advancement.create.item_drain.desc": "觀察液體物品被分液池抽空。", + "advancement.create.chained_item_drain": "讓我們一起搖滾!", + "advancement.create.chained_item_drain.desc": "看著物品穿過多個分液池。", + "advancement.create.glass_pipe": "偷窺液體", + "advancement.create.glass_pipe.desc": "透過窗戶觀察液體在管道中流動。使用板手可打開直線液體管道的窗戶。", + "advancement.create.pipe_collision": "永不交會的溪流!", + "advancement.create.pipe_collision.desc": "觀察兩種液體在您的管道中會合", + "advancement.create.pipe_spill": "漏水啦!", + "advancement.create.pipe_spill.desc": "觀察管道的末端將液體排放到到外面。", + "advancement.create.hose_pulley": "工業排放", + "advancement.create.hose_pulley.desc": "放下一個軟管滑輪,觀察它排乾或充滿液體。", + "advancement.create.infinite_water": "抽取海洋", + "advancement.create.infinite_water.desc": "從足以被認為是無限的水源中抽水。", + "advancement.create.infinite_lava": "吸取行星的核心", + "advancement.create.infinite_lava.desc": "從廣闊的岩漿湖中抽出岩漿。", + "advancement.create.infinite_chocolate": "淹沒在幻想中", + "advancement.create.infinite_chocolate.desc": "從廣闊的巧克力海中抽出巧克力。", + "advancement.create.crafter": "自動化流水作業", + "advancement.create.crafter.desc": "放置一些機械合成臺並且為其供能", + "advancement.create.clockwork_bearing": "時差", + "advancement.create.clockwork_bearing.desc": "組裝安裝在發條軸承上的結構。", + "advancement.create.nixie_tube": "風格的跡象", + "advancement.create.nixie_tube.desc": "獲得真空管顯示器並放置。", + "advancement.create.deployer": "指爽沒?", + "advancement.create.deployer.desc": "放置並且啟動一個機械手。這可是你右手完美的複製品", + "advancement.create.speed_controller": "攻城屍討厭他!", + "advancement.create.speed_controller.desc": "放置一個轉速控制器,這是換檔的終極裝置。", + "advancement.create.flywheel": "工廠之心", + "advancement.create.flywheel.desc": "將引擎成功連接到飛輪。", + "advancement.create.overstress_flywheel": "壓力過大", + "advancement.create.overstress_flywheel.desc": "超載熔爐引擎。", + "advancement.create.integrated_circuit": "複雜的運算", + "advancement.create.integrated_circuit.desc": "合成IC板。", + "advancement.create.mechanical_arm": "忙碌的手!", + "advancement.create.mechanical_arm.desc": "製作機械手臂,選擇輸入和輸出,放置並給它動能; 然後看著它完成所有你交代的工作。", + "advancement.create.musical_arm": "沒人能在我的BGM裡打敗我!", + "advancement.create.musical_arm.desc": "使用機械手臂播放唱片。", + "advancement.create.arm_many_targets": "你是要累死我?", + "advancement.create.arm_many_targets.desc": "配置一隻有十個或更多輸出位置的機械手臂。", + "advancement.create.arm_blaze_burner": "燃燒吧!烈焰使者!", + "advancement.create.arm_blaze_burner.desc": "指揮機械手臂給烈焰使者動力爐投食。", + "advancement.create.fist_bump": "朋友,來擊拳", + "advancement.create.fist_bump.desc": "使兩個機械手互相碰拳", + "advancement.create.crushing_wheel": "一對大傢伙", + "advancement.create.crushing_wheel.desc": "製作一對能更快粉碎物品的粉碎輪", + "advancement.create.blaze_cake": "糖份超標", + "advancement.create.blaze_cake.desc": "幫烈焰使者動力爐烤一份特別的蛋糕。", + "advancement.create.chromatic_compound": "兩極材料", + "advancement.create.chromatic_compound.desc": "製作一個異彩化合物", + "advancement.create.shadow_steel": "自虛空的歸來的寶石", + "advancement.create.shadow_steel.desc": "製作暗影鋼", + "advancement.create.refined_radiance": "閃耀著純白的聖光", + "advancement.create.refined_radiance.desc": "製作光輝石", + "advancement.create.chromatic_age": "繽紛時代", + "advancement.create.chromatic_age.desc": "創造出光與影的機殼。", + "advancement.create.zapper": "專業的建築師", + "advancement.create.zapper.desc": "製作一個非常方便的方塊放置器", + "advancement.create.upgraded_zapper": "來自異世界的超頻", + "advancement.create.upgraded_zapper.desc": "製作一個完全升級的方塊放置器", + "advancement.create.wand_of_symmetry": "簡單的鏡面幾何學", + "advancement.create.wand_of_symmetry.desc": "製作一個對稱杖", + "advancement.create.deforester": "超時空砍伐", + "advancement.create.deforester.desc": "製作一個連根拔樹斧,然後跟你後院的樹林道別吧", + "advancement.create.extendo_grip": "piu piu piu!", + "advancement.create.extendo_grip.desc": "拿到一個伸縮機械手", + "advancement.create.dual_extendo_grip": "piu——piu——piu——", + "advancement.create.dual_extendo_grip.desc": "雙持伸縮機械手進一步加長觸碰距離", + "advancement.create.eob": "Beta版結束", + "advancement.create.eob.desc": "期待日後的更新。", + + + "_": "->------------------------] UI & Messages [------------------------<-", + + "itemGroup.create.base": "動力機械", + "itemGroup.create.palettes": "動力機械建築與裝飾方塊", + + "death.attack.create.crush": "%1$s被壓扁了", + "death.attack.create.fan_fire": "%1$s想接受熱風的洗禮", + "death.attack.create.fan_lava": "%1$s想接受熱風的洗禮但走火入魔", + "death.attack.create.mechanical_drill": "%1$s被鑽頭鑽爆腦袋", + "death.attack.create.mechanical_saw": "%1$s被鋸切成了兩半", + "death.attack.create.cuckoo_clock_explosion": "%1$s 被布穀鳥鐘炸得粉身碎骨", + + "create.block.deployer.damage_source_name": "機械手", + "create.block.cart_assembler.invalid": "將您的礦車裝修站放在鐵軌上", + + "create.recipe.crushing": "粉碎", + "create.recipe.milling": "研磨", + "create.recipe.fan_washing": "批次洗滌", + "create.recipe.fan_washing.fan": "在水後放置鼓風機", + "create.recipe.fan_smoking": "批次煙燻", + "create.recipe.fan_smoking.fan": "在火焰後放置鼓風機", + "create.recipe.fan_blasting": "批次融煉", + "create.recipe.fan_blasting.fan": "在熔岩後放置鼓風機", + "create.recipe.pressing": "金屬壓片", + "create.recipe.mixing": "混合攪拌", + "create.recipe.automatic_shapeless": "自動攪拌", + "create.recipe.automatic_brewing": "自動釀造", + "create.recipe.packing": "壓塊塑形", + "create.recipe.automatic_packing": "自動打包", + "create.recipe.sawing": "板材切割", + "create.recipe.mechanical_crafting": "自動合成", + "create.recipe.automatic_shaped": "自動合成", + "create.recipe.block_cutting": "方塊切割", + "create.recipe.wood_cutting": "木材切割", + "create.recipe.blockzapper_upgrade": "方塊放置器升級", + "create.recipe.sandpaper_polishing": "砂紙打磨", + "create.recipe.mystery_conversion": "神秘轉化", + "create.recipe.spout_filling": "注液", + "create.recipe.draining": "分液", + "create.recipe.processing.chance": "%1$s%%概率", + "create.recipe.heat_requirement.none": "不需要加熱", + "create.recipe.heat_requirement.heated": "普通加熱", + "create.recipe.heat_requirement.superheated": "超級加熱", + + "create.generic.range": "範圍", + "create.generic.radius": "半徑", + "create.generic.width": "寬", + "create.generic.height": "高", + "create.generic.length": "長", + "create.generic.speed": "速度", + "create.generic.delay": "延時", + "create.generic.unit.ticks": "Ticks", + "create.generic.unit.seconds": "秒", + "create.generic.unit.minutes": "分", + "create.generic.unit.rpm": "RPM", + "create.generic.unit.stress": "su", + "create.generic.unit.degrees": "度", + "create.generic.unit.millibuckets": "%1$smB", + "create.generic.clockwise": "順時鐘方向", + "create.generic.counter_clockwise": "逆時鐘方向", + + "create.action.scroll": "滾輪", + "create.action.confirm": "確認", + "create.action.abort": "退出", + "create.action.saveToFile": "離開", + "create.action.discard": "放棄", + + "create.keyinfo.toolmenu": "選單", + "create.keyinfo.scrollup": "(遊戲中)向上滑鼠滾輪", + "create.keyinfo.scrolldown": "(遊戲中)向下滑鼠滾輪", + + "create.gui.scrollInput.defaultTitle": "選擇一個選項:", + "create.gui.scrollInput.scrollToModify": "滾動修改", + "create.gui.scrollInput.scrollToAdjustAmount": "滾動修改數量", + "create.gui.scrollInput.scrollToSelect": "滾動選擇", + "create.gui.scrollInput.shiftScrollsFaster": "按住Shift滾動更快", + "create.gui.toolmenu.focusKey": "按住 [%1$s] 滑鼠滾輪選擇", + "create.gui.toolmenu.cycle": "[SCROLL] 循環", + "create.gui.symmetryWand.mirrorType": "鏡子類型", + "create.gui.symmetryWand.orientation": "方向", + + "create.symmetry.mirror.plane": "鏡像", + "create.symmetry.mirror.doublePlane": "矩形", + "create.symmetry.mirror.triplePlane": "八角", + + "create.orientation.orthogonal": "垂直", + "create.orientation.diagonal": "對角線", + "create.orientation.horizontal": "水平", + "create.orientation.alongZ": "以z軸對齊", + "create.orientation.alongX": "以x軸對齊", + + "create.gui.blockzapper.title": "方塊放置機", + "create.gui.blockzapper.replaceMode": "替換模式", + "create.gui.blockzapper.searchDiagonal": "對角線延伸", + "create.gui.blockzapper.searchFuzzy": "忽視種類分界", + "create.gui.blockzapper.range": "延伸範圍", + "create.gui.blockzapper.needsUpgradedAmplifier": "需要升級範圍擴大器", + "create.gui.blockzapper.patternSection": "模式", + "create.gui.blockzapper.pattern.solid": "實心", + "create.gui.blockzapper.pattern.checkered": "棋盤", + "create.gui.blockzapper.pattern.inversecheckered": "反轉棋盤", + "create.gui.blockzapper.pattern.chance25": "25% ", + "create.gui.blockzapper.pattern.chance50": "50% ", + "create.gui.blockzapper.pattern.chance75": "75% ", + "create.gui.terrainzapper.title": "地形雕塑器", + "create.gui.terrainzapper.placement": "放置模式", + "create.gui.terrainzapper.placement.merged": "結合", + "create.gui.terrainzapper.placement.attached": "依附", + "create.gui.terrainzapper.placement.inserted": "插入", + "create.gui.terrainzapper.brush": "雕塑類型", + "create.gui.terrainzapper.brush.cuboid": "矩形體", + "create.gui.terrainzapper.brush.sphere": "球體", + "create.gui.terrainzapper.brush.cylinder": "圓柱體", + "create.gui.terrainzapper.tool": "填充類型", + "create.gui.terrainzapper.tool.fill": "填充", + "create.gui.terrainzapper.tool.place": "覆寫", + "create.gui.terrainzapper.tool.replace": "替換", + "create.gui.terrainzapper.tool.clear": "清除", + "create.gui.terrainzapper.tool.overlay": "覆蓋", + "create.gui.terrainzapper.tool.flatten": "平整", + + "create.terrainzapper.shiftRightClickToSet": "Shift+滑鼠右鍵 以設定雕塑類型", + + "create.blockzapper.usingBlock": "使用:%1$s", + "create.blockzapper.componentUpgrades": "零件升級:", + "create.blockzapper.component.body": "放置器機體", + "create.blockzapper.component.amplifier": "範圍擴大器", + "create.blockzapper.component.accelerator": "射擊加速器", + "create.blockzapper.component.retriever": "物品撿回器", + "create.blockzapper.component.scope": "距離觀察鏡", + "create.blockzapper.componentTier.none": "無", + "create.blockzapper.componentTier.brass": "黃銅", + "create.blockzapper.componentTier.chromatic": "異彩化合物", + "create.blockzapper.leftClickToSet": "左鍵點擊方塊以設定方塊種類", + "create.blockzapper.empty": "方塊不足!", + + "create.minecart_coupling.two_couplings_max": "礦車無法被連接兩個以上的礦車連結器", + "create.minecart_coupling.unloaded": "有一部份礦車存在於未讀取區塊中", + "create.minecart_coupling.no_loops": "礦車連結器不能連成一個環", + "create.minecart_coupling.removed": "從礦車上移除所有礦車連結器", + "create.minecart_coupling.too_far": "礦車距離你太遠了", + + "create.contraptions.movement_mode": "運動模式", + "create.contraptions.movement_mode.move_place": "停止時實體化方塊", + "create.contraptions.movement_mode.move_place_returned": "只在初始位置實體化方塊", + "create.contraptions.movement_mode.move_never_place": "只有在機械方塊摧毀後才實體化方塊", + "create.contraptions.movement_mode.rotate_place": "停止時實體化方塊", + "create.contraptions.movement_mode.rotate_place_returned": "只在接近初始角度實體化方塊", + "create.contraptions.movement_mode.rotate_never_place": "只有在旋轉軸摧毀後才實體化方塊", + "create.contraptions.cart_movement_mode": "礦車運動模式", + "create.contraptions.cart_movement_mode.rotate": "結構與礦車保持相同方向", + "create.contraptions.cart_movement_mode.rotate_paused": "礦車轉向時機器停止工作", + "create.contraptions.cart_movement_mode.rotation_locked": "結構方向保持不變", + "create.contraptions.windmill.rotation_direction": "旋轉方向", + "create.contraptions.clockwork.clock_hands": "鐘錶指針", + "create.contraptions.clockwork.hour_first": "時針優先", + "create.contraptions.clockwork.minute_first": "分針優先", + "create.contraptions.clockwork.hour_first_24": "24小時制優先", + + "create.logistics.filter": "過濾器", + "create.logistics.recipe_filter": "配方過濾器", + "create.logistics.fluid_filter": "液體過濾器", + "create.logistics.firstFrequency": "頻道. #1", + "create.logistics.secondFrequency": "頻道. #2", + "create.logistics.filter.apply": "將過濾器應用來%1$s。", + "create.logistics.filter.apply_click_again": "將過濾器應用來%1$s,再次點擊以復制數量。", + "create.logistics.filter.apply_count": "使用提取計數過濾。", + + "create.gui.goggles.generator_stats": "產能器狀態:", + "create.gui.goggles.kinetic_stats": "機械狀態:", + "create.gui.goggles.at_current_speed": "目前動能值", + "create.gui.goggles.pole_length": "活塞桿長度:", + "create.gui.goggles.fluid_container": "液體容器資訊:", + "create.gui.goggles.fluid_container.capacity": "容量: ", + "create.gui.assembly.exception": "該結構無法組合:", + "create.gui.assembly.exception.unmovableBlock": "無法移動的方塊 (%4$s) 位於 [%1$s,%2$s,%3$s]", + "create.gui.assembly.exception.chunkNotLoaded": "位於 [%1$s,%2$s,%3$s] 方塊屬未載入區塊", + "create.gui.assembly.exception.structureTooLarge": "結構中的方塊數量過多.\nThe 可放置的數量最大為: %1$s", + "create.gui.assembly.exception.tooManyPistonPoles": "活塞的活塞桿數量過多\nThe 可放置的數量最大為: %1$s", + "create.gui.assembly.exception.noPistonPoles": "這個活塞遺失了一些活塞桿", + "create.gui.assembly.exception.not_enough_sails": "結構中所需的風帆類方塊數量不足: %1$s\n最少需要的數量為: %2$s", + "create.gui.gauge.info_header": "儀表訊息:", + "create.gui.speedometer.title": "旋轉速度", + "create.gui.stressometer.title": "網路動能", + "create.gui.stressometer.capacity": "剩餘動能量", + "create.gui.stressometer.overstressed": "動能過載", + "create.gui.stressometer.no_rotation": "無旋轉", + "create.gui.contraptions.not_fast_enough": "看起來%1$s 沒有達到足夠的工作轉速。", + "create.gui.contraptions.network_overstressed": "裝置似乎過載,減少高動能消耗的裝置或者增加更多更多動能", + "create.gui.adjustable_crate.title": "板條箱", + "create.gui.adjustable_crate.storageSpace": "儲存空間", + "create.gui.stockpile_switch.title": "儲存開關", + "create.gui.stockpile_switch.invert_signal": "反轉訊號", + "create.gui.stockpile_switch.move_to_lower_at": "移至下線%1$s%%", + "create.gui.stockpile_switch.move_to_upper_at": "移至上線%1$s%%", + "create.gui.sequenced_gearshift.title": "可程式化齒輪箱", + "create.gui.sequenced_gearshift.instruction": "指令", + "create.gui.sequenced_gearshift.instruction.turn_angle.descriptive": "以特定角度旋轉", + "create.gui.sequenced_gearshift.instruction.turn_angle": "旋轉", + "create.gui.sequenced_gearshift.instruction.turn_angle.angle": "角度", + "create.gui.sequenced_gearshift.instruction.turn_distance.descriptive": "帶動 活塞/滑輪/門式起重機", + "create.gui.sequenced_gearshift.instruction.turn_distance": "驅動活塞", + "create.gui.sequenced_gearshift.instruction.turn_distance.distance": "距離", + "create.gui.sequenced_gearshift.instruction.delay.descriptive": "延遲時間", + "create.gui.sequenced_gearshift.instruction.delay": "延遲", + "create.gui.sequenced_gearshift.instruction.delay.duration": "間隔", + "create.gui.sequenced_gearshift.instruction.end.descriptive": "結束", + "create.gui.sequenced_gearshift.instruction.end": "停止", + "create.gui.sequenced_gearshift.instruction.await.descriptive": "等待新的紅石脈衝", + "create.gui.sequenced_gearshift.instruction.await": "等待", + "create.gui.sequenced_gearshift.speed": "速度,速度方向", + "create.gui.sequenced_gearshift.speed.forward": "一倍速,正向", + "create.gui.sequenced_gearshift.speed.forward_fast": "兩倍速,正向", + "create.gui.sequenced_gearshift.speed.back": "一倍速,反向", + "create.gui.sequenced_gearshift.speed.back_fast": "兩倍速,反向", + + "create.schematicAndQuill.dimensions": "藍圖尺寸:%1$sx%2$sx%3$s", + "create.schematicAndQuill.firstPos": "第一個位置。", + "create.schematicAndQuill.secondPos": "第二個位置。", + "create.schematicAndQuill.noTarget": "按住Ctrl選擇空氣方塊。", + "create.schematicAndQuill.abort": "刪除選擇。", + "create.schematicAndQuill.title": "藍圖名:", + "create.schematicAndQuill.convert": "立即存檔並發佈", + "create.schematicAndQuill.fallbackName": "我的藍圖", + "create.schematicAndQuill.saved": "另存為%1$s", + + "create.schematic.invalid": "[!] 無效的項目", + "create.schematic.position": "位置", + "create.schematic.rotation": "旋轉", + "create.schematic.rotation.none": "無", + "create.schematic.rotation.cw90": "順時鐘90", + "create.schematic.rotation.cw180": "順時鐘180", + "create.schematic.rotation.cw270": "順時鐘270", + "create.schematic.mirror": "鏡像", + "create.schematic.mirror.none": "無", + "create.schematic.mirror.frontBack": "前後", + "create.schematic.mirror.leftRight": "左右", + "create.schematic.tool.deploy": "發佈", + "create.schematic.tool.move": "移動 XZ", + "create.schematic.tool.movey": "移動 Y", + "create.schematic.tool.rotate": "旋轉", + "create.schematic.tool.print": "列印", + "create.schematic.tool.flip": "翻轉", + "create.schematic.tool.deploy.description.0": "將結構移到某個位置。", + "create.schematic.tool.deploy.description.1": "在地面上點擊滑鼠右鍵以放置。", + "create.schematic.tool.deploy.description.2": "按住Ctrl以固定距離選擇。", + "create.schematic.tool.deploy.description.3": "按住Ctrl滑鼠滾動更改距離。", + "create.schematic.tool.move.description.0": "水平移動藍圖", + "create.schematic.tool.move.description.1": "選定藍圖,然後按住Ctrl滑鼠滾動。", + "create.schematic.tool.move.description.2": "", + "create.schematic.tool.move.description.3": "", + "create.schematic.tool.movey.description.0": "垂直移動藍圖", + "create.schematic.tool.movey.description.1": "按住Ctrl滑鼠滾動上下移動", + "create.schematic.tool.movey.description.2": "", + "create.schematic.tool.movey.description.3": "", + "create.schematic.tool.rotate.description.0": "圍繞藍圖中心旋轉藍圖。", + "create.schematic.tool.rotate.description.1": "按住Ctrl滑鼠滾動旋轉90度", + "create.schematic.tool.rotate.description.2": "", + "create.schematic.tool.rotate.description.3": "", + "create.schematic.tool.print.description.0": "立即將結構放置在世界上", + "create.schematic.tool.print.description.1": "右鍵點擊確認目前位置。", + "create.schematic.tool.print.description.2": "該工具僅能用於創造模式。", + "create.schematic.tool.print.description.3": "", + "create.schematic.tool.flip.description.0": "沿你選擇的面翻轉藍圖。", + "create.schematic.tool.flip.description.1": "指向藍圖,然後按住Ctrl滑鼠滾動將其翻轉。", + "create.schematic.tool.flip.description.2": "", + "create.schematic.tool.flip.description.3": "", + + "create.schematics.synchronizing": "正在同步..", + "create.schematics.uploadTooLarge": "你的藍圖太大", + "create.schematics.maxAllowedSize": "允許的最大藍圖文件大小為:", + + "create.gui.schematicTable.refresh": "重新整理文件", + "create.gui.schematicTable.open_folder": "打開資料夾", + "create.gui.schematicTable.title": "藍圖桌", + "create.gui.schematicTable.availableSchematics": "可用藍圖", + "create.gui.schematicTable.noSchematics": "沒有存檔的藍圖", + "create.gui.schematicTable.uploading": "正在上傳...", + "create.gui.schematicTable.finished": "上傳完成!", + "create.gui.schematicannon.title": "藍圖加農炮", + "create.gui.schematicannon.listPrinter": "物品清單列印機", + "create.gui.schematicannon.gunpowderLevel": "火藥%1$s%%", + "create.gui.schematicannon.shotsRemaining": "發射進度:%1$s", + "create.gui.schematicannon.shotsRemainingWithBackup": "備份:%1$s", + "create.gui.schematicannon.optionEnabled": "目前啟用", + "create.gui.schematicannon.optionDisabled": "目前停用", + "create.gui.schematicannon.showOptions": "顯示藍圖加農炮設定", + "create.gui.schematicannon.option.dontReplaceSolid": "不要替換方塊", + "create.gui.schematicannon.option.replaceWithSolid": "用固體方塊替換工作區域內的方塊", + "create.gui.schematicannon.option.replaceWithAny": "用任何方塊替換工作區域內的方塊", + "create.gui.schematicannon.option.replaceWithEmpty": "用空氣替換工作區域內的方塊", + "create.gui.schematicannon.option.skipMissing": "繞過缺少的方塊", + "create.gui.schematicannon.option.skipTileEntities": "保護儲存方塊", + "create.gui.schematicannon.slot.gunpowder": "向藍圖加農炮添加火藥以提供動能", + "create.gui.schematicannon.slot.listPrinter": "在此處放置書以列印藍圖所需的材料清單", + "create.gui.schematicannon.slot.schematic": "在此處添加你的藍圖,務必確保其已被部放置在特定位置", + "create.gui.schematicannon.option.skipMissing.description": "如果材料不夠,藍圖大炮將忽略目前不夠的材料並且使用其他已有材料繼續工作", + "create.gui.schematicannon.option.skipTileEntities.description": "藍圖將避免更換儲存方塊,如箱子。", + "create.gui.schematicannon.option.dontReplaceSolid.description": "藍圖加農炮將不會替換工作範圍內的任何固體方塊。", + "create.gui.schematicannon.option.replaceWithSolid.description": "藍圖加農炮會使用所提供的固體方塊來替換工作區域內的其他固體方塊", + "create.gui.schematicannon.option.replaceWithAny.description": "藍圖加農炮會使用任何所提供的方塊來替換工作區域內的固體方塊", + "create.gui.schematicannon.option.replaceWithEmpty.description": "藍圖加農炮將清理和替換工作區域內所有原本的方塊。", + + "create.schematicannon.status.idle": "閒置", + "create.schematicannon.status.ready": "準備", + "create.schematicannon.status.running": "啟動", + "create.schematicannon.status.finished": "完成", + "create.schematicannon.status.paused": "已暫停", + "create.schematicannon.status.stopped": "停止", + "create.schematicannon.status.noGunpowder": "火藥消耗完畢", + "create.schematicannon.status.targetNotLoaded": "方塊未讀取", + "create.schematicannon.status.targetOutsideRange": "定位目標太遠", + "create.schematicannon.status.searching": "搜尋", + "create.schematicannon.status.skipping": "跳過", + "create.schematicannon.status.missingBlock": "缺少方塊:", + "create.schematicannon.status.placing": "建築中", + "create.schematicannon.status.clearing": "清除方塊中", + "create.schematicannon.status.schematicInvalid": "藍圖無效", + "create.schematicannon.status.schematicNotPlaced": "藍圖未發佈", + "create.schematicannon.status.schematicExpired": "藍圖文件已過期", + + "create.materialChecklist": "材料清單", + "create.materialChecklist.blocksNotLoaded": "*免責聲明* \n\n由於未讀取相關區塊,材料清單可能不正確。", + + "create.gui.filter.deny_list": "黑名單", + "create.gui.filter.deny_list.description": "只通過不在黑名單中的物品,如果黑名單為空,所有物品都可以通過", + "create.gui.filter.allow_list": "白名單", + "create.gui.filter.allow_list.description": "只通過在白名單中的物品,如果白名單為空,所有物品都無法通過", + "create.gui.filter.respect_data": "比對物品屬性", + "create.gui.filter.respect_data.description": "只有物品的耐久、附魔等其他屬性相同時才可以比對", + "create.gui.filter.ignore_data": "忽略物品屬性", + "create.gui.filter.ignore_data.description": "配對時忽略物品的耐久、附魔等其他屬性", + + "create.item_attributes.placeable": "可放置", + "create.item_attributes.placeable.inverted": "不可放置", + "create.item_attributes.consumable": "可食用", + "create.item_attributes.consumable.inverted": "不可食用", + "create.item_attributes.smeltable": "可被熔爐融煉", + "create.item_attributes.smeltable.inverted": "不可被熔爐融煉", + "create.item_attributes.washable": "可被篩洗", + "create.item_attributes.washable.inverted": "不可被篩洗", + "create.item_attributes.smokable": "可被煙熏", + "create.item_attributes.smokable.inverted": "不可被煙熏", + "create.item_attributes.crushable": "可被粉碎", + "create.item_attributes.crushable.inverted": "不可被粉碎", + "create.item_attributes.blastable": "可被高爐融煉", + "create.item_attributes.blastable.inverted": "不可被高爐融煉", + "create.item_attributes.enchanted": "已被附魔", + "create.item_attributes.enchanted.inverted": "未被附魔", + "create.item_attributes.damaged": "已損壞", + "create.item_attributes.damaged.inverted": "未損壞", + "create.item_attributes.badly_damaged": "嚴重受損", + "create.item_attributes.badly_damaged.inverted": "未嚴重受損", + "create.item_attributes.not_stackable": "無法堆疊", + "create.item_attributes.not_stackable.inverted": "可堆疊", + "create.item_attributes.equipable": "可裝備", + "create.item_attributes.equipable.inverted": "不可裝備", + "create.item_attributes.furnace_fuel": "是燃料", + "create.item_attributes.furnace_fuel.inverted": "不是燃料", + "create.item_attributes.in_tag": "標籤是%1$s", + "create.item_attributes.in_tag.inverted": "標籤不是%1$s", + "create.item_attributes.in_item_group": "屬於%1$s", + "create.item_attributes.in_item_group.inverted": "不屬於%1$s", + "create.item_attributes.added_by": "由%1$s添加", + "create.item_attributes.added_by.inverted": "不是由%1$s添加", + "create.item_attributes.has_enchant": "有附魔效果%1$s", + "create.item_attributes.has_enchant.inverted": "沒有附魔效果%1$s", + "create.item_attributes.color": "UNLOCALIZED: is dyed %1$s", + "create.item_attributes.color.inverted": "UNLOCALIZED: is not dyed %1$s", + "create.item_attributes.max_enchanted": "UNLOCALIZED: is enchanted at max level", + "create.item_attributes.max_enchanted.inverted": "UNLOCALIZED: is not enchanted at max level", + "create.item_attributes.has_fluid": "包含%1$s", + "create.item_attributes.has_fluid.inverted": "不包含%1$s", + "create.item_attributes.has_name": "有自定義名稱%1$s", + "create.item_attributes.has_name.inverted": "沒有自定義名稱%1$s", + "create.item_attributes.book_author": "由%1$s編寫", + "create.item_attributes.book_author.inverted": "未由%1$s編寫", + "create.item_attributes.book_copy_original": "是原創的", + "create.item_attributes.book_copy_original.inverted": "不是原創的", + "create.item_attributes.book_copy_first": "是第一份複製", + "create.item_attributes.book_copy_first.inverted": "不是第一份複製", + "create.item_attributes.book_copy_second": "是第二份複製", + "create.item_attributes.book_copy_second.inverted": "不是第二份複製", + "create.item_attributes.book_copy_tattered": "是第三份複製", + "create.item_attributes.book_copy_tattered.inverted": "不是第三份複製", + "create.item_attributes.astralsorcery_crystal": "具有晶體屬性%1$s", + "create.item_attributes.astralsorcery_crystal.inverted": "不具有晶體屬性%1$s", + "create.item_attributes.astralsorcery_constellation": "與%1$s調諧", + "create.item_attributes.astralsorcery_constellation.inverted": "未與%1$s調諧", + "create.item_attributes.astralsorcery_perk_gem": "具有特殊屬性%1$s", + "create.item_attributes.astralsorcery_perk_gem.inverted": "不具有特殊屬性%1$s", + "create.item_attributes.astralsorcery_amulet": "提升%1$s", + "create.item_attributes.astralsorcery_amulet.inverted": "不提升%1$s", + + "create.gui.attribute_filter.no_selected_attributes": "沒有標記任何屬性", + "create.gui.attribute_filter.selected_attributes": "已選擇的屬性:", + "create.gui.attribute_filter.add_attribute": "向列表中添加屬性", + "create.gui.attribute_filter.add_inverted_attribute": "向列表中添加相反屬性", + "create.gui.attribute_filter.allow_list_disjunctive": "任意比對白名單(任何)", + "create.gui.attribute_filter.allow_list_disjunctive.description": "只要有其中一項屬性符合,就可以通過", + "create.gui.attribute_filter.allow_list_conjunctive": "全部比對白名單(全部)", + "create.gui.attribute_filter.allow_list_conjunctive.description": "只有所有屬性都相符才可以通過", + "create.gui.attribute_filter.deny_list": "黑名單", + "create.gui.attribute_filter.deny_list.description": "只要沒有上述屬性,就可以通過", + "create.gui.attribute_filter.add_reference_item": "添加參考物品", + + "create.tooltip.holdForDescription": "按住 [%1$s] 來讀取物品概要", + "create.tooltip.holdForControls": "按住 [%1$s] 來讀取控制方法", + "create.tooltip.keyShift": "Shift", + "create.tooltip.keyCtrl": "Ctrl", + "create.tooltip.speedRequirement": "需求速度:%1$s", + "create.tooltip.speedRequirement.none": "無", + "create.tooltip.speedRequirement.medium": "適當", + "create.tooltip.speedRequirement.high": "快", + "create.tooltip.stressImpact": "動能消耗:%1$s", + "create.tooltip.stressImpact.low": "低", + "create.tooltip.stressImpact.medium": "中", + "create.tooltip.stressImpact.high": "高", + "create.tooltip.stressImpact.overstressed": "過載", + "create.tooltip.capacityProvided": "動能生產量:%1$s", + "create.tooltip.capacityProvided.low": "小", + "create.tooltip.capacityProvided.medium": "中", + "create.tooltip.capacityProvided.high": "大", + "create.tooltip.generationSpeed": "產生%1$s %2$s", + "create.tooltip.analogStrength": "調節強度:%1$s/15", + + "create.mechanical_arm.extract_from": "從%1$s 拿取物品", + "create.mechanical_arm.deposit_to": "向%1$s 儲存物品", + "create.mechanical_arm.summary": "機械手臂有%1$s 輸入以及 %2$s 輸出。", + "create.mechanical_arm.points_outside_range": "%1$s 由於距離限制,選定的交互點被移除。", + + "create.weighted_ejector.target_set": "已選取目的地", + "create.weighted_ejector.target_not_valid": "彈射到鄰近的方塊 (目的地無效)", + "create.weighted_ejector.no_target": "彈射到鄰近的方塊 (未選取目的地)", + "create.weighted_ejector.targeting": "彈射到 [%1$s,%2$s,%3$s]", + "create.weighted_ejector.stack_size": "彈射物品數量", + + "create.logistics.when_multiple_outputs_available": "當多個輸出可用時", + + "create.mechanical_arm.selection_mode.round_robin": "輪詢調度", + "create.mechanical_arm.selection_mode.forced_round_robin": "強制輪詢調度", + "create.mechanical_arm.selection_mode.prefer_first": "第一目標優先", + + "create.tunnel.selection_mode.split": "分攤", + "create.tunnel.selection_mode.forced_split": "強制分攤", + "create.tunnel.selection_mode.round_robin": "輪詢調度", + "create.tunnel.selection_mode.forced_round_robin": "強制輪詢調度", + "create.tunnel.selection_mode.prefer_nearest": "最近優先", + "create.tunnel.selection_mode.randomize": "隨機", + "create.tunnel.selection_mode.synchronize": "同步輸入", + + "create.tooltip.chute.header": "滑道訊息", + "create.tooltip.chute.items_move_down": "物品向下移動", + "create.tooltip.chute.items_move_up": "物品向上移動", + "create.tooltip.chute.no_fans_attached": "未安裝鼓風機", + "create.tooltip.chute.fans_push_up": "鼓風機從下方進行推動", + "create.tooltip.chute.fans_push_down": "鼓風機從上方進行推動", + "create.tooltip.chute.fans_pull_up": "鼓風機從下方進行吸引", + "create.tooltip.chute.fans_pull_down": "鼓風機從上方進行吸引", + "create.tooltip.chute.contains": "物品: %1$s x%2$s", + + "create.hint.hose_pulley.title": "無限供應", + "create.hint.hose_pulley": "目標液體為無限供應", + "create.hint.mechanical_arm_no_targets.title": "沒有目標", + "create.hint.mechanical_arm_no_targets": "看起來這個_機械手臂_沒有被分配任何_目標_。在手持機械手臂的同時,右鍵選取輸送帶、置物臺、漏斗或其他設備來設定目標。", + "create.hint.empty_bearing.title": "更新軸承", + "create.hint.empty_bearing": "_空手右鍵_軸承來_添加_你新建造的結構。", + "create.hint.full_deployer.title": "機械手物品溢出", + "create.hint.full_deployer": "_機械手_包含_過剩的物品_需要被_取出._使用漏斗_或其他方法將溢出解決。", + + "create.gui.config.overlay1": "嗨 :)", + "create.gui.config.overlay2": "這是一個實例層", + "create.gui.config.overlay3": "點擊拖拽你的滑鼠", + "create.gui.config.overlay4": "來將它移動到前方", + "create.gui.config.overlay5": "ESC退出目前介面", + "create.gui.config.overlay6": "並儲存新的位置", + "create.gui.config.overlay7": "輸入/create overlay reset", + "create.gui.config.overlay8": "重置到預設位置", + + "create.command.killTPSCommand": "killtps", + "create.command.killTPSCommand.status.slowed_by.0": "[Create]: 伺服器每秒TICK被降為 %s ms :o", + "create.command.killTPSCommand.status.slowed_by.1": "[Create]: 伺服器現在每秒TICK被降為 >:)", + "create.command.killTPSCommand.status.slowed_by.2": "[Create]: 伺服器現在不延遲了,TPS正常 :D", + "create.command.killTPSCommand.status.usage.0": "[Create]: 用 /killtps stop 來讓伺服器的TPS速度恢復正常", + "create.command.killTPSCommand.status.usage.1": "[Create]: 用 /killtps start 來手動降低伺服器TPS", + "create.command.killTPSCommand.argument.tickTime": "tickTime", + + "create.contraption.minecart_contraption_too_big": "這個礦車結構太大了而無法撿取", + + + "_": "->------------------------] Subtitles [------------------------<-", + + "create.subtitle.schematicannon_launch_block": "藍圖大炮發射", + "create.subtitle.schematicannon_finish": "藍圖大炮完成任務", + "create.subtitle.slime_added": "黏液擠壓", + "create.subtitle.mechanical_press_activation_belt": "液壓機工作", + "create.subtitle.mechanical_press_activation": "液壓機工作", + "create.subtitle.blockzapper_deny": "放置失敗", + "create.subtitle.blockzapper_confirm": "選擇方塊", + "create.subtitle.blockzapper_place": "放置方塊", + "create.subtitle.blaze_munch": "烈焰使者開心地吃著", + + + "_": "->------------------------] Item Descriptions [------------------------<-", + + "item.create.example_item.tooltip": "EXAMPLE ITEM (just a marker that this tooltip exists)", + "item.create.example_item.tooltip.summary": "A brief description of the item._Underscores_highlight a term.", + "item.create.example_item.tooltip.condition1": "When this", + "item.create.example_item.tooltip.behaviour1": "Then this item does this。(behaviours show on shift)", + "item.create.example_item.tooltip.condition2": "And When this", + "item.create.example_item.tooltip.behaviour2": "You can add as many behaviours as you like", + "item.create.example_item.tooltip.control1": "When Ctrl pressed", + "item.create.example_item.tooltip.action1": "These controls are displayed.", + + "block.create.wooden_bracket.tooltip": "木製支架", + "block.create.wooden_bracket.tooltip.summary": "用來裝飾_傳動軸_,_齒輪_和_管道_。", + + "block.create.metal_bracket.tooltip": "金屬支架", + "block.create.metal_bracket.tooltip.summary": "用來裝飾_傳動軸_,_齒輪_和_管道_。", + + "block.create.copper_casing.tooltip": "銅製機殼", + "block.create.copper_casing.tooltip.summary": "具備多種用途的堅固機殼,也可用於裝飾。", + "block.create.copper_casing.tooltip.condition1": "對液體管道使用時", + "block.create.copper_casing.tooltip.behaviour1": "會把管道裝入機殼,裝進機殼的管道會與其他管道分開,以免它們自動相連。", + + "block.create.encased_fluid_pipe.tooltip": "液體管道箱", + "block.create.encased_fluid_pipe.tooltip.summary": "用銅機殼加固后的液體管道。", + + "block.create.seat.tooltip": "坐墊", + "block.create.seat.tooltip.summary": "坐下來享受旅程吧!坐墊將會把玩家固定在一個移動裝置上。也可以用來作為居家裝飾,畢竟他有許多顏色。", + "block.create.seat.tooltip.condition1": "對坐墊右鍵", + "block.create.seat.tooltip.behaviour1": "玩家將坐在_坐墊_上,Left-Shift可離開_坐墊_。", + + "item.create.blaze_cake.tooltip": "熔岩蛋糕", + "item.create.blaze_cake.tooltip.summary": "對辛苦的_烈焰使者_的美味款待。讓他們興奮起來吧!", + + "block.create.fluid_pipe.tooltip": "液體管道", + "block.create.fluid_pipe.tooltip.summary": "用來傳輸_液體_。需要一個_機械泵_來提供壓強。", + "block.create.fluid_pipe.tooltip.condition1": "轉移液體", + "block.create.fluid_pipe.tooltip.behaviour1": "可以與_液體容器_如_儲存罐_或_作業盆_相連_。裸露的_管道_末端也可以排放或抽取液體。注意別漏水了!", + "block.create.fluid_pipe.tooltip.condition2": "使用扳手對其右鍵時", + "block.create.fluid_pipe.tooltip.behaviour2": "在狀況許可的情況下在管道上安裝透明窗", + + "block.create.hose_pulley.tooltip": "軟管滑輪", + "block.create.hose_pulley.tooltip.summary": "用來在_世界_中放置或排放大量的液體。", + "block.create.hose_pulley.tooltip.condition1": "接入機械時", + "block.create.hose_pulley.tooltip.behaviour1": "升高或降低軟管,軟管的位置決定了抽取或填充液體的高度。", + "block.create.hose_pulley.tooltip.condition2": "當軟管滑輪抽取液體時", + "block.create.hose_pulley.tooltip.behaviour2": "開始從軟管末端將其從中取出_液體方塊_。巨大的液體湖將被認定是_無限_的", + "block.create.hose_pulley.tooltip.condition3": "當液體從軟管滑輪中排出時", + "block.create.hose_pulley.tooltip.behaviour3": "開始向世界填充液體,直到達到_軟管末端_的高度。", + + "block.create.fluid_tank.tooltip": "液體儲存罐", + "block.create.fluid_tank.tooltip.summary": "_儲存_任意_液體_", + "block.create.fluid_tank.tooltip.condition1": "使用扳手右鍵", + "block.create.fluid_tank.tooltip.behaviour1": "改變可選窗口", + + "block.create.creative_fluid_tank.tooltip": "創造液體儲存罐", + "block.create.creative_fluid_tank.tooltip.summary": "此液體儲存罐能夠_無限的復制_任何液體。", + "block.create.creative_fluid_tank.tooltip.condition1": "罐中裝有液體時", + "block.create.creative_fluid_tank.tooltip.behaviour1": "任意的_液體提取設備_能夠從中提取無窮無盡的指定液體,液體的導入功能同時也會無效。", + "block.create.creative_fluid_tank.tooltip.condition2": "扳手右擊時", + "block.create.creative_fluid_tank.tooltip.behaviour2": "打開關閉窗戶", + + "block.create.fluid_valve.tooltip": "液體閥門", + "block.create.fluid_valve.tooltip.summary": "阻止液體沿管道向前流動。", + "block.create.fluid_valve.tooltip.condition1": "控制流量", + "block.create.fluid_valve.tooltip.behaviour1": "施加的_動能_將迫使閥門關閉,從而阻止液體流動。_逆轉旋轉方向_以重新打開閥門。", + + "block.create.mechanical_pump.tooltip": "機械泵", + "block.create.mechanical_pump.tooltip.summary": "_接入機械_,能迫使液體_沿管道指定方向移動_。在兩個方向上都有_最大的作用範圍_。(默認為16個方塊距離)", + "block.create.mechanical_pump.tooltip.condition1": "液體流向", + "block.create.mechanical_pump.tooltip.behaviour1": "_接入機械_后會產生壓力,迫使液體通過管道。_反轉機械_的方向以切換液體_流向_。", + "block.create.mechanical_pump.tooltip.control1": "扳手右鍵時", + "block.create.mechanical_pump.tooltip.action1": "反轉泵的方向,從而改變默認的液體流向", + + "block.create.smart_fluid_pipe.tooltip": "智慧液體管道", + "block.create.smart_fluid_pipe.tooltip.summary": "帶有過濾器的_液體管道_。可以指定通過哪個_液體_。", + "block.create.smart_fluid_pipe.tooltip.condition1": "當液體進入時", + "block.create.smart_fluid_pipe.tooltip.behaviour1": "進入的液體與_過濾器_不匹配時,智慧管道將_阻止_其通過。", + "block.create.smart_fluid_pipe.tooltip.condition2": "與_液體容器相鄰_時", + "block.create.smart_fluid_pipe.tooltip.behaviour2": "從_任何容器_開始流動的_智慧管道_只會抽取與其過濾器匹配的液體。", + + "block.create.spout.tooltip": "注液器", + "block.create.spout.tooltip.summary": "一種用來_裝罐_的機器。", + "block.create.spout.tooltip.condition1": "液體傳輸", + "block.create.spout.tooltip.behaviour1": "當下方放置類似_玻璃瓶_,_桶_這樣的液體容器物品時,注液器將試圖將自身儲存的液體注入到下方的_液體容器物品_中。", + "block.create.spout.tooltip.condition2": "液體自動化", + "block.create.spout.tooltip.behaviour2": "注液器位於_輸送帶_或者_置物臺_上方時,將自動為流水線上的_液體容器物品_進行_注入_。", + + "block.create.item_drain.tooltip": "分液池", + "block.create.item_drain.tooltip.summary": "一種用來_抽空液體容器物品_的置物臺", + "block.create.item_drain.tooltip.condition1": "液體傳輸", + "block.create.item_drain.tooltip.behaviour1": "當從側面導入諸如_桶_或_瓶子_之類的_液體容器物品_時,_分液池_將嘗試將其倒入其_自身的液體庫存_中。空的_液體容器物品_將被彈出至_另一側_。", + + "item.create.wand_of_symmetry.tooltip": "對稱杖", + "item.create.wand_of_symmetry.tooltip.summary": "完美地鏡面復制工作區域內的方塊放置於破壞", + "item.create.wand_of_symmetry.tooltip.condition1": "當在熱鍵欄時", + "item.create.wand_of_symmetry.tooltip.behaviour1": "持續進行鏡面復制", + "item.create.wand_of_symmetry.tooltip.control1": "當右鍵地面時", + "item.create.wand_of_symmetry.tooltip.action1": "_創建_或_移動_鏡子", + "item.create.wand_of_symmetry.tooltip.control2": "當右鍵空氣時", + "item.create.wand_of_symmetry.tooltip.action2": "_刪除_鏡子", + "item.create.wand_of_symmetry.tooltip.control3": "當潛行右鍵時", + "item.create.wand_of_symmetry.tooltip.action3": "打開_gui介面_", + + "item.create.handheld_blockzapper.tooltip": "方塊放置器", + "item.create.handheld_blockzapper.tooltip.summary": "新穎的小工具,可以遠距離放置或更換方塊。", + "item.create.handheld_blockzapper.tooltip.control1": "當左鍵方塊時", + "item.create.handheld_blockzapper.tooltip.action1": "設定放置此方塊。", + "item.create.handheld_blockzapper.tooltip.control2": "當右鍵方塊時", + "item.create.handheld_blockzapper.tooltip.action2": "_放置_或_替換_目標方塊。", + "item.create.handheld_blockzapper.tooltip.control3": "當潛行右鍵時", + "item.create.handheld_blockzapper.tooltip.action3": "打開_gui介面_", + + "item.create.handheld_worldshaper.tooltip": "環境塑形器", + "item.create.handheld_worldshaper.tooltip.summary": "_大面積_更改地形的手持工具", + "item.create.handheld_worldshaper.tooltip.control1": "當左鍵方塊時", + "item.create.handheld_worldshaper.tooltip.action1": "設定放置此方塊", + "item.create.handheld_worldshaper.tooltip.control2": "當右鍵方塊時", + "item.create.handheld_worldshaper.tooltip.action2": "_放置_或_替換_目標方塊", + "item.create.handheld_worldshaper.tooltip.control3": "當潛行右鍵時", + "item.create.handheld_worldshaper.tooltip.action3": "打開工具的_gui介面_", + + "item.create.tree_fertilizer.tooltip": "樹木肥料", + "item.create.tree_fertilizer.tooltip.summary": "適用來常見樹木的快速肥料", + "item.create.tree_fertilizer.tooltip.condition1": "在樹苗上使用時", + "item.create.tree_fertilizer.tooltip.behaviour1": "無論_生長時間_多少,直接長大", + + "item.create.deforester.tooltip": "連根拔樹斧", + "item.create.deforester.tooltip.summary": "_連根拔樹斧_,從最根砍樹時,能夠瞬間連根拔起一棵樹", + + "item.create.extendo_grip.tooltip": "伸縮機械手", + "item.create.extendo_grip.tooltip.summary": "biubiubiu! 大幅度_增加了_使用者的_觸碰距離_。", + "item.create.extendo_grip.tooltip.condition1": "放置於副手欄時", + "item.create.extendo_grip.tooltip.behaviour1": "大幅增加_主手_的觸碰距離,與_主手_的伸縮機械手攜同使用,可進一步增加_觸碰距離_。", + + "item.create.filter.tooltip": "過濾器", + "item.create.filter.tooltip.summary": "將物品更精確地進行_篩選分類_,可以同時_篩選_多個物品或者將已標記的_過濾器_放在另一個_過濾器_里_嵌套_使用。", + "item.create.filter.tooltip.condition1": "放置於過濾插槽中時", + "item.create.filter.tooltip.behaviour1": "根據_過濾器_的設定,來_決定_物品是否能夠通過", + "item.create.filter.tooltip.condition2": "當右鍵時", + "item.create.filter.tooltip.behaviour2": "打開_設定面板_", + + "item.create.attribute_filter.tooltip": "屬性過濾器", + "item.create.attribute_filter.tooltip.summary": "比起普通過濾器,_屬性過濾器_可以根據不同物品的_屬性_來進行過濾", + "item.create.attribute_filter.tooltip.condition1": "放置於過濾插槽中時", + "item.create.attribute_filter.tooltip.behaviour1": "根據_過濾器_的配置,來_決定_物品是否能夠通過", + "item.create.attribute_filter.tooltip.condition2": "當右鍵時", + "item.create.attribute_filter.tooltip.behaviour2": "打開_配置面板_", + + "item.create.empty_schematic.tooltip": "空白藍圖", + "item.create.empty_schematic.tooltip.summary": "可作為合成材料或在_藍圖桌_使用", + + "item.create.schematic.tooltip": "藍圖", + "item.create.schematic.tooltip.summary": "將工程結構的_設計圖_放置於_世界中_,並使用_藍圖加農炮_進行構建。", + "item.create.schematic.tooltip.condition1": "當設計圖存在時", + "item.create.schematic.tooltip.behaviour1": "可以使用屏幕上的工具調整位置", + "item.create.schematic.tooltip.control1": "當潛行右鍵時", + "item.create.schematic.tooltip.action1": "打開一個用來輸入_精確坐標_的介面。", + + "item.create.schematic_and_quill.tooltip": "藍圖與筆", + "item.create.schematic_and_quill.tooltip.summary": "用來將世界中的結構存到.nbt文件。", + "item.create.schematic_and_quill.tooltip.condition1": "第一步", + "item.create.schematic_and_quill.tooltip.behaviour1": "手持藍圖與右鍵旋轉兩個點", + "item.create.schematic_and_quill.tooltip.condition2": "第二步", + "item.create.schematic_and_quill.tooltip.behaviour2": "按住Ctrl滑鼠滾輪選擇選區大小,右鍵空白處存檔。", + "item.create.schematic_and_quill.tooltip.control1": "右鍵", + "item.create.schematic_and_quill.tooltip.action1": "選取點/確認存檔", + "item.create.schematic_and_quill.tooltip.control2": "按住Ctrl滑鼠滾輪", + "item.create.schematic_and_quill.tooltip.action2": "在_空中_選擇點滾動以調整距離。", + "item.create.schematic_and_quill.tooltip.control3": "當潛行右鍵時", + "item.create.schematic_and_quill.tooltip.action3": "_重置_並刪除選區。", + + "block.create.schematicannon.tooltip": "藍圖加農炮", + "block.create.schematicannon.tooltip.summary": "通過發射方塊以在世界中重新構建已部署的_全息圖_,使用相鄰箱子中的物品及_火藥_作為燃料。", + "block.create.schematicannon.tooltip.condition1": "當你對加農砲右鍵時", + "block.create.schematicannon.tooltip.behaviour1": "打開加農砲的設定介面", + + "block.create.schematic_table.tooltip": "藍圖桌", + "block.create.schematic_table.tooltip.summary": "將保存的藍圖圖寫入_空白藍圖_", + "block.create.schematic_table.tooltip.condition1": "放入空白藍圖時", + "block.create.schematic_table.tooltip.behaviour1": "從Schematics文件夾上傳所選文件", + + "item.create.goggles.tooltip": "MR護目鏡", + "item.create.goggles.tooltip.summary": "一副特殊的眼鏡,能夠讓你看見_動能_的信息。", + "item.create.goggles.tooltip.condition1": "當裝備後", + "item.create.goggles.tooltip.behaviour1": "將會顯示該機械元件的_速度_、_動能_等數值。", + "item.create.goggles.tooltip.condition2": "當裝備後看向儀表時", + "item.create.goggles.tooltip.behaviour2": "將會顯示該儀表所連接網路的_速度_、_動能_等數值。", + "item.create.goggles.tooltip.condition3": "當裝備後看向液體容器時", + "item.create.goggles.tooltip.behaviour3": "將會顯示儲存在該容器內的 _液體_ 以及其 _容量_ 等資訊。", + + "item.create.wrench.tooltip": "板手", + "item.create.wrench.tooltip.summary": "一種常用的工具,能夠調整_動能_的_方向_、_配置_等。", + "item.create.wrench.tooltip.control1": "當右鍵點擊_動能元件_時", + "item.create.wrench.tooltip.action1": "以點擊的面為軸心_旋轉_點擊的方塊", + "item.create.wrench.tooltip.control2": "當潛行右鍵時", + "item.create.wrench.tooltip.action2": "將物品_取下_並移動到你的背包中。", + + "block.create.nozzle.tooltip": "分散網", + "block.create.nozzle.tooltip.summary": "依附在鼓風機上,能夠將鼓風機的效果_分散_各個方向。", + + "block.create.cuckoo_clock.tooltip": "布穀鳥鐘", + "block.create.cuckoo_clock.tooltip.summary": "精美的布穀鳥鐘,能夠報時", + "block.create.cuckoo_clock.tooltip.condition1": "連接機械時", + "block.create.cuckoo_clock.tooltip.behaviour1": "顯示_現在時間_且一天會報時_兩次_。中午一次,黃昏可以睡覺時一次 ", + + "block.create.turntable.tooltip": "轉盤", + "block.create.turntable.tooltip.summary": "讓旋轉機械給你帶來一場刺激的旋轉風車體驗。", + + "block.create.portable_fluid_interface.tooltip": "移動液體接口", + "block.create.portable_fluid_interface.tooltip.summary": "為機械活塞、裝配礦車、旋轉軸承、滑輪_等移動結構_設計的_液體接口_,_移動結構_和_固定結構_之間的液體交換站,兩個會面的接口必須彼此面對且彼此隔開1-2個方塊。", + "block.create.portable_fluid_interface.tooltip.condition1": "裝配在移動結構上時", + "block.create.portable_fluid_interface.tooltip.behaviour1": "移動到能夠滿足與_固定結構_上的_移動式液體接口_對接的條件后,移動結構會_短暫地停下_,開始對接,並直接與_移動結構上的_液體儲存罐_交互,進行液體的_導入導出_。", + "block.create.portable_fluid_interface.tooltip.condition2": "被紅石激活時", + "block.create.portable_fluid_interface.tooltip.behaviour2": "立即終止任何活動的連接。", + + "block.create.stockpile_switch.tooltip": "存量偵測器", + "block.create.stockpile_switch.tooltip.summary": "根據連接的容器_儲存空間_的占用情況切換紅石訊號強度。", + "block.create.stockpile_switch.tooltip.condition1": "低於_下線_或高於_上線_時", + "block.create.stockpile_switch.tooltip.behaviour1": "提供紅石訊號", + + "block.create.content_observer.tooltip": "物品偵測器", + "block.create.content_observer.tooltip.summary": "偵測_容器_和_輸送帶_中過濾器匹配的物品。當觀察到包含匹配的物品時,此組件將發出_紅石訊號_。當觀察到的漏斗_轉移匹配的物品_時,此組件將發出_紅石脈沖_。", + + "block.create.adjustable_crate.tooltip": "可調節板條箱", + "block.create.adjustable_crate.tooltip.summary": "這個箱子可以調整容量,最大可以收納_16組_物品。", + "block.create.adjustable_crate.tooltip.condition1": "當你對箱子按右鍵時", + "block.create.adjustable_crate.tooltip.behaviour1": "打開箱子的設定介面", + + "block.create.creative_crate.tooltip": "創造板條箱", + "block.create.creative_crate.tooltip.summary": "這個容器可以給臨近的_藍圖大炮_提供無限物品以及燃料 (創造專用物品)", + "block.create.creative_crate.tooltip.condition1": "當標記了物品時", + "block.create.creative_crate.tooltip.behaviour1": "容器將會從虛空中提供_無限量_的標記物品,並且任何放置到容器中的物品都會被_送入虛空_", + + "block.create.controller_rail.tooltip": "控制鐵軌", + "block.create.controller_rail.tooltip.summary": "單向電動導軌,能夠精細控制礦車的移動速度。", + "block.create.controller_rail.tooltip.condition1": "被紅石激活時", + "block.create.controller_rail.tooltip.behaviour1": "根據訊號強度_加速_或_減速_經過的礦車。將紅石強度傳播到相鄰的控制鐵軌。", + + "item.create.sand_paper.tooltip": "紅砂紙", + "item.create.sand_paper.tooltip.summary": "用來_打磨_物品的砂紙,可以用_機械手_來實現自動化。", + "item.create.sand_paper.tooltip.condition1": "使用時", + "item.create.sand_paper.tooltip.behaviour1": "打磨_副手_上或者_準心所指_的物品。", + + "item.create.builders_tea.tooltip": "工人茶", + "item.create.builders_tea.tooltip.summary": "神清氣爽的一天,從這杯完美茶飲開始。恢復復_饑餓值_並獲得_加速_效果。", + + "item.create.refined_radiance.tooltip": "光輝石", + "item.create.refined_radiance.tooltip.summary": "一種用_光輝_鍛造的化合物材料。", + + "item.create.shadow_steel.tooltip": "暗影鋼", + "item.create.shadow_steel.tooltip.summary": "一種用_虛空_鍛造的化合物材料。", + + "item.create.minecart_coupling.tooltip": "礦車連軸器", + "item.create.minecart_coupling.tooltip.summary": "將多個_礦車_或運輸結構鏈接在一起,構成雄偉的火車。", + "item.create.minecart_coupling.tooltip.condition1": "作用與礦車時", + "item.create.minecart_coupling.tooltip.behaviour1": "將兩個礦車耦合在一起,在移動時將它們保持_恒定的距離_。", + + "create.tooltip.wip": "半成品", + "create.tooltip.workInProgress": "尚在製作中!", + "create.tooltip.randomWipDescription0": "禁止將此物品給屁孩。", + "create.tooltip.randomWipDescription1": "每~一~次~你使用此物品時,就會使一隻小熊貓死亡。", + "create.tooltip.randomWipDescription2": "使用此物品請自負後果。", + "create.tooltip.randomWipDescription3": "快走開,這不是你要找的東西(搖手指", + "create.tooltip.randomWipDescription4": "啟動自爆模式,10、9、8...。", + "create.tooltip.randomWipDescription5": "你已經沒有退路了。", + "create.tooltip.randomWipDescription6": "作者我將不負任何你使用此物所造成的責任。", + "create.tooltip.randomWipDescription7": "這東西不是給你用的,再找找吧!", + "create.tooltip.randomWipDescription8": "用了就死定了。", + + + "_": "->------------------------] Ponder Content [------------------------<-", + + "create.ponder.hold_to_ponder": "按住 [%1$s] 來思考此物品", + "create.ponder.subject": "本場景的主題", + "create.ponder.pondering": "思考有關於...", + "create.ponder.identify_mode": "暫停模式已啟動\n按 [%1$s] 來取消暫停模式", + "create.ponder.associated": "相關物品", + "create.ponder.close": "關閉", + "create.ponder.identify": "暫停", + "create.ponder.next": "下個場景", + "create.ponder.previous": "上個場景", + "create.ponder.replay": "重放", + "create.ponder.think_back": "返回", + "create.ponder.slow_text": "降低文字顯示速度", + "create.ponder.shared.movement_anchors": "有了機殼底盤和強力膠就可以移動大型結構", + "create.ponder.shared.rpm32": "32 RPM", + "create.ponder.shared.sneak_and": "潛行 +", + "create.ponder.shared.storage_on_contraption": "與結構相連的儲物空間會自動撿取物品", + "create.ponder.shared.behaviour_modify_wrench": "使用扳手來調整這個動作", + "create.ponder.shared.rpm8": "8 RPM", + "create.ponder.shared.ctrl_and": "Ctrl +", + "create.ponder.shared.rpm16_source": "轉速: 16 RPM", + "create.ponder.shared.rpm16": "16 RPM", + "create.ponder.tag.kinetic_sources": "動能產生裝置", + "create.ponder.tag.kinetic_sources.description": "該裝置能夠產生動能", + "create.ponder.tag.contraption_actor": "Contraption Actors", + "create.ponder.tag.contraption_actor.description": "Components which expose special behaviour when attached to a moving contraption", + "create.ponder.tag.arm_targets": "機械手臂的目標物", + "create.ponder.tag.arm_targets.description": "該裝置可作為機械手臂的工作目標", + "create.ponder.tag.logistics": "傳輸物品", + "create.ponder.tag.logistics.description": "該裝置用於物品的傳輸", + "create.ponder.tag.movement_anchor": "Movement Anchors", + "create.ponder.tag.movement_anchor.description": "Components which allow the creation of moving contraptions, animating an attached structure in a variety of ways", + "create.ponder.tag.creative": "創造模式", + "create.ponder.tag.creative.description": "該裝置無法在生存模式中獲得", + "create.ponder.tag.kinetic_relays": "動能傳遞方塊", + "create.ponder.tag.kinetic_relays.description": "該裝置用於傳遞動能", + "create.ponder.tag.windmill_sails": "風車軸承的帆", + "create.ponder.tag.windmill_sails.description": "建造風車時用於產生動能的帆,每個帆對風車產生的效果都是同等的", + "create.ponder.tag.contraption_assembly": "方塊連接物件", + "create.ponder.tag.contraption_assembly.description": "此物件用於連接各個零件以便組成一個成品", + "create.ponder.tag.decoration": "裝飾", + "create.ponder.tag.decoration.description": "這些零件通常用於裝飾", + "create.ponder.tag.kinetic_appliances": "動能利用裝置", + "create.ponder.tag.kinetic_appliances.description": "這些裝置利用動能運作", + "create.ponder.tag.redstone": "邏輯控制裝置", + "create.ponder.tag.redstone.description": "這些裝置會在紅石電路中發揮用處", + "create.ponder.tag.fluids": "液體控制裝置", + "create.ponder.tag.fluids.description": "這些裝置可傳輸並利用液體", + + "create.ponder.adjustable_pulse_repeater.header": "使用可調式脈衝中繼器來控制訊號", + "create.ponder.adjustable_pulse_repeater.text_1": "可調式脈衝中繼器每次運作時會產生一個短脈衝", + "create.ponder.adjustable_pulse_repeater.text_2": "使用滑鼠滾輪來設定啟動後到產生脈衝的延遲", + "create.ponder.adjustable_pulse_repeater.text_3": "延遲可設定到最大30分鐘", + + "create.ponder.adjustable_repeater.header": "使用可調式中繼器來控制訊號", + "create.ponder.adjustable_repeater.text_1": "可調式中繼器就像一般的中繼器", + "create.ponder.adjustable_repeater.text_2": "收到訊號後在設定好的時間過後才啟動...", + "create.ponder.adjustable_repeater.text_3": "...訊號停止後也需要相隔同樣的時間過後才會停止", + "create.ponder.adjustable_repeater.text_4": "使用滑鼠滾輪來設定延遲", + "create.ponder.adjustable_repeater.text_5": "延遲可設定到最大30分鐘", + + "create.ponder.analog_lever.header": "使用可調式拉桿來控制訊號", + "create.ponder.analog_lever.text_1": "可調式拉桿是一種小巧而輕準的紅石能源", + "create.ponder.analog_lever.text_2": "右鍵來增加其紅石訊號輸出", + "create.ponder.analog_lever.text_3": "潛行並右鍵來減少其紅石訊號輸出", + + "create.ponder.andesite_tunnel.header": "使用安山岩物品隧道", + "create.ponder.andesite_tunnel.text_1": "安山岩物品隧道可以覆蓋在輸送帶上", + "create.ponder.andesite_tunnel.text_2": "當安山岩物品隧道側邊連接到另一條輸送帶時...", + "create.ponder.andesite_tunnel.text_3": "...隧道將會從經過的整組物品中拿出一個丟到另一條輸送帶上", + "create.ponder.andesite_tunnel.text_4": "剩餘物品則按照原路輸出", + + "create.ponder.basin.header": "在作業盆中處理物品", + "create.ponder.basin.text_1": "作業盆可以放入物品或液體來進行處理", + "create.ponder.basin.text_2": "在每次的處理完成後, 作業盆會試著輸出成品到他的側面下方", + "create.ponder.basin.text_3": "當側面下方有一個有效的容器或設備, 作業盆側面會出現一個輸出嘴", + "create.ponder.basin.text_4": "有很多的容器或設備可以觸發上述現象", + "create.ponder.basin.text_5": "作業盆輸出的成品會被儲存到該容器或設備內", + "create.ponder.basin.text_6": "如果側面沒有出現輸出嘴, 則作業盆內的成品則不會輸出", + "create.ponder.basin.text_7": "這個原理用在產生的成品為下一輪處理的原料時相當有用", + "create.ponder.basin.text_8": "期望的成品將會從作業盆中輸出", + "create.ponder.basin.text_9": "加裝過濾器可防止未被處理的物品輸出", + + "create.ponder.bearing_modes.header": "機械軸承的工作模式", + "create.ponder.bearing_modes.text_1": "當機械軸承停止時,它會控制整個結構停在最近的垂直線上並實體化", + "create.ponder.bearing_modes.text_2": "你可以控制它不要實體化,或是在結構起始位置才實體化", + + "create.ponder.belt_casing.header": "包裹住輸送帶", + "create.ponder.belt_casing.text_1": "安山岩機殼或黃銅機殼可以用來裝飾輸送帶", + "create.ponder.belt_casing.text_2": "使用扳手可以移除機殼", + + "create.ponder.belt_connector.header": "使用輸送帶", + "create.ponder.belt_connector.text_1": "手持輸送帶對兩根傳動軸右鍵以安裝輸送帶", + "create.ponder.belt_connector.text_2": "不小心點到傳動軸的話可以用潛行+右鍵來取消選取", + "create.ponder.belt_connector.text_3": "輸送帶間只要有空間就能安裝額外的傳動軸", + "create.ponder.belt_connector.text_4": "相同輸送帶接出來的傳動軸轉速及轉向會相同", + "create.ponder.belt_connector.text_5": "使用扳手可以移除已安裝的傳動軸", + "create.ponder.belt_connector.text_6": "輸送帶可以被各種染料染色", + + "create.ponder.belt_directions.header": "輸送帶正確的安裝方向", + "create.ponder.belt_directions.text_1": "輸送帶不可以隨意聯結", + "create.ponder.belt_directions.text_2": "1. 輸送帶可以水平連結", + "create.ponder.belt_directions.text_3": "2. 輸送帶可以對角連結", + "create.ponder.belt_directions.text_4": "3. 輸送帶可以垂直連結", + "create.ponder.belt_directions.text_5": "4. 也可以連結在垂直的傳動軸上", + "create.ponder.belt_directions.text_6": "這些都是可以使用的連接方式,輸送帶可以放置的長度為2~20格", + + "create.ponder.belt_transport.header": "將輸送帶用於後勤", + "create.ponder.belt_transport.text_1": "被啟動的輸送帶能運送物品及實體", + "create.ponder.belt_transport.text_2": "空手對輸送帶上的物品右鍵即可從輸送帶上取下物品", + + "create.ponder.blaze_burner.header": "餵食烈焰使者動力爐", + "create.ponder.blaze_burner.text_1": "烈焰使者動力爐可以用來加熱作業盆", + "create.ponder.blaze_burner.text_2": "你需要餵食可以燃燒的物品來加熱作業盆", + "create.ponder.blaze_burner.text_3": "餵食熔岩蛋糕可以讓烈焰使者動力爐加熱到另一個更高的境界", + "create.ponder.blaze_burner.text_4": "使用機械手或機械手臂來將餵食自動化", + + "create.ponder.brass_funnel.header": "黃銅漏斗", + "create.ponder.brass_funnel.text_1": "安山岩漏斗每次只能傳輸一個物品", + "create.ponder.brass_funnel.text_2": "但黃銅漏斗每次可以傳輸整組物品", + "create.ponder.brass_funnel.text_3": "對漏斗上的過濾格使用滾輪可以調整每次輸出物品的數量", + "create.ponder.brass_funnel.text_4": "手持物品對漏斗上的過濾格右鍵可以限制漏斗只輸出該物品", + + "create.ponder.brass_tunnel.header": "使用黃銅隧道", + "create.ponder.brass_tunnel.text_1": "黃銅隧道必須裝設在輸送帶上", + "create.ponder.brass_tunnel.text_2": "黃銅隧道輸出入口上都有過濾格", + "create.ponder.brass_tunnel.text_3": "在輸入口上的過濾器會阻擋不相符的物品", + "create.ponder.brass_tunnel.text_4": "在輸出口上的過濾器可依種類整理排列物品", + "create.ponder.brass_tunnel.text_5": "如果數種與過濾相符的物品通過隧道, 隧道的分配模式將決定如何處理這些物品", + "create.ponder.brass_tunnel.text_6": "在平行相鄰的輸送帶上,相鄰的黃銅隧道將會成為一組", + "create.ponder.brass_tunnel.text_7": "輸入該組內的物品將會採用該組隧道的分配模式輸送", + "create.ponder.brass_tunnel.text_8": "在這個情況下, 物品也能被直接輸入到隧道方塊", + + "create.ponder.brass_tunnel_modes.header": "黃銅隧道的分配模式", + "create.ponder.brass_tunnel_modes.text_1": "使用扳手來調整隧道的分配模式", + "create.ponder.brass_tunnel_modes.text_10": "'同步輸入' 是一種黃銅隧道的特殊設定", + "create.ponder.brass_tunnel_modes.text_11": "當同組內的所有隧道都有一個可通過的物品時,所有隧道才可輸出物品", + "create.ponder.brass_tunnel_modes.text_12": "這確保了同組隧道所在的輸送帶都能以同一速率輸出物品", + "create.ponder.brass_tunnel_modes.text_2": "'分流輸出' 此模式會將物品輸出到該組隧道可用的輸出口", + "create.ponder.brass_tunnel_modes.text_3": "如果該組隧道內某個輸出口無法再輸出物品,則該輸出口會被跳過", + "create.ponder.brass_tunnel_modes.text_4": "'強制分流輸出' 模式不會跳過某個無法輸出物品的輸出口, 直到該輸出口可以輸出物品", + "create.ponder.brass_tunnel_modes.text_5": "'輪詢輸入' 模式將會保持整組物品完整性, 然後在有輸出口可以輸出時才輸入物品", + "create.ponder.brass_tunnel_modes.text_6": "如果該組隧道內某個輸出口無法再輸出物品,則該輸出口會被跳過", + "create.ponder.brass_tunnel_modes.text_7": "'強制輪詢輸入' 模式不會跳過某個無法輸出物品的輸出口, 直到該輸出口可以輸出物品", + "create.ponder.brass_tunnel_modes.text_8": "'鄰近優先' 模式會將物品輸出到該組隧道離物品輸入口最近的出口", + "create.ponder.brass_tunnel_modes.text_9": "'隨機輸出' 模式會隨機選擇同組隧道的一個輸出口輸出", + + "create.ponder.cart_assembler.header": "使用礦車裝修站裝修礦車來移動結構", + "create.ponder.cart_assembler.text_1": "礦車裝修站會將所有連接到礦車的結構裝在礦車上", + "create.ponder.cart_assembler.text_2": "如果沒有紅時訊號,它會將礦車結構分解成方塊", + "create.ponder.cart_assembler.text_3": "對礦車結構使用扳手可以將礦車變成物品", + + "create.ponder.cart_assembler_dual.header": "雙礦車結構", + "create.ponder.cart_assembler_dual.text_1": "當兩台礦車在同一礦車結構上", + "create.ponder.cart_assembler_dual.text_2": "任一礦車裝修站收到紅石訊號時,會形成完整的一個礦車結構", + "create.ponder.cart_assembler_dual.text_3": "整個礦車結構會類似於用礦車連結器連接兩個礦車結構", + + "create.ponder.cart_assembler_modes.header": "礦車結構的方向設定", + "create.ponder.cart_assembler_modes.text_1": "礦車結構會隨著礦車方向改變", + "create.ponder.cart_assembler_modes.text_2": "如果在裝修站鎖定其方向,則結構方向不會隨礦車方向改變", + + "create.ponder.cart_assembler_rails.header": "其他種類的礦車和鐵軌", + "create.ponder.cart_assembler_rails.text_1": "放在普通鐵軌上的礦車裝修站不會影響礦車的動作", + "create.ponder.cart_assembler_rails.text_2": "如果裝修站在沒有紅石訊號的動力鐵軌或控制鐵軌上,則礦車會停下直到鐵軌收到紅石訊號", + "create.ponder.cart_assembler_rails.text_3": "有幾種礦車可以當作錨來使用", + "create.ponder.cart_assembler_rails.text_4": "熔爐礦車會盡可能維持熔煉狀態,並會拿取鄰近儲存結構上的燃料", + + "create.ponder.chain_drive.header": "使用鏈式傳動箱傳遞動能", + "create.ponder.chain_drive.text_1": "同一排上的鏈式傳動箱會互相傳遞動能", + "create.ponder.chain_drive.text_2": "所有傳動軸此時會朝相同方向旋轉", + "create.ponder.chain_drive.text_3": "任一個鏈式傳動箱被旋轉90度時所有鏈式傳動箱仍可正常運作", + + "create.ponder.chain_gearshift.header": "使用可調式鏈式變速箱來調整轉速", + "create.ponder.chain_gearshift.text_1": "未被控制的可調式鏈式變速箱與鏈式傳動箱無異", + "create.ponder.chain_gearshift.text_2": "當可調式鏈式變速箱被啟動後,它會把轉速提升兩倍傳至其他鏈式傳動箱", + "create.ponder.chain_gearshift.text_3": "當被啟動的可調式鏈式變速箱並不是動能輸入端,則它會把轉速減半", + "create.ponder.chain_gearshift.text_4": "上述兩種狀況中,其他鏈式傳動箱都會被可調式鏈式變速箱提升兩倍的轉速", + "create.ponder.chain_gearshift.text_5": "利用紅石訊號的強弱可以調整轉速倍率為x1或x2", + "create.ponder.chain_gearshift.text_6": "12 RPM", + + "create.ponder.chute.header": "使用滑道向下輸送物品", + "create.ponder.chute.text_1": "滑道可以在兩個垂直的儲物空間中輸送物品", + "create.ponder.chute.text_2": "使用扳手可以讓它產生一個觀景窗", + "create.ponder.chute.text_3": "在滑道的側面放置另一個滑道,會產生一個斜狀的滑道", + + "create.ponder.chute_upward.header": "使用滑道向上輸送物品", + "create.ponder.chute_upward.text_1": "在滑道上方或下方使用鼓風機時,物品會根據被向上或向下吹", + "create.ponder.chute_upward.text_2": "裝備MR護目鏡以觀測物品的傳輸方向", + "create.ponder.chute_upward.text_3": "如滑道底端被擋住,則物品只能由側邊進行輸出入", + + "create.ponder.clockwork_bearing.header": "使用時鐘軸承來建造時鐘結構", + "create.ponder.clockwork_bearing.text_1": "時鐘軸承會黏住其前方方塊產生一個時針結構", + "create.ponder.clockwork_bearing.text_2": "在輸入動能後,該結構會依照遊戲時間來旋轉", + "create.ponder.clockwork_bearing.text_3": "3:00", + "create.ponder.clockwork_bearing.text_4": "4:00", + "create.ponder.clockwork_bearing.text_5": "對軸承右鍵會使結構啟動或停止", + "create.ponder.clockwork_bearing.text_6": "在時針結構的前方可再增加一組分針結構", + "create.ponder.clockwork_bearing.text_7": "你必須確保時針分針結構間未被使用強力膠之類的相連零件", + "create.ponder.clockwork_bearing.text_8": "分針結構此時將正常運作", + + "create.ponder.clutch.header": "使用離合器控制動能", + "create.ponder.clutch.text_1": "離合器能將動能直線傳遞", + "create.ponder.clutch.text_2": "當離合器被啟動,離合器會中斷動能傳遞", + + "create.ponder.cog_speedup.header": "使用大小齒輪來變速", + "create.ponder.cog_speedup.text_1": "大齒輪與小齒輪可以斜向傳遞動能", + "create.ponder.cog_speedup.text_2": "從大齒輪傳遞動能至小齒輪時,轉速加倍", + "create.ponder.cog_speedup.text_3": "從小齒輪傳遞動能至大齒輪時,轉速減半", + + "create.ponder.cogwheel.header": "使用齒輪來傳遞動能", + "create.ponder.cogwheel.text_1": "齒輪會將動力傳遞至臨近的齒輪", + "create.ponder.cogwheel.text_2": "以此方式連接的齒輪,旋轉方向相反", + + "create.ponder.creative_motor.header": "使用創造馬達產生動能", + "create.ponder.creative_motor.text_1": "創造馬達不僅能夠手動設定輸出動能,而且體積相當小巧", + "create.ponder.creative_motor.text_2": "對其背後面板滾動滾輪,可以改變馬達的轉速", + + "create.ponder.crushing_wheels.header": "使用粉碎輪處理物品", + "create.ponder.crushing_wheels.text_1": "一對粉碎輪,磨物快又準", + "create.ponder.crushing_wheels.text_2": "接入的動能必須使這兩個輪子契合轉動", + "create.ponder.crushing_wheels.text_3": "扔入或者放入的物品都會被粉碎處理", + "create.ponder.crushing_wheels.text_4": "你也可以使用自動化進行物品的輸入以及撿取", + + "create.ponder.deployer.header": "使用機械手", + "create.ponder.deployer.text_1": "在機械手獲得動能後能夠模仿玩家的各種行為", + "create.ponder.deployer.text_10": "對機械手手部右鍵,即可將手上的物品給它使用", + "create.ponder.deployer.text_11": "物品也可以自動化輸入到機械手內", + "create.ponder.deployer.text_12": "機械手附帶一個過濾格", + "create.ponder.deployer.text_13": "當設定了過濾後,只有當它的手中物品與過濾格相符時,它才會工作", + "create.ponder.deployer.text_14": "只有與過濾格相符的物品才可輸入...", + "create.ponder.deployer.text_15": "...不符的物品可被取出來", + "create.ponder.deployer.text_2": "它只會與它正前方兩格處的位置進行互動", + "create.ponder.deployer.text_3": "放在在它面前的方塊不會阻攔它的工作", + "create.ponder.deployer.text_4": "機械手可以:", + "create.ponder.deployer.text_5": "放置方塊", + "create.ponder.deployer.text_6": "使用物品", + "create.ponder.deployer.text_7": "啟動方塊", + "create.ponder.deployer.text_8": "採收方塊", + "create.ponder.deployer.text_9": "以及攻擊生物", + + "create.ponder.deployer_contraption.header": "在裝置上使用機械手", + "create.ponder.deployer_contraption.text_1": "當機械手在移動的結構上時...", + "create.ponder.deployer_contraption.text_2": "機械手會對每一個經過的方塊使用裝置中任意容器內的物品", + "create.ponder.deployer_contraption.text_3": "可以透過過濾格來指定其從存儲空間中抽取的物品", + + "create.ponder.deployer_modes.header": "機械手的工作模式", + "create.ponder.deployer_modes.text_1": "在設設情況下,機械手模仿玩家的右鍵", + "create.ponder.deployer_modes.text_2": "使用扳手可以將模式調整為模仿玩家的左鍵", + + "create.ponder.deployer_redstone.header": "使用紅石控制機械手", + "create.ponder.deployer_redstone.text_1": "當機械手收到紅時訊號時會停止工作", + "create.ponder.deployer_redstone.text_2": "在停止工作前,機械手會完成目前手頭上的工作", + "create.ponder.deployer_redstone.text_3": "因此,輸入脈衝訊號可以使其每次只進行一個週期的工作", + + "_": "m", + + "create.ponder.depot.header": "使用置物台", + "create.ponder.depot.text_1": "置物台可以被當成一個“靜止的”傳送帶原件使用", + "create.ponder.depot.text_2": "右擊可以手動放置或取下物品", + "create.ponder.depot.text_3": "與傳送帶一樣,它也可以將其內的物品轉送到其他設備中進行加工...", + "create.ponder.depot.text_4": "...同時物品也可以被機械手存取", + + "create.ponder.empty_blaze_burner.header": "使用空的烈焰人燃燒室", + "create.ponder.empty_blaze_burner.text_1": "手持空的烈焰人燃燒室右擊烈焰人來抓取烈焰人", + "create.ponder.empty_blaze_burner.text_2": "或者,也可以透過右擊烈焰人刷怪籠來填充啟動烈焰人燃燒室", + "create.ponder.empty_blaze_burner.text_3": "這樣,你便有了一個可供部分機器加工的熱源", + "create.ponder.empty_blaze_burner.text_4": "如果是為了美觀,空的烈焰人燃燒室也可以被打火石點燃", + "create.ponder.empty_blaze_burner.text_5": "但是,這樣的熱源不足以給機器提加工供足夠的熱量", + + "create.ponder.fan_direction.header": "鼓風機的氣流", + "create.ponder.fan_direction.text_1": "鼓風機使用動能來製造氣流", + "create.ponder.fan_direction.text_2": "流速以及方向由所接收動能的強弱以及方向而定", + + "create.ponder.fan_processing.header": "使用鼓風機加工物品", + "create.ponder.fan_processing.text_1": "當氣流吹過熔岩時,氣流會被加熱", + "create.ponder.fan_processing.text_2": "熱氣流中的物品會被冶煉", + "create.ponder.fan_processing.text_3": "但在氣流中的食物會被直接燒成灰", + "create.ponder.fan_processing.text_4": "而想要烹飪食物,必須要透過吹過火焰的氣流來煙燻食物", + "create.ponder.fan_processing.text_5": "當氣流吹過水後,便可用於洗滌物品", + "create.ponder.fan_processing.text_6": "這種加工方法可以做到不少有趣的事情", + "create.ponder.fan_processing.text_7": "鼓風機的轉速對加工的速度沒有影響,只影響氣流的吹拂距離", + "create.ponder.fan_processing.text_8": "而那些放置在置物台或者傳送帶上的物品,鼓風機也是可以處理的", + + "create.ponder.fan_source.header": "使用鼓風機來產生動能", + "create.ponder.fan_source.text_1": "如鼓風機的扇葉向下朝著熱源放置,鼓風機可以藉此產生動能", + "create.ponder.fan_source.text_2": "當鼓風機接受紅石訊號後,它便會向外供給動能", + + "create.ponder.flywheel.header": "使用飛輪來產生動能", + "create.ponder.flywheel.text_1": "飛輪和熔爐引擎必須配套使用,方可產生動能", + "create.ponder.flywheel.text_2": "如此產生的動能具有非常大的應力值", + "create.ponder.flywheel.text_3": "使用高爐會使得引擎的效率翻倍", + + "create.ponder.funnel_compat.header": "漏斗的相容性", + "create.ponder.funnel_compat.text_1": "漏斗可以與一些其他組件互動", + "create.ponder.funnel_compat.text_2": "動力鋸", + "create.ponder.funnel_compat.text_3": "置物台", + "create.ponder.funnel_compat.text_4": "分液池", + + "create.ponder.funnel_direction.header": "物流方向", + "create.ponder.funnel_direction.text_1": "直接放置時,漏斗會將物品從容器中取出", + "create.ponder.funnel_direction.text_2": "潛行時放置時,漏斗會將物品置入容器中", + "create.ponder.funnel_direction.text_3": "使用扳手可以改變漏斗的存/取模式", + "create.ponder.funnel_direction.text_4": "對大多數朝向放置的漏斗都具有此特性", + "create.ponder.funnel_direction.text_5": "在傳送帶末端放置的漏斗會根據傳送帶的傳動方向存/取物品", + + "create.ponder.funnel_intro.header": "使用漏斗", + "create.ponder.funnel_intro.text_1": "用漏斗來存取物品欄內的物品,可謂又快又好", + + "create.ponder.funnel_redstone.header": "紅石訊號控制", + "create.ponder.funnel_redstone.text_1": "紅石訊號會使漏斗停止工作", + + "create.ponder.funnel_transfer.header": "直接運輸", + "create.ponder.funnel_transfer.text_1": "漏斗無法將物品傳輸到非開放式的物品欄中", + "create.ponder.funnel_transfer.text_2": "溜槽和智慧溜槽更適用於這樣的場景", + "create.ponder.funnel_transfer.text_3": "水平傳輸也是如此,也許傳送帶更方便快捷", + + "create.ponder.furnace_engine.header": "使用熔爐引擎生產動能", + "create.ponder.furnace_engine.text_1": "熔爐引擎會在與其相連熔爐工作時生產動能", + "create.ponder.furnace_engine.text_2": "如此產生的動能具有非常大的應力值", + "create.ponder.furnace_engine.text_3": "使用高爐會使得引擎的效率翻倍", + + "create.ponder.gantry_carriage.header": "使用起重機取物器", + "create.ponder.gantry_carriage.text_1": "起重機取物器可以被放置在起重機杆上,並且可以沿著起重機杆運動", + "create.ponder.gantry_carriage.text_2": "起重機可以移動其黏附的方塊", + + "create.ponder.gantry_cascaded.header": "串聯起重機", + "create.ponder.gantry_cascaded.text_1": "無需強力膠,取物器便可與起重機杆相連", + "create.ponder.gantry_cascaded.text_2": "即使是在移動的起重機杆上也是如此", + "create.ponder.gantry_cascaded.text_3": "因此,起重機系統可以串聯起來,如此可以影響到多軸向的運動", + + "create.ponder.gantry_direction.header": "起重機移動方向", + "create.ponder.gantry_direction.text_1": "起重機杆可以有相反的方向", + "create.ponder.gantry_direction.text_2": "取物器的移動方向取決於起重機杆的方向", + "create.ponder.gantry_direction.text_3": "......以及起重機杆的旋轉方向", + "create.ponder.gantry_direction.text_4": "在旋轉傳遞中,此規則同樣適用", + + "create.ponder.gantry_redstone.header": "起重機的力傳遞", + "create.ponder.gantry_redstone.text_1": "被紅石訊號啟動的起重機,將不會移動其上的取物器", + "create.ponder.gantry_redstone.text_2": "作為替代,杆上的動能會傳遞到取物器的輸出杆上", + + "create.ponder.gantry_shaft.header": "使用起重機杆", + "create.ponder.gantry_shaft.text_1": "起重機杆組成了起重機結構的基礎。與其相接的載物器可以沿著杆進行移動。", + "create.ponder.gantry_shaft.text_2": "起重機結構可以移動與其相接的方塊。", + + "create.ponder.gearbox.header": "使用十字齒輪箱傳遞動能", + "create.ponder.gearbox.text_1": "更改旋轉軸,很容易使得整個旋轉體系變得臃腫不堪", + "create.ponder.gearbox.text_2": "十字齒輪箱則是替代方案,它的體積更為小巧緊", + "create.ponder.gearbox.text_3": "側邊連接的傳動桿,旋轉方向與輸入端一致", + "create.ponder.gearbox.text_4": "直線連接的傳動桿,旋轉方向會被反轉", + + "create.ponder.gearshift.header": "使用反轉齒輪箱控制動能", + "create.ponder.gearshift.text_1": "反轉齒輪箱可以直線傳輸旋轉", + "create.ponder.gearshift.text_2": "通入紅石訊號後,輸出端的旋轉方向會被反轉", + + "create.ponder.hand_crank.header": "使用手搖把手產生動能", + "create.ponder.hand_crank.text_1": "玩家可以使用手搖把手來手動產生動能", + "create.ponder.hand_crank.text_2": "按住右鍵可以逆時針旋轉它", + "create.ponder.hand_crank.text_3": "它產生的轉速相對較高", + "create.ponder.hand_crank.text_4": "潛行長按右鍵可以順時針旋轉它", + + "create.ponder.large_cogwheel.header": "使用大齒輪傳遞動能", + "create.ponder.large_cogwheel.text_1": "大齒輪可以以特定的角度相互連接", + "create.ponder.large_cogwheel.text_2": "可以利用大齒輪變更旋轉軸向", + + "create.ponder.linear_chassis_attachment.header": "使用機殼底盤黏合方塊", + "create.ponder.linear_chassis_attachment.text_1": "它的開放面可以變為黏性面", + "create.ponder.linear_chassis_attachment.text_2": "再次點擊黏性面,可以將它的相反面也變得具有黏性", + "create.ponder.linear_chassis_attachment.text_3": "空手潛行右擊可以移除此面的黏性物", + "create.ponder.linear_chassis_attachment.text_4": "黏性面可以將此面前方的一長條方塊黏住", + "create.ponder.linear_chassis_attachment.text_5": "使用扳手可以精確控制底盤的影響範圍", + "create.ponder.linear_chassis_attachment.text_6": "按住 Ctrl 滑動滾輪,你可以一次性調節所有底盤的影響範圍", + "create.ponder.linear_chassis_attachment.text_7": "若想讓底盤的其他面也能黏方塊,你需要用到強力膠", + "create.ponder.linear_chassis_attachment.text_8": "利用這些機制,任何形狀的機制都可以像裝置那樣移動", + + "create.ponder.linear_chassis_group.header": "成組移動機殼底盤", + "create.ponder.linear_chassis_group.text_1": "相鄰的機殼底盤可以相互連接在一起", + "create.ponder.linear_chassis_group.text_2": "其中的一個底盤若被移動,其餘的底盤也會跟著移動", + "create.ponder.linear_chassis_group.text_3": "不同種類的底盤,或者是朝向不一致的底盤,將不會相連", + + "create.ponder.mechanical_arm.header": "設定動力臂", + "create.ponder.mechanical_arm.text_1": "你得在放置動力臂之前就設定好它的輸入以及輸出端", + "create.ponder.mechanical_arm.text_2": "手持動力臂右擊某個存儲空間,可以將其指定為目標", + "create.ponder.mechanical_arm.text_3": "再次右擊可以將其在輸入端(藍色)以及輸出端(橙色)之間切換", + "create.ponder.mechanical_arm.text_4": "左擊此組件可以移除選擇", + "create.ponder.mechanical_arm.text_5": "將動力臂放下來後,它會將此前選擇的方塊作為目標", + "create.ponder.mechanical_arm.text_6": "在有效範圍內,機械手臂可以有任意數量的輸出以及輸入端", + "create.ponder.mechanical_arm.text_7": "然而,並不是所有的存儲空間可以被直接互動", + "create.ponder.mechanical_arm.text_8": "在此情況下,漏斗和置物台可以解決此問題", + + "create.ponder.mechanical_arm_filtering.header": "過濾動力臂的輸出端", + "create.ponder.mechanical_arm_filtering.text_1": "輸入", + "create.ponder.mechanical_arm_filtering.text_2": "輸出", + "create.ponder.mechanical_arm_filtering.text_3": "有時,你會想著利用某種過濾限煞車力臂的目標", + "create.ponder.mechanical_arm_filtering.text_4": "動力臂自身並不提供任何過濾選項", + "create.ponder.mechanical_arm_filtering.text_5": "然而,若將黃銅漏斗作為目標,則漏斗的過濾槽則可以應用至動力臂上", + "create.ponder.mechanical_arm_filtering.text_6": "動力臂足夠智慧,它不會去拿取那些它無法分配的物品", + + "create.ponder.mechanical_arm_modes.header": "動力臂的分配模式", + "create.ponder.mechanical_arm_modes.text_1": "輸入", + "create.ponder.mechanical_arm_modes.text_2": "輸出", + "create.ponder.mechanical_arm_modes.text_3": "若動力臂必須在數個有效的輸出端之間作出選擇...", + "create.ponder.mechanical_arm_modes.text_4": "...它會依照自己的設定選擇特定的行為", + "create.ponder.mechanical_arm_modes.text_5": "手持扳手對其滑動滾輪,可以改變其設定", + "create.ponder.mechanical_arm_modes.text_6": "輪詢調度模式很好理解,即循環輸出至所有有效的輸出端", + "create.ponder.mechanical_arm_modes.text_7": "如果某個輸出端無法容納更多物品,則它會被跳過", + "create.ponder.mechanical_arm_modes.text_8": "強制輪詢調度不會跳過任何輸出端,動力臂會一直等待,直到輸出端有空位容納物品輸入", + "create.ponder.mechanical_arm_modes.text_9": "最近優先模式會使得動力臂先將物品輸出至更早被選擇的輸出端", + + "create.ponder.mechanical_arm_redstone.header": "利用紅石訊號控制動力臂", + "create.ponder.mechanical_arm_redstone.text_1": "通入紅石訊號後,動力臂會停止工作", + "create.ponder.mechanical_arm_redstone.text_2": "在停止工作前,它會完成目前正在進行的工作週期", + "create.ponder.mechanical_arm_redstone.text_3": "因此,通入單次負紅石脈衝可以精確控制動力臂,使其每次只進行單個週期的工作", + + "create.ponder.mechanical_bearing.header": "使用動力軸承移動結構", + "create.ponder.mechanical_bearing.text_1": "動力軸承會與其前方的方塊黏合在一起", + "create.ponder.mechanical_bearing.text_2": "接收到動能後,它會將這一黏合結構組裝為旋轉裝置", + + "create.ponder.mechanical_crafter.header": "設置動力合成器", + "create.ponder.mechanical_crafter.text_1": "動力合成器陣列可用於自動化任何合成配方的製作", + "create.ponder.mechanical_crafter.text_2": "使用扳手可以調控合成器的合成通路", + "create.ponder.mechanical_crafter.text_3": "所有的合成通路必須匯集到任意一側的一個出口,整套合成器方可算是設置正確", + "create.ponder.mechanical_crafter.text_4": "輸出產物會被放入位於出口的存儲空間中", + "create.ponder.mechanical_crafter.text_5": "動力合成器的運轉需要動能的供應", + "create.ponder.mechanical_crafter.text_6": "右擊合成器正面,可以手動放入物品", + "create.ponder.mechanical_crafter.text_7": "一旦合成通路上的所有合成槽位都有了物品,合成就會開始", + "create.ponder.mechanical_crafter.text_8": "而對於那些沒有完全占滿所有合成器槽位的配方,你可以通入紅石訊號強制開啟合成", + + "create.ponder.mechanical_crafter_connect.header": "為合成器連接物品欄", + "create.ponder.mechanical_crafter_connect.text_1": "合成器可以自動接受向其輸入的物品", + "create.ponder.mechanical_crafter_connect.text_2": "對其背面使用扳手,可以連接合成器", + "create.ponder.mechanical_crafter_connect.text_3": "所有相連的合成器可以訪問同一個位置的輸入", + + "create.ponder.mechanical_crafter_covers.header": "蓋住動力合成器的合成槽", + "create.ponder.mechanical_crafter_covers.text_1": "有些配方需要額外的合成器,來補足合成通路上的間隙", + "create.ponder.mechanical_crafter_covers.text_2": "使用合成槽蓋板,合成器會在合成進行時的行為就如同一個空的合成槽位", + "create.ponder.mechanical_crafter_covers.text_3": "被蓋住的合成器並不會阻斷共享輸入端的影響", + + "create.ponder.mechanical_drill.header": "使用機械鑽頭破壞方塊", + "create.ponder.mechanical_drill.text_1": "當向其通入動能後,機械鑽頭會破壞它面前的方塊", + "create.ponder.mechanical_drill.text_2": "它的挖掘速度取決於通入的動能轉速", + + "create.ponder.mechanical_drill_contraption.header": "在裝置中使用機械鑽頭", + "create.ponder.mechanical_drill_contraption.text_1": "在運動裝置中使用機械鑽頭時...", + "create.ponder.mechanical_drill_contraption.text_2": "...它會破壞掉它撞上的方塊", + + "create.ponder.mechanical_harvester.header": "在裝置中使用動力收割機", + "create.ponder.mechanical_harvester.text_1": "在運動裝置中使用動力收割機時...", + "create.ponder.mechanical_harvester.text_2": "它會採收其路徑上的作物,並重設這些作物的生長進度", + + "create.ponder.mechanical_mixer.header": "使用動力攪拌器處理物品", + "create.ponder.mechanical_mixer.text_1": "使用攪拌器和工作盆,你可以自動化某些合成配方", + "create.ponder.mechanical_mixer.text_2": "有效配方包括各種無序合成配方,以及一些額外的配方", + "create.ponder.mechanical_mixer.text_3": "一些配方可能需要使用烈焰人燃燒室提供熱量", + "create.ponder.mechanical_mixer.text_4": "過濾槽可用於解決兩個配方相互衝突的情況", + + "create.ponder.mechanical_piston.header": "使用動力活塞移動結構", + "create.ponder.mechanical_piston.text_1": "動力活塞可以移動它前方的方塊", + "create.ponder.mechanical_piston.text_2": "移動速度和方向取決於通入活塞的動能", + "create.ponder.mechanical_piston.text_3": "黏性動力活塞可以將相接的方塊拉回來", + + "create.ponder.mechanical_piston_modes.header": "動力活塞的移動模式", + "create.ponder.mechanical_piston_modes.text_1": "一旦活塞停下,被移動的結構就會回退到方塊狀態", + "create.ponder.mechanical_piston_modes.text_2": "你也可以將其設定為從不方塊化,或者只在起始位置方塊化", + + "create.ponder.mechanical_plough.header": "在裝置中使用動力犁", + "create.ponder.mechanical_plough.text_1": "在運動裝置中使用動力犁時...", + "create.ponder.mechanical_plough.text_2": "...它會破壞掉那些不具有固體碰撞箱的方塊", + "create.ponder.mechanical_plough.text_3": "此外,動力犁可以耕地", + "create.ponder.mechanical_plough.text_4": "...它也可以在不傷害實體的情況下推動它們", + + "create.ponder.mechanical_press.header": "使用機械液壓機處理物品", + "create.ponder.mechanical_press.text_1": "機械液壓機可以處理位於其下方的物品", + "create.ponder.mechanical_press.text_2": "在其下方丟入物品,或者將物品放在置物台上,都算作有效的物品輸入", + "create.ponder.mechanical_press.text_3": "若物品被輸入時正位於傳送帶上...", + "create.ponder.mechanical_press.text_4": "輥軋機會使物品停下,然後自動處理這一物品", + + "create.ponder.mechanical_press_compacting.header": "使用機械液壓機壓縮物品", + "create.ponder.mechanical_press_compacting.text_1": "對放置於工作盆內的物品進行輥軋,可以將這些物品壓縮在一起", + "create.ponder.mechanical_press_compacting.text_2": "壓縮意指任何同種物品填滿了 2x2 或者 3x3 網格的配方,以及一些額外的配方", + "create.ponder.mechanical_press_compacting.text_3": "一些配方可能需要烈焰人燃燒室提供熱量", + "create.ponder.mechanical_press_compacting.text_4": "過濾槽可用於解決兩個配方相互衝突的情況", + + "create.ponder.mechanical_saw_breaker.header": "使用動力鋸伐木", + "create.ponder.mechanical_saw_breaker.text_1": "向其通入動能後,動力鋸可以直接砍伐掉它面前的樹木", + "create.ponder.mechanical_saw_breaker.text_2": "想要一次性砍掉整棵樹,鋸子必須破壞掉樹與地面連接的最後一個方塊", + + "create.ponder.mechanical_saw_contraption.header": "在裝置中使用動力鋸", + "create.ponder.mechanical_saw_contraption.text_1": "若在運動裝置中使用動力鋸...", + "create.ponder.mechanical_saw_contraption.text_2": "...它會將撞到它的樹木破壞掉", + + "create.ponder.mechanical_saw_processing.header": "使用動力鋸處理物品", + "create.ponder.mechanical_saw_processing.text_1": "面向朝上的動力鋸可以將物品處理為其變種", + "create.ponder.mechanical_saw_processing.text_2": "處理過後的物品的彈出方向始終與通入鋸中的旋轉轉向相反", + "create.ponder.mechanical_saw_processing.text_3": "鋸子可以", + "create.ponder.mechanical_saw_processing.text_4": "若輸入原料有多種可能產物,你可以用動力鋸上的過濾槽指定只產出某種產物", + "create.ponder.mechanical_saw_processing.text_5": "若沒有使用過濾槽,動力鋸會在各產物中按順序循環輸出", + + "create.ponder.millstone.header": "使用石磨處理物品", + "create.ponder.millstone.text_1": "石磨會對輸入的物品進行磨製", + "create.ponder.millstone.text_2": "在其側邊使用齒輪與其相耦合,方可為其通入動力", + "create.ponder.millstone.text_3": "頂部可以丟入或者塞入物品", + "create.ponder.millstone.text_4": "一段時間過後,右擊石磨可以拿出其中的產物", + "create.ponder.millstone.text_5": "產物的提取也是可以自動化的", + + "create.ponder.nixie_tube.header": "使用真空管顯示器", + "create.ponder.nixie_tube.text_1": "通入紅石訊號後,真空管顯示器會顯示出紅石訊號的強度", + "create.ponder.nixie_tube.text_2": "使用命名牌在鐵砧上為其命名,可以自訂它的顯示文本", + + "create.ponder.piston_pole.header": "活塞延長杆", + "create.ponder.piston_pole.text_1": "若無相接的延長杆,動力活塞無法移動其他方塊", + "create.ponder.piston_pole.text_2": "在其背面安裝的延長杆長度,決定了活塞的推動範圍", + + "create.ponder.portable_storage_interface.header": "裝置存儲交換", + "create.ponder.portable_storage_interface.text_1": "玩家無法與運動裝置內的存儲空間進行互動", + "create.ponder.portable_storage_interface.text_2": "這一組件可以在不停止裝置的情況下與裝置內的存儲空間進行互動", + "create.ponder.portable_storage_interface.text_3": "放置第二個介面時,記得要與裝置介面相隔 1 格或者 2 格的距離", + "create.ponder.portable_storage_interface.text_4": "當它們彼此經過時,它們會連接在一起", + "create.ponder.portable_storage_interface.text_5": "連接狀態下,固定側介面便會作為整個裝置的存儲空間代理", + "create.ponder.portable_storage_interface.text_6": "物品會被輸入到裝置內...", + "create.ponder.portable_storage_interface.text_7": "...或是從裝置中提取出來", + "create.ponder.portable_storage_interface.text_8": "物品交換完畢後,裝置仍然會停留在原地一小會,然後才會繼續前行", + + "create.ponder.portable_storage_interface_redstone.header": "紅石控制", + "create.ponder.portable_storage_interface_redstone.text_1": "通入紅石訊號可以阻止固定側介面的連接行為", + + "create.ponder.powered_latch.header": "使用閂鎖器控制訊號", + "create.ponder.powered_latch.text_1": "閂鎖器是一種可以用紅石訊號控制的拉杆", + "create.ponder.powered_latch.text_2": "後方輸入的訊號會將其設為開啟狀態", + "create.ponder.powered_latch.text_3": "側邊輸入的訊號會將其設為關閉狀態", + "create.ponder.powered_latch.text_4": "你也可以手動切換其狀態", + + "create.ponder.powered_toggle_latch.header": "使用T型正反器控制訊號", + "create.ponder.powered_toggle_latch.text_1": "T型正反器是一種可以用紅石訊號控制的拉杆", + "create.ponder.powered_toggle_latch.text_2": "後方訊號輸入可以改變它的狀態", + "create.ponder.powered_toggle_latch.text_3": "...開啟或者是關閉", + "create.ponder.powered_toggle_latch.text_4": "你也可以手動切換其狀態", + + "create.ponder.pulse_repeater.header": "使用脈衝中繼器控制訊號", + "create.ponder.pulse_repeater.text_1": "脈衝中繼器會將所有通入的紅石訊號縮減為一次脈衝", + + "create.ponder.radial_chassis.header": "使用旋轉底盤黏著方塊", + "create.ponder.radial_chassis.text_1": "同一行上的旋轉底盤會相互連接在一起", + "create.ponder.radial_chassis.text_2": "當其中的一個底盤被裝置帶動時,其餘的底盤也會被帶動", + "create.ponder.radial_chassis.text_3": "底盤的側邊可以變為黏性面", + "create.ponder.radial_chassis.text_4": "再次點擊黏性面,可以讓其所有面都變得帶黏性", + "create.ponder.radial_chassis.text_5": "空手潛行右擊可以移除其上的黏性物", + "create.ponder.radial_chassis.text_6": "若有物品與底盤的黏性面相接觸...", + "create.ponder.radial_chassis.text_7": "...底盤便會與同層且位於半徑內的所有可及方塊黏著在一起", + "create.ponder.radial_chassis.text_8": "使用扳手可以精確指定底盤的影響範圍", + "create.ponder.radial_chassis.text_9": "黏性面一側的不可及方塊不會被黏著", + + "create.ponder.redstone_contact.header": "接觸式紅石訊號發生器", + "create.ponder.redstone_contact.text_1": "當兩個接觸式紅石訊號發生器面對面時,它們會發出紅石訊號", + "create.ponder.redstone_contact.text_2": "並且,若有一方位於運動裝置上,此特性也能正常生效", + + "create.ponder.redstone_link.header": "使用無線紅石訊號機", + "create.ponder.redstone_link.text_1": "無線紅石訊號機可以無線傳輸紅石訊號", + "create.ponder.redstone_link.text_2": "潛行右擊可以改變其接收模式", + "create.ponder.redstone_link.text_3": "手持扳手右擊也可以", + "create.ponder.redstone_link.text_4": "接收端會發出由傳輸端發來的訊號,有效距離為 128 格", + "create.ponder.redstone_link.text_5": "在它們所帶的槽位中放上物品,可以為它們指定頻道", + "create.ponder.redstone_link.text_6": "只有頻道相互匹配的機方可互通", + + "create.ponder.rope_pulley.header": "使用繩索滑輪移動結構", + "create.ponder.rope_pulley.text_1": "繩索滑輪在接受動能時可以垂直移動方塊結構", + "create.ponder.rope_pulley.text_2": "移動的方向及速度取決於提供的轉速", + + "create.ponder.rope_pulley_attachment.header": "繩索滑輪與裝置一同運動", + "create.ponder.rope_pulley_attachment.text_1": "當繩索滑輪本身在裝置中被帶動時...", + "create.ponder.rope_pulley_attachment.text_2": "...它附著在滑輪上的結構會被滑輪拉著一同移動", + "create.ponder.rope_pulley_attachment.text_3": "注意,只有繩索滑輪停止工作時才能被移動", + + "create.ponder.rope_pulley_modes.header": "繩索滑輪的運動模式", + "create.ponder.rope_pulley_modes.text_1": "當繩索滑輪停止運動時,它所附屬的移動結構便會方塊化", + "create.ponder.rope_pulley_modes.text_2": "你可以調整整個結構永不方塊化,或者僅在結構的初始位置方塊化", + + "create.ponder.rotation_speed_controller.header": "使用轉速控制器", + "create.ponder.rotation_speed_controller.text_1": "轉速控制器將動能從其轉軸傳遞至它上方的大齒輪", + "create.ponder.rotation_speed_controller.text_2": "在其側面滾動滑鼠滾輪,可以調節輸出轉速", + + "create.ponder.sail.header": "使用風帆來組裝風車", + "create.ponder.sail.text_1": "風帆是製作風車的趁手材料", + "create.ponder.sail.text_2": "無需強力膠等黏附手段,它們便可自行互相連結", + "create.ponder.sail.text_3": "手持染料右擊可對其染色", + "create.ponder.sail.text_4": "手持剪刀右擊可剪除帆布,使其變迴風帆框架", + + "create.ponder.sail_frame.header": "使用風帆框架來組裝風車", + "create.ponder.sail_frame.text_1": "風帆框架是製作風車的趁手材料", + "create.ponder.sail_frame.text_2": "無需強力膠等黏附手段,它們便可自行互相連結", + + "create.ponder.sequenced_gearshift.header": "使用可編程齒輪箱來控制轉速", + "create.ponder.sequenced_gearshift.text_1": "可編程齒輪箱能夠根據玩家設置的預設時序表來傳遞旋轉", + "create.ponder.sequenced_gearshift.text_2": "對其右擊可以打開設置面板", + "create.ponder.sequenced_gearshift.text_3": "接受紅石訊號時,它會開始執行其內部已設定好的時序指令表", + "create.ponder.sequenced_gearshift.text_4": "當完成時序指令表後,它會進入待機狀態,再次接受紅石訊號後,它才會再次執行時序指令表內容", + "create.ponder.sequenced_gearshift.text_5": "紅石比較器可以讀取目前時序指令表完成進度", + + "create.ponder.shaft.header": "使用傳動軸來傳送動能", + "create.ponder.shaft.text_1": "傳動軸可以直線傳送動能", + + "create.ponder.shaft_casing.header": "包裹傳動軸", + "create.ponder.shaft_casing.text_1": "黃銅及安山岩機殼可以用來裝飾傳動軸", + + "create.ponder.smart_chute.header": "使用智慧滑道來過濾物品", + "create.ponder.smart_chute.text_1": "智慧滑道是一種可以被控制的滑道", + "create.ponder.smart_chute.text_2": "當在其過濾槽內指定了物品後,溜槽只會傳輸這一指定標記的物品", + "create.ponder.smart_chute.text_3": "使用滑鼠滾輪可以指定被過濾的物品數量", + "create.ponder.smart_chute.text_4": "通入紅石訊號,智慧溜槽將會完全暫停工作", + + "create.ponder.speedometer.header": "使用速度計來監測轉速", + "create.ponder.speedometer.text_1": "速度計能顯示相接組件的轉速", + "create.ponder.speedometer.text_2": "當佩戴MR護目鏡時,可以看到儀表所顯示的更詳細的數據", + "create.ponder.speedometer.text_3": "紅石比較器可以根據速度計的數值輸出不同強弱的紅石訊號", + + "create.ponder.stabilized_bearings.header": "裝置固定朝向", + "create.ponder.stabilized_bearings.text_1": "當動力軸承在結構被帶動時...", + "create.ponder.stabilized_bearings.text_2": "...它會確保它轉盤的垂直朝向不變", + "create.ponder.stabilized_bearings.text_3": "跟預設的一樣,動力軸承會黏著它前方的方塊", + "create.ponder.stabilized_bearings.text_4": "這種情況下,它所黏著的子結構的垂直朝向也不會改變", + + "create.ponder.sticker.header": "使用方塊黏著器來黏取方塊", + "create.ponder.sticker.text_1": "方塊黏著器是一個很棒的裝置,他受控於紅石訊號", + "create.ponder.sticker.text_2": "當接收到訊號時,他會黏起面前的一個方塊", + "create.ponder.sticker.text_3": "如果此時方塊黏著器被移動,被黏到的方塊會跟著移動", + "create.ponder.sticker.text_4": "再次接收到訊號後,黏著器會放下它面前的方塊", + + "create.ponder.stressometer.header": "使用動能錶來監測應力", + "create.ponder.stressometer.text_1": "動能錶能顯示目前動能網路內的應力訊息", + "create.ponder.stressometer.text_2": "當佩戴MR護目鏡時,可以看到儀表所顯示的更詳細的數據", + "create.ponder.stressometer.text_3": "紅石比較器可以根據動能錶的數值輸出不同強弱的紅石訊號", + + "create.ponder.super_glue.header": "使用強力膠來黏附方塊", + "create.ponder.super_glue.text_1": "強力膠可以在任意兩個方塊間使用", + "create.ponder.super_glue.text_2": "當被黏合的方塊被組裝為裝置時,他們會一起運動", + "create.ponder.super_glue.text_3": "當強力膠在副手時...", + "create.ponder.super_glue.text_4": "...新放置的方塊會自動被黏附在所放置方塊的面上", + "create.ponder.super_glue.text_5": "左擊可以清除強力膠", + + "create.ponder.valve_handle.header": "使用閥門手輪產生動能", + "create.ponder.valve_handle.text_1": "玩家可以手動使用閥門手輪來產生動能", + "create.ponder.valve_handle.text_2": "右擊可使它逆時針旋轉", + "create.ponder.valve_handle.text_3": "它的轉速慢而精確", + "create.ponder.valve_handle.text_4": "潛行右擊可使它順時針旋轉", + "create.ponder.valve_handle.text_5": "可以透過染色來美化閥門手輪", + + "create.ponder.water_wheel.header": "使用水車產生動能", + "create.ponder.water_wheel.text_1": "水車利用臨近的水流來進行應力發生", + "create.ponder.water_wheel.text_2": "水車接觸水流的麵越多,它的轉速越高", + "create.ponder.water_wheel.text_3": "水車葉片應逆著水流方向擺放", + "create.ponder.water_wheel.text_4": "如果順著水流擺放,它的效率則會降低", + + "create.ponder.weighted_ejector.header": "使用彈射置物台", + "create.ponder.weighted_ejector.text_1": "手持彈射置物台時,潛行時右擊可以設置彈射目標位置", + "create.ponder.weighted_ejector.text_10": "現在,只有等被放置的物品數量等於所設定數量時,彈射置物台才會彈射物品", + "create.ponder.weighted_ejector.text_11": "當其他實體站在彈射置物台上時會被直接彈射", + "create.ponder.weighted_ejector.text_2": "現在,放置下的彈射置物台會將物品彈射至目標位置", + "create.ponder.weighted_ejector.text_3": "限制範圍內的任意距離和高度均可作為有效目標地點", + "create.ponder.weighted_ejector.text_4": "但是,目標位置與置物台的連線,必須垂直於置物台的側面", + "create.ponder.weighted_ejector.text_5": "如果沒有設置有效目標位置,彈射置物台會直接將其前方一格設為默認目標位置", + "create.ponder.weighted_ejector.text_6": "提供動能可為其蓄力", + "create.ponder.weighted_ejector.text_7": "蓄力完畢後,放置在它上方的物品會被立刻彈射出去", + "create.ponder.weighted_ejector.text_8": "如果目標為容器,則彈射置物台會等待容器有位置後再彈射物品", + "create.ponder.weighted_ejector.text_9": "使用扳手可以調整彈射所要求的物品數量", + + "create.ponder.weighted_ejector_redstone.header": "使用紅石控制彈射置物台", + "create.ponder.weighted_ejector_redstone.text_1": "當被紅石充能時,彈射置物台停止工作", + "create.ponder.weighted_ejector_redstone.text_2": "此外,置物台彈射的瞬間可以被偵測器偵測", + "create.ponder.weighted_ejector_tunnel.header": "使用彈射置物台來分流物品", + "create.ponder.weighted_ejector_tunnel.text_1": "與黃銅隧道搭配使用時,彈射置物台可以將物品以特定數量進行分流", + "create.ponder.weighted_ejector_tunnel.text_2": "首先,將黃銅隧道調整為“最近優先”模式,從而讓它優先側面輸出", + "create.ponder.weighted_ejector_tunnel.text_3": "置物台上所設置的物品數量則為被分流出去的物品數量", + "create.ponder.weighted_ejector_tunnel.text_4": "當所設置的物品數量被分流出去後...", + "create.ponder.weighted_ejector_tunnel.text_5": "...剩餘的物品則會繼續前進", + + "create.ponder.windmill_source.header": "使用風車軸承產生動能", + "create.ponder.windmill_source.text_1": "風車軸承會黏著它面前的方塊結構", + "create.ponder.windmill_source.text_2": "如果黏著的方塊結構包含足夠的風帆方塊即為風車", + "create.ponder.windmill_source.text_3": "右鍵啟動風車後,風車開始提供動能", + "create.ponder.windmill_source.text_4": "產生的動能將取決於所黏風帆方塊之數量", + "create.ponder.windmill_source.text_5": "使用扳手來調整其旋轉方向", + "create.ponder.windmill_source.text_6": "對風車軸承右鍵可使其停止方便你維修風車", + + "create.ponder.windmill_structure.header": "風車結構", + "create.ponder.windmill_structure.text_1": "任一包含至少8個風帆方塊的結構即為有效的風車", + + "_": "Thank you for translating Create!" + +} \ No newline at end of file From 62026e3f130b70b36f7ffb0134f59dc0e73424ed Mon Sep 17 00:00:00 2001 From: dunois2737 <78353924+dunois2737@users.noreply.github.com> Date: Sat, 22 May 2021 16:10:23 +0900 Subject: [PATCH 084/198] update zh_tw for create 0.3.1 --- src/main/resources/assets/create/lang/zh_tw.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/assets/create/lang/zh_tw.json b/src/main/resources/assets/create/lang/zh_tw.json index e9b7b29bf..45c124d4c 100644 --- a/src/main/resources/assets/create/lang/zh_tw.json +++ b/src/main/resources/assets/create/lang/zh_tw.json @@ -1028,10 +1028,10 @@ "create.item_attributes.added_by.inverted": "不是由%1$s添加", "create.item_attributes.has_enchant": "有附魔效果%1$s", "create.item_attributes.has_enchant.inverted": "沒有附魔效果%1$s", - "create.item_attributes.color": "UNLOCALIZED: is dyed %1$s", - "create.item_attributes.color.inverted": "UNLOCALIZED: is not dyed %1$s", - "create.item_attributes.max_enchanted": "UNLOCALIZED: is enchanted at max level", - "create.item_attributes.max_enchanted.inverted": "UNLOCALIZED: is not enchanted at max level", + "create.item_attributes.color": "已被染色成 %1$s", + "create.item_attributes.color.inverted": "未被染色成 %1$s", + "create.item_attributes.max_enchanted": "已達到最高附魔等級", + "create.item_attributes.max_enchanted.inverted": "未達到最高附魔等級", "create.item_attributes.has_fluid": "包含%1$s", "create.item_attributes.has_fluid.inverted": "不包含%1$s", "create.item_attributes.has_name": "有自定義名稱%1$s", From f9ad211fb8c0a1e4b1511b72a4942f819dab91ce Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sat, 22 May 2021 17:33:49 +0200 Subject: [PATCH 085/198] Generate required data for Pepper's bed fix --- src/generated/resources/.cache/cache | 4 ++-- .../resources/data/create/advancements/aesthetics.json | 4 ++-- src/generated/resources/data/create/tags/blocks/brittle.json | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 7f62cb3f8..294fd7aef 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -1652,7 +1652,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json 096382a4c025b5ffdde9c496ee9da0d5345fbe17 assets/create/sounds.json -0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json +5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json 187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json 0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json 83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json @@ -3645,7 +3645,7 @@ d3fdb8ece6cb072a93ddb64a0baad5ac952117a4 data/create/recipes/weathered_limestone 0f3c993eb6dd3f37953f304b8fad15bf60469ef4 data/create/recipes/weathered_limestone_cobblestone_wall_from_weathered_limestone_cobblestone_stonecutting.json 6eceb25fabbb6b389ca35de3b829ad061c9c456a data/create/recipes/weathered_limestone_pillar.json 11667414f73bc2d00bda7c5c1a7d2934bf6e9165 data/create/recipes/weathered_limestone_pillar_from_weathered_limestone_stonecutting.json -eedf31af7134d03656c5fa57229982f9c5bed07c data/create/tags/blocks/brittle.json +20c20a12b0baff2ba493b1405db7d2d8a15b81af data/create/tags/blocks/brittle.json 330bfb3850ba3964b10b1bccbc3cbb9b012cae54 data/create/tags/blocks/fan_heaters.json 3bc64e3a1e7980237435b1770a9ba2102d57fcd4 data/create/tags/blocks/fan_transparent.json 74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/create/tags/blocks/non_movable.json diff --git a/src/generated/resources/data/create/advancements/aesthetics.json b/src/generated/resources/data/create/advancements/aesthetics.json index d723cbe38..59a86f429 100644 --- a/src/generated/resources/data/create/advancements/aesthetics.json +++ b/src/generated/resources/data/create/advancements/aesthetics.json @@ -28,8 +28,8 @@ "trigger": "create:bracket_apply", "conditions": { "accepted_entries": [ - "create:cogwheel", - "create:large_cogwheel" + "create:large_cogwheel", + "create:cogwheel" ] } }, diff --git a/src/generated/resources/data/create/tags/blocks/brittle.json b/src/generated/resources/data/create/tags/blocks/brittle.json index c028ad70c..7970c3bf9 100644 --- a/src/generated/resources/data/create/tags/blocks/brittle.json +++ b/src/generated/resources/data/create/tags/blocks/brittle.json @@ -25,6 +25,7 @@ "create:furnace_engine", "create:redstone_link", "#minecraft:doors", + "#minecraft:beds", "minecraft:flower_pot", "minecraft:bell", "minecraft:cocoa" From bfc8c3e3068a8e84da22b9c1d826ff7524a451a7 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sat, 22 May 2021 17:35:49 -0400 Subject: [PATCH 086/198] Make gantry carriage brittle, defer brittle blocks --- src/main/java/com/simibubi/create/AllBlocks.java | 1 + .../content/schematics/block/SchematicannonTileEntity.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 5ea72cd61..5b572ea89 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -739,6 +739,7 @@ public class AllBlocks { public static final BlockEntry GANTRY_CARRIAGE = REGISTRATE.block("gantry_carriage", GantryCarriageBlock::new) .initialProperties(SharedProperties::stone) + .tag(AllBlockTags.BRITTLE.tag) .properties(Block.Properties::nonOpaque) .blockstate(BlockStateGen.directionalAxisBlockProvider()) .item() diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index ef443d62d..2bc098dc3 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -11,6 +11,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTags.AllBlockTags; +import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltPart; import com.simibubi.create.content.contraptions.relays.belt.BeltSlope; @@ -728,8 +729,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } public static boolean shouldDeferBlock(BlockState state) { - Block block = state.getBlock(); - return block instanceof AbstractRailBlock || block.is(AllBlocks.GANTRY_CARRIAGE.get()); + return BlockMovementTraits.isBrittle(state); } public void finishedPrinting() { From 9352ef9ede74d4cf68b448df6449ce9ed00b1c26 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sat, 22 May 2021 17:45:01 -0700 Subject: [PATCH 087/198] Json program specs, new extension/gamestate system. - Program specs are now loaded from json instead of being defined in code and registered manually. - Within the json spec, a program can define a list of states. - A state consists of: - A "when" clause. - A list of strings to be #defined. - A list of extensions to apply at program link time. - Each frame, the first state whose "when" clause returns true will be used. - A when clause consists of: - A state provider defined by a resource location. - A value to match. - When the value returned by the provider matches the value defined in the when clause, the when clause is considered to be 'true'. - There is syntactic sugar for when a provider returns a boolean value. - This system is in its infancy, and there is plenty of room for improvement. --- .../jozufozu/flywheel/backend/Backend.java | 6 +- .../flywheel/backend/ResourceUtil.java | 9 +++ .../flywheel/backend/ShaderContext.java | 22 +++--- .../flywheel/backend/ShaderLoader.java | 43 +++++++++++- .../backend/core/CrumblingProgram.java | 6 +- .../backend/core/FogMultiProgram.java | 59 ---------------- .../flywheel/backend/core/WorldContext.java | 59 ++++++++++------ .../backend/core/WorldTileRenderer.java | 2 +- .../core/shader/ExtensibleGlProgram.java | 23 ++++--- .../flywheel/backend/core/shader/FogMode.java | 27 +------- .../flywheel/backend/core/shader/GlFog.java | 8 +-- .../backend/core/shader/GlFogMode.java | 38 ---------- .../{gl => core}/shader/IMultiProgram.java | 4 +- .../core/shader/IProgramExtension.java | 17 ----- .../backend/core/shader/ProgramExtender.java | 18 ----- .../backend/core/shader/ProgramSpec.java | 22 ------ .../{gl => core}/shader/ShaderCallback.java | 4 +- .../backend/core/shader/SingleProgram.java | 44 ------------ .../shader/StateSensitiveMultiProgram.java | 54 +++++++++++++++ .../backend/core/shader/WorldFog.java | 47 +++++++++++++ .../backend/core/shader/WorldProgram.java | 5 +- .../shader/extension/IExtensionInstance.java | 14 ++++ .../shader/extension/IProgramExtension.java | 26 +++++++ .../extension/UnitExtensionInstance.java | 23 +++++++ .../shader/gamestate/FogStateProvider.java | 22 ++++++ .../shader/gamestate/IGameStateProvider.java | 15 ++++ .../gamestate/NormalDebugStateProvider.java | 26 +++++++ .../gamestate/RainbowDebugStateProvider.java | 27 ++++++++ .../shader/spec/BooleanContextCondition.java | 37 ++++++++++ .../shader/spec/IBooleanStateProvider.java | 13 ++++ .../core/shader/spec/IContextCondition.java | 14 ++++ .../backend/core/shader/spec/ProgramSpec.java | 61 ++++++++++++++++ .../core/shader/spec/ProgramState.java | 67 ++++++++++++++++++ .../core/shader/spec/SpecMetaRegistry.java | 69 +++++++++++++++++++ .../shader/spec/SpecificValueCondition.java | 42 +++++++++++ .../flywheel/backend/gl/shader/GLSLType.java | 45 ------------ .../backend/gl/shader/ShaderSpecLoader.java | 10 --- .../instancing/InstancedTileRenderer.java | 2 +- .../backend/instancing/MaterialSpec.java | 7 +- .../backend/instancing/RenderMaterial.java | 2 +- .../com/jozufozu/flywheel/util/CodecUtil.java | 26 +++++++ .../java/com/jozufozu/flywheel/util/Pair.java | 68 ++++++++++++++++++ .../com/simibubi/create/CreateClient.java | 2 - .../render/ContraptionProgram.java | 6 +- .../render/ContraptionRenderDispatcher.java | 7 +- .../foundation/render/AllMaterialSpecs.java | 2 +- .../foundation/render/AllProgramSpecs.java | 37 +++------- .../render/effects/EffectsContext.java | 15 +++- .../render/effects/SphereFilterProgram.java | 11 ++- .../assets/create/flywheel/programs/belt.json | 33 +++++++++ .../create/flywheel/programs/chromatic.json | 4 ++ .../flywheel/programs/contraption_actor.json | 29 ++++++++ .../programs/contraption_structure.json | 29 ++++++++ .../assets/create/flywheel/programs/flap.json | 29 ++++++++ .../create/flywheel/programs/rotating.json | 33 +++++++++ .../assets/create/flywheel/shaders/belt.vert | 4 +- .../flywheel/shaders/contraption_actor.vert | 2 +- .../shaders/contraption_structure.vert | 2 +- .../assets/create/flywheel/shaders/flap.vert | 2 +- .../create/flywheel/shaders/rotating.vert | 4 +- .../flywheel/flywheel/programs/model.json | 29 ++++++++ .../flywheel/flywheel/programs/oriented.json | 29 ++++++++ .../flywheel/flywheel/shaders/model.vert | 2 +- .../flywheel/flywheel/shaders/oriented.vert | 2 +- 64 files changed, 1053 insertions(+), 393 deletions(-) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFogMode.java rename src/main/java/com/jozufozu/flywheel/backend/{gl => core}/shader/IMultiProgram.java (80%) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/IProgramExtension.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramExtender.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramSpec.java rename src/main/java/com/jozufozu/flywheel/backend/{gl => core}/shader/ShaderCallback.java (74%) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/SingleProgram.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/StateSensitiveMultiProgram.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldFog.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/IExtensionInstance.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/IProgramExtension.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/UnitExtensionInstance.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/FogStateProvider.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/IGameStateProvider.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/NormalDebugStateProvider.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/RainbowDebugStateProvider.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/BooleanContextCondition.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/IBooleanStateProvider.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/IContextCondition.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/ProgramSpec.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/ProgramState.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/SpecMetaRegistry.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/SpecificValueCondition.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/shader/GLSLType.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java create mode 100644 src/main/java/com/jozufozu/flywheel/util/CodecUtil.java create mode 100644 src/main/java/com/jozufozu/flywheel/util/Pair.java create mode 100644 src/main/resources/assets/create/flywheel/programs/belt.json create mode 100644 src/main/resources/assets/create/flywheel/programs/chromatic.json create mode 100644 src/main/resources/assets/create/flywheel/programs/contraption_actor.json create mode 100644 src/main/resources/assets/create/flywheel/programs/contraption_structure.json create mode 100644 src/main/resources/assets/create/flywheel/programs/flap.json create mode 100644 src/main/resources/assets/create/flywheel/programs/rotating.json create mode 100644 src/main/resources/assets/flywheel/flywheel/programs/model.json create mode 100644 src/main/resources/assets/flywheel/flywheel/programs/oriented.json diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index a704b8273..fc0b3ac8a 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -23,8 +23,8 @@ import org.lwjgl.opengl.GLCapabilities; import com.jozufozu.flywheel.backend.core.CrumblingRenderer; import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.core.WorldTileRenderer; -import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; +import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; @@ -137,6 +137,10 @@ public class Backend { return spec; } + public static ProgramSpec getSpec(ResourceLocation name) { + return programSpecRegistry.get(name); + } + public static boolean isFlywheelWorld(World world) { return world == Minecraft.getInstance().world || (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/ResourceUtil.java b/src/main/java/com/jozufozu/flywheel/backend/ResourceUtil.java index 3a80b026e..a8294d3d1 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ResourceUtil.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ResourceUtil.java @@ -7,4 +7,13 @@ public class ResourceUtil { public static ResourceLocation subPath(ResourceLocation root, String subPath) { return new ResourceLocation(root.getNamespace(), root.getPath() + subPath); } + + public static ResourceLocation removePrefixUnchecked(ResourceLocation full, String root) { + return new ResourceLocation(full.getNamespace(), full.getPath().substring(root.length())); + } + + public static ResourceLocation trim(ResourceLocation loc, String prefix, String suffix) { + String path = loc.getPath(); + return new ResourceLocation(loc.getNamespace(), path.substring(prefix.length(), path.length() - suffix.length())); + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java index 89ab4e48f..0a86e017a 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java @@ -4,25 +4,23 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.core.shader.IMultiProgram; +import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; -import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; -import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.backend.loading.Shader; import com.jozufozu.flywheel.backend.loading.ShaderTransformer; +import net.minecraft.util.ResourceLocation; + public abstract class ShaderContext

{ - public final Map> programs = new HashMap<>(); + protected final Map> programs = new HashMap<>(); - protected final ShaderSpecLoader

specLoader; protected ShaderTransformer transformer = new ShaderTransformer(); - public ShaderContext(ShaderSpecLoader

specLoader) { - this.specLoader = specLoader; - } + public ShaderContext() { } // TODO: Untangle the loading functions @@ -31,14 +29,16 @@ public abstract class ShaderContext

{ */ public abstract void load(ShaderLoader loader); + protected abstract IMultiProgram

loadSpecInternal(ShaderLoader loader, ProgramSpec spec); + public void loadProgramFromSpec(ShaderLoader loader, ProgramSpec programSpec) { try { - programs.put(programSpec, specLoader.create(loader, this, programSpec)); + programs.put(programSpec.name, loadSpecInternal(loader, programSpec)); Backend.log.debug("Loaded program {}", programSpec.name); } catch (Exception e) { - Backend.log.error("program '{}': {}", programSpec.name, e.getMessage()); + Backend.log.error("Program '{}': {}", programSpec.name, e); loader.notifyError(); } } @@ -66,7 +66,7 @@ public abstract class ShaderContext

{ } - public P getProgram(ProgramSpec spec) { + public P getProgram(ResourceLocation spec) { return programs.get(spec).get(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index 2dbf1a100..848b5943c 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -27,6 +27,11 @@ import javax.annotation.Nonnull; import org.lwjgl.system.MemoryUtil; import com.google.common.collect.Lists; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; +import com.jozufozu.flywheel.backend.core.shader.spec.SpecMetaRegistry; import com.jozufozu.flywheel.backend.gl.GlObject; import com.jozufozu.flywheel.backend.gl.shader.GlShader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; @@ -34,6 +39,9 @@ import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.backend.loading.Shader; import com.jozufozu.flywheel.backend.loading.ShaderLoadingException; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.DataResult; +import com.mojang.serialization.JsonOps; import net.minecraft.resources.IResource; import net.minecraft.resources.IResourceManager; @@ -43,6 +51,7 @@ import net.minecraftforge.resource.VanillaResourceType; public class ShaderLoader { public static final String SHADER_DIR = "flywheel/shaders/"; + public static final String PROGRAM_DIR = "flywheel/programs/"; public static final ArrayList EXTENSIONS = Lists.newArrayList(".vert", ".vsh", ".frag", ".fsh", ".glsl"); // #flwinclude <"valid_namespace:valid/path_to_file.glsl"> @@ -52,6 +61,7 @@ public class ShaderLoader { private final Map shaderSource = new HashMap<>(); private boolean shouldCrash; + private final Gson gson = new GsonBuilder().create(); void onResourceManagerReload(IResourceManager manager, Predicate predicate) { if (predicate.test(VanillaResourceType.SHADERS)) { @@ -63,6 +73,10 @@ public class ShaderLoader { shouldCrash = false; + SpecMetaRegistry.init(); + + loadProgramSpecs(manager); + loadShaderSources(manager); for (ShaderContext context : Backend.contexts) { @@ -70,7 +84,7 @@ public class ShaderLoader { } if (shouldCrash) { - throw new ShaderLoadingException("could not load all shaders, see log for details"); + throw new ShaderLoadingException("Could not load all shaders, see log for details"); } Backend.log.info("Loaded all shader programs."); @@ -81,6 +95,30 @@ public class ShaderLoader { } } + private void loadProgramSpecs(IResourceManager manager) { + Collection programSpecs = manager.getAllResourceLocations(PROGRAM_DIR, s -> s.endsWith(".json")); + + for (ResourceLocation location : programSpecs) { + try { + IResource file = manager.getResource(location); + + String s = readToString(file.getInputStream()); + + ResourceLocation specName = ResourceUtil.trim(location, PROGRAM_DIR, ".json"); + + DataResult> result = ProgramSpec.CODEC.decode(JsonOps.INSTANCE, gson.fromJson(s, JsonElement.class)); + + ProgramSpec spec = result.get().orThrow().getFirst(); + + spec.setName(specName); + + Backend.register(spec); + } catch (Exception e) { + Backend.log.error(e); + } + } + } + public void notifyError() { shouldCrash = true; } @@ -110,8 +148,7 @@ public class ShaderLoader { String file = readToString(resource.getInputStream()); - ResourceLocation name = new ResourceLocation(location.getNamespace(), - location.getPath().substring(SHADER_DIR.length())); + ResourceLocation name = ResourceUtil.removePrefixUnchecked(location, SHADER_DIR); shaderSource.put(name, file); } catch (IOException e) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java index 2c1606813..1bdf177e9 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingProgram.java @@ -4,16 +4,16 @@ import static org.lwjgl.opengl.GL20.glUniform2f; import java.util.List; -import com.jozufozu.flywheel.backend.core.shader.ProgramExtender; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; +import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension; import com.jozufozu.flywheel.backend.loading.Program; public class CrumblingProgram extends WorldProgram { protected final int uTextureScale; protected int uCrumbling; - public CrumblingProgram(Program program, List fogFactory) { - super(program, fogFactory); + public CrumblingProgram(Program program, List extensions) { + super(program, extensions); uTextureScale = getUniformLocation("uTextureScale"); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java deleted file mode 100644 index babe5d039..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.jozufozu.flywheel.backend.core; - -import java.util.Collections; -import java.util.EnumMap; -import java.util.Map; - -import com.jozufozu.flywheel.backend.ShaderContext; -import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.core.shader.ExtensibleGlProgram; -import com.jozufozu.flywheel.backend.core.shader.GlFog; -import com.jozufozu.flywheel.backend.core.shader.GlFogMode; -import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; -import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; -import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; -import com.jozufozu.flywheel.backend.loading.Program; - -public class FogMultiProgram

implements IMultiProgram

{ - - private final Map programs; - - public FogMultiProgram(Map programs) { - this.programs = programs; - } - - @Override - public P get() { - return programs.get(GlFog.getFogMode()); - } - - @Override - public void delete() { - programs.values().forEach(GlProgram::delete); - } - - public static class SpecLoader

implements ShaderSpecLoader

{ - - private final ExtensibleGlProgram.Factory

factory; - - public SpecLoader(ExtensibleGlProgram.Factory

factory) { - this.factory = factory; - } - - @Override - public IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { - Map programs = new EnumMap<>(GlFogMode.class); - - for (GlFogMode fogMode : GlFogMode.values()) { - Program builder = ctx.loadProgram(loader, spec, fogMode.getDefines()); - - programs.put(fogMode, factory.create(builder, Collections.singletonList(fogMode))); - } - - return new FogMultiProgram<>(programs); - } - - } - -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index 0bf84e0c9..008e5c7a9 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -12,10 +12,11 @@ import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.ResourceUtil; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; +import com.jozufozu.flywheel.backend.core.shader.ExtensibleGlProgram; +import com.jozufozu.flywheel.backend.core.shader.IMultiProgram; +import com.jozufozu.flywheel.backend.core.shader.StateSensitiveMultiProgram; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; -import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; -import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; +import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; import com.jozufozu.flywheel.backend.loading.InstancedArraysTemplate; @@ -32,45 +33,59 @@ public class WorldContext

extends ShaderContext

{ private static final String declaration = "#flwbuiltins"; private static final Pattern builtinPattern = Pattern.compile(declaration); - public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new FogMultiProgram.SpecLoader<>(WorldProgram::new)); - public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new FogMultiProgram.SpecLoader<>(CrumblingProgram::new)); + public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), WorldProgram::new); + public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), CrumblingProgram::new); - protected ProgramTemplate template; protected final ResourceLocation name; - protected final Supplier> specStream; - protected final TemplateFactory templateFactory; + private final ExtensibleGlProgram.Factory

factory; + protected Supplier> specStream; + protected TemplateFactory templateFactory; private final Map builtins = new EnumMap<>(ShaderType.class); private final Map builtinSources = new EnumMap<>(ShaderType.class); - public WorldContext(ResourceLocation root, ShaderSpecLoader

loader) { - this(root, loader, () -> Backend.allMaterials() - .stream() - .map(MaterialSpec::getProgramSpec), InstancedArraysTemplate::new); - } - - public WorldContext(ResourceLocation root, ShaderSpecLoader

loader, Supplier> specStream, TemplateFactory templateFactory) { - super(loader); + public WorldContext(ResourceLocation root, ExtensibleGlProgram.Factory

factory) { + this.factory = factory; this.name = root; - this.specStream = specStream; - this.templateFactory = templateFactory; builtins.put(ShaderType.FRAGMENT, ResourceUtil.subPath(root, "/builtin.frag")); builtins.put(ShaderType.VERTEX, ResourceUtil.subPath(root, "/builtin.vert")); + + specStream = () -> Backend.allMaterials() + .stream() + .map(MaterialSpec::getProgramSpec); + + templateFactory = InstancedArraysTemplate::new; } + public WorldContext

setSpecStream(Supplier> specStream) { + this.specStream = specStream; + return this; + } + + public WorldContext

setTemplateFactory(TemplateFactory templateFactory) { + this.templateFactory = templateFactory; + return this; + } + + @Override + protected IMultiProgram

loadSpecInternal(ShaderLoader loader, ProgramSpec spec) { + return new StateSensitiveMultiProgram<>(loader, factory, this, spec); + } + + protected ProgramTemplate template; @Override public void load(ShaderLoader loader) { programs.values().forEach(IMultiProgram::delete); programs.clear(); - Backend.log.info("loading context '{}'", name); + Backend.log.info("Loading context '{}'", name); try { builtins.forEach((type, resourceLocation) -> builtinSources.put(type, loader.getShaderSource(resourceLocation))); } catch (ShaderLoadingException e) { loader.notifyError(); - Backend.log.error(String.format("could not find builtin: %s", e.getMessage())); + Backend.log.error(String.format("Could not find builtin: %s", e.getMessage())); return; } @@ -83,7 +98,9 @@ public class WorldContext

extends ShaderContext

{ .pushStage(template) .pushStage(loader::processIncludes); - specStream.get().forEach(spec -> loadProgramFromSpec(loader, spec)); + specStream.get() + .map(Backend::getSpec) + .forEach(spec -> loadProgramFromSpec(loader, spec)); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java index 1e04b9edc..5401bd444 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java @@ -2,8 +2,8 @@ package com.jozufozu.flywheel.backend.core; import java.util.ArrayList; +import com.jozufozu.flywheel.backend.core.shader.ShaderCallback; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; -import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; import net.minecraft.client.renderer.ActiveRenderInfo; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java index 701122ea6..a582595b9 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java @@ -1,18 +1,20 @@ package com.jozufozu.flywheel.backend.core.shader; +import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import com.jozufozu.flywheel.backend.core.shader.extension.IExtensionInstance; +import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.loading.Program; /** * A shader program that be arbitrarily "extended". This class can take in any number of program extensions, and - * will initialize them and then call their {@link IProgramExtension#bind() bind} function every subsequent time this + * will initialize them and then call their {@link IExtensionInstance#bind() bind} function every subsequent time this * program is bound. An "extension" is something that interacts with the shader program in a way that is invisible to * the caller using the program. This is used by some programs to implement the different fog modes. Other uses might * include binding extra textures to allow for blocks to have normal maps, for example. As the extensions are @@ -21,15 +23,18 @@ import com.jozufozu.flywheel.backend.loading.Program; */ public class ExtensibleGlProgram extends GlProgram { - protected final List extensions; + protected final List extensions; - public ExtensibleGlProgram(Program program, @Nullable List extensions) { + public ExtensibleGlProgram(Program program, @Nullable List extensions) { super(program); if (extensions != null) { - this.extensions = extensions.stream() - .map(e -> e.create(this)) - .collect(Collectors.toList()); + List list = new ArrayList<>(); + for (IProgramExtension e : extensions) { + IExtensionInstance extension = e.create(this); + list.add(extension); + } + this.extensions = list; } else { this.extensions = Collections.emptyList(); } @@ -39,7 +44,7 @@ public class ExtensibleGlProgram extends GlProgram { public void bind() { super.bind(); - extensions.forEach(IProgramExtension::bind); + extensions.forEach(IExtensionInstance::bind); } @Override @@ -57,7 +62,7 @@ public class ExtensibleGlProgram extends GlProgram { public interface Factory

{ @Nonnull - P create(Program program, @Nullable List extensions); + P create(Program program, @Nullable List extensions); default P create(Program program) { return create(program, null); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/FogMode.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/FogMode.java index 5e88019d2..b8c80f3f5 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/FogMode.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/FogMode.java @@ -3,32 +3,14 @@ package com.jozufozu.flywheel.backend.core.shader; import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.Flywheel; +import com.jozufozu.flywheel.backend.core.shader.extension.IExtensionInstance; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import net.minecraft.util.ResourceLocation; public abstract class FogMode { - public static class None implements IProgramExtension { - - public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_none"); - - public None(GlProgram program) { - - } - - @Override - public void bind() { - - } - - @Override - public ResourceLocation name() { - return NAME; - } - } - - public static class Linear implements IProgramExtension { + public static class Linear implements IExtensionInstance { public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_linear"); @@ -52,7 +34,7 @@ public abstract class FogMode { } } - public static class Exp2 implements IProgramExtension { + public static class Exp2 implements IExtensionInstance { public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_exp2"); @@ -75,7 +57,4 @@ public abstract class FogMode { return NAME; } } - - public interface Factory extends IProgramExtension { - } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFog.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFog.java index 100c1a71d..dd1111425 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFog.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFog.java @@ -27,9 +27,9 @@ public class GlFog { return GlStateManager.FOG.field_179045_d; } - public static GlFogMode getFogMode() { + public static WorldFog getFogMode() { if (!fogEnabled()) { - return GlFogMode.NONE; + return WorldFog.NONE; } int mode = getFogModeGlEnum(); @@ -37,9 +37,9 @@ public class GlFog { switch (mode) { case GL11.GL_EXP2: case GL11.GL_EXP: - return GlFogMode.EXP2; + return WorldFog.EXP2; case GL11.GL_LINEAR: - return GlFogMode.LINEAR; + return WorldFog.LINEAR; default: throw new UnsupportedOperationException("Unknown fog mode: " + mode); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFogMode.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFogMode.java deleted file mode 100644 index 57f1acea6..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/GlFogMode.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.jozufozu.flywheel.backend.core.shader; - -import java.util.Collections; -import java.util.List; - -import com.google.common.collect.Lists; -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; - -public enum GlFogMode implements ProgramExtender { - NONE(FogMode.None::new), - LINEAR(FogMode.Linear::new, "USE_FOG_LINEAR"), - EXP2(FogMode.Exp2::new, "USE_FOG_EXP2"), - ; - - public static final String USE_FOG = "USE_FOG"; - - private final ProgramExtender fogFactory; - private final List defines; - - GlFogMode(ProgramExtender fogFactory) { - this.fogFactory = fogFactory; - this.defines = Collections.emptyList(); - } - - GlFogMode(ProgramExtender fogFactory, String name) { - this.fogFactory = fogFactory; - this.defines = Lists.newArrayList(USE_FOG, name); - } - - public List getDefines() { - return defines; - } - - @Override - public IProgramExtension create(GlProgram program) { - return fogFactory.create(program); - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/IMultiProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/IMultiProgram.java similarity index 80% rename from src/main/java/com/jozufozu/flywheel/backend/gl/shader/IMultiProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/core/shader/IMultiProgram.java index 950bcddc1..f4d7478e4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/IMultiProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/IMultiProgram.java @@ -1,4 +1,6 @@ -package com.jozufozu.flywheel.backend.gl.shader; +package com.jozufozu.flywheel.backend.core.shader; + +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; /** * Encapsulates any number of shader programs for use in similar contexts. diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/IProgramExtension.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/IProgramExtension.java deleted file mode 100644 index 4e825fa5c..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/IProgramExtension.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.jozufozu.flywheel.backend.core.shader; - -import net.minecraft.util.ResourceLocation; - -/** - * A program extension to be passed to - */ -public interface IProgramExtension { - - /** - * Bind the extra program state. It is recommended to grab the state information from global variables, - * or local variables passed through a {@link ProgramExtender} closure. - */ - void bind(); - - ResourceLocation name(); -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramExtender.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramExtender.java deleted file mode 100644 index b187fa7d2..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramExtender.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.jozufozu.flywheel.backend.core.shader; - -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; - -/** - * A factory interface for creating {@link IProgramExtension}s. These are what end up being passed in - * during shader program construction. - */ -public interface ProgramExtender { - - /** - * Construct the extension, binding any necessary information using the provided {@link GlProgram}. - * - * @param program The program being extended. - * @return An extension object, possibly initialized using the program. - */ - IProgramExtension create(GlProgram program); -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramSpec.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramSpec.java deleted file mode 100644 index 6474c008c..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ProgramSpec.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.jozufozu.flywheel.backend.core.shader; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.util.ResourceLocation; - -public class ProgramSpec { - - public final ResourceLocation name; - public final ResourceLocation vert; - public final ResourceLocation frag; - - public final List debugModes = new ArrayList<>(); - - public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag) { - this.name = name; - this.vert = vert; - this.frag = frag; - } - -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderCallback.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ShaderCallback.java similarity index 74% rename from src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderCallback.java rename to src/main/java/com/jozufozu/flywheel/backend/core/shader/ShaderCallback.java index cdf5cf2ff..2bf2f5440 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderCallback.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ShaderCallback.java @@ -1,4 +1,6 @@ -package com.jozufozu.flywheel.backend.gl.shader; +package com.jozufozu.flywheel.backend.core.shader; + +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; /** * A Callback for when a shader is called. Used to define shader uniforms. diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/SingleProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/SingleProgram.java deleted file mode 100644 index f4da285f3..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/SingleProgram.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jozufozu.flywheel.backend.core.shader; - -import com.jozufozu.flywheel.backend.ShaderContext; -import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; -import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; -import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; -import com.jozufozu.flywheel.backend.loading.Program; - -public class SingleProgram

implements IMultiProgram

{ - final P program; - - public SingleProgram(P program) { - this.program = program; - } - - @Override - public P get() { - return program; - } - - @Override - public void delete() { - program.delete(); - } - - public static class SpecLoader

implements ShaderSpecLoader

{ - final ProgramFactory

factory; - - public SpecLoader(ProgramFactory

factory) { - this.factory = factory; - } - - @Override - public IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { - return new SingleProgram<>(factory.create(ctx.loadProgram(loader, spec, null))); - } - } - - @FunctionalInterface - public interface ProgramFactory

{ - P create(Program program); - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/StateSensitiveMultiProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/StateSensitiveMultiProgram.java new file mode 100644 index 000000000..2dbce5473 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/StateSensitiveMultiProgram.java @@ -0,0 +1,54 @@ +package com.jozufozu.flywheel.backend.core.shader; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.jozufozu.flywheel.backend.ShaderContext; +import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.core.shader.spec.IContextCondition; +import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; +import com.jozufozu.flywheel.backend.core.shader.spec.ProgramState; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.jozufozu.flywheel.backend.loading.Program; +import com.jozufozu.flywheel.util.Pair; + +public class StateSensitiveMultiProgram

implements IMultiProgram

{ + + List> variants; + P fallback; + + public StateSensitiveMultiProgram(ShaderLoader loader, ExtensibleGlProgram.Factory

factory, ShaderContext

context, ProgramSpec p) { + variants = new ArrayList<>(p.states.size()); + + for (ProgramState state : p.states) { + + Program variant = context.loadProgram(loader, p, state.getDefines()); + + Pair pair = Pair.of(state.getContext(), factory.create(variant, state.getExtensions())); + + variants.add(pair); + } + + fallback = factory.create(context.loadProgram(loader, p, Collections.emptyList())); + } + + @Override + public P get() { + for (Pair variant : variants) { + if (variant.getFirst().get()) + return variant.getSecond(); + } + + return fallback; + } + + @Override + public void delete() { + for (Pair variant : variants) { + variant.getSecond().delete(); + } + + fallback.delete(); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldFog.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldFog.java new file mode 100644 index 000000000..1ae189611 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldFog.java @@ -0,0 +1,47 @@ +package com.jozufozu.flywheel.backend.core.shader; + +import java.util.function.Function; + +import com.jozufozu.flywheel.Flywheel; +import com.jozufozu.flywheel.backend.core.shader.extension.IExtensionInstance; +import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension; +import com.jozufozu.flywheel.backend.core.shader.extension.UnitExtensionInstance; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; + +import net.minecraft.util.ResourceLocation; + +public enum WorldFog implements IProgramExtension { + NONE("none", UnitExtensionInstance::new), + LINEAR("linear", FogMode.Linear::new), + EXP2("exp2", FogMode.Exp2::new), + ; + + private final ResourceLocation id; + private final String name; + private final Function fogFactory; + + WorldFog(String name, Function fogFactory) { + this.id = new ResourceLocation(Flywheel.ID, "fog_" + name); + this.name = name; + this.fogFactory = fogFactory; + } + + public String getName() { + return name; + } + + @Override + public IExtensionInstance create(GlProgram program) { + return fogFactory.apply(program); + } + + @Override + public ResourceLocation getID() { + return id; + } + + @Override + public String toString() { + return name; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldProgram.java index 749be410b..c83c4ba6f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/WorldProgram.java @@ -5,6 +5,7 @@ import static org.lwjgl.opengl.GL20.glUniform3f; import java.util.List; +import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension; import com.jozufozu.flywheel.backend.loading.Program; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -18,8 +19,8 @@ public class WorldProgram extends ExtensibleGlProgram { protected int uBlockAtlas; protected int uLightMap; - public WorldProgram(Program program, List fogFactory) { - super(program, fogFactory); + public WorldProgram(Program program, List extensions) { + super(program, extensions); uTime = getUniformLocation("uTime"); uViewProjection = getUniformLocation("uViewProjection"); uCameraPos = getUniformLocation("uCameraPos"); diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/IExtensionInstance.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/IExtensionInstance.java new file mode 100644 index 000000000..586121bce --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/IExtensionInstance.java @@ -0,0 +1,14 @@ +package com.jozufozu.flywheel.backend.core.shader.extension; + +import net.minecraft.util.ResourceLocation; + +public interface IExtensionInstance { + + /** + * Bind the extra program state. It is recommended to grab the state information from global variables, + * or local variables passed through a {@link IProgramExtension}. + */ + void bind(); + + ResourceLocation name(); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/IProgramExtension.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/IProgramExtension.java new file mode 100644 index 000000000..f0ad388b7 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/IProgramExtension.java @@ -0,0 +1,26 @@ +package com.jozufozu.flywheel.backend.core.shader.extension; + +import com.jozufozu.flywheel.backend.core.shader.spec.SpecMetaRegistry; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; +import com.mojang.serialization.Codec; + +import net.minecraft.util.ResourceLocation; + +/** + * A factory interface for creating {@link IExtensionInstance}s. These are what end up being passed in + * during shader program construction. + */ +public interface IProgramExtension { + + Codec CODEC = ResourceLocation.CODEC.xmap(SpecMetaRegistry::getExtension, IProgramExtension::getID); + + /** + * Construct the extension, binding any necessary information using the provided {@link GlProgram}. + * + * @param program The program being extended. + * @return An extension object, possibly initialized using the program. + */ + IExtensionInstance create(GlProgram program); + + ResourceLocation getID(); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/UnitExtensionInstance.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/UnitExtensionInstance.java new file mode 100644 index 000000000..a66e1a30d --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/extension/UnitExtensionInstance.java @@ -0,0 +1,23 @@ +package com.jozufozu.flywheel.backend.core.shader.extension; + +import com.jozufozu.flywheel.Flywheel; +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; + +import net.minecraft.util.ResourceLocation; + +public class UnitExtensionInstance implements IExtensionInstance { + + public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "unit"); + + public UnitExtensionInstance(GlProgram program) { } + + @Override + public void bind() { + + } + + @Override + public ResourceLocation name() { + return NAME; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/FogStateProvider.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/FogStateProvider.java new file mode 100644 index 000000000..6abddede4 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/FogStateProvider.java @@ -0,0 +1,22 @@ +package com.jozufozu.flywheel.backend.core.shader.gamestate; + +import com.jozufozu.flywheel.Flywheel; +import com.jozufozu.flywheel.backend.core.shader.GlFog; + +import net.minecraft.util.ResourceLocation; + +public class FogStateProvider implements IGameStateProvider { + + public static final FogStateProvider INSTANCE = new FogStateProvider(); + public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_mode"); + + @Override + public ResourceLocation getID() { + return NAME; + } + + @Override + public Object getValue() { + return GlFog.getFogMode(); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/IGameStateProvider.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/IGameStateProvider.java new file mode 100644 index 000000000..82fe2653c --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/IGameStateProvider.java @@ -0,0 +1,15 @@ +package com.jozufozu.flywheel.backend.core.shader.gamestate; + +import com.jozufozu.flywheel.backend.core.shader.spec.SpecMetaRegistry; +import com.mojang.serialization.Codec; + +import net.minecraft.util.ResourceLocation; + +public interface IGameStateProvider { + + Codec CODEC = ResourceLocation.CODEC.xmap(SpecMetaRegistry::getStateProvider, IGameStateProvider::getID); + + ResourceLocation getID(); + + Object getValue(); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/NormalDebugStateProvider.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/NormalDebugStateProvider.java new file mode 100644 index 000000000..b87943e22 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/NormalDebugStateProvider.java @@ -0,0 +1,26 @@ +package com.jozufozu.flywheel.backend.core.shader.gamestate; + +import com.jozufozu.flywheel.Flywheel; +import com.jozufozu.flywheel.backend.core.shader.spec.IBooleanStateProvider; + +import net.minecraft.util.ResourceLocation; + +public class NormalDebugStateProvider implements IBooleanStateProvider { + + public static final NormalDebugStateProvider INSTANCE = new NormalDebugStateProvider(); + public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "normal_debug"); + + protected NormalDebugStateProvider() { + + } + + @Override + public boolean isTrue() { + return false; + } + + @Override + public ResourceLocation getID() { + return NAME; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/RainbowDebugStateProvider.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/RainbowDebugStateProvider.java new file mode 100644 index 000000000..a49cf28e8 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/gamestate/RainbowDebugStateProvider.java @@ -0,0 +1,27 @@ +package com.jozufozu.flywheel.backend.core.shader.gamestate; + +import com.jozufozu.flywheel.backend.core.shader.spec.IBooleanStateProvider; +import com.simibubi.create.Create; +import com.simibubi.create.content.contraptions.KineticDebugger; + +import net.minecraft.util.ResourceLocation; + +public class RainbowDebugStateProvider implements IBooleanStateProvider { + + public static final RainbowDebugStateProvider INSTANCE = new RainbowDebugStateProvider(); + public static final ResourceLocation NAME = new ResourceLocation(Create.ID, "rainbow_debug"); + + protected RainbowDebugStateProvider() { + + } + + @Override + public boolean isTrue() { + return KineticDebugger.isActive(); + } + + @Override + public ResourceLocation getID() { + return NAME; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/BooleanContextCondition.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/BooleanContextCondition.java new file mode 100644 index 000000000..ae3dc164c --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/BooleanContextCondition.java @@ -0,0 +1,37 @@ +package com.jozufozu.flywheel.backend.core.shader.spec; + +import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider; +import com.mojang.serialization.Codec; + +import net.minecraft.util.ResourceLocation; + +public class BooleanContextCondition implements IContextCondition { + + public static final Codec BOOLEAN_SUGAR = IGameStateProvider.CODEC.xmap(gameContext -> { + if (gameContext instanceof IBooleanStateProvider) { + return new BooleanContextCondition(((IBooleanStateProvider) gameContext)); + } + + return null; + }, IContextCondition::contextProvider); + protected final IBooleanStateProvider context; + + public BooleanContextCondition(IBooleanStateProvider context) { + this.context = context; + } + + @Override + public ResourceLocation getID() { + return context.getID(); + } + + @Override + public IGameStateProvider contextProvider() { + return context; + } + + @Override + public boolean get() { + return context.isTrue(); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/IBooleanStateProvider.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/IBooleanStateProvider.java new file mode 100644 index 000000000..3265c11a0 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/IBooleanStateProvider.java @@ -0,0 +1,13 @@ +package com.jozufozu.flywheel.backend.core.shader.spec; + +import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider; + +public interface IBooleanStateProvider extends IGameStateProvider { + + boolean isTrue(); + + @Override + default Boolean getValue() { + return isTrue(); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/IContextCondition.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/IContextCondition.java new file mode 100644 index 000000000..b9499da84 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/IContextCondition.java @@ -0,0 +1,14 @@ +package com.jozufozu.flywheel.backend.core.shader.spec; + +import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider; + +import net.minecraft.util.ResourceLocation; + +public interface IContextCondition { + + ResourceLocation getID(); + + IGameStateProvider contextProvider(); + + boolean get(); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/ProgramSpec.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/ProgramSpec.java new file mode 100644 index 000000000..05c76888f --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/ProgramSpec.java @@ -0,0 +1,61 @@ +package com.jozufozu.flywheel.backend.core.shader.spec; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; + +import net.minecraft.util.ResourceLocation; + +public class ProgramSpec { + + // TODO: Block model style inheritance? + public static final Codec CODEC = RecordCodecBuilder.create(instance -> + instance.group( + ResourceLocation.CODEC.fieldOf("vert") + .forGetter(ProgramSpec::getVert), + ResourceLocation.CODEC.fieldOf("frag") + .forGetter(ProgramSpec::getFrag), + ProgramState.CODEC.listOf() + .optionalFieldOf("states", Collections.emptyList()) + .forGetter(ProgramSpec::getStates) + ).apply(instance, ProgramSpec::new)); + + public ResourceLocation name; + public final ResourceLocation vert; + public final ResourceLocation frag; + + public final List states; + + public ProgramSpec(ResourceLocation vert, ResourceLocation frag, List states) { + this.vert = vert; + this.frag = frag; + this.states = states; + } + + public ProgramSpec(ResourceLocation name, ResourceLocation vert, ResourceLocation frag) { + this.name = name; + this.vert = vert; + this.frag = frag; + this.states = new ArrayList<>(); + } + + public void setName(ResourceLocation name) { + this.name = name; + } + + public ResourceLocation getVert() { + return vert; + } + + public ResourceLocation getFrag() { + return frag; + } + + public List getStates() { + return states; + } + +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/ProgramState.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/ProgramState.java new file mode 100644 index 000000000..4a39e8b7f --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/ProgramState.java @@ -0,0 +1,67 @@ +package com.jozufozu.flywheel.backend.core.shader.spec; + +import java.util.Collections; +import java.util.List; + +import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension; +import com.jozufozu.flywheel.util.CodecUtil; +import com.mojang.datafixers.util.Either; +import com.mojang.serialization.Codec; +import com.mojang.serialization.DataResult; +import com.mojang.serialization.codecs.RecordCodecBuilder; + +public class ProgramState { + + // TODO: Use Codec.dispatch + private static final Codec WHEN = Codec.either( + BooleanContextCondition.BOOLEAN_SUGAR, + SpecificValueCondition.CODEC + ).flatXmap( + either -> either.map(DataResult::success, DataResult::success), + any -> { + if (any instanceof BooleanContextCondition) { + return DataResult.success(Either.left((BooleanContextCondition) any)); + } + + if (any instanceof SpecificValueCondition) { + return DataResult.success(Either.right((SpecificValueCondition) any)); + } + + return DataResult.error("unknown context condition"); + } + ); + + public static final Codec CODEC = RecordCodecBuilder.create(state -> + state.group( + WHEN.fieldOf("when") + .forGetter(ProgramState::getContext), + CodecUtil.oneOrMore(Codec.STRING) + .optionalFieldOf("define", Collections.emptyList()) + .forGetter(ProgramState::getDefines), + CodecUtil.oneOrMore(IProgramExtension.CODEC) + .optionalFieldOf("extend", Collections.emptyList()) + .forGetter(ProgramState::getExtensions) + ).apply(state, ProgramState::new)); + + private final IContextCondition context; + private final List defines; + private final List extensions; + + public ProgramState(IContextCondition context, List defines, List extensions) { + this.context = context; + this.defines = defines; + this.extensions = extensions; + } + + public IContextCondition getContext() { + return context; + } + + public List getDefines() { + return defines; + } + + public List getExtensions() { + return extensions; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/SpecMetaRegistry.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/SpecMetaRegistry.java new file mode 100644 index 000000000..9f26fe448 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/SpecMetaRegistry.java @@ -0,0 +1,69 @@ +package com.jozufozu.flywheel.backend.core.shader.spec; + +import java.util.HashMap; +import java.util.Map; + +import com.jozufozu.flywheel.backend.core.shader.WorldFog; +import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension; +import com.jozufozu.flywheel.backend.core.shader.gamestate.FogStateProvider; +import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider; +import com.jozufozu.flywheel.backend.core.shader.gamestate.NormalDebugStateProvider; +import com.jozufozu.flywheel.backend.core.shader.gamestate.RainbowDebugStateProvider; + +import net.minecraft.util.ResourceLocation; + +public class SpecMetaRegistry { + + private static final Map registeredExtensions = new HashMap<>(); + private static final Map registeredStateProviders = new HashMap<>(); + + // TODO: proper registration, don't call this from ShaderLoader + private static boolean initialized = false; + public static void init() { + if (initialized) return; + initialized = true; + + register(FogStateProvider.INSTANCE); + register(RainbowDebugStateProvider.INSTANCE); + register(NormalDebugStateProvider.INSTANCE); + + register(WorldFog.LINEAR); + register(WorldFog.EXP2); + } + + public static IGameStateProvider getStateProvider(ResourceLocation location) { + IGameStateProvider out = registeredStateProviders.get(location); + + if (out == null) { + throw new IllegalArgumentException("State provider '" + location + "' does not exist."); + } + + return out; + } + + public static IProgramExtension getExtension(ResourceLocation location) { + IProgramExtension out = registeredExtensions.get(location); + + if (out == null) { + throw new IllegalArgumentException("Extension '" + location + "' does not exist."); + } + + return out; + } + + public static void register(IGameStateProvider context) { + if (registeredStateProviders.containsKey(context.getID())) { + throw new IllegalStateException("Duplicate game state provider: " + context.getID()); + } + + registeredStateProviders.put(context.getID(), context); + } + + public static void register(IProgramExtension extender) { + if (registeredStateProviders.containsKey(extender.getID())) { + throw new IllegalStateException("Duplicate shader extension: " + extender.getID()); + } + + registeredExtensions.put(extender.getID(), extender); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/SpecificValueCondition.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/SpecificValueCondition.java new file mode 100644 index 000000000..8b05e3588 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/spec/SpecificValueCondition.java @@ -0,0 +1,42 @@ +package com.jozufozu.flywheel.backend.core.shader.spec; + +import com.jozufozu.flywheel.backend.core.shader.gamestate.IGameStateProvider; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; + +import net.minecraft.util.ResourceLocation; + +public class SpecificValueCondition implements IContextCondition { + + public static final Codec CODEC = RecordCodecBuilder.create(condition -> condition.group( + IGameStateProvider.CODEC.fieldOf("provider").forGetter(SpecificValueCondition::contextProvider), + Codec.STRING.fieldOf("value").forGetter(SpecificValueCondition::getValue) + ).apply(condition, SpecificValueCondition::new)); + + private final String required; + private final IGameStateProvider context; + + public SpecificValueCondition(IGameStateProvider context, String required) { + this.required = required; + this.context = context; + } + + @Override + public ResourceLocation getID() { + return context.getID(); + } + + public String getValue() { + return required; + } + + @Override + public IGameStateProvider contextProvider() { + return context; + } + + @Override + public boolean get() { + return required.equals(context.getValue().toString()); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GLSLType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GLSLType.java deleted file mode 100644 index 0ef93042d..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/GLSLType.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jozufozu.flywheel.backend.gl.shader; - -import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; - -public class GLSLType { - public static final GLSLType FLOAT = new GLSLType("mat4", GlPrimitiveType.FLOAT, 16); - public static final GLSLType VEC2 = new GLSLType("vec4", GlPrimitiveType.FLOAT, 4); - public static final GLSLType VEC3 = new GLSLType("vec3", GlPrimitiveType.FLOAT, 3); - public static final GLSLType VEC4 = new GLSLType("vec2", GlPrimitiveType.FLOAT, 2); - public static final GLSLType MAT4 = new GLSLType("float", GlPrimitiveType.FLOAT, 1); - - private final String symbol; - private final GlPrimitiveType base; - private final int count; - private final int size; - private final int attributeCount; - - public GLSLType(String symbol, GlPrimitiveType base, int count) { - this.symbol = symbol; - this.base = base; - this.count = count; - this.size = base.getSize() * count; - this.attributeCount = (this.size + 15) / 16; // ceiling division. GLSL vertex attributes can only be 16 bytes wide - } - - public String getSymbol() { - return symbol; - } - - public GlPrimitiveType getBase() { - return base; - } - - public int getCount() { - return count; - } - - public int getSize() { - return size; - } - - public int getAttributeCount() { - return attributeCount; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java deleted file mode 100644 index 51ed1d8c1..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.jozufozu.flywheel.backend.gl.shader; - -import com.jozufozu.flywheel.backend.ShaderContext; -import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; - -public interface ShaderSpecLoader

{ - - IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec); -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java index 69f81f7a1..8d7c2fe11 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java @@ -11,8 +11,8 @@ import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.core.materials.OrientedData; +import com.jozufozu.flywheel.backend.core.shader.ShaderCallback; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; -import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.simibubi.create.foundation.render.AllMaterialSpecs; import net.minecraft.client.Minecraft; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java index fc30978b2..7ff1dbcd4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/MaterialSpec.java @@ -1,6 +1,5 @@ package com.jozufozu.flywheel.backend.instancing; -import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import net.minecraft.util.ResourceLocation; @@ -9,12 +8,12 @@ public class MaterialSpec { public final ResourceLocation name; - private final ProgramSpec programSpec; + private final ResourceLocation programSpec; private final VertexFormat modelFormat; private final VertexFormat instanceFormat; private final InstanceFactory instanceFactory; - public MaterialSpec(ResourceLocation name, ProgramSpec programSpec, VertexFormat modelFormat, VertexFormat instanceFormat, InstanceFactory instanceFactory) { + public MaterialSpec(ResourceLocation name, ResourceLocation programSpec, VertexFormat modelFormat, VertexFormat instanceFormat, InstanceFactory instanceFactory) { this.name = name; this.programSpec = programSpec; this.modelFormat = modelFormat; @@ -22,7 +21,7 @@ public class MaterialSpec { this.instanceFactory = instanceFactory; } - public ProgramSpec getProgramSpec() { + public ResourceLocation getProgramSpec() { return programSpec; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index 209516f56..25c85b84b 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -13,9 +13,9 @@ import org.lwjgl.opengl.GL11; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.jozufozu.flywheel.backend.core.PartialModel; +import com.jozufozu.flywheel.backend.core.shader.ShaderCallback; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback; import com.jozufozu.flywheel.util.BufferBuilderReader; import com.jozufozu.flywheel.util.RenderUtil; import com.jozufozu.flywheel.util.VirtualEmptyModelData; diff --git a/src/main/java/com/jozufozu/flywheel/util/CodecUtil.java b/src/main/java/com/jozufozu/flywheel/util/CodecUtil.java new file mode 100644 index 000000000..3b83fac86 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/util/CodecUtil.java @@ -0,0 +1,26 @@ +package com.jozufozu.flywheel.util; + +import java.util.Collections; +import java.util.List; + +import com.mojang.datafixers.util.Either; +import com.mojang.serialization.Codec; + +public class CodecUtil { + + /** + * Creates a list codec that can be parsed from either a single element or a complete list. + */ + public static Codec> oneOrMore(Codec codec) { + return Codec.either(codec.listOf(), codec) + .xmap( + either -> either.map(l -> l, Collections::singletonList), + list -> { + if (list.size() == 1) { + return Either.right(list.get(0)); + } else { + return Either.left(list); + } + }); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/util/Pair.java b/src/main/java/com/jozufozu/flywheel/util/Pair.java new file mode 100644 index 000000000..b1e232037 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/util/Pair.java @@ -0,0 +1,68 @@ +package com.jozufozu.flywheel.util; + +import java.util.Objects; + +public class Pair { + + F first; + S second; + + protected Pair(F first, S second) { + this.first = first; + this.second = second; + } + + public static Pair of(F first, S second) { + return new Pair<>(first, second); + } + + public F getFirst() { + return first; + } + + public S getSecond() { + return second; + } + + public void setFirst(F first) { + this.first = first; + } + + public void setSecond(S second) { + this.second = second; + } + + public Pair copy() { + return Pair.of(first, second); + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) + return true; + if (obj instanceof Pair) { + final Pair other = (Pair) obj; + return Objects.equals(first, other.first) && Objects.equals(second, other.second); + } + return false; + } + + @Override + public int hashCode() { + return (nullHash(first) * 31) ^ nullHash(second); + } + + int nullHash(Object o) { + return o == null ? 0 : o.hashCode(); + } + + @Override + public String toString() { + return "(" + first + ", " + second + ")"; + } + + public Pair swap() { + return Pair.of(second, first); + } + +} diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index d9ccf1f64..05401f07f 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -27,7 +27,6 @@ import com.simibubi.create.foundation.item.CustomRenderedItems; import com.simibubi.create.foundation.ponder.content.PonderIndex; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.render.AllMaterialSpecs; -import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.render.CreateFlywheelHandler; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.utility.ghost.GhostBlocks; @@ -87,7 +86,6 @@ public class CreateClient { } public static void clientInit(FMLClientSetupEvent event) { - AllProgramSpecs.init(); AllMaterialSpecs.init(); schematicSender = new ClientSchematicLoader(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java index 203b5c0fa..a343ee9b8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionProgram.java @@ -4,8 +4,8 @@ import java.util.List; import org.lwjgl.opengl.GL20; -import com.jozufozu.flywheel.backend.core.shader.ProgramExtender; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; +import com.jozufozu.flywheel.backend.core.shader.extension.IProgramExtension; import com.jozufozu.flywheel.backend.loading.Program; import net.minecraft.util.math.AxisAlignedBB; @@ -18,8 +18,8 @@ public class ContraptionProgram extends WorldProgram { protected int uLightVolume; - public ContraptionProgram(Program program, List fogFactory) { - super(program, fogFactory); + public ContraptionProgram(Program program, List extensions) { + super(program, extensions); uLightBoxSize = getUniformLocation("uLightBoxSize"); uLightBoxMin = getUniformLocation("uLightBoxMin"); uModel = getUniformLocation("uModel"); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 5eb5331f7..5d537347d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -15,7 +15,6 @@ import java.util.stream.Stream; import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.core.FogMultiProgram; import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.loading.ModelTemplate; import com.mojang.blaze3d.matrix.MatrixStack; @@ -71,8 +70,10 @@ public class ContraptionRenderDispatcher { public static final Compartment> CONTRAPTION = new Compartment<>(); private static final ResourceLocation ctxRoot = new ResourceLocation("create", "context/contraption"); - public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new FogMultiProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); - public static final WorldContext TILES = new WorldContext<>(ctxRoot, new FogMultiProgram.SpecLoader<>(ContraptionProgram::new)); + public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, ContraptionProgram::new) + .setSpecStream(() -> Stream.of(AllProgramSpecs.STRUCTURE)) + .setTemplateFactory(ModelTemplate::new); + public static final WorldContext TILES = new WorldContext<>(ctxRoot, ContraptionProgram::new); public static void tick() { if (Minecraft.getInstance().isGamePaused()) return; diff --git a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java index 4a9d1a3da..ce9d21249 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java @@ -24,10 +24,10 @@ public class AllMaterialSpecs { .addAttributes(CommonAttributes.VEC3, CommonAttributes.NORMAL, CommonAttributes.UV) .build(); + public static final MaterialSpec ROTATING = register(new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, UNLIT_MODEL, AllInstanceFormats.ROTATING, RotatingData::new)); public static final MaterialSpec TRANSFORMED = register(new MaterialSpec<>(Locations.MODEL, AllProgramSpecs.MODEL, UNLIT_MODEL, AllInstanceFormats.MODEL, ModelData::new)); public static final MaterialSpec ORIENTED = register(new MaterialSpec<>(Locations.ORIENTED, AllProgramSpecs.ORIENTED, UNLIT_MODEL, AllInstanceFormats.ORIENTED, OrientedData::new)); - public static final MaterialSpec ROTATING = register(new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, UNLIT_MODEL, AllInstanceFormats.ROTATING, RotatingData::new)); public static final MaterialSpec BELTS = register(new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, UNLIT_MODEL, AllInstanceFormats.BELT, BeltData::new)); public static final MaterialSpec ACTORS = register(new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, UNLIT_MODEL, AllInstanceFormats.ACTOR, ActorData::new)); public static final MaterialSpec FLAPS = register(new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, UNLIT_MODEL, AllInstanceFormats.FLAP, FlapData::new)); diff --git a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java index c6d50eebd..94acc2e71 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllProgramSpecs.java @@ -1,42 +1,21 @@ package com.simibubi.create.foundation.render; -import static com.jozufozu.flywheel.backend.Backend.register; - import com.jozufozu.flywheel.Flywheel; -import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; import com.simibubi.create.Create; import net.minecraft.util.ResourceLocation; public class AllProgramSpecs { - public static void init() { - // noop, make sure the static field are loaded. - } - public static final ProgramSpec CHROMATIC = register(new ProgramSpec(loc("chromatic"), Locations.EFFECT_VERT, Locations.EFFECT_FRAG)); - public static final ProgramSpec MODEL = register(new ProgramSpec(new ResourceLocation(Flywheel.ID, "model"), Locations.MODEL_VERT, Locations.BLOCK)); - public static final ProgramSpec ORIENTED = register(new ProgramSpec(new ResourceLocation(Flywheel.ID, "oriented"), Locations.ORIENTED, Locations.BLOCK)); - public static final ProgramSpec ROTATING = register(new ProgramSpec(loc("rotating"), Locations.ROTATING, Locations.BLOCK)); - public static final ProgramSpec BELT = register(new ProgramSpec(loc("belt"), Locations.BELT, Locations.BLOCK)); - public static final ProgramSpec FLAPS = register(new ProgramSpec(loc("flap"), Locations.FLAP, Locations.BLOCK)); - public static final ProgramSpec STRUCTURE = register(new ProgramSpec(loc("contraption_structure"), Locations.CONTRAPTION_STRUCTURE, Locations.BLOCK)); - public static final ProgramSpec ACTOR = register(new ProgramSpec(loc("contraption_actor"), Locations.CONTRAPTION_ACTOR, Locations.BLOCK)); + public static final ResourceLocation MODEL = new ResourceLocation(Flywheel.ID, "model");//, Locations.MODEL_VERT, Locations.BLOCK); + public static final ResourceLocation ORIENTED = new ResourceLocation(Flywheel.ID, "oriented");//, Locations.ORIENTED, Locations.BLOCK); - public static class Locations { - public static final ResourceLocation BLOCK = new ResourceLocation(Flywheel.ID, "block.frag"); - - public static final ResourceLocation MODEL_VERT = new ResourceLocation(Flywheel.ID, "model.vert"); - public static final ResourceLocation ORIENTED = new ResourceLocation(Flywheel.ID, "oriented.vert"); - - public static final ResourceLocation ROTATING = loc("rotating.vert"); - public static final ResourceLocation BELT = loc("belt.vert"); - public static final ResourceLocation FLAP = loc("flap.vert"); - public static final ResourceLocation CONTRAPTION_STRUCTURE = loc("contraption_structure.vert"); - public static final ResourceLocation CONTRAPTION_ACTOR = loc("contraption_actor.vert"); - - public static final ResourceLocation EFFECT_VERT = loc("area_effect.vert"); - public static final ResourceLocation EFFECT_FRAG = loc("area_effect.frag"); - } + public static final ResourceLocation ROTATING = loc("rotating"); + public static final ResourceLocation CHROMATIC = loc("chromatic"); + public static final ResourceLocation BELT = loc("belt"); + public static final ResourceLocation FLAPS = loc("flap"); + public static final ResourceLocation STRUCTURE = loc("contraption_structure"); + public static final ResourceLocation ACTOR = loc("contraption_actor"); private static ResourceLocation loc(String name) { return new ResourceLocation(Create.ID, name); diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java index 0f13aa9e8..d0510522f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsContext.java @@ -1,8 +1,12 @@ package com.simibubi.create.foundation.render.effects; +import java.util.Collections; + +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; -import com.jozufozu.flywheel.backend.core.shader.SingleProgram; +import com.jozufozu.flywheel.backend.core.shader.IMultiProgram; +import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.backend.loading.ShaderTransformer; import com.simibubi.create.foundation.render.AllProgramSpecs; @@ -11,13 +15,18 @@ public class EffectsContext extends ShaderContext { public static final EffectsContext INSTANCE = new EffectsContext(); public EffectsContext() { - super(new SingleProgram.SpecLoader<>(SphereFilterProgram::new)); + super(); + } + + @Override + protected IMultiProgram loadSpecInternal(ShaderLoader loader, ProgramSpec spec) { + return new SphereFilterProgram(loadProgram(loader, spec, Collections.emptyList())); } @Override public void load(ShaderLoader loader) { transformer = new ShaderTransformer() .pushStage(loader::processIncludes); - loadProgramFromSpec(loader, AllProgramSpecs.CHROMATIC); + loadProgramFromSpec(loader, Backend.getSpec(AllProgramSpecs.CHROMATIC)); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java index 80c4b5b67..b11f9c5d4 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/SphereFilterProgram.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL31; +import com.jozufozu.flywheel.backend.core.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; @@ -14,7 +15,7 @@ import com.jozufozu.flywheel.backend.loading.Program; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Vector3d; -public class SphereFilterProgram extends GlProgram { +public class SphereFilterProgram extends GlProgram implements IMultiProgram { protected static final int UBO_BINDING = 4; @@ -80,7 +81,7 @@ public class SphereFilterProgram extends GlProgram { } public void uploadFilters(ArrayList filters) { - effectsUBO.bind(GlBufferType.ARRAY_BUFFER); + effectsUBO.bind(); MappedBuffer buffer = effectsUBO.getBuffer(0, BUFFER_SIZE) .putInt(filters.size()) .position(16); @@ -89,7 +90,7 @@ public class SphereFilterProgram extends GlProgram { buffer.flush(); - effectsUBO.unbind(GlBufferType.ARRAY_BUFFER); + effectsUBO.unbind(); } public void bindInverseProjection(Matrix4f mat) { @@ -110,4 +111,8 @@ public class SphereFilterProgram extends GlProgram { GL20.glBindTexture(GL20.GL_TEXTURE_2D, textureObject); } + @Override + public SphereFilterProgram get() { + return this; + } } diff --git a/src/main/resources/assets/create/flywheel/programs/belt.json b/src/main/resources/assets/create/flywheel/programs/belt.json new file mode 100644 index 000000000..e6b53432e --- /dev/null +++ b/src/main/resources/assets/create/flywheel/programs/belt.json @@ -0,0 +1,33 @@ +{ + "vert": "create:belt.vert", + "frag": "flywheel:block.frag", + "states": [ + { + "when": "create:rainbow_debug", + "define": "DEBUG_RAINBOW" + }, + { + "when": { + "provider": "flywheel:normal_debug", + "value": "true" + }, + "define": "DEBUG_NORMAL" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "linear" + }, + "define": ["USE_FOG", "USE_FOG_LINEAR"], + "extend": "flywheel:fog_linear" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "exp2" + }, + "define": ["USE_FOG", "USE_FOG_EXP2"], + "extend": "flywheel:fog_exp2" + } + ] +} diff --git a/src/main/resources/assets/create/flywheel/programs/chromatic.json b/src/main/resources/assets/create/flywheel/programs/chromatic.json new file mode 100644 index 000000000..f521eefa6 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/programs/chromatic.json @@ -0,0 +1,4 @@ +{ + "vert": "create:area_effect.vert", + "frag": "create:area_effect.frag" +} diff --git a/src/main/resources/assets/create/flywheel/programs/contraption_actor.json b/src/main/resources/assets/create/flywheel/programs/contraption_actor.json new file mode 100644 index 000000000..e9acf9d1e --- /dev/null +++ b/src/main/resources/assets/create/flywheel/programs/contraption_actor.json @@ -0,0 +1,29 @@ +{ + "vert": "create:contraption_actor.vert", + "frag": "flywheel:block.frag", + "states": [ + { + "when": { + "provider": "flywheel:normal_debug", + "value": "true" + }, + "define": "DEBUG_NORMAL" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "linear" + }, + "define": ["USE_FOG", "USE_FOG_LINEAR"], + "extend": "flywheel:fog_linear" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "exp2" + }, + "define": ["USE_FOG", "USE_FOG_EXP2"], + "extend": "flywheel:fog_exp2" + } + ] +} diff --git a/src/main/resources/assets/create/flywheel/programs/contraption_structure.json b/src/main/resources/assets/create/flywheel/programs/contraption_structure.json new file mode 100644 index 000000000..9440ca25a --- /dev/null +++ b/src/main/resources/assets/create/flywheel/programs/contraption_structure.json @@ -0,0 +1,29 @@ +{ + "vert": "create:contraption_structure.vert", + "frag": "flywheel:block.frag", + "states": [ + { + "when": { + "provider": "flywheel:normal_debug", + "value": "true" + }, + "define": "DEBUG_NORMAL" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "linear" + }, + "define": ["USE_FOG", "USE_FOG_LINEAR"], + "extend": "flywheel:fog_linear" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "exp2" + }, + "define": ["USE_FOG", "USE_FOG_EXP2"], + "extend": "flywheel:fog_exp2" + } + ] +} diff --git a/src/main/resources/assets/create/flywheel/programs/flap.json b/src/main/resources/assets/create/flywheel/programs/flap.json new file mode 100644 index 000000000..f7de4c45e --- /dev/null +++ b/src/main/resources/assets/create/flywheel/programs/flap.json @@ -0,0 +1,29 @@ +{ + "vert": "create:flap.vert", + "frag": "flywheel:block.frag", + "states": [ + { + "when": { + "provider": "flywheel:normal_debug", + "value": "true" + }, + "define": "DEBUG_NORMAL" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "linear" + }, + "define": ["USE_FOG", "USE_FOG_LINEAR"], + "extend": "flywheel:fog_linear" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "exp2" + }, + "define": ["USE_FOG", "USE_FOG_EXP2"], + "extend": "flywheel:fog_exp2" + } + ] +} diff --git a/src/main/resources/assets/create/flywheel/programs/rotating.json b/src/main/resources/assets/create/flywheel/programs/rotating.json new file mode 100644 index 000000000..58d80d445 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/programs/rotating.json @@ -0,0 +1,33 @@ +{ + "vert": "create:rotating.vert", + "frag": "flywheel:block.frag", + "states": [ + { + "when": "create:rainbow_debug", + "define": "DEBUG_RAINBOW" + }, + { + "when": { + "provider": "flywheel:normal_debug", + "value": "true" + }, + "define": "DEBUG_NORMAL" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "linear" + }, + "define": ["USE_FOG", "USE_FOG_LINEAR"], + "extend": "flywheel:fog_linear" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "exp2" + }, + "define": ["USE_FOG", "USE_FOG_EXP2"], + "extend": "flywheel:fog_exp2" + } + ] +} diff --git a/src/main/resources/assets/create/flywheel/shaders/belt.vert b/src/main/resources/assets/create/flywheel/shaders/belt.vert index ce8ec2d5e..be5d51a43 100644 --- a/src/main/resources/assets/create/flywheel/shaders/belt.vert +++ b/src/main/resources/assets/create/flywheel/shaders/belt.vert @@ -39,9 +39,9 @@ BlockFrag FLWMain(Vertex v, Belt instance) { b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll); b.light = instance.light; - #if defined(RAINBOW_DEBUG) + #if defined(DEBUG_RAINBOW) b.color = instance.color; - #elif defined(NORMAL_DEBUG) + #elif defined(DEBUG_NORMAL) b.color = vec4(norm, 1.); #else b.color = vec4(1.); diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert index b075730b9..25ff4980a 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert @@ -37,7 +37,7 @@ BlockFrag FLWMain(Vertex v, Actor instance) { b.texCoords = v.texCoords; b.light = instance.light; - #if defined(NORMAL_DEBUG) + #if defined(DEBUG_NORMAL) b.color = vec4(norm, 1.); #else b.color = vec4(1.); diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert index fb3e66070..a42245c1d 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert @@ -27,7 +27,7 @@ BlockFrag FLWMain(Vertex v) { b.texCoords = v.texCoords; b.light = v.modelLight; - #if defined(NORMAL_DEBUG) + #if defined(DEBUG_NORMAL) b.color = vec4(norm, 1.); #else b.color = v.color / diffuse(v.normal); diff --git a/src/main/resources/assets/create/flywheel/shaders/flap.vert b/src/main/resources/assets/create/flywheel/shaders/flap.vert index 047455554..ef39637df 100644 --- a/src/main/resources/assets/create/flywheel/shaders/flap.vert +++ b/src/main/resources/assets/create/flywheel/shaders/flap.vert @@ -57,7 +57,7 @@ BlockFrag FLWMain(Vertex v, Flap flap) { b.diffuse = diffuse(norm); b.texCoords = v.texCoords; b.light = flap.light; - #if defined(NORMAL_DEBUG) + #if defined(DEBUG_NORMAL) b.color = vec4(norm, 1.); #else b.color = vec4(1.); diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/shaders/rotating.vert index f5fe07bde..5acfdbd3f 100644 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ b/src/main/resources/assets/create/flywheel/shaders/rotating.vert @@ -40,9 +40,9 @@ BlockFrag FLWMain(Vertex v, Rotating instance) { b.texCoords = v.texCoords; b.light = instance.light; - #if defined(RAINBOW_DEBUG) + #if defined(DEBUG_RAINBOW) b.color = instance.color; - #elif defined(NORMAL_DEBUG) + #elif defined(DEBUG_NORMAL) b.color = vec4(norm, 1.); #else b.color = vec4(1.); diff --git a/src/main/resources/assets/flywheel/flywheel/programs/model.json b/src/main/resources/assets/flywheel/flywheel/programs/model.json new file mode 100644 index 000000000..b30bb0fe2 --- /dev/null +++ b/src/main/resources/assets/flywheel/flywheel/programs/model.json @@ -0,0 +1,29 @@ +{ + "vert": "flywheel:model.vert", + "frag": "flywheel:block.frag", + "states": [ + { + "when": { + "provider": "flywheel:normal_debug", + "value": "true" + }, + "define": "DEBUG_NORMAL" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "linear" + }, + "define": ["USE_FOG", "USE_FOG_LINEAR"], + "extend": "flywheel:fog_linear" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "exp2" + }, + "define": ["USE_FOG", "USE_FOG_EXP2"], + "extend": "flywheel:fog_exp2" + } + ] +} diff --git a/src/main/resources/assets/flywheel/flywheel/programs/oriented.json b/src/main/resources/assets/flywheel/flywheel/programs/oriented.json new file mode 100644 index 000000000..0340b5602 --- /dev/null +++ b/src/main/resources/assets/flywheel/flywheel/programs/oriented.json @@ -0,0 +1,29 @@ +{ + "vert": "flywheel:oriented.vert", + "frag": "flywheel:block.frag", + "states": [ + { + "when": { + "provider": "flywheel:normal_debug", + "value": "true" + }, + "define": "DEBUG_NORMAL" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "linear" + }, + "define": ["USE_FOG", "USE_FOG_LINEAR"], + "extend": "flywheel:fog_linear" + }, + { + "when": { + "provider": "flywheel:fog_mode", + "value": "exp2" + }, + "define": ["USE_FOG", "USE_FOG_EXP2"], + "extend": "flywheel:fog_exp2" + } + ] +} diff --git a/src/main/resources/assets/flywheel/flywheel/shaders/model.vert b/src/main/resources/assets/flywheel/flywheel/shaders/model.vert index d475c7a3b..310815b56 100644 --- a/src/main/resources/assets/flywheel/flywheel/shaders/model.vert +++ b/src/main/resources/assets/flywheel/flywheel/shaders/model.vert @@ -26,7 +26,7 @@ BlockFrag FLWMain(Vertex v, Instance i) { b.diffuse = diffuse(norm); b.texCoords = v.texCoords; b.light = i.light; - #if defined(NORMAL_DEBUG) + #if defined(DEBUG_NORMAL) b.color = vec4(norm, 1.); #else b.color = i.color; diff --git a/src/main/resources/assets/flywheel/flywheel/shaders/oriented.vert b/src/main/resources/assets/flywheel/flywheel/shaders/oriented.vert index 809e8fa92..5c040349d 100644 --- a/src/main/resources/assets/flywheel/flywheel/shaders/oriented.vert +++ b/src/main/resources/assets/flywheel/flywheel/shaders/oriented.vert @@ -27,7 +27,7 @@ BlockFrag FLWMain(Vertex v, Oriented o) { b.diffuse = diffuse(norm); b.texCoords = v.texCoords; b.light = o.light; - #if defined(NORMAL_DEBUG) + #if defined(DEBUG_NORMAL) b.color = vec4(norm, 1.); #else b.color = o.color; From 6c390977d885948dce773ed0779242b8f6dc118d Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 22 May 2021 18:00:10 -0700 Subject: [PATCH 088/198] Init Cleanup - Refactor AllContainerTypes to use Registrate - Replace RegistryEntry in AllEntityTypes and AllFluids with EntityEntry and FluidEntry, respectively - Make AllEntityTypes use Registrate to register entity renderers instead of a separate method - Refactor AllColorHandlers - Fix error when a POI block is moved by a contraption - Rename some static final fields to be upper snake case - Make static fields in Create and CreateClient final - Add I prefix to Coordinate interface - Fix typo (BracketedTileEntityBehaviour#isBacketPresent) - Make mixins go in alphabetical order - Make pack.mcmeta use 2 spaces for indents --- .../java/com/simibubi/create/AllBlocks.java | 2 +- .../com/simibubi/create/AllColorHandlers.java | 82 ++++--------------- .../simibubi/create/AllContainerTypes.java | 65 +++++---------- .../com/simibubi/create/AllEntityTypes.java | 59 +++++++------ .../java/com/simibubi/create/AllFluids.java | 14 ++-- .../java/com/simibubi/create/AllItems.java | 2 +- .../java/com/simibubi/create/AllKeys.java | 3 +- .../create/AllMovementBehaviours.java | 12 +-- .../simibubi/create/AllSpecialTextures.java | 3 - .../java/com/simibubi/create/AllTags.java | 2 +- src/main/java/com/simibubi/create/Create.java | 72 ++++++++-------- .../com/simibubi/create/CreateClient.java | 65 ++++++--------- .../content/contraptions/KineticDebugger.java | 6 +- .../contraptions/TorquePropagator.java | 4 +- .../contraptions/base/KineticTileEntity.java | 2 +- .../base/KineticTileEntityRenderer.java | 4 +- .../deployer/BeltDeployerCallbacks.java | 2 +- .../millstone/MillstoneRenderer.java | 2 +- .../press/BeltPressingCallbacks.java | 2 +- .../press/MechanicalPressTileEntity.java | 2 +- .../components/saw/SawRenderer.java | 2 +- .../AbstractContraptionEntity.java | 2 +- .../structureMovement/Contraption.java | 7 +- .../chassis/ChassisRangeDisplay.java | 12 +-- .../pulley/PulleyRenderer.java | 4 +- .../render/ContraptionRenderDispatcher.java | 2 +- .../train/CouplingHandler.java | 2 +- .../train/CouplingRenderer.java | 4 +- .../train/capability/MinecartController.java | 2 +- .../fluids/pipes/FluidPipeBlock.java | 4 +- .../goggles/GoggleOverlayRenderer.java | 2 +- .../particle/AirFlowParticle.java | 2 +- .../contraptions/particle/AirParticle.java | 6 +- .../contraptions/processing/BasinBlock.java | 2 +- .../processing/HeatCondition.java | 2 +- .../processing/ProcessingRecipe.java | 2 +- .../advanced/SpeedControllerRenderer.java | 2 +- .../contraptions/relays/belt/BeltBlock.java | 2 +- .../relays/belt/BeltRenderer.java | 2 +- .../relays/belt/item/BeltConnectorItem.java | 2 +- .../BracketedKineticBlockModel.java | 2 +- .../BracketedTileEntityBehaviour.java | 2 +- .../contraptions/wrench/IWrenchable.java | 4 +- .../armor/CopperBacktankArmorLayer.java | 4 +- .../armor/CopperBacktankRenderer.java | 2 +- .../armor/CopperBacktankTileEntity.java | 2 +- .../zapper/ZapperRenderHandler.java | 2 +- .../WorldshaperRenderHandler.java | 2 +- .../logistics/RedstoneLinkNetworkHandler.java | 6 +- .../block/chute/ChuteTileEntity.java | 6 +- .../block/depot/EjectorTargetHandler.java | 4 +- .../block/depot/SharedDepotBlockMethods.java | 2 +- .../inventories/AdjustableCrateContainer.java | 13 ++- .../AdjustableCrateTileEntity.java | 2 +- .../ArmInteractionPointHandler.java | 2 +- .../block/mechanicalArm/ArmTileEntity.java | 2 +- .../item/filter/AttributeFilterContainer.java | 13 ++- .../item/filter/FilterContainer.java | 13 ++- .../logistics/item/filter/FilterItem.java | 4 +- .../content/palettes/AllPaletteBlocks.java | 2 +- .../schematics/ClientSchematicLoader.java | 2 +- .../content/schematics/SchematicWorld.java | 2 +- .../schematics/ServerSchematicLoader.java | 28 +++---- .../block/SchematicTableContainer.java | 13 ++- .../block/SchematicTableScreen.java | 6 +- .../block/SchematicTableTileEntity.java | 4 +- .../block/SchematicannonContainer.java | 13 ++- .../block/SchematicannonTileEntity.java | 4 +- .../client/SchematicAndQuillHandler.java | 6 +- .../client/SchematicEditScreen.java | 2 +- .../client/SchematicPromptScreen.java | 4 +- .../client/tools/SchematicToolBase.java | 2 +- .../packet/InstantSchematicPacket.java | 2 +- .../packet/SchematicUploadPacket.java | 6 +- .../simibubi/create/events/ClientEvents.java | 20 ++--- .../simibubi/create/events/CommonEvents.java | 17 ++-- .../simibubi/create/events/InputEvents.java | 10 +-- .../simibubi/create/foundation/block/ITE.java | 2 +- .../foundation/command/ChunkUtilCommand.java | 6 +- .../foundation/command/HighlightPacket.java | 2 +- .../foundation/command/KillTPSCommand.java | 14 ++-- .../command/SConfigureConfigPacket.java | 2 +- .../foundation/data/CreateRegistrate.java | 13 +-- .../create/foundation/data/LangMerger.java | 4 +- .../data/recipe/CreateRecipeProvider.java | 2 +- .../foundation/mixin/LightUpdateMixin.java | 2 +- .../mixin/NetworkLightUpdateMixin.java | 2 +- .../foundation/mixin/RenderHooksMixin.java | 6 +- .../foundation/mixin/TileRemoveMixin.java | 2 +- .../foundation/mixin/TileWorldHookMixin.java | 4 +- .../foundation/ponder/PonderRegistry.java | 4 +- .../ponder/elements/ParrotElement.java | 2 +- .../ponder/elements/WorldSectionElement.java | 2 +- .../EmitParticlesInstruction.java | 6 +- .../foundation/render/PartialBufferer.java | 4 +- .../render/TileEntityRenderHelper.java | 4 +- .../render/backend/FastRenderDispatcher.java | 4 +- .../EdgeInteractionRenderer.java | 2 +- .../filtering/FilteringRenderer.java | 2 +- .../behaviour/linked/LinkBehaviour.java | 4 +- .../behaviour/linked/LinkRenderer.java | 2 +- .../scrollvalue/ScrollValueRenderer.java | 2 +- .../foundation/utility/FilesHelper.java | 2 +- .../{Coordinate.java => ICoordinate.java} | 2 +- .../foundation/utility/RemapHelper.java | 8 +- .../utility/placement/IPlacementHelper.java | 6 +- src/main/resources/create.mixins.json | 4 +- src/main/resources/pack.mcmeta | 8 +- 108 files changed, 374 insertions(+), 455 deletions(-) rename src/main/java/com/simibubi/create/foundation/utility/{Coordinate.java => ICoordinate.java} (81%) diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 5ea72cd61..8944e78c6 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -203,7 +203,7 @@ import net.minecraftforge.common.ToolType; public class AllBlocks { private static final CreateRegistrate REGISTRATE = Create.registrate() - .itemGroup(() -> Create.baseCreativeTab); + .itemGroup(() -> Create.BASE_CREATIVE_TAB); // Schematics diff --git a/src/main/java/com/simibubi/create/AllColorHandlers.java b/src/main/java/com/simibubi/create/AllColorHandlers.java index f8d86596d..813f4f3ed 100644 --- a/src/main/java/com/simibubi/create/AllColorHandlers.java +++ b/src/main/java/com/simibubi/create/AllColorHandlers.java @@ -3,46 +3,38 @@ package com.simibubi.create; import java.util.HashMap; import java.util.Map; -import com.simibubi.create.foundation.block.IBlockVertexColor; -import com.simibubi.create.foundation.block.render.ColoredVertexModel; - import net.minecraft.block.Block; -import net.minecraft.block.BlockState; import net.minecraft.block.RedstoneWireBlock; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.ItemColors; -import net.minecraft.item.ItemStack; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.IItemProvider; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.GrassColors; -import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.biome.BiomeColors; +import net.minecraftforge.client.event.ColorHandlerEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; public class AllColorHandlers { - private final Map coloredVertexBlocks = new HashMap<>(); private final Map coloredBlocks = new HashMap<>(); private final Map coloredItems = new HashMap<>(); // public static IBlockColor getGrassyBlock() { - return new BlockColor( - (state, world, pos, layer) -> pos != null && world != null ? BiomeColors.getGrassColor(world, pos) - : GrassColors.get(0.5D, 1.0D)); + return (state, world, pos, layer) -> pos != null && world != null ? BiomeColors.getGrassColor(world, pos) + : GrassColors.get(0.5D, 1.0D); } public static IItemColor getGrassyItem() { - return new ItemColor((stack, layer) -> GrassColors.get(0.5D, 1.0D)); + return (stack, layer) -> GrassColors.get(0.5D, 1.0D); } public static IBlockColor getRedstonePower() { - return new BlockColor((state, world, pos, layer) -> RedstoneWireBlock - .getWireColor(pos != null && world != null ? state.get(BlockStateProperties.POWER_0_15) : 0)); + return (state, world, pos, layer) -> RedstoneWireBlock + .getWireColor(pos != null && world != null ? state.get(BlockStateProperties.POWER_0_15) : 0); } // @@ -51,66 +43,22 @@ public class AllColorHandlers { coloredBlocks.put(block, color); } - public void register(Block block, IBlockVertexColor color) { - coloredVertexBlocks.put(block, color); - } - public void register(IItemProvider item, IItemColor color) { coloredItems.put(item, color); } - public void init() { - BlockColors blockColors = Minecraft.getInstance() - .getBlockColors(); - ItemColors itemColors = Minecraft.getInstance() - .getItemColors(); - - coloredBlocks.forEach((block, color) -> blockColors.register(color, block)); - coloredItems.forEach((item, color) -> itemColors.register(color, item)); - coloredVertexBlocks.forEach((block, color) -> CreateClient.getCustomBlockModels() - .register(() -> block, model -> new ColoredVertexModel(model, color))); - } - // - private static class ItemColor implements IItemColor { - - private Function function; - - @FunctionalInterface - interface Function { - int apply(ItemStack stack, int layer); - } - - public ItemColor(Function function) { - this.function = function; - } - - @Override - public int getColor(ItemStack stack, int layer) { - return function.apply(stack, layer); - } - + @SubscribeEvent + public void registerBlockColors(ColorHandlerEvent.Block event) { + BlockColors blockColors = event.getBlockColors(); + coloredBlocks.forEach((block, color) -> blockColors.register(color, block)); } - private static class BlockColor implements IBlockColor { - - private Function function; - - @FunctionalInterface - interface Function { - int apply(BlockState state, IBlockDisplayReader world, BlockPos pos, int layer); - } - - public BlockColor(Function function) { - this.function = function; - } - - @Override - public int getColor(BlockState state, IBlockDisplayReader world, BlockPos pos, int layer) { - return function.apply(state, world, pos, layer); - } - + @SubscribeEvent + public void registerItemColors(ColorHandlerEvent.Item event) { + ItemColors itemColors = event.getItemColors(); + coloredItems.forEach((item, color) -> itemColors.register(color, item)); } } diff --git a/src/main/java/com/simibubi/create/AllContainerTypes.java b/src/main/java/com/simibubi/create/AllContainerTypes.java index f7ea37a0c..2e5e87d8d 100644 --- a/src/main/java/com/simibubi/create/AllContainerTypes.java +++ b/src/main/java/com/simibubi/create/AllContainerTypes.java @@ -10,61 +10,36 @@ import com.simibubi.create.content.schematics.block.SchematicTableContainer; import com.simibubi.create.content.schematics.block.SchematicTableScreen; import com.simibubi.create.content.schematics.block.SchematicannonContainer; import com.simibubi.create.content.schematics.block.SchematicannonScreen; -import com.simibubi.create.foundation.utility.Lang; +import com.tterrag.registrate.builders.ContainerBuilder.ForgeContainerFactory; +import com.tterrag.registrate.builders.ContainerBuilder.ScreenFactory; +import com.tterrag.registrate.util.entry.ContainerEntry; +import com.tterrag.registrate.util.nullness.NonNullSupplier; import net.minecraft.client.gui.IHasContainer; -import net.minecraft.client.gui.ScreenManager; -import net.minecraft.client.gui.ScreenManager.IScreenFactory; import net.minecraft.client.gui.screen.Screen; import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.ContainerType; -import net.minecraft.inventory.container.ContainerType.IFactory; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.fml.network.IContainerFactory; -public enum AllContainerTypes { +public class AllContainerTypes { - SCHEMATIC_TABLE(SchematicTableContainer::new), - SCHEMATICANNON(SchematicannonContainer::new), - FLEXCRATE(AdjustableCrateContainer::new), - FILTER(FilterContainer::new), - ATTRIBUTE_FILTER(AttributeFilterContainer::new), + public static final ContainerEntry SCHEMATIC_TABLE = + register("schematic_table", SchematicTableContainer::new, () -> SchematicTableScreen::new); - ; + public static final ContainerEntry SCHEMATICANNON = + register("schematicannon", SchematicannonContainer::new, () -> SchematicannonScreen::new); - public ContainerType type; - private IFactory factory; + public static final ContainerEntry FLEXCRATE = + register("flexcrate", AdjustableCrateContainer::new, () -> AdjustableCrateScreen::new); - private AllContainerTypes(IContainerFactory factory) { - this.factory = factory; + public static final ContainerEntry FILTER = + register("filter", FilterContainer::new, () -> FilterScreen::new); + + public static final ContainerEntry ATTRIBUTE_FILTER = + register("attribute_filter", AttributeFilterContainer::new, () -> AttributeFilterScreen::new); + + private static > ContainerEntry register(String name, ForgeContainerFactory factory, NonNullSupplier> screenFactory) { + return Create.registrate().container(name, factory, screenFactory).register(); } - public static void register(RegistryEvent.Register> event) { - for (AllContainerTypes container : values()) { - container.type = new ContainerType<>(container.factory) - .setRegistryName(new ResourceLocation(Create.ID, Lang.asId(container.name()))); - event.getRegistry() - .register(container.type); - } - } - - @OnlyIn(Dist.CLIENT) - public static void registerScreenFactories() { - bind(SCHEMATIC_TABLE, SchematicTableScreen::new); - bind(SCHEMATICANNON, SchematicannonScreen::new); - bind(FLEXCRATE, AdjustableCrateScreen::new); - bind(FILTER, FilterScreen::new); - bind(ATTRIBUTE_FILTER, AttributeFilterScreen::new); - } - - @OnlyIn(Dist.CLIENT) - @SuppressWarnings("unchecked") - private static > void bind(AllContainerTypes c, - IScreenFactory factory) { - ScreenManager.registerFactory((ContainerType) c.type, factory); - } + public static void register() {} } diff --git a/src/main/java/com/simibubi/create/AllEntityTypes.java b/src/main/java/com/simibubi/create/AllEntityTypes.java index 32afec7fa..b6a6fb322 100644 --- a/src/main/java/com/simibubi/create/AllEntityTypes.java +++ b/src/main/java/com/simibubi/create/AllEntityTypes.java @@ -10,43 +10,47 @@ import com.simibubi.create.content.contraptions.components.structureMovement.gan import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity; import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueRenderer; import com.simibubi.create.foundation.utility.Lang; -import com.tterrag.registrate.util.entry.RegistryEntry; +import com.tterrag.registrate.util.entry.EntityEntry; import com.tterrag.registrate.util.nullness.NonNullConsumer; +import com.tterrag.registrate.util.nullness.NonNullSupplier; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType.IFactory; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.client.registry.RenderingRegistry; +import net.minecraftforge.fml.client.registry.IRenderFactory; public class AllEntityTypes { - public static final RegistryEntry> ORIENTED_CONTRAPTION = - contraption("contraption", OrientedContraptionEntity::new, 5, 3, true); - public static final RegistryEntry> CONTROLLED_CONTRAPTION = - contraption("stationary_contraption", ControlledContraptionEntity::new, 20, 40, false); - public static final RegistryEntry> GANTRY_CONTRAPTION = - contraption("gantry_contraption", GantryContraptionEntity::new, 10, 40, false); + public static final EntityEntry ORIENTED_CONTRAPTION = + contraption("contraption", OrientedContraptionEntity::new, () -> OrientedContraptionEntityRenderer::new, + 5, 3, true); + public static final EntityEntry CONTROLLED_CONTRAPTION = + contraption("stationary_contraption", ControlledContraptionEntity::new, () -> ContraptionEntityRenderer::new, + 20, 40, false); + public static final EntityEntry GANTRY_CONTRAPTION = + contraption("gantry_contraption", GantryContraptionEntity::new, () -> ContraptionEntityRenderer::new, + 10, 40, false); - public static final RegistryEntry> SUPER_GLUE = register("super_glue", - SuperGlueEntity::new, EntityClassification.MISC, 10, Integer.MAX_VALUE, false, true, SuperGlueEntity::build); - public static final RegistryEntry> SEAT = register("seat", SeatEntity::new, - EntityClassification.MISC, 0, Integer.MAX_VALUE, false, true, SeatEntity::build); + public static final EntityEntry SUPER_GLUE = + register("super_glue", SuperGlueEntity::new, () -> SuperGlueRenderer::new, + EntityClassification.MISC, 10, Integer.MAX_VALUE, false, true, SuperGlueEntity::build); + public static final EntityEntry SEAT = + register("seat", SeatEntity::new, () -> SeatEntity.Render::new, + EntityClassification.MISC, 0, Integer.MAX_VALUE, false, true, SeatEntity::build); // - public static void register() {} - - private static RegistryEntry> contraption(String name, IFactory factory, - int range, int updateFrequency, boolean sendVelocity) { - return register(name, factory, EntityClassification.MISC, range, updateFrequency, sendVelocity, true, - AbstractContraptionEntity::build); + private static EntityEntry contraption(String name, IFactory factory, + NonNullSupplier> renderer, int range, int updateFrequency, + boolean sendVelocity) { + return register(name, factory, renderer, EntityClassification.MISC, range, updateFrequency, + sendVelocity, true, AbstractContraptionEntity::build); } - private static RegistryEntry> register(String name, IFactory factory, - EntityClassification group, int range, int updateFrequency, boolean sendVelocity, boolean immuneToFire, + private static EntityEntry register(String name, IFactory factory, + NonNullSupplier> renderer, EntityClassification group, int range, + int updateFrequency, boolean sendVelocity, boolean immuneToFire, NonNullConsumer> propertyBuilder) { String id = Lang.asId(name); return Create.registrate() @@ -59,16 +63,9 @@ public class AllEntityTypes { if (immuneToFire) b.immuneToFire(); }) + .renderer(renderer) .register(); } - @OnlyIn(value = Dist.CLIENT) - public static void registerRenderers() { - RenderingRegistry.registerEntityRenderingHandler(CONTROLLED_CONTRAPTION.get(), ContraptionEntityRenderer::new); - RenderingRegistry.registerEntityRenderingHandler(ORIENTED_CONTRAPTION.get(), - OrientedContraptionEntityRenderer::new); - RenderingRegistry.registerEntityRenderingHandler(GANTRY_CONTRAPTION.get(), ContraptionEntityRenderer::new); - RenderingRegistry.registerEntityRenderingHandler(SUPER_GLUE.get(), SuperGlueRenderer::new); - RenderingRegistry.registerEntityRenderingHandler(SEAT.get(), SeatEntity.Render::new); - } + public static void register() {} } diff --git a/src/main/java/com/simibubi/create/AllFluids.java b/src/main/java/com/simibubi/create/AllFluids.java index 5a7b92355..8262aa8dc 100644 --- a/src/main/java/com/simibubi/create/AllFluids.java +++ b/src/main/java/com/simibubi/create/AllFluids.java @@ -7,7 +7,7 @@ import com.simibubi.create.content.contraptions.fluids.potion.PotionFluid; import com.simibubi.create.content.contraptions.fluids.potion.PotionFluid.PotionFluidAttributes; import com.simibubi.create.content.palettes.AllPaletteBlocks; import com.simibubi.create.foundation.data.CreateRegistrate; -import com.tterrag.registrate.util.entry.RegistryEntry; +import com.tterrag.registrate.util.entry.FluidEntry; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.RenderType; @@ -25,22 +25,22 @@ public class AllFluids { private static final CreateRegistrate REGISTRATE = Create.registrate(); - public static RegistryEntry POTION = + public static FluidEntry POTION = REGISTRATE.virtualFluid("potion", PotionFluidAttributes::new, PotionFluid::new) .lang(f -> "fluid.create.potion", "Potion") .register(); - public static RegistryEntry TEA = REGISTRATE.virtualFluid("tea") + public static FluidEntry TEA = REGISTRATE.virtualFluid("tea") .lang(f -> "fluid.create.tea", "Builder's Tea") .tag(AllTags.forgeFluidTag("tea")) .register(); - public static RegistryEntry MILK = REGISTRATE.virtualFluid("milk") + public static FluidEntry MILK = REGISTRATE.virtualFluid("milk") .lang(f -> "fluid.create.milk", "Milk") .tag(AllTags.forgeFluidTag("milk")) .register(); - public static RegistryEntry HONEY = + public static FluidEntry HONEY = REGISTRATE.standardFluid("honey", NoColorFluidAttributes::new) .lang(f -> "fluid.create.honey", "Honey") .attributes(b -> b.viscosity(500) @@ -55,7 +55,7 @@ public class AllFluids { .build() .register(); - public static RegistryEntry CHOCOLATE = + public static FluidEntry CHOCOLATE = REGISTRATE.standardFluid("chocolate", NoColorFluidAttributes::new) .lang(f -> "fluid.create.chocolate", "Chocolate") .tag(AllTags.forgeFluidTag("chocolate")) @@ -78,7 +78,7 @@ public class AllFluids { public static void assignRenderLayers() {} @OnlyIn(Dist.CLIENT) - private static void makeTranslucent(RegistryEntry entry) { + private static void makeTranslucent(FluidEntry entry) { ForgeFlowingFluid fluid = entry.get(); RenderTypeLookup.setRenderLayer(fluid, RenderType.getTranslucent()); RenderTypeLookup.setRenderLayer(fluid.getStillFluid(), RenderType.getTranslucent()); diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 2d13ad744..901ab6710 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -61,7 +61,7 @@ import net.minecraft.util.ResourceLocation; public class AllItems { private static final CreateRegistrate REGISTRATE = Create.registrate() - .itemGroup(() -> Create.baseCreativeTab); + .itemGroup(() -> Create.BASE_CREATIVE_TAB); // Schematics diff --git a/src/main/java/com/simibubi/create/AllKeys.java b/src/main/java/com/simibubi/create/AllKeys.java index d997811b2..3877f1026 100644 --- a/src/main/java/com/simibubi/create/AllKeys.java +++ b/src/main/java/com/simibubi/create/AllKeys.java @@ -9,7 +9,8 @@ import net.minecraftforge.fml.client.registry.ClientRegistry; public enum AllKeys { - TOOL_MENU("toolmenu", GLFW.GLFW_KEY_LEFT_ALT), ACTIVATE_TOOL("", GLFW.GLFW_KEY_LEFT_CONTROL), + TOOL_MENU("toolmenu", GLFW.GLFW_KEY_LEFT_ALT), + ACTIVATE_TOOL("", GLFW.GLFW_KEY_LEFT_CONTROL), ; diff --git a/src/main/java/com/simibubi/create/AllMovementBehaviours.java b/src/main/java/com/simibubi/create/AllMovementBehaviours.java index 0d306ddaf..ece2e1f65 100644 --- a/src/main/java/com/simibubi/create/AllMovementBehaviours.java +++ b/src/main/java/com/simibubi/create/AllMovementBehaviours.java @@ -17,12 +17,12 @@ import net.minecraft.block.Blocks; import net.minecraft.util.ResourceLocation; public class AllMovementBehaviours { - private static final HashMap movementBehaviours = new HashMap<>(); + private static final HashMap MOVEMENT_BEHAVIOURS = new HashMap<>(); public static void addMovementBehaviour(ResourceLocation resourceLocation, MovementBehaviour movementBehaviour) { - if (movementBehaviours.containsKey(resourceLocation)) - Create.logger.warn("Movement behaviour for " + resourceLocation.toString() + " was overridden"); - movementBehaviours.put(resourceLocation, movementBehaviour); + if (MOVEMENT_BEHAVIOURS.containsKey(resourceLocation)) + Create.LOGGER.warn("Movement behaviour for " + resourceLocation.toString() + " was overridden"); + MOVEMENT_BEHAVIOURS.put(resourceLocation, movementBehaviour); } public static void addMovementBehaviour(Block block, MovementBehaviour movementBehaviour) { @@ -31,7 +31,7 @@ public class AllMovementBehaviours { @Nullable public static MovementBehaviour of(ResourceLocation resourceLocation) { - return movementBehaviours.getOrDefault(resourceLocation, null); + return MOVEMENT_BEHAVIOURS.getOrDefault(resourceLocation, null); } @Nullable @@ -45,7 +45,7 @@ public class AllMovementBehaviours { } public static boolean contains(Block block) { - return movementBehaviours.containsKey(block.getRegistryName()); + return MOVEMENT_BEHAVIOURS.containsKey(block.getRegistryName()); } public static NonNullConsumer addMovementBehaviour( diff --git a/src/main/java/com/simibubi/create/AllSpecialTextures.java b/src/main/java/com/simibubi/create/AllSpecialTextures.java index d3b95fe85..786dde9be 100644 --- a/src/main/java/com/simibubi/create/AllSpecialTextures.java +++ b/src/main/java/com/simibubi/create/AllSpecialTextures.java @@ -2,10 +2,7 @@ package com.simibubi.create; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -@EventBusSubscriber(value = Dist.CLIENT) public enum AllSpecialTextures { BLANK("blank.png"), diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index 231973559..568412ddc 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -31,7 +31,7 @@ import net.minecraftforge.fml.ModList; public class AllTags { private static final CreateRegistrate REGISTRATE = Create.registrate() - .itemGroup(() -> Create.baseCreativeTab); + .itemGroup(() -> Create.BASE_CREATIVE_TAB); public static NonNullFunction, ItemBuilder>> tagBlockAndItem( String tagName) { diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index c62a11acb..087c577ae 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -31,7 +31,6 @@ import com.simibubi.create.foundation.worldgen.AllWorldFeatures; import com.tterrag.registrate.util.NonNullLazyValue; import net.minecraft.data.DataGenerator; -import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemGroup; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.particles.ParticleType; @@ -57,52 +56,52 @@ public class Create { public static final String NAME = "Create"; public static final String VERSION = "0.3.1c"; - public static Logger logger = LogManager.getLogger(); - public static ItemGroup baseCreativeTab = new CreateItemGroup(); - public static ItemGroup palettesCreativeTab = new PalettesItemGroup(); + public static final Logger LOGGER = LogManager.getLogger(); - public static Gson GSON = new GsonBuilder().setPrettyPrinting() + public static final Gson GSON = new GsonBuilder().setPrettyPrinting() .disableHtmlEscaping() .create(); - public static ServerSchematicLoader schematicReceiver; - public static RedstoneLinkNetworkHandler redstoneLinkNetworkHandler; - public static TorquePropagator torquePropagator; - public static ServerLagger lagger; - public static ChunkUtil chunkUtil; - public static Random random; + public static final ItemGroup BASE_CREATIVE_TAB = new CreateItemGroup(); + public static final ItemGroup PALETTES_CREATIVE_TAB = new PalettesItemGroup(); - private static final NonNullLazyValue registrate = CreateRegistrate.lazy(ID); + public static final ServerSchematicLoader SCHEMATIC_RECEIVER = new ServerSchematicLoader(); + public static final RedstoneLinkNetworkHandler REDSTONE_LINK_NETWORK_HANDLER = new RedstoneLinkNetworkHandler(); + public static final TorquePropagator TORQUE_PROPAGATOR = new TorquePropagator(); + public static final ServerLagger LAGGER = new ServerLagger(); + public static final ChunkUtil CHUNK_UTIL = new ChunkUtil(); + public static final Random RANDOM = new Random(); + + private static final NonNullLazyValue REGISTRATE = CreateRegistrate.lazy(ID); public Create() { - IEventBus modEventBus = FMLJavaModLoadingContext.get() - .getModEventBus(); - AllSoundEvents.prepare(); AllBlocks.register(); AllItems.register(); AllFluids.register(); AllTags.register(); AllPaletteBlocks.register(); + AllContainerTypes.register(); AllEntityTypes.register(); AllTileEntities.register(); AllMovementBehaviours.register(); AllWorldFeatures.register(); + AllConfigs.register(); + + IEventBus modEventBus = FMLJavaModLoadingContext.get() + .getModEventBus(); + IEventBus forgeEventBus = MinecraftForge.EVENT_BUS; modEventBus.addListener(Create::init); - MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, Create::onBiomeLoad); modEventBus.addGenericListener(Feature.class, AllWorldFeatures::registerOreFeatures); modEventBus.addGenericListener(Placement.class, AllWorldFeatures::registerDecoratorFeatures); modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipeTypes::register); - modEventBus.addGenericListener(ContainerType.class, AllContainerTypes::register); modEventBus.addGenericListener(ParticleType.class, AllParticleTypes::register); modEventBus.addGenericListener(SoundEvent.class, AllSoundEvents::register); modEventBus.addListener(AllConfigs::onLoad); modEventBus.addListener(AllConfigs::onReload); modEventBus.addListener(EventPriority.LOWEST, this::gatherData); - - AllConfigs.register(); - random = new Random(); + forgeEventBus.addListener(EventPriority.HIGH, Create::onBiomeLoad); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> CreateClient.addClientListeners(modEventBus)); } @@ -110,14 +109,9 @@ public class Create { public static void init(final FMLCommonSetupEvent event) { CapabilityMinecartController.register(); SchematicInstances.register(); - schematicReceiver = new ServerSchematicLoader(); - redstoneLinkNetworkHandler = new RedstoneLinkNetworkHandler(); - torquePropagator = new TorquePropagator(); - lagger = new ServerLagger(); - chunkUtil = new ChunkUtil(); - chunkUtil.init(); - MinecraftForge.EVENT_BUS.register(chunkUtil); + CHUNK_UTIL.init(); + MinecraftForge.EVENT_BUS.register(CHUNK_UTIL); AllPackets.registerPackets(); AllTriggers.register(); @@ -128,18 +122,6 @@ public class Create { }); } - public static void onBiomeLoad(BiomeLoadingEvent event) { - AllWorldFeatures.reload(event); - } - - public static CreateRegistrate registrate() { - return registrate.get(); - } - - public static ResourceLocation asResource(String path) { - return new ResourceLocation(ID, path); - } - public void gatherData(GatherDataEvent event) { DataGenerator gen = event.getGenerator(); gen.addProvider(new AllAdvancements(gen)); @@ -150,4 +132,16 @@ public class Create { ProcessingRecipeGen.registerAll(gen); } + public static void onBiomeLoad(BiomeLoadingEvent event) { + AllWorldFeatures.reload(event); + } + + public static CreateRegistrate registrate() { + return REGISTRATE.get(); + } + + public static ResourceLocation asResource(String path) { + return new ResourceLocation(ID, path); + } + } diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 635998c39..6bbe40109 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -63,13 +63,13 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; public class CreateClient { - public static ClientSchematicLoader schematicSender; - public static SchematicHandler schematicHandler; - public static SchematicAndQuillHandler schematicAndQuillHandler; - public static SuperByteBufferCache bufferCache; - public static WorldAttached kineticRenderer; - public static final Outliner outliner = new Outliner(); - public static GhostBlocks ghostBlocks; + public static final ClientSchematicLoader SCHEMATIC_SENDER = new ClientSchematicLoader(); + public static final SchematicHandler SCHEMATIC_HANDLER = new SchematicHandler(); + public static final SchematicAndQuillHandler SCHEMATIC_AND_QUILL_HANDLER = new SchematicAndQuillHandler(); + public static final SuperByteBufferCache BUFFER_CACHE = new SuperByteBufferCache(); + public static final WorldAttached KINETIC_RENDERER = new WorldAttached<>(KineticRenderer::new); + public static final Outliner OUTLINER = new Outliner(); + public static final GhostBlocks GHOST_BLOCKS = new GhostBlocks(); private static CustomBlockModels customBlockModels; private static CustomItemModels customItemModels; @@ -79,9 +79,10 @@ public class CreateClient { public static void addClientListeners(IEventBus modEventBus) { modEventBus.addListener(CreateClient::clientInit); - modEventBus.addListener(CreateClient::onModelBake); - modEventBus.addListener(CreateClient::onModelRegistry); + modEventBus.register(getColorHandler()); modEventBus.addListener(CreateClient::onTextureStitch); + modEventBus.addListener(CreateClient::onModelRegistry); + modEventBus.addListener(CreateClient::onModelBake); modEventBus.addListener(AllParticleTypes::registerFactories); modEventBus.addListener(ClientEvents::loadCompleted); @@ -91,25 +92,15 @@ public class CreateClient { public static void clientInit(FMLClientSetupEvent event) { AllProgramSpecs.init(); - kineticRenderer = new WorldAttached<>(KineticRenderer::new); - schematicSender = new ClientSchematicLoader(); - schematicHandler = new SchematicHandler(); - schematicAndQuillHandler = new SchematicAndQuillHandler(); - - bufferCache = new SuperByteBufferCache(); - bufferCache.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE); - bufferCache.registerCompartment(ContraptionRenderDispatcher.CONTRAPTION, 20); - bufferCache.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20); - - ghostBlocks = new GhostBlocks(); + BUFFER_CACHE.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE); + BUFFER_CACHE.registerCompartment(ContraptionRenderDispatcher.CONTRAPTION, 20); + BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20); AllKeys.register(); - AllContainerTypes.registerScreenFactories(); - // AllTileEntities.registerRenderers(); - AllEntityTypes.registerRenderers(); - getColorHandler().init(); - AllFluids.assignRenderLayers(); + // AllFluids.assignRenderLayers(); + AllBlockPartials.clientInit(); + PonderIndex.register(); PonderIndex.registerTags(); @@ -121,8 +112,6 @@ public class CreateClient { if (resourceManager instanceof IReloadableResourceManager) ((IReloadableResourceManager) resourceManager).addReloadListener(new ResourceReloadHandler()); - AllBlockPartials.clientInit(); - event.enqueueWork(() -> { CopperBacktankArmorLayer.register(); }); @@ -137,6 +126,14 @@ public class CreateClient { .forEach(event::addSprite); } + public static void onModelRegistry(ModelRegistryEvent event) { + PartialModel.onModelRegistry(event); + + getCustomRenderedItems().foreach((item, modelFunc) -> modelFunc.apply(null) + .getModelLocations() + .forEach(ModelLoader::addSpecialModel)); + } + public static void onModelBake(ModelBakeEvent event) { Map modelRegistry = event.getModelRegistry(); PartialModel.onModelBake(event); @@ -151,14 +148,6 @@ public class CreateClient { }); } - public static void onModelRegistry(ModelRegistryEvent event) { - PartialModel.onModelRegistry(event); - - getCustomRenderedItems().foreach((item, modelFunc) -> modelFunc.apply(null) - .getModelLocations() - .forEach(ModelLoader::addSpecialModel)); - } - protected static ModelResourceLocation getItemModelLocation(Item item) { return new ModelResourceLocation(item.getRegistryName(), "inventory"); } @@ -224,13 +213,13 @@ public class CreateClient { } public static void invalidateRenderers(@Nullable IWorld world) { - bufferCache.invalidate(); + BUFFER_CACHE.invalidate(); if (world != null) { - kineticRenderer.get(world) + KINETIC_RENDERER.get(world) .invalidate(); } else { - kineticRenderer.forEach(InstancedTileRenderer::invalidate); + KINETIC_RENDERER.forEach(InstancedTileRenderer::invalidate); } ContraptionRenderDispatcher.invalidateAll(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java b/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java index f62c174bc..4f00b3b7f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java +++ b/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java @@ -28,7 +28,7 @@ public class KineticDebugger { if (!isActive()) { if (KineticTileEntityRenderer.rainbowMode) { KineticTileEntityRenderer.rainbowMode = false; - CreateClient.bufferCache.invalidate(); + CreateClient.BUFFER_CACHE.invalidate(); } return; } @@ -44,7 +44,7 @@ public class KineticDebugger { .getRenderShape(world, toOutline); if (te.getTheoreticalSpeed() != 0 && !shape.isEmpty()) - CreateClient.outliner.chaseAABB("kineticSource", shape.getBoundingBox() + CreateClient.OUTLINER.chaseAABB("kineticSource", shape.getBoundingBox() .offset(toOutline)) .lineWidth(1 / 16f) .colored(te.hasSource() ? ColorHelper.colorFromLong(te.network) : 0xffcc00); @@ -54,7 +54,7 @@ public class KineticDebugger { Vector3d vec = Vector3d.of(Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis) .getDirectionVec()); Vector3d center = VecHelper.getCenterOf(te.getPos()); - CreateClient.outliner.showLine("rotationAxis", center.add(vec), center.subtract(vec)) + CreateClient.OUTLINER.showLine("rotationAxis", center.add(vec), center.subtract(vec)) .lineWidth(1 / 16f); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java b/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java index 6dfae6185..3d169a6ef 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java @@ -15,12 +15,12 @@ public class TorquePropagator { public void onLoadWorld(IWorld world) { networks.put(world, new HashMap<>()); - Create.logger.debug("Prepared Kinetic Network Space for " + WorldHelper.getDimensionID(world)); + Create.LOGGER.debug("Prepared Kinetic Network Space for " + WorldHelper.getDimensionID(world)); } public void onUnloadWorld(IWorld world) { networks.remove(world); - Create.logger.debug("Removed Kinetic Network Space for " + WorldHelper.getDimensionID(world)); + Create.LOGGER.debug("Removed Kinetic Network Space for " + WorldHelper.getDimensionID(world)); } public KineticNetwork getOrCreateNetworkFor(KineticTileEntity te) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java index 93058fb64..a6c5e5d6c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntity.java @@ -329,7 +329,7 @@ public abstract class KineticTileEntity extends SmartTileEntity } public KineticNetwork getOrCreateNetwork() { - return Create.torquePropagator.getOrCreateNetworkFor(this); + return Create.TORQUE_PROPAGATOR.getOrCreateNetworkFor(this); } public boolean hasNetwork() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java index dcefcadfe..9f817051e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java @@ -48,7 +48,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer { BlockState state = te.getBlockState(); if (state.get(FACING).getAxis().isHorizontal()) return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, state.rotate(te.getWorld(), te.getPos(), Rotation.CLOCKWISE_180)); - return CreateClient.bufferCache.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE, + return CreateClient.BUFFER_CACHE.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE, getRenderedBlockState(te)); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java index 5c651529a..5102326e8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java @@ -391,7 +391,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit byte[] byteArray = dataOutput.toByteArray(); int estimatedPacketSize = byteArray.length; if (estimatedPacketSize > 2_000_000) { - Create.logger.warn("Could not send Contraption Spawn Data (Packet too big): " + Create.LOGGER.warn("Could not send Contraption Spawn Data (Packet too big): " + getContraption().getType().id + " @" + getPositionVec() + " (" + getUniqueID().toString() + ")"); buffer.writeCompoundTag(new CompoundNBT()); return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index f7c07d10d..9ab82f1dc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -61,7 +61,7 @@ import com.simibubi.create.foundation.render.backend.light.EmptyLighter; import com.simibubi.create.foundation.render.backend.light.GridAlignedBB; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.BlockFace; -import com.simibubi.create.foundation.utility.Coordinate; +import com.simibubi.create.foundation.utility.ICoordinate; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTProcessors; @@ -974,10 +974,7 @@ public abstract class Contraption { // continue; int flags = BlockFlags.IS_MOVING | BlockFlags.DEFAULT; world.notifyBlockUpdate(add, block.state, Blocks.AIR.getDefaultState(), flags); - world.markAndNotifyBlock(add, world.getChunkAt(add), block.state, Blocks.AIR.getDefaultState(), flags, 512); block.state.updateDiagonalNeighbors(world, add, flags & -2); -// world.markAndNotifyBlock(add, null, block.state, Blocks.AIR.getDefaultState(), -// BlockFlags.IS_MOVING | BlockFlags.DEFAULT); this method did strange logspamming with POI-related blocks } } @@ -1235,7 +1232,7 @@ public abstract class Contraption { throw new IllegalStateException("Impossible axis"); } - public static float getMaxDistSqr(Set blocks, Coordinate one, Coordinate other) { + public static float getMaxDistSqr(Set blocks, ICoordinate one, ICoordinate other) { float maxDistSq = -1; for (BlockPos pos : blocks) { float a = one.get(pos); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisRangeDisplay.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisRangeDisplay.java index b8784ba92..f56f965f8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisRangeDisplay.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisRangeDisplay.java @@ -35,7 +35,7 @@ public class ChassisRangeDisplay { public Entry(ChassisTileEntity te) { this.te = te; timer = DISPLAY_TIME; - CreateClient.outliner.showCluster(getOutlineKey(), createSelection(te)) + CreateClient.OUTLINER.showCluster(getOutlineKey(), createSelection(te)) .colored(0xFFFFFF) .disableNormals() .lineWidth(1 / 16f) @@ -97,7 +97,7 @@ public class ChassisRangeDisplay { Entry entry = entries.get(pos); if (tickEntry(entry, hasWrench)) iterator.remove(); - CreateClient.outliner.keep(entry.getOutlineKey()); + CreateClient.OUTLINER.keep(entry.getOutlineKey()); } for (Iterator iterator = groupEntries.iterator(); iterator.hasNext();) { @@ -107,7 +107,7 @@ public class ChassisRangeDisplay { if (group == lastHoveredGroup) lastHoveredGroup = null; } - CreateClient.outliner.keep(group.getOutlineKey()); + CreateClient.OUTLINER.keep(group.getOutlineKey()); } if (!hasWrench) @@ -173,9 +173,9 @@ public class ChassisRangeDisplay { GroupEntry hoveredGroup = new GroupEntry(chassis); for (ChassisTileEntity included : hoveredGroup.includedTEs) - CreateClient.outliner.remove(included.getPos()); + CreateClient.OUTLINER.remove(included.getPos()); - groupEntries.forEach(entry -> CreateClient.outliner.remove(entry.getOutlineKey())); + groupEntries.forEach(entry -> CreateClient.OUTLINER.remove(entry.getOutlineKey())); groupEntries.clear(); entries.clear(); groupEntries.add(hoveredGroup); @@ -186,7 +186,7 @@ public class ChassisRangeDisplay { BlockPos pos = chassis.getPos(); GroupEntry entry = getExistingGroupForPos(pos); if (entry != null) - CreateClient.outliner.remove(entry.getOutlineKey()); + CreateClient.OUTLINER.remove(entry.getOutlineKey()); groupEntries.clear(); entries.clear(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java index 4db922553..d2a10e45c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java @@ -31,12 +31,12 @@ public class PulleyRenderer extends AbstractPulleyRenderer { @Override protected SuperByteBuffer renderRope(KineticTileEntity te) { - return CreateClient.bufferCache.renderBlock(AllBlocks.ROPE.getDefaultState()); + return CreateClient.BUFFER_CACHE.renderBlock(AllBlocks.ROPE.getDefaultState()); } @Override protected SuperByteBuffer renderMagnet(KineticTileEntity te) { - return CreateClient.bufferCache.renderBlock(AllBlocks.PULLEY_MAGNET.getDefaultState()); + return CreateClient.BUFFER_CACHE.renderBlock(AllBlocks.PULLEY_MAGNET.getDefaultState()); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 83c39757f..1c117deef 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -124,7 +124,7 @@ public class ContraptionRenderDispatcher { public static void renderStructure(World world, Contraption c, MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - SuperByteBufferCache bufferCache = CreateClient.bufferCache; + SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE; List blockLayers = RenderType.getBlockLayers(); buffer.getBuffer(RenderType.getSolid()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java index c3836991c..e16e87de6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java @@ -124,7 +124,7 @@ public class CouplingHandler { while (true) { if (safetyCount-- <= 0) { - Create.logger.warn("Infinite loop in coupling iteration"); + Create.LOGGER.warn("Infinite loop in coupling iteration"); return false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java index 0a6edeb8d..8de4ef96f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java @@ -228,13 +228,13 @@ public class CouplingRenderer { int color = ColorHelper.mixColors(0xabf0e9, 0xee8572, (float) MathHelper .clamp(Math.abs(first.getCouplingLength(true) - connectedCenter.distanceTo(mainCenter)) * 8, 0, 1)); - CreateClient.outliner.showLine(mainCart.getEntityId() + "", mainCenter, connectedCenter) + CreateClient.OUTLINER.showLine(mainCart.getEntityId() + "", mainCenter, connectedCenter) .colored(color) .lineWidth(1 / 8f); Vector3d point = mainCart.getPositionVec() .add(0, yOffset, 0); - CreateClient.outliner.showLine(mainCart.getEntityId() + "_dot", point, point.add(0, 1 / 128f, 0)) + CreateClient.OUTLINER.showLine(mainCart.getEntityId() + "_dot", point, point.add(0, 1 / 128f, 0)) .colored(0xffffff) .lineWidth(1 / 4f); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/MinecartController.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/MinecartController.java index 134b38262..59b33b656 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/MinecartController.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/capability/MinecartController.java @@ -197,7 +197,7 @@ public class MinecartController implements INBTSerializable { while (true) { if (safetyCount-- <= 0) { - Create.logger.warn("Infinite loop in coupling iteration"); + Create.LOGGER.warn("Infinite loop in coupling iteration"); return; } cartsToFlip.add(current); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java index ec2cc1b2d..51ddeff5b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java @@ -148,7 +148,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren FluidTransportBehaviour transport = TileEntityBehaviour.get(world, neighbourPos, FluidTransportBehaviour.TYPE); BracketedTileEntityBehaviour bracket = TileEntityBehaviour.get(world, neighbourPos, BracketedTileEntityBehaviour.TYPE); if (isPipe(neighbour)) - return bracket == null || !bracket.isBacketPresent() + return bracket == null || !bracket.isBracketPresent() || FluidPropagator.getStraightPipeAxis(neighbour) == direction.getAxis(); if (transport == null) return false; @@ -228,7 +228,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren IBlockDisplayReader world, BlockPos pos) { BracketedTileEntityBehaviour bracket = TileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE); - if (bracket != null && bracket.isBacketPresent()) + if (bracket != null && bracket.isBracketPresent()) return state; // Update sides that are not ignored diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java index 32455af5c..1caccf3d5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java @@ -42,7 +42,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @EventBusSubscriber(value = Dist.CLIENT) public class GoggleOverlayRenderer { - private static final Map outlines = CreateClient.outliner.getOutlines(); + private static final Map outlines = CreateClient.OUTLINER.getOutlines(); @SubscribeEvent public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java index 19ac87552..3d5c41c8a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java @@ -35,7 +35,7 @@ public class AirFlowParticle extends SimpleAnimatedParticle { this.maxAge = 40; canCollide = false; selectSprite(7); - Vector3d offset = VecHelper.offsetRandomly(Vector3d.ZERO, Create.random, .25f); + Vector3d offset = VecHelper.offsetRandomly(Vector3d.ZERO, Create.RANDOM, .25f); this.setPosition(posX + offset.x, posY + offset.y, posZ + offset.z); this.prevPosX = posX; this.prevPosY = posY; diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java index ffe3e0e39..31d219f96 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirParticle.java @@ -39,9 +39,9 @@ public class AirParticle extends SimpleAnimatedParticle { targetZ = (float) (z + dz); drag = data.drag; - twirlRadius = Create.random.nextFloat() / 6; - twirlAngleOffset = Create.random.nextFloat() * 360; - twirlAxis = Create.random.nextBoolean() ? Axis.X : Axis.Z; + twirlRadius = Create.RANDOM.nextFloat() / 6; + twirlAngleOffset = Create.RANDOM.nextFloat() * 360; + twirlAxis = Create.RANDOM.nextBoolean() ? Axis.X : Axis.Z; // speed in m/ticks maxAge = Math.min((int) (new Vector3d(dx, dy, dz).length() / data.speed), 60); diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java index cd27761a6..49d3b1607 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java @@ -126,7 +126,7 @@ public class BasinBlock extends Block implements ITE, IWrenchab } if (success) worldIn.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, .2f, - 1f + Create.random.nextFloat()); + 1f + Create.RANDOM.nextFloat()); te.onEmptied(); } catch (TileEntityException e) { } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/HeatCondition.java b/src/main/java/com/simibubi/create/content/contraptions/processing/HeatCondition.java index 0f84596cd..8b78627d6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/HeatCondition.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/HeatCondition.java @@ -46,7 +46,7 @@ public enum HeatCondition { if (heatCondition.serialize() .equals(name)) return heatCondition; - Create.logger.warn("Tried to deserialize invalid heat condition: \"" + name + "\""); + Create.LOGGER.warn("Tried to deserialize invalid heat condition: \"" + name + "\""); return NONE; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipe.java index 9fc92040c..bd84a014f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipe.java @@ -85,7 +85,7 @@ public abstract class ProcessingRecipe implements IRecipe< private void validate(String recipeTypeName) { String messageHeader = "Your custom " + recipeTypeName + " recipe (" + id.toString() + ")"; - Logger logger = Create.logger; + Logger logger = Create.LOGGER; int ingredientCount = ingredients.size(); int outputCount = results.size(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java index 6d4fec12e..23b89bcc6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerRenderer.java @@ -53,7 +53,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer { return stack; }; - SuperByteBuffer superBuffer = CreateClient.bufferCache.renderDirectionalPartial(AllBlockPartials.BELT_PULLEY, blockState, dir, matrixStackSupplier); + SuperByteBuffer superBuffer = CreateClient.BUFFER_CACHE.renderDirectionalPartial(AllBlockPartials.BELT_PULLEY, blockState, dir, matrixStackSupplier); KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java index 29d5ad0b3..1df40f3b8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java @@ -47,7 +47,7 @@ public class BeltConnectorItem extends BlockItem { @Override public void fillItemGroup(ItemGroup p_150895_1_, NonNullList p_150895_2_) { - if (p_150895_1_ == Create.baseCreativeTab) + if (p_150895_1_ == Create.BASE_CREATIVE_TAB) return; super.fillItemGroup(p_150895_1_, p_150895_2_); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java index 28b3c46a6..c4df7f899 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java @@ -21,7 +21,7 @@ import net.minecraftforge.client.model.data.ModelProperty; public class BracketedKineticBlockModel extends BakedModelWrapper { - private static ModelProperty BRACKET_PROPERTY = new ModelProperty<>(); + private static final ModelProperty BRACKET_PROPERTY = new ModelProperty<>(); public BracketedKineticBlockModel(IBakedModel template) { super(template); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java index f2dbec548..32d3ce142 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java @@ -73,7 +73,7 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { tileEntity.notifyUpdate(); } - public boolean isBacketPresent() { + public boolean isBracketPresent() { return getBracket() != Blocks.AIR.getDefaultState(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchable.java b/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchable.java index 52d9489c4..68b5365a5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchable.java +++ b/src/main/java/com/simibubi/create/content/contraptions/wrench/IWrenchable.java @@ -71,11 +71,11 @@ public interface IWrenchable { } default void playRemoveSound(World world, BlockPos pos) { - AllSoundEvents.WRENCH_REMOVE.playOnServer(world, pos, 1, Create.random.nextFloat() * .5f + .5f); + AllSoundEvents.WRENCH_REMOVE.playOnServer(world, pos, 1, Create.RANDOM.nextFloat() * .5f + .5f); } default void playRotateSound(World world, BlockPos pos) { - AllSoundEvents.WRENCH_ROTATE.playOnServer(world, pos, 1, Create.random.nextFloat() + .5f); + AllSoundEvents.WRENCH_ROTATE.playOnServer(world, pos, 1, Create.RANDOM.nextFloat() + .5f); } default BlockState getRotatedBlockState(BlockState originalState, Direction targetedFace) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java index f127b8b26..c7f3832a6 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java @@ -62,9 +62,9 @@ public class CopperBacktankArmorLayer { - CreateClient.outliner.endChasingLine(beam, beam.start, beam.end, 1 - beam.itensity) + CreateClient.OUTLINER.endChasingLine(beam, beam.start, beam.end, 1 - beam.itensity) .disableNormals() .colored(0xffffff) .lineWidth(beam.itensity * 1 / 8f); diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperRenderHandler.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperRenderHandler.java index 9edd53a8d..b048a5a6a 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperRenderHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperRenderHandler.java @@ -31,7 +31,7 @@ public class WorldshaperRenderHandler { if (renderedPositions == null) return; - CreateClient.outliner.showCluster("terrainZapper", renderedPositions.get()) + CreateClient.OUTLINER.showCluster("terrainZapper", renderedPositions.get()) .colored(0xbfbfbf) .disableNormals() .lineWidth(1 / 32f) diff --git a/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java b/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java index 910ef68d1..867a9edf5 100644 --- a/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java @@ -67,12 +67,12 @@ public class RedstoneLinkNetworkHandler { public void onLoadWorld(IWorld world) { connections.put(world, new HashMap<>()); - Create.logger.debug("Prepared Redstone Network Space for " + WorldHelper.getDimensionID(world)); + Create.LOGGER.debug("Prepared Redstone Network Space for " + WorldHelper.getDimensionID(world)); } public void onUnloadWorld(IWorld world) { connections.remove(world); - Create.logger.debug("Removed Redstone Network Space for " + WorldHelper.getDimensionID(world)); + Create.LOGGER.debug("Removed Redstone Network Space for " + WorldHelper.getDimensionID(world)); } public Set getNetworkOf(LinkBehaviour actor) { @@ -144,7 +144,7 @@ public class RedstoneLinkNetworkHandler { public Map, Set> networksIn(IWorld world) { if (!connections.containsKey(world)) { - Create.logger.warn( + Create.LOGGER.warn( "Tried to Access unprepared network space of " + WorldHelper.getDimensionID(world)); return new HashMap<>(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java index 701ca4566..b0c96b8b2 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java @@ -313,12 +313,12 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return; AirParticleData airParticleData = new AirParticleData(drag, motion); Vector3d origin = Vector3d.of(pos); - float xOff = Create.random.nextFloat() * .5f + .25f; - float zOff = Create.random.nextFloat() * .5f + .25f; + float xOff = Create.RANDOM.nextFloat() * .5f + .25f; + float zOff = Create.RANDOM.nextFloat() * .5f + .25f; Vector3d v = origin.add(xOff, verticalStart, zOff); Vector3d d = origin.add(xOff, verticalEnd, zOff) .subtract(v); - if (Create.random.nextFloat() < 2 * motion) + if (Create.RANDOM.nextFloat() < 2 * motion) world.addOptionalParticle(airParticleData, v.x, v.y, v.z, d.x, d.y, d.z); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTargetHandler.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTargetHandler.java index db730fdc6..5130a77d9 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTargetHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTargetHandler.java @@ -210,7 +210,7 @@ public class EjectorTargetHandler { ClientWorld world = mc.world; AxisAlignedBB bb = new AxisAlignedBB(0, 0, 0, 1, 0, 1).offset(currentSelection.add(-validX, -yDiff, -validZ)); - CreateClient.outliner.chaseAABB("valid", bb) + CreateClient.OUTLINER.chaseAABB("valid", bb) .colored(intColor) .lineWidth(1 / 16f); @@ -260,7 +260,7 @@ public class EjectorTargetHandler { BlockState state = world.getBlockState(pos); VoxelShape shape = state.getShape(world, pos); AxisAlignedBB boundingBox = shape.isEmpty() ? new AxisAlignedBB(BlockPos.ZERO) : shape.getBoundingBox(); - CreateClient.outliner.showAABB("target", boundingBox.offset(pos)) + CreateClient.OUTLINER.showAABB("target", boundingBox.offset(pos)) .colored(0xffcb74) .lineWidth(1 / 16f); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/SharedDepotBlockMethods.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/SharedDepotBlockMethods.java index 7470f7703..f5b1bee6f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/SharedDepotBlockMethods.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/SharedDepotBlockMethods.java @@ -53,7 +53,7 @@ public class SharedDepotBlockMethods { player.inventory.placeItemBackInInventory(world, mainItemStack); behaviour.removeHeldItem(); world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, .2f, - 1f + Create.random.nextFloat()); + 1f + Create.RANDOM.nextFloat()); } ItemStackHandler outputs = behaviour.processingOutputBuffer; for (int i = 0; i < outputs.getSlots(); i++) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateContainer.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateContainer.java index 5b7db777c..7e9e573eb 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateContainer.java @@ -7,6 +7,7 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; @@ -19,8 +20,8 @@ public class AdjustableCrateContainer extends Container { public PlayerInventory playerInventory; public boolean doubleCrate; - public AdjustableCrateContainer(int id, PlayerInventory inv, PacketBuffer extraData) { - super(AllContainerTypes.FLEXCRATE.type, id); + public AdjustableCrateContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + super(type, id); ClientWorld world = Minecraft.getInstance().world; TileEntity tileEntity = world.getTileEntity(extraData.readBlockPos()); this.playerInventory = inv; @@ -31,13 +32,17 @@ public class AdjustableCrateContainer extends Container { } } - public AdjustableCrateContainer(int id, PlayerInventory inv, AdjustableCrateTileEntity te) { - super(AllContainerTypes.FLEXCRATE.type, id); + public AdjustableCrateContainer(ContainerType type, int id, PlayerInventory inv, AdjustableCrateTileEntity te) { + super(type, id); this.te = te; this.playerInventory = inv; init(); } + public static AdjustableCrateContainer create(int id, PlayerInventory inv, AdjustableCrateTileEntity te) { + return new AdjustableCrateContainer(AllContainerTypes.FLEXCRATE.get(), id, inv, te); + } + private void init() { doubleCrate = te.isDoubleCrate(); int x = doubleCrate ? 51 : 123; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateTileEntity.java index ec986de25..6e20236cb 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/inventories/AdjustableCrateTileEntity.java @@ -72,7 +72,7 @@ public class AdjustableCrateTileEntity extends CrateTileEntity implements INamed @Override public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) { - return new AdjustableCrateContainer(id, inventory, this); + return AdjustableCrateContainer.create(id, inventory, this); } public AdjustableCrateTileEntity getOtherCrate() { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java index 1dfe270bf..38f4ac67d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java @@ -195,7 +195,7 @@ public class ArmInteractionPointHandler { continue; int color = point.mode == Mode.DEPOSIT ? 0xffcb74 : 0x4f8a8b; - CreateClient.outliner.showAABB(point, shape.getBoundingBox() + CreateClient.OUTLINER.showAABB(point, shape.getBoundingBox() .offset(pos)) .colored(color) .lineWidth(1 / 16f); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java index 0229882b3..5f86a4098 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java @@ -352,7 +352,7 @@ public class ArmTileEntity extends KineticTileEntity { if (!prevHeld.isItemEqual(heldItem)) world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, .125f, - .5f + Create.random.nextFloat() * .25f); + .5f + Create.RANDOM.nextFloat() * .25f); return; } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java index 8d4b209e8..589f1a9e3 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java @@ -9,6 +9,7 @@ import com.simibubi.create.foundation.utility.Pair; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ClickType; +import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -30,12 +31,16 @@ public class AttributeFilterContainer extends AbstractFilterContainer { WhitelistMode whitelistMode; List> selectedAttributes; - public AttributeFilterContainer(int id, PlayerInventory inv, PacketBuffer extraData) { - super(AllContainerTypes.ATTRIBUTE_FILTER.type, id, inv, extraData); + public AttributeFilterContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + super(type, id, inv, extraData); } - public AttributeFilterContainer(int id, PlayerInventory inv, ItemStack stack) { - super(AllContainerTypes.ATTRIBUTE_FILTER.type, id, inv, stack); + public AttributeFilterContainer(ContainerType type, int id, PlayerInventory inv, ItemStack stack) { + super(type, id, inv, stack); + } + + public static AttributeFilterContainer create(int id, PlayerInventory inv, ItemStack stack) { + return new AttributeFilterContainer(AllContainerTypes.ATTRIBUTE_FILTER.get(), id, inv, stack); } public void appendSelectedAttribute(ItemAttribute itemAttribute, boolean inverted) { diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterContainer.java index c14b007fe..7df7b0853 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterContainer.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.item.filter; import com.simibubi.create.AllContainerTypes; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; @@ -14,12 +15,16 @@ public class FilterContainer extends AbstractFilterContainer { boolean respectNBT; boolean blacklist; - public FilterContainer(int id, PlayerInventory inv, PacketBuffer extraData) { - super(AllContainerTypes.FILTER.type, id, inv, extraData); + public FilterContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + super(type, id, inv, extraData); } - public FilterContainer(int id, PlayerInventory inv, ItemStack stack) { - super(AllContainerTypes.FILTER.type, id, inv, stack); + public FilterContainer(ContainerType type, int id, PlayerInventory inv, ItemStack stack) { + super(type, id, inv, stack); + } + + public static FilterContainer create(int id, PlayerInventory inv, ItemStack stack) { + return new FilterContainer(AllContainerTypes.FILTER.get(), id, inv, stack); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java index 16d7dcdf2..7daabaf5f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterItem.java @@ -157,9 +157,9 @@ public class FilterItem extends Item implements INamedContainerProvider { public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { ItemStack heldItem = player.getHeldItemMainhand(); if (type == FilterType.REGULAR) - return new FilterContainer(id, inv, heldItem); + return FilterContainer.create(id, inv, heldItem); if (type == FilterType.ATTRIBUTE) - return new AttributeFilterContainer(id, inv, heldItem); + return AttributeFilterContainer.create(id, inv, heldItem); return null; } diff --git a/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java b/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java index dfb730b13..b3042abf2 100644 --- a/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java +++ b/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java @@ -36,7 +36,7 @@ import net.minecraftforge.common.Tags; public class AllPaletteBlocks { private static final CreateRegistrate REGISTRATE = Create.registrate() - .itemGroup(() -> Create.palettesCreativeTab) + .itemGroup(() -> Create.PALETTES_CREATIVE_TAB) .startSection(AllSections.PALETTES); // Windows and Glass diff --git a/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java b/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java index 9ddd18729..0416a9acd 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java +++ b/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java @@ -59,7 +59,7 @@ public class ClientSchematicLoader { Path path = Paths.get("schematics", schematic); if (!Files.exists(path)) { - Create.logger.fatal("Missing Schematic file: " + path.toString()); + Create.LOGGER.fatal("Missing Schematic file: " + path.toString()); return; } diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java index e60bb7a40..f839edd24 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java @@ -104,7 +104,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } return tileEntity; } catch (Exception e) { - Create.logger.debug("Could not create TE of block " + blockState + ": " + e); + Create.LOGGER.debug("Could not create TE of block " + blockState + ": " + e); } } return null; diff --git a/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java b/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java index f6750f506..151fdaf08 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java +++ b/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java @@ -72,7 +72,7 @@ public class ServerSchematicLoader { SchematicUploadEntry entry = activeUploads.get(upload); if (entry.idleTime++ > getConfig().schematicIdleTimeout.get()) { - Create.logger.warn("Schematic Upload timed out: " + upload); + Create.LOGGER.warn("Schematic Upload timed out: " + upload); deadEntries.add(upload); } @@ -94,7 +94,7 @@ public class ServerSchematicLoader { // Unsupported Format if (!schematic.endsWith(".nbt")) { - Create.logger.warn("Attempted Schematic Upload with non-supported Format: " + playerSchematicId); + Create.LOGGER.warn("Attempted Schematic Upload with non-supported Format: " + playerSchematicId); return; } @@ -102,7 +102,7 @@ public class ServerSchematicLoader { Path uploadPath = playerSchematicsPath.resolve(schematic).normalize(); if (!uploadPath.startsWith(playerSchematicsPath)) { - Create.logger.warn("Attempted Schematic Upload with directory escape: {}", playerSchematicId); + Create.LOGGER.warn("Attempted Schematic Upload with directory escape: {}", playerSchematicId); return; } @@ -148,7 +148,7 @@ public class ServerSchematicLoader { table.startUpload(schematic); } catch (IOException e) { - Create.logger.error("Exception Thrown when starting Upload: " + playerSchematicId); + Create.LOGGER.error("Exception Thrown when starting Upload: " + playerSchematicId); e.printStackTrace(); } } @@ -178,13 +178,13 @@ public class ServerSchematicLoader { // Size Validations if (data.length > getConfig().maxSchematicPacketSize.get()) { - Create.logger.warn("Oversized Upload Packet received: " + playerSchematicId); + Create.LOGGER.warn("Oversized Upload Packet received: " + playerSchematicId); cancelUpload(playerSchematicId); return; } if (entry.bytesUploaded > entry.totalBytes) { - Create.logger.warn("Received more data than Expected: " + playerSchematicId); + Create.LOGGER.warn("Received more data than Expected: " + playerSchematicId); cancelUpload(playerSchematicId); return; } @@ -200,7 +200,7 @@ public class ServerSchematicLoader { table.sendUpdate = true; } catch (IOException e) { - Create.logger.error("Exception Thrown when uploading Schematic: " + playerSchematicId); + Create.LOGGER.error("Exception Thrown when uploading Schematic: " + playerSchematicId); e.printStackTrace(); cancelUpload(playerSchematicId); } @@ -215,10 +215,10 @@ public class ServerSchematicLoader { try { entry.stream.close(); Files.deleteIfExists(Paths.get(getSchematicPath(), playerSchematicId)); - Create.logger.warn("Cancelled Schematic Upload: " + playerSchematicId); + Create.LOGGER.warn("Cancelled Schematic Upload: " + playerSchematicId); } catch (IOException e) { - Create.logger.error("Exception Thrown when cancelling Upload: " + playerSchematicId); + Create.LOGGER.error("Exception Thrown when cancelling Upload: " + playerSchematicId); e.printStackTrace(); } @@ -249,7 +249,7 @@ public class ServerSchematicLoader { World world = removed.world; BlockPos pos = removed.tablePos; - Create.logger.info("New Schematic Uploaded: " + playerSchematicId); + Create.LOGGER.info("New Schematic Uploaded: " + playerSchematicId); if (pos == null) return; @@ -264,7 +264,7 @@ public class ServerSchematicLoader { table.inventory.setStackInSlot(1, SchematicItem.create(schematic, player.getGameProfile().getName())); } catch (IOException e) { - Create.logger.error("Exception Thrown when finishing Upload: " + playerSchematicId); + Create.LOGGER.error("Exception Thrown when finishing Upload: " + playerSchematicId); e.printStackTrace(); } } @@ -278,7 +278,7 @@ public class ServerSchematicLoader { // Unsupported Format if (!schematic.endsWith(".nbt")) { - Create.logger.warn("Attempted Schematic Upload with non-supported Format: {}", playerSchematicId); + Create.LOGGER.warn("Attempted Schematic Upload with non-supported Format: {}", playerSchematicId); return; } @@ -286,7 +286,7 @@ public class ServerSchematicLoader { Path path = schematicPath.resolve(playerSchematicId).normalize(); if (!path.startsWith(schematicPath)) { - Create.logger.warn("Attempted Schematic Upload with directory escape: {}", playerSchematicId); + Create.LOGGER.warn("Attempted Schematic Upload with directory escape: {}", playerSchematicId); return; } @@ -326,7 +326,7 @@ public class ServerSchematicLoader { e.printStackTrace(); } } catch (IOException e) { - Create.logger.error("Exception Thrown in direct Schematic Upload: " + playerSchematicId); + Create.LOGGER.error("Exception Thrown in direct Schematic Upload: " + playerSchematicId); e.printStackTrace(); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableContainer.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableContainer.java index fe9bf1dea..e7818d11f 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableContainer.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableContainer.java @@ -8,6 +8,7 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; @@ -21,8 +22,8 @@ public class SchematicTableContainer extends Container { private Slot outputSlot; private PlayerEntity player; - public SchematicTableContainer(int id, PlayerInventory inv, PacketBuffer extraData) { - super(AllContainerTypes.SCHEMATIC_TABLE.type, id); + public SchematicTableContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + super(type, id); player = inv.player; ClientWorld world = Minecraft.getInstance().world; TileEntity tileEntity = world.getTileEntity(extraData.readBlockPos()); @@ -33,13 +34,17 @@ public class SchematicTableContainer extends Container { } } - public SchematicTableContainer(int id, PlayerInventory inv, SchematicTableTileEntity te) { - super(AllContainerTypes.SCHEMATIC_TABLE.type, id); + public SchematicTableContainer(ContainerType type, int id, PlayerInventory inv, SchematicTableTileEntity te) { + super(type, id); this.player = inv.player; this.te = te; init(); } + public static SchematicTableContainer create(int id, PlayerInventory inv, SchematicTableTileEntity te) { + return new SchematicTableContainer(AllContainerTypes.SCHEMATIC_TABLE.get(), id, inv, te); + } + protected void init() { inputSlot = new SlotItemHandler(te.inventory, 0, -35, 41) { @Override diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java index 93b98c4b7..12149b84a 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java @@ -68,8 +68,8 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = CreateClient.schematicSender.getAvailableSchematics(); + CreateClient.SCHEMATIC_SENDER.refresh(); + List availableSchematics = CreateClient.SCHEMATIC_SENDER.getAvailableSchematics(); schematicsLabel = new Label(mainLeft + 49, mainTop + 26, StringTextComponent.EMPTY).withShadow(); schematicsLabel.text = StringTextComponent.EMPTY; @@ -176,7 +176,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen type, int id, PlayerInventory inv, PacketBuffer buffer) { + super(type, id); player = inv.player; ClientWorld world = Minecraft.getInstance().world; TileEntity tileEntity = world.getTileEntity(buffer.readBlockPos()); @@ -30,13 +31,17 @@ public class SchematicannonContainer extends Container { } } - public SchematicannonContainer(int id, PlayerInventory inv, SchematicannonTileEntity te) { - super(AllContainerTypes.SCHEMATICANNON.type, id); + public SchematicannonContainer(ContainerType type, int id, PlayerInventory inv, SchematicannonTileEntity te) { + super(type, id); player = inv.player; this.te = te; init(); } + public static SchematicannonContainer create(int id, PlayerInventory inv, SchematicannonTileEntity te) { + return new SchematicannonContainer(AllContainerTypes.SCHEMATICANNON.get(), id, inv, te); + } + protected void init() { int x = 20; int y = 0; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index ef443d62d..85f60d001 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -28,8 +28,6 @@ import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode; import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; -import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.IPartialSafeNBT; import com.simibubi.create.foundation.utility.Iterate; @@ -934,7 +932,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC @Override public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { - return new SchematicannonContainer(id, inv, this); + return SchematicannonContainer.create(id, inv, this); } @Override diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java index aee90c939..af0624b67 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java @@ -239,7 +239,7 @@ public class SchematicAndQuillHandler { if (!convertImmediately) return; if (!Files.exists(path)) { - Create.logger.fatal("Missing Schematic file: " + path.toString()); + Create.LOGGER.fatal("Missing Schematic file: " + path.toString()); return; } try { @@ -248,14 +248,14 @@ public class SchematicAndQuillHandler { AllPackets.channel.sendToServer(new InstantSchematicPacket(filename, origin, bounds)); } catch (IOException e) { - Create.logger.fatal("Error finding Schematic file: " + path.toString()); + Create.LOGGER.fatal("Error finding Schematic file: " + path.toString()); e.printStackTrace(); return; } } private Outliner outliner() { - return CreateClient.outliner; + return CreateClient.OUTLINER; } } \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java index b775572c0..316d00746 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java @@ -50,7 +50,7 @@ public class SchematicEditScreen extends AbstractSimiScreen { setWindowSize(background.width + 50, background.height); int x = guiLeft; int y = guiTop; - handler = CreateClient.schematicHandler; + handler = CreateClient.SCHEMATIC_HANDLER; xInput = new TextFieldWidget(textRenderer, x + 50, y + 26, 34, 10, StringTextComponent.EMPTY); yInput = new TextFieldWidget(textRenderer, x + 90, y + 26, 34, 10, StringTextComponent.EMPTY); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicPromptScreen.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicPromptScreen.java index 1738b233e..ce7cd33df 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicPromptScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicPromptScreen.java @@ -90,7 +90,7 @@ public class SchematicPromptScreen extends AbstractSimiScreen { return true; } if (abort.isHovered()) { - CreateClient.schematicAndQuillHandler.discard(); + CreateClient.SCHEMATIC_AND_QUILL_HANDLER.discard(); Minecraft.getInstance().player.closeScreen(); return true; } @@ -102,7 +102,7 @@ public class SchematicPromptScreen extends AbstractSimiScreen { } private void confirm(boolean convertImmediately) { - CreateClient.schematicAndQuillHandler.saveSchematic(nameField.getText(), convertImmediately); + CreateClient.SCHEMATIC_AND_QUILL_HANDLER.saveSchematic(nameField.getText(), convertImmediately); Minecraft.getInstance().player.closeScreen(); } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java index 0a60b3433..bbfa5163c 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/SchematicToolBase.java @@ -45,7 +45,7 @@ public abstract class SchematicToolBase implements ISchematicTool { @Override public void init() { - schematicHandler = CreateClient.schematicHandler; + schematicHandler = CreateClient.SCHEMATIC_HANDLER; selectedPos = null; selectedFace = null; schematicSelected = false; diff --git a/src/main/java/com/simibubi/create/content/schematics/packet/InstantSchematicPacket.java b/src/main/java/com/simibubi/create/content/schematics/packet/InstantSchematicPacket.java index 30a4fdcba..cf7f60e3b 100644 --- a/src/main/java/com/simibubi/create/content/schematics/packet/InstantSchematicPacket.java +++ b/src/main/java/com/simibubi/create/content/schematics/packet/InstantSchematicPacket.java @@ -43,7 +43,7 @@ public class InstantSchematicPacket extends SimplePacketBase { .getSender(); if (player == null) return; - Create.schematicReceiver.handleInstantSchematic(player, name, player.world, origin, bounds); + Create.SCHEMATIC_RECEIVER.handleInstantSchematic(player, name, player.world, origin, bounds); }); context.get() .setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicUploadPacket.java b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicUploadPacket.java index b8c37ac39..0b945ebb7 100644 --- a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicUploadPacket.java +++ b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicUploadPacket.java @@ -73,12 +73,12 @@ public class SchematicUploadPacket extends SimplePacketBase { if (code == BEGIN) { BlockPos pos = ((SchematicTableContainer) player.openContainer).getTileEntity() .getPos(); - Create.schematicReceiver.handleNewUpload(player, schematic, size, pos); + Create.SCHEMATIC_RECEIVER.handleNewUpload(player, schematic, size, pos); } if (code == WRITE) - Create.schematicReceiver.handleWriteRequest(player, schematic, data); + Create.SCHEMATIC_RECEIVER.handleWriteRequest(player, schematic, data); if (code == FINISH) - Create.schematicReceiver.handleFinishedUpload(player, schematic); + Create.SCHEMATIC_RECEIVER.handleFinishedUpload(player, schematic); }); context.get() .setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index aa9db5918..37c126432 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -110,9 +110,9 @@ public class ClientEvents { FastRenderDispatcher.tick(); ScrollValueHandler.tick(); - CreateClient.schematicSender.tick(); - CreateClient.schematicAndQuillHandler.tick(); - CreateClient.schematicHandler.tick(); + CreateClient.SCHEMATIC_SENDER.tick(); + CreateClient.SCHEMATIC_AND_QUILL_HANDLER.tick(); + CreateClient.SCHEMATIC_HANDLER.tick(); ContraptionHandler.tick(world); CapabilityMinecartController.tick(world); @@ -137,8 +137,8 @@ public class ClientEvents { ArmInteractionPointHandler.tick(); EjectorTargetHandler.tick(); PlacementHelpers.tick(); - CreateClient.outliner.tickOutlines(); - CreateClient.ghostBlocks.tickGhosts(); + CreateClient.OUTLINER.tickOutlines(); + CreateClient.GHOST_BLOCKS.tickGhosts(); ContraptionRenderDispatcher.tick(); } @@ -153,7 +153,7 @@ public class ClientEvents { if (world.isRemote() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) { CreateClient.invalidateRenderers(world); AnimationTickHolder.reset(); - KineticRenderer renderer = CreateClient.kineticRenderer.get(world); + KineticRenderer renderer = CreateClient.KINETIC_RENDERER.get(world); renderer.invalidate(); ((ClientWorld) world).loadedTileEntityList.forEach(renderer::add); } @@ -187,10 +187,10 @@ public class ClientEvents { SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance(); CouplingRenderer.renderAll(ms, buffer); - CreateClient.schematicHandler.render(ms, buffer); - CreateClient.ghostBlocks.renderAll(ms, buffer); + CreateClient.SCHEMATIC_HANDLER.render(ms, buffer); + CreateClient.GHOST_BLOCKS.renderAll(ms, buffer); - CreateClient.outliner.renderOutlines(ms, buffer, pt); + CreateClient.OUTLINER.renderOutlines(ms, buffer, pt); // LightVolumeDebugger.render(ms, buffer); buffer.draw(); RenderSystem.enableCull(); @@ -220,7 +220,7 @@ public class ClientEvents { public static void onRenderHotbar(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, float partialTicks) { - CreateClient.schematicHandler.renderOverlay(ms, buffer, light, overlay, partialTicks); + CreateClient.SCHEMATIC_HANDLER.renderOverlay(ms, buffer, light, overlay, partialTicks); } @SubscribeEvent diff --git a/src/main/java/com/simibubi/create/events/CommonEvents.java b/src/main/java/com/simibubi/create/events/CommonEvents.java index dfcb926a4..7fcd4f57a 100644 --- a/src/main/java/com/simibubi/create/events/CommonEvents.java +++ b/src/main/java/com/simibubi/create/events/CommonEvents.java @@ -10,7 +10,6 @@ import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipe import com.simibubi.create.content.contraptions.wrench.WrenchItem; import com.simibubi.create.content.curiosities.zapper.ZapperInteractionHandler; import com.simibubi.create.content.curiosities.zapper.ZapperItem; -import com.simibubi.create.content.schematics.ServerSchematicLoader; import com.simibubi.create.foundation.command.AllCommands; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.utility.Iterate; @@ -54,10 +53,8 @@ public class CommonEvents { public static void onServerTick(ServerTickEvent event) { if (event.phase == Phase.START) return; - if (Create.schematicReceiver == null) - Create.schematicReceiver = new ServerSchematicLoader(); - Create.schematicReceiver.tick(); - Create.lagger.tick(); + Create.SCHEMATIC_RECEIVER.tick(); + Create.LAGGER.tick(); ServerSpeedProvider.serverTick(); } @@ -133,21 +130,21 @@ public class CommonEvents { @SubscribeEvent public static void serverStopped(FMLServerStoppingEvent event) { - Create.schematicReceiver.shutdown(); + Create.SCHEMATIC_RECEIVER.shutdown(); } @SubscribeEvent public static void onLoadWorld(WorldEvent.Load event) { IWorld world = event.getWorld(); - Create.redstoneLinkNetworkHandler.onLoadWorld(world); - Create.torquePropagator.onLoadWorld(world); + Create.REDSTONE_LINK_NETWORK_HANDLER.onLoadWorld(world); + Create.TORQUE_PROPAGATOR.onLoadWorld(world); } @SubscribeEvent public static void onUnloadWorld(WorldEvent.Unload event) { IWorld world = event.getWorld(); - Create.redstoneLinkNetworkHandler.onUnloadWorld(world); - Create.torquePropagator.onUnloadWorld(world); + Create.REDSTONE_LINK_NETWORK_HANDLER.onUnloadWorld(world); + Create.TORQUE_PROPAGATOR.onUnloadWorld(world); WorldAttached.invalidateWorld(world); } diff --git a/src/main/java/com/simibubi/create/events/InputEvents.java b/src/main/java/com/simibubi/create/events/InputEvents.java index 7447b0a94..07ba796a5 100644 --- a/src/main/java/com/simibubi/create/events/InputEvents.java +++ b/src/main/java/com/simibubi/create/events/InputEvents.java @@ -23,7 +23,7 @@ public class InputEvents { if (Minecraft.getInstance().currentScreen != null) return; - CreateClient.schematicHandler.onKeyInput(key, pressed); + CreateClient.SCHEMATIC_HANDLER.onKeyInput(key, pressed); } @SubscribeEvent @@ -33,8 +33,8 @@ public class InputEvents { double delta = event.getScrollDelta(); // CollisionDebugger.onScroll(delta); - boolean cancelled = CreateClient.schematicHandler.mouseScrolled(delta) - || CreateClient.schematicAndQuillHandler.mouseScrolled(delta) || FilteringHandler.onScroll(delta) + boolean cancelled = CreateClient.SCHEMATIC_HANDLER.mouseScrolled(delta) + || CreateClient.SCHEMATIC_AND_QUILL_HANDLER.mouseScrolled(delta) || FilteringHandler.onScroll(delta) || ScrollValueHandler.onScroll(delta); event.setCanceled(cancelled); } @@ -47,8 +47,8 @@ public class InputEvents { int button = event.getButton(); boolean pressed = !(event.getAction() == 0); - CreateClient.schematicHandler.onMouseInput(button, pressed); - CreateClient.schematicAndQuillHandler.onMouseInput(button, pressed); + CreateClient.SCHEMATIC_HANDLER.onMouseInput(button, pressed); + CreateClient.SCHEMATIC_AND_QUILL_HANDLER.onMouseInput(button, pressed); } } diff --git a/src/main/java/com/simibubi/create/foundation/block/ITE.java b/src/main/java/com/simibubi/create/foundation/block/ITE.java index 8054544e8..1bc0863c9 100644 --- a/src/main/java/com/simibubi/create/foundation/block/ITE.java +++ b/src/main/java/com/simibubi/create/foundation/block/ITE.java @@ -97,7 +97,7 @@ public interface ITE { static void report(TileEntityException e) { if (AllConfigs.COMMON.logTeErrors.get()) - Create.logger.debug("TileEntityException thrown!", e); + Create.LOGGER.debug("TileEntityException thrown!", e); } } diff --git a/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java b/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java index 4a67e3d82..4d174e697 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ChunkUtilCommand.java @@ -26,7 +26,7 @@ public class ChunkUtilCommand { .getWorld() .getChunkProvider(); - boolean success = Create.chunkUtil.reloadChunk(chunkProvider, chunkPos); + boolean success = Create.CHUNK_UTIL.reloadChunk(chunkProvider, chunkPos); if (success) { ctx.getSource() @@ -52,7 +52,7 @@ public class ChunkUtilCommand { .getWorld() .getChunkProvider(); - boolean success = Create.chunkUtil.unloadChunk(chunkProvider, chunkPos); + boolean success = Create.CHUNK_UTIL.unloadChunk(chunkProvider, chunkPos); ctx.getSource() .sendFeedback( new StringTextComponent("added chunk " + chunkPos.toString() + " to unload list"), @@ -75,7 +75,7 @@ public class ChunkUtilCommand { .then(Commands.literal("clear") .executes(ctx -> { // chunk clear - int count = Create.chunkUtil.clear(ctx.getSource() + int count = Create.CHUNK_UTIL.clear(ctx.getSource() .getWorld() .getChunkProvider()); ctx.getSource() diff --git a/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java b/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java index a66bbb06e..126f93010 100644 --- a/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java +++ b/src/main/java/com/simibubi/create/foundation/command/HighlightPacket.java @@ -48,7 +48,7 @@ public class HighlightPacket extends SimplePacketBase { if (Minecraft.getInstance().world == null || !Minecraft.getInstance().world.isBlockPresent(pos)) return; - CreateClient.outliner.showAABB("highlightCommand", VoxelShapes.fullCube() + CreateClient.OUTLINER.showAABB("highlightCommand", VoxelShapes.fullCube() .getBoundingBox() .offset(pos), 200) .lineWidth(1 / 32f) diff --git a/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java b/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java index 22ecbce81..2df4f9e06 100644 --- a/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/KillTPSCommand.java @@ -17,8 +17,8 @@ public class KillTPSCommand { // killtps no arguments ctx.getSource() .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.0", - Create.lagger.isLagging() ? Create.lagger.getTickTime() : 0), true); - if (Create.lagger.isLagging()) + Create.LAGGER.isLagging() ? Create.LAGGER.getTickTime() : 0), true); + if (Create.LAGGER.isLagging()) ctx.getSource() .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.usage.0"), true); @@ -32,9 +32,9 @@ public class KillTPSCommand { .then(Commands.literal("start") .executes(ctx -> { // killtps start no time - int tickTime = Create.lagger.getTickTime(); + int tickTime = Create.LAGGER.getTickTime(); if (tickTime > 0) { - Create.lagger.setLagging(true); + Create.LAGGER.setLagging(true); ctx.getSource() .sendFeedback((Lang .createTranslationTextComponent("command.killTPSCommand.status.slowed_by.1", tickTime)), @@ -57,8 +57,8 @@ public class KillTPSCommand { int tickTime = IntegerArgumentType.getInteger(ctx, Lang.translate("command.killTPSCommand.argument.tickTime") .getUnformattedComponentText()); - Create.lagger.setTickTime(tickTime); - Create.lagger.setLagging(true); + Create.LAGGER.setTickTime(tickTime); + Create.LAGGER.setLagging(true); ctx.getSource() .sendFeedback((Lang .createTranslationTextComponent("command.killTPSCommand.status.slowed_by.1", tickTime)), @@ -72,7 +72,7 @@ public class KillTPSCommand { .then(Commands.literal("stop") .executes(ctx -> { // killtps stop - Create.lagger.setLagging(false); + Create.LAGGER.setLagging(false); ctx.getSource() .sendFeedback(Lang.createTranslationTextComponent("command.killTPSCommand.status.slowed_by.2"), false); diff --git a/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java b/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java index c1dcd3105..d4e1a6115 100644 --- a/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java @@ -170,7 +170,7 @@ public class SConfigureConfigPacket extends SimplePacketBase { ResourceLocation id = new ResourceLocation(value); if (!PonderRegistry.all.containsKey(id)) { - Create.logger.error("Could not find ponder scenes for item: " + id); + Create.LOGGER.error("Could not find ponder scenes for item: " + id); return; } diff --git a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java index 06851d0f3..c9c591f76 100644 --- a/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java +++ b/src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java @@ -17,6 +17,7 @@ import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivit import com.simibubi.create.foundation.block.IBlockVertexColor; import com.simibubi.create.foundation.block.connected.CTModel; import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour; +import com.simibubi.create.foundation.block.render.ColoredVertexModel; import com.simibubi.create.foundation.block.render.CustomRenderedItemModel; import com.tterrag.registrate.AbstractRegistrate; import com.tterrag.registrate.builders.BlockBuilder; @@ -222,6 +223,12 @@ public class CreateRegistrate extends AbstractRegistrate { consumer.accept(entry, CreateClient.getCasingConnectivity()); } + @OnlyIn(Dist.CLIENT) + private static void registerBlockVertexColor(Block entry, IBlockVertexColor colorFunc) { + CreateClient.getCustomBlockModels() + .register(entry.delegate, model -> new ColoredVertexModel(model, colorFunc)); + } + @OnlyIn(Dist.CLIENT) private static void registerBlockModel(Block entry, Supplier> func) { @@ -250,12 +257,6 @@ public class CreateRegistrate extends AbstractRegistrate { .get()); } - @OnlyIn(Dist.CLIENT) - private static void registerBlockVertexColor(Block entry, IBlockVertexColor colorFunc) { - CreateClient.getColorHandler() - .register(entry, colorFunc); - } - @OnlyIn(Dist.CLIENT) private static void registerItemColor(IItemProvider entry, Supplier> colorFunc) { CreateClient.getColorHandler() diff --git a/src/main/java/com/simibubi/create/foundation/data/LangMerger.java b/src/main/java/com/simibubi/create/foundation/data/LangMerger.java index a4426a706..b1f717bfa 100644 --- a/src/main/java/com/simibubi/create/foundation/data/LangMerger.java +++ b/src/main/java/com/simibubi/create/foundation/data/LangMerger.java @@ -119,7 +119,7 @@ public class LangMerger implements IDataProvider { private void collectExistingEntries(Path path) throws IOException { if (!Files.exists(path)) { - Create.logger.warn("Nothing to merge! It appears no lang was generated before me."); + Create.LOGGER.warn("Nothing to merge! It appears no lang was generated before me."); return; } @@ -237,7 +237,7 @@ public class LangMerger implements IDataProvider { Files.createDirectories(target.getParent()); try (BufferedWriter bufferedwriter = Files.newBufferedWriter(target)) { - Create.logger.info(message); + Create.LOGGER.info(message); bufferedwriter.write(data); bufferedwriter.close(); } diff --git a/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java b/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java index d26ee4d42..3f5f87671 100644 --- a/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java +++ b/src/main/java/com/simibubi/create/foundation/data/recipe/CreateRecipeProvider.java @@ -29,7 +29,7 @@ public abstract class CreateRecipeProvider extends RecipeProvider { @Override protected void registerRecipes(Consumer p_200404_1_) { all.forEach(c -> c.register(p_200404_1_)); - Create.logger.info(getName() + " registered " + all.size() + " recipe" + (all.size() == 1 ? "" : "s")); + Create.LOGGER.info(getName() + " registered " + all.size() + " recipe" + (all.size() == 1 ? "" : "s")); } @FunctionalInterface diff --git a/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java index 440a3f68b..ed7fc9b9d 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/LightUpdateMixin.java @@ -46,7 +46,7 @@ public abstract class LightUpdateMixin extends AbstractChunkProvider { .getY()) == sectionY) .map(Map.Entry::getValue) .forEach(tile -> { - CreateClient.kineticRenderer.get(world) + CreateClient.KINETIC_RENDERER.get(world) .onLightUpdate(tile); }); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java index 06ddf0c30..3ee6ae33f 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/NetworkLightUpdateMixin.java @@ -36,7 +36,7 @@ public class NetworkLightUpdateMixin { chunk.getTileEntityMap() .values() .forEach(tile -> { - CreateClient.kineticRenderer.get(world) + CreateClient.KINETIC_RENDERER.get(world) .onLightUpdate(tile); }); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java index da41425e6..e36d48104 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/RenderHooksMixin.java @@ -67,14 +67,14 @@ public class RenderHooksMixin { double camY = cameraPos.getY(); double camZ = cameraPos.getZ(); - CreateClient.kineticRenderer.get(world) + CreateClient.KINETIC_RENDERER.get(world) .beginFrame(info, camX, camY, camZ); ContraptionRenderDispatcher.beginFrame(info, camX, camY, camZ); } @Inject(at = @At("TAIL"), method = "scheduleBlockRerenderIfNeeded") private void checkUpdate(BlockPos pos, BlockState lastState, BlockState newState, CallbackInfo ci) { - CreateClient.kineticRenderer.get(world) + CreateClient.KINETIC_RENDERER.get(world) .update(world.getTileEntity(pos)); } @@ -85,7 +85,7 @@ public class RenderHooksMixin { Backend.refresh(); if (Backend.canUseInstancing() && world != null) { - KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + KineticRenderer kineticRenderer = CreateClient.KINETIC_RENDERER.get(world); kineticRenderer.invalidate(); world.loadedTileEntityList.forEach(kineticRenderer::add); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java index b2907a127..2af03c59c 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/TileRemoveMixin.java @@ -24,7 +24,7 @@ public class TileRemoveMixin { @Inject(at = @At("TAIL"), method = "remove") private void onRemove(CallbackInfo ci) { if (world instanceof ClientWorld) - CreateClient.kineticRenderer.get(this.world) + CreateClient.KINETIC_RENDERER.get(this.world) .remove((TileEntity) (Object) this); } } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java index a50fbc6ec..ca87888b8 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/TileWorldHookMixin.java @@ -35,7 +35,7 @@ public class TileWorldHookMixin { @Inject(at = @At("TAIL"), method = "addTileEntity") private void onAddTile(TileEntity te, CallbackInfoReturnable cir) { if (isRemote) { - CreateClient.kineticRenderer.get(self) + CreateClient.KINETIC_RENDERER.get(self) .queueAdd(te); } } @@ -46,7 +46,7 @@ public class TileWorldHookMixin { @Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities") private void onChunkUnload(CallbackInfo ci) { if (isRemote) { - KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(self); + KineticRenderer kineticRenderer = CreateClient.KINETIC_RENDERER.get(self); for (TileEntity tile : tileEntitiesToBeRemoved) { kineticRenderer.remove(tile); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java index 412eb6ae8..06348383c 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderRegistry.java @@ -113,7 +113,7 @@ public class PonderRegistry { InputStream resourceAsStream = Create.class.getClassLoader() .getResourceAsStream(filepath); if (resourceAsStream == null) { - Create.logger.error("Ponder schematic missing: " + path); + Create.LOGGER.error("Ponder schematic missing: " + path); return t; } try (DataInputStream stream = @@ -121,7 +121,7 @@ public class PonderRegistry { CompoundNBT nbt = CompressedStreamTools.read(stream, new NBTSizeTracker(0x20000000L)); t.read(nbt); } catch (IOException e) { - Create.logger.warn("Failed to read ponder schematic", e); + Create.LOGGER.warn("Failed to read ponder schematic", e); } return t; } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java index 7456ff92b..b43efb782 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java @@ -143,7 +143,7 @@ public class ParrotElement extends AnimatedSceneElement { ParrotEntity create(PonderWorld world) { ParrotEntity entity = new ParrotEntity(EntityType.PARROT, world); - int nextInt = Create.random.nextInt(5); + int nextInt = Create.RANDOM.nextInt(5); entity.setVariant(nextInt == 1 ? 0 : nextInt); // blue parrots are kinda hard to see return entity; } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java index 2f9c86278..5862087bf 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java @@ -329,7 +329,7 @@ public class WorldSectionElement extends AnimatedSceneElement { protected void renderStructure(PonderWorld world, MatrixStack ms, IRenderTypeBuffer buffer, RenderType type, float fade) { - SuperByteBufferCache bufferCache = CreateClient.bufferCache; + SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE; int code = hashCode() ^ world.hashCode(); Pair key = Pair.of(code, RenderType.getBlockLayers() diff --git a/src/main/java/com/simibubi/create/foundation/ponder/instructions/EmitParticlesInstruction.java b/src/main/java/com/simibubi/create/foundation/ponder/instructions/EmitParticlesInstruction.java index 176e79b05..655a08b72 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/instructions/EmitParticlesInstruction.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/instructions/EmitParticlesInstruction.java @@ -23,8 +23,8 @@ public class EmitParticlesInstruction extends TickingInstruction { } public static Emitter withinBlockSpace(T data, Vector3d motion) { - return (w, x, y, z) -> w.addParticle(data, Math.floor(x) + Create.random.nextFloat(), - Math.floor(y) + Create.random.nextFloat(), Math.floor(z) + Create.random.nextFloat(), motion.x, + return (w, x, y, z) -> w.addParticle(data, Math.floor(x) + Create.RANDOM.nextFloat(), + Math.floor(y) + Create.RANDOM.nextFloat(), Math.floor(z) + Create.RANDOM.nextFloat(), motion.x, motion.y, motion.z); } @@ -47,7 +47,7 @@ public class EmitParticlesInstruction extends TickingInstruction { public void tick(PonderScene scene) { super.tick(scene); int runs = (int) runsPerTick; - if (Create.random.nextFloat() < (runsPerTick - runs)) + if (Create.RANDOM.nextFloat() < (runsPerTick - runs)) runs++; for (int i = 0; i < runs; i++) emitter.create(scene.getWorld(), anchor.x, anchor.y, anchor.z); diff --git a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java index 4ed176c64..bc560bb94 100644 --- a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java +++ b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java @@ -16,7 +16,7 @@ import net.minecraft.util.Direction; public class PartialBufferer { public static SuperByteBuffer get(PartialModel partial, BlockState referenceState) { - return CreateClient.bufferCache.renderPartial(partial, referenceState); + return CreateClient.BUFFER_CACHE.renderPartial(partial, referenceState); } public static SuperByteBuffer getFacing(PartialModel partial, BlockState referenceState) { @@ -25,7 +25,7 @@ public class PartialBufferer { } public static SuperByteBuffer getFacing(PartialModel partial, BlockState referenceState, Direction facing) { - return CreateClient.bufferCache.renderDirectionalPartial(partial, referenceState, facing, rotateToFace(facing)); + return CreateClient.BUFFER_CACHE.renderDirectionalPartial(partial, referenceState, facing, rotateToFace(facing)); } public static Supplier rotateToFace(Direction facing) { diff --git a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java index efbf65cff..4ddfa57e9 100644 --- a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java @@ -73,9 +73,9 @@ public class TileEntityRenderHelper { .getRegistryName() .toString() + " didn't want to render while moved.\n"; if (AllConfigs.CLIENT.explainRenderErrors.get()) - Create.logger.error(message, e); + Create.LOGGER.error(message, e); else - Create.logger.error(message); + Create.LOGGER.error(message); } ms.pop(); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java b/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java index ee9fc282f..edeed800b 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/FastRenderDispatcher.java @@ -27,7 +27,7 @@ public class FastRenderDispatcher { Minecraft mc = Minecraft.getInstance(); ClientWorld world = mc.world; - KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + KineticRenderer kineticRenderer = CreateClient.KINETIC_RENDERER.get(world); Entity renderViewEntity = mc.renderViewEntity; kineticRenderer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ()); @@ -61,7 +61,7 @@ public class FastRenderDispatcher { if (!Backend.canUseInstancing()) return; ClientWorld world = Minecraft.getInstance().world; - KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world); + KineticRenderer kineticRenderer = CreateClient.KINETIC_RENDERER.get(world); layer.startDrawing(); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionRenderer.java index 87ddf3a7a..b9c4170fd 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionRenderer.java @@ -84,7 +84,7 @@ public class EdgeInteractionRenderer { .withColors(0x7A6A2C, 0xB79D64) .passive(!hit); - CreateClient.outliner.showValueBox("edge", box) + CreateClient.OUTLINER.showValueBox("edge", box) .lineWidth(1 / 64f) .withFaceTexture(hit ? AllSpecialTextures.THIN_CHECKERED : null) .highlightFace(face); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java index 349949f76..bf3437d59 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java @@ -80,7 +80,7 @@ public class FilteringRenderer { .scrollTooltip(showCount && !isFilterSlotted ? new StringTextComponent("[").append(Lang.translate("action.scroll")).append("]") : StringTextComponent.EMPTY) .passive(!hit); - CreateClient.outliner.showValueBox(Pair.of("filter", pos), box.transform(behaviour.slotPositioning)) + CreateClient.OUTLINER.showValueBox(Pair.of("filter", pos), box.transform(behaviour.slotPositioning)) .lineWidth(1 / 64f) .withFaceTexture(hit ? AllSpecialTextures.THIN_CHECKERED : null) .highlightFace(result.getFace()); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java index 27d529ca7..9b9ef352d 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java @@ -91,7 +91,7 @@ public class LinkBehaviour extends TileEntityBehaviour { } public void notifySignalChange() { - Create.redstoneLinkNetworkHandler.updateNetworkOf(this); + Create.REDSTONE_LINK_NETWORK_HANDLER.updateNetworkOf(this); } @Override @@ -169,7 +169,7 @@ public class LinkBehaviour extends TileEntityBehaviour { } private RedstoneLinkNetworkHandler getHandler() { - return Create.redstoneLinkNetworkHandler; + return Create.REDSTONE_LINK_NETWORK_HANDLER; } public static class SlotPositioning { diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkRenderer.java index 6ebd59da6..5773d72c2 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkRenderer.java @@ -51,7 +51,7 @@ public class LinkRenderer { ValueBox box = new ValueBox(label, bb, pos).withColors(0x601F18, 0xB73C2D) .offsetLabel(behaviour.textShift) .passive(!hit); - CreateClient.outliner.showValueBox(Pair.of(Boolean.valueOf(first), pos), box.transform(transform)) + CreateClient.OUTLINER.showValueBox(Pair.of(Boolean.valueOf(first), pos), box.transform(transform)) .lineWidth(1 / 64f) .withFaceTexture(hit ? AllSpecialTextures.THIN_CHECKERED : null) .highlightFace(result.getFace()); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java index cae0d79e1..bc61be6b3 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueRenderer.java @@ -75,7 +75,7 @@ public class ScrollValueRenderer { .withColors(0x5A5D5A, 0xB5B7B6) .passive(!highlight); - CreateClient.outliner.showValueBox(pos, box.transform(behaviour.slotPositioning)) + CreateClient.OUTLINER.showValueBox(pos, box.transform(behaviour.slotPositioning)) .lineWidth(1 / 64f) .highlightFace(face); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java b/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java index 38a66f0b0..deb9d4027 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/FilesHelper.java @@ -23,7 +23,7 @@ public class FilesHelper { try { Files.createDirectories(Paths.get(name)); } catch (IOException e) { - Create.logger.warn("Could not create Folder: {}", name); + Create.LOGGER.warn("Could not create Folder: {}", name); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/Coordinate.java b/src/main/java/com/simibubi/create/foundation/utility/ICoordinate.java similarity index 81% rename from src/main/java/com/simibubi/create/foundation/utility/Coordinate.java rename to src/main/java/com/simibubi/create/foundation/utility/ICoordinate.java index 6d1a246c7..aa4bdcbb8 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Coordinate.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ICoordinate.java @@ -3,6 +3,6 @@ package com.simibubi.create.foundation.utility; import net.minecraft.util.math.BlockPos; @FunctionalInterface -public interface Coordinate { +public interface ICoordinate { float get(BlockPos from); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/RemapHelper.java b/src/main/java/com/simibubi/create/foundation/utility/RemapHelper.java index fc362c1ca..3b1fa356a 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/RemapHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/RemapHelper.java @@ -200,10 +200,10 @@ public class RemapHelper { for (RegistryEvent.MissingMappings.Mapping mapping : mappings) { if (reMap.containsKey(mapping.key.getPath())) { try { - Create.logger.warn("Remapping block '{}' to '{}'", mapping.key, reMap.get(mapping.key.getPath())); + Create.LOGGER.warn("Remapping block '{}' to '{}'", mapping.key, reMap.get(mapping.key.getPath())); mapping.remap(ForgeRegistries.BLOCKS.getValue(reMap.get(mapping.key.getPath()))); } catch (Throwable t) { - Create.logger.warn("Remapping block '{}' to '{}' failed: {}", mapping.key, + Create.LOGGER.warn("Remapping block '{}' to '{}' failed: {}", mapping.key, reMap.get(mapping.key.getPath()), t); } } @@ -223,10 +223,10 @@ public class RemapHelper { for (RegistryEvent.MissingMappings.Mapping mapping : mappings) { if (reMap.containsKey(mapping.key.getPath())) { try { - Create.logger.warn("Remapping item '{}' to '{}'", mapping.key, reMap.get(mapping.key.getPath())); + Create.LOGGER.warn("Remapping item '{}' to '{}'", mapping.key, reMap.get(mapping.key.getPath())); mapping.remap(ForgeRegistries.ITEMS.getValue(reMap.get(mapping.key.getPath()))); } catch (Throwable t) { - Create.logger.warn("Remapping item '{}' to '{}' failed: {}", mapping.key, + Create.LOGGER.warn("Remapping item '{}' to '{}' failed: {}", mapping.key, reMap.get(mapping.key.getPath()), t); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java b/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java index 0dcdb3e14..684808943 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java @@ -96,15 +96,15 @@ public interface IPlacementHelper { Vector3d offsetB = facing.crossProduct(direction).normalize().scale(.25); Vector3d endA = center.add(direction.scale(.75)).add(offsetA); Vector3d endB = center.add(direction.scale(.75)).add(offsetB); - CreateClient.outliner.showLine("placementArrowA" + center + target, start.add(offset), endA.add(offset)).lineWidth(1/16f); - CreateClient.outliner.showLine("placementArrowB" + center + target, start.add(offset), endB.add(offset)).lineWidth(1/16f); + CreateClient.OUTLINER.showLine("placementArrowA" + center + target, start.add(offset), endA.add(offset)).lineWidth(1/16f); + CreateClient.OUTLINER.showLine("placementArrowB" + center + target, start.add(offset), endB.add(offset)).lineWidth(1/16f); } default void displayGhost(PlacementOffset offset) { if (!offset.hasGhostState()) return; - CreateClient.ghostBlocks.showGhostState(this, offset.getTransform().apply(offset.getGhostState())) + CreateClient.GHOST_BLOCKS.showGhostState(this, offset.getTransform().apply(offset.getGhostState())) .at(offset.getBlockPos()) .breathingAlpha(); } diff --git a/src/main/resources/create.mixins.json b/src/main/resources/create.mixins.json index db6a800f6..0649bd2ef 100644 --- a/src/main/resources/create.mixins.json +++ b/src/main/resources/create.mixins.json @@ -13,14 +13,14 @@ "FogColorTrackerMixin", "HeavyBootsOnPlayerMixin", "LightUpdateMixin", + "ModelDataRefreshMixin", "NetworkLightUpdateMixin", "RenderHooksMixin", "ShaderCloseMixin", "StoreProjectionMatrixMixin", "TileRemoveMixin", "TileWorldHookMixin", - "WindowResizeMixin", - "ModelDataRefreshMixin" + "WindowResizeMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 8c6c34537..2705fd617 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { - "pack": { - "description": "create resources", - "pack_format": 6 - } + "pack": { + "description": "Create resources", + "pack_format": 6 + } } From 73895604c8e7e4a821654d058a580c5cf5565696 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sat, 22 May 2021 21:50:31 -0400 Subject: [PATCH 089/198] Fix filter dupe, allow Schematicannon to place brackets --- .../deployer/DeployerMovementBehaviour.java | 20 ++--- .../mounted/CartAssemblerBlock.java | 2 +- .../fluids/pipes/EncasedPipeBlock.java | 6 +- .../fluids/pipes/GlassFluidPipeBlock.java | 10 +-- .../contraptions/relays/belt/BeltBlock.java | 4 +- .../BracketedTileEntityBehaviour.java | 13 +++- .../relays/encased/EncasedShaftBlock.java | 12 +-- .../block/funnel/BeltFunnelBlock.java | 5 +- .../ISpecialBlockItemRequirement.java | 5 +- .../content/schematics/ItemRequirement.java | 77 +++++++++++++++---- .../content/schematics/MaterialChecklist.java | 10 +-- .../block/SchematicannonTileEntity.java | 36 +++++---- .../tileEntity/SmartTileEntity.java | 11 +++ .../tileEntity/TileEntityBehaviour.java | 4 + .../filtering/FilteringBehaviour.java | 11 +++ .../filtering/SidedFilteringBehaviour.java | 13 +++- 16 files changed, 166 insertions(+), 73 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java index ab152a5f5..147885f31 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -107,28 +107,28 @@ public class DeployerMovementBehaviour extends MovementBehaviour { .isVecInside(pos.subtract(schematicWorld.anchor))) return; BlockState blockState = schematicWorld.getBlockState(pos); - ItemRequirement requirement = ItemRequirement.of(blockState); + ItemRequirement requirement = ItemRequirement.of(blockState, schematicWorld.getTileEntity(pos)); if (requirement.isInvalid() || requirement.isEmpty()) return; if (AllBlocks.BELT.has(blockState)) return; - List requiredItems = requirement.getRequiredItems(); - ItemStack firstRequired = requiredItems.isEmpty() ? ItemStack.EMPTY : requiredItems.get(0); + List requiredItems = requirement.getRequiredItems(); + ItemStack firstRequired = requiredItems.isEmpty() ? ItemStack.EMPTY : requiredItems.get(0).item; if (!context.contraption.hasUniversalCreativeCrate) { IItemHandler iItemHandler = context.contraption.inventory; - for (ItemStack required : requiredItems) { + for (ItemRequirement.StackRequirement required : requiredItems) { int amountFound = ItemHelper - .extract(iItemHandler, s -> ItemRequirement.validate(required, s), ExtractionCountMode.UPTO, - required.getCount(), true) + .extract(iItemHandler, s -> ItemRequirement.validate(required.item, s), ExtractionCountMode.UPTO, + required.item.getCount(), true) .getCount(); - if (amountFound < required.getCount()) + if (amountFound < required.item.getCount()) return; } - for (ItemStack required : requiredItems) - ItemHelper.extract(iItemHandler, s -> ItemRequirement.validate(required, s), ExtractionCountMode.UPTO, - required.getCount(), false); + for (ItemRequirement.StackRequirement required : requiredItems) + ItemHelper.extract(iItemHandler, s -> ItemRequirement.validate(required.item, s), ExtractionCountMode.UPTO, + required.item.getCount(), false); } CompoundNBT data = null; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java index 1da586170..62c811bf8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java @@ -433,7 +433,7 @@ public class CartAssemblerBlock extends AbstractRailBlock } @Override - public ItemRequirement getRequiredItems(BlockState state) { + public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { ArrayList reuiredItems = new ArrayList<>(); reuiredItems.add(new ItemStack(getRailItem(state))); reuiredItems.add(new ItemStack(asItem())); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/EncasedPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/EncasedPipeBlock.java index 3a6ff0f7a..fe75a7c28 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/EncasedPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/EncasedPipeBlock.java @@ -138,10 +138,10 @@ public class EncasedPipeBlock extends Block implements IWrenchable, ISpecialBloc } return to; } - + @Override - public ItemRequirement getRequiredItems(BlockState state) { - return ItemRequirement.of(AllBlocks.FLUID_PIPE.getDefaultState()); + public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + return ItemRequirement.of(AllBlocks.FLUID_PIPE.getDefaultState(), te); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/GlassFluidPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/GlassFluidPipeBlock.java index 5d88c5c9f..fffa566df 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/GlassFluidPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/GlassFluidPipeBlock.java @@ -78,15 +78,15 @@ public class GlassFluidPipeBlock extends AxisPipeBlock implements IWaterLoggable return state.get(BlockStateProperties.WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : Fluids.EMPTY.getDefaultState(); } - + @Override - public ItemRequirement getRequiredItems(BlockState state) { - return ItemRequirement.of(AllBlocks.FLUID_PIPE.getDefaultState()); + public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + return ItemRequirement.of(AllBlocks.FLUID_PIPE.getDefaultState(), te); } - + @Override public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; } - + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java index f942d4983..e93ddb501 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltBlock.java @@ -126,7 +126,7 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE required = new ArrayList<>(); if (state.get(PART) != BeltPart.MIDDLE) required.add(AllBlocks.SHAFT.asStack()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java index f2dbec548..a5da7e74e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedTileEntityBehaviour.java @@ -4,6 +4,7 @@ import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; +import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.ITriggerable; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; @@ -38,7 +39,7 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { this.pred = pred; bracket = Optional.empty(); } - + public BracketedTileEntityBehaviour withTrigger(Function trigger) { this.trigger = trigger; return this; @@ -54,7 +55,7 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { reRender = true; tileEntity.notifyUpdate(); } - + public void triggerAdvancements(World world, PlayerEntity player, BlockState state) { if (trigger == null) return; @@ -81,6 +82,14 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour { return bracket.orElse(Blocks.AIR.getDefaultState()); } + @Override + public ItemRequirement getRequiredItems() { + return ItemRequirement.of(getBracket(), null); + } + + @Override + public boolean isSafeNBT() { return true; } + @Override public void write(CompoundNBT nbt, boolean clientPacket) { bracket.ifPresent(p -> nbt.put("Bracket", NBTUtil.writeBlockState(p))); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java index d74f8f72e..09e6749a7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftBlock.java @@ -22,11 +22,11 @@ public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpe public static EncasedShaftBlock andesite(Properties properties) { return new EncasedShaftBlock(properties, AllBlocks.ANDESITE_CASING); } - + public static EncasedShaftBlock brass(Properties properties) { return new EncasedShaftBlock(properties, AllBlocks.BRASS_CASING); } - + protected EncasedShaftBlock(Properties properties, BlockEntry casing) { super(properties); this.casing = casing; @@ -36,7 +36,7 @@ public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpe public TileEntity createTileEntity(BlockState state, IBlockReader world) { return AllTileEntities.ENCASED_SHAFT.create(); } - + public BlockEntry getCasing() { return casing; } @@ -49,10 +49,10 @@ public class EncasedShaftBlock extends AbstractEncasedShaftBlock implements ISpe KineticTileEntity.switchToBlockState(context.getWorld(), context.getPos(), AllBlocks.SHAFT.getDefaultState().with(AXIS, state.get(AXIS))); return ActionResultType.SUCCESS; } - + @Override - public ItemRequirement getRequiredItems(BlockState state) { - return ItemRequirement.of(AllBlocks.SHAFT.getDefaultState()); + public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + return ItemRequirement.of(AllBlocks.SHAFT.getDefaultState(), te); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java index 839053db0..56de5730e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java @@ -22,6 +22,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.state.EnumProperty; import net.minecraft.state.StateContainer.Builder; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.IStringSerializable; @@ -192,8 +193,8 @@ public class BeltFunnelBlock extends AbstractHorizontalFunnelBlock implements IS } @Override - public ItemRequirement getRequiredItems(BlockState state) { - return ItemRequirement.of(parent.getDefaultState()); + public ItemRequirement getRequiredItems(BlockState state, TileEntity te) { + return ItemRequirement.of(parent.getDefaultState(), te); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/ISpecialBlockItemRequirement.java b/src/main/java/com/simibubi/create/content/schematics/ISpecialBlockItemRequirement.java index c23feb02a..d8c65892a 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ISpecialBlockItemRequirement.java +++ b/src/main/java/com/simibubi/create/content/schematics/ISpecialBlockItemRequirement.java @@ -1,11 +1,12 @@ package com.simibubi.create.content.schematics; import net.minecraft.block.BlockState; +import net.minecraft.tileentity.TileEntity; public interface ISpecialBlockItemRequirement { - default ItemRequirement getRequiredItems(BlockState state) { + default ItemRequirement getRequiredItems(BlockState state, TileEntity te) { return ItemRequirement.INVALID; } - + } diff --git a/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java b/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java index 67c013348..eae1a4d4e 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java +++ b/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java @@ -3,6 +3,10 @@ package com.simibubi.create.content.schematics; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -24,6 +28,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.SlabType; +import net.minecraft.tileentity.TileEntity; public class ItemRequirement { @@ -31,8 +36,17 @@ public class ItemRequirement { CONSUME, DAMAGE } - ItemUseType usage; - List requiredItems; + public static class StackRequirement { + public final ItemStack item; + public final ItemUseType usage; + + public StackRequirement(ItemUseType usage, ItemStack item) { + this.item = item; + this.usage = usage; + } + } + + List requiredItems; public static ItemRequirement INVALID = new ItemRequirement(); public static ItemRequirement NONE = new ItemRequirement(); @@ -40,21 +54,43 @@ public class ItemRequirement { private ItemRequirement() { } - public ItemRequirement(ItemUseType usage, Item item) { - this(usage, Arrays.asList(new ItemStack(item))); - } - - public ItemRequirement(ItemUseType usage, List requiredItems) { - this.usage = usage; + public ItemRequirement(List requiredItems) { this.requiredItems = requiredItems; } - public static ItemRequirement of(BlockState state) { + public ItemRequirement(ItemUseType usage, ItemStack items) { + this(Arrays.asList(new StackRequirement(usage, items))); + } + + public ItemRequirement(ItemUseType usage, Item item) { + this(usage, new ItemStack(item)); + } + + public ItemRequirement(ItemUseType usage, List requiredItems) { + this(requiredItems.stream().map(req -> new StackRequirement(usage, req)).collect(Collectors.toList())); + } + + + public static ItemRequirement of(BlockState state, TileEntity te) { Block block = state.getBlock(); + + ItemRequirement baseRequirement; + if (block instanceof ISpecialBlockItemRequirement) { + baseRequirement = ((ISpecialBlockItemRequirement) block).getRequiredItems(state, te); + } else { + baseRequirement = ofBlockState(state, block); + } + + // Behaviours can add additional required items + if (te instanceof SmartTileEntity) + baseRequirement = baseRequirement.with(((SmartTileEntity) te).getRequiredItems()); + + return baseRequirement; + } + + private static ItemRequirement ofBlockState(BlockState state, Block block) { if (block == Blocks.AIR) return NONE; - if (block instanceof ISpecialBlockItemRequirement) - return ((ISpecialBlockItemRequirement) block).getRequiredItems(state); Item item = BlockItem.BLOCK_TO_ITEM.getOrDefault(state.getBlock(), Items.AIR); @@ -125,16 +161,25 @@ public class ItemRequirement { return INVALID == this; } - public List getRequiredItems() { + public List getRequiredItems() { return requiredItems; } - public ItemUseType getUsage() { - return usage; - } - public static boolean validate(ItemStack required, ItemStack present) { return required.isEmpty() || required.getItem() == present.getItem(); } + public ItemRequirement with(ItemRequirement other) { + if (this.isInvalid() || other.isInvalid()) + return INVALID; + if (this.isEmpty()) + return other; + if (other.isEmpty()) + return this; + + return new ItemRequirement( + Stream.concat(requiredItems.stream(), other.requiredItems.stream()).collect(Collectors.toList()) + ); + } + } diff --git a/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java b/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java index e4a37dcc3..1619173b4 100644 --- a/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java +++ b/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java @@ -43,11 +43,11 @@ public class MaterialChecklist { if (requirement.isInvalid()) return; - for (ItemStack stack : requirement.requiredItems) { - if (requirement.getUsage() == ItemUseType.DAMAGE) - putOrIncrement(damageRequired, stack); - if (requirement.getUsage() == ItemUseType.CONSUME) - putOrIncrement(required, stack); + for (ItemRequirement.StackRequirement stack : requirement.requiredItems) { + if (stack.usage == ItemUseType.DAMAGE) + putOrIncrement(damageRequired, stack.item); + if (stack.usage == ItemUseType.CONSUME) + putOrIncrement(required, stack.item); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index 2bc098dc3..0301f23d4 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -433,6 +433,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC boolean shouldSkip = false; BlockState blockState = Blocks.AIR.getDefaultState(); + TileEntity tileEntity = null; ItemRequirement requirement; if (entityMode) { @@ -442,8 +443,9 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } else { blockState = BlockHelper.setZeroAge(blockReader.getBlockState(target)); - requirement = ItemRequirement.of(blockState); - shouldSkip = !shouldPlace(target, blockState); + tileEntity = blockReader.getTileEntity(target); + requirement = ItemRequirement.of(blockState, tileEntity); + shouldSkip = !shouldPlace(target, blockState, tileEntity); } if (shouldSkip || requirement.isInvalid()) { @@ -453,10 +455,10 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } // Find item - List requiredItems = requirement.getRequiredItems(); + List requiredItems = requirement.getRequiredItems(); if (!requirement.isEmpty()) { - for (ItemStack required : requiredItems) { - if (!grabItemsFromAttachedInventories(required, requirement.getUsage(), true)) { + for (ItemRequirement.StackRequirement required : requiredItems) { + if (!grabItemsFromAttachedInventories(required.item, required.usage, true)) { if (skipMissing) { statusMsg = "skipping"; blockSkipped = true; @@ -467,15 +469,15 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC return; } - missingItem = required; + missingItem = required.item; state = State.PAUSED; statusMsg = "missingBlock"; return; } } - for (ItemStack required : requiredItems) - grabItemsFromAttachedInventories(required, requirement.getUsage(), false); + for (ItemRequirement.StackRequirement required : requiredItems) + grabItemsFromAttachedInventories(required.item, required.usage, false); } // Success @@ -485,7 +487,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC else statusMsg = "clearing"; - ItemStack icon = requirement.isEmpty() || requiredItems.isEmpty() ? ItemStack.EMPTY : requiredItems.get(0); + ItemStack icon = requirement.isEmpty() || requiredItems.isEmpty() ? ItemStack.EMPTY : requiredItems.get(0).item; if (entityMode) launchEntity(target, icon, blockReader.getEntities() .collect(Collectors.toList()) @@ -759,7 +761,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC deferredBlocks.clear(); } - protected boolean shouldPlace(BlockPos pos, BlockState state) { + protected boolean shouldPlace(BlockPos pos, BlockState state, TileEntity te) { if (world == null) return false; BlockState toReplace = world.getBlockState(pos); @@ -790,7 +792,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC && (toReplace.hasTileEntity() || (toReplaceOther != null && toReplaceOther.hasTileEntity()))) return false; - if (shouldIgnoreBlockState(state)) + if (shouldIgnoreBlockState(state, te)) return false; if (replaceMode == 3) @@ -809,12 +811,12 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC return false; } - protected boolean shouldIgnoreBlockState(BlockState state) { + protected boolean shouldIgnoreBlockState(BlockState state, TileEntity te) { // Block doesnt have a mapping (Water, lava, etc) if (state.getBlock() == Blocks.STRUCTURE_VOID) return true; - ItemRequirement requirement = ItemRequirement.of(state); + ItemRequirement requirement = ItemRequirement.of(state, te); if (requirement.isEmpty()) return false; if (requirement.isInvalid()) @@ -951,15 +953,17 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC if (schematicLoaded) { blocksToPlace = blocksPlaced; for (BlockPos pos : blockReader.getAllPositions()) { - BlockState required = blockReader.getBlockState(pos.add(schematicAnchor)); + BlockPos relPos = pos.add(schematicAnchor); + BlockState required = blockReader.getBlockState(relPos); + TileEntity requiredTE = blockReader.getTileEntity(relPos); if (!getWorld().isAreaLoaded(pos.add(schematicAnchor), 0)) { checklist.warnBlockNotLoaded(); continue; } - if (!shouldPlace(pos.add(schematicAnchor), required)) + if (!shouldPlace(pos.add(schematicAnchor), required, requiredTE)) continue; - ItemRequirement requirement = ItemRequirement.of(required); + ItemRequirement requirement = ItemRequirement.of(required, blockReader.getTileEntity(relPos)); if (requirement.isEmpty()) continue; if (requirement.isInvalid()) diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java b/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java index e036d7dab..bee1a0f3e 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; +import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import com.simibubi.create.foundation.utility.IPartialSafeNBT; @@ -13,6 +14,7 @@ import com.simibubi.create.foundation.utility.IPartialSafeNBT; import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; +import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -120,6 +122,7 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka behaviourList.forEach(tb -> tb.write(compound, clientPacket)); } + @Override public void writeSafe(CompoundNBT compound, boolean clientPacket) { super.write(compound); behaviourList.forEach(tb -> { @@ -128,6 +131,14 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements ITicka }); } + public ItemRequirement getRequiredItems() { + return behaviourList.stream().reduce( + ItemRequirement.NONE, + (a,b) -> a.with(b.getRequiredItems()), + (a,b) -> a.with(b) + ); + } + @Override public void remove() { forEachBehaviour(TileEntityBehaviour::remove); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java index 931b5f4bd..cfba21b6b 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java @@ -1,8 +1,10 @@ package com.simibubi.create.foundation.tileEntity; +import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import net.minecraft.block.BlockState; +import net.minecraft.item.Item; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; @@ -44,6 +46,8 @@ public abstract class TileEntityBehaviour { public boolean isSafeNBT() { return false; } + public ItemRequirement getRequiredItems() { return ItemRequirement.NONE; } + public void onBlockChanged(BlockState oldState) { } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java index c6b7acebe..1768fd0cd 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringBehaviour.java @@ -4,6 +4,7 @@ import java.util.function.Consumer; import java.util.function.Supplier; import com.simibubi.create.content.logistics.item.filter.FilterItem; +import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; @@ -13,6 +14,7 @@ import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.block.BlockState; import net.minecraft.entity.item.ItemEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; @@ -168,6 +170,15 @@ public class FilteringBehaviour extends TileEntityBehaviour { super.destroy(); } + @Override + public ItemRequirement getRequiredItems() { + Item filterItem = filter.getItem(); + if (filterItem instanceof FilterItem) + return new ItemRequirement(ItemRequirement.ItemUseType.CONSUME, filterItem); + + return ItemRequirement.NONE; + } + public ItemStack getFilter(Direction side) { return getFilter(); } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/SidedFilteringBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/SidedFilteringBehaviour.java index 9a7f0a490..a1ea9383b 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/SidedFilteringBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/SidedFilteringBehaviour.java @@ -7,6 +7,7 @@ import java.util.Set; import java.util.function.BiFunction; import java.util.function.Predicate; +import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided; @@ -58,9 +59,6 @@ public class SidedFilteringBehaviour extends FilteringBehaviour { removeFilter(d); } - @Override - public boolean isSafeNBT() { return true; } - @Override public void write(CompoundNBT nbt, boolean clientPacket) { nbt.put("Filters", NBTHelper.writeCompoundList(sidedFilters.entrySet(), entry -> { @@ -122,6 +120,15 @@ public class SidedFilteringBehaviour extends FilteringBehaviour { super.destroy(); } + @Override + public ItemRequirement getRequiredItems() { + return sidedFilters.values().stream().reduce( + ItemRequirement.NONE, + (a,b) -> a.with(b.getRequiredItems()), + (a,b) -> a.with(b) + ); + } + public void removeFilter(Direction side) { if (!sidedFilters.containsKey(side)) return; From 5ec83123224a255a7b6b5340e6a8f9eeeb8a96c6 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sun, 23 May 2021 00:16:01 -0400 Subject: [PATCH 090/198] Fix DoublePlantBlock dupe using deployers --- src/generated/resources/.cache/cache | 4 ++-- .../data/create/advancements/aesthetics.json | 4 ++-- .../data/create/tags/blocks/brittle.json | 1 + .../components/deployer/DeployerHandler.java | 22 +++++++++++++++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index fb6f24a64..7ed72b4d7 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -1652,7 +1652,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json 096382a4c025b5ffdde9c496ee9da0d5345fbe17 assets/create/sounds.json -5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json +0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json 187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json 0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json 83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json @@ -3645,7 +3645,7 @@ d3fdb8ece6cb072a93ddb64a0baad5ac952117a4 data/create/recipes/weathered_limestone 0f3c993eb6dd3f37953f304b8fad15bf60469ef4 data/create/recipes/weathered_limestone_cobblestone_wall_from_weathered_limestone_cobblestone_stonecutting.json 6eceb25fabbb6b389ca35de3b829ad061c9c456a data/create/recipes/weathered_limestone_pillar.json 11667414f73bc2d00bda7c5c1a7d2934bf6e9165 data/create/recipes/weathered_limestone_pillar_from_weathered_limestone_stonecutting.json -20c20a12b0baff2ba493b1405db7d2d8a15b81af data/create/tags/blocks/brittle.json +d7fe46e7d00e47294f9e0e7c2c0070e86c88a606 data/create/tags/blocks/brittle.json 330bfb3850ba3964b10b1bccbc3cbb9b012cae54 data/create/tags/blocks/fan_heaters.json 3bc64e3a1e7980237435b1770a9ba2102d57fcd4 data/create/tags/blocks/fan_transparent.json 74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/create/tags/blocks/non_movable.json diff --git a/src/generated/resources/data/create/advancements/aesthetics.json b/src/generated/resources/data/create/advancements/aesthetics.json index 59a86f429..d723cbe38 100644 --- a/src/generated/resources/data/create/advancements/aesthetics.json +++ b/src/generated/resources/data/create/advancements/aesthetics.json @@ -28,8 +28,8 @@ "trigger": "create:bracket_apply", "conditions": { "accepted_entries": [ - "create:large_cogwheel", - "create:cogwheel" + "create:cogwheel", + "create:large_cogwheel" ] } }, diff --git a/src/generated/resources/data/create/tags/blocks/brittle.json b/src/generated/resources/data/create/tags/blocks/brittle.json index 7970c3bf9..217f2fcc8 100644 --- a/src/generated/resources/data/create/tags/blocks/brittle.json +++ b/src/generated/resources/data/create/tags/blocks/brittle.json @@ -20,6 +20,7 @@ "create:green_valve_handle", "create:red_valve_handle", "create:black_valve_handle", + "create:gantry_carriage", "create:rope", "create:pulley_magnet", "create:furnace_engine", diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java index 55f3a928d..1476b810c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java @@ -8,6 +8,10 @@ import java.util.List; import javax.annotation.Nullable; +import net.minecraft.block.DoublePlantBlock; + +import net.minecraft.state.properties.DoubleBlockHalf; + import org.apache.commons.lang3.tuple.Pair; import com.google.common.collect.Multimap; @@ -349,8 +353,22 @@ public class DeployerHandler { prevHeldItem.onBlockDestroyed(world, blockstate, pos, player); if (prevHeldItem.isEmpty() && !heldItem.isEmpty()) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, heldItem, Hand.MAIN_HAND); - if (!blockstate.removedByPlayer(world, pos, player, canHarvest, world.getFluidState(pos))) - return true; + + + BlockPos posUp = pos.up(); + BlockState stateUp = world.getBlockState(posUp); + if (blockstate.getBlock() instanceof DoublePlantBlock + && blockstate.get(DoublePlantBlock.HALF) == DoubleBlockHalf.LOWER + && stateUp.getBlock() == blockstate.getBlock() + && stateUp.get(DoublePlantBlock.HALF) == DoubleBlockHalf.UPPER + ) { + // hack to prevent DoublePlantBlock from dropping a duplicate item + world.setBlockState(pos, Blocks.AIR.getDefaultState(), 35); + world.setBlockState(posUp, Blocks.AIR.getDefaultState(), 35); + } else { + if (!blockstate.removedByPlayer(world, pos, player, canHarvest, world.getFluidState(pos))) + return true; + } blockstate.getBlock() .onPlayerDestroy(world, pos, blockstate); From b0a84a9bc125acbe3b83ce0ab820f1180a4385e9 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sun, 23 May 2021 15:08:43 -0400 Subject: [PATCH 091/198] Fix breaking piston pole making piston base unusable --- .../piston/LinearActuatorTileEntity.java | 7 ++++++- .../piston/PistonExtensionPoleBlock.java | 13 +++++++++++-- .../structureMovement/pulley/PulleyBlock.java | 12 ++++++------ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java index 6cb418ec2..300f17aab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java @@ -288,6 +288,11 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity } } + public void onLengthBroken() { + offset = 0; + sendData(); + } + @Override public boolean isValid() { return !isRemoved(); @@ -311,4 +316,4 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity public BlockPos getBlockPosition() { return pos; } -} \ No newline at end of file +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java index b88ef5c3a..d42563d24 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java @@ -9,6 +9,7 @@ import java.util.function.Predicate; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState; +import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyTileEntity; import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.block.ProperDirectionalBlock; import com.simibubi.create.foundation.utility.placement.IPlacementHelper; @@ -29,6 +30,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.pathfinding.PathType; import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; @@ -71,7 +73,7 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements public boolean isToolEffective(BlockState state, ToolType tool) { return tool == ToolType.AXE || tool == ToolType.PICKAXE; } - + @Override public PushReaction getPushReaction(BlockState state) { return PushReaction.NORMAL; @@ -117,6 +119,13 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements .forEach(p -> worldIn.destroyBlock(p, !player.isCreative())); worldIn.setBlockState(basePos, worldIn.getBlockState(basePos) .with(MechanicalPistonBlock.STATE, PistonState.RETRACTED)); + + TileEntity te = worldIn.getTileEntity(basePos); + if (te instanceof MechanicalPistonTileEntity) { + MechanicalPistonTileEntity baseTE = (MechanicalPistonTileEntity) te; + baseTE.offset = 0; + baseTE.onLengthBroken(); + } } super.onBlockHarvested(worldIn, pos, state, player); @@ -168,7 +177,7 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements } return state; } - + @Override public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java index 2aa7b6d13..8ec99fff0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java @@ -43,11 +43,11 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE Date: Sun, 23 May 2021 16:40:15 -0400 Subject: [PATCH 092/198] Allow deployer to place cart assemblers --- .../contraptions/components/deployer/DeployerHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java index 1476b810c..6125d3150 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java @@ -8,6 +8,8 @@ import java.util.List; import javax.annotation.Nullable; +import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlockItem; + import net.minecraft.block.DoublePlantBlock; import net.minecraft.state.properties.DoubleBlockHalf; @@ -281,7 +283,9 @@ public class DeployerHandler { return; if (useItem == DENY) return; - if (item instanceof BlockItem && !clickedState.isReplaceable(new BlockItemUseContext(itemusecontext))) + if (item instanceof BlockItem + && !(item instanceof CartAssemblerBlockItem) + && !clickedState.isReplaceable(new BlockItemUseContext(itemusecontext))) return; // Reposition fire placement for convenience From db53b7a3cfc0169c797e7ce00fd745068e2e1e1a Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sun, 23 May 2021 19:36:44 -0700 Subject: [PATCH 093/198] Fix gl error spam --- .../jozufozu/flywheel/backend/Backend.java | 2 +- .../backend/core/CrumblingRenderer.java | 2 + .../flywheel/backend/core/FullscreenQuad.java | 61 +++++++++++++++++++ .../backend/core/WorldTileRenderer.java | 1 + .../core/{ => context}/WorldContext.java | 3 +- .../instancing/InstancedTileRenderer.java | 2 +- .../com/simibubi/create/CreateClient.java | 3 +- .../render/ContraptionRenderDispatcher.java | 2 +- .../foundation/config/ui/ConfigScreen.java | 38 +++++++++++- .../foundation/gui/AbstractSimiScreen.java | 12 +++- .../create/foundation/gui/StencilElement.java | 1 + .../create/foundation/gui/UIRenderHelper.java | 30 ++++++--- .../foundation/mixin/WindowResizeMixin.java | 3 +- .../render/effects/EffectsHandler.java | 44 +------------ 14 files changed, 142 insertions(+), 62 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/FullscreenQuad.java rename src/main/java/com/jozufozu/flywheel/backend/core/{ => context}/WorldContext.java (97%) diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index fc0b3ac8a..73fb81cad 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -21,8 +21,8 @@ import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; import com.jozufozu.flywheel.backend.core.CrumblingRenderer; -import com.jozufozu.flywheel.backend.core.WorldContext; import com.jozufozu.flywheel.backend.core.WorldTileRenderer; +import com.jozufozu.flywheel.backend.core.context.WorldContext; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingRenderer.java index f1be59600..002540e27 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/CrumblingRenderer.java @@ -1,5 +1,7 @@ package com.jozufozu.flywheel.backend.core; +import com.jozufozu.flywheel.backend.core.context.WorldContext; + import net.minecraft.util.math.BlockPos; public class CrumblingRenderer extends WorldTileRenderer { diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/FullscreenQuad.java b/src/main/java/com/jozufozu/flywheel/backend/core/FullscreenQuad.java new file mode 100644 index 000000000..d290e7e58 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/FullscreenQuad.java @@ -0,0 +1,61 @@ +package com.jozufozu.flywheel.backend.core; + +import org.lwjgl.opengl.GL20; + +import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.GlVertexArray; +import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; +import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; + +import net.minecraftforge.common.util.Lazy; + +public class FullscreenQuad { + + public static final Lazy INSTANCE = Lazy.of(FullscreenQuad::new); + + private static final float[] vertices = { + // pos // tex + -1.0f, -1.0f, 0.0f, 0.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + -1.0f, 1.0f, 0.0f, 1.0f, + + -1.0f, -1.0f, 0.0f, 0.0f, + 1.0f, -1.0f, 1.0f, 0.0f, + 1.0f, 1.0f, 1.0f, 1.0f + }; + + private static final int bufferSize = vertices.length * 4; + + private final GlVertexArray vao; + private final GlBuffer vbo; + + private FullscreenQuad() { + vbo = new GlBuffer(GlBufferType.ARRAY_BUFFER); + vbo.bind(); + vbo.alloc(bufferSize); + vbo.getBuffer(0, bufferSize) + .putFloatArray(vertices) + .flush(); + + vao = new GlVertexArray(); + vao.bind(); + + GL20.glEnableVertexAttribArray(0); + + GL20.glVertexAttribPointer(0, 4, GlPrimitiveType.FLOAT.getGlConstant(), false, 4 * 4, 0); + + vao.unbind(); + vbo.unbind(); + } + + public void draw() { + vao.bind(); + GL20.glDrawArrays(GL20.GL_TRIANGLES, 0, 6); + vao.unbind(); + } + + public void delete() { + vao.delete(); + vbo.delete(); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java index 5401bd444..c473905db 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldTileRenderer.java @@ -2,6 +2,7 @@ package com.jozufozu.flywheel.backend.core; import java.util.ArrayList; +import com.jozufozu.flywheel.backend.core.context.WorldContext; import com.jozufozu.flywheel.backend.core.shader.ShaderCallback; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/context/WorldContext.java similarity index 97% rename from src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java rename to src/main/java/com/jozufozu/flywheel/backend/core/context/WorldContext.java index 008e5c7a9..c3197dbd5 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/context/WorldContext.java @@ -1,4 +1,4 @@ -package com.jozufozu.flywheel.backend.core; +package com.jozufozu.flywheel.backend.core.context; import java.util.EnumMap; import java.util.Map; @@ -12,6 +12,7 @@ import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.ResourceUtil; import com.jozufozu.flywheel.backend.ShaderContext; import com.jozufozu.flywheel.backend.ShaderLoader; +import com.jozufozu.flywheel.backend.core.CrumblingProgram; import com.jozufozu.flywheel.backend.core.shader.ExtensibleGlProgram; import com.jozufozu.flywheel.backend.core.shader.IMultiProgram; import com.jozufozu.flywheel.backend.core.shader.StateSensitiveMultiProgram; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java index 8d7c2fe11..8101d291a 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedTileRenderer.java @@ -8,7 +8,7 @@ import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.core.WorldContext; +import com.jozufozu.flywheel.backend.core.context.WorldContext; import com.jozufozu.flywheel.backend.core.materials.ModelData; import com.jozufozu.flywheel.backend.core.materials.OrientedData; import com.jozufozu.flywheel.backend.core.shader.ShaderCallback; diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index cd804a361..6feabe8a7 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -112,7 +112,6 @@ public class CreateClient { PonderIndex.registerTags(); UIRenderHelper.init(); - UIRenderHelper.enableStencil(); IResourceManager resourceManager = Minecraft.getInstance() .getResourceManager(); @@ -120,7 +119,7 @@ public class CreateClient { ((IReloadableResourceManager) resourceManager).addReloadListener(new ResourceReloadHandler()); AllBlockPartials.clientInit(); - + event.enqueueWork(() -> { CopperBacktankArmorLayer.register(); }); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 5d537347d..1e9992cbc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -15,7 +15,7 @@ import java.util.stream.Stream; import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.core.WorldContext; +import com.jozufozu.flywheel.backend.core.context.WorldContext; import com.jozufozu.flywheel.backend.loading.ModelTemplate; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllMovementBehaviours; diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java index 98086a786..24a2d4da6 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java @@ -8,18 +8,26 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import org.apache.commons.lang3.StringUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL30; +import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock; import com.simibubi.create.foundation.gui.AbstractSimiScreen; import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.StencilElement; +import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.utility.animation.Force; import com.simibubi.create.foundation.utility.animation.PhysicalFloat; import net.minecraft.block.BlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.client.shader.FramebufferConstants; import net.minecraft.util.Direction; public abstract class ConfigScreen extends AbstractSimiScreen { @@ -83,7 +91,35 @@ public abstract class ConfigScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {} + protected void prepareFrame() { + Framebuffer thisBuffer = UIRenderHelper.framebuffer; + Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); + + Backend.compat.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.framebufferObject); + Backend.compat.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, thisBuffer.framebufferObject); + Backend.compat.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); + + Backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, thisBuffer.framebufferObject); + GL11.glClear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT); + + } + + @Override + protected void endFrame() { + + Framebuffer thisBuffer = UIRenderHelper.framebuffer; + Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer(); + + Backend.compat.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.framebufferObject); + Backend.compat.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject); + Backend.compat.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR); + + Backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject); + } + + @Override + protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + } @Override public boolean mouseScrolled(double mouseX, double mouseY, double delta) { diff --git a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java index b064ccbfa..4a78dc36e 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AbstractSimiScreen.java @@ -43,20 +43,30 @@ public abstract class AbstractSimiScreen extends Screen { @Override public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { partialTicks = partialTicks == 10 ? 0 - : Minecraft.getInstance() + : Minecraft.getInstance() .getRenderPartialTicks(); ms.push(); + prepareFrame(); + renderWindowBackground(ms, mouseX, mouseY, partialTicks); renderWindow(ms, mouseX, mouseY, partialTicks); for (Widget widget : widgets) widget.render(ms, mouseX, mouseY, partialTicks); renderWindowForeground(ms, mouseX, mouseY, partialTicks); + endFrame(); + ms.pop(); } + protected void prepareFrame() { + } + + protected void endFrame() { + } + protected void renderWindowBackground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { renderBackground(ms); } diff --git a/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java b/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java index 26677e053..22c70b75f 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/StencilElement.java @@ -47,5 +47,6 @@ public abstract class StencilElement extends RenderElement { protected void cleanUp(MatrixStack ms) { GL11.glDisable(GL11.GL_STENCIL_TEST); + } } diff --git a/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java b/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java index fee8e48c6..23adb2cc2 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/gui/UIRenderHelper.java @@ -1,6 +1,6 @@ package com.simibubi.create.foundation.gui; -import java.awt.Color; +import java.awt.*; import javax.annotation.Nonnull; @@ -25,23 +25,33 @@ import net.minecraftforge.fml.client.gui.GuiUtils; public class UIRenderHelper { - public static void enableStencil() { - RenderSystem.recordRenderCall(() -> Minecraft.getInstance().getFramebuffer().enableStencil()); - } - + /** + * An FBO that has a stencil buffer for use wherever stencil are necessary. Forcing the main FBO to have a stencil + * buffer will cause GL error spam when using fabulous graphics. + */ public static Framebuffer framebuffer; + public static void updateWindowSize(MainWindow mainWindow) { + if (framebuffer != null) + framebuffer.func_216491_a(mainWindow.getFramebufferWidth(), mainWindow.getFramebufferHeight(), Minecraft.IS_RUNNING_ON_MAC); + } + public static void init() { RenderSystem.recordRenderCall(() -> { MainWindow mainWindow = Minecraft.getInstance() .getWindow(); - framebuffer = new Framebuffer(mainWindow.getFramebufferWidth(), mainWindow.getFramebufferHeight(), true, - Minecraft.IS_RUNNING_ON_MAC); - framebuffer.setFramebufferColor(0, 0, 0, 0); - framebuffer.enableStencil(); + framebuffer = createFramebuffer(mainWindow); }); } + private static Framebuffer createFramebuffer(MainWindow mainWindow) { + Framebuffer framebuffer = new Framebuffer(mainWindow.getFramebufferWidth(), mainWindow.getFramebufferHeight(), true, + Minecraft.IS_RUNNING_ON_MAC); + framebuffer.setFramebufferColor(0, 0, 0, 0); + framebuffer.enableStencil(); + return framebuffer; + } + public static void drawFramebuffer(float alpha) { MainWindow window = Minecraft.getInstance() .getWindow(); @@ -70,10 +80,10 @@ public class UIRenderHelper { } public static void streak(MatrixStack ms, float angle, int x, int y, int breadth, int length) {streak(ms, angle, x, y, breadth, length, Theme.i(Theme.Key.STREAK));} - // angle in degrees; 0° -> fading to the right // x and y specify the middle point of the starting edge // breadth is the total width of the streak + public static void streak(MatrixStack ms, float angle, int x, int y, int breadth, int length, int color) { int a1 = 0xa0 << 24; int a2 = 0x80 << 24; diff --git a/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java index 5008129b3..21ed291ff 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/WindowResizeMixin.java @@ -22,8 +22,7 @@ public class WindowResizeMixin { @Inject(at = @At("TAIL"), method = "updateWindowSize") private void updateWindowSize(CallbackInfo ci) { - if (UIRenderHelper.framebuffer != null) - UIRenderHelper.framebuffer.func_216491_a(mainWindow.getFramebufferWidth(), mainWindow.getFramebufferHeight(), Minecraft.IS_RUNNING_ON_MAC); + UIRenderHelper.updateWindowSize(mainWindow); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java index eae45b987..2e3e71301 100644 --- a/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java +++ b/src/main/java/com/simibubi/create/foundation/render/effects/EffectsHandler.java @@ -9,10 +9,7 @@ import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; -import com.jozufozu.flywheel.backend.gl.GlVertexArray; -import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; -import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; +import com.jozufozu.flywheel.backend.core.FullscreenQuad; import com.jozufozu.flywheel.util.RenderUtil; import com.simibubi.create.foundation.render.AllProgramSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -52,23 +49,8 @@ public class EffectsHandler { return Minecraft.getInstance().gameRenderer.getFarPlaneDistance() * 4; } - public static final float[] vertices = { - // pos // tex - -1.0f, -1.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 1.0f, - -1.0f, 1.0f, 0.0f, 1.0f, - - -1.0f, -1.0f, 0.0f, 0.0f, - 1.0f, -1.0f, 1.0f, 0.0f, - 1.0f, 1.0f, 1.0f, 1.0f - }; - - private static final int bufferSize = vertices.length * 4; private final Framebuffer framebuffer; - private final GlVertexArray vao; - - private final GlBuffer vbo; private final ArrayList spheres; @@ -78,23 +60,6 @@ public class EffectsHandler { Framebuffer render = Minecraft.getInstance().getFramebuffer(); framebuffer = new Framebuffer(render.framebufferWidth, render.framebufferHeight, false, Minecraft.IS_RUNNING_ON_MAC); - vbo = new GlBuffer(GlBufferType.ARRAY_BUFFER); - vbo.bind(); - vbo.alloc(bufferSize); - vbo.getBuffer(0, bufferSize) - .putFloatArray(vertices) - .flush(); - - vao = new GlVertexArray(); - vao.bind(); - - GL20.glEnableVertexAttribArray(0); - - GL20.glVertexAttribPointer(0, 4, GlPrimitiveType.FLOAT.getGlConstant(), false, 4 * 4, 0); - - vao.unbind(); - vbo.unbind(); - } public void addSphere(FilterSphere sphere) { @@ -155,9 +120,7 @@ public class EffectsHandler { program.setFarPlane(getFarPlane()); program.setNearPlane(getNearPlane()); - vao.bind(); - GL20.glDrawArrays(GL20.GL_TRIANGLES, 0, 6); - vao.unbind(); + FullscreenQuad.INSTANCE.get().draw(); program.bindColorTexture(0); program.bindDepthTexture(0); @@ -174,9 +137,6 @@ public class EffectsHandler { public void delete() { framebuffer.deleteFramebuffer(); - - vao.delete(); - vbo.delete(); } private void prepFramebufferSize() { From 0cd49317d7a30e8ab3152f1ef42029c0c65911f8 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sun, 23 May 2021 22:42:03 -0400 Subject: [PATCH 094/198] Revert "Make gantry carriage brittle" This reverts commit bfc8c3e3 --- src/generated/resources/.cache/cache | 4 ++-- .../resources/data/create/advancements/aesthetics.json | 4 ++-- src/generated/resources/data/create/tags/blocks/brittle.json | 1 - src/main/java/com/simibubi/create/AllBlocks.java | 1 - .../content/schematics/block/SchematicannonTileEntity.java | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 7ed72b4d7..fb6f24a64 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -1652,7 +1652,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json 096382a4c025b5ffdde9c496ee9da0d5345fbe17 assets/create/sounds.json -0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json +5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json 187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json 0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json 83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json @@ -3645,7 +3645,7 @@ d3fdb8ece6cb072a93ddb64a0baad5ac952117a4 data/create/recipes/weathered_limestone 0f3c993eb6dd3f37953f304b8fad15bf60469ef4 data/create/recipes/weathered_limestone_cobblestone_wall_from_weathered_limestone_cobblestone_stonecutting.json 6eceb25fabbb6b389ca35de3b829ad061c9c456a data/create/recipes/weathered_limestone_pillar.json 11667414f73bc2d00bda7c5c1a7d2934bf6e9165 data/create/recipes/weathered_limestone_pillar_from_weathered_limestone_stonecutting.json -d7fe46e7d00e47294f9e0e7c2c0070e86c88a606 data/create/tags/blocks/brittle.json +20c20a12b0baff2ba493b1405db7d2d8a15b81af data/create/tags/blocks/brittle.json 330bfb3850ba3964b10b1bccbc3cbb9b012cae54 data/create/tags/blocks/fan_heaters.json 3bc64e3a1e7980237435b1770a9ba2102d57fcd4 data/create/tags/blocks/fan_transparent.json 74700d556ca80c7a1db5fd4efb09c3ddb26cad66 data/create/tags/blocks/non_movable.json diff --git a/src/generated/resources/data/create/advancements/aesthetics.json b/src/generated/resources/data/create/advancements/aesthetics.json index d723cbe38..59a86f429 100644 --- a/src/generated/resources/data/create/advancements/aesthetics.json +++ b/src/generated/resources/data/create/advancements/aesthetics.json @@ -28,8 +28,8 @@ "trigger": "create:bracket_apply", "conditions": { "accepted_entries": [ - "create:cogwheel", - "create:large_cogwheel" + "create:large_cogwheel", + "create:cogwheel" ] } }, diff --git a/src/generated/resources/data/create/tags/blocks/brittle.json b/src/generated/resources/data/create/tags/blocks/brittle.json index 217f2fcc8..7970c3bf9 100644 --- a/src/generated/resources/data/create/tags/blocks/brittle.json +++ b/src/generated/resources/data/create/tags/blocks/brittle.json @@ -20,7 +20,6 @@ "create:green_valve_handle", "create:red_valve_handle", "create:black_valve_handle", - "create:gantry_carriage", "create:rope", "create:pulley_magnet", "create:furnace_engine", diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 5b572ea89..5ea72cd61 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -739,7 +739,6 @@ public class AllBlocks { public static final BlockEntry GANTRY_CARRIAGE = REGISTRATE.block("gantry_carriage", GantryCarriageBlock::new) .initialProperties(SharedProperties::stone) - .tag(AllBlockTags.BRITTLE.tag) .properties(Block.Properties::nonOpaque) .blockstate(BlockStateGen.directionalAxisBlockProvider()) .item() diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index 0301f23d4..d3a96fc1b 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -731,7 +731,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } public static boolean shouldDeferBlock(BlockState state) { - return BlockMovementTraits.isBrittle(state); + return state.getBlock().is(AllBlocks.GANTRY_CARRIAGE.get()) || BlockMovementTraits.isBrittle(state); } public void finishedPrinting() { From 3f31b765dd3401fc00736076575cb6d61695ef70 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Mon, 24 May 2021 15:19:54 -0400 Subject: [PATCH 095/198] Make fan and nozzles not push players flying in creative --- .../contraptions/components/fan/AirCurrent.java | 11 +++++++++-- .../contraptions/components/fan/NozzleTileEntity.java | 9 +++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java index 0440de076..3b4d2ba91 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java @@ -89,8 +89,7 @@ public class AirCurrent { protected void tickAffectedEntities(World world, Direction facing) { for (Iterator iterator = caughtEntities.iterator(); iterator.hasNext();) { Entity entity = iterator.next(); - if (!entity.isAlive() || !entity.getBoundingBox() - .intersects(bounds)) { + if (!entity.isAlive() || !entity.getBoundingBox().intersects(bounds) || isPlayerCreativeFlying(entity)) { iterator.remove(); continue; } @@ -389,4 +388,12 @@ public class AirCurrent { isClientPlayerInAirCurrent = false; } + public static boolean isPlayerCreativeFlying(Entity entity) { + if (entity instanceof PlayerEntity) { + PlayerEntity player = (PlayerEntity) entity; + return player.isCreative() && player.abilities.isFlying; + } + return false; + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java index 945e8498c..74c7a83b4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java @@ -49,7 +49,7 @@ public class NozzleTileEntity extends SmartTileEntity { compound.putFloat("Range", range); compound.putBoolean("Pushing", pushing); } - + @Override protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); @@ -95,8 +95,7 @@ public class NozzleTileEntity extends SmartTileEntity { continue; double distance = diff.length(); - if (distance > range || entity.isSneaking() - || (entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative())) { + if (distance > range || entity.isSneaking() || AirCurrent.isPlayerCreativeFlying(entity)) { iterator.remove(); continue; } @@ -153,10 +152,8 @@ public class NozzleTileEntity extends SmartTileEntity { .subtract(center); double distance = diff.length(); - if (distance > range || entity.isSneaking() - || (entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative())) { + if (distance > range || entity.isSneaking() || AirCurrent.isPlayerCreativeFlying(entity)) continue; - } boolean canSee = canSee(entity); if (!canSee) { From 20cd8da377bd856af0af89a6e394ff062ac670ea Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Mon, 24 May 2021 13:32:39 -0700 Subject: [PATCH 096/198] Allow registering custom block movement checks Registering block movement checks works by using one of the six static register methods on an instance of an implementation of one of the six corresponding interfaces. Each one takes some arguments and returns a CheckResult, which defines whether to return from the global check or fall through to the next registered check or fallback check. - Rename BlockMovementTraits to BlockMovementChecks - Rename some check methods to be consistent - Pass World instead of IBlockReader to isBlockAttachedTowards - Make the bottom half of doors attach up and down - Remove door check from Contrapion#moveBlock as it is unnecessary --- ...ntTraits.java => BlockMovementChecks.java} | 195 ++++++++++++++++-- .../structureMovement/Contraption.java | 31 +-- .../chassis/ChassisTileEntity.java | 14 +- .../glue/SuperGlueEntity.java | 8 +- .../piston/PistonContraption.java | 10 +- .../pulley/PulleyTileEntity.java | 6 +- 6 files changed, 203 insertions(+), 61 deletions(-) rename src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/{BlockMovementTraits.java => BlockMovementChecks.java} (67%) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java similarity index 67% rename from src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java rename to src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java index a7bfd1806..8e2a8fc7c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementTraits.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/BlockMovementChecks.java @@ -1,5 +1,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement; +import java.util.ArrayList; +import java.util.List; + import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.content.contraptions.components.actors.AttachedActorBlock; @@ -53,15 +56,118 @@ import net.minecraft.state.properties.AttachFace; import net.minecraft.state.properties.BedPart; import net.minecraft.state.properties.BellAttachment; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.state.properties.DoubleBlockHalf; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -public class BlockMovementTraits { +public class BlockMovementChecks { - public static boolean movementNecessary(BlockState state, World world, BlockPos pos) { + private static final List MOVEMENT_NECESSARY_CHECKS = new ArrayList<>(); + private static final List MOVEMENT_ALLOWED_CHECKS = new ArrayList<>(); + private static final List BRITTLE_CHECKS = new ArrayList<>(); + private static final List ATTACHED_CHECKS = new ArrayList<>(); + private static final List NOT_SUPPORTIVE_CHECKS = new ArrayList<>(); + + // Registration + // Add new checks to the front instead of the end + + public static void registerMovementNecessaryCheck(MovementNecessaryCheck check) { + MOVEMENT_NECESSARY_CHECKS.add(0, check); + } + + public static void registerMovementAllowedCheck(MovementAllowedCheck check) { + MOVEMENT_ALLOWED_CHECKS.add(0, check); + } + + public static void registerBrittleCheck(BrittleCheck check) { + BRITTLE_CHECKS.add(0, check); + } + + public static void registerAttachedCheck(AttachedCheck check) { + ATTACHED_CHECKS.add(0, check); + } + + public static void registerNotSupportiveCheck(NotSupportiveCheck check) { + NOT_SUPPORTIVE_CHECKS.add(0, check); + } + + public static void registerAllChecks(AllChecks checks) { + registerMovementNecessaryCheck(checks); + registerMovementAllowedCheck(checks); + registerBrittleCheck(checks); + registerAttachedCheck(checks); + registerNotSupportiveCheck(checks); + } + + // Actual check methods + + public static boolean isMovementNecessary(BlockState state, World world, BlockPos pos) { + for (MovementNecessaryCheck check : MOVEMENT_NECESSARY_CHECKS) { + CheckResult result = check.isMovementNecessary(state, world, pos); + if (result != CheckResult.PASS) { + return result.toBoolean(); + } + } + return isMovementNecessaryFallback(state, world, pos); + } + + public static boolean isMovementAllowed(BlockState state, World world, BlockPos pos) { + for (MovementAllowedCheck check : MOVEMENT_ALLOWED_CHECKS) { + CheckResult result = check.isMovementAllowed(state, world, pos); + if (result != CheckResult.PASS) { + return result.toBoolean(); + } + } + return isMovementAllowedFallback(state, world, pos); + } + + /** + * Brittle blocks will be collected first, as they may break when other blocks + * are removed before them + */ + public static boolean isBrittle(BlockState state) { + for (BrittleCheck check : BRITTLE_CHECKS) { + CheckResult result = check.isBrittle(state); + if (result != CheckResult.PASS) { + return result.toBoolean(); + } + } + return isBrittleFallback(state); + } + + /** + * Attached blocks will move if blocks they are attached to are moved + */ + public static boolean isBlockAttachedTowards(BlockState state, World world, BlockPos pos, + Direction direction) { + for (AttachedCheck check : ATTACHED_CHECKS) { + CheckResult result = check.isBlockAttachedTowards(state, world, pos, direction); + if (result != CheckResult.PASS) { + return result.toBoolean(); + } + } + return isBlockAttachedTowardsFallback(state, world, pos, direction); + } + + /** + * Non-Supportive blocks will not continue a chain of blocks picked up by e.g. a + * piston + */ + public static boolean isNotSupportive(BlockState state, Direction facing) { + for (NotSupportiveCheck check : NOT_SUPPORTIVE_CHECKS) { + CheckResult result = check.isNotSupportive(state, facing); + if (result != CheckResult.PASS) { + return result.toBoolean(); + } + } + return isNotSupportiveFallback(state, facing); + } + + // Fallback checks + + private static boolean isMovementNecessaryFallback(BlockState state, World world, BlockPos pos) { if (isBrittle(state)) return true; if (state.getBlock() instanceof FenceGateBlock) @@ -75,7 +181,7 @@ public class BlockMovementTraits { return true; } - public static boolean movementAllowed(BlockState state, World world, BlockPos pos) { + private static boolean isMovementAllowedFallback(BlockState state, World world, BlockPos pos) { Block block = state.getBlock(); if (block instanceof AbstractChassisBlock) return true; @@ -115,11 +221,7 @@ public class BlockMovementTraits { return state.getPushReaction() != PushReaction.BLOCK; } - /** - * Brittle blocks will be collected first, as they may break when other blocks - * are removed before them - */ - public static boolean isBrittle(BlockState state) { + private static boolean isBrittleFallback(BlockState state) { Block block = state.getBlock(); if (state.contains(BlockStateProperties.HANGING)) return true; @@ -147,10 +249,7 @@ public class BlockMovementTraits { return AllBlockTags.BRITTLE.tag.contains(block); } - /** - * Attached blocks will move if blocks they are attached to are moved - */ - public static boolean isBlockAttachedTowards(IBlockReader world, BlockPos pos, BlockState state, + private static boolean isBlockAttachedTowardsFallback(BlockState state, World world, BlockPos pos, Direction direction) { Block block = state.getBlock(); if (block instanceof LadderBlock) @@ -163,13 +262,15 @@ public class BlockMovementTraits { return direction == Direction.DOWN; if (block instanceof AbstractPressurePlateBlock) return direction == Direction.DOWN; - if (block instanceof DoorBlock) + if (block instanceof DoorBlock) { + if (state.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER && direction == Direction.UP) + return true; return direction == Direction.DOWN; + } if (block instanceof BedBlock) { Direction facing = state.get(BedBlock.HORIZONTAL_FACING); - if (state.get(BedBlock.PART) == BedPart.HEAD) { + if (state.get(BedBlock.PART) == BedPart.HEAD) facing = facing.getOpposite(); - } return direction == facing; } if (block instanceof RedstoneLinkBlock) @@ -226,16 +327,12 @@ public class BlockMovementTraits { return FluidTankConnectivityHandler.isConnected(world, pos, pos.offset(direction)); if (AllBlocks.STICKER.has(state) && state.get(StickerBlock.EXTENDED)) { return direction == state.get(StickerBlock.FACING) - && !notSupportive(world.getBlockState(pos.offset(direction)), direction.getOpposite()); + && !isNotSupportive(world.getBlockState(pos.offset(direction)), direction.getOpposite()); } return false; } - /** - * Non-Supportive blocks will not continue a chain of blocks picked up by e.g. a - * piston - */ - public static boolean notSupportive(BlockState state, Direction facing) { + private static boolean isNotSupportiveFallback(BlockState state, Direction facing) { if (AllBlocks.MECHANICAL_DRILL.has(state)) return state.get(BlockStateProperties.FACING) == facing; if (AllBlocks.MECHANICAL_BEARING.has(state)) @@ -266,4 +363,58 @@ public class BlockMovementTraits { return isBrittle(state); } + // Check classes + + public static interface MovementNecessaryCheck { + public CheckResult isMovementNecessary(BlockState state, World world, BlockPos pos); + } + + public static interface MovementAllowedCheck { + public CheckResult isMovementAllowed(BlockState state, World world, BlockPos pos); + } + + public static interface BrittleCheck { + /** + * Brittle blocks will be collected first, as they may break when other blocks + * are removed before them + */ + public CheckResult isBrittle(BlockState state); + } + + public static interface AttachedCheck { + /** + * Attached blocks will move if blocks they are attached to are moved + */ + public CheckResult isBlockAttachedTowards(BlockState state, World world, BlockPos pos, Direction direction); + } + + public static interface NotSupportiveCheck { + /** + * Non-Supportive blocks will not continue a chain of blocks picked up by e.g. a + * piston + */ + public CheckResult isNotSupportive(BlockState state, Direction direction); + } + + public static interface AllChecks extends MovementNecessaryCheck, MovementAllowedCheck, BrittleCheck, AttachedCheck, NotSupportiveCheck { + } + + public static enum CheckResult { + SUCCESS, + FAIL, + PASS; + + public Boolean toBoolean() { + return this == PASS ? null : (this == SUCCESS ? true : false); + } + + public static CheckResult of(boolean b) { + return b ? SUCCESS : FAIL; + } + + public static CheckResult of(Boolean b) { + return b == null ? PASS : (b ? SUCCESS : FAIL); + } + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index 9ab82f1dc..32f9a2a34 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -73,7 +73,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.ChestBlock; -import net.minecraft.block.DoorBlock; import net.minecraft.block.IWaterLoggable; import net.minecraft.block.PressurePlateBlock; import net.minecraft.block.material.PushReaction; @@ -87,7 +86,6 @@ import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.ChestType; -import net.minecraft.state.properties.DoubleBlockHalf; import net.minecraft.state.properties.PistonType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; @@ -212,7 +210,7 @@ public abstract class Contraption { if (bounds == null) bounds = new AxisAlignedBB(BlockPos.ZERO); - if (!BlockMovementTraits.isBrittle(world.getBlockState(pos))) + if (!BlockMovementChecks.isBrittle(world.getBlockState(pos))) frontier.add(pos); if (!addToInitialFrontier(world, pos, forcedDirection, frontier)) return false; @@ -312,7 +310,7 @@ public abstract class Contraption { if (isAnchoringBlockAt(pos)) return true; BlockState state = world.getBlockState(pos); - if (!BlockMovementTraits.movementNecessary(state, world, pos)) + if (!BlockMovementChecks.isMovementNecessary(state, world, pos)) return true; if (!movementAllowed(state, world, pos)) throw AssemblyException.unmovableBlock(pos, state); @@ -336,7 +334,7 @@ public abstract class Contraption { Direction offset = state.get(StickerBlock.FACING); BlockPos attached = pos.offset(offset); if (!visited.contains(attached) - && !BlockMovementTraits.notSupportive(world.getBlockState(attached), offset.getOpposite())) + && !BlockMovementChecks.isNotSupportive(world.getBlockState(attached), offset.getOpposite())) frontier.add(attached); } @@ -365,13 +363,6 @@ public abstract class Contraption { if (isPistonHead(state)) movePistonHead(world, pos, frontier, visited, state); - // Doors try to stay whole - if (state.getBlock() instanceof DoorBlock) { - BlockPos otherPartPos = pos.up(state.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? 1 : -1); - if (!visited.contains(otherPartPos)) - frontier.add(otherPartPos); - } - // Cart assemblers attach themselves BlockPos posDown = pos.down(); BlockState stateBelow = world.getBlockState(posDown); @@ -395,24 +386,24 @@ public abstract class Contraption { boolean wasVisited = visited.contains(offsetPos); boolean faceHasGlue = superglue.containsKey(offset); boolean blockAttachedTowardsFace = - BlockMovementTraits.isBlockAttachedTowards(world, offsetPos, blockState, offset.getOpposite()); - boolean brittle = BlockMovementTraits.isBrittle(blockState); + BlockMovementChecks.isBlockAttachedTowards(blockState, world, offsetPos, offset.getOpposite()); + boolean brittle = BlockMovementChecks.isBrittle(blockState); boolean canStick = !brittle && state.canStickTo(blockState) && blockState.canStickTo(state); if (canStick) { if (state.getPushReaction() == PushReaction.PUSH_ONLY || blockState.getPushReaction() == PushReaction.PUSH_ONLY) { canStick = false; } - if (BlockMovementTraits.notSupportive(state, offset)) { + if (BlockMovementChecks.isNotSupportive(state, offset)) { canStick = false; } - if (BlockMovementTraits.notSupportive(blockState, offset.getOpposite())) { + if (BlockMovementChecks.isNotSupportive(blockState, offset.getOpposite())) { canStick = false; } } if (!wasVisited && (canStick || blockAttachedTowardsFace || faceHasGlue - || (offset == forcedDirection && !BlockMovementTraits.notSupportive(state, forcedDirection)))) + || (offset == forcedDirection && !BlockMovementChecks.isNotSupportive(state, forcedDirection)))) frontier.add(offsetPos); if (faceHasGlue) addGlue(superglue.get(offset)); @@ -674,7 +665,7 @@ public abstract class Contraption { } protected boolean movementAllowed(BlockState state, World world, BlockPos pos) { - return BlockMovementTraits.movementAllowed(state, world, pos); + return BlockMovementChecks.isMovementAllowed(state, world, pos); } protected boolean isAnchoringBlockAt(BlockPos pos) { @@ -944,7 +935,7 @@ public abstract class Contraption { for (Iterator iterator = blocks.values() .iterator(); iterator.hasNext();) { BlockInfo block = iterator.next(); - if (brittles != BlockMovementTraits.isBrittle(block.state)) + if (brittles != BlockMovementChecks.isBrittle(block.state)) continue; BlockPos add = block.pos.add(anchor) @@ -981,7 +972,7 @@ public abstract class Contraption { public void addBlocksToWorld(World world, StructureTransform transform) { for (boolean nonBrittles : Iterate.trueAndFalse) { for (BlockInfo block : blocks.values()) { - if (nonBrittles == BlockMovementTraits.isBrittle(block.state)) + if (nonBrittles == BlockMovementChecks.isBrittle(block.state)) continue; BlockPos targetPos = transform.apply(block.pos); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java index 0c21d2b83..51e17c7fc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/ChassisTileEntity.java @@ -11,7 +11,7 @@ import java.util.Queue; import java.util.Set; import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits; +import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; @@ -165,14 +165,14 @@ public class ChassisTileEntity extends SmartTileEntity { break; // Ignore replaceable Blocks and Air-like - if (!BlockMovementTraits.movementNecessary(currentState, world, current)) + if (!BlockMovementChecks.isMovementNecessary(currentState, world, current)) break; - if (BlockMovementTraits.isBrittle(currentState)) + if (BlockMovementChecks.isBrittle(currentState)) break; positions.add(current); - if (BlockMovementTraits.notSupportive(currentState, facing)) + if (BlockMovementChecks.isNotSupportive(currentState, facing)) break; } } @@ -206,9 +206,9 @@ public class ChassisTileEntity extends SmartTileEntity { continue; if (!searchPos.withinDistance(pos, chassisRange + .5f)) continue; - if (!BlockMovementTraits.movementNecessary(searchedState, world, searchPos)) + if (!BlockMovementChecks.isMovementNecessary(searchedState, world, searchPos)) continue; - if (BlockMovementTraits.isBrittle(searchedState)) + if (BlockMovementChecks.isBrittle(searchedState)) continue; localVisited.add(searchPos); @@ -220,7 +220,7 @@ public class ChassisTileEntity extends SmartTileEntity { continue; if (searchPos.equals(pos) && offset != facing) continue; - if (BlockMovementTraits.notSupportive(searchedState, offset)) + if (BlockMovementChecks.isNotSupportive(searchedState, offset)) continue; localFrontier.add(searchPos.offset(offset)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java index 5a7957c92..a66c769ba 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java @@ -9,7 +9,7 @@ import com.simibubi.create.AllEntityTypes; import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock; -import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits; +import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingBlock; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.AbstractChassisBlock; import com.simibubi.create.content.schematics.ISpecialEntityItemRequirement; @@ -195,11 +195,11 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat public static boolean isValidFace(World world, BlockPos pos, Direction direction) { BlockState state = world.getBlockState(pos); - if (BlockMovementTraits.isBlockAttachedTowards(world, pos, state, direction)) + if (BlockMovementChecks.isBlockAttachedTowards(state, world, pos, direction)) return true; - if (!BlockMovementTraits.movementNecessary(state, world, pos)) + if (!BlockMovementChecks.isMovementNecessary(state, world, pos)) return false; - if (BlockMovementTraits.notSupportive(state, direction)) + if (BlockMovementChecks.isNotSupportive(state, direction)) return false; return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonContraption.java index 7c1ba23b0..b8c33f45b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonContraption.java @@ -15,7 +15,7 @@ import java.util.Queue; import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; -import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits; +import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionType; import com.simibubi.create.content.contraptions.components.structureMovement.TranslatingContraption; @@ -169,13 +169,13 @@ public class PistonContraption extends TranslatingContraption { if (!world.isBlockPresent(currentPos)) throw AssemblyException.unloadedChunk(currentPos); BlockState state = world.getBlockState(currentPos); - if (!BlockMovementTraits.movementNecessary(state, world, currentPos)) + if (!BlockMovementChecks.isMovementNecessary(state, world, currentPos)) return true; - if (BlockMovementTraits.isBrittle(state) && !(state.getBlock() instanceof CarpetBlock)) + if (BlockMovementChecks.isBrittle(state) && !(state.getBlock() instanceof CarpetBlock)) return true; if (isPistonHead(state) && state.get(FACING) == direction.getOpposite()) return true; - if (!BlockMovementTraits.movementAllowed(state, world, currentPos)) + if (!BlockMovementChecks.isMovementAllowed(state, world, currentPos)) if (retracting) return true; else @@ -183,7 +183,7 @@ public class PistonContraption extends TranslatingContraption { if (retracting && state.getPushReaction() == PushReaction.PUSH_ONLY) return true; frontier.add(currentPos); - if (BlockMovementTraits.notSupportive(state, orientation)) + if (BlockMovementChecks.isNotSupportive(state, orientation)) return true; } return true; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java index 075d08335..ec522e422 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java @@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.structureMovement.AssemblyException; -import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits; +import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionCollider; import com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.piston.LinearActuatorTileEntity; @@ -186,9 +186,9 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { BlockPos posBelow = pos.down((int) (offset + getMovementSpeed()) + 1); BlockState state = world.getBlockState(posBelow); - if (!BlockMovementTraits.movementNecessary(state, world, posBelow)) + if (!BlockMovementChecks.isMovementNecessary(state, world, posBelow)) return; - if (BlockMovementTraits.isBrittle(state)) + if (BlockMovementChecks.isBrittle(state)) return; disassemble(); From d31fe013cead44d4112eeb25cf890ed6ede15b50 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Mon, 24 May 2021 13:49:59 -0700 Subject: [PATCH 097/198] Fix dyed handle compilation error - Revert DYED_VALVE_HANDLES to using an array instead of a Vector --- src/main/java/com/simibubi/create/AllBlocks.java | 9 +++------ src/main/java/com/simibubi/create/AllTileEntities.java | 3 +-- .../contraptions/components/crank/ValveHandleBlock.java | 2 +- .../create/foundation/ponder/content/KineticsScenes.java | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 8944e78c6..c50c3701e 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -9,8 +9,6 @@ import static com.simibubi.create.foundation.data.CreateRegistrate.connectedText import static com.simibubi.create.foundation.data.ModelGen.customItemModel; import static com.simibubi.create.foundation.data.ModelGen.oxidizedItemModel; -import java.util.Vector; - import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.AllTags.AllItemTags; import com.simibubi.create.content.AllSections; @@ -627,13 +625,12 @@ public class AllBlocks { .transform(BuilderTransformers.valveHandle(null)) .register(); - public static final Vector> DYED_VALVE_HANDLES = - new Vector<>(DyeColor.values().length); + public static final BlockEntry[] DYED_VALVE_HANDLES = new BlockEntry[DyeColor.values().length]; static { for (DyeColor colour : DyeColor.values()) { String colourName = colour.getString(); - DYED_VALVE_HANDLES.add(REGISTRATE.block(colourName + "_valve_handle", ValveHandleBlock::dyed) + DYED_VALVE_HANDLES[colour.ordinal()] = REGISTRATE.block(colourName + "_valve_handle", ValveHandleBlock::dyed) .transform(BuilderTransformers.valveHandle(colour)) .recipe((c, p) -> ShapedRecipeBuilder.shapedRecipe(c.get()) .patternLine("#") @@ -642,7 +639,7 @@ public class AllBlocks { .key('-', AllItemTags.VALVE_HANDLES.tag) .addCriterion("has_valve", RegistrateRecipeProvider.hasItem(AllItemTags.VALVE_HANDLES.tag)) .build(p, Create.asResource("crafting/kinetics/" + c.getName() + "_from_other_valve_handle"))) - .register()); + .register(); } } diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index 329786289..1ff2f9a0f 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -157,7 +157,6 @@ import com.simibubi.create.content.schematics.block.SchematicannonInstance; import com.simibubi.create.content.schematics.block.SchematicannonRenderer; import com.simibubi.create.content.schematics.block.SchematicannonTileEntity; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; -import com.tterrag.registrate.util.entry.BlockEntry; import com.tterrag.registrate.util.entry.TileEntityEntry; public class AllTileEntities { @@ -249,7 +248,7 @@ public class AllTileEntities { .tileEntity("hand_crank", HandCrankTileEntity::new) .instance(() -> HandCrankInstance::new) .validBlocks(AllBlocks.HAND_CRANK, AllBlocks.COPPER_VALVE_HANDLE) - .validBlocks(AllBlocks.DYED_VALVE_HANDLES.toArray(new BlockEntry[AllBlocks.DYED_VALVE_HANDLES.size()])) + .validBlocks(AllBlocks.DYED_VALVE_HANDLES) .renderer(() -> HandCrankRenderer::new) .register(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java index e9e8c32d7..a29a996c1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java @@ -48,7 +48,7 @@ public class ValveHandleBlock extends HandCrankBlock { if (worldIn.isRemote) return ActionResultType.SUCCESS; - BlockState newState = AllBlocks.DYED_VALVE_HANDLES.get(color.ordinal()) + BlockState newState = AllBlocks.DYED_VALVE_HANDLES[color.ordinal()] .getDefaultState() .with(FACING, state.get(FACING)); if (newState != state) diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/KineticsScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/KineticsScenes.java index 3bc0ccf90..8177eb9b3 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/KineticsScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/KineticsScenes.java @@ -631,7 +631,7 @@ public class KineticsScenes { scene.overlay.showControls(new InputWindowElement(centerOf, Pointing.DOWN).rightClick() .withItem(new ItemStack(Items.BLUE_DYE)), 40); scene.idle(7); - scene.world.modifyBlock(util.grid.at(2, 2, 2), s -> AllBlocks.DYED_VALVE_HANDLES.get(11).getDefaultState() + scene.world.modifyBlock(util.grid.at(2, 2, 2), s -> AllBlocks.DYED_VALVE_HANDLES[11].getDefaultState() .with(ValveHandleBlock.FACING, Direction.UP), true); scene.idle(10); scene.overlay.showText(70) From c8814f123bbf52ab071ee5b0625811fadcbc70ef Mon Sep 17 00:00:00 2001 From: JozsefA Date: Mon, 24 May 2021 17:50:13 -0700 Subject: [PATCH 098/198] More sane models - BufferedModel is no longer abstract. - InstancedModel no longer inherits from BufferedModel, it accepts one as input. - Replace usage of IndexedModel with BufferedModel --- .../flywheel/backend/core/BufferedModel.java | 124 ++++++++++-------- .../flywheel/backend/core/IndexedModel.java | 67 ++++------ .../backend/gl/attrib/VertexFormat.java | 2 +- .../backend/instancing/InstancedModel.java | 100 +++++++------- .../backend/instancing/RenderMaterial.java | 11 +- .../jozufozu/flywheel/util/AttribUtil.java | 26 ++++ .../render/RenderedContraption.java | 16 +-- 7 files changed, 191 insertions(+), 155 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/util/AttribUtil.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java index 28825202c..74c187d76 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java @@ -1,90 +1,98 @@ package com.jozufozu.flywheel.backend.core; +import static org.lwjgl.opengl.GL20.GL_COLOR_ARRAY; +import static org.lwjgl.opengl.GL20.GL_INDEX_ARRAY; +import static org.lwjgl.opengl.GL20.GL_NORMAL_ARRAY; +import static org.lwjgl.opengl.GL20.GL_QUADS; +import static org.lwjgl.opengl.GL20.GL_TEXTURE_COORD_ARRAY; +import static org.lwjgl.opengl.GL20.GL_VERTEX_ARRAY; +import static org.lwjgl.opengl.GL20.glDisableClientState; +import static org.lwjgl.opengl.GL20.glDrawArrays; + import java.nio.ByteBuffer; -import org.lwjgl.opengl.GL20; - -import com.jozufozu.flywheel.backend.RenderWork; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; -import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; +import com.jozufozu.flywheel.util.AttribUtil; -public abstract class BufferedModel { +public class BufferedModel { protected final ByteBuffer data; - protected final VertexFormat modelFormat; + protected final VertexFormat format; protected final int vertexCount; - protected GlBuffer modelVBO; - private boolean initialized; // lazy init + protected GlBuffer vbo; private boolean removed; - protected BufferedModel(VertexFormat modelFormat, ByteBuffer data, int vertices) { + public BufferedModel(VertexFormat format, ByteBuffer data, int vertices) { this.data = data; - this.modelFormat = modelFormat; + this.format = format; this.vertexCount = vertices; + + vbo = new GlBuffer(GlBufferType.ARRAY_BUFFER); + + vbo.bind(); + // allocate the buffer on the gpu + vbo.alloc(this.data.capacity()); + + // mirror it in system memory so we can write to it, and upload our model. + vbo.getBuffer(0, this.data.capacity()) + .put(this.data) + .flush(); + vbo.unbind(); + } + + public VertexFormat getFormat() { + return format; + } + + public int getVertexCount() { + return vertexCount; + } + + public void bindBuffer() { + vbo.bind(); + } + + public void unbindBuffer() { + vbo.unbind(); } /** * Renders this model, checking first if there is anything to render. */ - public final void render() { + public void render() { if (vertexCount <= 0 || removed) return; - if (!initialized) { - // Lazily acquire resources in order to get around initialization order, as #getTotalShaderAttributeCount - // might depend on fields in subclasses. - init(); - initialized = true; - } + // TODO: minecraft sometimes leaves its state dirty on launch. this is a hack + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_INDEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); - doRender(); + vbo.bind(); + + AttribUtil.enableArrays(getAttributeCount()); + format.vertexAttribPointers(0); + + glDrawArrays(GL_QUADS, 0, vertexCount); + + AttribUtil.disableArrays(getAttributeCount()); + + vbo.unbind(); } - /** - * Set up any state and make the draw calls. - */ - protected abstract void doRender(); + public void delete() { + if (removed) return; - public final void delete() { removed = true; - if (initialized) { - RenderWork.enqueue(this::deleteInternal); - } + vbo.delete(); } - protected void init() { - modelVBO = new GlBuffer(GlBufferType.ARRAY_BUFFER); - - modelVBO.bind(); - initModel(); - modelVBO.unbind(); + public int getAttributeCount() { + return format.getAttributeCount(); } - protected void initModel() { - // allocate the buffer on the gpu - modelVBO.alloc(data.capacity()); - - // mirror it in system memory so we can write to it - MappedBuffer buffer = modelVBO.getBuffer(0, data.capacity()); - buffer.put(data); - buffer.flush(); - } - - protected int getTotalShaderAttributeCount() { - return modelFormat.getShaderAttributeCount(); - } - - protected void setupAttributes() { - int numAttributes = getTotalShaderAttributeCount(); - for (int i = 0; i <= numAttributes; i++) { - GL20.glEnableVertexAttribArray(i); - } - - modelFormat.vertexAttribPointers(0); - } - - protected void deleteInternal() { - modelVBO.delete(); - } } + diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java index 1372a13ca..cb76197d7 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java @@ -8,62 +8,49 @@ import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; -import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; +import com.jozufozu.flywheel.util.AttribUtil; public class IndexedModel extends BufferedModel { protected GlPrimitiveType eboIndexType; protected GlBuffer ebo; - public IndexedModel(VertexFormat modelFormat, ByteBuffer buf, int vertices) { + public IndexedModel(VertexFormat modelFormat, ByteBuffer buf, int vertices, ByteBuffer indices, GlPrimitiveType indexType) { super(modelFormat, buf, vertices); - } - @Override - protected void init() { - super.init(); - - createEBO(); - } - - @Override - protected void doRender() { - modelVBO.bind(); - ebo.bind(); - - setupAttributes(); - GL20.glDrawElements(GL20.GL_QUADS, vertexCount, eboIndexType.getGlConstant(), 0); - - int numAttributes = getTotalShaderAttributeCount(); - for (int i = 0; i <= numAttributes; i++) { - GL20.glDisableVertexAttribArray(i); - } - - ebo.unbind(); - modelVBO.unbind(); - } - - protected final void createEBO() { ebo = new GlBuffer(GlBufferType.ELEMENT_ARRAY_BUFFER); - eboIndexType = GlPrimitiveType.UINT; // TODO: choose this based on the number of vertices + this.eboIndexType = indexType; - int indicesSize = vertexCount * eboIndexType.getSize(); + int indicesSize = vertexCount * indexType.getSize(); ebo.bind(); ebo.alloc(indicesSize); - MappedBuffer indices = ebo.getBuffer(0, indicesSize); - for (int i = 0; i < vertexCount; i++) { - indices.putInt(i); - } - indices.flush(); + ebo.getBuffer(0, indicesSize) + .put(indices) + .flush(); ebo.unbind(); } - @Override - protected void deleteInternal() { - super.deleteInternal(); - ebo.delete(); - } + public void render() { + vbo.bind(); + ebo.bind(); + + AttribUtil.enableArrays(getAttributeCount()); + format.vertexAttribPointers(0); + + GL20.glDrawElements(GL20.GL_QUADS, vertexCount, eboIndexType.getGlConstant(), 0); + + AttribUtil.disableArrays(getAttributeCount()); + + ebo.unbind(); + vbo.unbind(); + } + + @Override + public void delete() { + super.delete(); + ebo.delete(); + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java index 9b325e6ed..9d48fd142 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java @@ -22,7 +22,7 @@ public class VertexFormat { this.stride = stride; } - public int getShaderAttributeCount() { + public int getAttributeCount() { return numAttributes; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java index a70108cbe..69a46bfac 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedModel.java @@ -1,7 +1,6 @@ package com.jozufozu.flywheel.backend.instancing; -import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.BitSet; @@ -14,31 +13,64 @@ import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; +import com.jozufozu.flywheel.util.AttribUtil; -public class InstancedModel extends BufferedModel { +public class InstancedModel { public final InstancedTileRenderer renderer; + protected final BufferedModel model; + protected final VertexFormat instanceFormat; protected final InstanceFactory factory; protected GlVertexArray vao; protected GlBuffer instanceVBO; protected int glBufferSize = -1; protected int glInstanceCount = 0; + private boolean deleted; protected final ArrayList data = new ArrayList<>(); boolean anyToRemove; boolean anyToUpdate; - public InstancedModel(VertexFormat modelFormat, ByteBuffer buf, int vertices, InstancedTileRenderer renderer, VertexFormat instanceFormat, InstanceFactory factory) { - super(modelFormat, buf, vertices); + public InstancedModel(BufferedModel model, InstancedTileRenderer renderer, VertexFormat instanceFormat, InstanceFactory factory) { + this.model = model; this.factory = factory; this.instanceFormat = instanceFormat; this.renderer = renderer; + + if (model.getVertexCount() <= 0) + throw new IllegalArgumentException("Refusing to instance a model with no vertices."); + + vao = new GlVertexArray(); + instanceVBO = new GlBuffer(GlBufferType.ARRAY_BUFFER); + + vao.bind(); + + // bind the model's vbo to our vao + model.bindBuffer(); + model.getFormat().vertexAttribPointers(0); + model.unbindBuffer(); + + // enable all the attribute arrays in our vao. we only need to do this once + AttribUtil.enableArrays(model.getAttributeCount() + this.instanceFormat.getAttributeCount()); + vao.unbind(); } - public synchronized D createInstance() { + public void render() { + if (deleted) return; + + vao.bind(); + renderSetup(); + + if (glInstanceCount > 0) + Backend.compat.drawInstanced.drawArraysInstanced(GL11.GL_QUADS, 0, model.getVertexCount(), glInstanceCount); + + vao.unbind(); + } + + public D createInstance() { D instanceData = factory.create(this); instanceData.dirty = true; anyToUpdate = true; @@ -47,39 +79,17 @@ public class InstancedModel extends BufferedModel { return instanceData; } - @Override - protected void init() { - vao = new GlVertexArray(); - instanceVBO = new GlBuffer(GlBufferType.ARRAY_BUFFER); + public void delete() { + if (deleted) return; - vao.bind(); - super.init(); - vao.unbind(); - } + deleted = true; - @Override - protected void initModel() { - super.initModel(); - setupAttributes(); - } - - protected void deleteInternal() { - super.deleteInternal(); + model.delete(); instanceVBO.delete(); vao.delete(); } - protected void doRender() { - vao.bind(); - renderSetup(); - - if (glInstanceCount > 0) - Backend.compat.drawInstanced.drawArraysInstanced(GL11.GL_QUADS, 0, vertexCount, glInstanceCount); - - vao.unbind(); - } - protected void renderSetup() { if (anyToRemove) { removeDeletedInstances(); @@ -96,23 +106,12 @@ public class InstancedModel extends BufferedModel { updateBuffer(); } + glInstanceCount = data.size(); } - glInstanceCount = data.size(); - informAttribDivisors(); instanceVBO.unbind(); - this.anyToRemove = false; - this.anyToUpdate = false; - } - - private void informAttribDivisors() { - int staticAttributes = modelFormat.getShaderAttributeCount(); - instanceFormat.vertexAttribPointers(staticAttributes); - - for (int i = 0; i < instanceFormat.getShaderAttributeCount(); i++) { - Backend.compat.instancedArrays.vertexAttribDivisor(i + staticAttributes, 1); - } + anyToRemove = anyToUpdate = false; } private void clearBufferTail() { @@ -185,6 +184,9 @@ public class InstancedModel extends BufferedModel { buffer.flush(); glInstanceCount = size; + + informAttribDivisors(); + return true; } return false; @@ -222,7 +224,13 @@ public class InstancedModel extends BufferedModel { } - protected int getTotalShaderAttributeCount() { - return instanceFormat.getShaderAttributeCount() + super.getTotalShaderAttributeCount(); + private void informAttribDivisors() { + int staticAttributes = model.getAttributeCount(); + instanceFormat.vertexAttribPointers(staticAttributes); + + for (int i = 0; i < instanceFormat.getAttributeCount(); i++) { + Backend.compat.instancedArrays.vertexAttribDivisor(i + staticAttributes, 1); + } } + } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java index 25c85b84b..0729eb6da 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderMaterial.java @@ -12,6 +12,8 @@ import org.lwjgl.opengl.GL11; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import com.jozufozu.flywheel.backend.RenderWork; +import com.jozufozu.flywheel.backend.core.BufferedModel; import com.jozufozu.flywheel.backend.core.PartialModel; import com.jozufozu.flywheel.backend.core.shader.ShaderCallback; import com.jozufozu.flywheel.backend.core.shader.WorldProgram; @@ -45,7 +47,10 @@ public class RenderMaterial

{ this.spec = spec; this.models = CacheBuilder.newBuilder() - .removalListener(notification -> ((InstancedModel) notification.getValue()).delete()) + .removalListener(notification -> { + InstancedModel model = (InstancedModel) notification.getValue(); + RenderWork.enqueue(model::delete); + }) .build(); } @@ -140,7 +145,9 @@ public class RenderMaterial

{ to.rewind(); - return new InstancedModel<>(format, to, vertexCount, renderer, spec.getInstanceFormat(), spec.getInstanceFactory()); + BufferedModel bufferedModel = new BufferedModel(format, to, vertexCount); + + return new InstancedModel<>(bufferedModel, renderer, spec.getInstanceFormat(), spec.getInstanceFactory()); } private static final Direction[] dirs; diff --git a/src/main/java/com/jozufozu/flywheel/util/AttribUtil.java b/src/main/java/com/jozufozu/flywheel/util/AttribUtil.java new file mode 100644 index 000000000..bb8cd1ce4 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/util/AttribUtil.java @@ -0,0 +1,26 @@ +package com.jozufozu.flywheel.util; + +import org.lwjgl.opengl.GL20; + +public class AttribUtil { + + public static void enableArrays(int count) { + enableArrays(0, count); + } + + public static void enableArrays(int start, int end) { + for (int i = start; i <= end; i++) { + GL20.glEnableVertexAttribArray(i); + } + } + + public static void disableArrays(int count) { + disableArrays(0, count); + } + + public static void disableArrays(int start, int end) { + for (int i = start; i <= end; i++) { + GL20.glDisableVertexAttribArray(i); + } + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index 513fa4913..d8a4aae08 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -10,7 +10,7 @@ import java.util.Map; import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.core.IndexedModel; +import com.jozufozu.flywheel.backend.core.BufferedModel; import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.instancing.IInstanceRendered; @@ -45,7 +45,7 @@ public class RenderedContraption extends ContraptionWorldHolder { private final ContraptionLighter lighter; public final ContraptionKineticRenderer kinetics; - private final Map renderLayers = new HashMap<>(); + private final Map renderLayers = new HashMap<>(); private Matrix4f model; private AxisAlignedBB lightBox; @@ -67,7 +67,7 @@ public class RenderedContraption extends ContraptionWorldHolder { } public void doRenderLayer(RenderType layer, ContraptionProgram shader) { - IndexedModel structure = renderLayers.get(layer); + BufferedModel structure = renderLayers.get(layer); if (structure != null) { setup(shader); structure.render(); @@ -108,7 +108,7 @@ public class RenderedContraption extends ContraptionWorldHolder { } void invalidate() { - for (IndexedModel buffer : renderLayers.values()) { + for (BufferedModel buffer : renderLayers.values()) { buffer.delete(); } renderLayers.clear(); @@ -119,7 +119,7 @@ public class RenderedContraption extends ContraptionWorldHolder { } private void buildLayers() { - for (IndexedModel buffer : renderLayers.values()) { + for (BufferedModel buffer : renderLayers.values()) { buffer.delete(); } @@ -128,7 +128,7 @@ public class RenderedContraption extends ContraptionWorldHolder { List blockLayers = RenderType.getBlockLayers(); for (RenderType layer : blockLayers) { - IndexedModel layerModel = buildStructureModel(renderWorld, contraption, layer); + BufferedModel layerModel = buildStructureModel(renderWorld, contraption, layer); if (layerModel != null) renderLayers.put(layer, layerModel); } } @@ -153,7 +153,7 @@ public class RenderedContraption extends ContraptionWorldHolder { } @Nullable - private static IndexedModel buildStructureModel(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { + private static BufferedModel buildStructureModel(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) { BufferBuilderReader reader = new BufferBuilderReader(ContraptionRenderDispatcher.buildStructure(renderWorld, c, layer)); int vertexCount = reader.getVertexCount(); @@ -192,6 +192,6 @@ public class RenderedContraption extends ContraptionWorldHolder { to.rewind(); - return new IndexedModel(format, to, vertexCount); + return new BufferedModel(format, to, vertexCount); } } From ffa252ac257ff2984333ea1e1636381d4984e43b Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 25 May 2021 14:43:08 +0200 Subject: [PATCH 099/198] PR compat --- .../content/schematics/block/SchematicannonTileEntity.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index 024858210..b22386aa2 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -11,7 +11,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTags.AllBlockTags; -import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits; +import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltPart; import com.simibubi.create.content.contraptions.relays.belt.BeltSlope; @@ -34,8 +34,6 @@ import com.simibubi.create.foundation.utility.IPartialSafeNBT; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.NBTProcessors; -import net.minecraft.block.AbstractRailBlock; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.PistonHeadBlock; @@ -729,7 +727,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC } public static boolean shouldDeferBlock(BlockState state) { - return state.getBlock().is(AllBlocks.GANTRY_CARRIAGE.get()) || BlockMovementTraits.isBrittle(state); + return state.getBlock().is(AllBlocks.GANTRY_CARRIAGE.get()) || BlockMovementChecks.isBrittle(state); } public void finishedPrinting() { From de451553ddccfb797b756795aa0d308525af0e8c Mon Sep 17 00:00:00 2001 From: JozsefA Date: Tue, 25 May 2021 12:46:34 -0700 Subject: [PATCH 100/198] Use VAOs for contraption structures --- .../backend/core/BufferedArrayModel.java | 48 +++++++++++++++++++ .../flywheel/backend/core/BufferedModel.java | 8 ++-- .../render/RenderedContraption.java | 6 ++- 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/BufferedArrayModel.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BufferedArrayModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/BufferedArrayModel.java new file mode 100644 index 000000000..ef8fddee2 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BufferedArrayModel.java @@ -0,0 +1,48 @@ +package com.jozufozu.flywheel.backend.core; + +import java.nio.ByteBuffer; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL20; + +import com.jozufozu.flywheel.backend.gl.GlVertexArray; +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.util.AttribUtil; + +public class BufferedArrayModel extends BufferedModel { + + protected GlVertexArray vao; + + public BufferedArrayModel(VertexFormat format, ByteBuffer data, int vertices) { + super(format, data, vertices); + + vao = new GlVertexArray(); + + vao.bind(); + + // bind the model's vbo to our vao + vbo.bind(); + getFormat().vertexAttribPointers(0); + vbo.unbind(); + + // enable all the attribute arrays in our vao. we only need to do this once + AttribUtil.enableArrays(getAttributeCount()); + vao.unbind(); + } + + public void render() { + if (vertexCount <= 0 || deleted) return; + + vao.bind(); + + GL20.glDrawArrays(GL11.GL_QUADS, 0, vertexCount); + + vao.unbind(); + } + + @Override + public void delete() { + super.delete(); + vao.delete(); + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java index 74c187d76..ab79726f8 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/BufferedModel.java @@ -22,7 +22,7 @@ public class BufferedModel { protected final VertexFormat format; protected final int vertexCount; protected GlBuffer vbo; - private boolean removed; + protected boolean deleted; public BufferedModel(VertexFormat format, ByteBuffer data, int vertices) { this.data = data; @@ -62,7 +62,7 @@ public class BufferedModel { * Renders this model, checking first if there is anything to render. */ public void render() { - if (vertexCount <= 0 || removed) return; + if (vertexCount <= 0 || deleted) return; // TODO: minecraft sometimes leaves its state dirty on launch. this is a hack glDisableClientState(GL_VERTEX_ARRAY); @@ -84,9 +84,9 @@ public class BufferedModel { } public void delete() { - if (removed) return; + if (deleted) return; - removed = true; + deleted = true; vbo.delete(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java index d8a4aae08..40dce589a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/RenderedContraption.java @@ -10,6 +10,7 @@ import java.util.Map; import javax.annotation.Nullable; import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.core.BufferedArrayModel; import com.jozufozu.flywheel.backend.core.BufferedModel; import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; @@ -192,6 +193,9 @@ public class RenderedContraption extends ContraptionWorldHolder { to.rewind(); - return new BufferedModel(format, to, vertexCount); + if (Backend.compat.vertexArrayObjectsSupported()) + return new BufferedArrayModel(format, to, vertexCount); + else + return new BufferedModel(format, to, vertexCount); } } From 73fd42baf5a353cad48c18cac33819195db3dc2d Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Tue, 25 May 2021 22:33:44 -0400 Subject: [PATCH 101/198] Add button to open new config menu --- .../create/foundation/config/CClient.java | 14 +++ .../config/ui/OpenConfigButton.java | 114 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 src/main/java/com/simibubi/create/foundation/config/ui/OpenConfigButton.java diff --git a/src/main/java/com/simibubi/create/foundation/config/CClient.java b/src/main/java/com/simibubi/create/foundation/config/CClient.java index ce9017241..ebe8f1e31 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CClient.java +++ b/src/main/java/com/simibubi/create/foundation/config/CClient.java @@ -19,6 +19,20 @@ public class CClient extends ConfigBase { public ConfigInt overlayOffsetY = i(0, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetY", "Offset the overlay from goggle- and hover- information by this many pixels on the Y axis; Use /create overlay"); + public ConfigInt mainMenuConfigButtonRow = i(2, 0, 4, "mainMenuConfigButtonRow", + "Choose the menu row that the Create config button appears on in the main menu", + "Set to 0 to disable the button altogether"); + public ConfigInt mainMenuConfigButtonOffsetX = i(-4, Integer.MIN_VALUE, Integer.MAX_VALUE, "mainMenuConfigButtonOffsetX", + "Offset the Create config button in the main menu by this many pixels on the X axis", + "The sign (+/-) of this value determines what side of the row the button appears on (right/left)"); + + public ConfigInt ingameMenuConfigButtonRow = i(3, 0, 5, "ingameMenuConfigButtonRow", + "Choose the menu row that the Create config button appears on in the in-game menu", + "Set to 0 to disable the button altogether"); + public ConfigInt ingameMenuConfigButtonOffsetX = i(-4, Integer.MIN_VALUE, Integer.MAX_VALUE, "ingameMenuConfigButtonOffsetX", + "Offset the Create config button in the in-game menu by this many pixels on the X axis", + "The sign (+/-) of this value determines what side of the row the button appears on (right/left)"); + public ConfigBool ignoreFabulousWarning = b(false, "ignoreFabulousWarning", "Setting this to true will prevent Create from sending you a warning when playing with Fabulous graphics enabled"); diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/OpenConfigButton.java b/src/main/java/com/simibubi/create/foundation/config/ui/OpenConfigButton.java new file mode 100644 index 000000000..07dd44942 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/config/ui/OpenConfigButton.java @@ -0,0 +1,114 @@ +package com.simibubi.create.foundation.config.ui; + +import com.mojang.blaze3d.matrix.MatrixStack; + +import com.simibubi.create.AllItems; + +import com.simibubi.create.foundation.config.AllConfigs; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.IngameMenuScreen; +import net.minecraft.client.gui.screen.MainMenuScreen; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.StringTextComponent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class OpenConfigButton extends Button { + + public static ItemStack icon = AllItems.GOGGLES.asStack(); + + public OpenConfigButton(int x, int y) { + super(x, y, 20, 20, StringTextComponent.EMPTY, OpenConfigButton::click); + } + + @Override + public void render(MatrixStack mstack, int mouseX, int mouseY, float pticks) { + super.render(mstack, mouseX, mouseY, pticks); + Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(icon, x + 2, y + 2); + } + + public static void click(Button b) { + Minecraft.getInstance().displayGuiScreen(new BaseConfigScreen(Minecraft.getInstance().currentScreen)); + } + + public static class SingleMenuRow { + public final String left, right; + public SingleMenuRow(String left, String right) { + this.left = I18n.format(left); + this.right = I18n.format(right); + } + public SingleMenuRow(String center) { + this(center, center); + } + } + + public static class MenuRows { + public static final MenuRows MAIN_MENU = new MenuRows(Arrays.asList( + new SingleMenuRow("menu.singleplayer"), + new SingleMenuRow("menu.multiplayer"), + new SingleMenuRow("fml.menu.mods", "menu.online"), + new SingleMenuRow("narrator.button.language", "narrator.button.accessibility") + )); + + public static final MenuRows INGAME_MENU = new MenuRows(Arrays.asList( + new SingleMenuRow("menu.returnToGame"), + new SingleMenuRow("gui.advancements", "gui.stats"), + new SingleMenuRow("menu.sendFeedback", "menu.reportBugs"), + new SingleMenuRow("menu.options", "menu.shareToLan"), + new SingleMenuRow("menu.returnToMenu") + )); + + protected final List leftButtons, rightButtons; + + public MenuRows(List variants) { + leftButtons = variants.stream().map(r -> r.left).collect(Collectors.toList()); + rightButtons = variants.stream().map(r -> r.right).collect(Collectors.toList()); + } + } + + @EventBusSubscriber(value = Dist.CLIENT) + public static class OpenConfigButtonHandler { + + @SubscribeEvent + public static void onGuiInit(GuiScreenEvent.InitGuiEvent event) { + Screen gui = event.getGui(); + + MenuRows menu = null; + int rowIdx = 0, offsetX = 0; + if (gui instanceof MainMenuScreen) { + menu = MenuRows.MAIN_MENU; + rowIdx = AllConfigs.CLIENT.mainMenuConfigButtonRow.get(); + offsetX = AllConfigs.CLIENT.mainMenuConfigButtonOffsetX.get(); + } else if (gui instanceof IngameMenuScreen) { + menu = MenuRows.INGAME_MENU; + rowIdx = AllConfigs.CLIENT.ingameMenuConfigButtonRow.get(); + offsetX = AllConfigs.CLIENT.ingameMenuConfigButtonOffsetX.get(); + } + + if (rowIdx != 0 && menu != null) { + boolean onLeft = offsetX < 0; + String target = (onLeft ? menu.leftButtons : menu.rightButtons).get(rowIdx - 1); + + int offsetX_ = offsetX; + event.getWidgetList().stream() + .filter(w -> w.getMessage().getString().equals(target)) + .findFirst() + .ifPresent(w -> event.addWidget( + new OpenConfigButton(w.x + offsetX_ + (onLeft ? -20 : w.getWidth()), w.y) + )); + } + } + + } + +} From 09691b4b40fc339a4e3dedec83358472e3e01725 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 26 May 2021 22:03:06 +0200 Subject: [PATCH 102/198] Redstone gamepads - Added the Linked Controller --- src/generated/resources/.cache/cache | 33 +-- .../resources/assets/create/lang/en_ud.json | 1 + .../resources/assets/create/lang/en_us.json | 7 + .../assets/create/lang/unfinished/de_de.json | 9 +- .../assets/create/lang/unfinished/es_es.json | 9 +- .../assets/create/lang/unfinished/es_mx.json | 9 +- .../assets/create/lang/unfinished/fr_fr.json | 9 +- .../assets/create/lang/unfinished/it_it.json | 9 +- .../assets/create/lang/unfinished/ja_jp.json | 9 +- .../assets/create/lang/unfinished/ko_kr.json | 9 +- .../assets/create/lang/unfinished/nl_nl.json | 9 +- .../assets/create/lang/unfinished/pl_pl.json | 9 +- .../assets/create/lang/unfinished/pt_br.json | 9 +- .../assets/create/lang/unfinished/ru_ru.json | 9 +- .../assets/create/lang/unfinished/zh_cn.json | 9 +- .../assets/create/lang/unfinished/zh_tw.json | 9 +- .../create/models/item/linked_controller.json | 3 + .../data/create/advancements/aesthetics.json | 4 +- .../simibubi/create/AllContainerTypes.java | 5 + .../java/com/simibubi/create/AllItems.java | 8 + .../goggles/GoggleOverlayRenderer.java | 4 +- .../content/logistics/IRedstoneLinkable.java | 23 ++ .../logistics/RedstoneLinkNetworkHandler.java | 66 +++-- .../item/LinkedControllerBindPacket.java | 55 +++++ .../item/LinkedControllerClientHandler.java | 225 ++++++++++++++++++ .../item/LinkedControllerContainer.java | 152 ++++++++++++ .../item/LinkedControllerInputPacket.java | 50 ++++ .../logistics/item/LinkedControllerItem.java | 116 +++++++++ .../item/LinkedControllerItemRenderer.java | 134 +++++++++++ .../logistics/item/LinkedControllerModel.java | 20 ++ .../item/LinkedControllerPacketBase.java | 37 +++ .../item/LinkedControllerScreen.java | 134 +++++++++++ .../item/LinkedControllerServerHandler.java | 123 ++++++++++ .../item/filter/AbstractFilterContainer.java | 7 +- .../item/filter/AbstractFilterScreen.java | 4 +- .../item/filter/AttributeFilterContainer.java | 2 +- .../item/filter/FilterScreenPacket.java | 10 +- .../simibubi/create/events/ClientEvents.java | 4 + .../simibubi/create/events/CommonEvents.java | 2 + .../create/foundation/gui/AllGuiTextures.java | 2 + .../foundation/gui/ClearContainerPacket.java | 36 +++ .../foundation/gui/IClearableContainer.java | 13 + .../foundation/networking/AllPackets.java | 8 +- .../foundation/renderState/RenderTypes.java | 2 +- .../tileEntity/TileEntityBehaviour.java | 1 - .../behaviour/linked/LinkBehaviour.java | 38 ++- .../behaviour/linked/LinkHandler.java | 11 +- .../assets/create/lang/default/messages.json | 6 + .../models/item/linked_controller/button.json | 22 ++ .../models/item/linked_controller/item.json | 166 +++++++++++++ .../item/linked_controller/powered.json | 94 ++++++++ .../create/textures/gui/curiosities2.png | Bin 0 -> 1407 bytes .../textures/item/linked_controller.png | Bin 0 -> 351 bytes .../item/linked_controller_powered.png | Bin 0 -> 350 bytes .../create/textures/item/refined_radiance.png | Bin 242 -> 262 bytes 55 files changed, 1649 insertions(+), 96 deletions(-) create mode 100644 src/generated/resources/assets/create/models/item/linked_controller.json create mode 100644 src/main/java/com/simibubi/create/content/logistics/IRedstoneLinkable.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerBindPacket.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerContainer.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerInputPacket.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItem.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerPacketBase.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerScreen.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerServerHandler.java create mode 100644 src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java create mode 100644 src/main/java/com/simibubi/create/foundation/gui/IClearableContainer.java create mode 100644 src/main/resources/assets/create/models/item/linked_controller/button.json create mode 100644 src/main/resources/assets/create/models/item/linked_controller/item.json create mode 100644 src/main/resources/assets/create/models/item/linked_controller/powered.json create mode 100644 src/main/resources/assets/create/textures/gui/curiosities2.png create mode 100644 src/main/resources/assets/create/textures/item/linked_controller.png create mode 100644 src/main/resources/assets/create/textures/item/linked_controller_powered.png diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index fb6f24a64..091f2d332 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -407,21 +407,21 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j 6801fa1f466f172700e573e5b8ee8ee5f9ca4583 assets/create/blockstates/yellow_valve_handle.json 7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json -a6d814f94926d88764c38862cc4ece9c367e023b assets/create/lang/en_ud.json -d1838140c8383ee4537db90eb8f657d0c268fe91 assets/create/lang/en_us.json -4fcda300efe5a2ad8695b5ae3f24a54ea109a954 assets/create/lang/unfinished/de_de.json -6a1dde57b2224d4b0287ebc705d6a75d329b5e1f assets/create/lang/unfinished/es_es.json -93ee0e30a56b405a9e766d353c36276e36a84b5c assets/create/lang/unfinished/es_mx.json -49a691320c73e09f921cd0ea97398126231e99fa assets/create/lang/unfinished/fr_fr.json -cf14b3828b6c11013f606f277d88fb63245bb2a8 assets/create/lang/unfinished/it_it.json -73c1c1489833cbcb28bb1ce90541c8c8bdf329c0 assets/create/lang/unfinished/ja_jp.json -924303b9bcf56aedbbfc46108655f71324308e12 assets/create/lang/unfinished/ko_kr.json -079aea6843e756efbfca0976983be1957863717c assets/create/lang/unfinished/nl_nl.json -b7bab15167400ee48a9728f81446e572c494fd8d assets/create/lang/unfinished/pl_pl.json -07e84cc3eee3faa1ab3d26e0c85c7f09c8573368 assets/create/lang/unfinished/pt_br.json -6ffb0cf20d712aee23a42a9ec440dd7dc92293d6 assets/create/lang/unfinished/ru_ru.json -0ae98a18e59f478da41d8c5d832737b65f6a8c8a assets/create/lang/unfinished/zh_cn.json -4c96e5a76e72368a59190b7588d389fdd2cc75e1 assets/create/lang/unfinished/zh_tw.json +e9c463e0cf56ed28ee26a33debeae3ecc2e941d2 assets/create/lang/en_ud.json +a9a31be19fc2e109967e68b63746dee766b8b4d1 assets/create/lang/en_us.json +916eb5e579f283b81f100098bf168203d75db5c5 assets/create/lang/unfinished/de_de.json +fc1a5dc58cb00012cd311f909de3cd6085664994 assets/create/lang/unfinished/es_es.json +7716f8e2a1cc161778e627f6c1f527356cfd34f9 assets/create/lang/unfinished/es_mx.json +2e032434706937780312c8c9a72ec0e0a8f1a8e6 assets/create/lang/unfinished/fr_fr.json +011b39c4217c2d5da59d0c8f4fd3c5f272a91c3e assets/create/lang/unfinished/it_it.json +dd04db4e469ece034e9edde1d182d40ece3c917f assets/create/lang/unfinished/ja_jp.json +a46af574991af844c58a7fe75b4c2b0ac888b4e0 assets/create/lang/unfinished/ko_kr.json +1ee72b0c9ac509ffcd17b19d17ab1f4b3506c9ce assets/create/lang/unfinished/nl_nl.json +b23f249ef0b28b2e2312e63f2fccf4401b282ac4 assets/create/lang/unfinished/pl_pl.json +73030bf3d5aace5c3e991c6bf265322bba42286f assets/create/lang/unfinished/pt_br.json +73b1927e1d32e4229caa96e8d1bc25d39fb51377 assets/create/lang/unfinished/ru_ru.json +aa3f0b918d948795e10878c3d42dbd4c39f71795 assets/create/lang/unfinished/zh_cn.json +1f15238d524e7b94b0ce5bcd09703b4742b9f960 assets/create/lang/unfinished/zh_tw.json 487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json 3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json @@ -1452,6 +1452,7 @@ ebdf23b99b7895e347c29057c8070a6e16e56beb assets/create/models/item/limestone_cob 288da8b29a4e9d0d0b694567a61b5a816a2859b8 assets/create/models/item/limestone_cobblestone_wall.json 8065de871ad2fbaed711735561b8ed91a2ce0004 assets/create/models/item/limestone_pillar.json d245aa4994ff197b1ffeb7980d05f96bd20cdeb3 assets/create/models/item/linear_chassis.json +2866bff509b060cd3ee99b4eef25a4e1e4639703 assets/create/models/item/linked_controller.json d912be3e87f2beaa8e22747f867739139667241b assets/create/models/item/magenta_seat.json 928c5e3747fb758d2610475258cc168b0d4ee7b6 assets/create/models/item/magenta_valve_handle.json 932facf4bf93b471e8630f4132a4284a9f4d0d39 assets/create/models/item/mechanical_arm.json @@ -1652,7 +1653,7 @@ d080b1b25e5bc8baf5aee68691b08c7f12ece3b0 assets/create/models/item/windmill_bear a80fb25a0b655e76be986b5b49fcb0f03461a1ab assets/create/models/item/zinc_nugget.json b1689617190c05ef34bd18456b0c7ae09bb3210f assets/create/models/item/zinc_ore.json 096382a4c025b5ffdde9c496ee9da0d5345fbe17 assets/create/sounds.json -5d0cc4c0255dc241e61c173b31ddca70c88d08e4 data/create/advancements/aesthetics.json +0f1b4b980afba9bf2caf583b88e261bba8b10313 data/create/advancements/aesthetics.json 187921fa131b06721bfaf63f2623a28c141aae9a data/create/advancements/andesite_alloy.json 0ea2db7173b5be28b289ea7c9a6a0cf5805c60c7 data/create/advancements/andesite_casing.json 83c046bd200623933545c9e4326f782fb02c87fa data/create/advancements/arm_blaze_burner.json diff --git a/src/generated/resources/assets/create/lang/en_ud.json b/src/generated/resources/assets/create/lang/en_ud.json index 12c9bc03a..80d533b06 100644 --- a/src/generated/resources/assets/create/lang/en_ud.json +++ b/src/generated/resources/assets/create/lang/en_ud.json @@ -468,6 +468,7 @@ "item.create.integrated_circuit": "\u0287\u0131n\u0254\u0279\u0131\u0186 p\u01DD\u0287\u0250\u0279b\u01DD\u0287uI", "item.create.iron_sheet": "\u0287\u01DD\u01DD\u0265S uo\u0279I", "item.create.lapis_sheet": "\u0287\u01DD\u01DD\u0265S s\u0131d\u0250\uA780", + "item.create.linked_controller": "\u0279\u01DD\u05DF\u05DFo\u0279\u0287uo\u0186 p\u01DD\u029Eu\u0131\uA780", "item.create.minecart_contraption": "uo\u0131\u0287d\u0250\u0279\u0287uo\u0186 \u0287\u0279\u0250\u0254\u01DDu\u0131W", "item.create.minecart_coupling": "bu\u0131\u05DFdno\u0186 \u0287\u0279\u0250\u0254\u01DDu\u0131W", "item.create.polished_rose_quartz": "z\u0287\u0279\u0250n\u1F49 \u01DDso\u1D1A p\u01DD\u0265s\u0131\u05DFo\u0500", diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index 427d2c658..5386c44f9 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -474,6 +474,7 @@ "item.create.integrated_circuit": "Integrated Circuit", "item.create.iron_sheet": "Iron Sheet", "item.create.lapis_sheet": "Lapis Sheet", + "item.create.linked_controller": "Linked Controller", "item.create.minecart_contraption": "Minecart Contraption", "item.create.minecart_coupling": "Minecart Coupling", "item.create.polished_rose_quartz": "Polished Rose Quartz", @@ -1104,6 +1105,12 @@ "create.tooltip.chute.fans_pull_down": "Fans pull from Below", "create.tooltip.chute.contains": "Contains: %1$s x%2$s", + "create.linked_controller.bind_mode": "Bind mode active", + "create.linked_controller.press_keybind": "Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "Bottomless Supply", "create.hint.hose_pulley": "The targeted body of fluid is considered infinite.", "create.hint.mechanical_arm_no_targets.title": "No Targets", diff --git a/src/generated/resources/assets/create/lang/unfinished/de_de.json b/src/generated/resources/assets/create/lang/unfinished/de_de.json index bffa0a121..35b456937 100644 --- a/src/generated/resources/assets/create/lang/unfinished/de_de.json +++ b/src/generated/resources/assets/create/lang/unfinished/de_de.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 942", + "_": "Missing Localizations: 948", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "Integrierter Schaltkreis", "item.create.iron_sheet": "Eisenblech", "item.create.lapis_sheet": "Lapislazuliblech", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "Loren Vorrichtung", "item.create.minecart_coupling": "Lorenkupplung", "item.create.polished_rose_quartz": "Polierter Rosenquarz", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "Propeller ziehen von unterhalb", "create.tooltip.chute.contains": "Enthält: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "Endlose Versorgung", "create.hint.hose_pulley": "Das angewählte Gewässer wird als unendlich betrachtet.", "create.hint.mechanical_arm_no_targets.title": "Keine Ziele", diff --git a/src/generated/resources/assets/create/lang/unfinished/es_es.json b/src/generated/resources/assets/create/lang/unfinished/es_es.json index 12880cfef..0d801148c 100644 --- a/src/generated/resources/assets/create/lang/unfinished/es_es.json +++ b/src/generated/resources/assets/create/lang/unfinished/es_es.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 643", + "_": "Missing Localizations: 649", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "Chip de circuito integrado", "item.create.iron_sheet": "Lámina de hierro", "item.create.lapis_sheet": "Lámina de lapislázuli", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "Artilugio de vagoneta", "item.create.minecart_coupling": "Acoplamiento de vagoneta", "item.create.polished_rose_quartz": "Cuarzo rosado pulido", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "Los ventiladores tiran desde abajo", "create.tooltip.chute.contains": "Contiene: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "Suministro sin fondo", "create.hint.hose_pulley": "La masa de fluido objetivo se considera infinita", "create.hint.mechanical_arm_no_targets.title": "No hay objetivos", diff --git a/src/generated/resources/assets/create/lang/unfinished/es_mx.json b/src/generated/resources/assets/create/lang/unfinished/es_mx.json index f3de8dd15..6919bdae1 100644 --- a/src/generated/resources/assets/create/lang/unfinished/es_mx.json +++ b/src/generated/resources/assets/create/lang/unfinished/es_mx.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1266", + "_": "Missing Localizations: 1272", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "Circuito Integrado", "item.create.iron_sheet": "Lámina de Hierro", "item.create.lapis_sheet": "Lámina de Lapislázuli", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "Artefacto de Vagón", "item.create.minecart_coupling": "Acoplamiento de Vagonetas", "item.create.polished_rose_quartz": "Cuarzo Rosa Pulido", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "UNLOCALIZED: Fans pull from Below", "create.tooltip.chute.contains": "UNLOCALIZED: Contains: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "UNLOCALIZED: Bottomless Supply", "create.hint.hose_pulley": "UNLOCALIZED: The targeted body of fluid is considered infinite.", "create.hint.mechanical_arm_no_targets.title": "UNLOCALIZED: No Targets", diff --git a/src/generated/resources/assets/create/lang/unfinished/fr_fr.json b/src/generated/resources/assets/create/lang/unfinished/fr_fr.json index 558c2ff87..f6b6cc6a8 100644 --- a/src/generated/resources/assets/create/lang/unfinished/fr_fr.json +++ b/src/generated/resources/assets/create/lang/unfinished/fr_fr.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1194", + "_": "Missing Localizations: 1200", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "Circuit intégré", "item.create.iron_sheet": "Plaque de Fer", "item.create.lapis_sheet": "Feuille de lapis", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "Engin de wagonnet", "item.create.minecart_coupling": "Lien pour wagonnet", "item.create.polished_rose_quartz": "Quartz rose poli", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "UNLOCALIZED: Fans pull from Below", "create.tooltip.chute.contains": "UNLOCALIZED: Contains: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "UNLOCALIZED: Bottomless Supply", "create.hint.hose_pulley": "UNLOCALIZED: The targeted body of fluid is considered infinite.", "create.hint.mechanical_arm_no_targets.title": "UNLOCALIZED: No Targets", diff --git a/src/generated/resources/assets/create/lang/unfinished/it_it.json b/src/generated/resources/assets/create/lang/unfinished/it_it.json index afa0b3942..687d7ca8b 100644 --- a/src/generated/resources/assets/create/lang/unfinished/it_it.json +++ b/src/generated/resources/assets/create/lang/unfinished/it_it.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 660", + "_": "Missing Localizations: 666", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "Circuito integrato", "item.create.iron_sheet": "Lamiera di ferro", "item.create.lapis_sheet": "Lamiera di lapislazzuli", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "Contrazione per carrello da miniera", "item.create.minecart_coupling": "Aggancio per carrelli da miniera", "item.create.polished_rose_quartz": "Quarzo rosa levigato", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "I ventilatori tirano da sotto", "create.tooltip.chute.contains": "Contiene: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "Buco senza fondo", "create.hint.hose_pulley": "Il corpo fluido selezionato è considerato infinito.", "create.hint.mechanical_arm_no_targets.title": "Nessun bersaglio", diff --git a/src/generated/resources/assets/create/lang/unfinished/ja_jp.json b/src/generated/resources/assets/create/lang/unfinished/ja_jp.json index 9bf53aabf..57dc32780 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ja_jp.json +++ b/src/generated/resources/assets/create/lang/unfinished/ja_jp.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 24", + "_": "Missing Localizations: 30", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "集積回路", "item.create.iron_sheet": "鉄板", "item.create.lapis_sheet": "ラピスラズリ板", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "からくり付きトロッコ", "item.create.minecart_coupling": "トロッコ連結器", "item.create.polished_rose_quartz": "磨かれたローズクォーツ", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "ファンが下から吸い込んでいます", "create.tooltip.chute.contains": "内容物: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "底なし搬出", "create.hint.hose_pulley": "対象となる液体は無限とみなされています。", "create.hint.mechanical_arm_no_targets.title": "ターゲットが見つかりません", diff --git a/src/generated/resources/assets/create/lang/unfinished/ko_kr.json b/src/generated/resources/assets/create/lang/unfinished/ko_kr.json index 17289ec89..2b0032b45 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ko_kr.json +++ b/src/generated/resources/assets/create/lang/unfinished/ko_kr.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 713", + "_": "Missing Localizations: 719", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "집적 회로", "item.create.iron_sheet": "철 판", "item.create.lapis_sheet": "청금석 판", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "광산 수레 장치", "item.create.minecart_coupling": "광산 수레 커플링", "item.create.polished_rose_quartz": "윤나는 장밋빛 석영", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "선풍기가 아래에서 당김", "create.tooltip.chute.contains": "UNLOCALIZED: Contains: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "UNLOCALIZED: Bottomless Supply", "create.hint.hose_pulley": "UNLOCALIZED: The targeted body of fluid is considered infinite.", "create.hint.mechanical_arm_no_targets.title": "목표 없음", diff --git a/src/generated/resources/assets/create/lang/unfinished/nl_nl.json b/src/generated/resources/assets/create/lang/unfinished/nl_nl.json index acb783a8e..a6cd4e26d 100644 --- a/src/generated/resources/assets/create/lang/unfinished/nl_nl.json +++ b/src/generated/resources/assets/create/lang/unfinished/nl_nl.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1577", + "_": "Missing Localizations: 1583", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "UNLOCALIZED: Integrated Circuit", "item.create.iron_sheet": "IJzeren Platen", "item.create.lapis_sheet": "UNLOCALIZED: Lapis Sheet", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "UNLOCALIZED: Minecart Contraption", "item.create.minecart_coupling": "UNLOCALIZED: Minecart Coupling", "item.create.polished_rose_quartz": "UNLOCALIZED: Polished Rose Quartz", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "UNLOCALIZED: Fans pull from Below", "create.tooltip.chute.contains": "UNLOCALIZED: Contains: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "UNLOCALIZED: Bottomless Supply", "create.hint.hose_pulley": "UNLOCALIZED: The targeted body of fluid is considered infinite.", "create.hint.mechanical_arm_no_targets.title": "UNLOCALIZED: No Targets", diff --git a/src/generated/resources/assets/create/lang/unfinished/pl_pl.json b/src/generated/resources/assets/create/lang/unfinished/pl_pl.json index 3b4dd77cd..e52917f1b 100644 --- a/src/generated/resources/assets/create/lang/unfinished/pl_pl.json +++ b/src/generated/resources/assets/create/lang/unfinished/pl_pl.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 38", + "_": "Missing Localizations: 44", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "Układ scalony", "item.create.iron_sheet": "Arkusz żelaza", "item.create.lapis_sheet": "Arkusz lazurytu", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "Maszyna w wagoniku", "item.create.minecart_coupling": "Łącznik wagoników", "item.create.polished_rose_quartz": "Wypolerowany kwarc różowy", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "Wiatraki ciągną od dołu", "create.tooltip.chute.contains": "Zawiera: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "Niewyczerpany zapas", "create.hint.hose_pulley": "Wybrane zbiornik cieczy jest uznany za nieskończony", "create.hint.mechanical_arm_no_targets.title": "Brak celi", diff --git a/src/generated/resources/assets/create/lang/unfinished/pt_br.json b/src/generated/resources/assets/create/lang/unfinished/pt_br.json index 4d81d99bb..dc42dec85 100644 --- a/src/generated/resources/assets/create/lang/unfinished/pt_br.json +++ b/src/generated/resources/assets/create/lang/unfinished/pt_br.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1629", + "_": "Missing Localizations: 1635", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "UNLOCALIZED: Integrated Circuit", "item.create.iron_sheet": "Placas de Ferro", "item.create.lapis_sheet": "UNLOCALIZED: Lapis Sheet", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "UNLOCALIZED: Minecart Contraption", "item.create.minecart_coupling": "UNLOCALIZED: Minecart Coupling", "item.create.polished_rose_quartz": "UNLOCALIZED: Polished Rose Quartz", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "UNLOCALIZED: Fans pull from Below", "create.tooltip.chute.contains": "UNLOCALIZED: Contains: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "UNLOCALIZED: Bottomless Supply", "create.hint.hose_pulley": "UNLOCALIZED: The targeted body of fluid is considered infinite.", "create.hint.mechanical_arm_no_targets.title": "UNLOCALIZED: No Targets", diff --git a/src/generated/resources/assets/create/lang/unfinished/ru_ru.json b/src/generated/resources/assets/create/lang/unfinished/ru_ru.json index 1f092d472..994185e4e 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ru_ru.json +++ b/src/generated/resources/assets/create/lang/unfinished/ru_ru.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 557", + "_": "Missing Localizations: 563", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "Интегральная схема", "item.create.iron_sheet": "Железный лист", "item.create.lapis_sheet": "Лазуритовый лист", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "Вагонеточная штуковина", "item.create.minecart_coupling": "Связыватель вагонеток", "item.create.polished_rose_quartz": "Полированный розовый кварц", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "Вентилятор тянет снизу", "create.tooltip.chute.contains": "Содержит: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "Безграничное снабжение", "create.hint.hose_pulley": "Целевой водный резервуар считается бесконечным.", "create.hint.mechanical_arm_no_targets.title": "Нет целей", diff --git a/src/generated/resources/assets/create/lang/unfinished/zh_cn.json b/src/generated/resources/assets/create/lang/unfinished/zh_cn.json index 513325f0d..2e733b1b0 100644 --- a/src/generated/resources/assets/create/lang/unfinished/zh_cn.json +++ b/src/generated/resources/assets/create/lang/unfinished/zh_cn.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 43", + "_": "Missing Localizations: 49", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "集成电路板", "item.create.iron_sheet": "铁板", "item.create.lapis_sheet": "青金石板", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "装配过的矿车", "item.create.minecart_coupling": "矿车连轴器", "item.create.polished_rose_quartz": "磨制玫瑰石英", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "鼓风机从下方进行吸引", "create.tooltip.chute.contains": "内含物品:%1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "无限供应", "create.hint.hose_pulley": "目标液体对象被视为无限量的。", "create.hint.mechanical_arm_no_targets.title": "没有目标", diff --git a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json index 8b3a4f40a..5514b4f70 100644 --- a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json +++ b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 662", + "_": "Missing Localizations: 668", "_": "->------------------------] Game Elements [------------------------<-", @@ -475,6 +475,7 @@ "item.create.integrated_circuit": "IC板", "item.create.iron_sheet": "鐵板", "item.create.lapis_sheet": "青金石板", + "item.create.linked_controller": "UNLOCALIZED: Linked Controller", "item.create.minecart_contraption": "裝修過的礦車", "item.create.minecart_coupling": "礦車連結器", "item.create.polished_rose_quartz": "磨製玫瑰石英", @@ -1105,6 +1106,12 @@ "create.tooltip.chute.fans_pull_down": "鼓風機從上方進行吸引", "create.tooltip.chute.contains": "UNLOCALIZED: Contains: %1$s x%2$s", + "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", + "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "UNLOCALIZED: Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "UNLOCALIZED: Bottomless Supply", "create.hint.hose_pulley": "UNLOCALIZED: The targeted body of fluid is considered infinite.", "create.hint.mechanical_arm_no_targets.title": "沒有目標", diff --git a/src/generated/resources/assets/create/models/item/linked_controller.json b/src/generated/resources/assets/create/models/item/linked_controller.json new file mode 100644 index 000000000..6bf114f21 --- /dev/null +++ b/src/generated/resources/assets/create/models/item/linked_controller.json @@ -0,0 +1,3 @@ +{ + "parent": "create:item/linked_controller/item" +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/aesthetics.json b/src/generated/resources/data/create/advancements/aesthetics.json index 59a86f429..d723cbe38 100644 --- a/src/generated/resources/data/create/advancements/aesthetics.json +++ b/src/generated/resources/data/create/advancements/aesthetics.json @@ -28,8 +28,8 @@ "trigger": "create:bracket_apply", "conditions": { "accepted_entries": [ - "create:large_cogwheel", - "create:cogwheel" + "create:cogwheel", + "create:large_cogwheel" ] } }, diff --git a/src/main/java/com/simibubi/create/AllContainerTypes.java b/src/main/java/com/simibubi/create/AllContainerTypes.java index 2e5e87d8d..e171543a9 100644 --- a/src/main/java/com/simibubi/create/AllContainerTypes.java +++ b/src/main/java/com/simibubi/create/AllContainerTypes.java @@ -2,6 +2,8 @@ package com.simibubi.create; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateContainer; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateScreen; +import com.simibubi.create.content.logistics.item.LinkedControllerContainer; +import com.simibubi.create.content.logistics.item.LinkedControllerScreen; import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer; import com.simibubi.create.content.logistics.item.filter.AttributeFilterScreen; import com.simibubi.create.content.logistics.item.filter.FilterContainer; @@ -35,6 +37,9 @@ public class AllContainerTypes { public static final ContainerEntry ATTRIBUTE_FILTER = register("attribute_filter", AttributeFilterContainer::new, () -> AttributeFilterScreen::new); + + public static final ContainerEntry LINKED_CONTROLLER = + register("linked_controller", LinkedControllerContainer::new, () -> LinkedControllerScreen::new); private static > ContainerEntry register(String name, ForgeContainerFactory factory, NonNullSupplier> screenFactory) { return Create.registrate().container(name, factory, screenFactory).register(); diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 901ab6710..25a418064 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -41,6 +41,8 @@ import com.simibubi.create.content.curiosities.tools.SandPaperItem; import com.simibubi.create.content.curiosities.tools.SandPaperItemRenderer.SandPaperModel; import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperItem; import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperModel; +import com.simibubi.create.content.logistics.item.LinkedControllerItem; +import com.simibubi.create.content.logistics.item.LinkedControllerModel; import com.simibubi.create.content.logistics.item.filter.FilterItem; import com.simibubi.create.content.schematics.item.SchematicAndQuillItem; import com.simibubi.create.content.schematics.item.SchematicItem; @@ -227,6 +229,12 @@ public class AllItems { .lang("Creative Worldshaper") .model(AssetLookup.itemModelWithPartials()) .register(); + + public static final ItemEntry LINKED_CONTROLLER = + REGISTRATE.item("linked_controller", LinkedControllerItem::new) + .transform(CreateRegistrate.customRenderedItem(() -> LinkedControllerModel::new)) + .model(AssetLookup.itemModelWithPartials()) + .register(); public static final ItemEntry MINECART_CONTRAPTION = REGISTRATE.item("minecart_contraption", MinecartContraptionItem::rideable) diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java index 1caccf3d5..3bd7cebd9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GoggleOverlayRenderer.java @@ -172,8 +172,8 @@ public class GoggleOverlayRenderer { ms.pop(); } - private static final class TooltipScreen extends Screen { - private TooltipScreen(ITextComponent p_i51108_1_) { + public static final class TooltipScreen extends Screen { + public TooltipScreen(ITextComponent p_i51108_1_) { super(p_i51108_1_); } diff --git a/src/main/java/com/simibubi/create/content/logistics/IRedstoneLinkable.java b/src/main/java/com/simibubi/create/content/logistics/IRedstoneLinkable.java new file mode 100644 index 000000000..34286e6f6 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/IRedstoneLinkable.java @@ -0,0 +1,23 @@ +package com.simibubi.create.content.logistics; + +import org.apache.commons.lang3.tuple.Pair; + +import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler.Frequency; + +import net.minecraft.util.math.BlockPos; + +public interface IRedstoneLinkable { + + public int getTransmittedStrength(); + + public void setReceivedStrength(int power); + + public boolean isListening(); + + public boolean isAlive(); + + public Pair getNetworkKey(); + + public BlockPos getLocation(); + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java b/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java index 867a9edf5..38ab8b08c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/RedstoneLinkNetworkHandler.java @@ -18,11 +18,11 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.IWorld; -import net.minecraft.world.World; public class RedstoneLinkNetworkHandler { - static final Map, Set>> connections = new IdentityHashMap<>(); + static final Map, Set>> connections = + new IdentityHashMap<>(); public static class Frequency { public static final Frequency EMPTY = new Frequency(ItemStack.EMPTY); @@ -60,7 +60,7 @@ public class RedstoneLinkNetworkHandler { if (this == obj) return true; return obj instanceof Frequency ? ((Frequency) obj).item == item && ((Frequency) obj).color == color - : false; + : false; } } @@ -75,45 +75,40 @@ public class RedstoneLinkNetworkHandler { Create.LOGGER.debug("Removed Redstone Network Space for " + WorldHelper.getDimensionID(world)); } - public Set getNetworkOf(LinkBehaviour actor) { - Map, Set> networksInWorld = networksIn(actor.getWorld()); + public Set getNetworkOf(IWorld world, IRedstoneLinkable actor) { + Map, Set> networksInWorld = networksIn(world); Pair key = actor.getNetworkKey(); if (!networksInWorld.containsKey(key)) networksInWorld.put(key, new LinkedHashSet<>()); return networksInWorld.get(key); } - public void addToNetwork(LinkBehaviour actor) { - getNetworkOf(actor).add(actor); - updateNetworkOf(actor); + public void addToNetwork(IWorld world, IRedstoneLinkable actor) { + getNetworkOf(world, actor).add(actor); + updateNetworkOf(world, actor); } - public void removeFromNetwork(LinkBehaviour actor) { - Set network = getNetworkOf(actor); + public void removeFromNetwork(IWorld world, IRedstoneLinkable actor) { + Set network = getNetworkOf(world, actor); network.remove(actor); if (network.isEmpty()) { - networksIn(actor.getWorld()).remove(actor.getNetworkKey()); + networksIn(world).remove(actor.getNetworkKey()); return; } - updateNetworkOf(actor); + updateNetworkOf(world, actor); } - public void updateNetworkOf(LinkBehaviour actor) { - Set network = getNetworkOf(actor); + public void updateNetworkOf(IWorld world, IRedstoneLinkable actor) { + Set network = getNetworkOf(world, actor); int power = 0; - for (Iterator iterator = network.iterator(); iterator.hasNext();) { - LinkBehaviour other = iterator.next(); - if (other.tileEntity.isRemoved()) { + for (Iterator iterator = network.iterator(); iterator.hasNext();) { + IRedstoneLinkable other = iterator.next(); + if (!other.isAlive()) { iterator.remove(); continue; } - World world = actor.getWorld(); - if (!world.isBlockPresent(other.tileEntity.getPos())) { - iterator.remove(); - continue; - } - if (world.getTileEntity(other.tileEntity.getPos()) != other.tileEntity) { + if (!world.isAreaLoaded(other.getLocation(), 0)) { iterator.remove(); continue; } @@ -124,28 +119,31 @@ public class RedstoneLinkNetworkHandler { power = Math.max(other.getTransmittedStrength(), power); } - // fix one-to-one loading order problem - if (actor.isListening()) { - actor.newPosition = true; - actor.updateReceiver(power); + if (actor instanceof LinkBehaviour) { + LinkBehaviour linkBehaviour = (LinkBehaviour) actor; + // fix one-to-one loading order problem + if (linkBehaviour.isListening()) { + linkBehaviour.newPosition = true; + linkBehaviour.setReceivedStrength(power); + } } - for (LinkBehaviour other : network) { + for (IRedstoneLinkable other : network) { if (other != actor && other.isListening() && withinRange(actor, other)) - other.updateReceiver(power); + other.setReceivedStrength(power); } } - public static boolean withinRange(LinkBehaviour from, LinkBehaviour to) { + public static boolean withinRange(IRedstoneLinkable from, IRedstoneLinkable to) { if (from == to) return true; - return from.getPos().withinDistance(to.getPos(), AllConfigs.SERVER.logistics.linkRange.get()); + return from.getLocation() + .withinDistance(to.getLocation(), AllConfigs.SERVER.logistics.linkRange.get()); } - public Map, Set> networksIn(IWorld world) { + public Map, Set> networksIn(IWorld world) { if (!connections.containsKey(world)) { - Create.LOGGER.warn( - "Tried to Access unprepared network space of " + WorldHelper.getDimensionID(world)); + Create.LOGGER.warn("Tried to Access unprepared network space of " + WorldHelper.getDimensionID(world)); return new HashMap<>(); } return connections.get(world); diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerBindPacket.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerBindPacket.java new file mode 100644 index 000000000..c3c7cc060 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerBindPacket.java @@ -0,0 +1,55 @@ +package com.simibubi.create.content.logistics.item; + +import org.apache.commons.lang3.tuple.Pair; + +import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler.Frequency; +import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour; + +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.items.ItemStackHandler; + +public class LinkedControllerBindPacket extends LinkedControllerPacketBase { + + private int button; + private BlockPos linkLocation; + + public LinkedControllerBindPacket(int button, BlockPos linkLocation) { + this.button = button; + this.linkLocation = linkLocation; + } + + public LinkedControllerBindPacket(PacketBuffer buffer) { + this.button = buffer.readVarInt(); + this.linkLocation = buffer.readBlockPos(); + } + + @Override + public void write(PacketBuffer buffer) { + buffer.writeVarInt(button); + buffer.writeBlockPos(linkLocation); + } + + @Override + protected void handle(ServerPlayerEntity player, ItemStack heldItem) { + ItemStackHandler frequencyItems = LinkedControllerItem.getFrequencyItems(heldItem); + LinkBehaviour linkBehaviour = TileEntityBehaviour.get(player.world, linkLocation, LinkBehaviour.TYPE); + if (linkBehaviour == null) + return; + + Pair pair = linkBehaviour.getNetworkKey(); + frequencyItems.setStackInSlot(button * 2, pair.getKey() + .getStack() + .copy()); + frequencyItems.setStackInSlot(button * 2 + 1, pair.getValue() + .getStack() + .copy()); + + heldItem.getTag() + .put("Items", frequencyItems.serializeNBT()); + } + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java new file mode 100644 index 000000000..d37eb293a --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java @@ -0,0 +1,225 @@ +package com.simibubi.create.content.logistics.item; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Vector; + +import org.lwjgl.glfw.GLFW; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.AllItems; +import com.simibubi.create.CreateClient; +import com.simibubi.create.content.contraptions.goggles.GoggleOverlayRenderer.TooltipScreen; +import com.simibubi.create.foundation.item.TooltipHelper; +import com.simibubi.create.foundation.networking.AllPackets; +import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour; +import com.simibubi.create.foundation.utility.Lang; + +import net.minecraft.client.GameSettings; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.client.util.InputMappings; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextFormatting; + +public class LinkedControllerClientHandler { + + enum Mode { + IDLE, ACTIVE, BIND + } + + public static Mode MODE = Mode.IDLE; + public static int PACKET_RATE = 5; + public static Collection currentlyPressed = new HashSet<>(); + private static BlockPos selectedLocation = BlockPos.ZERO; + private static Vector controls; + + private static int packetCooldown; + + public static Vector getControls() { + if (controls == null) { + GameSettings gameSettings = Minecraft.getInstance().gameSettings; + controls = new Vector<>(6); + controls.add(gameSettings.keyBindForward); + controls.add(gameSettings.keyBindBack); + controls.add(gameSettings.keyBindLeft); + controls.add(gameSettings.keyBindRight); + controls.add(gameSettings.keyBindJump); + controls.add(gameSettings.keySneak); + } + return controls; + } + + public static void toggleBindMode(BlockPos location) { + if (MODE == Mode.IDLE) { + MODE = Mode.BIND; + selectedLocation = location; + } else { + MODE = Mode.IDLE; + onReset(); + } + } + + public static void toggle() { + if (MODE == Mode.IDLE) + MODE = Mode.ACTIVE; + else { + MODE = Mode.IDLE; + onReset(); + } + } + + protected static void onReset() { + getControls().forEach(kb -> kb.setPressed(isActuallyPressed(kb))); + packetCooldown = 0; + selectedLocation = BlockPos.ZERO; + + if (!currentlyPressed.isEmpty()) + AllPackets.channel.sendToServer(new LinkedControllerInputPacket(currentlyPressed, false)); + currentlyPressed.clear(); + } + + protected static boolean isActuallyPressed(KeyBinding kb) { + return InputMappings.isKeyDown(Minecraft.getInstance() + .getWindow() + .getHandle(), + kb.getKey() + .getKeyCode()); + } + + public static void tick() { + LinkedControllerItemRenderer.tick(); + if (MODE == Mode.IDLE) + return; + if (packetCooldown > 0) + packetCooldown--; + + Minecraft mc = Minecraft.getInstance(); + ClientPlayerEntity player = mc.player; + ItemStack heldItem = player.getHeldItemMainhand(); + + if (mc.gameSettings.keyBindInventory.isPressed() || InputMappings.isKeyDown(mc.getWindow() + .getHandle(), GLFW.GLFW_KEY_ESCAPE)) { + MODE = Mode.IDLE; + onReset(); + return; + } + + if (!AllItems.LINKED_CONTROLLER.isIn(heldItem)) { + heldItem = player.getHeldItemOffhand(); + if (!AllItems.LINKED_CONTROLLER.isIn(heldItem)) { + MODE = Mode.IDLE; + onReset(); + return; + } + } + + Vector controls = getControls(); + Collection pressedKeys = new HashSet<>(); + for (int i = 0; i < controls.size(); i++) { + if (isActuallyPressed(controls.get(i))) + pressedKeys.add(i); + } + + Collection newKeys = new HashSet<>(pressedKeys); + Collection releasedKeys = currentlyPressed; + newKeys.removeAll(releasedKeys); + releasedKeys.removeAll(pressedKeys); + + if (MODE == Mode.ACTIVE) { + // Released Keys + if (!releasedKeys.isEmpty()) + AllPackets.channel.sendToServer(new LinkedControllerInputPacket(releasedKeys, false)); + + // Newly Pressed Keys + if (!newKeys.isEmpty()) { + AllPackets.channel.sendToServer(new LinkedControllerInputPacket(newKeys, true)); + packetCooldown = PACKET_RATE; + } + + // Keepalive Pressed Keys + if (packetCooldown == 0) { + if (!pressedKeys.isEmpty()) { + AllPackets.channel.sendToServer(new LinkedControllerInputPacket(pressedKeys, true)); + packetCooldown = PACKET_RATE; + } + } + } + + if (MODE == Mode.BIND) { + VoxelShape shape = mc.world.getBlockState(selectedLocation) + .getShape(mc.world, selectedLocation); + if (!shape.isEmpty()) + CreateClient.OUTLINER.showAABB("controller", shape.getBoundingBox() + .offset(selectedLocation)) + .colored(0xB73C2D) + .lineWidth(1 / 16f); + + for (Integer integer : newKeys) { + LinkBehaviour linkBehaviour = TileEntityBehaviour.get(mc.world, selectedLocation, LinkBehaviour.TYPE); + if (linkBehaviour != null) { + AllPackets.channel.sendToServer(new LinkedControllerBindPacket(integer, selectedLocation)); + Lang.sendStatus(mc.player, "linked_controller.key_bound", controls.get(integer) + .getBoundKeyLocalizedText() + .getString()); + } + MODE = Mode.IDLE; + break; + } + } + + currentlyPressed = pressedKeys; + controls.forEach(kb -> kb.setPressed(false)); + } + + public static void renderOverlay(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, + float partialTicks) { + if (MODE != Mode.BIND) + return; + Minecraft mc = Minecraft.getInstance(); + + ms.push(); + Screen tooltipScreen = new TooltipScreen(null); + tooltipScreen.init(mc, mc.getWindow() + .getScaledWidth(), + mc.getWindow() + .getScaledHeight()); + + Object[] keys = new Object[6]; + Vector controls = getControls(); + for (int i = 0; i < controls.size(); i++) { + KeyBinding keyBinding = controls.get(i); + keys[i] = keyBinding.getBoundKeyLocalizedText() + .getString(); + } + + List list = new ArrayList<>(); + list.add(Lang.createTranslationTextComponent("linked_controller.bind_mode") + .formatted(TextFormatting.GOLD)); + list.addAll( + TooltipHelper.cutTextComponent(Lang.createTranslationTextComponent("linked_controller.press_keybind", keys), + TextFormatting.GRAY, TextFormatting.GRAY)); + + int width = 0; + int height = list.size() * mc.fontRenderer.FONT_HEIGHT; + for (ITextComponent iTextComponent : list) + width = Math.max(width, mc.fontRenderer.getWidth(iTextComponent)); + int x = (tooltipScreen.width / 3) - width / 2; + int y = tooltipScreen.height - height; + + tooltipScreen.renderTooltip(ms, list, x, y); + + ms.pop(); + + } + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerContainer.java new file mode 100644 index 000000000..5f834d46b --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerContainer.java @@ -0,0 +1,152 @@ +package com.simibubi.create.content.logistics.item; + +import com.simibubi.create.foundation.gui.IClearableContainer; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.inventory.container.ClickType; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.ContainerType; +import net.minecraft.inventory.container.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.items.ItemStackHandler; +import net.minecraftforge.items.SlotItemHandler; + +public class LinkedControllerContainer extends Container implements IClearableContainer { + + public PlayerEntity player; + protected PlayerInventory playerInventory; + public ItemStack mainItem; + public ItemStackHandler filterInventory; + + public LinkedControllerContainer(ContainerType type, int id, PlayerInventory inv, PacketBuffer extraData) { + this(type, id, inv, extraData.readItemStack()); + } + + public LinkedControllerContainer(ContainerType type, int id, PlayerInventory inv, ItemStack filterItem) { + super(type, id); + player = inv.player; + playerInventory = inv; + this.mainItem = filterItem; + init(); + } + + protected void init() { + this.filterInventory = createFilterInventory(); +// readData(mainItem); + addPlayerSlots(); + addLinkSlots(); + detectAndSendChanges(); + } + + @Override + public void clearContents() { + for (int i = 0; i < filterInventory.getSlots(); i++) + filterInventory.setStackInSlot(i, ItemStack.EMPTY); + } + + protected void addPlayerSlots() { + int x = 22; + int y = 142; + + for (int hotbarSlot = 0; hotbarSlot < 9; ++hotbarSlot) + this.addSlot(new Slot(playerInventory, hotbarSlot, x + hotbarSlot * 18, y + 58)); + for (int row = 0; row < 3; ++row) + for (int col = 0; col < 9; ++col) + this.addSlot(new Slot(playerInventory, col + row * 9 + 9, x + col * 18, y + row * 18)); + } + + protected void addLinkSlots() { + int slot = 0; + int x = 12; + int y = 44; + + for (int column = 0; column < 6; column++) { + for (int row = 0; row < 2; ++row) + addSlot(new SlotItemHandler(filterInventory, slot++, x, y + row * 18)); + x += 24; + if (column == 3) + x += 11; + } + } + + @Override + public boolean canMergeSlot(ItemStack stack, Slot slotIn) { + return canDragIntoSlot(slotIn); + } + + @Override + public boolean canDragIntoSlot(Slot slotIn) { + return slotIn.inventory == playerInventory; + } + + @Override + public boolean canInteractWith(PlayerEntity playerIn) { + return true; + } + + @Override + public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player) { + if (slotId == playerInventory.currentItem && clickTypeIn != ClickType.THROW) + return ItemStack.EMPTY; + + ItemStack held = playerInventory.getItemStack(); + if (slotId < 36) + return super.slotClick(slotId, dragType, clickTypeIn, player); + if (clickTypeIn == ClickType.THROW) + return ItemStack.EMPTY; + + int slot = slotId - 36; + if (clickTypeIn == ClickType.CLONE) { + if (player.isCreative() && held.isEmpty()) { + ItemStack stackInSlot = filterInventory.getStackInSlot(slot) + .copy(); + stackInSlot.setCount(64); + playerInventory.setItemStack(stackInSlot); + return ItemStack.EMPTY; + } + return ItemStack.EMPTY; + } + + if (held.isEmpty()) { + filterInventory.setStackInSlot(slot, ItemStack.EMPTY); + return ItemStack.EMPTY; + } + + ItemStack insert = held.copy(); + insert.setCount(1); + filterInventory.setStackInSlot(slot, insert); + return held; + } + + protected ItemStackHandler createFilterInventory() { + return LinkedControllerItem.getFrequencyItems(mainItem); + } + + @Override + public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + if (index < 36) { + ItemStack stackToInsert = playerInventory.getStackInSlot(index); + for (int i = 0; i < filterInventory.getSlots(); i++) { + ItemStack stack = filterInventory.getStackInSlot(i); + if (stack.isEmpty()) { + ItemStack copy = stackToInsert.copy(); + copy.setCount(1); + filterInventory.insertItem(i, copy, false); + break; + } + } + } else + filterInventory.extractItem(index - 36, 1, false); + return ItemStack.EMPTY; + } + + @Override + public void onContainerClosed(PlayerEntity playerIn) { + super.onContainerClosed(playerIn); + mainItem.getOrCreateTag() + .put("Items", filterInventory.serializeNBT()); +// saveData(filterItem); + } +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerInputPacket.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerInputPacket.java new file mode 100644 index 000000000..7d70ed4f9 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerInputPacket.java @@ -0,0 +1,50 @@ +package com.simibubi.create.content.logistics.item; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.UUID; +import java.util.stream.Collectors; + +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class LinkedControllerInputPacket extends LinkedControllerPacketBase { + + private Collection activatedButtons; + private boolean press; + + public LinkedControllerInputPacket(Collection activatedButtons, boolean press) { + this.activatedButtons = activatedButtons; + this.press = press; + } + + public LinkedControllerInputPacket(PacketBuffer buffer) { + activatedButtons = new ArrayList<>(); + press = buffer.readBoolean(); + int size = buffer.readVarInt(); + for (int i = 0; i < size; i++) + activatedButtons.add(buffer.readVarInt()); + } + + @Override + public void write(PacketBuffer buffer) { + buffer.writeBoolean(press); + buffer.writeVarInt(activatedButtons.size()); + activatedButtons.forEach(buffer::writeVarInt); + } + + @Override + protected void handle(ServerPlayerEntity player, ItemStack heldItem) { + World world = player.getEntityWorld(); + UUID uniqueID = player.getUniqueID(); + BlockPos pos = player.getBlockPos(); + + LinkedControllerServerHandler.receivePressed(world, pos, uniqueID, activatedButtons.stream() + .map(i -> LinkedControllerItem.toFrequency(heldItem, i)) + .collect(Collectors.toList()), press); + } + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItem.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItem.java new file mode 100644 index 000000000..882c3bcc7 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItem.java @@ -0,0 +1,116 @@ +package com.simibubi.create.content.logistics.item; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllContainerTypes; +import com.simibubi.create.AllItems; +import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler; +import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler.Frequency; +import com.simibubi.create.foundation.utility.Couple; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ActionResult; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraftforge.items.ItemStackHandler; + +public class LinkedControllerItem extends Item implements INamedContainerProvider { + + public LinkedControllerItem(Properties p_i48487_1_) { + super(p_i48487_1_); + } + + @Override + public ActionResultType onItemUse(ItemUseContext ctx) { + PlayerEntity player = ctx.getPlayer(); + if (player == null) + return ActionResultType.PASS; + World world = ctx.getWorld(); + + if (!player.isSneaking() && player.isAllowEdit() + && AllBlocks.REDSTONE_LINK.has(world.getBlockState(ctx.getPos()))) { + if (world.isRemote) + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> this.toggleBindMode(ctx.getPos())); + player.getCooldownTracker() + .setCooldown(this, 2); + return ActionResultType.SUCCESS; + } + + return onItemRightClick(world, player, ctx.getHand()).getType(); + } + + @Override + public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { + ItemStack heldItem = player.getHeldItem(hand); + + if (player.isSneaking() && hand == Hand.MAIN_HAND) { + if (!world.isRemote && player instanceof ServerPlayerEntity && player.isAllowEdit()) + NetworkHooks.openGui((ServerPlayerEntity) player, this, buf -> { + buf.writeItemStack(heldItem); + }); + return ActionResult.success(heldItem); + } + + if (!player.isSneaking()) { + if (world.isRemote) + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::toggleActive); + player.getCooldownTracker() + .setCooldown(this, 2); + } + + return ActionResult.pass(heldItem); + } + + @OnlyIn(Dist.CLIENT) + private void toggleBindMode(BlockPos pos) { + LinkedControllerClientHandler.toggleBindMode(pos); + } + + @OnlyIn(Dist.CLIENT) + private void toggleActive() { + LinkedControllerClientHandler.toggle(); + } + + public static ItemStackHandler getFrequencyItems(ItemStack stack) { + ItemStackHandler newInv = new ItemStackHandler(12); + if (AllItems.LINKED_CONTROLLER.get() != stack.getItem()) + throw new IllegalArgumentException("Cannot get frequency items from non-controller: " + stack); + CompoundNBT invNBT = stack.getOrCreateChildTag("Items"); + if (!invNBT.isEmpty()) + newInv.deserializeNBT(invNBT); + return newInv; + } + + public static Couple toFrequency(ItemStack controller, int slot) { + ItemStackHandler frequencyItems = getFrequencyItems(controller); + return Couple.create(Frequency.of(frequencyItems.getStackInSlot(slot * 2)), + Frequency.of(frequencyItems.getStackInSlot(slot * 2 + 1))); + } + + @Override + public Container createMenu(int id, PlayerInventory inv, PlayerEntity player) { + ItemStack heldItem = player.getHeldItemMainhand(); + return new LinkedControllerContainer(AllContainerTypes.LINKED_CONTROLLER.get(), id, inv, heldItem); + } + + @Override + public ITextComponent getDisplayName() { + return new TranslationTextComponent(getTranslationKey()); + } + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java new file mode 100644 index 000000000..2155442ec --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerItemRenderer.java @@ -0,0 +1,134 @@ +package com.simibubi.create.content.logistics.item; + +import java.util.Vector; + +import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.AllItems; +import com.simibubi.create.content.logistics.item.LinkedControllerClientHandler.Mode; +import com.simibubi.create.foundation.block.render.CustomRenderedItemModelRenderer; +import com.simibubi.create.foundation.item.PartialItemModelRenderer; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import com.simibubi.create.foundation.utility.MatrixStacker; +import com.simibubi.create.foundation.utility.animation.LerpedFloat; +import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.model.ItemCameraTransforms; +import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType; +import net.minecraft.item.ItemStack; +import net.minecraft.util.HandSide; +import net.minecraft.util.math.MathHelper; + +public class LinkedControllerItemRenderer extends CustomRenderedItemModelRenderer { + + static LerpedFloat equipProgress; + static Vector buttons; + + static { + equipProgress = LerpedFloat.linear() + .startWithValue(0); + buttons = new Vector<>(6); + for (int i = 0; i < 6; i++) + buttons.add(LerpedFloat.linear() + .startWithValue(0)); + } + + static void tick() { + boolean active = LinkedControllerClientHandler.MODE != Mode.IDLE; + equipProgress.chase(active ? 1 : 0, .2f, Chaser.EXP); + equipProgress.tickChaser(); + + if (!active) + return; + + for (int i = 0; i < buttons.size(); i++) { + LerpedFloat lerpedFloat = buttons.get(i); + lerpedFloat.chase(LinkedControllerClientHandler.currentlyPressed.contains(i) ? 1 : 0, .4f, Chaser.EXP); + lerpedFloat.tickChaser(); + } + } + + @Override + protected void render(ItemStack stack, LinkedControllerModel model, PartialItemModelRenderer renderer, + ItemCameraTransforms.TransformType transformType, MatrixStack ms, IRenderTypeBuffer buffer, int light, + int overlay) { + float pt = AnimationTickHolder.getPartialTicks(); + MatrixStacker msr = MatrixStacker.of(ms); + + ms.push(); + + Minecraft mc = Minecraft.getInstance(); + boolean rightHanded = mc.gameSettings.mainHand == HandSide.RIGHT; + TransformType mainHand = + rightHanded ? TransformType.FIRST_PERSON_RIGHT_HAND : TransformType.FIRST_PERSON_LEFT_HAND; + TransformType offHand = + rightHanded ? TransformType.FIRST_PERSON_LEFT_HAND : TransformType.FIRST_PERSON_RIGHT_HAND; + + boolean active = false; + boolean noControllerInMain = !AllItems.LINKED_CONTROLLER.isIn(mc.player.getHeldItemMainhand()); + + if (transformType == mainHand || (transformType == offHand && noControllerInMain)) { + float equip = equipProgress.getValue(pt); + int handModifier = transformType == TransformType.FIRST_PERSON_LEFT_HAND ? -1 : 1; + msr.translate(0, equip / 4, equip / 4 * handModifier); + msr.rotateY(equip * -30 * handModifier); + msr.rotateZ(equip * -30); + active = true; + } + + if (transformType == TransformType.GUI) { + if (stack == mc.player.getHeldItemMainhand()) + active = true; + if (stack == mc.player.getHeldItemOffhand() && noControllerInMain) + active = true; + } + + active &= LinkedControllerClientHandler.MODE != Mode.IDLE; + renderer.render(active ? model.getPartial("powered") : model.getOriginalModel(), light); + + if (!active) { + ms.pop(); + return; + } + + IBakedModel button = model.getPartial("button"); + float s = 1 / 16f; + float b = s * -.75f; + int index = 0; + + if (LinkedControllerClientHandler.MODE == Mode.BIND) { + int i = (int) MathHelper.lerp((MathHelper.sin(AnimationTickHolder.getRenderTime() / 4f) + 1) / 2, 5, 15); + light = i << 20; + } + + ms.push(); + msr.translate(2 * s, 0, 8 * s); + button(renderer, ms, light, pt, button, b, index++); + msr.translate(4 * s, 0, 0); + button(renderer, ms, light, pt, button, b, index++); + msr.translate(-2 * s, 0, 2 * s); + button(renderer, ms, light, pt, button, b, index++); + msr.translate(0, 0, -4 * s); + button(renderer, ms, light, pt, button, b, index++); + ms.pop(); + + msr.translate(3 * s, 0, 3 * s); + button(renderer, ms, light, pt, button, b, index++); + msr.translate(2 * s, 0, 0); + button(renderer, ms, light, pt, button, b, index++); + + ms.pop(); + } + + protected void button(PartialItemModelRenderer renderer, MatrixStack ms, int light, float pt, IBakedModel button, + float b, int index) { + ms.push(); + ms.translate(0, b * buttons.get(index) + .getValue(pt), 0); + renderer.renderSolid(button, light); + ms.pop(); + } + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java new file mode 100644 index 000000000..075880dfd --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerModel.java @@ -0,0 +1,20 @@ +package com.simibubi.create.content.logistics.item; + +import com.simibubi.create.foundation.block.render.CustomRenderedItemModel; + +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; + +public class LinkedControllerModel extends CustomRenderedItemModel { + + public LinkedControllerModel(IBakedModel template) { + super(template, "linked_controller"); + addPartials("powered", "button"); + } + + @Override + public ItemStackTileEntityRenderer createRenderer() { + return new LinkedControllerItemRenderer(); + } + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerPacketBase.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerPacketBase.java new file mode 100644 index 000000000..bbc5918c4 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerPacketBase.java @@ -0,0 +1,37 @@ +package com.simibubi.create.content.logistics.item; + +import java.util.function.Supplier; + +import com.simibubi.create.AllItems; +import com.simibubi.create.foundation.networking.SimplePacketBase; + +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.network.NetworkEvent.Context; + +public abstract class LinkedControllerPacketBase extends SimplePacketBase { + + @Override + public void handle(Supplier context) { + context.get() + .enqueueWork(() -> { + ServerPlayerEntity player = context.get() + .getSender(); + if (player == null) + return; + + ItemStack heldItem = player.getHeldItemMainhand(); + if (!AllItems.LINKED_CONTROLLER.isIn(heldItem)) { + heldItem = player.getHeldItemOffhand(); + if (!AllItems.LINKED_CONTROLLER.isIn(heldItem)) + return; + } + handle(player, heldItem); + }); + context.get() + .setPacketHandled(true); + } + + protected abstract void handle(ServerPlayerEntity player, ItemStack heldItem); + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerScreen.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerScreen.java new file mode 100644 index 000000000..24a7acab3 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerScreen.java @@ -0,0 +1,134 @@ +package com.simibubi.create.content.logistics.item; + +import static com.simibubi.create.foundation.gui.AllGuiTextures.PLAYER_INVENTORY; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import com.google.common.collect.ImmutableList; +import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; +import com.simibubi.create.foundation.gui.AllGuiTextures; +import com.simibubi.create.foundation.gui.AllIcons; +import com.simibubi.create.foundation.gui.GuiGameElement; +import com.simibubi.create.foundation.gui.widgets.IconButton; +import com.simibubi.create.foundation.utility.Lang; + +import net.minecraft.client.renderer.Rectangle2d; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextFormatting; + +public class LinkedControllerScreen extends AbstractSimiContainerScreen { + + protected AllGuiTextures background; + private List extraAreas = Collections.emptyList(); + + private IconButton resetButton; + private IconButton confirmButton; + + public LinkedControllerScreen(LinkedControllerContainer container, PlayerInventory inv, ITextComponent title) { + super(container, inv, title); + this.background = AllGuiTextures.LINKED_CONTROLLER; + } + + @Override + protected void drawMouseoverTooltip(MatrixStack ms, int x, int y) { + if (!this.client.player.inventory.getItemStack() + .isEmpty() || this.hoveredSlot == null || this.hoveredSlot.getHasStack()) { + super.drawMouseoverTooltip(ms, x, y); + return; + } + renderWrappedToolTip(ms, addToTooltip(new LinkedList<>(), hoveredSlot.getSlotIndex()), x, y, textRenderer); + } + + @Override + public List getTooltipFromItem(ItemStack stack) { + List list = super.getTooltipFromItem(stack); + return hoveredSlot != null ? addToTooltip(list, hoveredSlot.getSlotIndex()) : list; + } + + private List addToTooltip(List list, int slot) { + if (slot < 0 || slot >= 12) + return list; + list.add(Lang + .createTranslationTextComponent("linked_controller.frequency_slot_" + ((slot % 2) + 1), + LinkedControllerClientHandler.getControls() + .get(slot / 2) + .getBoundKeyLocalizedText() + .getString()) + .formatted(TextFormatting.GOLD)); + return list; + } + + @Override + protected void init() { + setWindowSize(PLAYER_INVENTORY.width + 50, background.height + PLAYER_INVENTORY.height + 20); + super.init(); + widgets.clear(); + int x = guiLeft - 50; + int offset = guiTop < 30 ? 30 - guiTop : 0; + extraAreas = + ImmutableList.of(new Rectangle2d(x, guiTop + offset, background.width + 70, background.height - offset)); + + resetButton = new IconButton(x + background.width - 12, guiTop + background.height - 14, AllIcons.I_TRASH); + confirmButton = new IconButton(x + background.width + 16, guiTop + background.height - 14, AllIcons.I_CONFIRM); + + widgets.add(resetButton); + widgets.add(confirmButton); + } + + @Override + protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) { + int x = guiLeft; + int y = guiTop + 10; + background.draw(ms, this, x, y); + + int invX = guiLeft + 14; + int invY = y + background.height + 5; + PLAYER_INVENTORY.draw(ms, this, invX, invY); + textRenderer.draw(ms, playerInventory.getDisplayName(), invX + 7, invY + 6, 0x666666); + textRenderer.draw(ms, I18n.format(container.mainItem.getTranslationKey()), x + 15, y + 4, 0x442000); + + GuiGameElement.of(container.mainItem).at(x + background.width - 8, guiTop + background.height - 53, -200) + .scale(5) + .render(ms); + + } + + @Override + public void tick() { + super.tick(); + if (!container.player.getHeldItemMainhand() + .equals(container.mainItem, false)) + client.player.closeScreen(); + } + + @Override + public boolean mouseClicked(double x, double y, int button) { + boolean mouseClicked = super.mouseClicked(x, y, button); + + if (button == 0) { + if (confirmButton.isHovered()) { + client.player.closeScreen(); + return true; + } + if (resetButton.isHovered()) { + container.clearContents(); + container.sendClearPacket(); + return true; + } + } + + return mouseClicked; + } + + @Override + public List getExtraAreas() { + return extraAreas; + } +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerServerHandler.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerServerHandler.java new file mode 100644 index 000000000..8e35e0cb6 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerServerHandler.java @@ -0,0 +1,123 @@ +package com.simibubi.create.content.logistics.item; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; + +import org.apache.commons.lang3.tuple.Pair; + +import com.simibubi.create.Create; +import com.simibubi.create.content.logistics.IRedstoneLinkable; +import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler.Frequency; +import com.simibubi.create.foundation.utility.Couple; +import com.simibubi.create.foundation.utility.IntAttached; +import com.simibubi.create.foundation.utility.WorldAttached; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; + +public class LinkedControllerServerHandler { + + public static WorldAttached>> receivedInputs = + new WorldAttached<>(HashMap::new); + static final int TIMEOUT = 30; + + public static void tick(IWorld world) { + Map> map = receivedInputs.get(world); + for (Iterator>> iterator = map.entrySet() + .iterator(); iterator.hasNext();) { + + Entry> entry = iterator.next(); + Collection list = entry.getValue(); + + for (Iterator entryIterator = list.iterator(); entryIterator.hasNext();) { + ManualFrequencyEntry manualFrequencyEntry = entryIterator.next(); + manualFrequencyEntry.decrement(); + if (!manualFrequencyEntry.isAlive()) { + Create.REDSTONE_LINK_NETWORK_HANDLER.removeFromNetwork(world, manualFrequencyEntry); + entryIterator.remove(); + } + } + + if (list.isEmpty()) + iterator.remove(); + } + } + + public static void receivePressed(IWorld world, BlockPos pos, UUID uniqueID, List> collect, + boolean pressed) { + Map> map = receivedInputs.get(world); + Collection list = map.computeIfAbsent(uniqueID, $ -> new ArrayList<>()); + + WithNext: for (Couple activated : collect) { + for (Iterator iterator = list.iterator(); iterator.hasNext();) { + ManualFrequencyEntry entry = iterator.next(); + if (entry.getSecond() + .equals(activated)) { + if (!pressed) + entry.setFirst(0); + else + entry.updatePosition(pos); + continue WithNext; + } + } + + if (!pressed) + continue; + + ManualFrequencyEntry entry = new ManualFrequencyEntry(pos, activated); + Create.REDSTONE_LINK_NETWORK_HANDLER.addToNetwork(world, entry); + list.add(entry); + } + } + + static class ManualFrequencyEntry extends IntAttached> implements IRedstoneLinkable { + + private BlockPos pos; + + public ManualFrequencyEntry(BlockPos pos, Couple second) { + super(TIMEOUT, second); + this.pos = pos; + } + + public void updatePosition(BlockPos pos) { + this.pos = pos; + setFirst(TIMEOUT); + } + + @Override + public int getTransmittedStrength() { + return isAlive() ? 15 : 0; + } + + @Override + public boolean isAlive() { + return getFirst() > 0; + } + + @Override + public BlockPos getLocation() { + return pos; + } + + @Override + public void setReceivedStrength(int power) {} + + @Override + public boolean isListening() { + return false; + } + + @Override + public Pair getNetworkKey() { + return Pair.of(getSecond().getFirst(), getSecond().getSecond()); + } + + } + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java index 1bd54d34d..ef433e77e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java @@ -1,5 +1,7 @@ package com.simibubi.create.content.logistics.item.filter; +import com.simibubi.create.foundation.gui.IClearableContainer; + import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.ClickType; @@ -11,7 +13,7 @@ import net.minecraft.network.PacketBuffer; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; -public abstract class AbstractFilterContainer extends Container { +public abstract class AbstractFilterContainer extends Container implements IClearableContainer { public PlayerEntity player; protected PlayerInventory playerInventory; @@ -38,7 +40,8 @@ public abstract class AbstractFilterContainer extends Container { detectAndSendChanges(); } - protected void clearContents() { + @Override + public void clearContents() { for (int i = 0; i < filterInventory.getSlots(); i++) filterInventory.setStackInSlot(i, ItemStack.EMPTY); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java index bade51cb0..de8703059 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java @@ -30,7 +30,7 @@ import net.minecraft.util.text.ITextComponent; public abstract class AbstractFilterScreen extends AbstractSimiContainerScreen { protected AllGuiTextures background; - private List extraAreas = Collections.EMPTY_LIST; + private List extraAreas = Collections.emptyList(); private IconButton resetButton; private IconButton confirmButton; @@ -146,7 +146,7 @@ public abstract class AbstractFilterScreen ex if (resetButton.isHovered()) { container.clearContents(); contentsCleared(); - sendOptionUpdate(Option.CLEAR); + container.sendClearPacket(); return true; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java index 589f1a9e3..487f801d7 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java @@ -48,7 +48,7 @@ public class AttributeFilterContainer extends AbstractFilterContainer { } @Override - protected void clearContents() { + public void clearContents() { selectedAttributes.clear(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreenPacket.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreenPacket.java index 071baffa2..ac4b1c7a8 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreenPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/FilterScreenPacket.java @@ -13,7 +13,7 @@ import net.minecraftforge.fml.network.NetworkEvent.Context; public class FilterScreenPacket extends SimplePacketBase { public enum Option { - CLEAR, WHITELIST, WHITELIST2, BLACKLIST, RESPECT_DATA, IGNORE_DATA, UPDATE_FILTER_ITEM, ADD_TAG, ADD_INVERTED_TAG; + WHITELIST, WHITELIST2, BLACKLIST, RESPECT_DATA, IGNORE_DATA, UPDATE_FILTER_ITEM, ADD_TAG, ADD_INVERTED_TAG; } private final Option option; @@ -46,14 +46,6 @@ public class FilterScreenPacket extends SimplePacketBase { if (player == null) return; - if (player.openContainer instanceof AbstractFilterContainer) { - AbstractFilterContainer c = (AbstractFilterContainer) player.openContainer; - if (option == Option.CLEAR) { - c.clearContents(); - return; - } - } - if (player.openContainer instanceof FilterContainer) { FilterContainer c = (FilterContainer) player.openContainer; if (option == Option.WHITELIST) diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 37c126432..30db2de2a 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -30,6 +30,7 @@ import com.simibubi.create.content.curiosities.zapper.ZapperRenderHandler; import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperRenderHandler; import com.simibubi.create.content.logistics.block.depot.EjectorTargetHandler; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionPointHandler; +import com.simibubi.create.content.logistics.item.LinkedControllerClientHandler; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.ui.BaseConfigScreen; import com.simibubi.create.foundation.fluid.FluidHelper; @@ -101,9 +102,11 @@ public class ClientEvents { return; if (event.phase == Phase.START) { + LinkedControllerClientHandler.tick(); AirCurrent.tickClientPlayerSounds(); return; } + SoundScapes.tick(); AnimationTickHolder.tick(); @@ -221,6 +224,7 @@ public class ClientEvents { public static void onRenderHotbar(MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay, float partialTicks) { CreateClient.SCHEMATIC_HANDLER.renderOverlay(ms, buffer, light, overlay, partialTicks); + LinkedControllerClientHandler.renderOverlay(ms, buffer, light, overlay, partialTicks); } @SubscribeEvent diff --git a/src/main/java/com/simibubi/create/events/CommonEvents.java b/src/main/java/com/simibubi/create/events/CommonEvents.java index 7fcd4f57a..6664931dd 100644 --- a/src/main/java/com/simibubi/create/events/CommonEvents.java +++ b/src/main/java/com/simibubi/create/events/CommonEvents.java @@ -10,6 +10,7 @@ import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipe import com.simibubi.create.content.contraptions.wrench.WrenchItem; import com.simibubi.create.content.curiosities.zapper.ZapperInteractionHandler; import com.simibubi.create.content.curiosities.zapper.ZapperItem; +import com.simibubi.create.content.logistics.item.LinkedControllerServerHandler; import com.simibubi.create.foundation.command.AllCommands; import com.simibubi.create.foundation.fluid.FluidHelper; import com.simibubi.create.foundation.utility.Iterate; @@ -93,6 +94,7 @@ public class CommonEvents { ContraptionHandler.tick(world); CapabilityMinecartController.tick(world); CouplingPhysics.tick(world); + LinkedControllerServerHandler.tick(world); } @SubscribeEvent diff --git a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java index db6fdea92..8055e15ce 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllGuiTextures.java @@ -57,6 +57,8 @@ public enum AllGuiTextures implements IScreenRenderable { SEQUENCER_END("sequencer.png", 0, 80, 162, 22), SEQUENCER_EMPTY("sequencer.png", 0, 102, 162, 22), SEQUENCER_AWAIT("sequencer.png", 0, 160, 162, 22), + + LINKED_CONTROLLER("curiosities2.png", 180, 109), // JEI JEI_SLOT("jei/widgets.png", 18, 18), diff --git a/src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java b/src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java new file mode 100644 index 000000000..4714c273c --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/gui/ClearContainerPacket.java @@ -0,0 +1,36 @@ +package com.simibubi.create.foundation.gui; + +import java.util.function.Supplier; + +import com.simibubi.create.foundation.networking.SimplePacketBase; + +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.fml.network.NetworkEvent.Context; + +public class ClearContainerPacket extends SimplePacketBase { + + public ClearContainerPacket() {} + + public ClearContainerPacket(PacketBuffer buffer) {} + + @Override + public void write(PacketBuffer buffer) {} + + @Override + public void handle(Supplier context) { + context.get() + .enqueueWork(() -> { + ServerPlayerEntity player = context.get() + .getSender(); + if (player == null) + return; + if (!(player.openContainer instanceof IClearableContainer)) + return; + ((IClearableContainer) player.openContainer).clearContents(); + }); + context.get() + .setPacketHandled(true); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/gui/IClearableContainer.java b/src/main/java/com/simibubi/create/foundation/gui/IClearableContainer.java new file mode 100644 index 000000000..eea746881 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/gui/IClearableContainer.java @@ -0,0 +1,13 @@ +package com.simibubi.create.foundation.gui; + +import com.simibubi.create.foundation.networking.AllPackets; + +public interface IClearableContainer { + + default void sendClearPacket() { + AllPackets.channel.sendToServer(new ClearContainerPacket()); + } + + public void clearContents(); + +} diff --git a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java index faa37475d..26cb098a5 100644 --- a/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java +++ b/src/main/java/com/simibubi/create/foundation/networking/AllPackets.java @@ -28,6 +28,8 @@ import com.simibubi.create.content.logistics.block.depot.EjectorElytraPacket; import com.simibubi.create.content.logistics.block.depot.EjectorPlacementPacket; import com.simibubi.create.content.logistics.block.depot.EjectorTriggerPacket; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmPlacementPacket; +import com.simibubi.create.content.logistics.item.LinkedControllerBindPacket; +import com.simibubi.create.content.logistics.item.LinkedControllerInputPacket; import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket; import com.simibubi.create.content.logistics.packet.ConfigureFlexcratePacket; import com.simibubi.create.content.logistics.packet.ConfigureStockswitchPacket; @@ -38,9 +40,10 @@ import com.simibubi.create.content.schematics.packet.InstantSchematicPacket; import com.simibubi.create.content.schematics.packet.SchematicPlacePacket; import com.simibubi.create.content.schematics.packet.SchematicSyncPacket; import com.simibubi.create.content.schematics.packet.SchematicUploadPacket; -import com.simibubi.create.foundation.command.SConfigureConfigPacket; import com.simibubi.create.foundation.command.HighlightPacket; +import com.simibubi.create.foundation.command.SConfigureConfigPacket; import com.simibubi.create.foundation.config.ui.CConfigureConfigPacket; +import com.simibubi.create.foundation.gui.ClearContainerPacket; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringCountUpdatePacket; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueUpdatePacket; import com.simibubi.create.foundation.utility.ServerSpeedProvider; @@ -67,6 +70,7 @@ public enum AllPackets { PLAY_TO_SERVER), PLACE_SCHEMATIC(SchematicPlacePacket.class, SchematicPlacePacket::new, PLAY_TO_SERVER), UPLOAD_SCHEMATIC(SchematicUploadPacket.class, SchematicUploadPacket::new, PLAY_TO_SERVER), + CLEAR_CONTAINER(ClearContainerPacket.class, ClearContainerPacket::new, PLAY_TO_SERVER), CONFIGURE_FILTER(FilterScreenPacket.class, FilterScreenPacket::new, PLAY_TO_SERVER), CONFIGURE_FILTERING_AMOUNT(FilteringCountUpdatePacket.class, FilteringCountUpdatePacket::new, PLAY_TO_SERVER), CONFIGURE_SCROLLABLE(ScrollValueUpdatePacket.class, ScrollValueUpdatePacket::new, PLAY_TO_SERVER), @@ -81,6 +85,8 @@ public enum AllPackets { PLACE_EJECTOR(EjectorPlacementPacket.class, EjectorPlacementPacket::new, PLAY_TO_SERVER), TRIGGER_EJECTOR(EjectorTriggerPacket.class, EjectorTriggerPacket::new, PLAY_TO_SERVER), EJECTOR_ELYTRA(EjectorElytraPacket.class, EjectorElytraPacket::new, PLAY_TO_SERVER), + LINKED_CONTROLLER_INPUT(LinkedControllerInputPacket.class, LinkedControllerInputPacket::new, PLAY_TO_SERVER), + LINKED_CONTROLLER_BIND(LinkedControllerBindPacket.class, LinkedControllerBindPacket::new, PLAY_TO_SERVER), C_CONFIGURE_CONFIG(CConfigureConfigPacket.class, CConfigureConfigPacket::new, PLAY_TO_SERVER), // Server to Client diff --git a/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java b/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java index 31c129642..41cc284bd 100644 --- a/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java +++ b/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java @@ -83,7 +83,7 @@ public class RenderTypes extends RenderState { .transparency(TRANSLUCENT_TRANSPARENCY) .diffuseLighting(ENABLE_DIFFUSE_LIGHTING) .alpha(ONE_TENTH_ALPHA) - .cull(DISABLE_CULLING) + .cull(ENABLE_CULLING) .lightmap(ENABLE_LIGHTMAP) .overlay(ENABLE_OVERLAY_COLOR) .build(true)); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java index cfba21b6b..e7d0cfac9 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/TileEntityBehaviour.java @@ -4,7 +4,6 @@ import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import net.minecraft.block.BlockState; -import net.minecraft.item.Item; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java index 9b9ef352d..75aa226e0 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkBehaviour.java @@ -7,6 +7,7 @@ import java.util.function.IntSupplier; import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.Create; +import com.simibubi.create.content.logistics.IRedstoneLinkable; import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler; import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler.Frequency; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; @@ -17,9 +18,10 @@ import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3d; -public class LinkBehaviour extends TileEntityBehaviour { +public class LinkBehaviour extends TileEntityBehaviour implements IRedstoneLinkable { public static BehaviourType TYPE = new BehaviourType<>(); @@ -76,33 +78,37 @@ public class LinkBehaviour extends TileEntityBehaviour { frequencyLast = behaviour.frequencyLast; } + @Override public boolean isListening() { return mode == Mode.RECEIVE; } + @Override public int getTransmittedStrength() { return mode == Mode.TRANSMIT ? transmission.getAsInt() : 0; } - public void updateReceiver(int networkPower) { + @Override + public void setReceivedStrength(int networkPower) { if (!newPosition) return; signalCallback.accept(networkPower); } public void notifySignalChange() { - Create.REDSTONE_LINK_NETWORK_HANDLER.updateNetworkOf(this); + Create.REDSTONE_LINK_NETWORK_HANDLER.updateNetworkOf(getWorld(), this); } @Override public void initialize() { super.initialize(); - if (tileEntity.getWorld().isRemote) + if (getWorld().isRemote) return; - getHandler().addToNetwork(this); + getHandler().addToNetwork(getWorld(), this); newPosition = true; } + @Override public Pair getNetworkKey() { return Pair.of(frequencyFirst, frequencyLast); } @@ -110,13 +116,15 @@ public class LinkBehaviour extends TileEntityBehaviour { @Override public void remove() { super.remove(); - if (tileEntity.getWorld().isRemote) + if (getWorld().isRemote) return; - getHandler().removeFromNetwork(this); + getHandler().removeFromNetwork(getWorld(), this); } @Override - public boolean isSafeNBT() { return true; } + public boolean isSafeNBT() { + return true; + } @Override public void write(CompoundNBT nbt, boolean clientPacket) { @@ -149,7 +157,7 @@ public class LinkBehaviour extends TileEntityBehaviour { !ItemStack.areItemsEqual(stack, toCompare) || !ItemStack.areItemStackTagsEqual(stack, toCompare); if (changed) - getHandler().removeFromNetwork(this); + getHandler().removeFromNetwork(getWorld(), this); if (first) frequencyFirst = Frequency.of(stack); @@ -160,7 +168,7 @@ public class LinkBehaviour extends TileEntityBehaviour { return; tileEntity.sendData(); - getHandler().addToNetwork(this); + getHandler().addToNetwork(getWorld(), this); } @Override @@ -197,4 +205,14 @@ public class LinkBehaviour extends TileEntityBehaviour { return (first ? firstSlot : secondSlot).testHit(state, localHit); } + @Override + public boolean isAlive() { + return !tileEntity.isRemoved() && getWorld().getTileEntity(getPos()) == tileEntity; + } + + @Override + public BlockPos getLocation() { + return getPos(); + } + } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java index 30a88de18..1c5e6319f 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java @@ -2,10 +2,12 @@ package com.simibubi.create.foundation.tileEntity.behaviour.linked; import java.util.Arrays; +import com.simibubi.create.AllItems; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.utility.RaycastHelper; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; @@ -35,14 +37,19 @@ public class LinkHandler { if (behaviour == null) return; + ItemStack heldItem = player.getHeldItem(hand); BlockRayTraceResult ray = RaycastHelper.rayTraceRange(world, player, 10); if (ray == null) return; + if (AllItems.LINKED_CONTROLLER.isIn(heldItem)) + return; + if (AllItems.WRENCH.isIn(heldItem)) + return; for (boolean first : Arrays.asList(false, true)) { if (behaviour.testHit(first, ray.getHitVec())) { - if (event.getSide() != LogicalSide.CLIENT) - behaviour.setFrequency(first, player.getHeldItem(hand)); + if (event.getSide() != LogicalSide.CLIENT) + behaviour.setFrequency(first, heldItem); event.setCanceled(true); event.setCancellationResult(ActionResultType.SUCCESS); world.playSound(null, pos, SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, SoundCategory.BLOCKS, .25f, .1f); diff --git a/src/main/resources/assets/create/lang/default/messages.json b/src/main/resources/assets/create/lang/default/messages.json index 22a691d46..ce2e8e7e6 100644 --- a/src/main/resources/assets/create/lang/default/messages.json +++ b/src/main/resources/assets/create/lang/default/messages.json @@ -464,6 +464,12 @@ "create.tooltip.chute.fans_pull_down": "Fans pull from Below", "create.tooltip.chute.contains": "Contains: %1$s x%2$s", + "create.linked_controller.bind_mode": "Bind mode active", + "create.linked_controller.press_keybind": "Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", + "create.linked_controller.key_bound": "Frequency bound to %1$s", + "create.linked_controller.frequency_slot_1": "Keybind: %1$s, Freq. #1", + "create.linked_controller.frequency_slot_2": "Keybind: %1$s, Freq. #2", + "create.hint.hose_pulley.title": "Bottomless Supply", "create.hint.hose_pulley": "The targeted body of fluid is considered infinite.", "create.hint.mechanical_arm_no_targets.title": "No Targets", diff --git a/src/main/resources/assets/create/models/item/linked_controller/button.json b/src/main/resources/assets/create/models/item/linked_controller/button.json new file mode 100644 index 000000000..9859c72ab --- /dev/null +++ b/src/main/resources/assets/create/models/item/linked_controller/button.json @@ -0,0 +1,22 @@ +{ + "credit": "Made with Blockbench", + "parent": "create:item/linked_controller/powered", + "textures": { + "particle": "create:item/linked_controller", + "redstone_bridge": "create:item/linked_controller" + }, + "elements": [ + { + "from": [3, 1, 0.5], + "to": [5, 3, 2.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0.5]}, + "faces": { + "north": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "east": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "south": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "west": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "up": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/item/linked_controller/item.json b/src/main/resources/assets/create/models/item/linked_controller/item.json new file mode 100644 index 000000000..88c8e9cdc --- /dev/null +++ b/src/main/resources/assets/create/models/item/linked_controller/item.json @@ -0,0 +1,166 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "textures": { + "redstone_antenna": "create:block/redstone_antenna", + "particle": "create:item/linked_controller", + "redstone_bridge": "create:item/linked_controller" + }, + "elements": [ + { + "name": "Controller", + "from": [4, 0, 1.5], + "to": [12, 2, 14.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0.5]}, + "faces": { + "north": {"uv": [13, 0, 15, 8], "rotation": 90, "texture": "#redstone_bridge"}, + "east": {"uv": [0, 8, 13, 10], "texture": "#redstone_bridge"}, + "south": {"uv": [13, 0, 15, 8], "rotation": 90, "texture": "#redstone_bridge"}, + "west": {"uv": [0, 8, 13, 10], "texture": "#redstone_bridge"}, + "up": {"uv": [0, 0, 13, 8], "rotation": 270, "texture": "#redstone_bridge"}, + "down": {"uv": [0, 0, 13, 8], "rotation": 90, "texture": "#redstone_bridge"} + } + }, + { + "name": "AntennaTop", + "from": [3, 6, 4.5], + "to": [4, 7, 5.5], + "rotation": {"angle": 0, "axis": "z", "origin": [4, 2, 14.5]}, + "faces": { + "up": {"uv": [1, 1, 2, 2], "texture": "#redstone_antenna"} + } + }, + { + "name": "AntennaZ", + "from": [3, 0, 3.5], + "to": [4, 8, 6.5], + "rotation": {"angle": 0, "axis": "z", "origin": [4, 2, 14.5]}, + "faces": { + "east": {"uv": [0, 0, 3, 8], "texture": "#redstone_antenna"}, + "west": {"uv": [0, 0, 3, 8], "texture": "#redstone_antenna"} + } + }, + { + "name": "AntennaX", + "from": [2, 0, 4.5], + "to": [5, 8, 5.5], + "rotation": {"angle": 0, "axis": "z", "origin": [4, 2, 14.5]}, + "faces": { + "north": {"uv": [0, 0, 3, 8], "texture": "#redstone_antenna"}, + "south": {"uv": [0, 0, 3, 8], "texture": "#redstone_antenna"}, + "down": {"uv": [0, 9, 3, 10], "texture": "#redstone_antenna"} + } + }, + { + "from": [9, 1, 8.5], + "to": [11, 3, 10.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0.5]}, + "faces": { + "north": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "east": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "south": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "west": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "up": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"} + } + }, + { + "from": [5, 1, 8.5], + "to": [7, 3, 10.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0.5]}, + "faces": { + "north": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "east": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "south": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "west": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "up": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"} + } + }, + { + "from": [7, 1, 10.5], + "to": [9, 3, 12.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0.5]}, + "faces": { + "north": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "east": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "south": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "west": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "up": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"} + } + }, + { + "from": [7, 1, 6.5], + "to": [9, 3, 8.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0.5]}, + "faces": { + "north": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "east": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "south": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "west": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "up": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"} + } + }, + { + "from": [8, 1, 3.5], + "to": [10, 3, 5.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0.5]}, + "faces": { + "north": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "east": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "south": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "west": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "up": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"} + } + }, + { + "from": [6, 1, 3.5], + "to": [8, 3, 5.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0.5]}, + "faces": { + "north": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "east": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "south": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "west": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"}, + "up": {"uv": [2, 11, 4, 13], "texture": "#redstone_bridge"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [0, -90, -74], + "translation": [-3, 3.25, 4.5], + "scale": [0.7, 0.7, 0.7] + }, + "thirdperson_lefthand": { + "rotation": [0, 90, 74], + "translation": [-3, 3.5, 5], + "scale": [0.7, 0.7, 0.7] + }, + "firstperson_righthand": { + "rotation": [0, -90, -13], + "translation": [1.13, 3, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "firstperson_lefthand": { + "rotation": [0, 71, 17], + "translation": [1.13, 3, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.65, 0.65, 0.65] + }, + "gui": { + "rotation": [30, -44, 0], + "translation": [0, 3.5, 0], + "scale": [0.76, 0.76, 0.76] + }, + "head": { + "rotation": [0, 180, 0], + "translation": [0, 13, 0] + }, + "fixed": { + "rotation": [0, 90, -90], + "translation": [0, 0, -8] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/item/linked_controller/powered.json b/src/main/resources/assets/create/models/item/linked_controller/powered.json new file mode 100644 index 000000000..1a747b4fa --- /dev/null +++ b/src/main/resources/assets/create/models/item/linked_controller/powered.json @@ -0,0 +1,94 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "textures": { + "redstone_antenna": "create:block/redstone_antenna_powered", + "particle": "create:item/linked_controller_powered", + "redstone_bridge": "create:item/linked_controller_powered" + }, + "elements": [ + { + "name": "Controller", + "from": [4, 0, 1.5], + "to": [12, 2, 14.5], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0.5]}, + "faces": { + "north": {"uv": [13, 0, 15, 8], "rotation": 90, "texture": "#redstone_bridge"}, + "east": {"uv": [0, 8, 13, 10], "texture": "#redstone_bridge"}, + "south": {"uv": [13, 0, 15, 8], "rotation": 90, "texture": "#redstone_bridge"}, + "west": {"uv": [0, 8, 13, 10], "texture": "#redstone_bridge"}, + "up": {"uv": [0, 0, 13, 8], "rotation": 270, "texture": "#redstone_bridge"}, + "down": {"uv": [0, 0, 13, 8], "rotation": 90, "texture": "#redstone_bridge"} + } + }, + { + "name": "AntennaTop", + "from": [3, 6, 4.5], + "to": [4, 7, 5.5], + "rotation": {"angle": 0, "axis": "z", "origin": [4, 2, 14.5]}, + "faces": { + "up": {"uv": [1, 1, 2, 2], "texture": "#redstone_antenna"} + } + }, + { + "name": "AntennaZ", + "from": [3, 0, 3.5], + "to": [4, 8, 6.5], + "rotation": {"angle": 0, "axis": "z", "origin": [4, 2, 14.5]}, + "faces": { + "east": {"uv": [0, 0, 3, 8], "texture": "#redstone_antenna"}, + "west": {"uv": [0, 0, 3, 8], "texture": "#redstone_antenna"} + } + }, + { + "name": "AntennaX", + "from": [2, 0, 4.5], + "to": [5, 8, 5.5], + "rotation": {"angle": 0, "axis": "z", "origin": [4, 2, 14.5]}, + "faces": { + "north": {"uv": [0, 0, 3, 8], "texture": "#redstone_antenna"}, + "south": {"uv": [0, 0, 3, 8], "texture": "#redstone_antenna"}, + "down": {"uv": [0, 9, 3, 10], "texture": "#redstone_antenna"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [0, -90, -74], + "translation": [-3, 3.25, 4.5], + "scale": [0.7, 0.7, 0.7] + }, + "thirdperson_lefthand": { + "rotation": [0, 90, 74], + "translation": [-3, 3.5, 5], + "scale": [0.7, 0.7, 0.7] + }, + "firstperson_righthand": { + "rotation": [0, -113, -27], + "translation": [-2, 9, 1.13], + "scale": [0.97, 0.97, 0.97] + }, + "firstperson_lefthand": { + "rotation": [0, 47, 27], + "translation": [-2, 9, 1.13], + "scale": [0.97, 0.97, 0.97] + }, + "ground": { + "translation": [0, 2, 0], + "scale": [0.75, 0.75, 0.75] + }, + "gui": { + "rotation": [30, -44, 0], + "translation": [0, 1.75, 0], + "scale": [0.76, 0.76, 0.76] + }, + "head": { + "rotation": [0, 180, 0], + "translation": [0, 13, 0] + }, + "fixed": { + "rotation": [0, 90, -90], + "translation": [0, 0, -8] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/textures/gui/curiosities2.png b/src/main/resources/assets/create/textures/gui/curiosities2.png new file mode 100644 index 0000000000000000000000000000000000000000..26fce588cc9c0e159e2d3e60a9024ef4c584931b GIT binary patch literal 1407 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911MRQ8&P5D>38$lZxy-8q?;Kn_c~qpu?a z!^VE@KZ&eBen@~%h%1n0Wo2bzVq#-s`*bjuk&$u#ESGRihBzZe78aHX6DCwtRP5NX z!@}G~Tg%}8|Nq_H-R9=z$BrEf4Gm38OMCR_QAtV3jT<*_+_-W5`t>DCmH-X(?)&i< zNXe80`2_>D-~tTdn;u;Us^cv1h%9Dc;5!7ujG`J|4M4Z{c)B=-RK&fV-B@(XK)~gy zn#inWjSRjDfBx5p9m}4Ox*@wb=;_Vcd5I4nxm-Hkwr%Fh;`?{XpU?Z#-0u=;pFi*F z^$*Xt#o7IwzFfrOyN$Taww&&08~gt=m`^WdNjSaDqk#p85;`|cWZ;~@kaKg|tM!K> z7UfJk%?eZ~z9CB2R@;A7j_qpsk5vkXr>~Uya5>(T`@jA=6-is}xbM#&t*pDG0#s?e zb9(&EiiDNZO`fl3+4HaNbm?BU^X_r$Iaym?FWD3yfT}r^%bHE`^K{qG zNrlX}yiMm%T+R4A^e^+i-saEC^vvIXm*;sN$b2ilC}ZAw#;=Dh|0mw#*irdEfcaJX zuW9dWa@_W@g*^Q%`sU55SDW*H_x{}bd-vxRjBlfNeU5T4K7Y00RPEM<72#L63*XQ2 zx7c6)e{JQLI_Z0t=Ki10_Jj5O%{?3DxbtS*H!?YYu|aR!=LL*2+P|FNZ1TYN*nZ*Y zbIoiIn8VHfezxJQ_-0_^?BZ89nzc-d}k%&jg5v`4N?o(RxqBG zN-j5jC~`vc-4%v6HzZ6QcmtTPG^F)z+&!y+>xoEt7DHK1kCcE(!sfn>bJ=-c+`D9d z{z`+yU$+xw>%KGm)m*@)uzW`_^M>SPV6cNU&oVvs4xcqfCI?=b+kb!N$o%f_v*-70 z{FyJsi(h}dUWV7B-u6Kh&;*28he|KSrJ6PT*?;~#N6t;L=O4=7eezUKi00ZoZ|$4! zLJhjNl^BHr<}}zF%3q!0dBDA8^|If8(}kEf3vT%P$7YFvfjr~w!-}nqlAIpN3rZOO z>3&dB=xjX18dA>|!FqTEc`dE;cnh> z#RZieEHmcszar0A|Ks#eX2x&N^}pFFSo{xlX!<<;w_1hme^-aD&(pOP7?>u_sdr<# zG^gHd2g|v;pD$Rz`}~b)78&qol`;+ E0C|39xc~qF literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/create/textures/item/linked_controller.png b/src/main/resources/assets/create/textures/item/linked_controller.png new file mode 100644 index 0000000000000000000000000000000000000000..474b3bf2c1cd3547b1d4f2fac136655b40585339 GIT binary patch literal 351 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|~0G|-oBh$T275NS1_?)yw*0tEpC^Kma(MWYxw`F9oQW5kwlJL|Qx6>2~ zwvY;AWb|fa?2OeZ^3iV1@~KO7&keH&8dGtjc|DL4D+%%o{*MhXFkU+F1gL_uz$3Dl zfr0NZ2s0kfUy%Y7Z1Hq)4ABVA?PcUUtia(KxJpbUc6Z_b)$g)rrN(|c(z543dxz7U z{>R&LHLZ_ISe)S!6j>g-#cbU%-=+LMJS(S)UiGPJe~}cmb>qrYGlXMrtdf!r`z9+H zzp$fKAxf?0+_D}?8J>?5C+`l{JHBK}(G(ljf4m)^E5CAgT(A7vU9VkU*YaEXT{zD& TfzR%s5M%Ik^>bP0l+XkKkgS3_ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/create/textures/item/linked_controller_powered.png b/src/main/resources/assets/create/textures/item/linked_controller_powered.png new file mode 100644 index 0000000000000000000000000000000000000000..bf0dcb3d3bba9d786edeb51edb7bebc7ce5aff7d GIT binary patch literal 350 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G|~0G|-oBh$T275NS1_?)yw*0tEpC^Kma(MWYxpU%Kwr6TBWB;lzqZl@^} zY$0`)fnf^+Luaf`k&pKN?dvwJSTJK^7tomXPm=q9lvqiSU+{lyfPwMSfhRx}oCO|{ z#S9F5hd`K7RKu$QDA?@j;uxY4oZHLI$E?V~8u({XMtStR`m1(lm%TKTHB=O?5SaM+ z^+tZhBPmbzCT~AgIic5U>b0GkRtF%}28J29*~C-ZWmqHw)*fKQ0))q5xY|Npo9$fE!M zzrFo>bJ5D4ufHB1J+~dG`o-C;l|YKKB*-uLKNK(o`&S5o1PeSOiy0XB4ude`@%$Aj zK*4xV7sn8d;L>y4Tn7v|m@i1oef!tnre1pS28WfE0h-??)*tYxWfYjXaaD+gK&ac- zsSIxYJt{YpGj_;)Z984$*mP8?NLN1K`+Qs1M>gTe~DWM4fJ2zo8 delta 226 zcmV<803H8^0`dWn7=Hu<0002(-QrRJ000DMK}|sb0I`n?{9y$E001FSOjJbx003=q zU+wkT#m={Xg=zKr;i9RGyTqc^-pK#|_W%F>w1D3n00001bW%=J06^y0W&i*HZ%IT! zR0!8&U_b_|AQacCjs;+PMaQZt5MxExs#VK@LR?)dXRQJWaa&c*oH+|5#8tF%=FC-% z6BxKsyJoH`Rs=CLR+SrvOkm*53|(H_I%NU_!?dX@TEjAd=5S^%a><+kGI3hUOfb#B cITOVN0Q8S0kPivr+5i9m07*qoM6N<$f+!?hr2qf` From 462089b43aa7a1e0e56c0e20245b6e91e3f874a9 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Wed, 26 May 2021 19:47:19 -0700 Subject: [PATCH 103/198] Clean up in world processing - Use static RecipeWrapper for finding recipes instead of making a new TileEntity every time - Move InWorldProcessing from logistics to contraptions/processing - Fix #799 by disallowing blasting processing on fireproof items --- .../deployer/BeltDeployerCallbacks.java | 2 +- .../components/fan/AirCurrent.java | 4 +- .../components/fan/SplashingRecipe.java | 8 +-- .../press/BeltPressingCallbacks.java | 2 +- .../press/MechanicalPressTileEntity.java | 2 +- .../particle/AirFlowParticle.java | 2 +- .../processing}/InWorldProcessing.java | 63 +++++++------------ .../belt/transport/TransportedItemStack.java | 2 +- .../logistics/item/filter/ItemAttribute.java | 2 +- .../advancement/AllAdvancements.java | 2 +- .../foundation/advancement/AllTriggers.java | 2 +- 11 files changed, 38 insertions(+), 53 deletions(-) rename src/main/java/com/simibubi/create/content/{logistics => contraptions/processing}/InWorldProcessing.java (86%) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java index 6cfc09ede..7d007d11e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/BeltDeployerCallbacks.java @@ -9,10 +9,10 @@ import com.simibubi.create.AllSoundEvents; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode; import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.State; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; import com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe; -import com.simibubi.create.content.logistics.InWorldProcessing; import com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java index 3b4d2ba91..72001c7ee 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java @@ -8,8 +8,8 @@ import org.apache.commons.lang3.tuple.Pair; import com.simibubi.create.AllTags; import com.simibubi.create.content.contraptions.particle.AirFlowParticleData; -import com.simibubi.create.content.logistics.InWorldProcessing; -import com.simibubi.create.content.logistics.InWorldProcessing.Type; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing.Type; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/SplashingRecipe.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/SplashingRecipe.java index e6eafe17f..9bf446385 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/SplashingRecipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/SplashingRecipe.java @@ -3,22 +3,22 @@ package com.simibubi.create.content.contraptions.components.fan; import javax.annotation.ParametersAreNonnullByDefault; import com.simibubi.create.AllRecipeTypes; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing.SplashingWrapper; import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeParams; -import com.simibubi.create.content.logistics.InWorldProcessing; -import com.simibubi.create.content.logistics.InWorldProcessing.SplashingInv; import net.minecraft.world.World; @ParametersAreNonnullByDefault -public class SplashingRecipe extends ProcessingRecipe { +public class SplashingRecipe extends ProcessingRecipe { public SplashingRecipe(ProcessingRecipeParams params) { super(AllRecipeTypes.SPLASHING, params); } @Override - public boolean matches(SplashingInv inv, World worldIn) { + public boolean matches(SplashingWrapper inv, World worldIn) { if (inv.isEmpty()) return false; return ingredients.get(0) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/BeltPressingCallbacks.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/BeltPressingCallbacks.java index 93f0d1cb4..3bc960959 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/BeltPressingCallbacks.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/BeltPressingCallbacks.java @@ -9,9 +9,9 @@ import java.util.stream.Collectors; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity.Mode; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; -import com.simibubi.create.content.logistics.InWorldProcessing; import com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java index 36eabc127..36651a7d6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java @@ -10,7 +10,7 @@ import com.simibubi.create.AllSoundEvents; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.processing.BasinOperatingTileEntity; import com.simibubi.create.content.contraptions.processing.BasinTileEntity; -import com.simibubi.create.content.logistics.InWorldProcessing; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.advancement.ITriggerable; import com.simibubi.create.foundation.config.AllConfigs; diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java index 3d5c41c8a..d4399cde7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/AirFlowParticle.java @@ -4,7 +4,7 @@ import javax.annotation.Nonnull; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.components.fan.IAirCurrentSource; -import com.simibubi.create.content.logistics.InWorldProcessing; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.VecHelper; diff --git a/src/main/java/com/simibubi/create/content/logistics/InWorldProcessing.java b/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java similarity index 86% rename from src/main/java/com/simibubi/create/content/logistics/InWorldProcessing.java rename to src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java index 670f02cfc..0858c17ed 100644 --- a/src/main/java/com/simibubi/create/content/logistics/InWorldProcessing.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics; +package com.simibubi.create.content.contraptions.processing; import static com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.getHeatLevelOf; @@ -12,7 +12,6 @@ import javax.annotation.Nullable; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllRecipeTypes; import com.simibubi.create.content.contraptions.components.fan.SplashingRecipe; -import com.simibubi.create.content.contraptions.processing.ProcessingRecipe; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; import com.simibubi.create.foundation.config.AllConfigs; @@ -37,9 +36,6 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.particles.ParticleTypes; import net.minecraft.particles.RedstoneParticleData; import net.minecraft.tags.BlockTags; -import net.minecraft.tileentity.BlastFurnaceTileEntity; -import net.minecraft.tileentity.FurnaceTileEntity; -import net.minecraft.tileentity.SmokerTileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.IBlockReader; @@ -50,13 +46,8 @@ import net.minecraftforge.items.wrapper.RecipeWrapper; public class InWorldProcessing { - public static class SplashingInv extends RecipeWrapper { - public SplashingInv() { - super(new ItemStackHandler(1)); - } - } - - public static SplashingInv splashingInv = new SplashingInv(); + private static final RecipeWrapper WRAPPER = new RecipeWrapper(new ItemStackHandler(1)); + private static final SplashingWrapper SPLASHING_WRAPPER = new SplashingWrapper(); public enum Type { SMOKING, BLASTING, SPLASHING, NONE @@ -103,17 +94,13 @@ public class InWorldProcessing { } private static boolean canProcess(ItemStack stack, Type type, World world) { - if (type == Type.BLASTING) { - return true; - } + if (type == Type.BLASTING) + return !stack.getItem().isFireproof(); if (type == Type.SMOKING) { - // FIXME this does not need to be a TE - SmokerTileEntity smoker = new SmokerTileEntity(); - smoker.setLocation(world, BlockPos.ZERO); - smoker.setInventorySlotContents(0, stack); + WRAPPER.setInventorySlotContents(0, stack); Optional recipe = world.getRecipeManager() - .getRecipe(IRecipeType.SMOKING, smoker, world); + .getRecipe(IRecipeType.SMOKING, WRAPPER, world); return recipe.isPresent(); } @@ -124,8 +111,8 @@ public class InWorldProcessing { } public static boolean isWashable(ItemStack stack, World world) { - splashingInv.setInventorySlotContents(0, stack); - Optional recipe = AllRecipeTypes.SPLASHING.find(splashingInv, world); + SPLASHING_WRAPPER.setInventorySlotContents(0, stack); + Optional recipe = AllRecipeTypes.SPLASHING.find(SPLASHING_WRAPPER, world); return recipe.isPresent(); } @@ -179,38 +166,29 @@ public class InWorldProcessing { private static List process(ItemStack stack, Type type, World world) { if (type == Type.SPLASHING) { - splashingInv.setInventorySlotContents(0, stack); - Optional recipe = AllRecipeTypes.SPLASHING.find(splashingInv, world); + SPLASHING_WRAPPER.setInventorySlotContents(0, stack); + Optional recipe = AllRecipeTypes.SPLASHING.find(SPLASHING_WRAPPER, world); if (recipe.isPresent()) return applyRecipeOn(stack, recipe.get()); return null; } - // FIXME this does not need to be a TE - SmokerTileEntity smoker = new SmokerTileEntity(); - smoker.setLocation(world, BlockPos.ZERO); - smoker.setInventorySlotContents(0, stack); + WRAPPER.setInventorySlotContents(0, stack); Optional smokingRecipe = world.getRecipeManager() - .getRecipe(IRecipeType.SMOKING, smoker, world); + .getRecipe(IRecipeType.SMOKING, WRAPPER, world); if (type == Type.BLASTING) { - // FIXME this does not need to be a TE - FurnaceTileEntity furnace = new FurnaceTileEntity(); - furnace.setLocation(world, BlockPos.ZERO); - furnace.setInventorySlotContents(0, stack); + WRAPPER.setInventorySlotContents(0, stack); Optional smeltingRecipe = world.getRecipeManager() - .getRecipe(IRecipeType.SMELTING, furnace, world); + .getRecipe(IRecipeType.SMELTING, WRAPPER, world); if (!smokingRecipe.isPresent()) { if (smeltingRecipe.isPresent()) return applyRecipeOn(stack, smeltingRecipe.get()); - // FIXME this does not need to be a TE - BlastFurnaceTileEntity blastFurnace = new BlastFurnaceTileEntity(); - blastFurnace.setLocation(world, BlockPos.ZERO); - blastFurnace.setInventorySlotContents(0, stack); + WRAPPER.setInventorySlotContents(0, stack); Optional blastingRecipe = world.getRecipeManager() - .getRecipe(IRecipeType.BLASTING, blastFurnace, world); + .getRecipe(IRecipeType.BLASTING, WRAPPER, world); if (blastingRecipe.isPresent()) return applyRecipeOn(stack, blastingRecipe.get()); @@ -299,6 +277,7 @@ public class InWorldProcessing { return stacks; } + public static void spawnParticlesForProcessing(@Nullable World world, Vector3d vec, Type type) { if (world == null || !world.isRemote) return; @@ -325,4 +304,10 @@ public class InWorldProcessing { } } + public static class SplashingWrapper extends RecipeWrapper { + public SplashingWrapper() { + super(new ItemStackHandler(1)); + } + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/TransportedItemStack.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/TransportedItemStack.java index 5202ea1df..85cea6d9a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/TransportedItemStack.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/TransportedItemStack.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.relays.belt.transport; import java.util.Random; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; -import com.simibubi.create.content.logistics.InWorldProcessing; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/ItemAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/ItemAttribute.java index 884156c60..7e7e1bb15 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/ItemAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/ItemAttribute.java @@ -12,7 +12,7 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import com.simibubi.create.AllRecipeTypes; -import com.simibubi.create.content.logistics.InWorldProcessing; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import com.simibubi.create.content.logistics.item.filter.attribute.BookAuthorAttribute; import com.simibubi.create.content.logistics.item.filter.attribute.BookCopyAttribute; import com.simibubi.create.content.logistics.item.filter.attribute.ColorAttribute; diff --git a/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java b/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java index 96392244e..18fcb1deb 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/AllAdvancements.java @@ -16,7 +16,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllFluids; import com.simibubi.create.AllItems; import com.simibubi.create.Create; -import com.simibubi.create.content.logistics.InWorldProcessing; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.Advancement.Builder; diff --git a/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java b/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java index 1e0c67527..959043354 100644 --- a/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java +++ b/src/main/java/com/simibubi/create/foundation/advancement/AllTriggers.java @@ -4,7 +4,7 @@ import java.util.LinkedList; import java.util.List; import java.util.function.Predicate; -import com.simibubi.create.content.logistics.InWorldProcessing; +import com.simibubi.create.content.contraptions.processing.InWorldProcessing; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.block.Block; From 773f74d33e9deabf1fcae6e100e4401732bf49ef Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Wed, 26 May 2021 20:13:07 -0700 Subject: [PATCH 104/198] Add piglin compat - Fix #678 by adding golden sheets and crushed gold ore to the piglin_loved tag --- src/main/java/com/simibubi/create/AllItems.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 25a418064..527a82549 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -58,6 +58,7 @@ import net.minecraft.item.Food; import net.minecraft.item.Item; import net.minecraft.item.Rarity; import net.minecraft.tags.ITag; +import net.minecraft.tags.ItemTags; import net.minecraft.util.ResourceLocation; public class AllItems { @@ -147,11 +148,11 @@ public class AllItems { COPPER_SHEET = taggedIngredient("copper_sheet", forgeItemTag("plates/copper"), PLATES.tag), BRASS_SHEET = taggedIngredient("brass_sheet", forgeItemTag("plates/brass"), PLATES.tag), IRON_SHEET = taggedIngredient("iron_sheet", forgeItemTag("plates/iron"), PLATES.tag), - GOLDEN_SHEET = taggedIngredient("golden_sheet", forgeItemTag("plates/gold"), PLATES.tag), + GOLDEN_SHEET = taggedIngredient("golden_sheet", forgeItemTag("plates/gold"), PLATES.tag, ItemTags.PIGLIN_LOVED), LAPIS_SHEET = taggedIngredient("lapis_sheet", forgeItemTag("plates/lapis_lazuli"), PLATES.tag), CRUSHED_IRON = taggedIngredient("crushed_iron_ore", CRUSHED_ORES.tag), - CRUSHED_GOLD = taggedIngredient("crushed_gold_ore", CRUSHED_ORES.tag), + CRUSHED_GOLD = taggedIngredient("crushed_gold_ore", CRUSHED_ORES.tag, ItemTags.PIGLIN_LOVED), CRUSHED_COPPER = taggedIngredient("crushed_copper_ore", CRUSHED_ORES.tag), CRUSHED_ZINC = taggedIngredient("crushed_zinc_ore", CRUSHED_ORES.tag), CRUSHED_BRASS = taggedIngredient("crushed_brass", CRUSHED_ORES.tag); From bcb365baa900bd14a5f9176a912ddfee66da62e4 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Wed, 26 May 2021 20:54:17 -0700 Subject: [PATCH 105/198] Fix processing for fireproof items with recipes - Check for smelting and blasting recipes before checking for fireproof-ness --- .../processing/InWorldProcessing.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java b/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java index 0858c17ed..b433755f1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/InWorldProcessing.java @@ -94,8 +94,23 @@ public class InWorldProcessing { } private static boolean canProcess(ItemStack stack, Type type, World world) { - if (type == Type.BLASTING) + if (type == Type.BLASTING) { + WRAPPER.setInventorySlotContents(0, stack); + Optional smeltingRecipe = world.getRecipeManager() + .getRecipe(IRecipeType.SMELTING, WRAPPER, world); + + if (smeltingRecipe.isPresent()) + return true; + + WRAPPER.setInventorySlotContents(0, stack); + Optional blastingRecipe = world.getRecipeManager() + .getRecipe(IRecipeType.BLASTING, WRAPPER, world); + + if (blastingRecipe.isPresent()) + return true; + return !stack.getItem().isFireproof(); + } if (type == Type.SMOKING) { WRAPPER.setInventorySlotContents(0, stack); @@ -178,11 +193,11 @@ public class InWorldProcessing { .getRecipe(IRecipeType.SMOKING, WRAPPER, world); if (type == Type.BLASTING) { - WRAPPER.setInventorySlotContents(0, stack); - Optional smeltingRecipe = world.getRecipeManager() - .getRecipe(IRecipeType.SMELTING, WRAPPER, world); - if (!smokingRecipe.isPresent()) { + WRAPPER.setInventorySlotContents(0, stack); + Optional smeltingRecipe = world.getRecipeManager() + .getRecipe(IRecipeType.SMELTING, WRAPPER, world); + if (smeltingRecipe.isPresent()) return applyRecipeOn(stack, smeltingRecipe.get()); From 3903631c7b9dcd25e856f525406aec1fe9e7b305 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Thu, 27 May 2021 14:36:24 +0200 Subject: [PATCH 106/198] Post-PR datagen --- src/generated/resources/.cache/cache | 5 +- .../assets/create/lang/unfinished/pl_pl.json | 86 +- .../assets/create/lang/unfinished/zh_tw.json | 1546 ++++++++--------- .../minecraft/tags/items/piglin_loved.json | 7 + 4 files changed, 826 insertions(+), 818 deletions(-) create mode 100644 src/generated/resources/data/minecraft/tags/items/piglin_loved.json diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 091f2d332..e1e64b2e5 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -417,11 +417,11 @@ fc1a5dc58cb00012cd311f909de3cd6085664994 assets/create/lang/unfinished/es_es.jso dd04db4e469ece034e9edde1d182d40ece3c917f assets/create/lang/unfinished/ja_jp.json a46af574991af844c58a7fe75b4c2b0ac888b4e0 assets/create/lang/unfinished/ko_kr.json 1ee72b0c9ac509ffcd17b19d17ab1f4b3506c9ce assets/create/lang/unfinished/nl_nl.json -b23f249ef0b28b2e2312e63f2fccf4401b282ac4 assets/create/lang/unfinished/pl_pl.json +c80b1e4310942e34b46f3cfed724e104782f1c65 assets/create/lang/unfinished/pl_pl.json 73030bf3d5aace5c3e991c6bf265322bba42286f assets/create/lang/unfinished/pt_br.json 73b1927e1d32e4229caa96e8d1bc25d39fb51377 assets/create/lang/unfinished/ru_ru.json aa3f0b918d948795e10878c3d42dbd4c39f71795 assets/create/lang/unfinished/zh_cn.json -1f15238d524e7b94b0ce5bcd09703b4742b9f960 assets/create/lang/unfinished/zh_tw.json +f6aef786fdc291201f388c661fb9ff2d0b936ba2 assets/create/lang/unfinished/zh_tw.json 487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json 3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json @@ -3708,6 +3708,7 @@ f6c8f34ceb475546dba5cc6ff288863ea795d20b data/forge/tags/items/storage_blocks/co 0d188ad2c33d10ee8f0d455c4e63a4460a8302fb data/minecraft/tags/blocks/stairs.json 92584f914c53e00c111f9ff5e3894e2e3594946b data/minecraft/tags/blocks/walls.json 09d26bcd0f94459f945219997277c4fbf14adeb7 data/minecraft/tags/fluids/water.json +49cadea86f6b63d5065b859a0d0e7ad772cf51d6 data/minecraft/tags/items/piglin_loved.json 29e6f7e3d4be9a9b0af1fca5d32fa55e29905ce2 data/minecraft/tags/items/slabs.json 0d188ad2c33d10ee8f0d455c4e63a4460a8302fb data/minecraft/tags/items/stairs.json 92584f914c53e00c111f9ff5e3894e2e3594946b data/minecraft/tags/items/walls.json diff --git a/src/generated/resources/assets/create/lang/unfinished/pl_pl.json b/src/generated/resources/assets/create/lang/unfinished/pl_pl.json index e52917f1b..c6cda6c14 100644 --- a/src/generated/resources/assets/create/lang/unfinished/pl_pl.json +++ b/src/generated/resources/assets/create/lang/unfinished/pl_pl.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 44", + "_": "Missing Localizations: 6", "_": "->------------------------] Game Elements [------------------------<-", @@ -58,7 +58,7 @@ "block.create.cogwheel": "Koło zębate", "block.create.content_observer": "Detektor zawartości", "block.create.controller_rail": "Tory sterujące", - "block.create.copper_backtank": "UNLOCALIZED: Copper Backtank", + "block.create.copper_backtank": "Miedziany zbiornik w plecaku", "block.create.copper_block": "Blok miedzi", "block.create.copper_casing": "Miedziana Obudowa", "block.create.copper_ore": "Ruda miedzi", @@ -439,7 +439,7 @@ "item.create.chocolate_glazed_berries": "Jagody w czekoladzie", "item.create.chromatic_compound": "Związek chromatyczny", "item.create.cinder_flour": "Rozżarzona mąka", - "item.create.copper_backtank": "UNLOCALIZED: Copper Backtank", + "item.create.copper_backtank": "Miedziany zbiornik w plecaku", "item.create.copper_ingot": "Sztabka miedzi", "item.create.copper_nugget": "Bryłka miedzi", "item.create.copper_sheet": "Arkusz miedzi", @@ -458,8 +458,8 @@ "item.create.crushed_tin_ore": "Rozkruszona ruda cyny", "item.create.crushed_uranium_ore": "Rozkruszona ruda uranu", "item.create.crushed_zinc_ore": "Rozkruszona ruda cynku", - "item.create.diving_boots": "UNLOCALIZED: Diving Boots", - "item.create.diving_helmet": "UNLOCALIZED: Diving Helmet", + "item.create.diving_boots": "Buty do nurkowania", + "item.create.diving_helmet": "Hełm do nurkowania", "item.create.dough": "Ciasto", "item.create.electron_tube": "Lampa elektronowa", "item.create.empty_blaze_burner": "Pusty płomienny palnik", @@ -683,7 +683,7 @@ "create.recipe.fan_blasting.fan": "Wiatrak za lawą", "create.recipe.pressing": "Tłoczenie", "create.recipe.mixing": "Mieszanie", - "create.recipe.deploying": "UNLOCALIZED: Deploying", + "create.recipe.deploying": "Aplikowanie", "create.recipe.automatic_shapeless": "Zautomatyzowanie nieokreślone konstruowanie", "create.recipe.automatic_brewing": "Zautomatyzowane warzenie", "create.recipe.packing": "Prasowanie", @@ -750,15 +750,15 @@ "create.orientation.alongX": "Wzdłuż X", "create.gui.terrainzapper.title": "Ręczny kształter", - "create.gui.terrainzapper.searchDiagonal": "UNLOCALIZED: Follow Diagonals", - "create.gui.terrainzapper.searchFuzzy": "UNLOCALIZED: Ignore Material Borders", - "create.gui.terrainzapper.patternSection": "UNLOCALIZED: Pattern", - "create.gui.terrainzapper.pattern.solid": "UNLOCALIZED: Solid", - "create.gui.terrainzapper.pattern.checkered": "UNLOCALIZED: Checkerboard", - "create.gui.terrainzapper.pattern.inversecheckered": "UNLOCALIZED: Inverted Checkerboard", - "create.gui.terrainzapper.pattern.chance25": "UNLOCALIZED: 25% Roll", - "create.gui.terrainzapper.pattern.chance50": "UNLOCALIZED: 50% Roll", - "create.gui.terrainzapper.pattern.chance75": "UNLOCALIZED: 75% Roll", + "create.gui.terrainzapper.searchDiagonal": "Wzdłuż linii ukośnych", + "create.gui.terrainzapper.searchFuzzy": "Ignoruj krawędzie materiałów", + "create.gui.terrainzapper.patternSection": "Wzór", + "create.gui.terrainzapper.pattern.solid": "Ciągły", + "create.gui.terrainzapper.pattern.checkered": "Szachownica", + "create.gui.terrainzapper.pattern.inversecheckered": "Odrócona szachownica", + "create.gui.terrainzapper.pattern.chance25": "Obrót o 25%", + "create.gui.terrainzapper.pattern.chance50": "Obrót o 50%", + "create.gui.terrainzapper.pattern.chance75": "Obrót o 75%", "create.gui.terrainzapper.placement": "Położenie", "create.gui.terrainzapper.placement.merged": "Połączony", "create.gui.terrainzapper.placement.attached": "Przyłączony", @@ -767,8 +767,8 @@ "create.gui.terrainzapper.brush.cuboid": "Prostopadłościan", "create.gui.terrainzapper.brush.sphere": "Kula", "create.gui.terrainzapper.brush.cylinder": "Walec", - "create.gui.terrainzapper.brush.surface": "UNLOCALIZED: Surface", - "create.gui.terrainzapper.brush.cluster": "UNLOCALIZED: Cluster", + "create.gui.terrainzapper.brush.surface": "Powierzchnia", + "create.gui.terrainzapper.brush.cluster": "Grupa", "create.gui.terrainzapper.tool": "Narzędzie", "create.gui.terrainzapper.tool.fill": "Wypełnianie", "create.gui.terrainzapper.tool.place": "Stawianie", @@ -778,8 +778,8 @@ "create.gui.terrainzapper.tool.flatten": "Wypłaszczanie", "create.terrainzapper.shiftRightClickToSet": "Shift+Prawe kliknięcie, aby wybrać kształt", - "create.terrainzapper.usingBlock": "UNLOCALIZED: Using: %1$s", - "create.terrainzapper.leftClickToSet": "UNLOCALIZED: Left-Click a Block to set Material", + "create.terrainzapper.usingBlock": "Używając: %1$s", + "create.terrainzapper.leftClickToSet": "Kliknij LPM na blok aby ustawić materiał", "create.minecart_coupling.two_couplings_max": "Wagoniki nie mogą mieć więcej niż dwa łączniki każdy", "create.minecart_coupling.unloaded": "Część twojego pociągu wydaje się być w niezaładowanych Chunkach.", @@ -1138,35 +1138,35 @@ "create.command.killTPSCommand.status.usage.1": "[Create]: Użyj \"/killtps start\", aby sztucznie spowolnić serwer\n", "create.command.killTPSCommand.argument.tickTime": "tickTime", - "create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up", + "create.contraption.minecart_contraption_too_big": "Ta maszyna w wagoniku jest zbyt duża, aby ją podnieść", "_": "->------------------------] Subtitles [------------------------<-", - "create.subtitle.cogs": "UNLOCALIZED: Cogwheels rumble", + "create.subtitle.cogs": "Koła zębate terkoczą", "create.subtitle.slime_added": "Szlam plaska", - "create.subtitle.contraption_disassemble": "UNLOCALIZED: Contraption stops", - "create.subtitle.wrench_rotate": "UNLOCALIZED: Wrench used", - "create.subtitle.mixing": "UNLOCALIZED: Mixing Noises", - "create.subtitle.mechanical_press_activation_belt": "UNLOCALIZED: Mechanical Press bonks", - "create.subtitle.worldshaper_place": "UNLOCALIZED: Worldshaper zaps", - "create.subtitle.deployer_polish": "UNLOCALIZED: Deployer applies polish", - "create.subtitle.depot_slide": "UNLOCALIZED: Item slides", - "create.subtitle.deny": "UNLOCALIZED: Declining boop", + "create.subtitle.contraption_disassemble": "Maszyna staje", + "create.subtitle.wrench_rotate": "Klucz skrzypi", + "create.subtitle.mixing": "Dźwięki mieszania", + "create.subtitle.mechanical_press_activation_belt": "Mechaniczna prasa stuka", + "create.subtitle.worldshaper_place": "Kształter strzela", + "create.subtitle.deployer_polish": "Aplikator poleruje", + "create.subtitle.depot_slide": "Przedmiot ślizga się", + "create.subtitle.deny": "Dźwięk odmowy", "create.subtitle.blaze_munch": "Płomyk szczęśliwie przeżuwa", "create.subtitle.schematicannon_launch_block": "Schematoarmata strzela", - "create.subtitle.funnel_flap": "UNLOCALIZED: Funnel Flaps", - "create.subtitle.copper_armor_equip": "UNLOCALIZED: Diving equipment clinks", + "create.subtitle.funnel_flap": "Lejek trzepocze", + "create.subtitle.copper_armor_equip": "Sprzęt do nurkowania pobrzękuje", "create.subtitle.schematicannon_finish": "Schematoarmata skończyła", - "create.subtitle.scroll_value": "UNLOCALIZED: Scroll-input clicks", + "create.subtitle.scroll_value": "Kliknięcie", "create.subtitle.mechanical_press_activation": "Mechaniczna prasa się uruchamia", - "create.subtitle.contraption_assemble": "UNLOCALIZED: Contraption moves", - "create.subtitle.crafter_craft": "UNLOCALIZED: Crafter crafts", - "create.subtitle.cranking": "UNLOCALIZED: Hand Crank turns", - "create.subtitle.crafter_click": "UNLOCALIZED: Crafter clicks", - "create.subtitle.wrench_remove": "UNLOCALIZED: Component breaks", - "create.subtitle.depot_plop": "UNLOCALIZED: Item lands", - "create.subtitle.confirm": "UNLOCALIZED: Affirmative ding", + "create.subtitle.contraption_assemble": "Maszyna przesuwa się", + "create.subtitle.crafter_craft": "Mechaniczny stół rzemieślniczy konstruuje", + "create.subtitle.cranking": "Ręczna korba obraca się", + "create.subtitle.crafter_click": "Mechaniczny stół rzemieślniczy stuka", + "create.subtitle.wrench_remove": "Komponent niszczy się", + "create.subtitle.depot_plop": "Przedmiot ląduje", + "create.subtitle.confirm": "Dźwięk potwierdzenia", "_": "->------------------------] Item Descriptions [------------------------<-", @@ -1545,11 +1545,11 @@ "create.ponder.blaze_burner.text_3": "Z użyciem płomiennego ciasta, palnik może uzyskać szczególnie wysoką temperaturę", "create.ponder.blaze_burner.text_4": "Dostarczanie płomykowi przedmiotów może zostać zautomatyzowane z użyciem aplikatorów lub mechanicznych ramion", - "create.ponder.brass_funnel.header": "Mosiężny lejek", - "create.ponder.brass_funnel.text_1": "Andezytowe lejki mogą pobierać jedynie pojedyncze przedmioty", - "create.ponder.brass_funnel.text_2": "Mosiężne lejki mogą pobierać nawet pełne stosy", + "create.ponder.brass_funnel.header": "Mosiężny lej", + "create.ponder.brass_funnel.text_1": "Andezytowe leje mogą pobierać jedynie pojedyncze przedmioty", + "create.ponder.brass_funnel.text_2": "Mosiężne leje mogą pobierać nawet pełne stosy", "create.ponder.brass_funnel.text_3": "Przewijanie na slocie filtrującym pozwala na precyzyjną kontrolę nad maksymalną wielkością stosu", - "create.ponder.brass_funnel.text_4": "Użycie przedmiotów patrząc na slot filtrujący spowoduje, że lejek będzie przesyłał tylko pasujące przedmioty", + "create.ponder.brass_funnel.text_4": "Użycie przedmiotu patrząc na slot filtrujący spowoduje, że lej będzie przesyłał tylko pasujące przedmioty", "create.ponder.brass_tunnel.header": "Używanie mosiężnych tuneli", "create.ponder.brass_tunnel.text_1": "Mosiężne tunele mogą być użyte do przykrycia Twoich taśmociągów", diff --git a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json index 5514b4f70..137dc29d9 100644 --- a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json +++ b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 668", + "_": "Missing Localizations: 42", "_": "->------------------------] Game Elements [------------------------<-", @@ -165,8 +165,8 @@ "block.create.gabbro_cobblestone_stairs": "碎輝長岩樓梯", "block.create.gabbro_cobblestone_wall": "碎輝長岩牆", "block.create.gabbro_pillar": "豎紋輝長岩", - "block.create.gantry_carriage": "UNLOCALIZED: Gantry Carriage", - "block.create.gantry_shaft": "UNLOCALIZED: Gantry Shaft", + "block.create.gantry_carriage": "門式起重機", + "block.create.gantry_shaft": "門式起重機滑道", "block.create.gearbox": "齒輪箱", "block.create.gearshift": "變速箱", "block.create.glass_fluid_pipe": "玻璃液體管道", @@ -373,15 +373,15 @@ "block.create.sequenced_gearshift": "可程式化齒輪箱", "block.create.shadow_steel_casing": "暗影機殼", "block.create.shaft": "傳動軸", - "block.create.smart_chute": "UNLOCALIZED: Smart Chute", + "block.create.smart_chute": "智慧滑道", "block.create.smart_fluid_pipe": "智慧液體管道", "block.create.speedometer": "速度計", "block.create.spout": "液體灌注器", "block.create.spruce_window": "雲杉木窗戶", "block.create.spruce_window_pane": "雲杉木窗戶片", - "block.create.sticker": "UNLOCALIZED: Sticker", + "block.create.sticker": "方塊黏著器", "block.create.sticky_mechanical_piston": "黏性機械活塞", - "block.create.stockpile_switch": "存量檢測器", + "block.create.stockpile_switch": "存量偵測器", "block.create.stressometer": "動能錶", "block.create.tiled_glass": "十字玻璃窗", "block.create.tiled_glass_pane": "十字玻璃窗戶片", @@ -401,7 +401,7 @@ "block.create.weathered_limestone_cobblestone_stairs": "碎風化石灰岩樓梯", "block.create.weathered_limestone_cobblestone_wall": "碎風化石灰岩牆", "block.create.weathered_limestone_pillar": "豎紋風化石灰岩", - "block.create.weighted_ejector": "UNLOCALIZED: Weighted Ejector", + "block.create.weighted_ejector": "物品彈射器", "block.create.white_sail": "白色風帆", "block.create.white_seat": "白色坐墊", "block.create.white_valve_handle": "白色閥門開關", @@ -414,7 +414,7 @@ "block.create.zinc_ore": "鋅礦石", "entity.create.contraption": "結構", - "entity.create.gantry_contraption": "UNLOCALIZED: Gantry Contraption", + "entity.create.gantry_contraption": "門式結構", "entity.create.seat": "坐墊", "entity.create.stationary_contraption": "固定結構", "entity.create.super_glue": "強力膠", @@ -436,7 +436,7 @@ "item.create.builders_tea": "工人茶", "item.create.chest_minecart_contraption": "裝修過的機械礦車", "item.create.chocolate_bucket": "巧克力桶", - "item.create.chocolate_glazed_berries": "UNLOCALIZED: Chocolate Glazed Berries", + "item.create.chocolate_glazed_berries": "巧克力甜莓", "item.create.chromatic_compound": "異彩化合物", "item.create.cinder_flour": "地獄麵粉", "item.create.copper_backtank": "UNLOCALIZED: Copper Backtank", @@ -471,7 +471,7 @@ "item.create.golden_sheet": "金板", "item.create.handheld_worldshaper": "地形雕塑器", "item.create.honey_bucket": "蜂蜜桶", - "item.create.honeyed_apple": "UNLOCALIZED: Honeyed Apple", + "item.create.honeyed_apple": "蜂蜜蘋果", "item.create.integrated_circuit": "IC板", "item.create.iron_sheet": "鐵板", "item.create.lapis_sheet": "青金石板", @@ -489,13 +489,13 @@ "item.create.schematic_and_quill": "藍圖與筆", "item.create.shadow_steel": "暗影鋼", "item.create.super_glue": "強力膠", - "item.create.sweet_roll": "UNLOCALIZED: Sweet Roll", + "item.create.sweet_roll": "甜捲捲", "item.create.tree_fertilizer": "樹木肥料", "item.create.vertical_gearbox": "豎直齒輪箱", "item.create.wand_of_symmetry": "對稱杖", "item.create.wheat_flour": "小麥粉", "item.create.whisk": "攪拌器", - "item.create.wrench": "板手", + "item.create.wrench": "扳手", "item.create.zinc_ingot": "鋅錠", "item.create.zinc_nugget": "鋅粒", @@ -510,8 +510,8 @@ "advancement.create.its_alive.desc": "首次使齒輪結構的旋轉。", "advancement.create.shifting_gears": "換檔,加速,起飛!", "advancement.create.shifting_gears.desc": "將大齒輪連接到小齒輪上,機械結構的轉速將會翻倍", - "advancement.create.overstressed": "超載", - "advancement.create.overstressed.desc": "首次使動能網路超載。", + "advancement.create.overstressed": "過載", + "advancement.create.overstressed.desc": "首次使動能網路過載。", "advancement.create.belt": "流水線作業", "advancement.create.belt.desc": "用輸送帶連接兩個傳動軸", "advancement.create.tunnel": "尋找掩護!", @@ -537,11 +537,11 @@ "advancement.create.wrench": "細部調整", "advancement.create.wrench.desc": "做出一個方便調整方塊的板手", "advancement.create.goggles": "動能,一目了然", - "advancement.create.goggles.desc": "做出一個能看到機械動能訊息的MR護目鏡", + "advancement.create.goggles.desc": "做出一個能看到機械動能訊息的MR護目鏡", "advancement.create.speedometer": "精密的速度控制", - "advancement.create.speedometer.desc": "放置一個速度計,並且戴上MR護目鏡來讀取數據", + "advancement.create.speedometer.desc": "放置一個速度計,並且戴上MR護目鏡來讀取數據", "advancement.create.stressometer": "精密的動能控制", - "advancement.create.stressometer.desc": "放置一個動能計,並且戴上MR護目鏡來讀取數據", + "advancement.create.stressometer.desc": "放置一個動能錶,並且戴上MR護目鏡來讀取數據", "advancement.create.aesthetics": "繁榮與美學!", "advancement.create.aesthetics.desc": "將支架放在傳動軸,管道和齒輪上。", "advancement.create.reinforced": "超級加固!", @@ -633,8 +633,8 @@ "advancement.create.arm_many_targets": "你是要累死我?", "advancement.create.arm_many_targets.desc": "配置一隻有十個或更多輸出位置的機械手臂。", "advancement.create.arm_blaze_burner": "燃燒吧!烈焰使者!", - "advancement.create.arm_blaze_burner.desc": "指揮機械臂給烈焰使者動力爐投食。", - "advancement.create.fist_bump": "朋友,來碰個拳", + "advancement.create.arm_blaze_burner.desc": "指揮機械手臂給烈焰使者動力爐投食。", + "advancement.create.fist_bump": "朋友,來擊拳", "advancement.create.fist_bump.desc": "使兩個機械手互相碰拳", "advancement.create.crushing_wheel": "一對大傢伙", "advancement.create.crushing_wheel.desc": "製作一對能更快粉碎物品的粉碎輪", @@ -692,14 +692,14 @@ "create.recipe.mechanical_crafting": "自動合成", "create.recipe.automatic_shaped": "自動合成", "create.recipe.block_cutting": "方塊切割", - "create.recipe.wood_cutting": "UNLOCALIZED: Wood Cutting", + "create.recipe.wood_cutting": "木材切割", "create.recipe.sandpaper_polishing": "砂紙打磨", "create.recipe.mystery_conversion": "神秘轉化", "create.recipe.spout_filling": "注液", "create.recipe.draining": "分液", "create.recipe.processing.chance": "%1$s%%概率", - "create.recipe.heat_requirement.none": "不需加熱", - "create.recipe.heat_requirement.heated": "加熱", + "create.recipe.heat_requirement.none": "不需要加熱", + "create.recipe.heat_requirement.heated": "普通加熱", "create.recipe.heat_requirement.superheated": "超級加熱", "create.generic.range": "範圍", @@ -713,8 +713,8 @@ "create.generic.unit.seconds": "秒", "create.generic.unit.minutes": "分", "create.generic.unit.rpm": "RPM", - "create.generic.unit.stress": "SU", - "create.generic.unit.degrees": "°", + "create.generic.unit.stress": "su", + "create.generic.unit.degrees": "度", "create.generic.unit.millibuckets": "%1$smB", "create.generic.clockwise": "順時鐘方向", "create.generic.counter_clockwise": "逆時鐘方向", @@ -814,18 +814,18 @@ "create.logistics.filter.apply_count": "使用提取計數過濾。", "create.gui.goggles.generator_stats": "產能器狀態:", - "create.gui.goggles.kinetic_stats": "機械學狀態:", - "create.gui.goggles.at_current_speed": "現在速度動能值", - "create.gui.goggles.pole_length": "UNLOCALIZED: Pole Length:", - "create.gui.goggles.fluid_container": "UNLOCALIZED: Fluid Container Info:", - "create.gui.goggles.fluid_container.capacity": "UNLOCALIZED: Capacity: ", - "create.gui.assembly.exception": "UNLOCALIZED: This Contraption was unable to assemble:", - "create.gui.assembly.exception.unmovableBlock": "UNLOCALIZED: Unmovable Block (%4$s) at [%1$s,%2$s,%3$s]", - "create.gui.assembly.exception.chunkNotLoaded": "UNLOCALIZED: The Block at [%1$s,%2$s,%3$s] was not in a loaded chunk", - "create.gui.assembly.exception.structureTooLarge": "UNLOCALIZED: There are too many Blocks included in the contraption.\nThe configured maximum is: %1$s", - "create.gui.assembly.exception.tooManyPistonPoles": "UNLOCALIZED: There are too many extension Poles attached to this Piston.\nThe configured maximum is: %1$s", - "create.gui.assembly.exception.noPistonPoles": "UNLOCALIZED: The Piston is missing some extension Poles", - "create.gui.assembly.exception.not_enough_sails": "UNLOCALIZED: Attached structure does not include enough sail-like blocks: %1$s\nA minimum of %2$s are required", + "create.gui.goggles.kinetic_stats": "機械狀態:", + "create.gui.goggles.at_current_speed": "目前動能值", + "create.gui.goggles.pole_length": "活塞桿長度:", + "create.gui.goggles.fluid_container": "液體容器資訊:", + "create.gui.goggles.fluid_container.capacity": "容量: ", + "create.gui.assembly.exception": "該結構無法組合:", + "create.gui.assembly.exception.unmovableBlock": "無法移動的方塊 (%4$s) 位於 [%1$s,%2$s,%3$s]", + "create.gui.assembly.exception.chunkNotLoaded": "位於 [%1$s,%2$s,%3$s] 方塊屬未載入區塊", + "create.gui.assembly.exception.structureTooLarge": "結構中的方塊數量過多.\nThe 可放置的數量最大為: %1$s", + "create.gui.assembly.exception.tooManyPistonPoles": "活塞的活塞桿數量過多\nThe 可放置的數量最大為: %1$s", + "create.gui.assembly.exception.noPistonPoles": "這個活塞遺失了一些活塞桿", + "create.gui.assembly.exception.not_enough_sails": "結構中所需的風帆類方塊數量不足: %1$s\n最少需要的數量為: %2$s", "create.gui.gauge.info_header": "儀表訊息:", "create.gui.speedometer.title": "旋轉速度", "create.gui.stressometer.title": "網路動能", @@ -842,19 +842,19 @@ "create.gui.stockpile_switch.move_to_upper_at": "移至上線%1$s%%", "create.gui.sequenced_gearshift.title": "可程式化齒輪箱", "create.gui.sequenced_gearshift.instruction": "指令", - "create.gui.sequenced_gearshift.instruction.turn_angle.descriptive": "UNLOCALIZED: Turn by angle", + "create.gui.sequenced_gearshift.instruction.turn_angle.descriptive": "以特定角度旋轉", "create.gui.sequenced_gearshift.instruction.turn_angle": "旋轉", "create.gui.sequenced_gearshift.instruction.turn_angle.angle": "角度", - "create.gui.sequenced_gearshift.instruction.turn_distance.descriptive": "UNLOCALIZED: Turn to move Piston/Pulley/Gantry", + "create.gui.sequenced_gearshift.instruction.turn_distance.descriptive": "帶動 活塞/滑輪/門式起重機", "create.gui.sequenced_gearshift.instruction.turn_distance": "驅動活塞", "create.gui.sequenced_gearshift.instruction.turn_distance.distance": "距離", - "create.gui.sequenced_gearshift.instruction.delay.descriptive": "UNLOCALIZED: Timed Delay", - "create.gui.sequenced_gearshift.instruction.delay": "UNLOCALIZED: Delay", - "create.gui.sequenced_gearshift.instruction.delay.duration": "UNLOCALIZED: Duration", - "create.gui.sequenced_gearshift.instruction.end.descriptive": "UNLOCALIZED: End", + "create.gui.sequenced_gearshift.instruction.delay.descriptive": "延遲時間", + "create.gui.sequenced_gearshift.instruction.delay": "延遲", + "create.gui.sequenced_gearshift.instruction.delay.duration": "間隔", + "create.gui.sequenced_gearshift.instruction.end.descriptive": "結束", "create.gui.sequenced_gearshift.instruction.end": "停止", - "create.gui.sequenced_gearshift.instruction.await.descriptive": "UNLOCALIZED: Await new Redstone Pulse", - "create.gui.sequenced_gearshift.instruction.await": "UNLOCALIZED: Await", + "create.gui.sequenced_gearshift.instruction.await.descriptive": "等待新的紅石脈衝", + "create.gui.sequenced_gearshift.instruction.await": "等待", "create.gui.sequenced_gearshift.speed": "速度,速度方向", "create.gui.sequenced_gearshift.speed.forward": "一倍速,正向", "create.gui.sequenced_gearshift.speed.forward_fast": "兩倍速,正向", @@ -1012,10 +1012,10 @@ "create.item_attributes.added_by.inverted": "不是由%1$s添加", "create.item_attributes.has_enchant": "有附魔效果%1$s", "create.item_attributes.has_enchant.inverted": "沒有附魔效果%1$s", - "create.item_attributes.color": "UNLOCALIZED: is dyed %1$s", - "create.item_attributes.color.inverted": "UNLOCALIZED: is not dyed %1$s", - "create.item_attributes.max_enchanted": "UNLOCALIZED: is enchanted at max level", - "create.item_attributes.max_enchanted.inverted": "UNLOCALIZED: is not enchanted at max level", + "create.item_attributes.color": "已被染色成 %1$s", + "create.item_attributes.color.inverted": "未被染色成 %1$s", + "create.item_attributes.max_enchanted": "已達到最高附魔等級", + "create.item_attributes.max_enchanted.inverted": "未達到最高附魔等級", "create.item_attributes.has_fluid": "包含%1$s", "create.item_attributes.has_fluid.inverted": "不包含%1$s", "create.item_attributes.has_name": "有自定義名稱%1$s", @@ -1051,8 +1051,8 @@ "create.gui.attribute_filter.deny_list.description": "只要沒有上述屬性,就可以通過", "create.gui.attribute_filter.add_reference_item": "添加參考物品", - "create.tooltip.holdForDescription": "UNLOCALIZED: Hold [%1$s] for Summary", - "create.tooltip.holdForControls": "UNLOCALIZED: Hold [%1$s] for Controls", + "create.tooltip.holdForDescription": "按住 [%1$s] 來讀取物品概要", + "create.tooltip.holdForControls": "按住 [%1$s] 來讀取控制方法", "create.tooltip.keyShift": "Shift", "create.tooltip.keyCtrl": "Ctrl", "create.tooltip.speedRequirement": "需求速度:%1$s", @@ -1076,11 +1076,11 @@ "create.mechanical_arm.summary": "機械手臂有%1$s 輸入以及 %2$s 輸出。", "create.mechanical_arm.points_outside_range": "%1$s 由於距離限制,選定的交互點被移除。", - "create.weighted_ejector.target_set": "UNLOCALIZED: Target Selected", - "create.weighted_ejector.target_not_valid": "UNLOCALIZED: Ejecting to Adjacent block (Target was not Valid)", - "create.weighted_ejector.no_target": "UNLOCALIZED: Ejecting to Adjacent block (No Target was Selected)", - "create.weighted_ejector.targeting": "UNLOCALIZED: Ejecting to [%1$s,%2$s,%3$s]", - "create.weighted_ejector.stack_size": "UNLOCALIZED: Ejected Stack Size", + "create.weighted_ejector.target_set": "已選取目的地", + "create.weighted_ejector.target_not_valid": "彈射到鄰近的方塊 (目的地無效)", + "create.weighted_ejector.no_target": "彈射到鄰近的方塊 (未選取目的地)", + "create.weighted_ejector.targeting": "彈射到 [%1$s,%2$s,%3$s]", + "create.weighted_ejector.stack_size": "彈射物品數量", "create.logistics.when_multiple_outputs_available": "當多個輸出可用時", @@ -1104,7 +1104,7 @@ "create.tooltip.chute.fans_push_down": "鼓風機從上方進行推動", "create.tooltip.chute.fans_pull_up": "鼓風機從下方進行吸引", "create.tooltip.chute.fans_pull_down": "鼓風機從上方進行吸引", - "create.tooltip.chute.contains": "UNLOCALIZED: Contains: %1$s x%2$s", + "create.tooltip.chute.contains": "物品: %1$s x%2$s", "create.linked_controller.bind_mode": "UNLOCALIZED: Bind mode active", "create.linked_controller.press_keybind": "UNLOCALIZED: Press %1$s, %2$s, %3$s, %4$s, %5$s or %6$s, to bind this frequency to the respective key", @@ -1112,20 +1112,20 @@ "create.linked_controller.frequency_slot_1": "UNLOCALIZED: Keybind: %1$s, Freq. #1", "create.linked_controller.frequency_slot_2": "UNLOCALIZED: Keybind: %1$s, Freq. #2", - "create.hint.hose_pulley.title": "UNLOCALIZED: Bottomless Supply", - "create.hint.hose_pulley": "UNLOCALIZED: The targeted body of fluid is considered infinite.", + "create.hint.hose_pulley.title": "無限供應", + "create.hint.hose_pulley": "目標液體為無限供應", "create.hint.mechanical_arm_no_targets.title": "沒有目標", "create.hint.mechanical_arm_no_targets": "看起來這個_機械手臂_沒有被分配任何_目標_。在手持機械手臂的同時,右鍵選取輸送帶、置物臺、漏斗或其他設備來設定目標。", "create.hint.empty_bearing.title": "更新軸承", "create.hint.empty_bearing": "_空手右鍵_軸承來_添加_你新建造的結構。", "create.hint.full_deployer.title": "機械手物品溢出", - "create.hint.full_deployer": "_機械手_包含_過剩的物品_需要被_提取._使用_漏斗,__漏斗_或其他方法將溢出解決。", + "create.hint.full_deployer": "_機械手_包含_過剩的物品_需要被_取出._使用漏斗_或其他方法將溢出解決。", "create.gui.config.overlay1": "嗨 :)", "create.gui.config.overlay2": "這是一個實例層", "create.gui.config.overlay3": "點擊拖拽你的滑鼠", "create.gui.config.overlay4": "來將它移動到前方", - "create.gui.config.overlay5": "ESC退出目前界面", + "create.gui.config.overlay5": "ESC退出目前介面", "create.gui.config.overlay6": "並儲存新的位置", "create.gui.config.overlay7": "輸入/create overlay reset", "create.gui.config.overlay8": "重置到預設位置", @@ -1138,7 +1138,7 @@ "create.command.killTPSCommand.status.usage.1": "[Create]: 用 /killtps start 來手動降低伺服器TPS", "create.command.killTPSCommand.argument.tickTime": "tickTime", - "create.contraption.minecart_contraption_too_big": "UNLOCALIZED: This Cart Contraption seems too big to pick up", + "create.contraption.minecart_contraption_too_big": "這個礦車結構太大了而無法撿取", "_": "->------------------------] Subtitles [------------------------<-", @@ -1148,7 +1148,7 @@ "create.subtitle.contraption_disassemble": "UNLOCALIZED: Contraption stops", "create.subtitle.wrench_rotate": "UNLOCALIZED: Wrench used", "create.subtitle.mixing": "UNLOCALIZED: Mixing Noises", - "create.subtitle.mechanical_press_activation_belt": "UNLOCALIZED: Mechanical Press bonks", + "create.subtitle.mechanical_press_activation_belt": "液壓機工作", "create.subtitle.worldshaper_place": "UNLOCALIZED: Worldshaper zaps", "create.subtitle.deployer_polish": "UNLOCALIZED: Deployer applies polish", "create.subtitle.depot_slide": "UNLOCALIZED: Item slides", @@ -1188,10 +1188,10 @@ "block.create.copper_casing.tooltip": "銅製機殼", "block.create.copper_casing.tooltip.summary": "具備多種用途的堅固機殼,也可用於裝飾。", - "block.create.copper_casing.tooltip.condition1": "對流體管道使用時", + "block.create.copper_casing.tooltip.condition1": "對液體管道使用時", "block.create.copper_casing.tooltip.behaviour1": "會把管道裝入機殼,裝進機殼的管道會與其他管道分開,以免它們自動相連。", - "block.create.encased_fluid_pipe.tooltip": "流體管道箱", + "block.create.encased_fluid_pipe.tooltip": "液體管道箱", "block.create.encased_fluid_pipe.tooltip.summary": "用銅機殼加固后的液體管道。", "block.create.seat.tooltip": "坐墊", @@ -1206,8 +1206,8 @@ "block.create.fluid_pipe.tooltip.summary": "用來傳輸_液體_。需要一個_機械泵_來提供壓強。", "block.create.fluid_pipe.tooltip.condition1": "轉移液體", "block.create.fluid_pipe.tooltip.behaviour1": "可以與_液體容器_如_儲存罐_或_作業盆_相連_。裸露的_管道_末端也可以排放或抽取液體。注意別漏水了!", - "block.create.fluid_pipe.tooltip.condition2": "UNLOCALIZED: Right-clicked with Wrench", - "block.create.fluid_pipe.tooltip.behaviour2": "UNLOCALIZED: Places a window on the pipe if available", + "block.create.fluid_pipe.tooltip.condition2": "使用扳手對其右鍵時", + "block.create.fluid_pipe.tooltip.behaviour2": "在狀況許可的情況下在管道上安裝透明窗", "block.create.hose_pulley.tooltip": "軟管滑輪", "block.create.hose_pulley.tooltip.summary": "用來在_世界_中放置或排放大量的液體。", @@ -1233,7 +1233,7 @@ "block.create.fluid_valve.tooltip": "液體閥門", "block.create.fluid_valve.tooltip.summary": "阻止液體沿管道向前流動。", "block.create.fluid_valve.tooltip.condition1": "控制流量", - "block.create.fluid_valve.tooltip.behaviour1": "施加的_旋轉力_將迫使閥門關閉,從而阻止液體流動。_逆轉旋轉方向_以重新打開閥門。", + "block.create.fluid_valve.tooltip.behaviour1": "施加的_動能_將迫使閥門關閉,從而阻止液體流動。_逆轉旋轉方向_以重新打開閥門。", "block.create.mechanical_pump.tooltip": "機械泵", "block.create.mechanical_pump.tooltip.summary": "_接入機械_,能迫使液體_沿管道指定方向移動_。在兩個方向上都有_最大的作用範圍_。(默認為16個方塊距離)", @@ -1270,7 +1270,7 @@ "item.create.wand_of_symmetry.tooltip.control2": "當右鍵空氣時", "item.create.wand_of_symmetry.tooltip.action2": "_刪除_鏡子", "item.create.wand_of_symmetry.tooltip.control3": "當潛行右鍵時", - "item.create.wand_of_symmetry.tooltip.action3": "打開_gui界面_", + "item.create.wand_of_symmetry.tooltip.action3": "打開_gui介面_", "item.create.handheld_worldshaper.tooltip": "環境塑形器", "item.create.handheld_worldshaper.tooltip.summary": "_大面積_更改地形的手持工具", @@ -1279,7 +1279,7 @@ "item.create.handheld_worldshaper.tooltip.control2": "當右鍵方塊時", "item.create.handheld_worldshaper.tooltip.action2": "_放置_或_替換_目標方塊", "item.create.handheld_worldshaper.tooltip.control3": "當潛行右鍵時", - "item.create.handheld_worldshaper.tooltip.action3": "打開工具的_gui界面_", + "item.create.handheld_worldshaper.tooltip.action3": "打開工具的_gui介面_", "item.create.tree_fertilizer.tooltip": "樹木肥料", "item.create.tree_fertilizer.tooltip.summary": "適用來常見樹木的快速肥料", @@ -1294,9 +1294,9 @@ "item.create.filter.tooltip": "過濾器", "item.create.filter.tooltip.summary": "將物品更精確地進行_篩選分類_,可以同時_篩選_多個物品或者將已標記的_過濾器_放在另一個_過濾器_里_嵌套_使用。", "item.create.filter.tooltip.condition1": "放置於過濾插槽中時", - "item.create.filter.tooltip.behaviour1": "根據_過濾器_的配置,來_決定_物品是否能夠通過", + "item.create.filter.tooltip.behaviour1": "根據_過濾器_的設定,來_決定_物品是否能夠通過", "item.create.filter.tooltip.condition2": "當右鍵時", - "item.create.filter.tooltip.behaviour2": "打開_配置面板_", + "item.create.filter.tooltip.behaviour2": "打開_設定面板_", "item.create.attribute_filter.tooltip": "屬性過濾器", "item.create.attribute_filter.tooltip.summary": "比起普通過濾器,_屬性過濾器_可以根據不同物品的_屬性_來進行過濾", @@ -1309,20 +1309,20 @@ "item.create.empty_schematic.tooltip.summary": "可作為合成材料或在_藍圖桌_使用", "item.create.schematic.tooltip": "藍圖", - "item.create.schematic.tooltip.summary": "將工程結構的_全息圖_放置於_世界中_,並使用_藍圖加農炮_進行構建。", - "item.create.schematic.tooltip.condition1": "當全息圖存在時", + "item.create.schematic.tooltip.summary": "將工程結構的_設計圖_放置於_世界中_,並使用_藍圖加農炮_進行構建。", + "item.create.schematic.tooltip.condition1": "當設計圖存在時", "item.create.schematic.tooltip.behaviour1": "可以使用屏幕上的工具調整位置", "item.create.schematic.tooltip.control1": "當潛行右鍵時", - "item.create.schematic.tooltip.action1": "打開一個用來輸入_精確坐標_的界面。", + "item.create.schematic.tooltip.action1": "打開一個用來輸入_精確坐標_的介面。", "item.create.schematic_and_quill.tooltip": "藍圖與筆", - "item.create.schematic_and_quill.tooltip.summary": "用來將世界中的結構保存到.nbt文件。", + "item.create.schematic_and_quill.tooltip.summary": "用來將世界中的結構存到.nbt文件。", "item.create.schematic_and_quill.tooltip.condition1": "第一步", "item.create.schematic_and_quill.tooltip.behaviour1": "手持藍圖與右鍵旋轉兩個點", "item.create.schematic_and_quill.tooltip.condition2": "第二步", - "item.create.schematic_and_quill.tooltip.behaviour2": "按住Ctrl滑鼠滾輪選擇選區大小,右鍵空白處保存。", + "item.create.schematic_and_quill.tooltip.behaviour2": "按住Ctrl滑鼠滾輪選擇選區大小,右鍵空白處存檔。", "item.create.schematic_and_quill.tooltip.control1": "右鍵", - "item.create.schematic_and_quill.tooltip.action1": "選取點/確認保存", + "item.create.schematic_and_quill.tooltip.action1": "選取點/確認存檔", "item.create.schematic_and_quill.tooltip.control2": "按住Ctrl滑鼠滾輪", "item.create.schematic_and_quill.tooltip.action2": "在_空中_選擇點滾動以調整距離。", "item.create.schematic_and_quill.tooltip.control3": "當潛行右鍵時", @@ -1330,8 +1330,8 @@ "block.create.schematicannon.tooltip": "藍圖加農炮", "block.create.schematicannon.tooltip.summary": "通過發射方塊以在世界中重新構建已部署的_全息圖_,使用相鄰箱子中的物品及_火藥_作為燃料。", - "block.create.schematicannon.tooltip.condition1": "UNLOCALIZED: When R-Clicked", - "block.create.schematicannon.tooltip.behaviour1": "UNLOCALIZED: Opens the _Interface_", + "block.create.schematicannon.tooltip.condition1": "當你對加農砲右鍵時", + "block.create.schematicannon.tooltip.behaviour1": "打開加農砲的設定介面", "block.create.schematic_table.tooltip": "藍圖桌", "block.create.schematic_table.tooltip.summary": "將保存的藍圖圖寫入_空白藍圖_", @@ -1341,11 +1341,11 @@ "item.create.goggles.tooltip": "MR護目鏡", "item.create.goggles.tooltip.summary": "一副特殊的眼鏡,能夠讓你看見_動能_的信息。", "item.create.goggles.tooltip.condition1": "當裝備後", - "item.create.goggles.tooltip.behaviour1": "將會展示該機械元件的_速度_、_動能_等數值", + "item.create.goggles.tooltip.behaviour1": "將會顯示該機械元件的_速度_、_動能_等數值。", "item.create.goggles.tooltip.condition2": "當裝備後看向儀表時", - "item.create.goggles.tooltip.behaviour2": "將會展示該儀表所連接網路的_速度_、_動能_等數值。", - "item.create.goggles.tooltip.condition3": "UNLOCALIZED: When looking at fluid containers", - "item.create.goggles.tooltip.behaviour3": "UNLOCALIZED: Shows detailed information about the _Capacity_ of the block and any _Fluids_ stored within.", + "item.create.goggles.tooltip.behaviour2": "將會顯示該儀表所連接網路的_速度_、_動能_等數值。", + "item.create.goggles.tooltip.condition3": "當裝備後看向液體容器時", + "item.create.goggles.tooltip.behaviour3": "將會顯示儲存在該容器內的 _液體_ 以及其 _容量_ 等資訊。", "item.create.wrench.tooltip": "板手", "item.create.wrench.tooltip.summary": "一種常用的工具,能夠調整_動能_的_方向_、_配置_等。", @@ -1372,18 +1372,18 @@ "block.create.portable_fluid_interface.tooltip.condition2": "被紅石激活時", "block.create.portable_fluid_interface.tooltip.behaviour2": "立即終止任何活動的連接。", - "block.create.stockpile_switch.tooltip": "存量檢測器", + "block.create.stockpile_switch.tooltip": "存量偵測器", "block.create.stockpile_switch.tooltip.summary": "根據連接的容器_儲存空間_的占用情況切換紅石訊號強度。", "block.create.stockpile_switch.tooltip.condition1": "低於_下線_或高於_上線_時", "block.create.stockpile_switch.tooltip.behaviour1": "提供紅石訊號", "block.create.content_observer.tooltip": "物品偵測器", - "block.create.content_observer.tooltip.summary": "檢測_容器_和_輸送帶_中過濾器匹配的物品。當觀察到包含匹配的物品時,此組件將發出_紅石訊號_。當觀察到的漏斗_轉移匹配的物品_時,此組件將發出_紅石脈沖_。", + "block.create.content_observer.tooltip.summary": "偵測_容器_和_輸送帶_中過濾器匹配的物品。當觀察到包含匹配的物品時,此組件將發出_紅石訊號_。當觀察到的漏斗_轉移匹配的物品_時,此組件將發出_紅石脈沖_。", "block.create.adjustable_crate.tooltip": "可調節板條箱", - "block.create.adjustable_crate.tooltip.summary": "該箱子支持玩家對其容量進行調整,最大可以容納_16組_物品。", - "block.create.adjustable_crate.tooltip.condition1": "UNLOCALIZED: When R-Clicked", - "block.create.adjustable_crate.tooltip.behaviour1": "UNLOCALIZED: Opens the _Interface_.", + "block.create.adjustable_crate.tooltip.summary": "這個箱子可以調整容量,最大可以收納_16組_物品。", + "block.create.adjustable_crate.tooltip.condition1": "當你對箱子按右鍵時", + "block.create.adjustable_crate.tooltip.behaviour1": "打開箱子的設定介面", "block.create.creative_crate.tooltip": "創造板條箱", "block.create.creative_crate.tooltip.summary": "這個容器可以給臨近的_藍圖大炮_提供無限物品以及燃料 (創造專用物品)", @@ -1400,7 +1400,7 @@ "item.create.sand_paper.tooltip.condition1": "使用時", "item.create.sand_paper.tooltip.behaviour1": "打磨_副手_上或者_準心所指_的物品。", - "item.create.builders_tea.tooltip": "建造工茶飲", + "item.create.builders_tea.tooltip": "工人茶", "item.create.builders_tea.tooltip.summary": "神清氣爽的一天,從這杯完美茶飲開始。恢復復_饑餓值_並獲得_加速_效果。", "item.create.refined_radiance.tooltip": "光輝石", @@ -1416,9 +1416,9 @@ "create.tooltip.wip": "半成品", "create.tooltip.workInProgress": "尚在製作中!", - "create.tooltip.randomWipDescription0": "禁止將此物品給兒童。", + "create.tooltip.randomWipDescription0": "禁止將此物品給屁孩。", "create.tooltip.randomWipDescription1": "每~一~次~你使用此物品時,就會使一隻小熊貓死亡。", - "create.tooltip.randomWipDescription2": "使用此物請自負後果。", + "create.tooltip.randomWipDescription2": "使用此物品請自負後果。", "create.tooltip.randomWipDescription3": "快走開,這不是你要找的東西(搖手指", "create.tooltip.randomWipDescription4": "啟動自爆模式,10、9、8...。", "create.tooltip.randomWipDescription5": "你已經沒有退路了。", @@ -1429,688 +1429,688 @@ "_": "->------------------------] Ponder Content [------------------------<-", - "create.ponder.hold_to_ponder": "UNLOCALIZED: Hold [%1$s] to Ponder", - "create.ponder.subject": "UNLOCALIZED: Subject of this scene", - "create.ponder.pondering": "UNLOCALIZED: Pondering about...", - "create.ponder.identify_mode": "UNLOCALIZED: Identify mode active.\nUnpause with [%1$s]", - "create.ponder.associated": "UNLOCALIZED: Associated Entries", - "create.ponder.close": "UNLOCALIZED: Close", - "create.ponder.identify": "UNLOCALIZED: Identify", - "create.ponder.next": "UNLOCALIZED: Next Scene", - "create.ponder.previous": "UNLOCALIZED: Previous Scene", - "create.ponder.replay": "UNLOCALIZED: Replay", - "create.ponder.think_back": "UNLOCALIZED: Think Back", - "create.ponder.slow_text": "UNLOCALIZED: Comfy Reading", - "create.ponder.shared.movement_anchors": "UNLOCALIZED: With the help of Chassis or Super Glue, larger structures can be moved.", - "create.ponder.shared.rpm32": "UNLOCALIZED: 32 RPM", - "create.ponder.shared.sneak_and": "UNLOCALIZED: Sneak +", - "create.ponder.shared.storage_on_contraption": "UNLOCALIZED: Inventories attached to the Contraption will pick up their drops automatically", - "create.ponder.shared.behaviour_modify_wrench": "UNLOCALIZED: This behaviour can be modified using a Wrench", - "create.ponder.shared.rpm8": "UNLOCALIZED: 8 RPM", - "create.ponder.shared.ctrl_and": "UNLOCALIZED: Ctrl +", - "create.ponder.shared.rpm16_source": "UNLOCALIZED: Source: 16 RPM", - "create.ponder.shared.rpm16": "UNLOCALIZED: 16 RPM", - "create.ponder.tag.kinetic_sources": "UNLOCALIZED: Kinetic Sources", - "create.ponder.tag.kinetic_sources.description": "UNLOCALIZED: Components which generate Rotational Force", - "create.ponder.tag.contraption_actor": "UNLOCALIZED: Contraption Actors", - "create.ponder.tag.contraption_actor.description": "UNLOCALIZED: Components which expose special behaviour when attached to a moving contraption", - "create.ponder.tag.arm_targets": "UNLOCALIZED: Targets for Mechanical Arms", - "create.ponder.tag.arm_targets.description": "UNLOCALIZED: Components which can be selected as inputs or outputs to the Mechanical Arm", - "create.ponder.tag.logistics": "UNLOCALIZED: Item Transportation", - "create.ponder.tag.logistics.description": "UNLOCALIZED: Components which help moving items around", - "create.ponder.tag.movement_anchor": "UNLOCALIZED: Movement Anchors", - "create.ponder.tag.movement_anchor.description": "UNLOCALIZED: Components which allow the creation of moving contraptions, animating an attached structure in a variety of ways", - "create.ponder.tag.creative": "UNLOCALIZED: Creative Mode", - "create.ponder.tag.creative.description": "UNLOCALIZED: Components not usually available for Survival Mode", - "create.ponder.tag.kinetic_relays": "UNLOCALIZED: Kinetic Blocks", - "create.ponder.tag.kinetic_relays.description": "UNLOCALIZED: Components which help relaying Rotational Force elsewhere", - "create.ponder.tag.windmill_sails": "UNLOCALIZED: Sails for Windmill Bearings", - "create.ponder.tag.windmill_sails.description": "UNLOCALIZED: Blocks that count towards the strength of a Windmill Contraption when assembled. Each of these have equal efficiency in doing so.", - "create.ponder.tag.contraption_assembly": "UNLOCALIZED: Block Attachment Utility", - "create.ponder.tag.contraption_assembly.description": "UNLOCALIZED: Tools and Components used to assemble structures moved as an animated Contraption", - "create.ponder.tag.decoration": "UNLOCALIZED: Aesthetics", - "create.ponder.tag.decoration.description": "UNLOCALIZED: Components used mostly for decorative purposes", - "create.ponder.tag.kinetic_appliances": "UNLOCALIZED: Kinetic Appliances", - "create.ponder.tag.kinetic_appliances.description": "UNLOCALIZED: Components which make use of Rotational Force", - "create.ponder.tag.redstone": "UNLOCALIZED: Logic Components", - "create.ponder.tag.redstone.description": "UNLOCALIZED: Components which help with redstone engineering", - "create.ponder.tag.fluids": "UNLOCALIZED: Fluid Manipulators", - "create.ponder.tag.fluids.description": "UNLOCALIZED: Components which help relaying and making use of Fluids", - - "create.ponder.adjustable_pulse_repeater.header": "UNLOCALIZED: Controlling signals using Adjustable Pulse Repeaters", - "create.ponder.adjustable_pulse_repeater.text_1": "UNLOCALIZED: Adjustable Pulse Repeaters emit a short pulse at a delay", - "create.ponder.adjustable_pulse_repeater.text_2": "UNLOCALIZED: Using the mouse wheel, the charge time can be configured", - "create.ponder.adjustable_pulse_repeater.text_3": "UNLOCALIZED: Configured delays can range up to 30 minutes", - - "create.ponder.adjustable_repeater.header": "UNLOCALIZED: Controlling signals using Adjustable Repeaters", - "create.ponder.adjustable_repeater.text_1": "UNLOCALIZED: Adjustable Repeaters behave similarly to regular Repeaters", - "create.ponder.adjustable_repeater.text_2": "UNLOCALIZED: They charge up for a set time...", - "create.ponder.adjustable_repeater.text_3": "UNLOCALIZED: ...and cool down for the same duration", - "create.ponder.adjustable_repeater.text_4": "UNLOCALIZED: Using the mouse wheel, the charge time can be configured", - "create.ponder.adjustable_repeater.text_5": "UNLOCALIZED: Configured delays can range up to 30 minutes", - - "create.ponder.analog_lever.header": "UNLOCALIZED: Controlling signals using the Analog Lever", - "create.ponder.analog_lever.text_1": "UNLOCALIZED: Analog Levers make for a compact and precise source of redstone power", - "create.ponder.analog_lever.text_2": "UNLOCALIZED: Right-click to increase its analog power output", - "create.ponder.analog_lever.text_3": "UNLOCALIZED: Right-click while Sneaking to decrease the power output again", - - "create.ponder.andesite_tunnel.header": "UNLOCALIZED: Using Andesite Tunnels", - "create.ponder.andesite_tunnel.text_1": "UNLOCALIZED: Andesite Tunnels can be used to cover up your belts", - "create.ponder.andesite_tunnel.text_2": "UNLOCALIZED: Whenever an Andesite Tunnel has connections to the sides...", - "create.ponder.andesite_tunnel.text_3": "UNLOCALIZED: ...they will split exactly one item off of any passing stacks", - "create.ponder.andesite_tunnel.text_4": "UNLOCALIZED: The remainder will continue on its path", - - "create.ponder.basin.header": "UNLOCALIZED: Processing Items in the Basin", - "create.ponder.basin.text_1": "UNLOCALIZED: A Basin can hold Items and Fluids for Processing", - "create.ponder.basin.text_2": "UNLOCALIZED: After a processing step, basins try to output below to the side of them", - "create.ponder.basin.text_3": "UNLOCALIZED: When a valid component is present, the Basin will show an output faucet", - "create.ponder.basin.text_4": "UNLOCALIZED: A number of options are applicable here", - "create.ponder.basin.text_5": "UNLOCALIZED: Outputs will be caught by the inventory below", - "create.ponder.basin.text_6": "UNLOCALIZED: Without output faucet, the Basin will retain items created in its processing", - "create.ponder.basin.text_7": "UNLOCALIZED: This can be useful if outputs should be re-used as ingredients", - "create.ponder.basin.text_8": "UNLOCALIZED: Desired outputs will then have to be extracted from the basin", - "create.ponder.basin.text_9": "UNLOCALIZED: A Filter might be necessary to avoid pulling out un-processed items", - - "create.ponder.bearing_modes.header": "UNLOCALIZED: Movement Modes of the Mechanical Bearing", - "create.ponder.bearing_modes.text_1": "UNLOCALIZED: When Stopped, the Bearing will place the structure at the nearest grid-aligned Angle", - "create.ponder.bearing_modes.text_2": "UNLOCALIZED: It can be configured never to revert to solid blocks, or only near the angle it started at", - - "create.ponder.belt_casing.header": "UNLOCALIZED: Encasing Belts", - "create.ponder.belt_casing.text_1": "UNLOCALIZED: Brass or Andesite Casing can be used to decorate Mechanical Belts", - "create.ponder.belt_casing.text_2": "UNLOCALIZED: A wrench can be used to remove the casing", - - "create.ponder.belt_connector.header": "UNLOCALIZED: Using Mechanical Belts", - "create.ponder.belt_connector.text_1": "UNLOCALIZED: Right-Clicking two shafts with a belt item will connect them together", - "create.ponder.belt_connector.text_2": "UNLOCALIZED: Accidental selections can be canceled with Right-Click while Sneaking", - "create.ponder.belt_connector.text_3": "UNLOCALIZED: Additional Shafts can be added throughout the Belt", - "create.ponder.belt_connector.text_4": "UNLOCALIZED: Shafts connected via Belts will rotate with Identical Speed and Direction", - "create.ponder.belt_connector.text_5": "UNLOCALIZED: Added shafts can be removed using the wrench", - "create.ponder.belt_connector.text_6": "UNLOCALIZED: Mechanical Belts can be dyed for aesthetic purposes", - - "create.ponder.belt_directions.header": "UNLOCALIZED: Valid Orientations for Mechanical Belts", - "create.ponder.belt_directions.text_1": "UNLOCALIZED: Belts cannot connect in arbitrary directions", - "create.ponder.belt_directions.text_2": "UNLOCALIZED: 1. They can connect horizontally", - "create.ponder.belt_directions.text_3": "UNLOCALIZED: 2. They can connect diagonally", - "create.ponder.belt_directions.text_4": "UNLOCALIZED: 3. They can connect vertically", - "create.ponder.belt_directions.text_5": "UNLOCALIZED: 4. And they can connect vertical shafts horizontally", - "create.ponder.belt_directions.text_6": "UNLOCALIZED: These are all possible directions. Belts can span any Length between 2 and 20 blocks", - - "create.ponder.belt_transport.header": "UNLOCALIZED: Using Mechanical Belts for Logistics", - "create.ponder.belt_transport.text_1": "UNLOCALIZED: Moving belts will transport Items and other Entities", - "create.ponder.belt_transport.text_2": "UNLOCALIZED: Right-Click with an empty hand to take items off a belt", - - "create.ponder.blaze_burner.header": "UNLOCALIZED: Feeding Blaze Burners", - "create.ponder.blaze_burner.text_1": "UNLOCALIZED: Blaze Burners can provide Heat to Items processed in a Basin", - "create.ponder.blaze_burner.text_2": "UNLOCALIZED: For this, the Blaze has to be fed with flammable items", - "create.ponder.blaze_burner.text_3": "UNLOCALIZED: With a Blaze Cake, the Burner can reach an even stronger level of heat", - "create.ponder.blaze_burner.text_4": "UNLOCALIZED: The feeding process can be automated using Deployers or Mechanical Arms", - - "create.ponder.brass_funnel.header": "UNLOCALIZED: The Brass Funnel", - "create.ponder.brass_funnel.text_1": "UNLOCALIZED: Andesite Funnels can only ever extract single items.", - "create.ponder.brass_funnel.text_2": "UNLOCALIZED: Brass Funnels can extract up to a full stack.", - "create.ponder.brass_funnel.text_3": "UNLOCALIZED: Scrolling on the filter slot allows for precise control over the extracted stack size.", - "create.ponder.brass_funnel.text_4": "UNLOCALIZED: Using items on the filter slot will restrict the funnel to only transfer matching stacks.", - - "create.ponder.brass_tunnel.header": "UNLOCALIZED: Using Brass Tunnels", - "create.ponder.brass_tunnel.text_1": "UNLOCALIZED: Brass Tunnels can be used to cover up your belts", - "create.ponder.brass_tunnel.text_2": "UNLOCALIZED: Brass Tunnels have filter slots on each open side", - "create.ponder.brass_tunnel.text_3": "UNLOCALIZED: Filters on inbound connections simply block non-matching items", - "create.ponder.brass_tunnel.text_4": "UNLOCALIZED: Filters on outbound connections can be used to sort items by type", - "create.ponder.brass_tunnel.text_5": "UNLOCALIZED: Whenever a passing item has multiple valid exits, the distribution mode will decide how to handle it", - "create.ponder.brass_tunnel.text_6": "UNLOCALIZED: Brass Tunnels on parallel belts will form a group", - "create.ponder.brass_tunnel.text_7": "UNLOCALIZED: Incoming Items will now be distributed across all connected exits", - "create.ponder.brass_tunnel.text_8": "UNLOCALIZED: For this, items can also be inserted into the Tunnel block directly", - - "create.ponder.brass_tunnel_modes.header": "UNLOCALIZED: Distribution Modes of the Brass Tunnel", - "create.ponder.brass_tunnel_modes.text_1": "UNLOCALIZED: Using a Wrench, the distribution behaviour of Brass Tunnels can be configured", - "create.ponder.brass_tunnel_modes.text_10": "UNLOCALIZED: 'Synchronize Inputs' is a unique setting for Brass Tunnels", - "create.ponder.brass_tunnel_modes.text_11": "UNLOCALIZED: Items are only allowed past if every tunnel in the group has one waiting", - "create.ponder.brass_tunnel_modes.text_12": "UNLOCALIZED: This ensures that all affected belts supply items at the same rate", - "create.ponder.brass_tunnel_modes.text_2": "UNLOCALIZED: 'Split' will attempt to distribute the stack evenly between available outputs", - "create.ponder.brass_tunnel_modes.text_3": "UNLOCALIZED: If an output is unable to take more items, it will be skipped", - "create.ponder.brass_tunnel_modes.text_4": "UNLOCALIZED: 'Forced Split' will never skip outputs, and instead wait until they are free", - "create.ponder.brass_tunnel_modes.text_5": "UNLOCALIZED: 'Round Robin' keeps stacks whole, and cycles through outputs iteratively", - "create.ponder.brass_tunnel_modes.text_6": "UNLOCALIZED: Once Again, if an output is unable to take more items, it will be skipped", - "create.ponder.brass_tunnel_modes.text_7": "UNLOCALIZED: 'Forced Round Robin' never skips outputs", - "create.ponder.brass_tunnel_modes.text_8": "UNLOCALIZED: 'Prefer Nearest' prioritizes the outputs closest to the items' input location", - "create.ponder.brass_tunnel_modes.text_9": "UNLOCALIZED: 'Randomize' will distribute whole stacks to randomly picked outputs", - - "create.ponder.cart_assembler.header": "UNLOCALIZED: Moving Structures using Cart Assemblers", - "create.ponder.cart_assembler.text_1": "UNLOCALIZED: Powered Cart Assemblers mount attached structures to passing Minecarts", - "create.ponder.cart_assembler.text_2": "UNLOCALIZED: Without a redstone signal, it disassembles passing cart contraptions back into blocks", - "create.ponder.cart_assembler.text_3": "UNLOCALIZED: Using a Wrench on the Minecart will let you carry the Contraption elsewhere", - - "create.ponder.cart_assembler_dual.header": "UNLOCALIZED: Assembling Carriage Contraptions", - "create.ponder.cart_assembler_dual.text_1": "UNLOCALIZED: Whenever two Cart Assembers share an attached structure...", - "create.ponder.cart_assembler_dual.text_2": "UNLOCALIZED: Powering either of them will create a Carriage Contraption", - "create.ponder.cart_assembler_dual.text_3": "UNLOCALIZED: The carts will behave like those connected via Minecart Coupling", - - "create.ponder.cart_assembler_modes.header": "UNLOCALIZED: Orientation Settings for Minecart Contraptions", - "create.ponder.cart_assembler_modes.text_1": "UNLOCALIZED: Cart Contraptions will rotate to face towards their carts' motion", - "create.ponder.cart_assembler_modes.text_2": "UNLOCALIZED: If the Assembler is set to Lock Rotation, the contraptions' orientation will never change", - - "create.ponder.cart_assembler_rails.header": "UNLOCALIZED: Other types of Minecarts and Rails", - "create.ponder.cart_assembler_rails.text_1": "UNLOCALIZED: Cart Assemblers on Regular Tracks will not affect the passing carts' motion", - "create.ponder.cart_assembler_rails.text_2": "UNLOCALIZED: When on Powered or Controller Rail, the carts will be held in place until it's Powered", - "create.ponder.cart_assembler_rails.text_3": "UNLOCALIZED: Other types of Minecarts can be used as the anchor", - "create.ponder.cart_assembler_rails.text_4": "UNLOCALIZED: Furnace Carts will keep themselves powered, pulling fuel from any attached inventories", - - "create.ponder.chain_drive.header": "UNLOCALIZED: Relaying rotational force with Chain Drives", - "create.ponder.chain_drive.text_1": "UNLOCALIZED: Chain Drives relay rotation to each other in a row", - "create.ponder.chain_drive.text_2": "UNLOCALIZED: All shafts connected like this will rotate in the same direction", - "create.ponder.chain_drive.text_3": "UNLOCALIZED: Any part of the row can be rotated by 90 degrees", - - "create.ponder.chain_gearshift.header": "UNLOCALIZED: Controlling rotational speed with Chain Gearshifts", - "create.ponder.chain_gearshift.text_1": "UNLOCALIZED: Unpowered Chain Gearshifts behave exacly like Chain Drives", - "create.ponder.chain_gearshift.text_2": "UNLOCALIZED: When Powered, the speed transmitted to other Chain Drives in the row is doubled", - "create.ponder.chain_gearshift.text_3": "UNLOCALIZED: Whenever the Powered Gearshift is not at the source, its speed will be halved instead", - "create.ponder.chain_gearshift.text_4": "UNLOCALIZED: In both cases, Chain Drives in the row always run at 2x the speed of the Powered Gearshift", - "create.ponder.chain_gearshift.text_5": "UNLOCALIZED: Using analog signals, the ratio can be adjusted more precisely between 1 and 2", - "create.ponder.chain_gearshift.text_6": "UNLOCALIZED: 12 RPM", - - "create.ponder.chute.header": "UNLOCALIZED: Transporting Items downward via Chutes", - "create.ponder.chute.text_1": "UNLOCALIZED: Chutes can transport items vertically from and to inventories", - "create.ponder.chute.text_2": "UNLOCALIZED: Using the Wrench, a window can be created", - "create.ponder.chute.text_3": "UNLOCALIZED: Placing chutes targeting the side faces of another will make it diagonal", - - "create.ponder.chute_upward.header": "UNLOCALIZED: Transporting Items upward via Chutes", - "create.ponder.chute_upward.text_1": "UNLOCALIZED: Using Encased Fans at the top or bottom, a Chute can move items upward", - "create.ponder.chute_upward.text_2": "UNLOCALIZED: Inspecting chutes with Engineers' Goggles reveals information about the movement direction", - "create.ponder.chute_upward.text_3": "UNLOCALIZED: On the 'blocked' end, items will have to be inserted/taken from the sides", - - "create.ponder.clockwork_bearing.header": "UNLOCALIZED: Animating Structures using Clockwork Bearings", - "create.ponder.clockwork_bearing.text_1": "UNLOCALIZED: Clockwork Bearings attach to blocks in front of them", - "create.ponder.clockwork_bearing.text_2": "UNLOCALIZED: Upon receiving Rotational Force, the structure will be rotated according to the hour of the day", - "create.ponder.clockwork_bearing.text_3": "UNLOCALIZED: 3:00", - "create.ponder.clockwork_bearing.text_4": "UNLOCALIZED: 4:00", - "create.ponder.clockwork_bearing.text_5": "UNLOCALIZED: Right-Click the bearing to start or stop animating the structure", - "create.ponder.clockwork_bearing.text_6": "UNLOCALIZED: In front of the Hour Hand, a second structure can be added", - "create.ponder.clockwork_bearing.text_7": "UNLOCALIZED: Ensure the two Structures are not attached to each other through super glue or similar", - "create.ponder.clockwork_bearing.text_8": "UNLOCALIZED: The Second Structure will now rotate as the Minute Hand", - - "create.ponder.clutch.header": "UNLOCALIZED: Controlling rotational force using a Clutch", - "create.ponder.clutch.text_1": "UNLOCALIZED: Clutches will relay rotation in a straight line", - "create.ponder.clutch.text_2": "UNLOCALIZED: When powered by Redstone, it breaks the connection", - - "create.ponder.cog_speedup.header": "UNLOCALIZED: Gearshifting with Cogs", - "create.ponder.cog_speedup.text_1": "UNLOCALIZED: Large and Small cogs can be connected diagonally", - "create.ponder.cog_speedup.text_2": "UNLOCALIZED: Shifting from large to small cogs, the conveyed speed will be doubled", - "create.ponder.cog_speedup.text_3": "UNLOCALIZED: Shifting the opposite way, the conveyed speed will be halved", - - "create.ponder.cogwheel.header": "UNLOCALIZED: Relaying rotational force using Cogwheels", - "create.ponder.cogwheel.text_1": "UNLOCALIZED: Cogwheels will relay rotation to other adjacent cogwheels", - "create.ponder.cogwheel.text_2": "UNLOCALIZED: Neighbouring shafts connected like this will rotate in opposite directions", - - "create.ponder.creative_motor.header": "UNLOCALIZED: Generating Rotational Force using Creative Motors", - "create.ponder.creative_motor.text_1": "UNLOCALIZED: Creative motors are a compact and configurable source of Rotational Force", - "create.ponder.creative_motor.text_2": "UNLOCALIZED: Scrolling on the back panel changes the RPM of the motors' rotational output", - - "create.ponder.crushing_wheels.header": "UNLOCALIZED: Processing Items with Crushing Wheels", - "create.ponder.crushing_wheels.text_1": "UNLOCALIZED: A pair of Crushing Wheels can grind items very effectively", - "create.ponder.crushing_wheels.text_2": "UNLOCALIZED: Their Rotational Input has to make them spin into each other", - "create.ponder.crushing_wheels.text_3": "UNLOCALIZED: Items thrown or inserted into the top will get processed", - "create.ponder.crushing_wheels.text_4": "UNLOCALIZED: Items can be inserted and picked up through automated means as well", - - "create.ponder.deployer.header": "UNLOCALIZED: Using the Deployer", - "create.ponder.deployer.text_1": "UNLOCALIZED: Given Rotational Force, a Deployer can imitate player interactions", - "create.ponder.deployer.text_10": "UNLOCALIZED: Right-click the front to give it an Item to use", - "create.ponder.deployer.text_11": "UNLOCALIZED: Items can also be inserted automatically", - "create.ponder.deployer.text_12": "UNLOCALIZED: Deployers carry a filter slot", - "create.ponder.deployer.text_13": "UNLOCALIZED: When a filter is set, it activates only while holding a matching item", - "create.ponder.deployer.text_14": "UNLOCALIZED: Only items matching the filter can now be inserted...", - "create.ponder.deployer.text_15": "UNLOCALIZED: ...and only non-matching items will be extracted", - "create.ponder.deployer.text_2": "UNLOCALIZED: It will always interact with the position 2 blocks in front of itself", - "create.ponder.deployer.text_3": "UNLOCALIZED: Blocks directly in front will not obstruct it", - "create.ponder.deployer.text_4": "UNLOCALIZED: Deployers can:", - "create.ponder.deployer.text_5": "UNLOCALIZED: Place Blocks,", - "create.ponder.deployer.text_6": "UNLOCALIZED: Use Items,", - "create.ponder.deployer.text_7": "UNLOCALIZED: Activate Blocks,", - "create.ponder.deployer.text_8": "UNLOCALIZED: Harvest blocks", - "create.ponder.deployer.text_9": "UNLOCALIZED: and Attack Mobs", - - "create.ponder.deployer_contraption.header": "UNLOCALIZED: Using Deployers on Contraptions", - "create.ponder.deployer_contraption.text_1": "UNLOCALIZED: Whenever Deployers are moved as part of an animated Contraption...", - "create.ponder.deployer_contraption.text_2": "UNLOCALIZED: They activate at each visited location, using items from inventories anywhere on the contraption", - "create.ponder.deployer_contraption.text_3": "UNLOCALIZED: The Filter slot can be used to specify which items to pull", - - "create.ponder.deployer_modes.header": "UNLOCALIZED: Modes of the Deployer", - "create.ponder.deployer_modes.text_1": "UNLOCALIZED: By default, a Deployer imitates a Right-click interaction", - "create.ponder.deployer_modes.text_2": "UNLOCALIZED: Using a Wrench, it can be set to imitate a Left-click instead", - - "create.ponder.deployer_redstone.header": "UNLOCALIZED: Controlling Deployers with Redstone", - "create.ponder.deployer_redstone.text_1": "UNLOCALIZED: When powered by Redstone, Deployers will not activate", - "create.ponder.deployer_redstone.text_2": "UNLOCALIZED: Before stopping, the Deployer will finish any started cycles", - "create.ponder.deployer_redstone.text_3": "UNLOCALIZED: Thus, a negative pulse can be used to trigger exactly one activation cycle", - - "create.ponder.depot.header": "UNLOCALIZED: Using Depots", - "create.ponder.depot.text_1": "UNLOCALIZED: Depots can serve as 'stationary' belt elements", - "create.ponder.depot.text_2": "UNLOCALIZED: Right-Click to manually place or remove Items from it", - "create.ponder.depot.text_3": "UNLOCALIZED: Just like Mechanical Belts, it can provide items to processing", - "create.ponder.depot.text_4": "UNLOCALIZED: ...as well as provide Items to Mechanical Arms", - - "create.ponder.empty_blaze_burner.header": "UNLOCALIZED: Using Empty Blaze Burners", - "create.ponder.empty_blaze_burner.text_1": "UNLOCALIZED: Right-click a Blaze with the empty burner to capture it", - "create.ponder.empty_blaze_burner.text_2": "UNLOCALIZED: Alternatively, Blazes can be collected from their Spawners directly", - "create.ponder.empty_blaze_burner.text_3": "UNLOCALIZED: You now have an ideal heat source for various machines", - "create.ponder.empty_blaze_burner.text_4": "UNLOCALIZED: For Aesthetic purposes, Empty Blaze Burners can also be lit using Flint and Steel", - "create.ponder.empty_blaze_burner.text_5": "UNLOCALIZED: However, these are not suitable for industrial heating", - - "create.ponder.fan_direction.header": "UNLOCALIZED: Air flow of Encased Fans", - "create.ponder.fan_direction.text_1": "UNLOCALIZED: Encased Fans use Rotational Force to create an Air Current", - "create.ponder.fan_direction.text_2": "UNLOCALIZED: Strength and Direction of Flow depends on the Rotational Input", - - "create.ponder.fan_processing.header": "UNLOCALIZED: Processing Items using Encased Fans", - "create.ponder.fan_processing.text_1": "UNLOCALIZED: When passing through lava, the Air Flow becomes Heated", - "create.ponder.fan_processing.text_2": "UNLOCALIZED: Items caught in the area will be smelted", - "create.ponder.fan_processing.text_3": "UNLOCALIZED: Food items thrown here would be incinerated", - "create.ponder.fan_processing.text_4": "UNLOCALIZED: Instead, a setup for Smoking using Fire should be used for them", - "create.ponder.fan_processing.text_5": "UNLOCALIZED: Air Flows passing through water create a Washing Setup", - "create.ponder.fan_processing.text_6": "UNLOCALIZED: Some interesting new processing can be done with it", - "create.ponder.fan_processing.text_7": "UNLOCALIZED: The Speed of the Fan does NOT affect the processing speed, only its range", - "create.ponder.fan_processing.text_8": "UNLOCALIZED: Fan Processing can also be applied to Items on Depots and Belts", - - "create.ponder.fan_source.header": "UNLOCALIZED: Generating Rotational Force using Encased Fans", - "create.ponder.fan_source.text_1": "UNLOCALIZED: Fans facing down into a source of heat can provide Rotational Force", - "create.ponder.fan_source.text_2": "UNLOCALIZED: When given a Redstone Signal, the Fans will start providing power", - - "create.ponder.flywheel.header": "UNLOCALIZED: Generating Rotational Force using the Flywheel", - "create.ponder.flywheel.text_1": "UNLOCALIZED: Flywheels are required for generating rotational force with the Furnace Engine", - "create.ponder.flywheel.text_2": "UNLOCALIZED: The provided Rotational Force has a very large stress capacity", - "create.ponder.flywheel.text_3": "UNLOCALIZED: Using a Blast Furnace will double the efficiency of the Engine", - - "create.ponder.funnel_compat.header": "UNLOCALIZED: Funnel compatibility", - "create.ponder.funnel_compat.text_1": "UNLOCALIZED: Funnels should also interact nicely with a handful of other components.", - "create.ponder.funnel_compat.text_2": "UNLOCALIZED: Vertical Saws", - "create.ponder.funnel_compat.text_3": "UNLOCALIZED: Depots", - "create.ponder.funnel_compat.text_4": "UNLOCALIZED: Item Drains", - - "create.ponder.funnel_direction.header": "UNLOCALIZED: Direction of Transfer", - "create.ponder.funnel_direction.text_1": "UNLOCALIZED: Placed normally, it pulls items from the inventory.", - "create.ponder.funnel_direction.text_2": "UNLOCALIZED: Placed while sneaking, it puts items into the inventory.", - "create.ponder.funnel_direction.text_3": "UNLOCALIZED: Using a wrench, the funnel can be flipped after placement.", - "create.ponder.funnel_direction.text_4": "UNLOCALIZED: Same rules will apply for most orientations.", - "create.ponder.funnel_direction.text_5": "UNLOCALIZED: Funnels on belts will extract/insert depending on its movement direction.", - - "create.ponder.funnel_intro.header": "UNLOCALIZED: Using funnels", - "create.ponder.funnel_intro.text_1": "UNLOCALIZED: Funnels are ideal for transferring items from and to inventories.", - - "create.ponder.funnel_redstone.header": "UNLOCALIZED: Redstone control", - "create.ponder.funnel_redstone.text_1": "UNLOCALIZED: Redstone power will prevent any funnel from acting", - - "create.ponder.funnel_transfer.header": "UNLOCALIZED: Direct transfer", - "create.ponder.funnel_transfer.text_1": "UNLOCALIZED: Funnels cannot ever transfer between closed inventories directly.", - "create.ponder.funnel_transfer.text_2": "UNLOCALIZED: Chutes or Smart chutes might be more suitable for such purposes.", - "create.ponder.funnel_transfer.text_3": "UNLOCALIZED: Same applies for horizontal movement. A mechanical belt should help here.", - - "create.ponder.furnace_engine.header": "UNLOCALIZED: Generating Rotational Force using the Furnace Engine", - "create.ponder.furnace_engine.text_1": "UNLOCALIZED: Furnace Engines generate Rotational Force while their attached Furnace is running", - "create.ponder.furnace_engine.text_2": "UNLOCALIZED: The provided Rotational Force has a very large stress capacity", - "create.ponder.furnace_engine.text_3": "UNLOCALIZED: Using a Blast Furnace will double the efficiency of the Engine", - - "create.ponder.gantry_carriage.header": "UNLOCALIZED: Using Gantry Carriages", - "create.ponder.gantry_carriage.text_1": "UNLOCALIZED: Gantry Carriages can mount to and slide along a Gantry Shaft.", - "create.ponder.gantry_carriage.text_2": "UNLOCALIZED: Gantry setups can move attached Blocks.", - - "create.ponder.gantry_cascaded.header": "UNLOCALIZED: Cascaded Gantries", - "create.ponder.gantry_cascaded.text_1": "UNLOCALIZED: Gantry shafts attach to a carriage without the need of super glue", - "create.ponder.gantry_cascaded.text_2": "UNLOCALIZED: Same applies for carriages on moved Gantry Shafts", - "create.ponder.gantry_cascaded.text_3": "UNLOCALIZED: Thus, a gantry system can be cascaded to cover multiple axes of movement", - - "create.ponder.gantry_direction.header": "UNLOCALIZED: Gantry Movement Direction", - "create.ponder.gantry_direction.text_1": "UNLOCALIZED: Gantry Shafts can have opposite orientations", - "create.ponder.gantry_direction.text_2": "UNLOCALIZED: The movement direction of carriages depend on their shafts' orientation", - "create.ponder.gantry_direction.text_3": "UNLOCALIZED: ...as well as the rotation direction of the shaft", - "create.ponder.gantry_direction.text_4": "UNLOCALIZED: Same rules apply for the propagated rotation", - - "create.ponder.gantry_redstone.header": "UNLOCALIZED: Gantry Power Propagation", - "create.ponder.gantry_redstone.text_1": "UNLOCALIZED: Redstone-powered gantry shafts stop moving their carriages", - "create.ponder.gantry_redstone.text_2": "UNLOCALIZED: Instead, its rotational force is relayed to the carriages' output shaft", - - "create.ponder.gantry_shaft.header": "UNLOCALIZED: Using Gantry Shafts", - "create.ponder.gantry_shaft.text_1": "UNLOCALIZED: Gantry Shafts form the basis of a gantry setup. Attached Carriages will move along them.", - "create.ponder.gantry_shaft.text_2": "UNLOCALIZED: Gantry setups can move attached Blocks.", - - "create.ponder.gearbox.header": "UNLOCALIZED: Relaying rotational force using Gearboxes", - "create.ponder.gearbox.text_1": "UNLOCALIZED: Jumping between axes of rotation can get bulky quickly", - "create.ponder.gearbox.text_2": "UNLOCALIZED: A gearbox is the more compact equivalent of this setup", - "create.ponder.gearbox.text_3": "UNLOCALIZED: Shafts around corners rotate in mirrored directions", - "create.ponder.gearbox.text_4": "UNLOCALIZED: Straight connections will be reversed", - - "create.ponder.gearshift.header": "UNLOCALIZED: Controlling rotational force using a Gearshift", - "create.ponder.gearshift.text_1": "UNLOCALIZED: Gearshifts will relay rotation in a straight line", - "create.ponder.gearshift.text_2": "UNLOCALIZED: When powered by Redstone, it reverses the transmission", - - "create.ponder.hand_crank.header": "UNLOCALIZED: Generating Rotational Force using Hand Cranks", - "create.ponder.hand_crank.text_1": "UNLOCALIZED: Hand Cranks can be used by players to apply rotational force manually", - "create.ponder.hand_crank.text_2": "UNLOCALIZED: Hold Right-Click to rotate it Counter-Clockwise", - "create.ponder.hand_crank.text_3": "UNLOCALIZED: Its conveyed speed is relatively high", - "create.ponder.hand_crank.text_4": "UNLOCALIZED: Sneak and Hold Right-Click to rotate it Clockwise", - - "create.ponder.large_cogwheel.header": "UNLOCALIZED: Relaying rotational force using Large Cogwheels", - "create.ponder.large_cogwheel.text_1": "UNLOCALIZED: Large cogwheels can connect to each other at right angles", - "create.ponder.large_cogwheel.text_2": "UNLOCALIZED: It will help relaying conveyed speed to other axes of rotation", - - "create.ponder.linear_chassis_attachment.header": "UNLOCALIZED: Attaching blocks using Linear Chassis", - "create.ponder.linear_chassis_attachment.text_1": "UNLOCALIZED: The open faces of a Linear Chassis can be made Sticky", - "create.ponder.linear_chassis_attachment.text_2": "UNLOCALIZED: Click again to make the opposite side sticky", - "create.ponder.linear_chassis_attachment.text_3": "UNLOCALIZED: Sneak and Right-Click with an empty hand to remove the slime", - "create.ponder.linear_chassis_attachment.text_4": "UNLOCALIZED: Stickied faces of the Linear Chassis will attach a line of blocks in front of it", - "create.ponder.linear_chassis_attachment.text_5": "UNLOCALIZED: Using a Wrench, a precise Range can be specified for this chassis", - "create.ponder.linear_chassis_attachment.text_6": "UNLOCALIZED: Holding CTRL and scrolling adjusts the range of all attached Chassis Blocks", - "create.ponder.linear_chassis_attachment.text_7": "UNLOCALIZED: Attaching blocks to any other side requires the use of Super Glue", - "create.ponder.linear_chassis_attachment.text_8": "UNLOCALIZED: Using these mechanics, structures of any shape can move as a Contraption", - - "create.ponder.linear_chassis_group.header": "UNLOCALIZED: Moving Linear Chassis in groups", - "create.ponder.linear_chassis_group.text_1": "UNLOCALIZED: Linear Chassis connect to identical Chassis blocks next to them", - "create.ponder.linear_chassis_group.text_2": "UNLOCALIZED: When one is moved by a Contraption, the others are dragged with it", - "create.ponder.linear_chassis_group.text_3": "UNLOCALIZED: Chassis of a different type or facing another direction will not attach", - - "create.ponder.mechanical_arm.header": "UNLOCALIZED: Setting up Mechanical Arms", - "create.ponder.mechanical_arm.text_1": "UNLOCALIZED: Mechanical Arms have to be assigned their in- and outputs before they are placed", - "create.ponder.mechanical_arm.text_2": "UNLOCALIZED: Right-Click inventories while holding the Arm to assign them as Targets", - "create.ponder.mechanical_arm.text_3": "UNLOCALIZED: Right-Click again to toggle between Input (Blue) and Output (Orange)", - "create.ponder.mechanical_arm.text_4": "UNLOCALIZED: Left-Click components to remove their Selection", - "create.ponder.mechanical_arm.text_5": "UNLOCALIZED: Once placed, the Mechanical Arm will target the blocks selected previously", - "create.ponder.mechanical_arm.text_6": "UNLOCALIZED: They can have any amount of in- and outputs within their range", - "create.ponder.mechanical_arm.text_7": "UNLOCALIZED: However, not every type of Inventory can be interacted with directly", - "create.ponder.mechanical_arm.text_8": "UNLOCALIZED: Funnels and Depots can help to Bridge that gap", - - "create.ponder.mechanical_arm_filtering.header": "UNLOCALIZED: Filtering Outputs of the Mechanical Arm", - "create.ponder.mechanical_arm_filtering.text_1": "UNLOCALIZED: Inputs", - "create.ponder.mechanical_arm_filtering.text_2": "UNLOCALIZED: Outputs", - "create.ponder.mechanical_arm_filtering.text_3": "UNLOCALIZED: Sometimes it is desirable to restrict targets of the Arm by matching a filter", - "create.ponder.mechanical_arm_filtering.text_4": "UNLOCALIZED: Mechanical Arms by themselves do not provide any options for filtering", - "create.ponder.mechanical_arm_filtering.text_5": "UNLOCALIZED: Brass Funnels as Targets do however communicate their own filter to the Arm", - "create.ponder.mechanical_arm_filtering.text_6": "UNLOCALIZED: The Arm is smart enough not to pick up items it couldn't distribute", - - "create.ponder.mechanical_arm_modes.header": "UNLOCALIZED: Distribution modes of the Mechanical Arm", - "create.ponder.mechanical_arm_modes.text_1": "UNLOCALIZED: Input", - "create.ponder.mechanical_arm_modes.text_2": "UNLOCALIZED: Outputs", - "create.ponder.mechanical_arm_modes.text_3": "UNLOCALIZED: Whenever an Arm has to choose between multiple valid outputs...", - "create.ponder.mechanical_arm_modes.text_4": "UNLOCALIZED: ...it will act according to its setting", - "create.ponder.mechanical_arm_modes.text_5": "UNLOCALIZED: Scrolling with a Wrench will allow you to configure it", - "create.ponder.mechanical_arm_modes.text_6": "UNLOCALIZED: Round Robin mode simply cycles through all outputs that are available", - "create.ponder.mechanical_arm_modes.text_7": "UNLOCALIZED: If an output is unable to take more items, it will be skipped", - "create.ponder.mechanical_arm_modes.text_8": "UNLOCALIZED: Forced Round Robin mode will never skip outputs, and instead wait until they are free", - "create.ponder.mechanical_arm_modes.text_9": "UNLOCALIZED: Prefer First prioritizes the outputs selected earliest when configuring this Arm", - - "create.ponder.mechanical_arm_redstone.header": "UNLOCALIZED: Controlling Mechanical Arms with Redstone", - "create.ponder.mechanical_arm_redstone.text_1": "UNLOCALIZED: When powered by Redstone, Mechanical Arms will not activate", - "create.ponder.mechanical_arm_redstone.text_2": "UNLOCALIZED: Before stopping, it will finish any started cycles", - "create.ponder.mechanical_arm_redstone.text_3": "UNLOCALIZED: Thus, a negative pulse can be used to trigger exactly one activation cycle", - - "create.ponder.mechanical_bearing.header": "UNLOCALIZED: Movings Structures using the Mechanical Bearing", - "create.ponder.mechanical_bearing.text_1": "UNLOCALIZED: Mechanical Bearings attach to the block in front of them", - "create.ponder.mechanical_bearing.text_2": "UNLOCALIZED: Upon receiving Rotational Force, it will assemble it into a Rotating Contraption", - - "create.ponder.mechanical_crafter.header": "UNLOCALIZED: Setting up Mechanical Crafters", - "create.ponder.mechanical_crafter.text_1": "UNLOCALIZED: An array of Mechanical Crafters can be used to automate any Crafting Recipe", - "create.ponder.mechanical_crafter.text_2": "UNLOCALIZED: Using a Wrench, the Crafters' paths can be arranged", - "create.ponder.mechanical_crafter.text_3": "UNLOCALIZED: For a valid setup, all paths have to converge into one exit at any side", - "create.ponder.mechanical_crafter.text_4": "UNLOCALIZED: The outputs will be placed into the inventory at the exit", - "create.ponder.mechanical_crafter.text_5": "UNLOCALIZED: Mechanical Crafters require Rotational Force to operate", - "create.ponder.mechanical_crafter.text_6": "UNLOCALIZED: Right-Click the front to insert Items manually", - "create.ponder.mechanical_crafter.text_7": "UNLOCALIZED: Once every slot of a path contains an Item, the crafting process will begin", - "create.ponder.mechanical_crafter.text_8": "UNLOCALIZED: For recipes not fully occupying the crafter setup, the start can be forced using a Redstone Pulse", - - "create.ponder.mechanical_crafter_connect.header": "UNLOCALIZED: Connecting Inventories of Crafters", - "create.ponder.mechanical_crafter_connect.text_1": "UNLOCALIZED: Items can be inserted to Crafters automatically", - "create.ponder.mechanical_crafter_connect.text_2": "UNLOCALIZED: Using the Wrench at their backs, Mechanical Crafter inputs can be combined", - "create.ponder.mechanical_crafter_connect.text_3": "UNLOCALIZED: All connected Crafters can now be accessed by the same input location", - - "create.ponder.mechanical_crafter_covers.header": "UNLOCALIZED: Covering slots of Mechanical Crafters", - "create.ponder.mechanical_crafter_covers.text_1": "UNLOCALIZED: Some recipes will require additional Crafters to bridge gaps in the path", - "create.ponder.mechanical_crafter_covers.text_2": "UNLOCALIZED: Using Slot Covers, Crafters can be set to act as an Empty Slot in the arrangement", - "create.ponder.mechanical_crafter_covers.text_3": "UNLOCALIZED: Shared Inputs created with the Wrench at the back can also reach across covered Crafters", - - "create.ponder.mechanical_drill.header": "UNLOCALIZED: Breaking Blocks with the Mechanical Drill", - "create.ponder.mechanical_drill.text_1": "UNLOCALIZED: When given Rotational Force, a Mechanical Drill will break blocks directly in front of it", - "create.ponder.mechanical_drill.text_2": "UNLOCALIZED: Its mining speed depends on the Rotational Input", - - "create.ponder.mechanical_drill_contraption.header": "UNLOCALIZED: Using Mechanical Drills on Contraptions", - "create.ponder.mechanical_drill_contraption.text_1": "UNLOCALIZED: Whenever Drills are moved as part of an animated Contraption...", - "create.ponder.mechanical_drill_contraption.text_2": "UNLOCALIZED: ...they will break blocks the contraption runs them into", - - "create.ponder.mechanical_harvester.header": "UNLOCALIZED: Using Mechanical Harvesters on Contraptions", - "create.ponder.mechanical_harvester.text_1": "UNLOCALIZED: Whenever Harvesters are moved as part of an animated Contraption...", - "create.ponder.mechanical_harvester.text_2": "UNLOCALIZED: They will harvest and reset any mature crops on their way", - - "create.ponder.mechanical_mixer.header": "UNLOCALIZED: Processing Items with the Mechanical Mixer", - "create.ponder.mechanical_mixer.text_1": "UNLOCALIZED: With a Mixer and Basin, some Crafting Recipes can be automated", - "create.ponder.mechanical_mixer.text_2": "UNLOCALIZED: Available recipes include any Shapeless Crafting Recipe, plus a couple extra ones", - "create.ponder.mechanical_mixer.text_3": "UNLOCALIZED: Some of those recipes may require the heat of a Blaze Burner", - "create.ponder.mechanical_mixer.text_4": "UNLOCALIZED: The filter slot can be used in case two recipes are conflicting.", - - "create.ponder.mechanical_piston.header": "UNLOCALIZED: Moving Structures using Mechanical Pistons", - "create.ponder.mechanical_piston.text_1": "UNLOCALIZED: Mechanical Pistons can move blocks in front of them", - "create.ponder.mechanical_piston.text_2": "UNLOCALIZED: Speed and direction of movement depend on the Rotational Input", - "create.ponder.mechanical_piston.text_3": "UNLOCALIZED: Sticky Mechanical Pistons can pull the attached blocks back", - - "create.ponder.mechanical_piston_modes.header": "UNLOCALIZED: Movement Modes of the Mechanical Piston", - "create.ponder.mechanical_piston_modes.text_1": "UNLOCALIZED: Whenever Pistons stop moving, the moved structure reverts to blocks", - "create.ponder.mechanical_piston_modes.text_2": "UNLOCALIZED: It can be configured never to revert to solid blocks, or only at the location it started at", - - "create.ponder.mechanical_plough.header": "UNLOCALIZED: Using Mechanical Ploughs on Contraptions", - "create.ponder.mechanical_plough.text_1": "UNLOCALIZED: Whenever Ploughs are moved as part of an animated Contraption...", - "create.ponder.mechanical_plough.text_2": "UNLOCALIZED: ...they will break blocks without a solid collision hitbox", - "create.ponder.mechanical_plough.text_3": "UNLOCALIZED: Additionally, ploughs can create farmland", - "create.ponder.mechanical_plough.text_4": "UNLOCALIZED: ...they can also launch entities without hurting them", - - "create.ponder.mechanical_press.header": "UNLOCALIZED: Processing Items with the Mechanical Press", - "create.ponder.mechanical_press.text_1": "UNLOCALIZED: The Mechanical Press can process items provided beneath it", - "create.ponder.mechanical_press.text_2": "UNLOCALIZED: The Input items can be dropped or placed on a Depot under the Press", - "create.ponder.mechanical_press.text_3": "UNLOCALIZED: When items are provided on a belt...", - "create.ponder.mechanical_press.text_4": "UNLOCALIZED: The Press will hold and process them automatically", - - "create.ponder.mechanical_press_compacting.header": "UNLOCALIZED: Compacting items with the Mechanical Press", - "create.ponder.mechanical_press_compacting.text_1": "UNLOCALIZED: Pressing items held in a Basin will cause them to be Compacted", - "create.ponder.mechanical_press_compacting.text_2": "UNLOCALIZED: Compacting includes any filled 2x2 or 3x3 Crafting Recipe, plus a couple extra ones", - "create.ponder.mechanical_press_compacting.text_3": "UNLOCALIZED: Some of those recipes may require the heat of a Blaze Burner", - "create.ponder.mechanical_press_compacting.text_4": "UNLOCALIZED: The filter slot can be used in case two recipes are conflicting.", - - "create.ponder.mechanical_saw_breaker.header": "UNLOCALIZED: Cutting Trees with the Mechanical Saw", - "create.ponder.mechanical_saw_breaker.text_1": "UNLOCALIZED: When given Rotational Force, a Mechanical Saw will cut trees directly in front of it", - "create.ponder.mechanical_saw_breaker.text_2": "UNLOCALIZED: In order to cut the tree fully, the Saw has to break the last block connecting it to the ground", - - "create.ponder.mechanical_saw_contraption.header": "UNLOCALIZED: Using Mechanical Saws on Contraptions", - "create.ponder.mechanical_saw_contraption.text_1": "UNLOCALIZED: Whenever Saws are moved as part of an animated Contraption...", - "create.ponder.mechanical_saw_contraption.text_2": "UNLOCALIZED: ...they will cut any trees the contraption runs them into", - - "create.ponder.mechanical_saw_processing.header": "UNLOCALIZED: Processing Items on the Mechanical Saw", - "create.ponder.mechanical_saw_processing.text_1": "UNLOCALIZED: Upward facing Mechanical Saws can process a variety of items", - "create.ponder.mechanical_saw_processing.text_2": "UNLOCALIZED: The processed item always moves against the rotational input to the saw", - "create.ponder.mechanical_saw_processing.text_3": "UNLOCALIZED: Saws can work in-line with Mechanical Belts", - "create.ponder.mechanical_saw_processing.text_4": "UNLOCALIZED: When an ingredient has multiple possible outcomes, the filter slot can specify it", - "create.ponder.mechanical_saw_processing.text_5": "UNLOCALIZED: Without filter, the Saw would cycle through all outcomes instead", - - "create.ponder.millstone.header": "UNLOCALIZED: Processing Items in the Millstone", - "create.ponder.millstone.text_1": "UNLOCALIZED: Millstones process items by grinding them", - "create.ponder.millstone.text_2": "UNLOCALIZED: They can be powered from the side using cogwheels", - "create.ponder.millstone.text_3": "UNLOCALIZED: Throw or Insert items at the top", - "create.ponder.millstone.text_4": "UNLOCALIZED: After some time, the result can be obtained via Right-click", - "create.ponder.millstone.text_5": "UNLOCALIZED: The outputs can also be extracted by automation", - - "create.ponder.nixie_tube.header": "UNLOCALIZED: Using Nixie Tubes", - "create.ponder.nixie_tube.text_1": "UNLOCALIZED: When powered by Redstone, Nixie Tubes will display the redstone signals' strength", - "create.ponder.nixie_tube.text_2": "UNLOCALIZED: Using name tags edited with an anvil, custom text can be displayed", - - "create.ponder.piston_pole.header": "UNLOCALIZED: Piston Extension Poles", - "create.ponder.piston_pole.text_1": "UNLOCALIZED: Without attached Poles, a Mechanical Piston cannot move", - "create.ponder.piston_pole.text_2": "UNLOCALIZED: The Length of pole added at its back determines the Extension Range", - - "create.ponder.portable_storage_interface.header": "UNLOCALIZED: Contraption Storage Exchange", - "create.ponder.portable_storage_interface.text_1": "UNLOCALIZED: Inventories on moving contraptions cannot be accessed by players.", - "create.ponder.portable_storage_interface.text_2": "UNLOCALIZED: This component can interact with storage without the need to stop the contraption.", - "create.ponder.portable_storage_interface.text_3": "UNLOCALIZED: Place a second one with a gap of 1 or 2 blocks inbetween", - "create.ponder.portable_storage_interface.text_4": "UNLOCALIZED: Whenever they pass by each other, they will engage in a connection", - "create.ponder.portable_storage_interface.text_5": "UNLOCALIZED: While engaged, the stationary interface will represent ALL inventories on the contraption", - "create.ponder.portable_storage_interface.text_6": "UNLOCALIZED: Items can now be inserted...", - "create.ponder.portable_storage_interface.text_7": "UNLOCALIZED: ...or extracted from the contraption", - "create.ponder.portable_storage_interface.text_8": "UNLOCALIZED: After no items have been exchanged for a while, the contraption will continue on its way", - - "create.ponder.portable_storage_interface_redstone.header": "UNLOCALIZED: Redstone Control", - "create.ponder.portable_storage_interface_redstone.text_1": "UNLOCALIZED: Redstone power will prevent the stationary interface from engaging", - - "create.ponder.powered_latch.header": "UNLOCALIZED: Controlling signals using the Powered Latch", - "create.ponder.powered_latch.text_1": "UNLOCALIZED: Powered Latches are redstone controllable Levers", - "create.ponder.powered_latch.text_2": "UNLOCALIZED: Signals at the back switch it on", - "create.ponder.powered_latch.text_3": "UNLOCALIZED: Signals from the side switch it back off", - "create.ponder.powered_latch.text_4": "UNLOCALIZED: Powered latches can also be toggled manually", - - "create.ponder.powered_toggle_latch.header": "UNLOCALIZED: Controlling signals using the Powered Toggle Latch", - "create.ponder.powered_toggle_latch.text_1": "UNLOCALIZED: Powered Toggle Latches are redstone controllable Levers", - "create.ponder.powered_toggle_latch.text_2": "UNLOCALIZED: Signals at the back will toggle its state", - "create.ponder.powered_toggle_latch.text_3": "UNLOCALIZED: ...on and back off", - "create.ponder.powered_toggle_latch.text_4": "UNLOCALIZED: Powered toggle latches can also be toggled manually", - - "create.ponder.pulse_repeater.header": "UNLOCALIZED: Controlling signals using Pulse Repeaters", - "create.ponder.pulse_repeater.text_1": "UNLOCALIZED: Pulse Repeaters will shorten any redstone signal to a single pulse", - - "create.ponder.radial_chassis.header": "UNLOCALIZED: Attaching blocks using Radial Chassis", - "create.ponder.radial_chassis.text_1": "UNLOCALIZED: Radial Chassis connect to identical Chassis blocks in a row", - "create.ponder.radial_chassis.text_2": "UNLOCALIZED: When one is moved by a Contraption, the others are dragged with it", - "create.ponder.radial_chassis.text_3": "UNLOCALIZED: The side faces of a Radial Chassis can be made Sticky", - "create.ponder.radial_chassis.text_4": "UNLOCALIZED: Click again to make all other sides sticky", - "create.ponder.radial_chassis.text_5": "UNLOCALIZED: Sneak and Right-Click with an empty hand to remove the slime", - "create.ponder.radial_chassis.text_6": "UNLOCALIZED: Whenever a Block is next to a sticky face...", - "create.ponder.radial_chassis.text_7": "UNLOCALIZED: ...it will attach all reachable blocks within a radius on that layer", - "create.ponder.radial_chassis.text_8": "UNLOCALIZED: Using a Wrench, a precise Radius can be specified for this chassis", - "create.ponder.radial_chassis.text_9": "UNLOCALIZED: Blocks not reachable by any sticky face will not attach", - - "create.ponder.redstone_contact.header": "UNLOCALIZED: Redstone Contacts", - "create.ponder.redstone_contact.text_1": "UNLOCALIZED: Redstone Contacts facing each other will emit a redstone signal", - "create.ponder.redstone_contact.text_2": "UNLOCALIZED: This still applies when one of them is part of a moving Contraption", - - "create.ponder.redstone_link.header": "UNLOCALIZED: Using Redstone Links", - "create.ponder.redstone_link.text_1": "UNLOCALIZED: Redstone Links can transmit redstone signals wirelessly", - "create.ponder.redstone_link.text_2": "UNLOCALIZED: Right-click while Sneaking to toggle receive mode", - "create.ponder.redstone_link.text_3": "UNLOCALIZED: A simple Right-click with a Wrench can do the same", - "create.ponder.redstone_link.text_4": "UNLOCALIZED: Receivers emit the redstone power of transmitters within 128 blocks", - "create.ponder.redstone_link.text_5": "UNLOCALIZED: Placing items in the two slots can specify a Frequency", - "create.ponder.redstone_link.text_6": "UNLOCALIZED: Only the links with matching Frequencies will communicate", - - "create.ponder.rope_pulley.header": "UNLOCALIZED: Moving Structures using Rope Pulleys", - "create.ponder.rope_pulley.text_1": "UNLOCALIZED: Rope Pulleys can move blocks vertically when given Rotational Force", - "create.ponder.rope_pulley.text_2": "UNLOCALIZED: Direction and Speed of movement depend on the Rotational Input", - - "create.ponder.rope_pulley_attachment.header": "UNLOCALIZED: Moving Pulleys as part of a Contraption", - "create.ponder.rope_pulley_attachment.text_1": "UNLOCALIZED: Whenever Pulleys are themselves being moved by a Contraption...", - "create.ponder.rope_pulley_attachment.text_2": "UNLOCALIZED: ...its attached structure will be dragged with it", - "create.ponder.rope_pulley_attachment.text_3": "UNLOCALIZED: Mind that pulleys are only movable while stopped", - - "create.ponder.rope_pulley_modes.header": "UNLOCALIZED: Movement Modes of the Rope Pulley", - "create.ponder.rope_pulley_modes.text_1": "UNLOCALIZED: Whenever Pulleys stop moving, the moved structure reverts to blocks", - "create.ponder.rope_pulley_modes.text_2": "UNLOCALIZED: It can be configured never to revert to solid blocks, or only at the location it started at", - - "create.ponder.rotation_speed_controller.header": "UNLOCALIZED: Using the Rotational Speed Controller", - "create.ponder.rotation_speed_controller.text_1": "UNLOCALIZED: Rot. Speed Controllers relay rotation from their axis to a Large Cogwheel above them", - "create.ponder.rotation_speed_controller.text_2": "UNLOCALIZED: Using the scroll input on its side, the conveyed speed can be configured", - - "create.ponder.sail.header": "UNLOCALIZED: Assembling Windmills using Sails", - "create.ponder.sail.text_1": "UNLOCALIZED: Sails are handy blocks to create Windmills with", - "create.ponder.sail.text_2": "UNLOCALIZED: They will attach to blocks and each other without the need of Super Glue or Chassis Blocks", - "create.ponder.sail.text_3": "UNLOCALIZED: Right-Click with Dye to paint them", - "create.ponder.sail.text_4": "UNLOCALIZED: Right-Click with Shears to turn them back into frames", - - "create.ponder.sail_frame.header": "UNLOCALIZED: Assembling Windmills using Sail Frames", - "create.ponder.sail_frame.text_1": "UNLOCALIZED: Sail Frames are handy blocks to create Windmills with", - "create.ponder.sail_frame.text_2": "UNLOCALIZED: They will attach to blocks and each other without the need of Super Glue or Chassis Blocks", - - "create.ponder.sequenced_gearshift.header": "UNLOCALIZED: Controlling Rotational Speed using Sequenced Gearshifts", - "create.ponder.sequenced_gearshift.text_1": "UNLOCALIZED: Seq. Gearshifts relay rotation by following a timed list of instructions", - "create.ponder.sequenced_gearshift.text_2": "UNLOCALIZED: Right-click it to open the Configuration UI", - "create.ponder.sequenced_gearshift.text_3": "UNLOCALIZED: Upon receiving a Redstone Signal, it will start running its configured sequence", - "create.ponder.sequenced_gearshift.text_4": "UNLOCALIZED: Once finished, it waits for the next Redstone Signal and starts over", - "create.ponder.sequenced_gearshift.text_5": "UNLOCALIZED: A redstone comparator can be used to read the current progress", - - "create.ponder.shaft.header": "UNLOCALIZED: Relaying rotational force using Shafts", - "create.ponder.shaft.text_1": "UNLOCALIZED: Shafts will relay rotation in a straight line.", - - "create.ponder.shaft_casing.header": "UNLOCALIZED: Encasing Shafts", - "create.ponder.shaft_casing.text_1": "UNLOCALIZED: Brass or Andesite Casing can be used to decorate Shafts", - - "create.ponder.smart_chute.header": "UNLOCALIZED: Filtering Items using Smart Chutes", - "create.ponder.smart_chute.text_1": "UNLOCALIZED: Smart Chutes are vertical chutes with additional control", - "create.ponder.smart_chute.text_2": "UNLOCALIZED: Items in the filter slot specify what exactly they can extract and transfer", - "create.ponder.smart_chute.text_3": "UNLOCALIZED: Use the Mouse Wheel to specify the extracted stack size", - "create.ponder.smart_chute.text_4": "UNLOCALIZED: Redstone power will prevent Smart Chutes from acting.", - - "create.ponder.speedometer.header": "UNLOCALIZED: Monitoring Kinetic information using the Speedometer", - "create.ponder.speedometer.text_1": "UNLOCALIZED: The Speedometer displays the current Speed of the attached components", - "create.ponder.speedometer.text_2": "UNLOCALIZED: When wearing Engineers' Goggles, the player can get more detailed information from the Gauge", - "create.ponder.speedometer.text_3": "UNLOCALIZED: Comparators can emit analog Restone Signals relative to the Speedometer's measurements", - - "create.ponder.stabilized_bearings.header": "UNLOCALIZED: Stabilized Contraptions", - "create.ponder.stabilized_bearings.text_1": "UNLOCALIZED: Whenever Mechanical Bearings are themselves part of a moving Structure..", - "create.ponder.stabilized_bearings.text_2": "UNLOCALIZED: ..they will attempt to keep themselves upright", - "create.ponder.stabilized_bearings.text_3": "UNLOCALIZED: Once again, the bearing will attach to the block in front of it", - "create.ponder.stabilized_bearings.text_4": "UNLOCALIZED: As a result, the entire sub-Contraption will stay upright", - - "create.ponder.sticker.header": "UNLOCALIZED: Attaching blocks using the Sticker", - "create.ponder.sticker.text_1": "UNLOCALIZED: Stickers are ideal for Redstone-controlled block attachment", - "create.ponder.sticker.text_2": "UNLOCALIZED: Upon receiving a signal, it will toggle its state", - "create.ponder.sticker.text_3": "UNLOCALIZED: If it is now moved in a contraption, the block will move with it", - "create.ponder.sticker.text_4": "UNLOCALIZED: Toggled once again, the block is no longer attached", - - "create.ponder.stressometer.header": "UNLOCALIZED: Monitoring Kinetic information using the Stressometer", - "create.ponder.stressometer.text_1": "UNLOCALIZED: The Stressometer displays the current Stress Capacity of the attached kinetic network", - "create.ponder.stressometer.text_2": "UNLOCALIZED: When wearing Engineers' Goggles, the player can get more detailed information from the Gauge", - "create.ponder.stressometer.text_3": "UNLOCALIZED: Comparators can emit analog Restone Signals relative to the Stressometer's measurements", - - "create.ponder.super_glue.header": "UNLOCALIZED: Attaching blocks using Super Glue", - "create.ponder.super_glue.text_1": "UNLOCALIZED: Super Glue can be used between any two blocks", - "create.ponder.super_glue.text_2": "UNLOCALIZED: The attached blocks will move together when assembled into a Contraption", - "create.ponder.super_glue.text_3": "UNLOCALIZED: Whenever Super Glue is held in the off-hand...", - "create.ponder.super_glue.text_4": "UNLOCALIZED: ...added blocks will be glued to the face they were placed on automatically", - "create.ponder.super_glue.text_5": "UNLOCALIZED: Super Glue can be removed with Left-Click", - - "create.ponder.valve_handle.header": "UNLOCALIZED: Generating Rotational Force using Valve Handles", - "create.ponder.valve_handle.text_1": "UNLOCALIZED: Valve Handles can be used by players to apply rotational force manually", - "create.ponder.valve_handle.text_2": "UNLOCALIZED: Hold Right-Click to rotate it Counter-Clockwise", - "create.ponder.valve_handle.text_3": "UNLOCALIZED: Its conveyed speed is slow and precise", - "create.ponder.valve_handle.text_4": "UNLOCALIZED: Sneak and Hold Right-Click to rotate it Clockwise", - "create.ponder.valve_handle.text_5": "UNLOCALIZED: Valve handles can be dyed for aesthetic purposes", - - "create.ponder.water_wheel.header": "UNLOCALIZED: Generating Rotational Force using Water Wheels", - "create.ponder.water_wheel.text_1": "UNLOCALIZED: Water Wheels draw force from adjacent Water Currents", - "create.ponder.water_wheel.text_2": "UNLOCALIZED: The more faces are powered, the faster the Water Wheel will rotate", - "create.ponder.water_wheel.text_3": "UNLOCALIZED: The Wheels' blades should be oriented against the flow", - "create.ponder.water_wheel.text_4": "UNLOCALIZED: Facing the opposite way, they will not be as effective", - - "create.ponder.weighted_ejector.header": "UNLOCALIZED: Using Weighted Ejectors", - "create.ponder.weighted_ejector.text_1": "UNLOCALIZED: Sneak and Right-Click holding an Ejector to select its target location", - "create.ponder.weighted_ejector.text_10": "UNLOCALIZED: It is now limited to this stack size, and only activates when its held stack reaches this amount", - "create.ponder.weighted_ejector.text_11": "UNLOCALIZED: Other Entities will always trigger an Ejector when stepping on it", - "create.ponder.weighted_ejector.text_2": "UNLOCALIZED: The placed ejector will now launch objects to the marked location", - "create.ponder.weighted_ejector.text_3": "UNLOCALIZED: A valid target can be at any height or distance within range", - "create.ponder.weighted_ejector.text_4": "UNLOCALIZED: They cannot however be off to a side", - "create.ponder.weighted_ejector.text_5": "UNLOCALIZED: If no valid Target was selected, it will simply target the block directly in front", - "create.ponder.weighted_ejector.text_6": "UNLOCALIZED: Supply Rotational Force in order to charge it up", - "create.ponder.weighted_ejector.text_7": "UNLOCALIZED: Items placed on the ejector cause it to trigger", - "create.ponder.weighted_ejector.text_8": "UNLOCALIZED: If Inventories are targeted, the ejector will wait until there is space", - "create.ponder.weighted_ejector.text_9": "UNLOCALIZED: Using the Wrench, a required Stack Size can be configured", - - "create.ponder.weighted_ejector_redstone.header": "UNLOCALIZED: Controlling Weighted Ejectors with Redstone", - "create.ponder.weighted_ejector_redstone.text_1": "UNLOCALIZED: When powered by Redstone, Ejectors will not activate", - "create.ponder.weighted_ejector_redstone.text_2": "UNLOCALIZED: Furthermore, Observers can detect when Ejectors activate", - - "create.ponder.weighted_ejector_tunnel.header": "UNLOCALIZED: Splitting item stacks using Weighted Ejectors", - "create.ponder.weighted_ejector_tunnel.text_1": "UNLOCALIZED: Combined with Brass Tunnels, Ejectors can split item stacks by specific amounts", - "create.ponder.weighted_ejector_tunnel.text_2": "UNLOCALIZED: First, configure the Brass Tunnel to 'Prefer Nearest', in order to prioritize its side output", - "create.ponder.weighted_ejector_tunnel.text_3": "UNLOCALIZED: The Stack Size set on the Ejector now determines the amount to be split off", - "create.ponder.weighted_ejector_tunnel.text_4": "UNLOCALIZED: While a new stack of the configured size exits the side output...", - "create.ponder.weighted_ejector_tunnel.text_5": "UNLOCALIZED: ...the remainder will continue on its path", - - "create.ponder.windmill_source.header": "UNLOCALIZED: Generating Rotational Force using Windmill Bearings", - "create.ponder.windmill_source.text_1": "UNLOCALIZED: Windmill Bearings attach to the block in front of them", - "create.ponder.windmill_source.text_2": "UNLOCALIZED: If enough Sail-like blocks are attached to the block, it can act as a Windmill", - "create.ponder.windmill_source.text_3": "UNLOCALIZED: Activated with Right-Click, the Windmill Bearing will start providing Rotational Force", - "create.ponder.windmill_source.text_4": "UNLOCALIZED: The Amount of Sail Blocks determine its Rotation Speed", - "create.ponder.windmill_source.text_5": "UNLOCALIZED: Use a Wrench to configure its rotation direction", - "create.ponder.windmill_source.text_6": "UNLOCALIZED: Right-click the Bearing anytime to stop and edit the Structure again", - - "create.ponder.windmill_structure.header": "UNLOCALIZED: Windmill Contraptions", - "create.ponder.windmill_structure.text_1": "UNLOCALIZED: Any Structure can count as a valid Windmill, as long as it contains at least 8 sail-like Blocks.", + "create.ponder.hold_to_ponder": "按住 [%1$s] 來思考此物品", + "create.ponder.subject": "本場景的主題", + "create.ponder.pondering": "思考有關於...", + "create.ponder.identify_mode": "暫停模式已啟動\n按 [%1$s] 來取消暫停模式", + "create.ponder.associated": "相關物品", + "create.ponder.close": "關閉", + "create.ponder.identify": "暫停", + "create.ponder.next": "下個場景", + "create.ponder.previous": "上個場景", + "create.ponder.replay": "重放", + "create.ponder.think_back": "返回", + "create.ponder.slow_text": "降低文字顯示速度", + "create.ponder.shared.movement_anchors": "有了機殼底盤和強力膠就可以移動大型結構", + "create.ponder.shared.rpm32": "32 RPM", + "create.ponder.shared.sneak_and": "潛行 +", + "create.ponder.shared.storage_on_contraption": "與結構相連的儲物空間會自動撿取物品", + "create.ponder.shared.behaviour_modify_wrench": "使用扳手來調整這個動作", + "create.ponder.shared.rpm8": "8 RPM", + "create.ponder.shared.ctrl_and": "Ctrl +", + "create.ponder.shared.rpm16_source": "轉速: 16 RPM", + "create.ponder.shared.rpm16": "16 RPM", + "create.ponder.tag.kinetic_sources": "動能產生裝置", + "create.ponder.tag.kinetic_sources.description": "該裝置能夠產生動能", + "create.ponder.tag.contraption_actor": "Contraption Actors", + "create.ponder.tag.contraption_actor.description": "Components which expose special behaviour when attached to a moving contraption", + "create.ponder.tag.arm_targets": "機械手臂的目標物", + "create.ponder.tag.arm_targets.description": "該裝置可作為機械手臂的工作目標", + "create.ponder.tag.logistics": "傳輸物品", + "create.ponder.tag.logistics.description": "該裝置用於物品的傳輸", + "create.ponder.tag.movement_anchor": "Movement Anchors", + "create.ponder.tag.movement_anchor.description": "Components which allow the creation of moving contraptions, animating an attached structure in a variety of ways", + "create.ponder.tag.creative": "創造模式", + "create.ponder.tag.creative.description": "該裝置無法在生存模式中獲得", + "create.ponder.tag.kinetic_relays": "動能傳遞方塊", + "create.ponder.tag.kinetic_relays.description": "該裝置用於傳遞動能", + "create.ponder.tag.windmill_sails": "風車軸承的帆", + "create.ponder.tag.windmill_sails.description": "建造風車時用於產生動能的帆,每個帆對風車產生的效果都是同等的", + "create.ponder.tag.contraption_assembly": "方塊連接物件", + "create.ponder.tag.contraption_assembly.description": "此物件用於連接各個零件以便組成一個成品", + "create.ponder.tag.decoration": "裝飾", + "create.ponder.tag.decoration.description": "這些零件通常用於裝飾", + "create.ponder.tag.kinetic_appliances": "動能利用裝置", + "create.ponder.tag.kinetic_appliances.description": "這些裝置利用動能運作", + "create.ponder.tag.redstone": "邏輯控制裝置", + "create.ponder.tag.redstone.description": "這些裝置會在紅石電路中發揮用處", + "create.ponder.tag.fluids": "液體控制裝置", + "create.ponder.tag.fluids.description": "這些裝置可傳輸並利用液體", + + "create.ponder.adjustable_pulse_repeater.header": "使用可調式脈衝中繼器來控制訊號", + "create.ponder.adjustable_pulse_repeater.text_1": "可調式脈衝中繼器每次運作時會產生一個短脈衝", + "create.ponder.adjustable_pulse_repeater.text_2": "使用滑鼠滾輪來設定啟動後到產生脈衝的延遲", + "create.ponder.adjustable_pulse_repeater.text_3": "延遲可設定到最大30分鐘", + + "create.ponder.adjustable_repeater.header": "使用可調式中繼器來控制訊號", + "create.ponder.adjustable_repeater.text_1": "可調式中繼器就像一般的中繼器", + "create.ponder.adjustable_repeater.text_2": "收到訊號後在設定好的時間過後才啟動...", + "create.ponder.adjustable_repeater.text_3": "...訊號停止後也需要相隔同樣的時間過後才會停止", + "create.ponder.adjustable_repeater.text_4": "使用滑鼠滾輪來設定延遲", + "create.ponder.adjustable_repeater.text_5": "延遲可設定到最大30分鐘", + + "create.ponder.analog_lever.header": "使用可調式拉桿來控制訊號", + "create.ponder.analog_lever.text_1": "可調式拉桿是一種小巧而輕準的紅石能源", + "create.ponder.analog_lever.text_2": "右鍵來增加其紅石訊號輸出", + "create.ponder.analog_lever.text_3": "潛行並右鍵來減少其紅石訊號輸出", + + "create.ponder.andesite_tunnel.header": "使用安山岩物品隧道", + "create.ponder.andesite_tunnel.text_1": "安山岩物品隧道可以覆蓋在輸送帶上", + "create.ponder.andesite_tunnel.text_2": "當安山岩物品隧道側邊連接到另一條輸送帶時...", + "create.ponder.andesite_tunnel.text_3": "...隧道將會從經過的整組物品中拿出一個丟到另一條輸送帶上", + "create.ponder.andesite_tunnel.text_4": "剩餘物品則按照原路輸出", + + "create.ponder.basin.header": "在作業盆中處理物品", + "create.ponder.basin.text_1": "作業盆可以放入物品或液體來進行處理", + "create.ponder.basin.text_2": "在每次的處理完成後, 作業盆會試著輸出成品到他的側面下方", + "create.ponder.basin.text_3": "當側面下方有一個有效的容器或設備, 作業盆側面會出現一個輸出嘴", + "create.ponder.basin.text_4": "有很多的容器或設備可以觸發上述現象", + "create.ponder.basin.text_5": "作業盆輸出的成品會被儲存到該容器或設備內", + "create.ponder.basin.text_6": "如果側面沒有出現輸出嘴, 則作業盆內的成品則不會輸出", + "create.ponder.basin.text_7": "這個原理用在產生的成品為下一輪處理的原料時相當有用", + "create.ponder.basin.text_8": "期望的成品將會從作業盆中輸出", + "create.ponder.basin.text_9": "加裝過濾器可防止未被處理的物品輸出", + + "create.ponder.bearing_modes.header": "機械軸承的工作模式", + "create.ponder.bearing_modes.text_1": "當機械軸承停止時,它會控制整個結構停在最近的垂直線上並實體化", + "create.ponder.bearing_modes.text_2": "你可以控制它不要實體化,或是在結構起始位置才實體化", + + "create.ponder.belt_casing.header": "包裹住輸送帶", + "create.ponder.belt_casing.text_1": "安山岩機殼或黃銅機殼可以用來裝飾輸送帶", + "create.ponder.belt_casing.text_2": "使用扳手可以移除機殼", + + "create.ponder.belt_connector.header": "使用輸送帶", + "create.ponder.belt_connector.text_1": "手持輸送帶對兩根傳動軸右鍵以安裝輸送帶", + "create.ponder.belt_connector.text_2": "不小心點到傳動軸的話可以用潛行+右鍵來取消選取", + "create.ponder.belt_connector.text_3": "輸送帶間只要有空間就能安裝額外的傳動軸", + "create.ponder.belt_connector.text_4": "相同輸送帶接出來的傳動軸轉速及轉向會相同", + "create.ponder.belt_connector.text_5": "使用扳手可以移除已安裝的傳動軸", + "create.ponder.belt_connector.text_6": "輸送帶可以被各種染料染色", + + "create.ponder.belt_directions.header": "輸送帶正確的安裝方向", + "create.ponder.belt_directions.text_1": "輸送帶不可以隨意聯結", + "create.ponder.belt_directions.text_2": "1. 輸送帶可以水平連結", + "create.ponder.belt_directions.text_3": "2. 輸送帶可以對角連結", + "create.ponder.belt_directions.text_4": "3. 輸送帶可以垂直連結", + "create.ponder.belt_directions.text_5": "4. 也可以連結在垂直的傳動軸上", + "create.ponder.belt_directions.text_6": "這些都是可以使用的連接方式,輸送帶可以放置的長度為2~20格", + + "create.ponder.belt_transport.header": "將輸送帶用於後勤", + "create.ponder.belt_transport.text_1": "被啟動的輸送帶能運送物品及實體", + "create.ponder.belt_transport.text_2": "空手對輸送帶上的物品右鍵即可從輸送帶上取下物品", + + "create.ponder.blaze_burner.header": "餵食烈焰使者動力爐", + "create.ponder.blaze_burner.text_1": "烈焰使者動力爐可以用來加熱作業盆", + "create.ponder.blaze_burner.text_2": "你需要餵食可以燃燒的物品來加熱作業盆", + "create.ponder.blaze_burner.text_3": "餵食熔岩蛋糕可以讓烈焰使者動力爐加熱到另一個更高的境界", + "create.ponder.blaze_burner.text_4": "使用機械手或機械手臂來將餵食自動化", + + "create.ponder.brass_funnel.header": "黃銅漏斗", + "create.ponder.brass_funnel.text_1": "安山岩漏斗每次只能傳輸一個物品", + "create.ponder.brass_funnel.text_2": "但黃銅漏斗每次可以傳輸整組物品", + "create.ponder.brass_funnel.text_3": "對漏斗上的過濾格使用滾輪可以調整每次輸出物品的數量", + "create.ponder.brass_funnel.text_4": "手持物品對漏斗上的過濾格右鍵可以限制漏斗只輸出該物品", + + "create.ponder.brass_tunnel.header": "使用黃銅隧道", + "create.ponder.brass_tunnel.text_1": "黃銅隧道必須裝設在輸送帶上", + "create.ponder.brass_tunnel.text_2": "黃銅隧道輸出入口上都有過濾格", + "create.ponder.brass_tunnel.text_3": "在輸入口上的過濾器會阻擋不相符的物品", + "create.ponder.brass_tunnel.text_4": "在輸出口上的過濾器可依種類整理排列物品", + "create.ponder.brass_tunnel.text_5": "如果數種與過濾相符的物品通過隧道, 隧道的分配模式將決定如何處理這些物品", + "create.ponder.brass_tunnel.text_6": "在平行相鄰的輸送帶上,相鄰的黃銅隧道將會成為一組", + "create.ponder.brass_tunnel.text_7": "輸入該組內的物品將會採用該組隧道的分配模式輸送", + "create.ponder.brass_tunnel.text_8": "在這個情況下, 物品也能被直接輸入到隧道方塊", + + "create.ponder.brass_tunnel_modes.header": "黃銅隧道的分配模式", + "create.ponder.brass_tunnel_modes.text_1": "使用扳手來調整隧道的分配模式", + "create.ponder.brass_tunnel_modes.text_10": "'同步輸入' 是一種黃銅隧道的特殊設定", + "create.ponder.brass_tunnel_modes.text_11": "當同組內的所有隧道都有一個可通過的物品時,所有隧道才可輸出物品", + "create.ponder.brass_tunnel_modes.text_12": "這確保了同組隧道所在的輸送帶都能以同一速率輸出物品", + "create.ponder.brass_tunnel_modes.text_2": "'分流輸出' 此模式會將物品輸出到該組隧道可用的輸出口", + "create.ponder.brass_tunnel_modes.text_3": "如果該組隧道內某個輸出口無法再輸出物品,則該輸出口會被跳過", + "create.ponder.brass_tunnel_modes.text_4": "'強制分流輸出' 模式不會跳過某個無法輸出物品的輸出口, 直到該輸出口可以輸出物品", + "create.ponder.brass_tunnel_modes.text_5": "'輪詢輸入' 模式將會保持整組物品完整性, 然後在有輸出口可以輸出時才輸入物品", + "create.ponder.brass_tunnel_modes.text_6": "如果該組隧道內某個輸出口無法再輸出物品,則該輸出口會被跳過", + "create.ponder.brass_tunnel_modes.text_7": "'強制輪詢輸入' 模式不會跳過某個無法輸出物品的輸出口, 直到該輸出口可以輸出物品", + "create.ponder.brass_tunnel_modes.text_8": "'鄰近優先' 模式會將物品輸出到該組隧道離物品輸入口最近的出口", + "create.ponder.brass_tunnel_modes.text_9": "'隨機輸出' 模式會隨機選擇同組隧道的一個輸出口輸出", + + "create.ponder.cart_assembler.header": "使用礦車裝修站裝修礦車來移動結構", + "create.ponder.cart_assembler.text_1": "礦車裝修站會將所有連接到礦車的結構裝在礦車上", + "create.ponder.cart_assembler.text_2": "如果沒有紅時訊號,它會將礦車結構分解成方塊", + "create.ponder.cart_assembler.text_3": "對礦車結構使用扳手可以將礦車變成物品", + + "create.ponder.cart_assembler_dual.header": "雙礦車結構", + "create.ponder.cart_assembler_dual.text_1": "當兩台礦車在同一礦車結構上", + "create.ponder.cart_assembler_dual.text_2": "任一礦車裝修站收到紅石訊號時,會形成完整的一個礦車結構", + "create.ponder.cart_assembler_dual.text_3": "整個礦車結構會類似於用礦車連結器連接兩個礦車結構", + + "create.ponder.cart_assembler_modes.header": "礦車結構的方向設定", + "create.ponder.cart_assembler_modes.text_1": "礦車結構會隨著礦車方向改變", + "create.ponder.cart_assembler_modes.text_2": "如果在裝修站鎖定其方向,則結構方向不會隨礦車方向改變", + + "create.ponder.cart_assembler_rails.header": "其他種類的礦車和鐵軌", + "create.ponder.cart_assembler_rails.text_1": "放在普通鐵軌上的礦車裝修站不會影響礦車的動作", + "create.ponder.cart_assembler_rails.text_2": "如果裝修站在沒有紅石訊號的動力鐵軌或控制鐵軌上,則礦車會停下直到鐵軌收到紅石訊號", + "create.ponder.cart_assembler_rails.text_3": "有幾種礦車可以當作錨來使用", + "create.ponder.cart_assembler_rails.text_4": "熔爐礦車會盡可能維持熔煉狀態,並會拿取鄰近儲存結構上的燃料", + + "create.ponder.chain_drive.header": "使用鏈式傳動箱傳遞動能", + "create.ponder.chain_drive.text_1": "同一排上的鏈式傳動箱會互相傳遞動能", + "create.ponder.chain_drive.text_2": "所有傳動軸此時會朝相同方向旋轉", + "create.ponder.chain_drive.text_3": "任一個鏈式傳動箱被旋轉90度時所有鏈式傳動箱仍可正常運作", + + "create.ponder.chain_gearshift.header": "使用可調式鏈式變速箱來調整轉速", + "create.ponder.chain_gearshift.text_1": "未被控制的可調式鏈式變速箱與鏈式傳動箱無異", + "create.ponder.chain_gearshift.text_2": "當可調式鏈式變速箱被啟動後,它會把轉速提升兩倍傳至其他鏈式傳動箱", + "create.ponder.chain_gearshift.text_3": "當被啟動的可調式鏈式變速箱並不是動能輸入端,則它會把轉速減半", + "create.ponder.chain_gearshift.text_4": "上述兩種狀況中,其他鏈式傳動箱都會被可調式鏈式變速箱提升兩倍的轉速", + "create.ponder.chain_gearshift.text_5": "利用紅石訊號的強弱可以調整轉速倍率為x1或x2", + "create.ponder.chain_gearshift.text_6": "12 RPM", + + "create.ponder.chute.header": "使用滑道向下輸送物品", + "create.ponder.chute.text_1": "滑道可以在兩個垂直的儲物空間中輸送物品", + "create.ponder.chute.text_2": "使用扳手可以讓它產生一個觀景窗", + "create.ponder.chute.text_3": "在滑道的側面放置另一個滑道,會產生一個斜狀的滑道", + + "create.ponder.chute_upward.header": "使用滑道向上輸送物品", + "create.ponder.chute_upward.text_1": "在滑道上方或下方使用鼓風機時,物品會根據被向上或向下吹", + "create.ponder.chute_upward.text_2": "裝備MR護目鏡以觀測物品的傳輸方向", + "create.ponder.chute_upward.text_3": "如滑道底端被擋住,則物品只能由側邊進行輸出入", + + "create.ponder.clockwork_bearing.header": "使用時鐘軸承來建造時鐘結構", + "create.ponder.clockwork_bearing.text_1": "時鐘軸承會黏住其前方方塊產生一個時針結構", + "create.ponder.clockwork_bearing.text_2": "在輸入動能後,該結構會依照遊戲時間來旋轉", + "create.ponder.clockwork_bearing.text_3": "3:00", + "create.ponder.clockwork_bearing.text_4": "4:00", + "create.ponder.clockwork_bearing.text_5": "對軸承右鍵會使結構啟動或停止", + "create.ponder.clockwork_bearing.text_6": "在時針結構的前方可再增加一組分針結構", + "create.ponder.clockwork_bearing.text_7": "你必須確保時針分針結構間未被使用強力膠之類的相連零件", + "create.ponder.clockwork_bearing.text_8": "分針結構此時將正常運作", + + "create.ponder.clutch.header": "使用離合器控制動能", + "create.ponder.clutch.text_1": "離合器能將動能直線傳遞", + "create.ponder.clutch.text_2": "當離合器被啟動,離合器會中斷動能傳遞", + + "create.ponder.cog_speedup.header": "使用大小齒輪來變速", + "create.ponder.cog_speedup.text_1": "大齒輪與小齒輪可以斜向傳遞動能", + "create.ponder.cog_speedup.text_2": "從大齒輪傳遞動能至小齒輪時,轉速加倍", + "create.ponder.cog_speedup.text_3": "從小齒輪傳遞動能至大齒輪時,轉速減半", + + "create.ponder.cogwheel.header": "使用齒輪來傳遞動能", + "create.ponder.cogwheel.text_1": "齒輪會將動力傳遞至臨近的齒輪", + "create.ponder.cogwheel.text_2": "以此方式連接的齒輪,旋轉方向相反", + + "create.ponder.creative_motor.header": "使用創造馬達產生動能", + "create.ponder.creative_motor.text_1": "創造馬達不僅能夠手動設定輸出動能,而且體積相當小巧", + "create.ponder.creative_motor.text_2": "對其背後面板滾動滾輪,可以改變馬達的轉速", + + "create.ponder.crushing_wheels.header": "使用粉碎輪處理物品", + "create.ponder.crushing_wheels.text_1": "一對粉碎輪,磨物快又準", + "create.ponder.crushing_wheels.text_2": "接入的動能必須使這兩個輪子契合轉動", + "create.ponder.crushing_wheels.text_3": "扔入或者放入的物品都會被粉碎處理", + "create.ponder.crushing_wheels.text_4": "你也可以使用自動化進行物品的輸入以及撿取", + + "create.ponder.deployer.header": "使用機械手", + "create.ponder.deployer.text_1": "在機械手獲得動能後能夠模仿玩家的各種行為", + "create.ponder.deployer.text_10": "對機械手手部右鍵,即可將手上的物品給它使用", + "create.ponder.deployer.text_11": "物品也可以自動化輸入到機械手內", + "create.ponder.deployer.text_12": "機械手附帶一個過濾格", + "create.ponder.deployer.text_13": "當設定了過濾後,只有當它的手中物品與過濾格相符時,它才會工作", + "create.ponder.deployer.text_14": "只有與過濾格相符的物品才可輸入...", + "create.ponder.deployer.text_15": "...不符的物品可被取出來", + "create.ponder.deployer.text_2": "它只會與它正前方兩格處的位置進行互動", + "create.ponder.deployer.text_3": "放在在它面前的方塊不會阻攔它的工作", + "create.ponder.deployer.text_4": "機械手可以:", + "create.ponder.deployer.text_5": "放置方塊", + "create.ponder.deployer.text_6": "使用物品", + "create.ponder.deployer.text_7": "啟動方塊", + "create.ponder.deployer.text_8": "採收方塊", + "create.ponder.deployer.text_9": "以及攻擊生物", + + "create.ponder.deployer_contraption.header": "在裝置上使用機械手", + "create.ponder.deployer_contraption.text_1": "當機械手在移動的結構上時...", + "create.ponder.deployer_contraption.text_2": "機械手會對每一個經過的方塊使用裝置中任意容器內的物品", + "create.ponder.deployer_contraption.text_3": "可以透過過濾格來指定其從存儲空間中抽取的物品", + + "create.ponder.deployer_modes.header": "機械手的工作模式", + "create.ponder.deployer_modes.text_1": "在設設情況下,機械手模仿玩家的右鍵", + "create.ponder.deployer_modes.text_2": "使用扳手可以將模式調整為模仿玩家的左鍵", + + "create.ponder.deployer_redstone.header": "使用紅石控制機械手", + "create.ponder.deployer_redstone.text_1": "當機械手收到紅時訊號時會停止工作", + "create.ponder.deployer_redstone.text_2": "在停止工作前,機械手會完成目前手頭上的工作", + "create.ponder.deployer_redstone.text_3": "因此,輸入脈衝訊號可以使其每次只進行一個週期的工作", + + "create.ponder.depot.header": "使用置物台", + "create.ponder.depot.text_1": "置物台可以被當成一個“靜止的”傳送帶原件使用", + "create.ponder.depot.text_2": "右擊可以手動放置或取下物品", + "create.ponder.depot.text_3": "與傳送帶一樣,它也可以將其內的物品轉送到其他設備中進行加工...", + "create.ponder.depot.text_4": "...同時物品也可以被機械手存取", + + "create.ponder.empty_blaze_burner.header": "使用空的烈焰人燃燒室", + "create.ponder.empty_blaze_burner.text_1": "手持空的烈焰人燃燒室右擊烈焰人來抓取烈焰人", + "create.ponder.empty_blaze_burner.text_2": "或者,也可以透過右擊烈焰人刷怪籠來填充啟動烈焰人燃燒室", + "create.ponder.empty_blaze_burner.text_3": "這樣,你便有了一個可供部分機器加工的熱源", + "create.ponder.empty_blaze_burner.text_4": "如果是為了美觀,空的烈焰人燃燒室也可以被打火石點燃", + "create.ponder.empty_blaze_burner.text_5": "但是,這樣的熱源不足以給機器提加工供足夠的熱量", + + "create.ponder.fan_direction.header": "鼓風機的氣流", + "create.ponder.fan_direction.text_1": "鼓風機使用動能來製造氣流", + "create.ponder.fan_direction.text_2": "流速以及方向由所接收動能的強弱以及方向而定", + + "create.ponder.fan_processing.header": "使用鼓風機加工物品", + "create.ponder.fan_processing.text_1": "當氣流吹過熔岩時,氣流會被加熱", + "create.ponder.fan_processing.text_2": "熱氣流中的物品會被冶煉", + "create.ponder.fan_processing.text_3": "但在氣流中的食物會被直接燒成灰", + "create.ponder.fan_processing.text_4": "而想要烹飪食物,必須要透過吹過火焰的氣流來煙燻食物", + "create.ponder.fan_processing.text_5": "當氣流吹過水後,便可用於洗滌物品", + "create.ponder.fan_processing.text_6": "這種加工方法可以做到不少有趣的事情", + "create.ponder.fan_processing.text_7": "鼓風機的轉速對加工的速度沒有影響,只影響氣流的吹拂距離", + "create.ponder.fan_processing.text_8": "而那些放置在置物台或者傳送帶上的物品,鼓風機也是可以處理的", + + "create.ponder.fan_source.header": "使用鼓風機來產生動能", + "create.ponder.fan_source.text_1": "如鼓風機的扇葉向下朝著熱源放置,鼓風機可以藉此產生動能", + "create.ponder.fan_source.text_2": "當鼓風機接受紅石訊號後,它便會向外供給動能", + + "create.ponder.flywheel.header": "使用飛輪來產生動能", + "create.ponder.flywheel.text_1": "飛輪和熔爐引擎必須配套使用,方可產生動能", + "create.ponder.flywheel.text_2": "如此產生的動能具有非常大的應力值", + "create.ponder.flywheel.text_3": "使用高爐會使得引擎的效率翻倍", + + "create.ponder.funnel_compat.header": "漏斗的相容性", + "create.ponder.funnel_compat.text_1": "漏斗可以與一些其他組件互動", + "create.ponder.funnel_compat.text_2": "動力鋸", + "create.ponder.funnel_compat.text_3": "置物台", + "create.ponder.funnel_compat.text_4": "分液池", + + "create.ponder.funnel_direction.header": "物流方向", + "create.ponder.funnel_direction.text_1": "直接放置時,漏斗會將物品從容器中取出", + "create.ponder.funnel_direction.text_2": "潛行時放置時,漏斗會將物品置入容器中", + "create.ponder.funnel_direction.text_3": "使用扳手可以改變漏斗的存/取模式", + "create.ponder.funnel_direction.text_4": "對大多數朝向放置的漏斗都具有此特性", + "create.ponder.funnel_direction.text_5": "在傳送帶末端放置的漏斗會根據傳送帶的傳動方向存/取物品", + + "create.ponder.funnel_intro.header": "使用漏斗", + "create.ponder.funnel_intro.text_1": "用漏斗來存取物品欄內的物品,可謂又快又好", + + "create.ponder.funnel_redstone.header": "紅石訊號控制", + "create.ponder.funnel_redstone.text_1": "紅石訊號會使漏斗停止工作", + + "create.ponder.funnel_transfer.header": "直接運輸", + "create.ponder.funnel_transfer.text_1": "漏斗無法將物品傳輸到非開放式的物品欄中", + "create.ponder.funnel_transfer.text_2": "溜槽和智慧溜槽更適用於這樣的場景", + "create.ponder.funnel_transfer.text_3": "水平傳輸也是如此,也許傳送帶更方便快捷", + + "create.ponder.furnace_engine.header": "使用熔爐引擎生產動能", + "create.ponder.furnace_engine.text_1": "熔爐引擎會在與其相連熔爐工作時生產動能", + "create.ponder.furnace_engine.text_2": "如此產生的動能具有非常大的應力值", + "create.ponder.furnace_engine.text_3": "使用高爐會使得引擎的效率翻倍", + + "create.ponder.gantry_carriage.header": "使用起重機取物器", + "create.ponder.gantry_carriage.text_1": "起重機取物器可以被放置在起重機杆上,並且可以沿著起重機杆運動", + "create.ponder.gantry_carriage.text_2": "起重機可以移動其黏附的方塊", + + "create.ponder.gantry_cascaded.header": "串聯起重機", + "create.ponder.gantry_cascaded.text_1": "無需強力膠,取物器便可與起重機杆相連", + "create.ponder.gantry_cascaded.text_2": "即使是在移動的起重機杆上也是如此", + "create.ponder.gantry_cascaded.text_3": "因此,起重機系統可以串聯起來,如此可以影響到多軸向的運動", + + "create.ponder.gantry_direction.header": "起重機移動方向", + "create.ponder.gantry_direction.text_1": "起重機杆可以有相反的方向", + "create.ponder.gantry_direction.text_2": "取物器的移動方向取決於起重機杆的方向", + "create.ponder.gantry_direction.text_3": "......以及起重機杆的旋轉方向", + "create.ponder.gantry_direction.text_4": "在旋轉傳遞中,此規則同樣適用", + + "create.ponder.gantry_redstone.header": "起重機的力傳遞", + "create.ponder.gantry_redstone.text_1": "被紅石訊號啟動的起重機,將不會移動其上的取物器", + "create.ponder.gantry_redstone.text_2": "作為替代,杆上的動能會傳遞到取物器的輸出杆上", + + "create.ponder.gantry_shaft.header": "使用起重機杆", + "create.ponder.gantry_shaft.text_1": "起重機杆組成了起重機結構的基礎。與其相接的載物器可以沿著杆進行移動。", + "create.ponder.gantry_shaft.text_2": "起重機結構可以移動與其相接的方塊。", + + "create.ponder.gearbox.header": "使用十字齒輪箱傳遞動能", + "create.ponder.gearbox.text_1": "更改旋轉軸,很容易使得整個旋轉體系變得臃腫不堪", + "create.ponder.gearbox.text_2": "十字齒輪箱則是替代方案,它的體積更為小巧緊", + "create.ponder.gearbox.text_3": "側邊連接的傳動桿,旋轉方向與輸入端一致", + "create.ponder.gearbox.text_4": "直線連接的傳動桿,旋轉方向會被反轉", + + "create.ponder.gearshift.header": "使用反轉齒輪箱控制動能", + "create.ponder.gearshift.text_1": "反轉齒輪箱可以直線傳輸旋轉", + "create.ponder.gearshift.text_2": "通入紅石訊號後,輸出端的旋轉方向會被反轉", + + "create.ponder.hand_crank.header": "使用手搖把手產生動能", + "create.ponder.hand_crank.text_1": "玩家可以使用手搖把手來手動產生動能", + "create.ponder.hand_crank.text_2": "按住右鍵可以逆時針旋轉它", + "create.ponder.hand_crank.text_3": "它產生的轉速相對較高", + "create.ponder.hand_crank.text_4": "潛行長按右鍵可以順時針旋轉它", + + "create.ponder.large_cogwheel.header": "使用大齒輪傳遞動能", + "create.ponder.large_cogwheel.text_1": "大齒輪可以以特定的角度相互連接", + "create.ponder.large_cogwheel.text_2": "可以利用大齒輪變更旋轉軸向", + + "create.ponder.linear_chassis_attachment.header": "使用機殼底盤黏合方塊", + "create.ponder.linear_chassis_attachment.text_1": "它的開放面可以變為黏性面", + "create.ponder.linear_chassis_attachment.text_2": "再次點擊黏性面,可以將它的相反面也變得具有黏性", + "create.ponder.linear_chassis_attachment.text_3": "空手潛行右擊可以移除此面的黏性物", + "create.ponder.linear_chassis_attachment.text_4": "黏性面可以將此面前方的一長條方塊黏住", + "create.ponder.linear_chassis_attachment.text_5": "使用扳手可以精確控制底盤的影響範圍", + "create.ponder.linear_chassis_attachment.text_6": "按住 Ctrl 滑動滾輪,你可以一次性調節所有底盤的影響範圍", + "create.ponder.linear_chassis_attachment.text_7": "若想讓底盤的其他面也能黏方塊,你需要用到強力膠", + "create.ponder.linear_chassis_attachment.text_8": "利用這些機制,任何形狀的機制都可以像裝置那樣移動", + + "create.ponder.linear_chassis_group.header": "成組移動機殼底盤", + "create.ponder.linear_chassis_group.text_1": "相鄰的機殼底盤可以相互連接在一起", + "create.ponder.linear_chassis_group.text_2": "其中的一個底盤若被移動,其餘的底盤也會跟著移動", + "create.ponder.linear_chassis_group.text_3": "不同種類的底盤,或者是朝向不一致的底盤,將不會相連", + + "create.ponder.mechanical_arm.header": "設定動力臂", + "create.ponder.mechanical_arm.text_1": "你得在放置動力臂之前就設定好它的輸入以及輸出端", + "create.ponder.mechanical_arm.text_2": "手持動力臂右擊某個存儲空間,可以將其指定為目標", + "create.ponder.mechanical_arm.text_3": "再次右擊可以將其在輸入端(藍色)以及輸出端(橙色)之間切換", + "create.ponder.mechanical_arm.text_4": "左擊此組件可以移除選擇", + "create.ponder.mechanical_arm.text_5": "將動力臂放下來後,它會將此前選擇的方塊作為目標", + "create.ponder.mechanical_arm.text_6": "在有效範圍內,機械手臂可以有任意數量的輸出以及輸入端", + "create.ponder.mechanical_arm.text_7": "然而,並不是所有的存儲空間可以被直接互動", + "create.ponder.mechanical_arm.text_8": "在此情況下,漏斗和置物台可以解決此問題", + + "create.ponder.mechanical_arm_filtering.header": "過濾動力臂的輸出端", + "create.ponder.mechanical_arm_filtering.text_1": "輸入", + "create.ponder.mechanical_arm_filtering.text_2": "輸出", + "create.ponder.mechanical_arm_filtering.text_3": "有時,你會想著利用某種過濾限煞車力臂的目標", + "create.ponder.mechanical_arm_filtering.text_4": "動力臂自身並不提供任何過濾選項", + "create.ponder.mechanical_arm_filtering.text_5": "然而,若將黃銅漏斗作為目標,則漏斗的過濾槽則可以應用至動力臂上", + "create.ponder.mechanical_arm_filtering.text_6": "動力臂足夠智慧,它不會去拿取那些它無法分配的物品", + + "create.ponder.mechanical_arm_modes.header": "動力臂的分配模式", + "create.ponder.mechanical_arm_modes.text_1": "輸入", + "create.ponder.mechanical_arm_modes.text_2": "輸出", + "create.ponder.mechanical_arm_modes.text_3": "若動力臂必須在數個有效的輸出端之間作出選擇...", + "create.ponder.mechanical_arm_modes.text_4": "...它會依照自己的設定選擇特定的行為", + "create.ponder.mechanical_arm_modes.text_5": "手持扳手對其滑動滾輪,可以改變其設定", + "create.ponder.mechanical_arm_modes.text_6": "輪詢調度模式很好理解,即循環輸出至所有有效的輸出端", + "create.ponder.mechanical_arm_modes.text_7": "如果某個輸出端無法容納更多物品,則它會被跳過", + "create.ponder.mechanical_arm_modes.text_8": "強制輪詢調度不會跳過任何輸出端,動力臂會一直等待,直到輸出端有空位容納物品輸入", + "create.ponder.mechanical_arm_modes.text_9": "最近優先模式會使得動力臂先將物品輸出至更早被選擇的輸出端", + + "create.ponder.mechanical_arm_redstone.header": "利用紅石訊號控制動力臂", + "create.ponder.mechanical_arm_redstone.text_1": "通入紅石訊號後,動力臂會停止工作", + "create.ponder.mechanical_arm_redstone.text_2": "在停止工作前,它會完成目前正在進行的工作週期", + "create.ponder.mechanical_arm_redstone.text_3": "因此,通入單次負紅石脈衝可以精確控制動力臂,使其每次只進行單個週期的工作", + + "create.ponder.mechanical_bearing.header": "使用動力軸承移動結構", + "create.ponder.mechanical_bearing.text_1": "動力軸承會與其前方的方塊黏合在一起", + "create.ponder.mechanical_bearing.text_2": "接收到動能後,它會將這一黏合結構組裝為旋轉裝置", + + "create.ponder.mechanical_crafter.header": "設置動力合成器", + "create.ponder.mechanical_crafter.text_1": "動力合成器陣列可用於自動化任何合成配方的製作", + "create.ponder.mechanical_crafter.text_2": "使用扳手可以調控合成器的合成通路", + "create.ponder.mechanical_crafter.text_3": "所有的合成通路必須匯集到任意一側的一個出口,整套合成器方可算是設置正確", + "create.ponder.mechanical_crafter.text_4": "輸出產物會被放入位於出口的存儲空間中", + "create.ponder.mechanical_crafter.text_5": "動力合成器的運轉需要動能的供應", + "create.ponder.mechanical_crafter.text_6": "右擊合成器正面,可以手動放入物品", + "create.ponder.mechanical_crafter.text_7": "一旦合成通路上的所有合成槽位都有了物品,合成就會開始", + "create.ponder.mechanical_crafter.text_8": "而對於那些沒有完全占滿所有合成器槽位的配方,你可以通入紅石訊號強制開啟合成", + + "create.ponder.mechanical_crafter_connect.header": "為合成器連接物品欄", + "create.ponder.mechanical_crafter_connect.text_1": "合成器可以自動接受向其輸入的物品", + "create.ponder.mechanical_crafter_connect.text_2": "對其背面使用扳手,可以連接合成器", + "create.ponder.mechanical_crafter_connect.text_3": "所有相連的合成器可以訪問同一個位置的輸入", + + "create.ponder.mechanical_crafter_covers.header": "蓋住動力合成器的合成槽", + "create.ponder.mechanical_crafter_covers.text_1": "有些配方需要額外的合成器,來補足合成通路上的間隙", + "create.ponder.mechanical_crafter_covers.text_2": "使用合成槽蓋板,合成器會在合成進行時的行為就如同一個空的合成槽位", + "create.ponder.mechanical_crafter_covers.text_3": "被蓋住的合成器並不會阻斷共享輸入端的影響", + + "create.ponder.mechanical_drill.header": "使用機械鑽頭破壞方塊", + "create.ponder.mechanical_drill.text_1": "當向其通入動能後,機械鑽頭會破壞它面前的方塊", + "create.ponder.mechanical_drill.text_2": "它的挖掘速度取決於通入的動能轉速", + + "create.ponder.mechanical_drill_contraption.header": "在裝置中使用機械鑽頭", + "create.ponder.mechanical_drill_contraption.text_1": "在運動裝置中使用機械鑽頭時...", + "create.ponder.mechanical_drill_contraption.text_2": "...它會破壞掉它撞上的方塊", + + "create.ponder.mechanical_harvester.header": "在裝置中使用動力收割機", + "create.ponder.mechanical_harvester.text_1": "在運動裝置中使用動力收割機時...", + "create.ponder.mechanical_harvester.text_2": "它會採收其路徑上的作物,並重設這些作物的生長進度", + + "create.ponder.mechanical_mixer.header": "使用動力攪拌器處理物品", + "create.ponder.mechanical_mixer.text_1": "使用攪拌器和工作盆,你可以自動化某些合成配方", + "create.ponder.mechanical_mixer.text_2": "有效配方包括各種無序合成配方,以及一些額外的配方", + "create.ponder.mechanical_mixer.text_3": "一些配方可能需要使用烈焰人燃燒室提供熱量", + "create.ponder.mechanical_mixer.text_4": "過濾槽可用於解決兩個配方相互衝突的情況", + + "create.ponder.mechanical_piston.header": "使用動力活塞移動結構", + "create.ponder.mechanical_piston.text_1": "動力活塞可以移動它前方的方塊", + "create.ponder.mechanical_piston.text_2": "移動速度和方向取決於通入活塞的動能", + "create.ponder.mechanical_piston.text_3": "黏性動力活塞可以將相接的方塊拉回來", + + "create.ponder.mechanical_piston_modes.header": "動力活塞的移動模式", + "create.ponder.mechanical_piston_modes.text_1": "一旦活塞停下,被移動的結構就會回退到方塊狀態", + "create.ponder.mechanical_piston_modes.text_2": "你也可以將其設定為從不方塊化,或者只在起始位置方塊化", + + "create.ponder.mechanical_plough.header": "在裝置中使用動力犁", + "create.ponder.mechanical_plough.text_1": "在運動裝置中使用動力犁時...", + "create.ponder.mechanical_plough.text_2": "...它會破壞掉那些不具有固體碰撞箱的方塊", + "create.ponder.mechanical_plough.text_3": "此外,動力犁可以耕地", + "create.ponder.mechanical_plough.text_4": "...它也可以在不傷害實體的情況下推動它們", + + "create.ponder.mechanical_press.header": "使用機械液壓機處理物品", + "create.ponder.mechanical_press.text_1": "機械液壓機可以處理位於其下方的物品", + "create.ponder.mechanical_press.text_2": "在其下方丟入物品,或者將物品放在置物台上,都算作有效的物品輸入", + "create.ponder.mechanical_press.text_3": "若物品被輸入時正位於傳送帶上...", + "create.ponder.mechanical_press.text_4": "輥軋機會使物品停下,然後自動處理這一物品", + + "create.ponder.mechanical_press_compacting.header": "使用機械液壓機壓縮物品", + "create.ponder.mechanical_press_compacting.text_1": "對放置於工作盆內的物品進行輥軋,可以將這些物品壓縮在一起", + "create.ponder.mechanical_press_compacting.text_2": "壓縮意指任何同種物品填滿了 2x2 或者 3x3 網格的配方,以及一些額外的配方", + "create.ponder.mechanical_press_compacting.text_3": "一些配方可能需要烈焰人燃燒室提供熱量", + "create.ponder.mechanical_press_compacting.text_4": "過濾槽可用於解決兩個配方相互衝突的情況", + + "create.ponder.mechanical_saw_breaker.header": "使用動力鋸伐木", + "create.ponder.mechanical_saw_breaker.text_1": "向其通入動能後,動力鋸可以直接砍伐掉它面前的樹木", + "create.ponder.mechanical_saw_breaker.text_2": "想要一次性砍掉整棵樹,鋸子必須破壞掉樹與地面連接的最後一個方塊", + + "create.ponder.mechanical_saw_contraption.header": "在裝置中使用動力鋸", + "create.ponder.mechanical_saw_contraption.text_1": "若在運動裝置中使用動力鋸...", + "create.ponder.mechanical_saw_contraption.text_2": "...它會將撞到它的樹木破壞掉", + + "create.ponder.mechanical_saw_processing.header": "使用動力鋸處理物品", + "create.ponder.mechanical_saw_processing.text_1": "面向朝上的動力鋸可以將物品處理為其變種", + "create.ponder.mechanical_saw_processing.text_2": "處理過後的物品的彈出方向始終與通入鋸中的旋轉轉向相反", + "create.ponder.mechanical_saw_processing.text_3": "鋸子可以", + "create.ponder.mechanical_saw_processing.text_4": "若輸入原料有多種可能產物,你可以用動力鋸上的過濾槽指定只產出某種產物", + "create.ponder.mechanical_saw_processing.text_5": "若沒有使用過濾槽,動力鋸會在各產物中按順序循環輸出", + + "create.ponder.millstone.header": "使用石磨處理物品", + "create.ponder.millstone.text_1": "石磨會對輸入的物品進行磨製", + "create.ponder.millstone.text_2": "在其側邊使用齒輪與其相耦合,方可為其通入動力", + "create.ponder.millstone.text_3": "頂部可以丟入或者塞入物品", + "create.ponder.millstone.text_4": "一段時間過後,右擊石磨可以拿出其中的產物", + "create.ponder.millstone.text_5": "產物的提取也是可以自動化的", + + "create.ponder.nixie_tube.header": "使用真空管顯示器", + "create.ponder.nixie_tube.text_1": "通入紅石訊號後,真空管顯示器會顯示出紅石訊號的強度", + "create.ponder.nixie_tube.text_2": "使用命名牌在鐵砧上為其命名,可以自訂它的顯示文本", + + "create.ponder.piston_pole.header": "活塞延長杆", + "create.ponder.piston_pole.text_1": "若無相接的延長杆,動力活塞無法移動其他方塊", + "create.ponder.piston_pole.text_2": "在其背面安裝的延長杆長度,決定了活塞的推動範圍", + + "create.ponder.portable_storage_interface.header": "裝置存儲交換", + "create.ponder.portable_storage_interface.text_1": "玩家無法與運動裝置內的存儲空間進行互動", + "create.ponder.portable_storage_interface.text_2": "這一組件可以在不停止裝置的情況下與裝置內的存儲空間進行互動", + "create.ponder.portable_storage_interface.text_3": "放置第二個介面時,記得要與裝置介面相隔 1 格或者 2 格的距離", + "create.ponder.portable_storage_interface.text_4": "當它們彼此經過時,它們會連接在一起", + "create.ponder.portable_storage_interface.text_5": "連接狀態下,固定側介面便會作為整個裝置的存儲空間代理", + "create.ponder.portable_storage_interface.text_6": "物品會被輸入到裝置內...", + "create.ponder.portable_storage_interface.text_7": "...或是從裝置中提取出來", + "create.ponder.portable_storage_interface.text_8": "物品交換完畢後,裝置仍然會停留在原地一小會,然後才會繼續前行", + + "create.ponder.portable_storage_interface_redstone.header": "紅石控制", + "create.ponder.portable_storage_interface_redstone.text_1": "通入紅石訊號可以阻止固定側介面的連接行為", + + "create.ponder.powered_latch.header": "使用閂鎖器控制訊號", + "create.ponder.powered_latch.text_1": "閂鎖器是一種可以用紅石訊號控制的拉杆", + "create.ponder.powered_latch.text_2": "後方輸入的訊號會將其設為開啟狀態", + "create.ponder.powered_latch.text_3": "側邊輸入的訊號會將其設為關閉狀態", + "create.ponder.powered_latch.text_4": "你也可以手動切換其狀態", + + "create.ponder.powered_toggle_latch.header": "使用T型正反器控制訊號", + "create.ponder.powered_toggle_latch.text_1": "T型正反器是一種可以用紅石訊號控制的拉杆", + "create.ponder.powered_toggle_latch.text_2": "後方訊號輸入可以改變它的狀態", + "create.ponder.powered_toggle_latch.text_3": "...開啟或者是關閉", + "create.ponder.powered_toggle_latch.text_4": "你也可以手動切換其狀態", + + "create.ponder.pulse_repeater.header": "使用脈衝中繼器控制訊號", + "create.ponder.pulse_repeater.text_1": "脈衝中繼器會將所有通入的紅石訊號縮減為一次脈衝", + + "create.ponder.radial_chassis.header": "使用旋轉底盤黏著方塊", + "create.ponder.radial_chassis.text_1": "同一行上的旋轉底盤會相互連接在一起", + "create.ponder.radial_chassis.text_2": "當其中的一個底盤被裝置帶動時,其餘的底盤也會被帶動", + "create.ponder.radial_chassis.text_3": "底盤的側邊可以變為黏性面", + "create.ponder.radial_chassis.text_4": "再次點擊黏性面,可以讓其所有面都變得帶黏性", + "create.ponder.radial_chassis.text_5": "空手潛行右擊可以移除其上的黏性物", + "create.ponder.radial_chassis.text_6": "若有物品與底盤的黏性面相接觸...", + "create.ponder.radial_chassis.text_7": "...底盤便會與同層且位於半徑內的所有可及方塊黏著在一起", + "create.ponder.radial_chassis.text_8": "使用扳手可以精確指定底盤的影響範圍", + "create.ponder.radial_chassis.text_9": "黏性面一側的不可及方塊不會被黏著", + + "create.ponder.redstone_contact.header": "接觸式紅石訊號發生器", + "create.ponder.redstone_contact.text_1": "當兩個接觸式紅石訊號發生器面對面時,它們會發出紅石訊號", + "create.ponder.redstone_contact.text_2": "並且,若有一方位於運動裝置上,此特性也能正常生效", + + "create.ponder.redstone_link.header": "使用無線紅石訊號機", + "create.ponder.redstone_link.text_1": "無線紅石訊號機可以無線傳輸紅石訊號", + "create.ponder.redstone_link.text_2": "潛行右擊可以改變其接收模式", + "create.ponder.redstone_link.text_3": "手持扳手右擊也可以", + "create.ponder.redstone_link.text_4": "接收端會發出由傳輸端發來的訊號,有效距離為 128 格", + "create.ponder.redstone_link.text_5": "在它們所帶的槽位中放上物品,可以為它們指定頻道", + "create.ponder.redstone_link.text_6": "只有頻道相互匹配的機方可互通", + + "create.ponder.rope_pulley.header": "使用繩索滑輪移動結構", + "create.ponder.rope_pulley.text_1": "繩索滑輪在接受動能時可以垂直移動方塊結構", + "create.ponder.rope_pulley.text_2": "移動的方向及速度取決於提供的轉速", + + "create.ponder.rope_pulley_attachment.header": "繩索滑輪與裝置一同運動", + "create.ponder.rope_pulley_attachment.text_1": "當繩索滑輪本身在裝置中被帶動時...", + "create.ponder.rope_pulley_attachment.text_2": "...它附著在滑輪上的結構會被滑輪拉著一同移動", + "create.ponder.rope_pulley_attachment.text_3": "注意,只有繩索滑輪停止工作時才能被移動", + + "create.ponder.rope_pulley_modes.header": "繩索滑輪的運動模式", + "create.ponder.rope_pulley_modes.text_1": "當繩索滑輪停止運動時,它所附屬的移動結構便會方塊化", + "create.ponder.rope_pulley_modes.text_2": "你可以調整整個結構永不方塊化,或者僅在結構的初始位置方塊化", + + "create.ponder.rotation_speed_controller.header": "使用轉速控制器", + "create.ponder.rotation_speed_controller.text_1": "轉速控制器將動能從其轉軸傳遞至它上方的大齒輪", + "create.ponder.rotation_speed_controller.text_2": "在其側面滾動滑鼠滾輪,可以調節輸出轉速", + + "create.ponder.sail.header": "使用風帆來組裝風車", + "create.ponder.sail.text_1": "風帆是製作風車的趁手材料", + "create.ponder.sail.text_2": "無需強力膠等黏附手段,它們便可自行互相連結", + "create.ponder.sail.text_3": "手持染料右擊可對其染色", + "create.ponder.sail.text_4": "手持剪刀右擊可剪除帆布,使其變迴風帆框架", + + "create.ponder.sail_frame.header": "使用風帆框架來組裝風車", + "create.ponder.sail_frame.text_1": "風帆框架是製作風車的趁手材料", + "create.ponder.sail_frame.text_2": "無需強力膠等黏附手段,它們便可自行互相連結", + + "create.ponder.sequenced_gearshift.header": "使用可編程齒輪箱來控制轉速", + "create.ponder.sequenced_gearshift.text_1": "可編程齒輪箱能夠根據玩家設置的預設時序表來傳遞旋轉", + "create.ponder.sequenced_gearshift.text_2": "對其右擊可以打開設置面板", + "create.ponder.sequenced_gearshift.text_3": "接受紅石訊號時,它會開始執行其內部已設定好的時序指令表", + "create.ponder.sequenced_gearshift.text_4": "當完成時序指令表後,它會進入待機狀態,再次接受紅石訊號後,它才會再次執行時序指令表內容", + "create.ponder.sequenced_gearshift.text_5": "紅石比較器可以讀取目前時序指令表完成進度", + + "create.ponder.shaft.header": "使用傳動軸來傳送動能", + "create.ponder.shaft.text_1": "傳動軸可以直線傳送動能", + + "create.ponder.shaft_casing.header": "包裹傳動軸", + "create.ponder.shaft_casing.text_1": "黃銅及安山岩機殼可以用來裝飾傳動軸", + + "create.ponder.smart_chute.header": "使用智慧滑道來過濾物品", + "create.ponder.smart_chute.text_1": "智慧滑道是一種可以被控制的滑道", + "create.ponder.smart_chute.text_2": "當在其過濾槽內指定了物品後,溜槽只會傳輸這一指定標記的物品", + "create.ponder.smart_chute.text_3": "使用滑鼠滾輪可以指定被過濾的物品數量", + "create.ponder.smart_chute.text_4": "通入紅石訊號,智慧溜槽將會完全暫停工作", + + "create.ponder.speedometer.header": "使用速度計來監測轉速", + "create.ponder.speedometer.text_1": "速度計能顯示相接組件的轉速", + "create.ponder.speedometer.text_2": "當佩戴MR護目鏡時,可以看到儀表所顯示的更詳細的數據", + "create.ponder.speedometer.text_3": "紅石比較器可以根據速度計的數值輸出不同強弱的紅石訊號", + + "create.ponder.stabilized_bearings.header": "裝置固定朝向", + "create.ponder.stabilized_bearings.text_1": "當動力軸承在結構被帶動時...", + "create.ponder.stabilized_bearings.text_2": "...它會確保它轉盤的垂直朝向不變", + "create.ponder.stabilized_bearings.text_3": "跟預設的一樣,動力軸承會黏著它前方的方塊", + "create.ponder.stabilized_bearings.text_4": "這種情況下,它所黏著的子結構的垂直朝向也不會改變", + + "create.ponder.sticker.header": "使用方塊黏著器來黏取方塊", + "create.ponder.sticker.text_1": "方塊黏著器是一個很棒的裝置,他受控於紅石訊號", + "create.ponder.sticker.text_2": "當接收到訊號時,他會黏起面前的一個方塊", + "create.ponder.sticker.text_3": "如果此時方塊黏著器被移動,被黏到的方塊會跟著移動", + "create.ponder.sticker.text_4": "再次接收到訊號後,黏著器會放下它面前的方塊", + + "create.ponder.stressometer.header": "使用動能錶來監測應力", + "create.ponder.stressometer.text_1": "動能錶能顯示目前動能網路內的應力訊息", + "create.ponder.stressometer.text_2": "當佩戴MR護目鏡時,可以看到儀表所顯示的更詳細的數據", + "create.ponder.stressometer.text_3": "紅石比較器可以根據動能錶的數值輸出不同強弱的紅石訊號", + + "create.ponder.super_glue.header": "使用強力膠來黏附方塊", + "create.ponder.super_glue.text_1": "強力膠可以在任意兩個方塊間使用", + "create.ponder.super_glue.text_2": "當被黏合的方塊被組裝為裝置時,他們會一起運動", + "create.ponder.super_glue.text_3": "當強力膠在副手時...", + "create.ponder.super_glue.text_4": "...新放置的方塊會自動被黏附在所放置方塊的面上", + "create.ponder.super_glue.text_5": "左擊可以清除強力膠", + + "create.ponder.valve_handle.header": "使用閥門手輪產生動能", + "create.ponder.valve_handle.text_1": "玩家可以手動使用閥門手輪來產生動能", + "create.ponder.valve_handle.text_2": "右擊可使它逆時針旋轉", + "create.ponder.valve_handle.text_3": "它的轉速慢而精確", + "create.ponder.valve_handle.text_4": "潛行右擊可使它順時針旋轉", + "create.ponder.valve_handle.text_5": "可以透過染色來美化閥門手輪", + + "create.ponder.water_wheel.header": "使用水車產生動能", + "create.ponder.water_wheel.text_1": "水車利用臨近的水流來進行應力發生", + "create.ponder.water_wheel.text_2": "水車接觸水流的麵越多,它的轉速越高", + "create.ponder.water_wheel.text_3": "水車葉片應逆著水流方向擺放", + "create.ponder.water_wheel.text_4": "如果順著水流擺放,它的效率則會降低", + + "create.ponder.weighted_ejector.header": "使用彈射置物台", + "create.ponder.weighted_ejector.text_1": "手持彈射置物台時,潛行時右擊可以設置彈射目標位置", + "create.ponder.weighted_ejector.text_10": "現在,只有等被放置的物品數量等於所設定數量時,彈射置物台才會彈射物品", + "create.ponder.weighted_ejector.text_11": "當其他實體站在彈射置物台上時會被直接彈射", + "create.ponder.weighted_ejector.text_2": "現在,放置下的彈射置物台會將物品彈射至目標位置", + "create.ponder.weighted_ejector.text_3": "限制範圍內的任意距離和高度均可作為有效目標地點", + "create.ponder.weighted_ejector.text_4": "但是,目標位置與置物台的連線,必須垂直於置物台的側面", + "create.ponder.weighted_ejector.text_5": "如果沒有設置有效目標位置,彈射置物台會直接將其前方一格設為默認目標位置", + "create.ponder.weighted_ejector.text_6": "提供動能可為其蓄力", + "create.ponder.weighted_ejector.text_7": "蓄力完畢後,放置在它上方的物品會被立刻彈射出去", + "create.ponder.weighted_ejector.text_8": "如果目標為容器,則彈射置物台會等待容器有位置後再彈射物品", + "create.ponder.weighted_ejector.text_9": "使用扳手可以調整彈射所要求的物品數量", + + "create.ponder.weighted_ejector_redstone.header": "使用紅石控制彈射置物台", + "create.ponder.weighted_ejector_redstone.text_1": "當被紅石充能時,彈射置物台停止工作", + "create.ponder.weighted_ejector_redstone.text_2": "此外,置物台彈射的瞬間可以被偵測器偵測", + + "create.ponder.weighted_ejector_tunnel.header": "使用彈射置物台來分流物品", + "create.ponder.weighted_ejector_tunnel.text_1": "與黃銅隧道搭配使用時,彈射置物台可以將物品以特定數量進行分流", + "create.ponder.weighted_ejector_tunnel.text_2": "首先,將黃銅隧道調整為“最近優先”模式,從而讓它優先側面輸出", + "create.ponder.weighted_ejector_tunnel.text_3": "置物台上所設置的物品數量則為被分流出去的物品數量", + "create.ponder.weighted_ejector_tunnel.text_4": "當所設置的物品數量被分流出去後...", + "create.ponder.weighted_ejector_tunnel.text_5": "...剩餘的物品則會繼續前進", + + "create.ponder.windmill_source.header": "使用風車軸承產生動能", + "create.ponder.windmill_source.text_1": "風車軸承會黏著它面前的方塊結構", + "create.ponder.windmill_source.text_2": "如果黏著的方塊結構包含足夠的風帆方塊即為風車", + "create.ponder.windmill_source.text_3": "右鍵啟動風車後,風車開始提供動能", + "create.ponder.windmill_source.text_4": "產生的動能將取決於所黏風帆方塊之數量", + "create.ponder.windmill_source.text_5": "使用扳手來調整其旋轉方向", + "create.ponder.windmill_source.text_6": "對風車軸承右鍵可使其停止方便你維修風車", + + "create.ponder.windmill_structure.header": "風車結構", + "create.ponder.windmill_structure.text_1": "任一包含至少8個風帆方塊的結構即為有效的風車", "_": "Thank you for translating Create!" diff --git a/src/generated/resources/data/minecraft/tags/items/piglin_loved.json b/src/generated/resources/data/minecraft/tags/items/piglin_loved.json new file mode 100644 index 000000000..478bada69 --- /dev/null +++ b/src/generated/resources/data/minecraft/tags/items/piglin_loved.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "create:golden_sheet", + "create:crushed_gold_ore" + ] +} \ No newline at end of file From 975d898ac618ccc8c187b785d09678efb38f5f7c Mon Sep 17 00:00:00 2001 From: zelophed Date: Fri, 28 May 2021 14:42:27 +0200 Subject: [PATCH 107/198] all the configs - make it easier for addon devs to hook into create's config ui - change the config command to allow for: - opening any mod's registered config - changing single values at a time - possibly solve incompatibility with CalemiUtils mod and placement helpers --- .../simibubi/create/events/ClientEvents.java | 6 +- .../foundation/command/ConfigCommand.java | 73 ++++++++- .../command/SConfigureConfigPacket.java | 58 ++++++- .../config/ui/BaseConfigScreen.java | 132 +++++++++++++--- .../config/ui/CConfigureConfigPacket.java | 41 +++-- .../foundation/config/ui/ConfigHelper.java | 142 ++++++++++++++++++ .../foundation/config/ui/ConfigScreen.java | 1 + .../config/ui/OpenConfigButton.java | 12 +- .../config/ui/SubMenuConfigScreen.java | 46 +++++- .../config/ui/entries/ValueEntry.java | 12 +- .../foundation/gui/ConfirmationScreen.java | 13 +- .../utility/placement/PlacementOffset.java | 8 +- 12 files changed, 468 insertions(+), 76 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java diff --git a/src/main/java/com/simibubi/create/events/ClientEvents.java b/src/main/java/com/simibubi/create/events/ClientEvents.java index 30db2de2a..cdfb70268 100644 --- a/src/main/java/com/simibubi/create/events/ClientEvents.java +++ b/src/main/java/com/simibubi/create/events/ClientEvents.java @@ -106,7 +106,7 @@ public class ClientEvents { AirCurrent.tickClientPlayerSounds(); return; } - + SoundScapes.tick(); AnimationTickHolder.tick(); @@ -339,8 +339,8 @@ public class ClientEvents { } public static void loadCompleted(FMLLoadCompleteEvent event) { - ModContainer createContainer = ModList.get().getModContainerById("create").orElseThrow(() -> new IllegalStateException("Create Mod Container missing after loadCompleted")); - createContainer.registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (mc, previousScreen) -> new BaseConfigScreen(previousScreen)); + ModContainer createContainer = ModList.get().getModContainerById(Create.ID).orElseThrow(() -> new IllegalStateException("Create Mod Container missing after loadCompleted")); + createContainer.registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (mc, previousScreen) -> BaseConfigScreen.forCreate(previousScreen)); } } diff --git a/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java b/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java index 24a45110a..5115d9d6f 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ConfigCommand.java @@ -1,14 +1,25 @@ package com.simibubi.create.foundation.command; +import com.mojang.brigadier.Command; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.builder.ArgumentBuilder; +import com.simibubi.create.Create; +import com.simibubi.create.foundation.config.ui.ConfigHelper; +import com.simibubi.create.foundation.networking.AllPackets; + import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.util.text.StringTextComponent; +import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.network.PacketDistributor; -import com.mojang.brigadier.Command; -import com.mojang.brigadier.builder.ArgumentBuilder; -import com.simibubi.create.foundation.networking.AllPackets; - +/** + * Examples: + * /create config client - to open Create's ConfigGui with the client config already selected + * /create config "botania:common" - to open Create's ConfigGui with Botania's common config already selected + * /create config "create:client.client.rainbowDebug" set false - to disable Create's rainbow debug for the sender + */ public class ConfigCommand { public static ArgumentBuilder register() { @@ -21,7 +32,59 @@ public class ConfigCommand { ); return Command.SINGLE_SUCCESS; - }); + }) + .then(Commands.argument("path", StringArgumentType.string()) + .executes(ctx -> { + ServerPlayerEntity player = ctx.getSource().asPlayer(); + AllPackets.channel.send( + PacketDistributor.PLAYER.with(() -> player), + new SConfigureConfigPacket(SConfigureConfigPacket.Actions.configScreen.name(), StringArgumentType.getString(ctx, "path")) + ); + + return Command.SINGLE_SUCCESS; + }) + .then(Commands.literal("set") + .requires(cs -> cs.hasPermissionLevel(2)) + .then(Commands.argument("value", StringArgumentType.string()) + .executes(ctx -> { + String path = StringArgumentType.getString(ctx, "path"); + String value = StringArgumentType.getString(ctx, "value"); + + + ConfigHelper.ConfigPath configPath; + try { + configPath = ConfigHelper.ConfigPath.parse(path); + } catch (IllegalArgumentException e) { + ctx.getSource().sendErrorMessage(new StringTextComponent(e.getMessage())); + return 0; + } + + if (configPath.getType() == ModConfig.Type.CLIENT) { + ServerPlayerEntity player = ctx.getSource().asPlayer(); + AllPackets.channel.send( + PacketDistributor.PLAYER.with(() -> player), + new SConfigureConfigPacket("SET" + path, value) + ); + + return Command.SINGLE_SUCCESS; + } + + try { + ConfigHelper.setConfigValue(configPath, value); + ctx.getSource().sendFeedback(new StringTextComponent("Great Success!"), false); + return Command.SINGLE_SUCCESS; + } catch (ConfigHelper.InvalidValueException e) { + ctx.getSource().sendErrorMessage(new StringTextComponent("Config could not be set the the specified value!")); + return 0; + } catch (Exception e) { + ctx.getSource().sendErrorMessage(new StringTextComponent("Something went wrong while trying to set config value. Check the server logs for more information")); + Create.LOGGER.warn("Exception during server-side config value set:", e); + return 0; + } + }) + ) + ) + ); } } diff --git a/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java b/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java index d4e1a6115..55283402c 100644 --- a/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/foundation/command/SConfigureConfigPacket.java @@ -9,6 +9,8 @@ import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.goggles.GoggleConfigScreen; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.ui.BaseConfigScreen; +import com.simibubi.create.foundation.config.ui.ConfigHelper; +import com.simibubi.create.foundation.config.ui.SubMenuConfigScreen; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.networking.SimplePacketBase; import com.simibubi.create.foundation.ponder.PonderRegistry; @@ -30,6 +32,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ForgeConfig; import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.network.NetworkEvent; public class SConfigureConfigPacket extends SimplePacketBase { @@ -57,6 +60,11 @@ public class SConfigureConfigPacket extends SimplePacketBase { public void handle(Supplier ctx) { ctx.get() .enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { + if (option.startsWith("SET")) { + trySetConfig(option.substring(3), value); + return; + } + try { Actions.valueOf(option) .performAction(value); @@ -70,6 +78,36 @@ public class SConfigureConfigPacket extends SimplePacketBase { .setPacketHandled(true); } + private static void trySetConfig(String option, String value) { + ClientPlayerEntity player = Minecraft.getInstance().player; + if (player == null) + return; + + ConfigHelper.ConfigPath configPath; + try { + configPath = ConfigHelper.ConfigPath.parse(option); + } catch (IllegalArgumentException e) { + player.sendStatusMessage(new StringTextComponent(e.getMessage()), false); + return; + } + + if (configPath.getType() != ModConfig.Type.CLIENT) { + Create.LOGGER.warn("Received type-mismatched config packet on client"); + return; + } + + try { + ConfigHelper.setConfigValue(configPath, value); + player.sendStatusMessage(new StringTextComponent("Great Success!"), false); + } catch (ConfigHelper.InvalidValueException e) { + player.sendStatusMessage(new StringTextComponent("Config could not be set the the specified value!"), false); + } catch (Exception e) { + player.sendStatusMessage(new StringTextComponent("Something went wrong while trying to set config value. Check the client logs for more information"), false); + Create.LOGGER.warn("Exception during client-side config value set:", e); + } + + } + public enum Actions { configScreen(() -> Actions::configScreen), rainbowDebug(() -> Actions::rainbowDebug), @@ -95,7 +133,25 @@ public class SConfigureConfigPacket extends SimplePacketBase { @OnlyIn(Dist.CLIENT) private static void configScreen(String value) { - ScreenOpener.open(new BaseConfigScreen(null)); + if (value.equals("")) { + ScreenOpener.open(BaseConfigScreen.forCreate(null)); + return; + } + + ClientPlayerEntity player = Minecraft.getInstance().player; + ConfigHelper.ConfigPath configPath; + try { + configPath = ConfigHelper.ConfigPath.parse(value); + } catch (IllegalArgumentException e) { + player.sendStatusMessage(new StringTextComponent(e.getMessage()), false); + return; + } + + try { + ScreenOpener.open(SubMenuConfigScreen.find(configPath)); + } catch (Exception e) { + player.sendStatusMessage(new StringTextComponent("Unable to find the specified config"), false); + } } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java index 915abcb38..6507c2820 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/BaseConfigScreen.java @@ -1,6 +1,11 @@ package com.simibubi.create.foundation.config.ui; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.simibubi.create.Create; import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.foundation.gui.DelegatedStencilElement; import com.simibubi.create.foundation.gui.ScreenOpener; import com.simibubi.create.foundation.gui.TextStencilElement; import com.simibubi.create.foundation.gui.Theme; @@ -11,49 +16,134 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.config.ModConfig; public class BaseConfigScreen extends ConfigScreen { + private static final DelegatedStencilElement.ElementRenderer DISABLED_RENDERER = (ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, height, width, Theme.i(Theme.Key.BUTTON_DISABLE, true), Theme.i(Theme.Key.BUTTON_DISABLE, false) | 0x40_000000); + + public static BaseConfigScreen forCreate(Screen parent) { + return new BaseConfigScreen(parent) + .withTitles("Client Settings", "World Generation Settings", "Gameplay Settings") + .withSpecs(AllConfigs.CLIENT.specification, AllConfigs.COMMON.specification, AllConfigs.SERVER.specification); + } + BoxWidget clientConfigWidget; BoxWidget commonConfigWidget; BoxWidget serverConfigWidget; - public BaseConfigScreen(Screen parent) { + ForgeConfigSpec clientSpec; + ForgeConfigSpec commonSpec; + ForgeConfigSpec serverSpec; + String clientTile = "CLIENT CONFIG"; + String commonTile = "COMMON CONFIG"; + String serverTile = "SERVER CONFIG"; + String modID = Create.ID; + + /** + * If you are a Create Addon dev and want to make use of the same GUI + * for your mod's config, use this Constructor to create a entry point + * + * @param parent the previously opened screen + * @param modID the modID of your addon/mod + */ + public BaseConfigScreen(Screen parent, @Nonnull String modID) { + this(parent); + this.modID = modID; + } + + private BaseConfigScreen(Screen parent) { super(parent); } + /** + * If you have static references to your Configs or ConfigSpecs (like Create does in {@link AllConfigs}), + * please use {@link #withSpecs(ForgeConfigSpec, ForgeConfigSpec, ForgeConfigSpec)} instead + */ + public BaseConfigScreen searchForSpecsInModContainer() { + try { + clientSpec = ConfigHelper.findConfigSpecFor(ModConfig.Type.CLIENT, this.modID); + } catch (Exception e) { + Create.LOGGER.warn("Unable to find ClientConfigSpec for mod: " + this.modID); + } + + try { + commonSpec = ConfigHelper.findConfigSpecFor(ModConfig.Type.COMMON, this.modID); + } catch (Exception e) { + Create.LOGGER.warn("Unable to find CommonConfigSpec for mod: " + this.modID, e); + } + + try { + serverSpec = ConfigHelper.findConfigSpecFor(ModConfig.Type.SERVER, this.modID); + } catch (Exception e) { + Create.LOGGER.warn("Unable to find ServerConfigSpec for mod: " + this.modID, e); + } + + return this; + } + + public BaseConfigScreen withSpecs(@Nullable ForgeConfigSpec client, @Nullable ForgeConfigSpec common, @Nullable ForgeConfigSpec server) { + clientSpec = client; + commonSpec = common; + serverSpec = server; + return this; + } + + public BaseConfigScreen withTitles(@Nullable String client, @Nullable String common, @Nullable String server) { + if (client != null) + clientTile = client; + + if (common != null) + commonTile = common; + + if (server != null) + serverTile = server; + + return this; + } + @Override protected void init() { widgets.clear(); super.init(); - TextStencilElement text = new TextStencilElement(client.fontRenderer, new StringTextComponent("Client Settings").formatted(TextFormatting.BOLD)).centered(true, true); - widgets.add(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16) - .showingElement(text) - .withCallback(() -> ScreenOpener.open(new SubMenuConfigScreen(this, ModConfig.Type.CLIENT, AllConfigs.CLIENT.specification))) - ); - text.withElementRenderer(BoxWidget.gradientFactory.apply(clientConfigWidget)); + TextStencilElement clientText = new TextStencilElement(client.fontRenderer, new StringTextComponent(clientTile).formatted(TextFormatting.BOLD)).centered(true, true); + widgets.add(clientConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 - 30, 200, 16).showingElement(clientText)); - TextStencilElement text2 = new TextStencilElement(client.fontRenderer, new StringTextComponent("World Generation Settings").formatted(TextFormatting.BOLD)).centered(true, true); - widgets.add(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 16) - .showingElement(text2) - .withCallback(() -> ScreenOpener.open(new SubMenuConfigScreen(this, ModConfig.Type.COMMON, AllConfigs.COMMON.specification))) - ); - text2.withElementRenderer(BoxWidget.gradientFactory.apply(commonConfigWidget)); + if (clientSpec != null) { + clientConfigWidget.withCallback(() -> ScreenOpener.open(new SubMenuConfigScreen(this, ModConfig.Type.CLIENT, clientSpec))); + clientText.withElementRenderer(BoxWidget.gradientFactory.apply(clientConfigWidget)); + } else { + clientConfigWidget.active = false; + clientConfigWidget.updateColorsFromState(); + clientText.withElementRenderer(DISABLED_RENDERER); + } - TextStencilElement text3 = new TextStencilElement(client.fontRenderer, new StringTextComponent("Gameplay Settings").formatted(TextFormatting.BOLD)).centered(true, true); - widgets.add(serverConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 + 30, 200, 16) - .showingElement(text3) - ); + TextStencilElement commonText = new TextStencilElement(client.fontRenderer, new StringTextComponent(commonTile).formatted(TextFormatting.BOLD)).centered(true, true); + widgets.add(commonConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15, 200, 16).showingElement(commonText)); - if (Minecraft.getInstance().world != null) { - serverConfigWidget.withCallback(() -> ScreenOpener.open(new SubMenuConfigScreen(this, ModConfig.Type.SERVER, AllConfigs.SERVER.specification))); - text3.withElementRenderer(BoxWidget.gradientFactory.apply(serverConfigWidget)); + if (commonSpec != null) { + commonConfigWidget.withCallback(() -> ScreenOpener.open(new SubMenuConfigScreen(this, ModConfig.Type.COMMON, commonSpec))); + commonText.withElementRenderer(BoxWidget.gradientFactory.apply(commonConfigWidget)); + } else { + commonConfigWidget.active = false; + commonConfigWidget.updateColorsFromState(); + commonText.withElementRenderer(DISABLED_RENDERER); + } + + TextStencilElement serverText = new TextStencilElement(client.fontRenderer, new StringTextComponent(serverTile).formatted(TextFormatting.BOLD)).centered(true, true); + widgets.add(serverConfigWidget = new BoxWidget(width / 2 - 100, height / 2 - 15 + 30, 200, 16).showingElement(serverText)); + + if (serverSpec != null && Minecraft.getInstance().world != null) { + serverConfigWidget.withCallback(() -> ScreenOpener.open(new SubMenuConfigScreen(this, ModConfig.Type.SERVER, serverSpec))); + serverText.withElementRenderer(BoxWidget.gradientFactory.apply(serverConfigWidget)); } else { serverConfigWidget.active = false; serverConfigWidget.updateColorsFromState(); - text3.withElementRenderer((ms, width, height, alpha) -> UIRenderHelper.angledGradient(ms, 0, 0, height / 2, height, width, Theme.i(Theme.Key.BUTTON_DISABLE, true), Theme.i(Theme.Key.BUTTON_DISABLE, false) | 0x40_000000)); + serverText.withElementRenderer(DISABLED_RENDERER); } + + ConfigScreen.modID = this.modID; } } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java b/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java index c1a475d29..b472b0a70 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/CConfigureConfigPacket.java @@ -1,54 +1,65 @@ package com.simibubi.create.foundation.config.ui; +import java.util.Objects; import java.util.function.Supplier; -import com.simibubi.create.foundation.command.SConfigureConfigPacket; -import com.simibubi.create.foundation.config.AllConfigs; -import com.simibubi.create.foundation.networking.AllPackets; +import com.simibubi.create.Create; import com.simibubi.create.foundation.networking.SimplePacketBase; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.network.PacketBuffer; import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.network.NetworkEvent; -import net.minecraftforge.fml.network.PacketDistributor; public class CConfigureConfigPacket extends SimplePacketBase { + private String modID; private String path; private String value; - public CConfigureConfigPacket(String path, T value) { + public CConfigureConfigPacket(String modID, String path, T value) { + this.modID = Objects.requireNonNull(modID); this.path = path; this.value = serialize(value); } public CConfigureConfigPacket(PacketBuffer buffer) { + this.modID = buffer.readString(32767); this.path = buffer.readString(32767); this.value = buffer.readString(32767); } @Override public void write(PacketBuffer buffer) { + buffer.writeString(modID); buffer.writeString(path); buffer.writeString(value); } @Override public void handle(Supplier context) { - ServerPlayerEntity sender = context.get().getSender(); - if (sender == null || !sender.hasPermissionLevel(2)) - return; + context.get().enqueueWork(() -> { + try { + ServerPlayerEntity sender = context.get().getSender(); + if (sender == null || !sender.hasPermissionLevel(2)) + return; - ForgeConfigSpec.ValueSpec valueSpec = AllConfigs.SERVER.specification.getRaw(path); - ForgeConfigSpec.ConfigValue configValue = AllConfigs.SERVER.specification.getValues().get(path); + ForgeConfigSpec spec = ConfigHelper.findConfigSpecFor(ModConfig.Type.SERVER, modID); + ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw(path); + ForgeConfigSpec.ConfigValue configValue = spec.getValues().get(path); - T v = (T) deserialize(configValue.get(), value); - if (!valueSpec.test(v)) - return; + T v = (T) deserialize(configValue.get(), value); + if (!valueSpec.test(v)) + return; - configValue.set(v); + configValue.set(v); + } catch (Exception e) { + Create.LOGGER.warn("Unable to handle ConfigureConfig Packet. ", e); + } + }); + context.get().setPacketHandled(true); } public String serialize(T value) { @@ -66,7 +77,7 @@ public class CConfigureConfigPacket extends SimplePacketBase { throw new IllegalArgumentException("unknown type " + value + ": " + value.getClass().getSimpleName()); } - public Object deserialize(Object type, String sValue) { + public static Object deserialize(Object type, String sValue) { if (type instanceof Boolean) return Boolean.parseBoolean(sValue); if (type instanceof Enum) diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java new file mode 100644 index 000000000..57a52417f --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigHelper.java @@ -0,0 +1,142 @@ +package com.simibubi.create.foundation.config.ui; + +import java.util.Arrays; +import java.util.EnumMap; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Nonnull; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.simibubi.create.Create; +import com.simibubi.create.foundation.config.AllConfigs; + +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.common.ObfuscationReflectionHelper; +import net.minecraftforge.fml.config.ModConfig; + +public class ConfigHelper { + + private static final LoadingCache> configCache = CacheBuilder.newBuilder().expireAfterAccess(15, TimeUnit.SECONDS).build( + new CacheLoader>() { + @Override + public EnumMap load(@Nonnull String key) { + return findModConfigsUncached(key); + } + } + ); + + private static EnumMap findModConfigsUncached(String modID) { + ModContainer modContainer = ModList.get().getModContainerById(modID).orElseThrow(() -> new IllegalArgumentException("Unable to find ModContainer for id: " + modID)); + EnumMap configs = ObfuscationReflectionHelper.getPrivateValue(ModContainer.class, modContainer, "configs"); + return Objects.requireNonNull(configs); + } + + public static ForgeConfigSpec findConfigSpecFor(ModConfig.Type type, String modID) { + if (!modID.equals(Create.ID)) + return configCache.getUnchecked(modID).get(type).getSpec(); + + switch (type) { + case COMMON: + return AllConfigs.COMMON.specification; + case CLIENT: + return AllConfigs.CLIENT.specification; + case SERVER: + return AllConfigs.SERVER.specification; + } + + return null; + } + + //Directly set a value + public static void setConfigValue(ConfigPath path, String value) throws InvalidValueException { + ForgeConfigSpec spec = findConfigSpecFor(path.getType(), path.getModID()); + List pathList = Arrays.asList(path.getPath()); + ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw(pathList); + ForgeConfigSpec.ConfigValue configValue = spec.getValues().get(pathList); + T v = (T) CConfigureConfigPacket.deserialize(configValue.get(), value); + if (!valueSpec.test(v)) + throw new InvalidValueException(); + + configValue.set(v); + } + + //Add a value to the current UI's changes list + public static void setValue(String path, ForgeConfigSpec.ConfigValue configValue, T value) { + if (value.equals(configValue.get())) { + ConfigScreen.changes.remove(path); + } else { + ConfigScreen.changes.put(path, value); + } + } + + //Get a value from the current UI's changes list or the config value, if its unchanged + public static T getValue(String path, ForgeConfigSpec.ConfigValue configValue) { + //noinspection unchecked + return (T) ConfigScreen.changes.getOrDefault(path, configValue.get()); + } + + public static class ConfigPath { + private String modID = Create.ID; + private ModConfig.Type type = ModConfig.Type.CLIENT; + private String[] path; + + public static ConfigPath parse(String string) { + ConfigPath cp = new ConfigPath(); + String p = string; + int index = string.indexOf(":"); + if (index >= 0) { + p = string.substring(index + 1); + if (index >= 1) { + cp.modID = string.substring(0, index); + } + } + String[] split = p.split("\\."); + try { + cp.type = ModConfig.Type.valueOf(split[0].toUpperCase(Locale.ROOT)); + } catch (Exception e) { + throw new IllegalArgumentException("path must start with either 'client.', 'common.' or 'server.'"); + } + + cp.path = new String[split.length - 1]; + System.arraycopy(split, 1, cp.path, 0, cp.path.length); + + return cp; + } + + public ConfigPath setID(String modID) { + this.modID = modID; + return this; + } + + public ConfigPath setType(ModConfig.Type type) { + this.type = type; + return this; + } + + public ConfigPath setPath(String[] path) { + this.path = path; + return this; + } + + public String getModID() { + return modID; + } + + public ModConfig.Type getType() { + return type; + } + + public String[] getPath() { + return path; + } + } + + public static class InvalidValueException extends Exception {} +} diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java index 98086a786..ecdcad3eb 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/ConfigScreen.java @@ -41,6 +41,7 @@ public abstract class ConfigScreen extends AbstractSimiScreen { public static final PhysicalFloat cogSpin = PhysicalFloat.create().withDrag(0.3).addForce(new Force.Static(.2f)); public static final BlockState cogwheelState = AllBlocks.LARGE_COGWHEEL.getDefaultState().with(CogWheelBlock.AXIS, Direction.Axis.Y); public static final Map changes = new HashMap<>(); + public static String modID = null; protected final Screen parent; public ConfigScreen(Screen parent) { diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/OpenConfigButton.java b/src/main/java/com/simibubi/create/foundation/config/ui/OpenConfigButton.java index 07dd44942..52c571796 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/OpenConfigButton.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/OpenConfigButton.java @@ -1,9 +1,11 @@ package com.simibubi.create.foundation.config.ui; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + import com.mojang.blaze3d.matrix.MatrixStack; - import com.simibubi.create.AllItems; - import com.simibubi.create.foundation.config.AllConfigs; import net.minecraft.client.Minecraft; @@ -19,10 +21,6 @@ import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - public class OpenConfigButton extends Button { public static ItemStack icon = AllItems.GOGGLES.asStack(); @@ -38,7 +36,7 @@ public class OpenConfigButton extends Button { } public static void click(Button b) { - Minecraft.getInstance().displayGuiScreen(new BaseConfigScreen(Minecraft.getInstance().currentScreen)); + Minecraft.getInstance().displayGuiScreen(BaseConfigScreen.forCreate(Minecraft.getInstance().currentScreen)); } public static class SingleMenuRow { diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java index e27502281..a8adcdc1f 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/SubMenuConfigScreen.java @@ -1,6 +1,9 @@ package com.simibubi.create.foundation.config.ui; import java.awt.Color; +import java.util.List; +import java.util.Locale; +import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -9,6 +12,7 @@ import org.lwjgl.glfw.GLFW; import com.electronwill.nightconfig.core.AbstractConfig; import com.electronwill.nightconfig.core.UnmodifiableConfig; +import com.google.common.collect.Lists; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.config.ui.entries.BooleanEntry; import com.simibubi.create.foundation.config.ui.entries.EnumEntry; @@ -50,6 +54,37 @@ public class SubMenuConfigScreen extends ConfigScreen { protected int listWidth; protected String title; + public static SubMenuConfigScreen find(ConfigHelper.ConfigPath path) { + ForgeConfigSpec spec = ConfigHelper.findConfigSpecFor(path.getType(), path.getModID()); + UnmodifiableConfig values = spec.getValues(); + BaseConfigScreen base = new BaseConfigScreen(null, path.getModID()).searchForSpecsInModContainer(); + SubMenuConfigScreen screen = new SubMenuConfigScreen(base, "root", path.getType(), spec, values); + List remainingPath = Lists.newArrayList(path.getPath()); + + path: while (!remainingPath.isEmpty()) { + String next = remainingPath.remove(0); + for (Map.Entry entry : values.valueMap().entrySet()) { + String key = entry.getKey(); + Object obj = entry.getValue(); + if (!key.equalsIgnoreCase(next)) + continue; + + if (!(obj instanceof AbstractConfig)) { + //highlight entry + continue; + } + + values = (UnmodifiableConfig) obj; + screen = new SubMenuConfigScreen(screen, toHumanReadable(key), path.getType(), spec, values); + continue path; + } + + break; + } + + ConfigScreen.modID = path.getModID(); + return screen; + } public SubMenuConfigScreen(Screen parent, String title, ModConfig.Type type, ForgeConfigSpec configSpec, UnmodifiableConfig configGroup) { super(parent); @@ -81,7 +116,7 @@ public class SubMenuConfigScreen extends ConfigScreen { ForgeConfigSpec.ConfigValue configValue = values.get(path); configValue.set(value); if (type == ModConfig.Type.SERVER) { - AllPackets.channel.sendToServer(new CConfigureConfigPacket<>(path, value)); + AllPackets.channel.sendToServer(new CConfigureConfigPacket<>(ConfigScreen.modID, path, value)); } }); clearChanges(); @@ -92,11 +127,10 @@ public class SubMenuConfigScreen extends ConfigScreen { if (obj instanceof AbstractConfig) { resetConfig((UnmodifiableConfig) obj); } else if (obj instanceof ForgeConfigSpec.ConfigValue) { - ForgeConfigSpec.ConfigValue configValue = (ForgeConfigSpec.ConfigValue) obj; - ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw(configValue.getPath()); + ForgeConfigSpec.ConfigValue configValue = (ForgeConfigSpec.ConfigValue) obj; + ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw((List) configValue.getPath()); - if (!configValue.get().equals(valueSpec.getDefault())) - changes.put(String.join(".", configValue.getPath()), valueSpec.getDefault()); + ConfigHelper.setValue(String.join(".", configValue.getPath()), configValue, valueSpec.getDefault()); } }); @@ -265,7 +299,7 @@ public class SubMenuConfigScreen extends ConfigScreen { super.renderWindow(ms, mouseX, mouseY, partialTicks); int x = width/2; - drawCenteredString(ms, client.fontRenderer, "Editing config: " + type.toString() + "@" + title, x, 15, Theme.i(Theme.Key.TEXT)); + drawCenteredString(ms, client.fontRenderer, "Editing config: " + ConfigScreen.modID + ":" + type.toString().toLowerCase(Locale.ROOT) + "@" + title, x, 15, Theme.i(Theme.Key.TEXT)); list.render(ms, mouseX, mouseY, partialTicks); } diff --git a/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java b/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java index 6f6f89093..48d1d86a0 100644 --- a/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java +++ b/src/main/java/com/simibubi/create/foundation/config/ui/entries/ValueEntry.java @@ -11,6 +11,7 @@ import javax.annotation.Nonnull; import org.apache.commons.lang3.ArrayUtils; import com.mojang.blaze3d.matrix.MatrixStack; +import com.simibubi.create.foundation.config.ui.ConfigHelper; import com.simibubi.create.foundation.config.ui.ConfigScreen; import com.simibubi.create.foundation.config.ui.ConfigScreenList; import com.simibubi.create.foundation.gui.AllIcons; @@ -115,20 +116,13 @@ public class ValueEntry extends ConfigScreenList.LabeledEntry { } public void setValue(@Nonnull T value) { - if (value.equals(this.value.get())) { - ConfigScreen.changes.remove(path); - onValueChange(value); - return; - } - - ConfigScreen.changes.put(path, value); + ConfigHelper.setValue(path, this.value, value); onValueChange(value); } @Nonnull public T getValue() { - //noinspection unchecked - return (T) ConfigScreen.changes.getOrDefault(path, this.value.get()); + return ConfigHelper.getValue(path, this.value); } protected boolean isCurrentValueChanged() { diff --git a/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java b/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java index e7b5b48cf..b0cfe2ffa 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ConfirmationScreen.java @@ -99,6 +99,14 @@ public class ConfirmationScreen extends AbstractSimiScreen { textHeight = text.size() * (client.fontRenderer.FONT_HEIGHT + 1) + 4; textWidth = 300; + if (centered) { + x = width/2 - textWidth/2 - 2; + y = height/2 - textHeight/2 - 16; + } else { + x = Math.max(0, x - textWidth / 2); + y = Math.max(0, y -= textHeight); + } + if (x + textWidth > width) { x = width - textWidth; } @@ -107,11 +115,6 @@ public class ConfirmationScreen extends AbstractSimiScreen { y = height - textHeight - 30; } - if (centered) { - x = width/2 - textWidth/2 - 2; - y = height/2 - textHeight/2 - 16; - } - TextStencilElement confirmText = new TextStencilElement(client.fontRenderer, "Confirm").centered(true, true); confirm = new BoxWidget(x + 4, y + textHeight + 2 , textWidth/2 - 10, 20) .withCallback(() -> accept(true)); diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java index ee7fa842e..17fd6505c 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java @@ -102,12 +102,15 @@ public class PlacementOffset { return world.getBlockState(new BlockPos(pos)).getMaterial().isReplaceable(); } - + public ActionResultType placeInWorld(World world, BlockItem blockItem, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { if (!isReplaceable(world)) return ActionResultType.PASS; + if (world.isRemote) + return ActionResultType.SUCCESS; + ItemUseContext context = new ItemUseContext(player, hand, ray); BlockPos newPos = new BlockPos(pos); @@ -135,9 +138,6 @@ public class PlacementOffset { player.addStat(Stats.ITEM_USED.get(blockItem)); - if (world.isRemote) - return ActionResultType.SUCCESS; - if (player instanceof ServerPlayerEntity) CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) player, newPos, context.getItem()); From 0aaa09260b76c69da252ca96295b2c29534cdda3 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Fri, 28 May 2021 14:42:47 -0400 Subject: [PATCH 108/198] Fix minecart coupling item dupe --- .../structureMovement/train/MinecartCouplingItem.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartCouplingItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartCouplingItem.java index d421c8fb1..66986c18d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartCouplingItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/MinecartCouplingItem.java @@ -4,6 +4,8 @@ import com.simibubi.create.AllItems; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; +import com.simibubi.create.foundation.utility.Iterate; + import net.minecraft.entity.Entity; import net.minecraft.entity.item.minecart.AbstractMinecartEntity; import net.minecraft.entity.player.PlayerEntity; @@ -78,6 +80,11 @@ public class MinecartCouplingItem extends Item { if (event.getWorld().isRemote) return true; + for (boolean forward : Iterate.trueAndFalse) { + if (controller.hasContraptionCoupling(forward)) + couplings--; + } + CouplingHandler.status(player, "removed"); controller.decouple(); if (!player.isCreative()) From 55abcde5d5d8816bdd9582a9b9b15300be1b8a84 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Fri, 28 May 2021 23:27:44 -0400 Subject: [PATCH 109/198] Allow block breakers to work at center of bearing --- .../structureMovement/ControlledContraptionEntity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java index 4d70938b2..dbdef7a30 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java @@ -34,6 +34,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { protected Axis rotationAxis; protected float prevAngle; protected float angle; + protected float angleDelta; public ControlledContraptionEntity(EntityType type, World world) { super(type, world); @@ -130,9 +131,10 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { public void setPositionAndRotationDirect(double x, double y, double z, float yw, float pt, int inc, boolean t) {} protected void tickContraption() { + angleDelta = angle - prevAngle; prevAngle = angle; tickActors(); - + if (controllerPos == null) return; if (!world.isBlockPresent(controllerPos)) @@ -171,7 +173,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { return false; if (!VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis())) return false; - context.motion = Vector3d.of(facing.getDirectionVec()).scale(angle - prevAngle); + context.motion = Vector3d.of(facing.getDirectionVec()).scale(angleDelta / 360.0); context.relativeMotion = context.motion; int timer = context.data.getInt("StationaryTimer"); if (timer > 0) { From 9235aa93babcdbe1e4838af14ca391e4a7ef28ac Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Fri, 28 May 2021 23:10:12 -0700 Subject: [PATCH 110/198] JEI Fixes - Fix #1661: blasting-only recipes would not be shown under the bulk blasting category - Add ability to remove matching recipes by type while using the category builder - Fix fan catalyst items being italicized - Add and tweak some visibility modifiers --- build.gradle | 4 +- .../simibubi/create/compat/jei/CreateJEI.java | 167 +++++++++++------- .../jei/category/CreateRecipeCategory.java | 18 +- .../category/ProcessingViaFanCategory.java | 3 +- 4 files changed, 111 insertions(+), 81 deletions(-) diff --git a/build.gradle b/build.gradle index c1c180826..fb82fdcf8 100644 --- a/build.gradle +++ b/build.gradle @@ -130,8 +130,8 @@ dependencies { // i'll leave this here commented for easier testing //runtimeOnly fg.deobf("vazkii.arl:AutoRegLib:1.4-35.69") //runtimeOnly fg.deobf("vazkii.quark:Quark:r2.0-212.984") - // runtimeOnly fg.deobf("slimeknights.mantle:Mantle:1.16.3-1.6.40") - // runtimeOnly fg.deobf("slimeknights.tconstruct:TConstruct:1.16.3-3.0.1.24") + //runtimeOnly fg.deobf("slimeknights.mantle:Mantle:1.16.5-1.6.103") + //runtimeOnly fg.deobf("slimeknights.tconstruct:TConstruct:1.16.5-3.0.3.168") annotationProcessor 'org.spongepowered:mixin:0.8:processor' } diff --git a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java index 5d545b40f..7cbb79a56 100644 --- a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java +++ b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java @@ -1,8 +1,8 @@ package com.simibubi.create.compat.jei; import java.util.ArrayList; -import java.util.Collections; import java.util.List; +import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; @@ -81,12 +81,12 @@ public class CreateJEI implements IModPlugin { } public IIngredientManager ingredientManager; - final List> ALL = new ArrayList<>(); - final CreateRecipeCategory + private final List> allCategories = new ArrayList<>(); + private final CreateRecipeCategory - milling = register("milling", MillingCategory::new).recipes(AllRecipeTypes.MILLING) - .catalyst(AllBlocks.MILLSTONE::get) - .build(), + milling = register("milling", MillingCategory::new).recipes(AllRecipeTypes.MILLING) + .catalyst(AllBlocks.MILLSTONE::get) + .build(), crushing = register("crushing", CrushingCategory::new).recipes(AllRecipeTypes.CRUSHING) .recipesExcluding(AllRecipeTypes.MILLING::getType, AllRecipeTypes.CRUSHING::getType) @@ -106,7 +106,9 @@ public class CreateJEI implements IModPlugin { .build(), blasting = register("fan_blasting", FanBlastingCategory::new) - .recipesExcluding(() -> IRecipeType.SMELTING, () -> IRecipeType.SMOKING) + .recipesExcluding(() -> IRecipeType.SMELTING, () -> IRecipeType.BLASTING) + .recipes(() -> IRecipeType.BLASTING) + .removeRecipes(() -> IRecipeType.SMOKING) .catalystStack(ProcessingViaFanCategory.getFan("fan_blasting")) .build(), @@ -213,20 +215,21 @@ public class CreateJEI implements IModPlugin { @Override public void registerCategories(IRecipeCategoryRegistration registration) { - ALL.forEach(registration::addRecipeCategories); + allCategories.forEach(registration::addRecipeCategories); } @Override public void registerRecipes(IRecipeRegistration registration) { ingredientManager = registration.getIngredientManager(); - ALL.forEach(c -> c.recipes.forEach(s -> registration.addRecipes(s.get(), c.getUid()))); + allCategories.forEach(c -> c.recipes.forEach(s -> registration.addRecipes(s.get(), c.getUid()))); } @Override public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { - ALL.forEach(c -> c.recipeCatalysts.forEach(s -> registration.addRecipeCatalyst(s.get(), c.getUid()))); + allCategories.forEach(c -> c.recipeCatalysts.forEach(s -> registration.addRecipeCatalyst(s.get(), c.getUid()))); } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void registerGuiHandlers(IGuiHandlerRegistration registration) { SlotMover slotMover = new SlotMover(); @@ -239,98 +242,106 @@ public class CreateJEI implements IModPlugin { } private class CategoryBuilder> { - CreateRecipeCategory category; + private CreateRecipeCategory category; + private List>>> recipeListConsumers = new ArrayList<>(); private Predicate pred; - CategoryBuilder(String name, Supplier> category) { + public CategoryBuilder(String name, Supplier> category) { this.category = category.get(); this.category.setCategoryId(name); - this.pred = Predicates.alwaysTrue(); + pred = Predicates.alwaysTrue(); } - CategoryBuilder catalyst(Supplier supplier) { - return catalystStack(() -> new ItemStack(supplier.get() - .asItem())); - } - - CategoryBuilder catalystStack(Supplier supplier) { - category.recipeCatalysts.add(supplier); - return this; - } - - CategoryBuilder recipes(AllRecipeTypes recipeTypeEntry) { + public CategoryBuilder recipes(AllRecipeTypes recipeTypeEntry) { return recipes(recipeTypeEntry::getType); } - CategoryBuilder recipes(Supplier> recipeType) { + public CategoryBuilder recipes(Supplier> recipeType) { return recipes(r -> r.getType() == recipeType.get()); } - CategoryBuilder recipes(ResourceLocation serializer) { + public CategoryBuilder recipes(ResourceLocation serializer) { return recipes(r -> r.getSerializer() .getRegistryName() .equals(serializer)); } - CategoryBuilder recipes(Predicate> pred) { + public CategoryBuilder recipes(Predicate> pred) { return recipeList(() -> findRecipes(pred)); } - CategoryBuilder recipes(Predicate> pred, Function, T> converter) { + public CategoryBuilder recipes(Predicate> pred, Function, T> converter) { return recipeList(() -> findRecipes(pred), converter); } - CategoryBuilder recipeList(Supplier>> list) { + public CategoryBuilder recipeList(Supplier>> list) { return recipeList(list, null); } - CategoryBuilder recipeList(Supplier>> list, Function, T> converter) { - category.recipes.add(() -> { - if (!this.pred.test(AllConfigs.SERVER.recipes)) - return Collections.emptyList(); + public CategoryBuilder recipeList(Supplier>> list, Function, T> converter) { + recipeListConsumers.add(recipes -> { + List> toAdd = list.get(); if (converter != null) - return list.get() + toAdd = toAdd .stream() .map(converter) .collect(Collectors.toList()); - return list.get(); + recipes.addAll(toAdd); }); return this; } - CategoryBuilder recipesExcluding(Supplier> recipeType, + public CategoryBuilder recipesExcluding(Supplier> recipeType, Supplier> excluded) { - category.recipes.add(() -> { - if (!this.pred.test(AllConfigs.SERVER.recipes)) - return Collections.emptyList(); - return findRecipesByTypeExcluding(recipeType.get(), excluded.get()); + recipeListConsumers.add(recipes -> { + recipes.addAll(findRecipesByTypeExcluding(recipeType.get(), excluded.get())); }); return this; } - CategoryBuilder enableWhen(Function configValue) { - this.pred = c -> configValue.apply(c) + public CategoryBuilder removeRecipes(Supplier> recipeType) { + recipeListConsumers.add(recipes -> { + removeRecipesByType(recipes, recipeType.get()); + }); + return this; + } + + public CategoryBuilder catalyst(Supplier supplier) { + return catalystStack(() -> new ItemStack(supplier.get() + .asItem())); + } + + public CategoryBuilder catalystStack(Supplier supplier) { + category.recipeCatalysts.add(supplier); + return this; + } + + public CategoryBuilder enableWhen(Function configValue) { + pred = c -> configValue.apply(c) .get(); return this; } - CategoryBuilder enableWhenBool(Function configValue) { - this.pred = configValue::apply; + public CategoryBuilder enableWhenBool(Function configValue) { + pred = configValue::apply; return this; } - CreateRecipeCategory build() { - ALL.add(category); + public CreateRecipeCategory build() { + if (pred.test(AllConfigs.SERVER.recipes)) + category.recipes.add(() -> { + List> recipes = new ArrayList<>(); + for (Consumer>> consumer : recipeListConsumers) + consumer.accept(recipes); + return recipes; + }); + allCategories.add(category); return category; } } - static List> findRecipesByType(IRecipeType type) { - return findRecipes(r -> r.getType() == type); - } - - static List> findRecipes(Predicate> predicate) { + public static List> findRecipes(Predicate> predicate) { return Minecraft.getInstance().world.getRecipeManager() .getRecipes() .stream() @@ -338,24 +349,44 @@ public class CreateJEI implements IModPlugin { .collect(Collectors.toList()); } - static List> findRecipesByTypeExcluding(IRecipeType type, IRecipeType excludingType) { - List> byType = findRecipes(r -> r.getType() == type); - List> byExcludingType = findRecipes(r -> r.getType() == excludingType); - byType.removeIf(recipe -> { - for (IRecipe r : byExcludingType) { - ItemStack[] matchingStacks = recipe.getIngredients() - .get(0) - .getMatchingStacks(); - if (matchingStacks.length == 0) - return true; - if (r.getIngredients() - .get(0) - .test(matchingStacks[0])) - return true; - } - return false; - }); + public static List> findRecipesByType(IRecipeType type) { + return findRecipes(recipe -> recipe.getType() == type); + } + + public static List> findRecipesByTypeExcluding(IRecipeType type, IRecipeType excludingType) { + List> byType = findRecipesByType(type); + removeRecipesByType(byType, excludingType); return byType; } + public static List> findRecipesByTypeExcluding(IRecipeType type, IRecipeType... excludingTypes) { + List> byType = findRecipesByType(type); + for (IRecipeType excludingType : excludingTypes) + removeRecipesByType(byType, excludingType); + return byType; + } + + public static void removeRecipesByType(List> recipes, IRecipeType type) { + List> byType = findRecipesByType(type); + recipes.removeIf(recipe -> { + for (IRecipe r : byType) + if (doInputsMatch(recipe, r)) + return true; + return false; + }); + } + + public static boolean doInputsMatch(IRecipe recipe1, IRecipe recipe2) { + ItemStack[] matchingStacks = recipe1.getIngredients() + .get(0) + .getMatchingStacks(); + if (matchingStacks.length == 0) + return true; + if (recipe2.getIngredients() + .get(0) + .test(matchingStacks[0])) + return true; + return false; + } + } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java index 84543da40..55bfbdab2 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java @@ -31,13 +31,13 @@ import net.minecraftforge.fluids.FluidStack; public abstract class CreateRecipeCategory> implements IRecipeCategory { - public List> recipeCatalysts = new ArrayList<>(); - public List>>> recipes = new ArrayList<>(); - public ResourceLocation uid; + public final List>>> recipes = new ArrayList<>(); + public final List> recipeCatalysts = new ArrayList<>(); + protected ResourceLocation uid; protected String name; - private IDrawable icon; private IDrawable background; + private IDrawable icon; public CreateRecipeCategory(IDrawable icon, IDrawable background) { this.background = background; @@ -49,11 +49,6 @@ public abstract class CreateRecipeCategory> implements IRec this.name = name; } - @Override - public IDrawable getIcon() { - return icon; - } - @Override public ResourceLocation getUid() { return uid; @@ -70,6 +65,11 @@ public abstract class CreateRecipeCategory> implements IRec return background; } + @Override + public IDrawable getIcon() { + return icon; + } + protected static AllGuiTextures getRenderedSlot(IRecipe recipe, int index) { AllGuiTextures jeiSlot = AllGuiTextures.JEI_SLOT; if (!(recipe instanceof ProcessingRecipe)) 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 2f03d2056..69b2292d8 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 @@ -21,7 +21,6 @@ import mezz.jei.api.ingredients.IIngredients; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.math.vector.Vector3f; -import net.minecraft.util.text.TextFormatting; public abstract class ProcessingViaFanCategory> extends CreateRecipeCategory { @@ -41,7 +40,7 @@ public abstract class ProcessingViaFanCategory> extends Cre public static Supplier getFan(String name) { return () -> AllBlocks.ENCASED_FAN.asStack() - .setDisplayName(Lang.translate("recipe." + name + ".fan").formatted(TextFormatting.RESET)); + .setDisplayName(Lang.translate("recipe." + name + ".fan").styled(style -> style.withItalic(false))); } @Override From 51c0e347b88eda662e8976829a9da943c5c9168b Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sat, 29 May 2021 15:17:24 -0400 Subject: [PATCH 111/198] Fix chest minecarts clearing their inventory when disassembled --- .../structureMovement/Contraption.java | 34 +++++++++++++++---- .../mounted/MountedContraption.java | 18 +++++----- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index 32f9a2a34..9480d7e04 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -119,7 +119,7 @@ public abstract class Contraption { public Optional> simplifiedEntityColliders; public AbstractContraptionEntity entity; - public CombinedInvWrapper inventory; + public ContraptionInvWrapper inventory; public CombinedTankWrapper fluidInventory; public AxisAlignedBB bounds; public BlockPos anchor; @@ -252,7 +252,7 @@ public abstract class Contraption { .stream() .map(MountedStorage::getItemHandler) .collect(Collectors.toList()); - inventory = new CombinedInvWrapper(Arrays.copyOf(list.toArray(), list.size(), IItemHandlerModifiable[].class)); + inventory = new ContraptionInvWrapper(Arrays.copyOf(list.toArray(), list.size(), IItemHandlerModifiable[].class)); List fluidHandlers = fluidStorage.values() .stream() @@ -341,7 +341,7 @@ public abstract class Contraption { // Bearings potentially create stabilized sub-contraptions if (AllBlocks.MECHANICAL_BEARING.has(state)) moveBearing(pos, frontier, visited, state); - + // WM Bearings attach their structure when moved if (AllBlocks.WINDMILL_BEARING.has(state)) moveWindmillBearing(pos, frontier, visited, state); @@ -739,7 +739,7 @@ public abstract class Contraption { for (MountedFluidStorage mountedStorage : fluidStorage.values()) fluidHandlers[index++] = mountedStorage.getFluidHandler(); - inventory = new CombinedInvWrapper(handlers); + inventory = new ContraptionInvWrapper(handlers); fluidInventory = new CombinedTankWrapper(fluidHandlers); if (nbt.contains("BoundsFront")) @@ -1053,8 +1053,10 @@ public abstract class Contraption { BlockFlags.IS_MOVING | BlockFlags.DEFAULT, 512); } - for (int i = 0; i < inventory.getSlots(); i++) - inventory.setStackInSlot(i, ItemStack.EMPTY); + for (int i = 0; i < inventory.getSlots(); i++) { + if (!inventory.isSlotExternal(i)) + inventory.setStackInSlot(i, ItemStack.EMPTY); + } for (int i = 0; i < fluidInventory.getTanks(); i++) fluidInventory.drain(fluidInventory.getFluidInTank(i), FluidAction.EXECUTE); @@ -1261,4 +1263,24 @@ public abstract class Contraption { return pos.equals(te.getPos()); } } + + public static class ContraptionInvWrapper extends CombinedInvWrapper { + protected final boolean isExternal; + + public ContraptionInvWrapper(boolean isExternal, IItemHandlerModifiable... itemHandler) { + super(itemHandler); + this.isExternal = isExternal; + } + + public ContraptionInvWrapper(IItemHandlerModifiable... itemHandler) { + this(false, itemHandler); + } + + public boolean isSlotExternal(int slot) { + if (isExternal) + return true; + IItemHandlerModifiable handler = getHandlerFromIndex(getIndexForSlot(slot)); + return handler instanceof ContraptionInvWrapper && ((ContraptionInvWrapper) handler).isSlotExternal(slot); + } + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MountedContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MountedContraption.java index 97b75e778..fae052d36 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MountedContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/MountedContraption.java @@ -53,7 +53,7 @@ public class MountedContraption extends Contraption { protected ContraptionType getType() { return ContraptionType.MOUNTED; } - + @Override public boolean assemble(World world, BlockPos pos) throws AssemblyException { BlockState state = world.getBlockState(pos); @@ -61,17 +61,17 @@ public class MountedContraption extends Contraption { return false; if (!searchMovedStructure(world, pos, null)) return false; - + Axis axis = state.get(RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.X : Axis.Z; addBlock(pos, Pair.of(new BlockInfo(pos, AllBlocks.MINECART_ANCHOR.getDefaultState() .with(BlockStateProperties.HORIZONTAL_AXIS, axis), null), null)); - + if (blocks.size() == 1) return false; - + return true; } - + @Override protected boolean addToInitialFrontier(World world, BlockPos pos, Direction direction, Queue frontier) { frontier.clear(); @@ -149,18 +149,18 @@ public class MountedContraption extends Contraption { protected boolean customBlockRemoval(IWorld world, BlockPos pos, BlockState state) { return AllBlocks.MINECART_ANCHOR.has(state); } - + @Override public boolean canBeStabilized(Direction facing, BlockPos localPos) { return true; } - + @Override public void addExtraInventories(Entity cart) { if (!(cart instanceof IInventory)) return; - IItemHandlerModifiable handlerFromInv = new InvWrapper((IInventory) cart); - inventory = new CombinedInvWrapper(handlerFromInv, inventory); + IItemHandlerModifiable handlerFromInv = new ContraptionInvWrapper(true, new InvWrapper((IInventory) cart)); + inventory = new ContraptionInvWrapper(handlerFromInv, inventory); } @Override From c0133458604627c1cb4d627fbb56cc76fb3a4c58 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 29 May 2021 16:31:36 -0700 Subject: [PATCH 112/198] Cobblestone drops and smelting - Make regular palette stone blocks drop their cobblestone variant instead of themselves (unless silk touch is used) - Add smelting recipes for cobblestone palette blocks - Rename PaletteBlockPatterns to PaletteBlockPattern - Move PatternNameType to PaletteBlockPattern - Rename some fields --- src/generated/resources/.cache/cache | 60 ++++++---- .../recipes/building_blocks/andesite.json | 32 +++++ .../recipes/building_blocks/diorite.json | 32 +++++ .../recipes/building_blocks/granite.json | 32 +++++ .../create.palettes/andesite_pillar.json | 4 +- .../recipes/create.palettes/dark_scoria.json | 32 +++++ .../create.palettes/dark_scoria_pillar.json | 4 +- .../create.palettes/diorite_pillar.json | 4 +- .../recipes/create.palettes/dolomite.json | 32 +++++ .../create.palettes/dolomite_pillar.json | 4 +- .../recipes/create.palettes/gabbro.json | 32 +++++ .../create.palettes/gabbro_pillar.json | 4 +- .../create.palettes/granite_pillar.json | 4 +- .../recipes/create.palettes/limestone.json | 32 +++++ .../create.palettes/limestone_pillar.json | 4 +- .../recipes/create.palettes/scoria.json | 32 +++++ .../create.palettes/scoria_pillar.json | 4 +- .../create.palettes/weathered_limestone.json | 32 +++++ .../weathered_limestone_pillar.json | 4 +- .../loot_tables/blocks/dark_scoria.json | 38 ++++-- .../create/loot_tables/blocks/dolomite.json | 38 ++++-- .../create/loot_tables/blocks/gabbro.json | 38 ++++-- .../create/loot_tables/blocks/limestone.json | 38 ++++-- .../create/loot_tables/blocks/scoria.json | 38 ++++-- .../blocks/weathered_limestone.json | 38 ++++-- .../data/create/recipes/andesite.json | 9 ++ .../data/create/recipes/dark_scoria.json | 9 ++ .../data/create/recipes/diorite.json | 9 ++ .../data/create/recipes/dolomite.json | 9 ++ .../resources/data/create/recipes/gabbro.json | 9 ++ .../data/create/recipes/granite.json | 9 ++ .../data/create/recipes/limestone.json | 9 ++ .../create/recipes/polished_dark_scoria.json | 6 +- .../create/recipes/polished_dolomite.json | 6 +- .../data/create/recipes/polished_gabbro.json | 6 +- .../create/recipes/polished_limestone.json | 6 +- .../data/create/recipes/polished_scoria.json | 6 +- .../recipes/polished_weathered_limestone.json | 6 +- .../resources/data/create/recipes/scoria.json | 9 ++ .../create/recipes/weathered_limestone.json | 9 ++ .../com/simibubi/create/AllSpriteShifts.java | 10 +- .../content/palettes/AllPaletteBlocks.java | 32 +++-- .../content/palettes/PaletteBlockPartial.java | 24 ++-- ...Patterns.java => PaletteBlockPattern.java} | 112 ++++++++++-------- .../palettes/PaletteStoneVariants.java | 26 ++-- .../palettes/PalettesVariantEntry.java | 10 +- .../content/palettes/PatternNameType.java | 5 - 47 files changed, 752 insertions(+), 196 deletions(-) create mode 100644 src/generated/resources/data/create/advancements/recipes/building_blocks/andesite.json create mode 100644 src/generated/resources/data/create/advancements/recipes/building_blocks/diorite.json create mode 100644 src/generated/resources/data/create/advancements/recipes/building_blocks/granite.json create mode 100644 src/generated/resources/data/create/advancements/recipes/create.palettes/dark_scoria.json create mode 100644 src/generated/resources/data/create/advancements/recipes/create.palettes/dolomite.json create mode 100644 src/generated/resources/data/create/advancements/recipes/create.palettes/gabbro.json create mode 100644 src/generated/resources/data/create/advancements/recipes/create.palettes/limestone.json create mode 100644 src/generated/resources/data/create/advancements/recipes/create.palettes/scoria.json create mode 100644 src/generated/resources/data/create/advancements/recipes/create.palettes/weathered_limestone.json create mode 100644 src/generated/resources/data/create/recipes/andesite.json create mode 100644 src/generated/resources/data/create/recipes/dark_scoria.json create mode 100644 src/generated/resources/data/create/recipes/diorite.json create mode 100644 src/generated/resources/data/create/recipes/dolomite.json create mode 100644 src/generated/resources/data/create/recipes/gabbro.json create mode 100644 src/generated/resources/data/create/recipes/granite.json create mode 100644 src/generated/resources/data/create/recipes/limestone.json create mode 100644 src/generated/resources/data/create/recipes/scoria.json create mode 100644 src/generated/resources/data/create/recipes/weathered_limestone.json rename src/main/java/com/simibubi/create/content/palettes/{PaletteBlockPatterns.java => PaletteBlockPattern.java} (70%) delete mode 100644 src/main/java/com/simibubi/create/content/palettes/PatternNameType.java diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index e1e64b2e5..879b6bf41 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -1713,6 +1713,7 @@ c9c4060ed207226b69fada2d61e01a97d7077eae data/create/advancements/nixie_tube.jso 4b621e5bb48fbb120853ec02c05c915d86bd6dd8 data/create/advancements/pipe_spill.json 72025d8bf73ab8096c29f12d0c8d9a346f09cd64 data/create/advancements/polished_rose_quartz.json 62d29ec01eff5d21968636a0479361ecdc11ae30 data/create/advancements/press.json +f80479b50e248ee8d6d1abb7d08866cf711ac2b2 data/create/advancements/recipes/building_blocks/andesite.json 5012e9d559439d0d62d0b34c2e39de048e8c7699 data/create/advancements/recipes/building_blocks/blasting/aluminum_ingot_compat_silents_mechanisms.json 2e253226c408dffb9dfb828b846f70ebd1cfb16e data/create/advancements/recipes/building_blocks/blasting/ingot_aluminum_compat_immersiveengineering.json 3f022f89aeb5034f2292ca71daa9f311e8af40ff data/create/advancements/recipes/building_blocks/blasting/ingot_lead_compat_immersiveengineering.json @@ -1739,6 +1740,8 @@ a61045a27757950d96fee77768bfd96f935f98b2 data/create/advancements/recipes/buildi a75f1162ac89cd50a1ca8e525dd059fb359a6550 data/create/advancements/recipes/building_blocks/blasting/tin_ingot_compat_silents_mechanisms.json 230c3da350aa45524712d5dd28b84aa59b2883e9 data/create/advancements/recipes/building_blocks/blasting/tin_ingot_compat_thermal.json 38410d4b3bbbf33c1c8913735abd1b3d71fb3829 data/create/advancements/recipes/building_blocks/blasting/uranium_ingot_compat_silents_mechanisms.json +8850272a97541e331482531c52cc94197fe808be data/create/advancements/recipes/building_blocks/diorite.json +0abb698cabe5f71675773e5eeadeccb509f1cb90 data/create/advancements/recipes/building_blocks/granite.json 22067545c460d95831d9dddf361da9becac3396e data/create/advancements/recipes/building_blocks/smelting/aluminum_ingot_compat_silents_mechanisms.json e525d8eda8d0aac6791ae935ed4f3f75cc521460 data/create/advancements/recipes/building_blocks/smelting/glass_from_framed_glass.json 295c5a61d6f175a65d25e19cbd7ca90d3b4a93b2 data/create/advancements/recipes/building_blocks/smelting/glass_from_horizontal_framed_glass.json @@ -1976,7 +1979,7 @@ bfb3673a30db807aa298f2fd128ec863a65818af data/create/advancements/recipes/create 47cc716674e1741f4115b04a20ac4c4a5b2a6d8a data/create/advancements/recipes/create.palettes/andesite_cobblestone_stairs_from_andesite_cobblestone_stonecutting.json bd79e63c29d68fbf87ded63ac1eedba3d7287996 data/create/advancements/recipes/create.palettes/andesite_cobblestone_wall.json 0ed4c084f05b2bd4c134293ad3554d6e31a1d568 data/create/advancements/recipes/create.palettes/andesite_cobblestone_wall_from_andesite_cobblestone_stonecutting.json -a453d05704cadb3279318192aac87e623738cdaa data/create/advancements/recipes/create.palettes/andesite_pillar.json +cc8e078ccce06e9489d8b62d88b6a2e4d4ca2d79 data/create/advancements/recipes/create.palettes/andesite_pillar.json d6f31097aef040e12eb288ab755d459f55269a70 data/create/advancements/recipes/create.palettes/andesite_pillar_from_andesite_stonecutting.json f10a4369147cc5e36d3ab1b0008d29fd36ffc8f6 data/create/advancements/recipes/create.palettes/birch_window.json bfea45da3f8df1c63f6c7ff1b63ad7e08c1d44b0 data/create/advancements/recipes/create.palettes/birch_window_pane.json @@ -1991,6 +1994,7 @@ b4651c8202331483e82b28b04edc6cd97e62ad1d data/create/advancements/recipes/create b2813566e6715c2d377dd4ef461b012cae7eb190 data/create/advancements/recipes/create.palettes/crimson_window_pane.json 25991d5667252d551e02c4fbbfa27ebf4353d28d data/create/advancements/recipes/create.palettes/dark_oak_window.json 4819383b1a7885b4401fdc25955d2c51f75b6236 data/create/advancements/recipes/create.palettes/dark_oak_window_pane.json +02cd339174aaf2c14e14f886d90fbbcae91783b6 data/create/advancements/recipes/create.palettes/dark_scoria.json ebd6413d530325eef6fcf42a0ee0ac840c1f7366 data/create/advancements/recipes/create.palettes/dark_scoria_bricks_from_dark_scoria_stonecutting.json 030ce9b61b8af158cf54e7a9ab673ccb7251483f data/create/advancements/recipes/create.palettes/dark_scoria_bricks_slab.json ac44d03859cfd4c00ddcbd1dafbb9acc51d849d7 data/create/advancements/recipes/create.palettes/dark_scoria_bricks_slab_from_dark_scoria_bricks_stonecutting.json @@ -2005,7 +2009,7 @@ eef6f85b20fb997af1b0c2383a45100be2e0cd34 data/create/advancements/recipes/create 8d44f675237a92513678a77da7a1f329475a3453 data/create/advancements/recipes/create.palettes/dark_scoria_cobblestone_stairs_from_dark_scoria_cobblestone_stonecutting.json 702527e6735770a6fcc3ad446df39d3b1b80709e data/create/advancements/recipes/create.palettes/dark_scoria_cobblestone_wall.json ce069a666d223f733bfa1cc9ca5e3e5e27de1ebc data/create/advancements/recipes/create.palettes/dark_scoria_cobblestone_wall_from_dark_scoria_cobblestone_stonecutting.json -c5d7f1e79302d47ea02cb63b99b286b90ec0287b data/create/advancements/recipes/create.palettes/dark_scoria_pillar.json +64f9ba8df2fd2357ad397b75156a4af9c26fa91b data/create/advancements/recipes/create.palettes/dark_scoria_pillar.json f3d6314d272d84c456c5df512dcc555b7694ded2 data/create/advancements/recipes/create.palettes/dark_scoria_pillar_from_dark_scoria_stonecutting.json 83e3c29d5d651a6bc6fd9d5843d8d75f4cda2b77 data/create/advancements/recipes/create.palettes/diorite_bricks_from_diorite_stonecutting.json 4649497555ca4269b1f3859f0275ca1ff7c85377 data/create/advancements/recipes/create.palettes/diorite_bricks_slab.json @@ -2021,8 +2025,9 @@ f3d6314d272d84c456c5df512dcc555b7694ded2 data/create/advancements/recipes/create 600c57c4dc3a3741d5db7ec01340e1c6a01d54b4 data/create/advancements/recipes/create.palettes/diorite_cobblestone_stairs_from_diorite_cobblestone_stonecutting.json 8b4990d3657e23a86c3e71eba77370c56692c93b data/create/advancements/recipes/create.palettes/diorite_cobblestone_wall.json e741ca0e76875ee12beecd45db764444956d5342 data/create/advancements/recipes/create.palettes/diorite_cobblestone_wall_from_diorite_cobblestone_stonecutting.json -9edb9886a6b2792dc38d5d61a2be2b7a3fd28eeb data/create/advancements/recipes/create.palettes/diorite_pillar.json +08e8495b798d54366f132da060e93e94e23f6354 data/create/advancements/recipes/create.palettes/diorite_pillar.json 87d34b8ca3dc73a778ab94ef4d852f418112adb3 data/create/advancements/recipes/create.palettes/diorite_pillar_from_diorite_stonecutting.json +17135274809b7a0f38294d2e6412b787e985e4d5 data/create/advancements/recipes/create.palettes/dolomite.json dbf201ceafc310f5cc6624c81777d50348844285 data/create/advancements/recipes/create.palettes/dolomite_bricks_from_dolomite_stonecutting.json 6716447628cce96a1f520766d019f09380ec67e5 data/create/advancements/recipes/create.palettes/dolomite_bricks_slab.json 52ae39c6f63860fa5a60c1ae70ef00eca5b961c9 data/create/advancements/recipes/create.palettes/dolomite_bricks_slab_from_dolomite_bricks_stonecutting.json @@ -2037,7 +2042,7 @@ a8904096a05eeb7e746563e1a4b97b39173d1708 data/create/advancements/recipes/create 124c586970edc5c15079bec53c734a2beb670130 data/create/advancements/recipes/create.palettes/dolomite_cobblestone_stairs_from_dolomite_cobblestone_stonecutting.json 2e9f1556a11d4d7190233be3af64453396865da9 data/create/advancements/recipes/create.palettes/dolomite_cobblestone_wall.json 1a1e8764ba05f72ffd7e5872a8f2fc9cf2108308 data/create/advancements/recipes/create.palettes/dolomite_cobblestone_wall_from_dolomite_cobblestone_stonecutting.json -4652a46d4b6590b988d57d855def253ebeb380fe data/create/advancements/recipes/create.palettes/dolomite_pillar.json +4b56a0490151fbc66dee82546b9e271a5a85fa12 data/create/advancements/recipes/create.palettes/dolomite_pillar.json a8752ee9bf9afc665c5d940d251c1cf4a83a0ae9 data/create/advancements/recipes/create.palettes/dolomite_pillar_from_dolomite_stonecutting.json ea981a446d8cc22d6b7fb4667e86dc18a48a4720 data/create/advancements/recipes/create.palettes/fancy_andesite_bricks_from_andesite_stonecutting.json 44dc6bc5a7303129db2268a025f49dcb222597a7 data/create/advancements/recipes/create.palettes/fancy_andesite_bricks_slab.json @@ -2104,6 +2109,7 @@ d51bee4b276805ecf1a93a37ec6d610e75c0117e data/create/advancements/recipes/create 17e02efc06d935c094bde5bb73a5127bc98e4758 data/create/advancements/recipes/create.palettes/fancy_weathered_limestone_bricks_wall_from_fancy_weathered_limestone_bricks_stonecutting.json 05331b5f1701453ecdfd0b3e6429b22ec209ba67 data/create/advancements/recipes/create.palettes/framed_glass_from_glass_colorless_stonecutting.json 605476eaf4e964936c031732cfef534edfdd749a data/create/advancements/recipes/create.palettes/framed_glass_pane.json +1b17b217e487b958e35ab0ad509bb8caceebda40 data/create/advancements/recipes/create.palettes/gabbro.json b835dd583d670e2d7f6af4dd74e44f5817b03b21 data/create/advancements/recipes/create.palettes/gabbro_bricks_from_gabbro_stonecutting.json 2bfac04754aaf07423b330134984d887ae43f00a data/create/advancements/recipes/create.palettes/gabbro_bricks_slab.json f05bb35d52866abc7dae9c7f3f5fc85257760564 data/create/advancements/recipes/create.palettes/gabbro_bricks_slab_from_gabbro_bricks_stonecutting.json @@ -2118,7 +2124,7 @@ c90a07c41b2e034437c8a765de7b517f89383830 data/create/advancements/recipes/create f9d917def55875dcba621246f80dc83904be3d73 data/create/advancements/recipes/create.palettes/gabbro_cobblestone_stairs_from_gabbro_cobblestone_stonecutting.json b081b91a5e11e8ce9b2455b944eb554f5f2e419e data/create/advancements/recipes/create.palettes/gabbro_cobblestone_wall.json 093f372d84c557791cebcb286b3505f32c4dc7c0 data/create/advancements/recipes/create.palettes/gabbro_cobblestone_wall_from_gabbro_cobblestone_stonecutting.json -dacb04ebd8bc20c2a0689a9e75ea67c07e43c56b data/create/advancements/recipes/create.palettes/gabbro_pillar.json +4b0f4a396397a791d08fe422fb4cfb922554779c data/create/advancements/recipes/create.palettes/gabbro_pillar.json 35288551f5146ebbf8dbbe987928dd2a1bdc7ea8 data/create/advancements/recipes/create.palettes/gabbro_pillar_from_gabbro_stonecutting.json 6a9a8b37ec264084ce0481200225017739546025 data/create/advancements/recipes/create.palettes/granite_bricks_from_granite_stonecutting.json 2ac84cb0b8b629bdfd740a6613df2a7e45964bf2 data/create/advancements/recipes/create.palettes/granite_bricks_slab.json @@ -2134,7 +2140,7 @@ c39e86c111a2c76ef9cb7046d2b87262524b06b9 data/create/advancements/recipes/create 06d3f3150db99f808a5fd4141c0fc6235d979ce5 data/create/advancements/recipes/create.palettes/granite_cobblestone_stairs_from_granite_cobblestone_stonecutting.json 6bbc97d2ac655a532eaf345fca64431dbf8af27d data/create/advancements/recipes/create.palettes/granite_cobblestone_wall.json d6b622a2cf302d0c39e0d38d24b0a17e1461d13b data/create/advancements/recipes/create.palettes/granite_cobblestone_wall_from_granite_cobblestone_stonecutting.json -03c3a88e1a320afe9866a1c09ef34b46763c8ec1 data/create/advancements/recipes/create.palettes/granite_pillar.json +5b9fe440648ae9f37b5d079cfcd1d9a72afa74fa data/create/advancements/recipes/create.palettes/granite_pillar.json 97cc61b1b510849ebc0bf51cf2b8107a5c43fc17 data/create/advancements/recipes/create.palettes/granite_pillar_from_granite_stonecutting.json cbb40e82dba460ee126966a52f0164e740ac1f11 data/create/advancements/recipes/create.palettes/horizontal_framed_glass_from_glass_colorless_stonecutting.json 29e2e2aeca3800c8ba432be30d54d046a3991217 data/create/advancements/recipes/create.palettes/horizontal_framed_glass_pane.json @@ -2149,6 +2155,7 @@ cbb40e82dba460ee126966a52f0164e740ac1f11 data/create/advancements/recipes/create c0dd961f07e85a183af7b942ed0e4bfe8f775373 data/create/advancements/recipes/create.palettes/layered_limestone_from_limestone_stonecutting.json 5d06584a83074f8a8d1a52d93d13f2718bc99152 data/create/advancements/recipes/create.palettes/layered_scoria_from_scoria_stonecutting.json b09e64b4989ef08b7ea6b9011681c2fbf780d949 data/create/advancements/recipes/create.palettes/layered_weathered_limestone_from_weathered_limestone_stonecutting.json +519234f31ee8cacc0f916df40703ba171c6a90e5 data/create/advancements/recipes/create.palettes/limestone.json 52c1902f260173fe610a4a03294a51c4cea3b37b data/create/advancements/recipes/create.palettes/limestone_bricks_from_limestone_stonecutting.json e6eb6c433541b7c4e3e5b64f240618e6df67ed58 data/create/advancements/recipes/create.palettes/limestone_bricks_slab.json 72f0586690ca4413082b2cbecf7938ba6e4756b4 data/create/advancements/recipes/create.palettes/limestone_bricks_slab_from_limestone_bricks_stonecutting.json @@ -2163,7 +2170,7 @@ d7b36c7fcf429eea7c57f2ae967e73b8e18d0d58 data/create/advancements/recipes/create 749936c7c33273c1833154a1eb1e13604ece8565 data/create/advancements/recipes/create.palettes/limestone_cobblestone_stairs_from_limestone_cobblestone_stonecutting.json c0e3f97a6f807ea8147f58bf4ca002725d1877b6 data/create/advancements/recipes/create.palettes/limestone_cobblestone_wall.json a01c91b927f50d367c3bfcca5f370002a991d45a data/create/advancements/recipes/create.palettes/limestone_cobblestone_wall_from_limestone_cobblestone_stonecutting.json -8b1ef23c71f0088230dcdd12374494bfdf700409 data/create/advancements/recipes/create.palettes/limestone_pillar.json +acf08b6a32e3678d63443fdb97e7332e05eb61f6 data/create/advancements/recipes/create.palettes/limestone_pillar.json d040f53dfb09a29c39d534d3595e35d058fe5557 data/create/advancements/recipes/create.palettes/limestone_pillar_from_limestone_stonecutting.json 3ee8ab0478344042136058be6cf870289c096bdd data/create/advancements/recipes/create.palettes/mossy_andesite_from_andesite_stonecutting.json c427e2626e468abee6fb4de83bf76f2d3c051449 data/create/advancements/recipes/create.palettes/mossy_dark_scoria_from_dark_scoria_stonecutting.json @@ -2298,6 +2305,7 @@ e46847d02ab7bfb2bc1da1a4ad4b7b54a3a28559 data/create/advancements/recipes/create 75480d0c13a80d9edf93a0eff947e5165db011c1 data/create/advancements/recipes/create.palettes/polished_weathered_limestone_stairs_from_polished_weathered_limestone_stonecutting.json 7b4b27211174e774169132a50da7bfd63ff28b30 data/create/advancements/recipes/create.palettes/polished_weathered_limestone_wall.json 81a759d9b069faedee49107642d947ea1bf1ac6c data/create/advancements/recipes/create.palettes/polished_weathered_limestone_wall_from_polished_weathered_limestone_stonecutting.json +28c7dd5fb1594295f977eff41ac677aab9660831 data/create/advancements/recipes/create.palettes/scoria.json 874023eabafb85aefacc86f395c5d4ef0cc9cfac data/create/advancements/recipes/create.palettes/scoria_bricks_from_scoria_stonecutting.json a9969fd00f8cba428715d27a8ab6af6ba6473c8a data/create/advancements/recipes/create.palettes/scoria_bricks_slab.json 1d129bb8d359de50344dcb46f77899b0651d7817 data/create/advancements/recipes/create.palettes/scoria_bricks_slab_from_scoria_bricks_stonecutting.json @@ -2312,7 +2320,7 @@ dc5df4f4feddc24a7c78b25b6ed3e7ed458342f1 data/create/advancements/recipes/create b852a9a59499c113f387ac06fdb27d3d455f18e3 data/create/advancements/recipes/create.palettes/scoria_cobblestone_stairs_from_scoria_cobblestone_stonecutting.json a43d45efa0fb0d3eaace93c18d80a14d4dcddf38 data/create/advancements/recipes/create.palettes/scoria_cobblestone_wall.json e340721aa78f260c2666214aa149241a37de216e data/create/advancements/recipes/create.palettes/scoria_cobblestone_wall_from_scoria_cobblestone_stonecutting.json -53cc5b006a19158e04094308accb66a7c35d2b26 data/create/advancements/recipes/create.palettes/scoria_pillar.json +68fc67ead3fd31885b30a5cf3e71dd33fb040634 data/create/advancements/recipes/create.palettes/scoria_pillar.json 53712a9ae59976dece952bea7ecaf73b679448f0 data/create/advancements/recipes/create.palettes/scoria_pillar_from_scoria_stonecutting.json 6b148def2f8789f9ff1d41bb71ab3608438a7207 data/create/advancements/recipes/create.palettes/smelting/dolomite.json 070720cc271767b26ad51fa089b4cf2a64d309be data/create/advancements/recipes/create.palettes/smelting/gabbro.json @@ -2327,6 +2335,7 @@ d40c7ce6b79630ace624d17b92667286998d93bc data/create/advancements/recipes/create cd5ee73117872ee98434be1d24b4f271f7e94a48 data/create/advancements/recipes/create.palettes/vertical_framed_glass_pane.json f26d1a1ee183b1b19d018fbdefc70f0bf29b41d0 data/create/advancements/recipes/create.palettes/warped_window.json faf33c9c630eecab88bb969e3b9f7fd9e9f6ccf6 data/create/advancements/recipes/create.palettes/warped_window_pane.json +5b3447ec4802fb27f1ee9a3b1bbe1936fac48fb3 data/create/advancements/recipes/create.palettes/weathered_limestone.json ef0d351d13f7e9c633581b537c59bddc1fa4c3a4 data/create/advancements/recipes/create.palettes/weathered_limestone_bricks_from_weathered_limestone_stonecutting.json 1c931e15af3e5b5f78a0a62b8c159fdf9f0d7f3e data/create/advancements/recipes/create.palettes/weathered_limestone_bricks_slab.json bba639941526cc23570e328e0b5e2a5545667219 data/create/advancements/recipes/create.palettes/weathered_limestone_bricks_slab_from_weathered_limestone_bricks_stonecutting.json @@ -2341,7 +2350,7 @@ b77c5aecd0b6dd37a0c69431ab7a4a40fe0770eb data/create/advancements/recipes/create 8ea05c6cdb313ff395d1f21cfb40e2d939dadf20 data/create/advancements/recipes/create.palettes/weathered_limestone_cobblestone_stairs_from_weathered_limestone_cobblestone_stonecutting.json 4d838d8ceaf207a59554444d82b80c31807341bc data/create/advancements/recipes/create.palettes/weathered_limestone_cobblestone_wall.json e548127075559307b767b802f4809ed52eedd543 data/create/advancements/recipes/create.palettes/weathered_limestone_cobblestone_wall_from_weathered_limestone_cobblestone_stonecutting.json -23ba836640a4d543db6f1cb72cc86a6543fe2fbe data/create/advancements/recipes/create.palettes/weathered_limestone_pillar.json +efab7b7f3829998a91fc506e4be3b6345f5ca168 data/create/advancements/recipes/create.palettes/weathered_limestone_pillar.json 9790a16fd56e47cb5abbfad4062672303c224d9f data/create/advancements/recipes/create.palettes/weathered_limestone_pillar_from_weathered_limestone_stonecutting.json e00155bcd00f50750e2cc4d6aa30c2f2d6e62922 data/create/advancements/recipes/decorations/smelting/glass_pane_from_framed_glass_pane.json bf9131527df4ad259b5a509753ba66417d764da2 data/create/advancements/recipes/decorations/smelting/glass_pane_from_horizontal_framed_glass_pane.json @@ -2448,7 +2457,7 @@ d370ee874b5b6b98e9a8c368218fe61f644d956d data/create/loot_tables/blocks/cuckoo_c fe24fd296812fea3f838defa2ca6270523d9d48e data/create/loot_tables/blocks/cyan_valve_handle.json fd309e1d39dcbcb25c3361edecd8c9afa0f847d0 data/create/loot_tables/blocks/dark_oak_window.json 58e6307ba0efa65a0715662a391fe7dc6fba0c68 data/create/loot_tables/blocks/dark_oak_window_pane.json -7a40002e4c05f6456b52558b9ee9607cfc868a69 data/create/loot_tables/blocks/dark_scoria.json +6769787b0c7a8d2762bae1c4826275bde8647b4e data/create/loot_tables/blocks/dark_scoria.json 502160551afd210c68582a1dfd41a2df720f53a1 data/create/loot_tables/blocks/dark_scoria_bricks.json d37adba01cd1220e265dbdc025b3f8d01b992289 data/create/loot_tables/blocks/dark_scoria_bricks_slab.json 265bb133af68497d9b4ba4bd418a198506caa45b data/create/loot_tables/blocks/dark_scoria_bricks_stairs.json @@ -2469,7 +2478,7 @@ bdaba62199f7a65e1149b742aaaf0c23a1e149b0 data/create/loot_tables/blocks/diorite_ 5141eec8eebed0feec906618dd3474ea402fbf28 data/create/loot_tables/blocks/diorite_cobblestone_stairs.json f3c963cfd51069876140373f410e868706744e9b data/create/loot_tables/blocks/diorite_cobblestone_wall.json fdcf47cddebca81730ac122925b01daeddf9233d data/create/loot_tables/blocks/diorite_pillar.json -7aa075c7fbe97447422bfcb95afb3bbe3b26301c data/create/loot_tables/blocks/dolomite.json +0be81285de44699dabb2c1e046ae109b2e39a4e9 data/create/loot_tables/blocks/dolomite.json 7ecdbfa3ebfc6865833bafed06ed7cd6eef58345 data/create/loot_tables/blocks/dolomite_bricks.json ecc855c3ce298855038eb7b53137cab519bca55a data/create/loot_tables/blocks/dolomite_bricks_slab.json 699815e110c76bcb793efdfedcb8ac3a5b9b7131 data/create/loot_tables/blocks/dolomite_bricks_stairs.json @@ -2525,7 +2534,7 @@ f37526c092c645045c22674dea6c7b1ec503c9c3 data/create/loot_tables/blocks/flywheel ce0bb978b11935bc2d1218445f8ab18099af6b8a data/create/loot_tables/blocks/framed_glass.json 89bd90ecd7a1ce1f75bd873989cc58a84c8dcef9 data/create/loot_tables/blocks/framed_glass_pane.json 4063880eda871fe63a4eb549a19daecabce849e5 data/create/loot_tables/blocks/furnace_engine.json -1070cba1c0f46cf7ebe31089f35333f5eadda6e4 data/create/loot_tables/blocks/gabbro.json +88b3438e50322b731cdd8589e36a9ea497cfe56e data/create/loot_tables/blocks/gabbro.json 0356e003d8890d31b89d0ad98e32aae892da71f9 data/create/loot_tables/blocks/gabbro_bricks.json bd93e42ebca985b8aeeaf0ea5fb736d496183615 data/create/loot_tables/blocks/gabbro_bricks_slab.json e51893e1601c470da466b35b17251238e15d0361 data/create/loot_tables/blocks/gabbro_bricks_stairs.json @@ -2582,7 +2591,7 @@ b403848d3a4b4ad7a048e70c21e200e40d0c67e3 data/create/loot_tables/blocks/light_bl f7893090c6ecb4862c90c408b7f9ce8316f8b608 data/create/loot_tables/blocks/lime_seat.json cae6d16c8967164698efbce3b91018a8e79a81e9 data/create/loot_tables/blocks/lime_valve_handle.json 7dfd638cc6f0d22bbc8fcbdb7212a3bfc8c85223 data/create/loot_tables/blocks/limesand.json -9d585f677a32a2336df5f17b5b389cdee867939f data/create/loot_tables/blocks/limestone.json +d476eed7b5f0c7438d2e517fc60cd23f19234056 data/create/loot_tables/blocks/limestone.json 57134f7d3d32fc1c48f2a20c4be84388587092bc data/create/loot_tables/blocks/limestone_bricks.json 1b59a36aa1a889c42d4b8b939f5eeee2967222d0 data/create/loot_tables/blocks/limestone_bricks_slab.json 41ed1d0750e8ddd7e7e75fd7e4cafde6346d1afe data/create/loot_tables/blocks/limestone_bricks_stairs.json @@ -2728,7 +2737,7 @@ aa6af37356d65105efab2503ffe75f778cfe873b data/create/loot_tables/blocks/rotation 30de11bec82606fead9d6bff7bba0232e97f1039 data/create/loot_tables/blocks/sail_frame.json 069701cb804b6522c18624a0d4f3f949ff8b0281 data/create/loot_tables/blocks/schematic_table.json a2b172dc749176d4df34729007019605fc6dd150 data/create/loot_tables/blocks/schematicannon.json -af1bbbb8236b4ab05a6a8edc6db960bc758cbdf3 data/create/loot_tables/blocks/scoria.json +5c1bd2b940fa04ab487155ca10c551dd9b0fbf37 data/create/loot_tables/blocks/scoria.json bb670ac5dd2fa4c743bc268cd0547926eb6cdb68 data/create/loot_tables/blocks/scoria_bricks.json a7217ea301a282d0ef52f2d8c06dd8683398408d data/create/loot_tables/blocks/scoria_bricks_slab.json 58a188f3ebfeb3d19323c3f8dfa3e020a7f6cdc4 data/create/loot_tables/blocks/scoria_bricks_stairs.json @@ -2760,7 +2769,7 @@ d0156602dd5f4a274c293df67e19374820c72890 data/create/loot_tables/blocks/vertical 1afc5ede08e72221e33910603fa7acd0b3c7a2ee data/create/loot_tables/blocks/warped_window.json f334fd2b9a92b0646674239e7e34e142fe2c5fad data/create/loot_tables/blocks/warped_window_pane.json 2883c63ceb1273009dbf91cb0693756cadf79a1a data/create/loot_tables/blocks/water_wheel.json -611d6195db52c074de484ec52d7ac9eb96b4ff10 data/create/loot_tables/blocks/weathered_limestone.json +6cbc693f915f409bc21c6084a4f75071bd660f7b data/create/loot_tables/blocks/weathered_limestone.json c1f379baad36a20fc767be094db10480a0378184 data/create/loot_tables/blocks/weathered_limestone_bricks.json 43be7e49b9a8a75077066aa824a0f784aa741683 data/create/loot_tables/blocks/weathered_limestone_bricks_slab.json c2a62f12680d04ed4f586c501bb026e367243dd2 data/create/loot_tables/blocks/weathered_limestone_bricks_stairs.json @@ -2783,6 +2792,7 @@ e3969f1c5966c4992b3280a06e1d6c5000c37df5 data/create/loot_tables/blocks/weighted 37248ca92d474e440b91c27e3c8e78e568328100 data/create/loot_tables/blocks/zinc_ore.json b65bac8bc2fbfd476040c1aab1c0588b8bd59ebe data/create/recipes/acacia_window.json 35b4da9c14da60584c32e959efc2223f64bb3ec2 data/create/recipes/acacia_window_pane.json +57fc55848415db3e9b74e2cc2f6dacfb1b13a6cc data/create/recipes/andesite.json 96bb0bceb7798c96d5cf9b9c24b8ef822080cb1e data/create/recipes/andesite_bricks_from_andesite_stonecutting.json 01867b07039615dc69bad1b9fd217a1d86e69062 data/create/recipes/andesite_bricks_slab.json 376ada0e08cc797c705c22ec35fe54baa5f24efe data/create/recipes/andesite_bricks_slab_from_andesite_bricks_stonecutting.json @@ -3103,6 +3113,7 @@ a022f2d541f04a9e2bed6b72af4e74703076fcbe data/create/recipes/cutting/warped_hyph 1bd01df5540df7db06afde28a3f9ebe4d25e4001 data/create/recipes/cutting/warped_stem.json f2c317e03ac4d42fb631e1625607061e10c480fe data/create/recipes/dark_oak_window.json d9dbae6e237eb38e53a619a0f1b339fca7c59b4d data/create/recipes/dark_oak_window_pane.json +2ff8ac7eaabef52dcb173d7af388c28307559aaa data/create/recipes/dark_scoria.json 55596a590962e3ddd40949917661f0bd94408274 data/create/recipes/dark_scoria_bricks_from_dark_scoria_stonecutting.json 2489fc29c47d3c9cb63f5f2f09dc79ea1ca1728e data/create/recipes/dark_scoria_bricks_slab.json 86f4d54ebcc5bc8786c72167395d8efee833744c data/create/recipes/dark_scoria_bricks_slab_from_dark_scoria_bricks_stonecutting.json @@ -3119,6 +3130,7 @@ f3a72b45daef00035ecb17b9cd7f8985a5f9e9ef data/create/recipes/dark_scoria_cobbles 0f2c14d40ed9013d45e331000ea03d39430f9d22 data/create/recipes/dark_scoria_cobblestone_wall_from_dark_scoria_cobblestone_stonecutting.json 31b7e65165cb0dbcd95362a81905b19fe4282cf3 data/create/recipes/dark_scoria_pillar.json 681f45f03b15dc1a8a72cf72042e725d3f0cc7ef data/create/recipes/dark_scoria_pillar_from_dark_scoria_stonecutting.json +0871ced2a434838e2db8f3df85af84b0cb4e40ad data/create/recipes/diorite.json 25c0fe29d1c2cedcaf21fac6cdfcce45dbf810bf data/create/recipes/diorite_bricks_from_diorite_stonecutting.json ff4a8687bdff339a10e0b813788bca272332abd9 data/create/recipes/diorite_bricks_slab.json 7c49a389f9222fdfd6653d9fbcb1ca05bf207aa8 data/create/recipes/diorite_bricks_slab_from_diorite_bricks_stonecutting.json @@ -3135,6 +3147,7 @@ f764471aab017775e0d7a6d43a9e36b186db3ac2 data/create/recipes/diorite_cobblestone d3628d5ce836d3b9072be3d4cf30416146cccad2 data/create/recipes/diorite_cobblestone_wall_from_diorite_cobblestone_stonecutting.json d69d767a77ae62f8e53342dffda4c627906439d7 data/create/recipes/diorite_pillar.json 3019172274fdfcc606ad0f5569db433913231c28 data/create/recipes/diorite_pillar_from_diorite_stonecutting.json +2f1bf27611c640ec454be0e73ed75f596a4f1add data/create/recipes/dolomite.json 6ee0f10522f4acfe554e4743fa2ba1d8297a12f2 data/create/recipes/dolomite_bricks_from_dolomite_stonecutting.json 88a9b8e89e67455a9c4f1c3dbff813a3c3bd1609 data/create/recipes/dolomite_bricks_slab.json 3adfb9924ada35d58275533425802b4829f058ac data/create/recipes/dolomite_bricks_slab_from_dolomite_bricks_stonecutting.json @@ -3230,6 +3243,7 @@ c83e77a9799b6ca34dd73aa76b56159f2103c48c data/create/recipes/filling/milk_bucket fb8e4378cd2240644a4b5c0d06e27ad772ec7695 data/create/recipes/filling/sweet_roll.json 5b8bbde7f8b270ab75fac18d6858f2fadbc0efa3 data/create/recipes/framed_glass_from_glass_colorless_stonecutting.json d697de0c9b706ca4e18da7a2d769e7e5fe8d769d data/create/recipes/framed_glass_pane.json +147e7a160b82c8128f8fa7c3c6e7f7d652b89a36 data/create/recipes/gabbro.json a0dae50faaa1b7142bb4309675e3084c68daa547 data/create/recipes/gabbro_bricks_from_gabbro_stonecutting.json a19f047fa8507e994eb026795c86bc10ff5c373b data/create/recipes/gabbro_bricks_slab.json 84d83643f7987864eca0e2ca7cda4330ad9f1f86 data/create/recipes/gabbro_bricks_slab_from_gabbro_bricks_stonecutting.json @@ -3246,6 +3260,7 @@ f7407fd04cfe7558d53c44cb33dfd8ff8a736ae3 data/create/recipes/gabbro_cobblestone_ 8171880f4374f9102949b85e9a17e0b313caf3a6 data/create/recipes/gabbro_cobblestone_wall_from_gabbro_cobblestone_stonecutting.json 6e52667c2f9ec62a95ba27676fdc07a8222f1746 data/create/recipes/gabbro_pillar.json da3743119130ef0946b05b21a84c2fe5926dccd5 data/create/recipes/gabbro_pillar_from_gabbro_stonecutting.json +dc21523e591068eb5df7b287c9eef7b773b7d5d0 data/create/recipes/granite.json 5664bad03fce4a4724e8fd21c9c02ca6ae900df9 data/create/recipes/granite_bricks_from_granite_stonecutting.json 1c5265828318670a11bd1e439b6a6005edb37487 data/create/recipes/granite_bricks_slab.json 0f460bda24ff799a9ef948933cfb50ef038739d4 data/create/recipes/granite_bricks_slab_from_granite_bricks_stonecutting.json @@ -3275,6 +3290,7 @@ b49c314e171f31a39f38aabad767d8d3be613602 data/create/recipes/layered_gabbro_from 9712031277020c39e8e643690a6a968c5e275a75 data/create/recipes/layered_limestone_from_limestone_stonecutting.json fdfbe941eb56a98c3d28639154b7bcd4dcc66dfa data/create/recipes/layered_scoria_from_scoria_stonecutting.json cc070e83594b20cf697aa5dbb8c4e09dbf576d00 data/create/recipes/layered_weathered_limestone_from_weathered_limestone_stonecutting.json +90253fc317a2551c50da7693df4a60e8543d2d64 data/create/recipes/limestone.json 3b43347da62a69c6e76e6a0261f840f46ff90038 data/create/recipes/limestone_bricks_from_limestone_stonecutting.json aed4b037af6921e9337213dc09a215ab7a18adde data/create/recipes/limestone_bricks_slab.json 7222e1f13c6aec69ea37c84b4aca3e2322ef00d2 data/create/recipes/limestone_bricks_slab_from_limestone_bricks_stonecutting.json @@ -3444,7 +3460,7 @@ f2a140cbaddefd387fd94f0ce94df763a585dd4f data/create/recipes/paved_weathered_lim 9f02f552173ae1c85750bb16aa6bbbfb87a5a7f1 data/create/recipes/paved_weathered_limestone_stairs_from_paved_weathered_limestone_stonecutting.json cc4a5a893b10ffdfcc10085323d89d34a1b8f122 data/create/recipes/paved_weathered_limestone_wall.json d996f6505433a74cd8bdab04c0e0bac1b9a2da16 data/create/recipes/paved_weathered_limestone_wall_from_paved_weathered_limestone_stonecutting.json -c83e29f260eee9844c85995d45bedef6100cb91d data/create/recipes/polished_dark_scoria.json +c32e1418b17011c8c423d44ee20f2b86e82e7626 data/create/recipes/polished_dark_scoria.json 753c85bfb84a5d31f9670478042321702a589dc8 data/create/recipes/polished_dark_scoria_from_dark_scoria_stonecutting.json d3c78c504672fec3316b206505c2cb5fc8daf822 data/create/recipes/polished_dark_scoria_slab.json bcc5a7325b7f7110e6b382e7ad60fc547222d3ad data/create/recipes/polished_dark_scoria_slab_from_polished_dark_scoria_stonecutting.json @@ -3452,7 +3468,7 @@ c7d7e5f39099a71482cdfbebe1ef2dfd508ae768 data/create/recipes/polished_dark_scori 364d77f01b380bbb0036810f6e0df09773ea8e1c data/create/recipes/polished_dark_scoria_stairs_from_polished_dark_scoria_stonecutting.json 396b6c97b5e7f608b293dee51be97717c3430bc4 data/create/recipes/polished_dark_scoria_wall.json 62b0769e0208831db822f6d2b986fff6aee60729 data/create/recipes/polished_dark_scoria_wall_from_polished_dark_scoria_stonecutting.json -53930b3b32b076c9786e5c61d8cc7fe70a47fed7 data/create/recipes/polished_dolomite.json +a1561acc26948db5cffc041d85b1d26204754caf data/create/recipes/polished_dolomite.json da91fd1ccaac64f7ef9737f3c773490d0c0b10d1 data/create/recipes/polished_dolomite_from_dolomite_stonecutting.json 75288e75b604eacfbc19cb51cb4d4759bdeaafa5 data/create/recipes/polished_dolomite_slab.json 9a89eaf5f00d8fb10297de61248f8d11dded8c4b data/create/recipes/polished_dolomite_slab_from_polished_dolomite_stonecutting.json @@ -3460,7 +3476,7 @@ da91fd1ccaac64f7ef9737f3c773490d0c0b10d1 data/create/recipes/polished_dolomite_f e2dce404e4bcde076615ed0d0cf6fab769d441d5 data/create/recipes/polished_dolomite_stairs_from_polished_dolomite_stonecutting.json 8f2f4643886d166609b198704dcadb5e87b6323e data/create/recipes/polished_dolomite_wall.json 3b5d553e408a8b6385932e2a8082fcb5bdead0d1 data/create/recipes/polished_dolomite_wall_from_polished_dolomite_stonecutting.json -d9d2b6f6f4c8223c4cfc6258ba9013463691d88c data/create/recipes/polished_gabbro.json +5873547a8561849a73c0d2cca3faba3e8b65b33d data/create/recipes/polished_gabbro.json ba3e1444b9d1804411cc9c7536c657806dc37c1d data/create/recipes/polished_gabbro_from_gabbro_stonecutting.json b7d29a29fde4868b4ceef1437e5d00975068bc58 data/create/recipes/polished_gabbro_slab.json f7a62c1edc74e54fc0c747f23d7da182d49ef7b6 data/create/recipes/polished_gabbro_slab_from_polished_gabbro_stonecutting.json @@ -3468,7 +3484,7 @@ f7a62c1edc74e54fc0c747f23d7da182d49ef7b6 data/create/recipes/polished_gabbro_sla 7df6fd466badaa3cef5e2ad0e78bbb3b6429805e data/create/recipes/polished_gabbro_stairs_from_polished_gabbro_stonecutting.json ec70334e13e05cff7e04e7dc6b23be273c235e50 data/create/recipes/polished_gabbro_wall.json 5176a8fe5a48592c7b487518a57c962c24e3e751 data/create/recipes/polished_gabbro_wall_from_polished_gabbro_stonecutting.json -bb7d651a6c79bd97390c7b1743c4fe58c9973c39 data/create/recipes/polished_limestone.json +59a01eb264c302fe455639bcafa4afb97de2379e data/create/recipes/polished_limestone.json 0e88c98c9ef0d15523b23b00f8afde71d9d8e3e9 data/create/recipes/polished_limestone_from_limestone_stonecutting.json 135fd40e291c7cfdc73c14496654008da9dd797d data/create/recipes/polished_limestone_slab.json 4ce225832ab45daf6b5bc013c6f8762fdbe9ff0f data/create/recipes/polished_limestone_slab_from_polished_limestone_stonecutting.json @@ -3476,7 +3492,7 @@ fee3d0ec8d4f27d82acd5d0e3a2a142900e18be3 data/create/recipes/polished_limestone_ 6780c8bd8747ebb6db7e0adfc486ce00e7e2cf26 data/create/recipes/polished_limestone_stairs_from_polished_limestone_stonecutting.json 44b1f3873fe8150abbacab10ff3cc2033a01b4a0 data/create/recipes/polished_limestone_wall.json d68a27e463d31ba5eed19181c0335824601b9e68 data/create/recipes/polished_limestone_wall_from_polished_limestone_stonecutting.json -300b9c979ac848fb6ae69eeb6e89c9e22056c562 data/create/recipes/polished_scoria.json +82b5b5fc1d2f789b48a48a7dc846aeb505b0c3c1 data/create/recipes/polished_scoria.json 9d6926822ea6f2bb38ba55204278fe82fd453d16 data/create/recipes/polished_scoria_from_scoria_stonecutting.json 814efd67d3f061d0c0ba104993c868e075a4fd3e data/create/recipes/polished_scoria_slab.json 8696f262927ae55ce72af1a34cae68fd6ccc4050 data/create/recipes/polished_scoria_slab_from_polished_scoria_stonecutting.json @@ -3484,7 +3500,7 @@ efe648aa4fd0f22faa78c016dbe2d083462e1ad6 data/create/recipes/polished_scoria_sta ba6dd9ad0c69b088c1a9e33000bd5b9bcedb0ca0 data/create/recipes/polished_scoria_stairs_from_polished_scoria_stonecutting.json 8319042a131a9dcabae016009b807b91c491f8d3 data/create/recipes/polished_scoria_wall.json bc9a83e7793768723031ff14269e43c83687b9f3 data/create/recipes/polished_scoria_wall_from_polished_scoria_stonecutting.json -31a0826653da3e752da8507a46b16dc17334693b data/create/recipes/polished_weathered_limestone.json +d9d188d55d9bb94bceaad8de3ccb02532b021576 data/create/recipes/polished_weathered_limestone.json 73b468de08f3e0542b7020129faff3a40b3fee67 data/create/recipes/polished_weathered_limestone_from_weathered_limestone_stonecutting.json c0924d72a856c3182b89996a6ceaffd56930c455 data/create/recipes/polished_weathered_limestone_slab.json 1f5503d22859a08eef824d33f6ed48335f66c423 data/create/recipes/polished_weathered_limestone_slab_from_polished_weathered_limestone_stonecutting.json @@ -3500,6 +3516,7 @@ a104ef6eb8872a40ea7b2ef67ae54cec943162f0 data/create/recipes/pressing/iron_ingot 654e274b07af172c22838d47e0974367c20101d4 data/create/recipes/pressing/path.json bd57ccc8eb4357b4a5af021db7b806b514cd2558 data/create/recipes/pressing/sugar_cane.json 141173778757d87e7f2e9466bdab6ff1263c8e98 data/create/recipes/sandpaper_polishing/rose_quartz.json +5ab9c8271a9e1d4a863940aeafd1f8816cb37a29 data/create/recipes/scoria.json d59c68621c78ff5d2c51be4440dea603480efed8 data/create/recipes/scoria_bricks_from_scoria_stonecutting.json a7a28cf77955c2b4ed3687205dd24162e461aa30 data/create/recipes/scoria_bricks_slab.json 0577ffde98e7a027b21c430cd71cdafdd3cee3a3 data/create/recipes/scoria_bricks_slab_from_scoria_bricks_stonecutting.json @@ -3630,6 +3647,7 @@ e2c1774577aeb0756fb1d092245d9d77e40ba5f8 data/create/recipes/splashing/yellow_co dc6093427210bd7034a0e2184f6a1630c7b33b3e data/create/recipes/vertical_framed_glass_pane.json 40ec72d571002206c276aec5de72459155e043ce data/create/recipes/warped_window.json 8f4b0a3cfb0073f1414bf18c0d4e5e751c4a9185 data/create/recipes/warped_window_pane.json +e483f41ab4e959bda4d88c23817913843d0fbef6 data/create/recipes/weathered_limestone.json f75f25d3259dd51c29bee6ada2a4540a7a2bbeab data/create/recipes/weathered_limestone_bricks_from_weathered_limestone_stonecutting.json f58ef5eb552fc7dcd89f30aa4231286ecef5e00a data/create/recipes/weathered_limestone_bricks_slab.json ca9b163b3aaa526d6c3b070c2a7e50a56a38c6f4 data/create/recipes/weathered_limestone_bricks_slab_from_weathered_limestone_bricks_stonecutting.json diff --git a/src/generated/resources/data/create/advancements/recipes/building_blocks/andesite.json b/src/generated/resources/data/create/advancements/recipes/building_blocks/andesite.json new file mode 100644 index 000000000..344f964cc --- /dev/null +++ b/src/generated/resources/data/create/advancements/recipes/building_blocks/andesite.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "create:andesite" + ] + }, + "criteria": { + "has_andesite_cobblestone": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:andesite_cobblestone" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "create:andesite" + } + } + }, + "requirements": [ + [ + "has_andesite_cobblestone", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/recipes/building_blocks/diorite.json b/src/generated/resources/data/create/advancements/recipes/building_blocks/diorite.json new file mode 100644 index 000000000..df09f4529 --- /dev/null +++ b/src/generated/resources/data/create/advancements/recipes/building_blocks/diorite.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "create:diorite" + ] + }, + "criteria": { + "has_diorite_cobblestone": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:diorite_cobblestone" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "create:diorite" + } + } + }, + "requirements": [ + [ + "has_diorite_cobblestone", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/recipes/building_blocks/granite.json b/src/generated/resources/data/create/advancements/recipes/building_blocks/granite.json new file mode 100644 index 000000000..f0a2adf3f --- /dev/null +++ b/src/generated/resources/data/create/advancements/recipes/building_blocks/granite.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "create:granite" + ] + }, + "criteria": { + "has_granite_cobblestone": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:granite_cobblestone" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "create:granite" + } + } + }, + "requirements": [ + [ + "has_granite_cobblestone", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/andesite_pillar.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/andesite_pillar.json index f8b57edb6..7c9df9388 100644 --- a/src/generated/resources/data/create/advancements/recipes/create.palettes/andesite_pillar.json +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/andesite_pillar.json @@ -6,7 +6,7 @@ ] }, "criteria": { - "has_ingredient": { + "has_andesite": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ @@ -25,7 +25,7 @@ }, "requirements": [ [ - "has_ingredient", + "has_andesite", "has_the_recipe" ] ] diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/dark_scoria.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/dark_scoria.json new file mode 100644 index 000000000..48a14dd4b --- /dev/null +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/dark_scoria.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "create:dark_scoria" + ] + }, + "criteria": { + "has_dark_scoria_cobblestone": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:dark_scoria_cobblestone" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "create:dark_scoria" + } + } + }, + "requirements": [ + [ + "has_dark_scoria_cobblestone", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/dark_scoria_pillar.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/dark_scoria_pillar.json index 351c3e02c..dc1bc8e5e 100644 --- a/src/generated/resources/data/create/advancements/recipes/create.palettes/dark_scoria_pillar.json +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/dark_scoria_pillar.json @@ -6,7 +6,7 @@ ] }, "criteria": { - "has_ingredient": { + "has_dark_scoria": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ @@ -25,7 +25,7 @@ }, "requirements": [ [ - "has_ingredient", + "has_dark_scoria", "has_the_recipe" ] ] diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/diorite_pillar.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/diorite_pillar.json index fea456f6c..846e74a19 100644 --- a/src/generated/resources/data/create/advancements/recipes/create.palettes/diorite_pillar.json +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/diorite_pillar.json @@ -6,7 +6,7 @@ ] }, "criteria": { - "has_ingredient": { + "has_diorite": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ @@ -25,7 +25,7 @@ }, "requirements": [ [ - "has_ingredient", + "has_diorite", "has_the_recipe" ] ] diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/dolomite.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/dolomite.json new file mode 100644 index 000000000..2ee623acf --- /dev/null +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/dolomite.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "create:dolomite" + ] + }, + "criteria": { + "has_dolomite_cobblestone": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:dolomite_cobblestone" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "create:dolomite" + } + } + }, + "requirements": [ + [ + "has_dolomite_cobblestone", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/dolomite_pillar.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/dolomite_pillar.json index ec49ae69a..d82162c4d 100644 --- a/src/generated/resources/data/create/advancements/recipes/create.palettes/dolomite_pillar.json +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/dolomite_pillar.json @@ -6,7 +6,7 @@ ] }, "criteria": { - "has_ingredient": { + "has_dolomite": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ @@ -25,7 +25,7 @@ }, "requirements": [ [ - "has_ingredient", + "has_dolomite", "has_the_recipe" ] ] diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/gabbro.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/gabbro.json new file mode 100644 index 000000000..85c5c99b3 --- /dev/null +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/gabbro.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "create:gabbro" + ] + }, + "criteria": { + "has_gabbro_cobblestone": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:gabbro_cobblestone" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "create:gabbro" + } + } + }, + "requirements": [ + [ + "has_gabbro_cobblestone", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/gabbro_pillar.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/gabbro_pillar.json index f6ec9691f..d33f4e3f3 100644 --- a/src/generated/resources/data/create/advancements/recipes/create.palettes/gabbro_pillar.json +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/gabbro_pillar.json @@ -6,7 +6,7 @@ ] }, "criteria": { - "has_ingredient": { + "has_gabbro": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ @@ -25,7 +25,7 @@ }, "requirements": [ [ - "has_ingredient", + "has_gabbro", "has_the_recipe" ] ] diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/granite_pillar.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/granite_pillar.json index 38443374f..884b1e38c 100644 --- a/src/generated/resources/data/create/advancements/recipes/create.palettes/granite_pillar.json +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/granite_pillar.json @@ -6,7 +6,7 @@ ] }, "criteria": { - "has_ingredient": { + "has_granite": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ @@ -25,7 +25,7 @@ }, "requirements": [ [ - "has_ingredient", + "has_granite", "has_the_recipe" ] ] diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/limestone.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/limestone.json new file mode 100644 index 000000000..1b38ab26f --- /dev/null +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/limestone.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "create:limestone" + ] + }, + "criteria": { + "has_limestone_cobblestone": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:limestone_cobblestone" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "create:limestone" + } + } + }, + "requirements": [ + [ + "has_limestone_cobblestone", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/limestone_pillar.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/limestone_pillar.json index 8150f5a59..2690c0cfc 100644 --- a/src/generated/resources/data/create/advancements/recipes/create.palettes/limestone_pillar.json +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/limestone_pillar.json @@ -6,7 +6,7 @@ ] }, "criteria": { - "has_ingredient": { + "has_limestone": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ @@ -25,7 +25,7 @@ }, "requirements": [ [ - "has_ingredient", + "has_limestone", "has_the_recipe" ] ] diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/scoria.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/scoria.json new file mode 100644 index 000000000..fc94ffc6f --- /dev/null +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/scoria.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "create:scoria" + ] + }, + "criteria": { + "has_scoria_cobblestone": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:scoria_cobblestone" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "create:scoria" + } + } + }, + "requirements": [ + [ + "has_scoria_cobblestone", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/scoria_pillar.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/scoria_pillar.json index 7d8e33863..e21ba1a34 100644 --- a/src/generated/resources/data/create/advancements/recipes/create.palettes/scoria_pillar.json +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/scoria_pillar.json @@ -6,7 +6,7 @@ ] }, "criteria": { - "has_ingredient": { + "has_scoria": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ @@ -25,7 +25,7 @@ }, "requirements": [ [ - "has_ingredient", + "has_scoria", "has_the_recipe" ] ] diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/weathered_limestone.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/weathered_limestone.json new file mode 100644 index 000000000..2b7672332 --- /dev/null +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/weathered_limestone.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "create:weathered_limestone" + ] + }, + "criteria": { + "has_weathered_limestone_cobblestone": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "create:weathered_limestone_cobblestone" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "create:weathered_limestone" + } + } + }, + "requirements": [ + [ + "has_weathered_limestone_cobblestone", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/create/advancements/recipes/create.palettes/weathered_limestone_pillar.json b/src/generated/resources/data/create/advancements/recipes/create.palettes/weathered_limestone_pillar.json index e9b129e93..6acc03c00 100644 --- a/src/generated/resources/data/create/advancements/recipes/create.palettes/weathered_limestone_pillar.json +++ b/src/generated/resources/data/create/advancements/recipes/create.palettes/weathered_limestone_pillar.json @@ -6,7 +6,7 @@ ] }, "criteria": { - "has_ingredient": { + "has_weathered_limestone": { "trigger": "minecraft:inventory_changed", "conditions": { "items": [ @@ -25,7 +25,7 @@ }, "requirements": [ [ - "has_ingredient", + "has_weathered_limestone", "has_the_recipe" ] ] diff --git a/src/generated/resources/data/create/loot_tables/blocks/dark_scoria.json b/src/generated/resources/data/create/loot_tables/blocks/dark_scoria.json index c26589bf5..912caa5f7 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/dark_scoria.json +++ b/src/generated/resources/data/create/loot_tables/blocks/dark_scoria.json @@ -5,13 +5,37 @@ "rolls": 1, "entries": [ { - "type": "minecraft:item", - "name": "create:dark_scoria" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ], + "name": "create:dark_scoria" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "name": "create:dark_scoria_cobblestone" + } + ] } ] } diff --git a/src/generated/resources/data/create/loot_tables/blocks/dolomite.json b/src/generated/resources/data/create/loot_tables/blocks/dolomite.json index d97bb3322..4085d60be 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/dolomite.json +++ b/src/generated/resources/data/create/loot_tables/blocks/dolomite.json @@ -5,13 +5,37 @@ "rolls": 1, "entries": [ { - "type": "minecraft:item", - "name": "create:dolomite" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ], + "name": "create:dolomite" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "name": "create:dolomite_cobblestone" + } + ] } ] } diff --git a/src/generated/resources/data/create/loot_tables/blocks/gabbro.json b/src/generated/resources/data/create/loot_tables/blocks/gabbro.json index 8446b845e..2f477a53e 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/gabbro.json +++ b/src/generated/resources/data/create/loot_tables/blocks/gabbro.json @@ -5,13 +5,37 @@ "rolls": 1, "entries": [ { - "type": "minecraft:item", - "name": "create:gabbro" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ], + "name": "create:gabbro" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "name": "create:gabbro_cobblestone" + } + ] } ] } diff --git a/src/generated/resources/data/create/loot_tables/blocks/limestone.json b/src/generated/resources/data/create/loot_tables/blocks/limestone.json index acec889d0..e5b513a61 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/limestone.json +++ b/src/generated/resources/data/create/loot_tables/blocks/limestone.json @@ -5,13 +5,37 @@ "rolls": 1, "entries": [ { - "type": "minecraft:item", - "name": "create:limestone" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ], + "name": "create:limestone" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "name": "create:limestone_cobblestone" + } + ] } ] } diff --git a/src/generated/resources/data/create/loot_tables/blocks/scoria.json b/src/generated/resources/data/create/loot_tables/blocks/scoria.json index 0025a35ae..a119016fa 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/scoria.json +++ b/src/generated/resources/data/create/loot_tables/blocks/scoria.json @@ -5,13 +5,37 @@ "rolls": 1, "entries": [ { - "type": "minecraft:item", - "name": "create:scoria" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ], + "name": "create:scoria" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "name": "create:scoria_cobblestone" + } + ] } ] } diff --git a/src/generated/resources/data/create/loot_tables/blocks/weathered_limestone.json b/src/generated/resources/data/create/loot_tables/blocks/weathered_limestone.json index 9a11fe4be..e2f779734 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/weathered_limestone.json +++ b/src/generated/resources/data/create/loot_tables/blocks/weathered_limestone.json @@ -5,13 +5,37 @@ "rolls": 1, "entries": [ { - "type": "minecraft:item", - "name": "create:weathered_limestone" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ], + "name": "create:weathered_limestone" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "name": "create:weathered_limestone_cobblestone" + } + ] } ] } diff --git a/src/generated/resources/data/create/recipes/andesite.json b/src/generated/resources/data/create/recipes/andesite.json new file mode 100644 index 000000000..1a8a89094 --- /dev/null +++ b/src/generated/resources/data/create/recipes/andesite.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "create:andesite_cobblestone" + }, + "result": "minecraft:andesite", + "experience": 0.1, + "cookingtime": 200 +} \ No newline at end of file diff --git a/src/generated/resources/data/create/recipes/dark_scoria.json b/src/generated/resources/data/create/recipes/dark_scoria.json new file mode 100644 index 000000000..e8677d0a9 --- /dev/null +++ b/src/generated/resources/data/create/recipes/dark_scoria.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "create:dark_scoria_cobblestone" + }, + "result": "create:dark_scoria", + "experience": 0.1, + "cookingtime": 200 +} \ No newline at end of file diff --git a/src/generated/resources/data/create/recipes/diorite.json b/src/generated/resources/data/create/recipes/diorite.json new file mode 100644 index 000000000..a9dc4b737 --- /dev/null +++ b/src/generated/resources/data/create/recipes/diorite.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "create:diorite_cobblestone" + }, + "result": "minecraft:diorite", + "experience": 0.1, + "cookingtime": 200 +} \ No newline at end of file diff --git a/src/generated/resources/data/create/recipes/dolomite.json b/src/generated/resources/data/create/recipes/dolomite.json new file mode 100644 index 000000000..c59ecebbb --- /dev/null +++ b/src/generated/resources/data/create/recipes/dolomite.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "create:dolomite_cobblestone" + }, + "result": "create:dolomite", + "experience": 0.1, + "cookingtime": 200 +} \ No newline at end of file diff --git a/src/generated/resources/data/create/recipes/gabbro.json b/src/generated/resources/data/create/recipes/gabbro.json new file mode 100644 index 000000000..6d05576cb --- /dev/null +++ b/src/generated/resources/data/create/recipes/gabbro.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "create:gabbro_cobblestone" + }, + "result": "create:gabbro", + "experience": 0.1, + "cookingtime": 200 +} \ No newline at end of file diff --git a/src/generated/resources/data/create/recipes/granite.json b/src/generated/resources/data/create/recipes/granite.json new file mode 100644 index 000000000..2a6e30e9b --- /dev/null +++ b/src/generated/resources/data/create/recipes/granite.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "create:granite_cobblestone" + }, + "result": "minecraft:granite", + "experience": 0.1, + "cookingtime": 200 +} \ No newline at end of file diff --git a/src/generated/resources/data/create/recipes/limestone.json b/src/generated/resources/data/create/recipes/limestone.json new file mode 100644 index 000000000..90c360ab1 --- /dev/null +++ b/src/generated/resources/data/create/recipes/limestone.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "create:limestone_cobblestone" + }, + "result": "create:limestone", + "experience": 0.1, + "cookingtime": 200 +} \ No newline at end of file diff --git a/src/generated/resources/data/create/recipes/polished_dark_scoria.json b/src/generated/resources/data/create/recipes/polished_dark_scoria.json index 1dcca3f52..5a9cfcde0 100644 --- a/src/generated/resources/data/create/recipes/polished_dark_scoria.json +++ b/src/generated/resources/data/create/recipes/polished_dark_scoria.json @@ -1,11 +1,11 @@ { "type": "minecraft:crafting_shaped", "pattern": [ - "XX", - "XX" + "##", + "##" ], "key": { - "X": { + "#": { "item": "create:dark_scoria" } }, diff --git a/src/generated/resources/data/create/recipes/polished_dolomite.json b/src/generated/resources/data/create/recipes/polished_dolomite.json index 16fbd2463..4fcd09891 100644 --- a/src/generated/resources/data/create/recipes/polished_dolomite.json +++ b/src/generated/resources/data/create/recipes/polished_dolomite.json @@ -1,11 +1,11 @@ { "type": "minecraft:crafting_shaped", "pattern": [ - "XX", - "XX" + "##", + "##" ], "key": { - "X": { + "#": { "item": "create:dolomite" } }, diff --git a/src/generated/resources/data/create/recipes/polished_gabbro.json b/src/generated/resources/data/create/recipes/polished_gabbro.json index c9fb7b71a..5c9cfe964 100644 --- a/src/generated/resources/data/create/recipes/polished_gabbro.json +++ b/src/generated/resources/data/create/recipes/polished_gabbro.json @@ -1,11 +1,11 @@ { "type": "minecraft:crafting_shaped", "pattern": [ - "XX", - "XX" + "##", + "##" ], "key": { - "X": { + "#": { "item": "create:gabbro" } }, diff --git a/src/generated/resources/data/create/recipes/polished_limestone.json b/src/generated/resources/data/create/recipes/polished_limestone.json index e07df319b..13556fd93 100644 --- a/src/generated/resources/data/create/recipes/polished_limestone.json +++ b/src/generated/resources/data/create/recipes/polished_limestone.json @@ -1,11 +1,11 @@ { "type": "minecraft:crafting_shaped", "pattern": [ - "XX", - "XX" + "##", + "##" ], "key": { - "X": { + "#": { "item": "create:limestone" } }, diff --git a/src/generated/resources/data/create/recipes/polished_scoria.json b/src/generated/resources/data/create/recipes/polished_scoria.json index 796ad769a..4ccbf5c05 100644 --- a/src/generated/resources/data/create/recipes/polished_scoria.json +++ b/src/generated/resources/data/create/recipes/polished_scoria.json @@ -1,11 +1,11 @@ { "type": "minecraft:crafting_shaped", "pattern": [ - "XX", - "XX" + "##", + "##" ], "key": { - "X": { + "#": { "item": "create:scoria" } }, diff --git a/src/generated/resources/data/create/recipes/polished_weathered_limestone.json b/src/generated/resources/data/create/recipes/polished_weathered_limestone.json index 3d29b1740..cd0a57df5 100644 --- a/src/generated/resources/data/create/recipes/polished_weathered_limestone.json +++ b/src/generated/resources/data/create/recipes/polished_weathered_limestone.json @@ -1,11 +1,11 @@ { "type": "minecraft:crafting_shaped", "pattern": [ - "XX", - "XX" + "##", + "##" ], "key": { - "X": { + "#": { "item": "create:weathered_limestone" } }, diff --git a/src/generated/resources/data/create/recipes/scoria.json b/src/generated/resources/data/create/recipes/scoria.json new file mode 100644 index 000000000..d63cf40bf --- /dev/null +++ b/src/generated/resources/data/create/recipes/scoria.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "create:scoria_cobblestone" + }, + "result": "create:scoria", + "experience": 0.1, + "cookingtime": 200 +} \ No newline at end of file diff --git a/src/generated/resources/data/create/recipes/weathered_limestone.json b/src/generated/resources/data/create/recipes/weathered_limestone.json new file mode 100644 index 000000000..93ce442c8 --- /dev/null +++ b/src/generated/resources/data/create/recipes/weathered_limestone.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "create:weathered_limestone_cobblestone" + }, + "result": "create:weathered_limestone", + "experience": 0.1, + "cookingtime": 200 +} \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/AllSpriteShifts.java b/src/main/java/com/simibubi/create/AllSpriteShifts.java index 224d852a7..1eba9a59f 100644 --- a/src/main/java/com/simibubi/create/AllSpriteShifts.java +++ b/src/main/java/com/simibubi/create/AllSpriteShifts.java @@ -8,8 +8,8 @@ import static com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTT import java.util.IdentityHashMap; import java.util.Map; -import com.simibubi.create.content.palettes.PaletteBlockPatterns; -import com.simibubi.create.content.palettes.PaletteBlockPatterns.CTs; +import com.simibubi.create.content.palettes.PaletteBlockPattern; +import com.simibubi.create.content.palettes.PaletteBlockPattern.CTs; import com.simibubi.create.content.palettes.PaletteStoneVariants; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.block.connected.CTSpriteShifter.CTType; @@ -23,7 +23,7 @@ import net.minecraft.item.DyeColor; public class AllSpriteShifts { static final Map WOODEN_WINDOWS = new IdentityHashMap<>(); - static final Map> PALETTE_VARIANT_PATTERNS = + static final Map> PALETTE_VARIANT_PATTERNS = new IdentityHashMap<>(); public static final Map DYED_BELTS = new IdentityHashMap<>(), @@ -69,7 +69,7 @@ public class AllSpriteShifts { return WOODEN_WINDOWS.get(woodType); } - public static CTSpriteShiftEntry getVariantPattern(PaletteStoneVariants variant, PaletteBlockPatterns.CTs texture) { + public static CTSpriteShiftEntry getVariantPattern(PaletteStoneVariants variant, PaletteBlockPattern.CTs texture) { return PALETTE_VARIANT_PATTERNS.get(variant) .get(texture); } @@ -85,7 +85,7 @@ public class AllSpriteShifts { IdentityHashMap map = new IdentityHashMap<>(); PALETTE_VARIANT_PATTERNS.put(paletteStoneVariants, map); - for (PaletteBlockPatterns.CTs texture : PaletteBlockPatterns.CTs.values()) { + for (PaletteBlockPattern.CTs texture : PaletteBlockPattern.CTs.values()) { String textureName = Lang.asId(texture.name()); String target = "palettes/" + variantName + "/" + textureName; map.put(texture, getCT(texture.type, target)); diff --git a/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java b/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java index b3042abf2..b60407fe8 100644 --- a/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java +++ b/src/main/java/com/simibubi/create/content/palettes/AllPaletteBlocks.java @@ -96,13 +96,13 @@ public class AllPaletteBlocks { // Vanilla stone variant patterns public static final PalettesVariantEntry GRANITE_VARIANTS = - new PalettesVariantEntry(PaletteStoneVariants.GRANITE, PaletteBlockPatterns.vanillaRange, () -> Blocks.GRANITE); + new PalettesVariantEntry(PaletteStoneVariants.GRANITE, PaletteBlockPattern.VANILLA_RANGE, () -> Blocks.GRANITE); public static final PalettesVariantEntry DIORITE_VARIANTS = - new PalettesVariantEntry(PaletteStoneVariants.DIORITE, PaletteBlockPatterns.vanillaRange, () -> Blocks.DIORITE); + new PalettesVariantEntry(PaletteStoneVariants.DIORITE, PaletteBlockPattern.VANILLA_RANGE, () -> Blocks.DIORITE); public static final PalettesVariantEntry ANDESITE_VARIANTS = new PalettesVariantEntry(PaletteStoneVariants.ANDESITE, - PaletteBlockPatterns.vanillaRange, () -> Blocks.ANDESITE); + PaletteBlockPattern.VANILLA_RANGE, () -> Blocks.ANDESITE); // Create stone variants @@ -115,37 +115,42 @@ public class AllPaletteBlocks { public static final BlockEntry LIMESTONE = REGISTRATE.baseBlock("limestone", Block::new, () -> Blocks.SANDSTONE, true) .tag(BlockTags.BASE_STONE_OVERWORLD) + .loot(cobblestoneLoot(PaletteStoneVariants.LIMESTONE)) .register(); public static final PalettesVariantEntry LIMESTONE_VARIANTS = - new PalettesVariantEntry(PaletteStoneVariants.LIMESTONE, PaletteBlockPatterns.standardRange, LIMESTONE); + new PalettesVariantEntry(PaletteStoneVariants.LIMESTONE, PaletteBlockPattern.STANDARD_RANGE, LIMESTONE); public static final BlockEntry WEATHERED_LIMESTONE = REGISTRATE.baseBlock("weathered_limestone", Block::new, () -> Blocks.SANDSTONE, true) .tag(BlockTags.BASE_STONE_OVERWORLD) + .loot(cobblestoneLoot(PaletteStoneVariants.WEATHERED_LIMESTONE)) .register(); public static final PalettesVariantEntry WEATHERED_LIMESTONE_VARIANTS = new PalettesVariantEntry( - PaletteStoneVariants.WEATHERED_LIMESTONE, PaletteBlockPatterns.standardRange, WEATHERED_LIMESTONE); + PaletteStoneVariants.WEATHERED_LIMESTONE, PaletteBlockPattern.STANDARD_RANGE, WEATHERED_LIMESTONE); public static final BlockEntry DOLOMITE = REGISTRATE.baseBlock("dolomite", Block::new, () -> Blocks.QUARTZ_BLOCK, true) .tag(BlockTags.BASE_STONE_OVERWORLD) + .loot(cobblestoneLoot(PaletteStoneVariants.DOLOMITE)) .register(); public static final PalettesVariantEntry DOLOMITE_VARIANTS = - new PalettesVariantEntry(PaletteStoneVariants.DOLOMITE, PaletteBlockPatterns.standardRange, DOLOMITE); + new PalettesVariantEntry(PaletteStoneVariants.DOLOMITE, PaletteBlockPattern.STANDARD_RANGE, DOLOMITE); public static final BlockEntry GABBRO = REGISTRATE.baseBlock("gabbro", Block::new, () -> Blocks.ANDESITE, true) .tag(BlockTags.BASE_STONE_OVERWORLD) + .loot(cobblestoneLoot(PaletteStoneVariants.GABBRO)) .register(); public static final PalettesVariantEntry GABBRO_VARIANTS = - new PalettesVariantEntry(PaletteStoneVariants.GABBRO, PaletteBlockPatterns.standardRange, GABBRO); + new PalettesVariantEntry(PaletteStoneVariants.GABBRO, PaletteBlockPattern.STANDARD_RANGE, GABBRO); public static final BlockEntry SCORIA = REGISTRATE.baseBlock("scoria", Block::new, () -> Blocks.ANDESITE, true) + .loot(cobblestoneLoot(PaletteStoneVariants.SCORIA)) .register(); public static final BlockEntry NATURAL_SCORIA = REGISTRATE.block("natural_scoria", Block::new) @@ -158,18 +163,25 @@ public class AllPaletteBlocks { .register(); public static final PalettesVariantEntry SCORIA_VARIANTS = - new PalettesVariantEntry(PaletteStoneVariants.SCORIA, PaletteBlockPatterns.standardRange, SCORIA); + new PalettesVariantEntry(PaletteStoneVariants.SCORIA, PaletteBlockPattern.STANDARD_RANGE, SCORIA); public static final BlockEntry DARK_SCORIA = REGISTRATE.baseBlock("dark_scoria", Block::new, () -> Blocks.ANDESITE, false) + .loot(cobblestoneLoot(PaletteStoneVariants.DARK_SCORIA)) .register(); public static final PalettesVariantEntry DARK_SCORIA_VARIANTS = - new PalettesVariantEntry(PaletteStoneVariants.DARK_SCORIA, PaletteBlockPatterns.standardRange, DARK_SCORIA); + new PalettesVariantEntry(PaletteStoneVariants.DARK_SCORIA, PaletteBlockPattern.STANDARD_RANGE, DARK_SCORIA); - public static void register() {} + private static NonNullBiConsumer cobblestoneLoot(PaletteStoneVariants variant) { + return (loot, block) -> loot.registerLootTable(block, RegistrateBlockLootTables.droppingWithSilkTouch(block, + variant.getVariants().registeredBlocks.get(0).get())); + } private static NonNullBiConsumer, RegistrateBlockstateProvider> palettesCubeAll() { return (c, p) -> BlockStateGen.cubeAll(c, p, "palettes/"); } + + public static void register() {} + } diff --git a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java index ba6ff24a4..9c79046af 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java +++ b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPartial.java @@ -34,8 +34,8 @@ public abstract class PaletteBlockPartial { public static final PaletteBlockPartial UNIQUE_SLAB = new Slab(true); public static final PaletteBlockPartial WALL = new Wall(); - public static final PaletteBlockPartial[] AllPartials = { STAIR, SLAB, WALL }; - public static final PaletteBlockPartial[] ForPolished = { STAIR, UNIQUE_SLAB, WALL }; + public static final PaletteBlockPartial[] ALL_PARTIALS = { STAIR, SLAB, WALL }; + public static final PaletteBlockPartial[] FOR_POLISHED = { STAIR, UNIQUE_SLAB, WALL }; private String name; @@ -43,7 +43,7 @@ public abstract class PaletteBlockPartial { this.name = name; } - public @NonnullType BlockBuilder create(String variantName, PaletteBlockPatterns pattern, + public @NonnullType BlockBuilder create(String variantName, PaletteBlockPattern pattern, Supplier block) { String patternName = pattern.createName(variantName); String blockName = patternName + "_" + this.name; @@ -57,19 +57,19 @@ public abstract class PaletteBlockPartial { .build(); } - protected ResourceLocation getMainTexture(String variantName, PaletteBlockPatterns pattern) { + protected ResourceLocation getMainTexture(String variantName, PaletteBlockPattern pattern) { return pattern.toLocation(variantName, pattern.getTextureForPartials()); } protected BlockBuilder transformBlock(BlockBuilder builder, - String variantName, PaletteBlockPatterns pattern) { + String variantName, PaletteBlockPattern pattern) { getBlockTags().forEach(builder::tag); return builder; } protected ItemBuilder> transformItem( ItemBuilder> builder, String variantName, - PaletteBlockPatterns pattern) { + PaletteBlockPattern pattern) { getItemTags().forEach(builder::tag); return builder; } @@ -84,7 +84,7 @@ public abstract class PaletteBlockPartial { RegistrateRecipeProvider p); protected abstract void generateBlockState(DataGenContext ctx, RegistrateBlockstateProvider prov, - String variantName, PaletteBlockPatterns pattern, Supplier block); + String variantName, PaletteBlockPattern pattern, Supplier block); private static class Stairs extends PaletteBlockPartial { @@ -100,7 +100,7 @@ public abstract class PaletteBlockPartial { @Override protected void generateBlockState(DataGenContext ctx, RegistrateBlockstateProvider prov, - String variantName, PaletteBlockPatterns pattern, Supplier block) { + String variantName, PaletteBlockPattern pattern, Supplier block) { prov.stairsBlock(ctx.get(), getMainTexture(variantName, pattern)); } @@ -140,7 +140,7 @@ public abstract class PaletteBlockPartial { @Override protected void generateBlockState(DataGenContext ctx, RegistrateBlockstateProvider prov, - String variantName, PaletteBlockPatterns pattern, Supplier block) { + String variantName, PaletteBlockPattern pattern, Supplier block) { String name = ctx.getName(); ResourceLocation mainTexture = getMainTexture(variantName, pattern); ResourceLocation sideTexture = @@ -185,7 +185,7 @@ public abstract class PaletteBlockPartial { @Override protected BlockBuilder transformBlock( BlockBuilder builder, - String variantName, PaletteBlockPatterns pattern) { + String variantName, PaletteBlockPattern pattern) { builder.loot((lt, block) -> lt.registerLootTable(block, RegistrateBlockLootTables.droppingSlab(block))); return super.transformBlock(builder, variantName, pattern); } @@ -206,14 +206,14 @@ public abstract class PaletteBlockPartial { @Override protected ItemBuilder> transformItem( ItemBuilder> builder, String variantName, - PaletteBlockPatterns pattern) { + PaletteBlockPattern pattern) { builder.model((c, p) -> p.wallInventory(c.getName(), getMainTexture(variantName, pattern))); return super.transformItem(builder, variantName, pattern); } @Override protected void generateBlockState(DataGenContext ctx, RegistrateBlockstateProvider prov, - String variantName, PaletteBlockPatterns pattern, Supplier block) { + String variantName, PaletteBlockPattern pattern, Supplier block) { prov.wallBlock(ctx.get(), pattern.createName(variantName), getMainTexture(variantName, pattern)); } diff --git a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPatterns.java b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java similarity index 70% rename from src/main/java/com/simibubi/create/content/palettes/PaletteBlockPatterns.java rename to src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java index 4fa8d9b7d..16cdd6dfe 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPatterns.java +++ b/src/main/java/com/simibubi/create/content/palettes/PaletteBlockPattern.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.palettes; -import static com.simibubi.create.content.palettes.PaletteBlockPartial.AllPartials; -import static com.simibubi.create.content.palettes.PaletteBlockPartial.ForPolished; -import static com.simibubi.create.content.palettes.PatternNameType.Prefix; -import static com.simibubi.create.content.palettes.PatternNameType.Suffix; -import static com.simibubi.create.content.palettes.PatternNameType.Wrap; +import static com.simibubi.create.content.palettes.PaletteBlockPartial.ALL_PARTIALS; +import static com.simibubi.create.content.palettes.PaletteBlockPartial.FOR_POLISHED; +import static com.simibubi.create.content.palettes.PaletteBlockPattern.PatternNameType.PREFIX; +import static com.simibubi.create.content.palettes.PaletteBlockPattern.PatternNameType.SUFFIX; +import static com.simibubi.create.content.palettes.PaletteBlockPattern.PatternNameType.WRAP; import java.util.Optional; import java.util.function.Function; @@ -28,73 +28,83 @@ import net.minecraft.block.AbstractBlock.Properties; import net.minecraft.block.Block; import net.minecraft.block.RotatedPillarBlock; import net.minecraft.client.renderer.RenderType; +import net.minecraft.data.CookingRecipeBuilder; import net.minecraft.data.ShapedRecipeBuilder; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.generators.ModelFile; -public class PaletteBlockPatterns { +public class PaletteBlockPattern { - public static final PaletteBlockPatterns + public static final PaletteBlockPattern - COBBLESTONE = create("cobblestone", Suffix, AllPartials), + COBBLESTONE = create("cobblestone", SUFFIX, ALL_PARTIALS) + .addRecipes(v -> (c, p) -> { + DataIngredient ingredient = DataIngredient.items(c.get()); + Block result = v.getBaseBlock().get(); + CookingRecipeBuilder.smeltingRecipe(ingredient, result, 0.1f, 200) + .addCriterion("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) + .build(p, p.safeId(result)); + }), - POLISHED = create("polished", Prefix, ForPolished) - .addRecipes(v -> (c, - p) -> { + POLISHED = create("polished", PREFIX, FOR_POLISHED) + .addRecipes(v -> (c, p) -> { DataIngredient ingredient = DataIngredient.items(v.getBaseBlock().get()); - ShapedRecipeBuilder.shapedRecipe(c.get(), 4).key('X', ingredient) - .patternLine("XX").patternLine("XX") - .addCriterion("has_" + p.safeName(ingredient), ingredient.getCritereon(p)).build(p, p.safeId(c.get())); - } - ), + ShapedRecipeBuilder.shapedRecipe(c.get(), 4) + .key('#', ingredient) + .patternLine("##") + .patternLine("##") + .addCriterion("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) + .build(p, p.safeId(c.get())); + }), - BRICKS = create("bricks", Suffix, AllPartials), FANCY_BRICKS = create("fancy_bricks", Wrap, AllPartials), + BRICKS = create("bricks", SUFFIX, ALL_PARTIALS), FANCY_BRICKS = create("fancy_bricks", WRAP, ALL_PARTIALS), - PAVED = create("paved", Prefix, AllPartials).blockStateFactory(p -> p::paved) + PAVED = create("paved", PREFIX, ALL_PARTIALS).blockStateFactory(p -> p::paved) .block(PavedBlock::new) .textures("paved", "paved_borderless", "paved_top"), - LAYERED = create("layered", Prefix).blockStateFactory(p -> p::cubeColumn) + LAYERED = create("layered", PREFIX).blockStateFactory(p -> p::cubeColumn) .textures("layered", "polished") .connectedTextures(v -> new HorizontalCTBehaviour(ct(v, CTs.LAYERED), ct(v, CTs.POLISHED))), - CHISELED = create("chiseled", Prefix).blockStateFactory(p -> p::cubeColumn) + CHISELED = create("chiseled", PREFIX).blockStateFactory(p -> p::cubeColumn) .textures("chiseled", "chiseled_top"), - PILLAR = create("pillar", Suffix).blockStateFactory(p -> p::pillar) + PILLAR = create("pillar", SUFFIX).blockStateFactory(p -> p::pillar) .block(RotatedPillarBlock::new) .textures("pillar", "pillar_end") - .addRecipes(v -> (c, p) -> ShapedRecipeBuilder.shapedRecipe(c.get(), 2) - .key('#', v.getBaseBlock() - .get()) - .patternLine("#") - .patternLine("#") - .addCriterion("has_ingredient", p.hasItem(v.getBaseBlock() - .get())) - .build(p::accept)), + .addRecipes(v -> (c, p) -> { + DataIngredient ingredient = DataIngredient.items(v.getBaseBlock().get()); + ShapedRecipeBuilder.shapedRecipe(c.get(), 2) + .key('#', ingredient) + .patternLine("#") + .patternLine("#") + .addCriterion("has_" + p.safeName(ingredient), ingredient.getCritereon(p)) + .build(p, p.safeId(c.get())); + }), - MOSSY = create("mossy", Prefix).blockStateFactory(p -> p::cubeAllButMossy) + MOSSY = create("mossy", PREFIX).blockStateFactory(p -> p::cubeAllButMossy) .textures("bricks", "mossy") .useTranslucentLayer() .withFoliage(), - OVERGROWN = create("overgrown", Prefix).blockStateFactory(p -> p::cubeAllButMossy) + OVERGROWN = create("overgrown", PREFIX).blockStateFactory(p -> p::cubeAllButMossy) .textures("bricks", "overgrown") .useTranslucentLayer() .withFoliage() ; - public static final PaletteBlockPatterns[] vanillaRange = + public static final PaletteBlockPattern[] VANILLA_RANGE = { COBBLESTONE, BRICKS, FANCY_BRICKS, PILLAR, PAVED, LAYERED, MOSSY, OVERGROWN }; - public static final PaletteBlockPatterns[] standardRange = + public static final PaletteBlockPattern[] STANDARD_RANGE = { COBBLESTONE, POLISHED, BRICKS, FANCY_BRICKS, PILLAR, PAVED, LAYERED, CHISELED, MOSSY, OVERGROWN }; - static final String textureLocation = "block/palettes/%s/%s"; - static final String overlayLocation = "block/palettes/%s"; + static final String TEXTURE_LOCATION = "block/palettes/%s/%s"; + static final String OVERLAY_LOCATION = "block/palettes/%s"; private PatternNameType nameType; private String[] textures; @@ -111,9 +121,9 @@ public class PaletteBlockPatterns { @OnlyIn(Dist.CLIENT) private RenderType renderType; - private static PaletteBlockPatterns create(String name, PatternNameType nameType, + private static PaletteBlockPattern create(String name, PatternNameType nameType, PaletteBlockPartial... partials) { - PaletteBlockPatterns pattern = new PaletteBlockPatterns(); + PaletteBlockPattern pattern = new PaletteBlockPattern(); pattern.id = name; pattern.ctBehaviour = Optional.empty(); pattern.nameType = nameType; @@ -163,37 +173,37 @@ public class PaletteBlockPatterns { // Builder - private PaletteBlockPatterns blockStateFactory(IPatternBlockStateGenerator factory) { + private PaletteBlockPattern blockStateFactory(IPatternBlockStateGenerator factory) { blockStateGenerator = factory; return this; } - private PaletteBlockPatterns textures(String... textures) { + private PaletteBlockPattern textures(String... textures) { this.textures = textures; return this; } - private PaletteBlockPatterns block(NonNullFunction blockFactory) { + private PaletteBlockPattern block(NonNullFunction blockFactory) { this.blockFactory = blockFactory; return this; } - private PaletteBlockPatterns useTranslucentLayer() { + private PaletteBlockPattern useTranslucentLayer() { isTranslucent = true; return this; } - private PaletteBlockPatterns withFoliage() { + private PaletteBlockPattern withFoliage() { hasFoliage = true; return this; } - private PaletteBlockPatterns connectedTextures(Function factory) { + private PaletteBlockPattern connectedTextures(Function factory) { this.ctBehaviour = Optional.of(factory); return this; } - private PaletteBlockPatterns addRecipes( + private PaletteBlockPattern addRecipes( NonNullFunction, RegistrateRecipeProvider>> func) { this.additionalRecipes = func; return this; @@ -251,7 +261,7 @@ public class PaletteBlockPatterns { // Utility protected String createName(String variant) { - if (nameType == Wrap) { + if (nameType == WRAP) { String[] split = id.split("_"); if (split.length == 2) { String formatString = "%s_%s_%s"; @@ -259,15 +269,15 @@ public class PaletteBlockPatterns { } } String formatString = "%s_%s"; - return nameType == Suffix ? String.format(formatString, variant, id) : String.format(formatString, id, variant); + return nameType == SUFFIX ? String.format(formatString, variant, id) : String.format(formatString, id, variant); } protected ResourceLocation toLocation(String variant, String texture) { - return Create.asResource(String.format(textureLocation, variant, texture)); + return Create.asResource(String.format(TEXTURE_LOCATION, variant, texture)); } protected ResourceLocation toOverlayLocation(String texture) { - return Create.asResource(String.format(overlayLocation, texture)); + return Create.asResource(String.format(OVERLAY_LOCATION, texture)); } protected static CTSpriteShiftEntry ct(PaletteStoneVariants variant, CTs texture) { @@ -276,7 +286,7 @@ public class PaletteBlockPatterns { @FunctionalInterface static interface IPatternBlockStateGenerator - extends Function> { + extends Function> { } @FunctionalInterface @@ -284,6 +294,10 @@ public class PaletteBlockPatterns { extends NonNullBiConsumer, RegistrateBlockstateProvider> { } + enum PatternNameType { + PREFIX, SUFFIX, WRAP + } + // Textures with connectability, used by Spriteshifter public static enum CTs { diff --git a/src/main/java/com/simibubi/create/content/palettes/PaletteStoneVariants.java b/src/main/java/com/simibubi/create/content/palettes/PaletteStoneVariants.java index ac43b64e9..f15d019f3 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PaletteStoneVariants.java +++ b/src/main/java/com/simibubi/create/content/palettes/PaletteStoneVariants.java @@ -7,26 +7,32 @@ import net.minecraft.block.Blocks; public enum PaletteStoneVariants { - GRANITE(() -> () -> Blocks.GRANITE), - DIORITE(() -> () -> Blocks.DIORITE), - ANDESITE(() -> () -> Blocks.ANDESITE), - LIMESTONE(() -> AllPaletteBlocks.LIMESTONE), - WEATHERED_LIMESTONE(() -> AllPaletteBlocks.WEATHERED_LIMESTONE), - DOLOMITE(() -> AllPaletteBlocks.DOLOMITE), - GABBRO(() -> AllPaletteBlocks.GABBRO), - SCORIA(() -> AllPaletteBlocks.SCORIA), - DARK_SCORIA(() -> AllPaletteBlocks.DARK_SCORIA) + GRANITE(() -> () -> Blocks.GRANITE, () -> AllPaletteBlocks.GRANITE_VARIANTS), + DIORITE(() -> () -> Blocks.DIORITE, () -> AllPaletteBlocks.DIORITE_VARIANTS), + ANDESITE(() -> () -> Blocks.ANDESITE, () -> AllPaletteBlocks.ANDESITE_VARIANTS), + LIMESTONE(() -> AllPaletteBlocks.LIMESTONE, () -> AllPaletteBlocks.LIMESTONE_VARIANTS), + WEATHERED_LIMESTONE(() -> AllPaletteBlocks.WEATHERED_LIMESTONE, () -> AllPaletteBlocks.WEATHERED_LIMESTONE_VARIANTS), + DOLOMITE(() -> AllPaletteBlocks.DOLOMITE, () -> AllPaletteBlocks.DOLOMITE_VARIANTS), + GABBRO(() -> AllPaletteBlocks.GABBRO, () -> AllPaletteBlocks.GABBRO_VARIANTS), + SCORIA(() -> AllPaletteBlocks.SCORIA, () -> AllPaletteBlocks.SCORIA_VARIANTS), + DARK_SCORIA(() -> AllPaletteBlocks.DARK_SCORIA, () -> AllPaletteBlocks.DARK_SCORIA_VARIANTS) ; private Supplier> baseBlock; + private Supplier variants; - private PaletteStoneVariants(Supplier> baseBlock) { + private PaletteStoneVariants(Supplier> baseBlock, Supplier variants) { this.baseBlock = baseBlock; + this.variants = variants; } public Supplier getBaseBlock() { return baseBlock.get(); } + public PalettesVariantEntry getVariants() { + return variants.get(); + } + } diff --git a/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java b/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java index 794016d13..76ab74af3 100644 --- a/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java +++ b/src/main/java/com/simibubi/create/content/palettes/PalettesVariantEntry.java @@ -21,14 +21,13 @@ public class PalettesVariantEntry { public ImmutableList> registeredBlocks; public ImmutableList> registeredPartials; - public PalettesVariantEntry(PaletteStoneVariants variant, PaletteBlockPatterns[] patterns, + public PalettesVariantEntry(PaletteStoneVariants variant, PaletteBlockPattern[] patterns, NonNullSupplier initialProperties) { - String name = Lang.asId(variant.name()); ImmutableList.Builder> registeredBlocks = ImmutableList.builder(); ImmutableList.Builder> registeredPartials = ImmutableList.builder(); - for (PaletteBlockPatterns pattern : patterns) { + for (PaletteBlockPattern pattern : patterns) { CreateRegistrate registrate = Create.registrate(); BlockBuilder builder = registrate.block(pattern.createName(name), pattern.getBlockFactory()) @@ -39,7 +38,7 @@ public class PalettesVariantEntry { if (pattern.isTranslucent()) builder.addLayer(() -> RenderType::getTranslucent); - if (pattern == PaletteBlockPatterns.COBBLESTONE) + if (pattern == PaletteBlockPattern.COBBLESTONE) builder.item().tag(AllTags.AllItemTags.COBBLESTONE.tag); if (pattern.hasFoliage()) builder.onRegister(CreateRegistrate.blockColors(() -> AllColorHandlers::getGrassyBlock)); @@ -65,11 +64,10 @@ public class PalettesVariantEntry { for (PaletteBlockPartial partialBlock : pattern.getPartials()) registeredPartials.add(partialBlock.create(name, pattern, block) .register()); - } + this.registeredBlocks = registeredBlocks.build(); this.registeredPartials = registeredPartials.build(); - } } diff --git a/src/main/java/com/simibubi/create/content/palettes/PatternNameType.java b/src/main/java/com/simibubi/create/content/palettes/PatternNameType.java deleted file mode 100644 index 67c9cf1d5..000000000 --- a/src/main/java/com/simibubi/create/content/palettes/PatternNameType.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.simibubi.create.content.palettes; - -enum PatternNameType { - Prefix, Suffix, Wrap -} \ No newline at end of file From 2bedc94bc6965fbfcd2ef4831005a49c363b9062 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sat, 29 May 2021 22:09:58 -0400 Subject: [PATCH 113/198] Fix schematic deployment crash caused by some Mekanism blocks --- .../worldWrappers/WrappedChunkProvider.java | 26 +++++- .../worldWrappers/chunk/EmptierChunk.java | 82 +++++++++++++++++++ 2 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java index 4bb1dfffa..43a4bbde7 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java @@ -1,20 +1,40 @@ package com.simibubi.create.foundation.utility.worldWrappers; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.function.Predicate; import java.util.stream.Stream; import javax.annotation.Nullable; +import com.simibubi.create.foundation.utility.worldWrappers.chunk.EmptierChunk; import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; +import net.minecraft.fluid.FluidState; +import net.minecraft.fluid.Fluids; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Util; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.registry.Registry; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.BiomeContainer; +import net.minecraft.world.biome.BiomeRegistry; import net.minecraft.world.chunk.AbstractChunkProvider; +import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkStatus; +import net.minecraft.world.chunk.EmptyChunk; import net.minecraft.world.chunk.IChunk; import net.minecraft.world.lighting.WorldLightManager; +import net.minecraft.world.server.ChunkHolder; public class WrappedChunkProvider extends AbstractChunkProvider { private PlacementSimulationWorld world; @@ -52,11 +72,11 @@ public class WrappedChunkProvider extends AbstractChunkProvider { return getChunk(x, z); } - public WrappedChunk getChunk(int x, int z) { + public IChunk getChunk(int x, int z) { long pos = ChunkPos.asLong(x, z); - + if (chunks == null) - return null; + return new EmptierChunk(); return chunks.computeIfAbsent(pos, $ -> new WrappedChunk(world, x, z)); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java new file mode 100644 index 000000000..dae7595f3 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java @@ -0,0 +1,82 @@ +package com.simibubi.create.foundation.utility.worldWrappers.chunk; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; +import net.minecraft.fluid.FluidState; +import net.minecraft.fluid.Fluids; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.lighting.WorldLightManager; +import net.minecraft.world.server.ChunkHolder; + +import javax.annotation.Nullable; + +import java.util.List; +import java.util.function.Predicate; + +public class EmptierChunk extends Chunk { + + public EmptierChunk() { + super(null, null, null); + } + + public BlockState getBlockState(BlockPos p_180495_1_) { + return Blocks.VOID_AIR.getDefaultState(); + } + + @Nullable + public BlockState setBlockState(BlockPos p_177436_1_, BlockState p_177436_2_, boolean p_177436_3_) { + return null; + } + + public FluidState getFluidState(BlockPos p_204610_1_) { + return Fluids.EMPTY.getDefaultState(); + } + + @Nullable + public WorldLightManager getWorldLightManager() { + return null; + } + + public int getLightValue(BlockPos p_217298_1_) { + return 0; + } + + public void addEntity(Entity p_76612_1_) { } + + public void removeEntity(Entity p_76622_1_) { } + + public void removeEntityAtIndex(Entity p_76608_1_, int p_76608_2_) { } + + @Nullable + public TileEntity getTileEntity(BlockPos p_177424_1_, Chunk.CreateEntityType p_177424_2_) { + return null; + } + + public void addTileEntity(TileEntity p_150813_1_) { } + + public void addTileEntity(BlockPos p_177426_1_, TileEntity p_177426_2_) { } + + public void removeTileEntity(BlockPos p_177425_1_) { } + + public void markDirty() { } + + public void getEntitiesWithinAABBForEntity(@Nullable Entity p_177414_1_, AxisAlignedBB p_177414_2_, List p_177414_3_, Predicate p_177414_4_) { } + + public void getEntitiesOfTypeWithinAABB(Class p_177430_1_, AxisAlignedBB p_177430_2_, List p_177430_3_, Predicate p_177430_4_) { } + + public boolean isEmpty() { + return true; + } + + public boolean isEmptyBetween(int p_76606_1_, int p_76606_2_) { + return true; + } + + public ChunkHolder.LocationType getLocationType() { + return ChunkHolder.LocationType.BORDER; + } +} From b890204f44f5bb969ba62d3b54d0a07c4fe77766 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sun, 30 May 2021 01:40:24 -0400 Subject: [PATCH 114/198] Fix schematic init crash caused by updating null ChunkSections --- .../worldWrappers/WrappedChunkProvider.java | 19 ------------------- .../utility/worldWrappers/WrappedWorld.java | 14 +++++++++++--- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java index 43a4bbde7..dbc75fcfd 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java @@ -1,10 +1,7 @@ package com.simibubi.create.foundation.utility.worldWrappers; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.function.Predicate; import java.util.stream.Stream; import javax.annotation.Nullable; @@ -12,29 +9,13 @@ import javax.annotation.Nullable; import com.simibubi.create.foundation.utility.worldWrappers.chunk.EmptierChunk; import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.fluid.FluidState; -import net.minecraft.fluid.Fluids; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Util; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.Registry; import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeContainer; -import net.minecraft.world.biome.BiomeRegistry; import net.minecraft.world.chunk.AbstractChunkProvider; -import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.EmptyChunk; import net.minecraft.world.chunk.IChunk; import net.minecraft.world.lighting.WorldLightManager; -import net.minecraft.world.server.ChunkHolder; public class WrappedChunkProvider extends AbstractChunkProvider { private PlacementSimulationWorld world; diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java index a5984048c..7d14d0061 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java @@ -21,11 +21,14 @@ import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.SectionPos; import net.minecraft.util.registry.DynamicRegistries; import net.minecraft.world.ITickList; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.AbstractChunkProvider; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.lighting.WorldLightManager; import net.minecraft.world.storage.ISpawnWorldInfo; import net.minecraft.world.storage.MapData; @@ -51,12 +54,12 @@ public class WrappedWorld extends World { public World getWorld() { return world; } - + @Override public WorldLightManager getLightingProvider() { return world.getLightingProvider(); } - + @Override public BlockState getBlockState(@Nullable BlockPos pos) { return world.getBlockState(pos); @@ -84,7 +87,12 @@ public class WrappedWorld extends World { @Override public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { - world.notifyBlockUpdate(pos, oldState, newState, flags); + Chunk chunk = world.getChunkProvider().getWorldChunk(pos.getX() >> 4, pos.getZ() >> 4); + if (chunk != null) { + ChunkSection chunksection = chunk.getSections()[SectionPos.toChunk(pos.getY())]; + if (chunksection != null) + world.notifyBlockUpdate(pos, oldState, newState, flags); + } } @Override From a633bc47befdbfcd0302cb0f8b867f1b00019503 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sun, 30 May 2021 14:36:06 -0400 Subject: [PATCH 115/198] Actually, we should prevent all updates caused by SchematicWorld --- .../simibubi/create/content/schematics/SchematicWorld.java | 4 ++++ .../foundation/utility/worldWrappers/WrappedWorld.java | 7 +------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java index f839edd24..58df85ed1 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java @@ -202,6 +202,9 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { return true; } + @Override + public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { } + @Override public ITickList getPendingBlockTicks() { return EmptyTickList.get(); @@ -233,4 +236,5 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld { } throw new IllegalStateException("Cannot use IServerWorld#getWorld in a client environment"); } + } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java index 7d14d0061..7f65c17e3 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java @@ -87,12 +87,7 @@ public class WrappedWorld extends World { @Override public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { - Chunk chunk = world.getChunkProvider().getWorldChunk(pos.getX() >> 4, pos.getZ() >> 4); - if (chunk != null) { - ChunkSection chunksection = chunk.getSections()[SectionPos.toChunk(pos.getY())]; - if (chunksection != null) - world.notifyBlockUpdate(pos, oldState, newState, flags); - } + world.notifyBlockUpdate(pos, oldState, newState, flags); } @Override From 2300ef2088051a33dfb8c68c432b07f6e41cb56a Mon Sep 17 00:00:00 2001 From: JozsefA Date: Sun, 30 May 2021 17:05:41 -0700 Subject: [PATCH 116/198] Organization, renaming, and fixing a dumb crash --- .../jozufozu/flywheel/backend/Backend.java | 16 +++-- .../{instancing => }/IFlywheelWorld.java | 4 +- .../flywheel/backend/ShaderContext.java | 4 +- .../flywheel/backend/ShaderLoader.java | 4 +- .../core/FirstNonnullMultiProgram.java | 6 -- .../flywheel/backend/core/IndexedModel.java | 56 --------------- .../backend/core/shader/ShaderCallback.java | 19 ----- ...lPrimitiveType.java => GlNumericType.java} | 23 ++++--- .../flywheel/backend/gl/GlPrimitive.java | 23 +++++++ .../backend/gl/attrib/CommonAttributes.java | 24 +++---- .../backend/gl/attrib/MatrixAttributes.java | 8 +-- .../backend/gl/attrib/VertexAttribSpec.java | 10 +-- .../versioned/instancing/DrawInstanced.java | 43 ++++++++---- .../backend/instancing/IInstance.java | 5 +- .../backend/instancing/IInstanceFactory.java | 5 ++ .../backend/instancing/IInstanceRendered.java | 9 ++- .../backend/instancing/ITickableInstance.java | 2 +- .../backend/instancing/InstanceData.java | 4 +- .../backend/instancing/InstanceFactory.java | 5 -- .../InstancedTileRenderRegistry.java | 6 +- .../instancing/InstancedTileRenderer.java | 19 +++-- .../{InstancedModel.java => Instancer.java} | 12 ++-- .../backend/instancing/MaterialSpec.java | 6 +- .../backend/instancing/RenderMaterial.java | 41 +++++------ .../instancing/TileEntityInstance.java | 6 +- .../backend/light/CoordinateConsumer.java | 6 -- ...essingStage.java => IProcessingStage.java} | 2 +- .../flywheel/backend/loading/LayoutTag.java | 6 +- .../backend/loading/ProgramTemplate.java | 2 +- .../backend/loading/ShaderTransformer.java | 8 +-- .../core/BufferedArrayModel.java | 11 +-- .../{backend => }/core/BufferedModel.java | 35 +++++----- .../{backend => }/core/CrumblingProgram.java | 6 +- .../{backend => }/core/CrumblingRenderer.java | 4 +- .../{backend => }/core/FullscreenQuad.java | 6 +- .../jozufozu/flywheel/core/IndexedModel.java | 69 +++++++++++++++++++ .../{backend => }/core/PartialModel.java | 2 +- .../core/context => core}/WorldContext.java | 13 ++-- .../{backend => }/core/WorldTileRenderer.java | 9 ++- .../instancing}/ConditionalInstance.java | 8 +-- .../instancing/GroupInstance.java} | 12 ++-- .../instancing}/SelectInstance.java | 8 +-- .../core/materials/BasicData.java | 6 +- .../core/materials/IFlatLight.java | 2 +- .../core/materials/ModelData.java | 6 +- .../core/materials/OrientedData.java | 6 +- .../core/shader/ExtensibleGlProgram.java | 6 +- .../{backend => }/core/shader/FogMode.java | 4 +- .../{backend => }/core/shader/GlFog.java | 2 +- .../core/shader/IMultiProgram.java | 2 +- .../core/shader/IProgramCallback.java | 19 +++++ .../shader/StateSensitiveMultiProgram.java | 8 +-- .../{backend => }/core/shader/WorldFog.java | 8 +-- .../core/shader/WorldProgram.java | 4 +- .../shader/extension/IExtensionInstance.java | 2 +- .../shader/extension/IProgramExtension.java | 4 +- .../extension/UnitExtensionInstance.java | 2 +- .../shader/gamestate/FogStateProvider.java | 4 +- .../shader/gamestate/IGameStateProvider.java | 4 +- .../gamestate/NormalDebugStateProvider.java | 4 +- .../gamestate/RainbowDebugStateProvider.java | 4 +- .../shader/spec/BooleanContextCondition.java | 4 +- .../shader/spec/IBooleanStateProvider.java | 4 +- .../core/shader/spec/IContextCondition.java | 4 +- .../core/shader/spec/ProgramSpec.java | 2 +- .../core/shader/spec/ProgramState.java | 4 +- .../core/shader/spec/SpecMetaRegistry.java | 14 ++-- .../shader/spec/SpecificValueCondition.java | 4 +- .../{backend => }/light/GridAlignedBB.java | 4 +- .../flywheel/light/ICoordinateConsumer.java | 6 ++ .../ILightUpdateListener.java} | 4 +- .../{backend => }/light/LightUpdater.java | 42 +++++------ .../{backend => }/light/LightVolume.java | 2 +- .../jozufozu/flywheel/util/AttribUtil.java | 8 +-- .../com/simibubi/create/AllBlockPartials.java | 4 +- .../com/simibubi/create/CreateClient.java | 2 +- .../animations/AnimatedBlazeBurner.java | 2 +- .../category/animations/AnimatedKinetics.java | 2 +- .../contraptions/base/HalfShaftInstance.java | 4 +- .../contraptions/base/KineticData.java | 6 +- .../contraptions/base/RotatingData.java | 4 +- .../base/ShaftlessCogInstance.java | 4 +- .../base/SingleRotatingInstance.java | 4 +- .../components/actors/ActorData.java | 4 +- .../components/actors/DrillInstance.java | 4 +- .../actors/HarvesterActorInstance.java | 2 +- .../PortableStorageInterfaceRenderer.java | 2 +- .../components/clock/CuckooClockRenderer.java | 2 +- .../clock/CuckooClockTileEntity.java | 10 +-- .../crafter/MechanicalCrafterInstance.java | 4 +- .../crafter/MechanicalCrafterRenderer.java | 2 +- .../crafter/MechanicalCrafterTileEntity.java | 8 +-- .../components/crank/HandCrankBlock.java | 2 +- .../components/crank/HandCrankInstance.java | 8 +-- .../components/crank/HandCrankRenderer.java | 2 +- .../components/crank/HandCrankTileEntity.java | 2 +- .../components/crank/ValveHandleBlock.java | 2 +- .../deployer/DeployerActorInstance.java | 4 +- .../components/deployer/DeployerInstance.java | 4 +- .../components/deployer/DeployerRenderer.java | 2 +- .../deployer/DeployerTileEntity.java | 4 +- .../components/flywheel/FlyWheelInstance.java | 6 +- .../flywheel/engine/EngineBlock.java | 2 +- .../flywheel/engine/EngineInstance.java | 4 +- .../flywheel/engine/EngineRenderer.java | 2 +- .../flywheel/engine/FurnaceEngineBlock.java | 2 +- .../millstone/MillStoneCogInstance.java | 4 +- .../components/mixer/MixerInstance.java | 2 +- .../components/press/PressInstance.java | 2 +- .../components/saw/SawInstance.java | 4 +- .../components/saw/SawRenderer.java | 2 +- .../components/saw/SawTileEntity.java | 4 +- .../structureMovement/Contraption.java | 4 +- .../structureMovement/ContraptionLighter.java | 10 +-- .../NonStationaryLighter.java | 2 +- .../bearing/AnchoredLighter.java | 2 +- .../bearing/BearingInstance.java | 4 +- .../bearing/BearingRenderer.java | 2 +- .../bearing/ClockworkBearingTileEntity.java | 6 +- .../bearing/MechanicalBearingTileEntity.java | 8 +-- .../bearing/StabilizedBearingInstance.java | 2 +- .../StabilizedBearingMovementBehaviour.java | 2 +- .../chassis/StickerInstance.java | 2 +- .../gantry/GantryCarriageInstance.java | 2 +- .../gantry/GantryCarriageTileEntity.java | 4 +- .../piston/PistonLighter.java | 2 +- .../pulley/AbstractPulleyInstance.java | 46 ++++++------- .../pulley/AbstractPulleyRenderer.java | 2 +- .../pulley/HosePulleyInstance.java | 14 ++-- .../pulley/PulleyLighter.java | 2 +- .../pulley/PulleyRenderer.java | 2 +- .../pulley/PulleyTileEntity.java | 8 +-- .../pulley/RopePulleyInstance.java | 14 ++-- .../render/ContraptionProgram.java | 4 +- .../render/ContraptionRenderDispatcher.java | 2 +- .../render/EmptyLighter.java | 2 +- .../render/LightVolumeDebugger.java | 2 +- .../render/RenderedContraption.java | 13 ++-- .../contraptions/fluids/PumpCogInstance.java | 4 +- .../contraptions/fluids/PumpTileEntity.java | 4 +- .../fluids/actors/HosePulleyRenderer.java | 2 +- .../fluids/actors/HosePulleyTileEntity.java | 2 +- .../fluids/actors/SpoutRenderer.java | 2 +- .../fluids/pipes/FluidValveInstance.java | 2 +- .../fluids/pipes/FluidValveTileEntity.java | 4 +- .../processing/BasinOperatingTileEntity.java | 12 ++-- .../burner/BlazeBurnerRenderer.java | 2 +- .../advanced/SpeedControllerTileEntity.java | 4 +- .../contraptions/relays/belt/BeltData.java | 4 +- .../relays/belt/BeltInstance.java | 10 +-- .../relays/belt/BeltRenderer.java | 2 +- .../relays/belt/BeltTileEntity.java | 10 +-- .../relays/encased/SplitShaftInstance.java | 4 +- .../relays/gauge/GaugeInstance.java | 16 ++--- .../relays/gauge/GaugeRenderer.java | 2 +- .../relays/gauge/GaugeTileEntity.java | 2 +- .../relays/gearbox/GearboxInstance.java | 4 +- .../armor/CopperBacktankInstance.java | 4 +- .../armor/CopperBacktankTileEntity.java | 4 +- .../symmetry/mirror/CrossPlaneMirror.java | 2 +- .../symmetry/mirror/EmptyMirror.java | 2 +- .../symmetry/mirror/PlaneMirror.java | 2 +- .../symmetry/mirror/SymmetryMirror.java | 2 +- .../symmetry/mirror/TriplePlaneMirror.java | 2 +- .../tools/ExtendoGripRenderHandler.java | 2 +- .../content/logistics/block/FlapData.java | 6 +- .../belts/tunnel/BeltTunnelInstance.java | 4 +- .../belts/tunnel/BeltTunnelTileEntity.java | 2 +- .../block/depot/EjectorInstance.java | 2 +- .../block/depot/EjectorTileEntity.java | 2 +- .../diodes/AdjustableRepeaterInstance.java | 2 +- .../block/funnel/FunnelInstance.java | 6 +- .../block/funnel/FunnelRenderer.java | 2 +- .../block/funnel/FunnelTileEntity.java | 2 +- .../block/mechanicalArm/ArmInstance.java | 8 +-- .../mechanicalArm/ArmInteractionPoint.java | 2 +- .../block/mechanicalArm/ArmTileEntity.java | 2 +- .../block/redstone/AnalogLeverInstance.java | 2 +- .../block/SchematicannonInstance.java | 2 +- .../block/SchematicannonTileEntity.java | 2 +- .../simibubi/create/events/ClientEvents.java | 4 +- .../data/CreateTileEntityBuilder.java | 2 +- .../create/foundation/gui/GuiGameElement.java | 2 +- .../flywheel/CancelTileEntityRenderMixin.java | 2 +- .../mixin/flywheel/FogColorTrackerMixin.java | 2 +- .../mixin/flywheel/TileWorldHookMixin.java | 4 +- .../flywheel/light/LightUpdateMixin.java | 2 +- .../light/NetworkLightUpdateMixin.java | 2 +- .../foundation/render/AllMaterialSpecs.java | 4 +- .../create/foundation/render/Compartment.java | 2 +- .../foundation/render/PartialBufferer.java | 2 +- .../render/SuperByteBufferCache.java | 2 +- .../render/effects/EffectsContext.java | 4 +- .../render/effects/EffectsHandler.java | 2 +- .../render/effects/SphereFilterProgram.java | 2 +- .../PlacementSimulationWorld.java | 2 +- 196 files changed, 659 insertions(+), 602 deletions(-) rename src/main/java/com/jozufozu/flywheel/backend/{instancing => }/IFlywheelWorld.java (61%) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/FirstNonnullMultiProgram.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/core/shader/ShaderCallback.java rename src/main/java/com/jozufozu/flywheel/backend/gl/{GlPrimitiveType.java => GlNumericType.java} (63%) create mode 100644 src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitive.java create mode 100644 src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceFactory.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceFactory.java rename src/main/java/com/jozufozu/flywheel/backend/instancing/{InstancedModel.java => Instancer.java} (92%) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/light/CoordinateConsumer.java rename src/main/java/com/jozufozu/flywheel/backend/loading/{ProcessingStage.java => IProcessingStage.java} (73%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/BufferedArrayModel.java (76%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/BufferedModel.java (64%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/CrumblingProgram.java (77%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/CrumblingRenderer.java (75%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/FullscreenQuad.java (86%) create mode 100644 src/main/java/com/jozufozu/flywheel/core/IndexedModel.java rename src/main/java/com/jozufozu/flywheel/{backend => }/core/PartialModel.java (97%) rename src/main/java/com/jozufozu/flywheel/{backend/core/context => core}/WorldContext.java (90%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/WorldTileRenderer.java (87%) rename src/main/java/com/jozufozu/flywheel/{backend/instancing/util => core/instancing}/ConditionalInstance.java (80%) rename src/main/java/com/jozufozu/flywheel/{backend/instancing/util/InstanceGroup.java => core/instancing/GroupInstance.java} (80%) rename src/main/java/com/jozufozu/flywheel/{backend/instancing/util => core/instancing}/SelectInstance.java (82%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/materials/BasicData.java (90%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/materials/IFlatLight.java (94%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/materials/ModelData.java (77%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/materials/OrientedData.java (92%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/ExtensibleGlProgram.java (91%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/FogMode.java (91%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/GlFog.java (95%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/IMultiProgram.java (91%) create mode 100644 src/main/java/com/jozufozu/flywheel/core/shader/IProgramCallback.java rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/StateSensitiveMultiProgram.java (83%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/WorldFog.java (76%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/WorldProgram.java (91%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/extension/IExtensionInstance.java (83%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/extension/IProgramExtension.java (85%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/extension/UnitExtensionInstance.java (88%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/gamestate/FogStateProvider.java (79%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/gamestate/IGameStateProvider.java (69%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/gamestate/NormalDebugStateProvider.java (78%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/gamestate/RainbowDebugStateProvider.java (81%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/spec/BooleanContextCondition.java (86%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/spec/IBooleanStateProvider.java (53%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/spec/IContextCondition.java (55%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/spec/ProgramSpec.java (96%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/spec/ProgramState.java (93%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/spec/SpecMetaRegistry.java (78%) rename src/main/java/com/jozufozu/flywheel/{backend => }/core/shader/spec/SpecificValueCondition.java (88%) rename src/main/java/com/jozufozu/flywheel/{backend => }/light/GridAlignedBB.java (98%) create mode 100644 src/main/java/com/jozufozu/flywheel/light/ICoordinateConsumer.java rename src/main/java/com/jozufozu/flywheel/{backend/light/LightUpdateListener.java => light/ILightUpdateListener.java} (92%) rename src/main/java/com/jozufozu/flywheel/{backend => }/light/LightUpdater.java (75%) rename src/main/java/com/jozufozu/flywheel/{backend => }/light/LightVolume.java (99%) diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index 73fb81cad..5e577a590 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -20,16 +20,15 @@ import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GLCapabilities; -import com.jozufozu.flywheel.backend.core.CrumblingRenderer; -import com.jozufozu.flywheel.backend.core.WorldTileRenderer; -import com.jozufozu.flywheel.backend.core.context.WorldContext; -import com.jozufozu.flywheel.backend.core.shader.WorldProgram; -import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.versioned.GlCompat; -import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.MaterialSpec; +import com.jozufozu.flywheel.core.CrumblingRenderer; +import com.jozufozu.flywheel.core.WorldContext; +import com.jozufozu.flywheel.core.WorldTileRenderer; +import com.jozufozu.flywheel.core.shader.WorldProgram; +import com.jozufozu.flywheel.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.util.WorldAttached; import com.simibubi.create.foundation.config.AllConfigs; @@ -141,8 +140,11 @@ public class Backend { return programSpecRegistry.get(name); } + /** + * Used to avoid calling Flywheel functions on (fake) worlds that don't specifically support it. + */ public static boolean isFlywheelWorld(World world) { - return world == Minecraft.getInstance().world || (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()); + return (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()) || world == Minecraft.getInstance().world; } public static boolean available() { diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/IFlywheelWorld.java b/src/main/java/com/jozufozu/flywheel/backend/IFlywheelWorld.java similarity index 61% rename from src/main/java/com/jozufozu/flywheel/backend/instancing/IFlywheelWorld.java rename to src/main/java/com/jozufozu/flywheel/backend/IFlywheelWorld.java index 5a138fefc..52f1712ed 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/IFlywheelWorld.java +++ b/src/main/java/com/jozufozu/flywheel/backend/IFlywheelWorld.java @@ -1,10 +1,10 @@ -package com.jozufozu.flywheel.backend.instancing; +package com.jozufozu.flywheel.backend; /** * A marker interface custom worlds can override to indicate * that tiles inside the world should render with Flywheel. * - * Minecraft.getInstance().world will always support Flywheel. + * Minecraft.getInstance().world is special cased and will support Flywheel by default. */ public interface IFlywheelWorld { default boolean supportsFlywheel() { diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java index 0a86e017a..e93aeae41 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java @@ -4,13 +4,13 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import com.jozufozu.flywheel.backend.core.shader.IMultiProgram; -import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.backend.loading.Shader; import com.jozufozu.flywheel.backend.loading.ShaderTransformer; +import com.jozufozu.flywheel.core.shader.IMultiProgram; +import com.jozufozu.flywheel.core.shader.spec.ProgramSpec; import net.minecraft.util.ResourceLocation; diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java index 848b5943c..068c8ecb1 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/ShaderLoader.java @@ -30,14 +30,14 @@ import com.google.common.collect.Lists; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; -import com.jozufozu.flywheel.backend.core.shader.spec.ProgramSpec; -import com.jozufozu.flywheel.backend.core.shader.spec.SpecMetaRegistry; import com.jozufozu.flywheel.backend.gl.GlObject; import com.jozufozu.flywheel.backend.gl.shader.GlShader; import com.jozufozu.flywheel.backend.gl.shader.ShaderType; import com.jozufozu.flywheel.backend.loading.Program; import com.jozufozu.flywheel.backend.loading.Shader; import com.jozufozu.flywheel.backend.loading.ShaderLoadingException; +import com.jozufozu.flywheel.core.shader.spec.ProgramSpec; +import com.jozufozu.flywheel.core.shader.spec.SpecMetaRegistry; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.DataResult; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/FirstNonnullMultiProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/FirstNonnullMultiProgram.java deleted file mode 100644 index 1e7b441dd..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/FirstNonnullMultiProgram.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.jozufozu.flywheel.backend.core; - -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; - -public class FirstNonnullMultiProgram

{ -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java b/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java deleted file mode 100644 index cb76197d7..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/IndexedModel.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.jozufozu.flywheel.backend.core; - -import java.nio.ByteBuffer; - -import org.lwjgl.opengl.GL20; - -import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; -import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; -import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; -import com.jozufozu.flywheel.util.AttribUtil; - -public class IndexedModel extends BufferedModel { - - protected GlPrimitiveType eboIndexType; - protected GlBuffer ebo; - - public IndexedModel(VertexFormat modelFormat, ByteBuffer buf, int vertices, ByteBuffer indices, GlPrimitiveType indexType) { - super(modelFormat, buf, vertices); - - ebo = new GlBuffer(GlBufferType.ELEMENT_ARRAY_BUFFER); - this.eboIndexType = indexType; - - int indicesSize = vertexCount * indexType.getSize(); - - ebo.bind(); - - ebo.alloc(indicesSize); - ebo.getBuffer(0, indicesSize) - .put(indices) - .flush(); - - ebo.unbind(); - } - - public void render() { - vbo.bind(); - ebo.bind(); - - AttribUtil.enableArrays(getAttributeCount()); - format.vertexAttribPointers(0); - - GL20.glDrawElements(GL20.GL_QUADS, vertexCount, eboIndexType.getGlConstant(), 0); - - AttribUtil.disableArrays(getAttributeCount()); - - ebo.unbind(); - vbo.unbind(); - } - - @Override - public void delete() { - super.delete(); - ebo.delete(); - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ShaderCallback.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ShaderCallback.java deleted file mode 100644 index 2bf2f5440..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ShaderCallback.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.jozufozu.flywheel.backend.core.shader; - -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; - -/** - * A Callback for when a shader is called. Used to define shader uniforms. - */ -@FunctionalInterface -public interface ShaderCallback

{ - - void call(P program); - - default ShaderCallback

andThen(ShaderCallback

other) { - return program -> { - call(program); - other.call(program); - }; - } -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlNumericType.java similarity index 63% rename from src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/GlNumericType.java index 1737c6bd4..7a39b34b6 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitiveType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlNumericType.java @@ -13,27 +13,28 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public enum GlPrimitiveType { +public enum GlNumericType { FLOAT(4, "float", GL11.GL_FLOAT), UBYTE(1, "ubyte", GL11.GL_UNSIGNED_BYTE), BYTE(1, "byte", GL11.GL_BYTE), USHORT(2, "ushort", GL11.GL_UNSIGNED_SHORT), SHORT(2, "short", GL11.GL_SHORT), UINT(4, "uint", GL11.GL_UNSIGNED_INT), - INT(4, "int", GL11.GL_INT); + INT(4, "int", GL11.GL_INT), + ; - private static final GlPrimitiveType[] VALUES = values(); - private static final Map NAME_LOOKUP = Arrays.stream(VALUES) - .collect(Collectors.toMap(GlPrimitiveType::getDisplayName, type -> type)); + private static final GlNumericType[] VALUES = values(); + private static final Map NAME_LOOKUP = Arrays.stream(VALUES) + .collect(Collectors.toMap(GlNumericType::getDisplayName, type -> type)); private final int size; private final String displayName; - private final int glConstant; + private final int glEnum; - GlPrimitiveType(int bytes, String name, int glEnum) { + GlNumericType(int bytes, String name, int glEnum) { this.size = bytes; this.displayName = name; - this.glConstant = glEnum; + this.glEnum = glEnum; } public int getSize() { @@ -44,12 +45,12 @@ public enum GlPrimitiveType { return this.displayName; } - public int getGlConstant() { - return this.glConstant; + public int getGlEnum() { + return this.glEnum; } @Nullable - public static GlPrimitiveType byName(String name) { + public static GlNumericType byName(String name) { return name == null ? null : NAME_LOOKUP.get(name.toLowerCase(Locale.ROOT)); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitive.java b/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitive.java new file mode 100644 index 000000000..71a8d5353 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/GlPrimitive.java @@ -0,0 +1,23 @@ +package com.jozufozu.flywheel.backend.gl; + +import org.lwjgl.opengl.GL11; + +public enum GlPrimitive { + POINTS(GL11.GL_POINTS), + LINES(GL11.GL_LINES), + LINE_LOOP(GL11.GL_LINE_LOOP), + LINE_STRIP(GL11.GL_LINE_STRIP), + TRIANGLES(GL11.GL_TRIANGLES), + TRIANGLE_STRIP(GL11.GL_TRIANGLE_STRIP), + TRIANGLE_FAN(GL11.GL_TRIANGLE_FAN), + QUADS(GL11.GL_QUADS), + QUAD_STRIP(GL11.GL_QUAD_STRIP), + POLYGON(GL11.GL_POLYGON), + ; + + public final int glEnum; + + GlPrimitive(int glEnum) { + this.glEnum = glEnum; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/CommonAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/CommonAttributes.java index 99f754efe..a1726fae0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/CommonAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/CommonAttributes.java @@ -1,21 +1,21 @@ package com.jozufozu.flywheel.backend.gl.attrib; -import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.GlNumericType; public class CommonAttributes { - public static final VertexAttribSpec VEC4 = new VertexAttribSpec(GlPrimitiveType.FLOAT, 4); - public static final VertexAttribSpec VEC3 = new VertexAttribSpec(GlPrimitiveType.FLOAT, 3); - public static final VertexAttribSpec VEC2 = new VertexAttribSpec(GlPrimitiveType.FLOAT, 2); - public static final VertexAttribSpec FLOAT = new VertexAttribSpec(GlPrimitiveType.FLOAT, 1); + public static final VertexAttribSpec VEC4 = new VertexAttribSpec(GlNumericType.FLOAT, 4); + public static final VertexAttribSpec VEC3 = new VertexAttribSpec(GlNumericType.FLOAT, 3); + public static final VertexAttribSpec VEC2 = new VertexAttribSpec(GlNumericType.FLOAT, 2); + public static final VertexAttribSpec FLOAT = new VertexAttribSpec(GlNumericType.FLOAT, 1); - public static final VertexAttribSpec QUATERNION = new VertexAttribSpec(GlPrimitiveType.FLOAT, 4); - public static final VertexAttribSpec NORMAL = new VertexAttribSpec(GlPrimitiveType.BYTE, 3, true); - public static final VertexAttribSpec UV = new VertexAttribSpec(GlPrimitiveType.FLOAT, 2); + public static final VertexAttribSpec QUATERNION = new VertexAttribSpec(GlNumericType.FLOAT, 4); + public static final VertexAttribSpec NORMAL = new VertexAttribSpec(GlNumericType.BYTE, 3, true); + public static final VertexAttribSpec UV = new VertexAttribSpec(GlNumericType.FLOAT, 2); - public static final VertexAttribSpec RGBA = new VertexAttribSpec(GlPrimitiveType.UBYTE, 4, true); - public static final VertexAttribSpec RGB = new VertexAttribSpec(GlPrimitiveType.UBYTE, 3, true); - public static final VertexAttribSpec LIGHT = new VertexAttribSpec(GlPrimitiveType.UBYTE, 2, true); + public static final VertexAttribSpec RGBA = new VertexAttribSpec(GlNumericType.UBYTE, 4, true); + public static final VertexAttribSpec RGB = new VertexAttribSpec(GlNumericType.UBYTE, 3, true); + public static final VertexAttribSpec LIGHT = new VertexAttribSpec(GlNumericType.UBYTE, 2, true); - public static final VertexAttribSpec NORMALIZED_BYTE = new VertexAttribSpec(GlPrimitiveType.BYTE, 1, true); + public static final VertexAttribSpec NORMALIZED_BYTE = new VertexAttribSpec(GlNumericType.BYTE, 1, true); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java index 86cf089aa..49b6731fe 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java @@ -2,7 +2,7 @@ package com.jozufozu.flywheel.backend.gl.attrib; import org.lwjgl.opengl.GL20; -import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.GlNumericType; public enum MatrixAttributes implements IAttribSpec { MAT3(3, 3), @@ -20,14 +20,14 @@ public enum MatrixAttributes implements IAttribSpec { @Override public void vertexAttribPointer(int stride, int index, int pointer) { for (int i = 0; i < rows; i++) { - long attribPointer = pointer + (long) i * cols * GlPrimitiveType.FLOAT.getSize(); - GL20.glVertexAttribPointer(index + i, cols, GlPrimitiveType.FLOAT.getGlConstant(), false, stride, attribPointer); + long attribPointer = pointer + (long) i * cols * GlNumericType.FLOAT.getSize(); + GL20.glVertexAttribPointer(index + i, cols, GlNumericType.FLOAT.getGlEnum(), false, stride, attribPointer); } } @Override public int getSize() { - return GlPrimitiveType.FLOAT.getSize() * rows * cols; + return GlNumericType.FLOAT.getSize() * rows * cols; } @Override diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java index 7717114ab..663ad8342 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java @@ -2,21 +2,21 @@ package com.jozufozu.flywheel.backend.gl.attrib; import org.lwjgl.opengl.GL20; -import com.jozufozu.flywheel.backend.gl.GlPrimitiveType; +import com.jozufozu.flywheel.backend.gl.GlNumericType; public class VertexAttribSpec implements IAttribSpec { - private final GlPrimitiveType type; + private final GlNumericType type; private final int count; private final int size; private final int attributeCount; private final boolean normalized; - public VertexAttribSpec(GlPrimitiveType type, int count) { + public VertexAttribSpec(GlNumericType type, int count) { this(type, count, false); } - public VertexAttribSpec(GlPrimitiveType type, int count, boolean normalized) { + public VertexAttribSpec(GlNumericType type, int count, boolean normalized) { this.type = type; this.count = count; this.size = type.getSize() * count; @@ -26,7 +26,7 @@ public class VertexAttribSpec implements IAttribSpec { @Override public void vertexAttribPointer(int stride, int index, int pointer) { - GL20.glVertexAttribPointer(index, count, type.getGlConstant(), normalized, stride, pointer); + GL20.glVertexAttribPointer(index, count, type.getGlEnum(), normalized, stride, pointer); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/DrawInstanced.java b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/DrawInstanced.java index e30ba9bfc..c2d73e0c4 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/DrawInstanced.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/versioned/instancing/DrawInstanced.java @@ -5,6 +5,8 @@ import org.lwjgl.opengl.EXTDrawInstanced; import org.lwjgl.opengl.GL31; import org.lwjgl.opengl.GLCapabilities; +import com.jozufozu.flywheel.backend.gl.GlNumericType; +import com.jozufozu.flywheel.backend.gl.GlPrimitive; import com.jozufozu.flywheel.backend.gl.versioned.GlVersioned; public enum DrawInstanced implements GlVersioned { @@ -15,8 +17,13 @@ public enum DrawInstanced implements GlVersioned { } @Override - public void drawArraysInstanced(int mode, int first, int count, int primcount) { - GL31.glDrawArraysInstanced(mode, first, count, primcount); + public void drawArraysInstanced(GlPrimitive mode, int first, int count, int primcount) { + GL31.glDrawArraysInstanced(mode.glEnum, first, count, primcount); + } + + @Override + public void drawElementsInstanced(GlPrimitive mode, int elementCount, GlNumericType type, long indices, int primcount) { + GL31.glDrawElementsInstanced(mode.glEnum, elementCount, type.getGlEnum(), indices, primcount); } }, ARB_DRAW_INSTANCED { @@ -26,8 +33,13 @@ public enum DrawInstanced implements GlVersioned { } @Override - public void drawArraysInstanced(int mode, int first, int count, int primcount) { - ARBDrawInstanced.glDrawArraysInstancedARB(mode, first, count, primcount); + public void drawArraysInstanced(GlPrimitive mode, int first, int count, int primcount) { + ARBDrawInstanced.glDrawArraysInstancedARB(mode.glEnum, first, count, primcount); + } + + @Override + public void drawElementsInstanced(GlPrimitive mode, int elementCount, GlNumericType type, long indices, int primcount) { + ARBDrawInstanced.glDrawElementsInstancedARB(mode.glEnum, elementCount, type.getGlEnum(), indices, primcount); } }, EXT_DRAW_INSTANCED { @@ -37,8 +49,13 @@ public enum DrawInstanced implements GlVersioned { } @Override - public void drawArraysInstanced(int mode, int first, int count, int primcount) { - EXTDrawInstanced.glDrawArraysInstancedEXT(mode, first, count, primcount); + public void drawArraysInstanced(GlPrimitive mode, int first, int count, int primcount) { + EXTDrawInstanced.glDrawArraysInstancedEXT(mode.glEnum, first, count, primcount); + } + + @Override + public void drawElementsInstanced(GlPrimitive mode, int elementCount, GlNumericType type, long indices, int primcount) { + EXTDrawInstanced.glDrawElementsInstancedEXT(mode.glEnum, elementCount, type.getGlEnum(), indices, primcount); } }, UNSUPPORTED { @@ -46,12 +63,14 @@ public enum DrawInstanced implements GlVersioned { public boolean supported(GLCapabilities caps) { return true; } - - @Override - public void drawArraysInstanced(int mode, int first, int count, int primcount) { - throw new UnsupportedOperationException(); - } }; - public abstract void drawArraysInstanced(int mode, int first, int count, int primcount); + + public void drawArraysInstanced(GlPrimitive mode, int first, int count, int primcount) { + throw new UnsupportedOperationException(); + } + + public void drawElementsInstanced(GlPrimitive mode, int elementCount, GlNumericType type, long indices, int primcount) { + throw new UnsupportedOperationException(); + } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java index 32bab42ab..8030ef77d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java @@ -3,9 +3,8 @@ package com.jozufozu.flywheel.backend.instancing; import net.minecraft.util.math.BlockPos; /** - * A general interface providing information about any type of thing that could use - * Flywheel's instanced rendering. Right now, that's only {@link InstancedTileRenderer}, - * but there could be an entity equivalent in the future. + * A general interface providing information about any type of thing that could use Flywheel's instanced rendering. + * Right now, that's only {@link InstancedTileRenderer}, but there could be an entity equivalent in the future. */ public interface IInstance { diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceFactory.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceFactory.java new file mode 100644 index 000000000..f2364392c --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceFactory.java @@ -0,0 +1,5 @@ +package com.jozufozu.flywheel.backend.instancing; + +public interface IInstanceFactory { + D create(Instancer owner); +} diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java index b9494058c..bf5382e34 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java @@ -1,7 +1,14 @@ package com.jozufozu.flywheel.backend.instancing; +/** + * Something (a TileEntity or Entity) that can be rendered using the instancing API. + */ public interface IInstanceRendered { - default boolean shouldRenderAsTE() { + + /** + * @return true if there are parts of the renderer that cannot be implemented with Flywheel. + */ + default boolean shouldRenderNormally() { return false; } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java index e660195c1..846ad7d8e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java @@ -8,7 +8,7 @@ package com.jozufozu.flywheel.backend.instancing; *