From 8d54e9268a9c8447f9132ae183843baf90c76b64 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 8 Jan 2024 16:36:41 -0800 Subject: [PATCH] Top 50 errors of all time - Down to 50 compile errors. - Port over to new instance type builders. - Move shaders and delete program specs. - Switch #use to #include. - Move content.kinetics.base.flwdata.* up a level. - Move BeltInstance to the belt package. - Make all instance fields public. --- gradle.properties | 2 +- .../actors/flwdata/ActorInstance.java | 36 ++-- .../actors/flwdata/ActorType.java | 48 ----- .../actors/flwdata/UnsafeActorWriter.java | 30 ---- .../bearing/StabilizedBearingInstance.java | 2 +- .../base/KineticBlockEntityInstance.java | 1 - .../base/{flwdata => }/KineticInstance.java | 13 +- .../base/{flwdata => }/RotatingInstance.java | 10 +- .../kinetics/base/SingleRotatingInstance.java | 1 - .../kinetics/base/flwdata/BeltType.java | 53 ------ .../kinetics/base/flwdata/BeltWriter.java | 23 --- .../kinetics/base/flwdata/KineticWriter.java | 17 -- .../kinetics/base/flwdata/RotatingType.java | 49 ------ .../kinetics/base/flwdata/RotatingWriter.java | 15 -- .../kinetics/base/flwdata/package-info.java | 6 - .../kinetics/belt/BeltBlockEntity.java | 7 +- .../{base/flwdata => belt}/BeltInstance.java | 27 +-- .../content/kinetics/belt/BeltVisual.java | 3 +- .../deployer/DeployerActorInstance.java | 2 +- .../content/kinetics/fan/FanInstance.java | 2 +- .../kinetics/flywheel/FlywheelInstance.java | 2 +- .../kinetics/gearbox/GearboxInstance.java | 3 +- .../content/kinetics/mixer/MixerInstance.java | 2 +- .../content/kinetics/saw/SawInstance.java | 1 - .../BracketedKineticBlockEntityInstance.java | 2 +- .../encased/EncasedCogInstance.java | 3 +- .../transmission/SplitShaftInstance.java | 4 +- .../content/logistics/flwdata/FlapData.java | 32 ++-- .../content/logistics/flwdata/FlapType.java | 61 ------- .../content/logistics/flwdata/FlapWriter.java | 28 --- .../foundation/render/AllInstanceLayouts.java | 33 ---- .../foundation/render/AllInstanceShaders.java | 14 -- .../foundation/render/AllInstanceTypes.java | 166 +++++++++++++++--- .../{shaders => }/context/contraption.glsl | 0 .../flywheel/{shaders => instance}/belt.vert | 4 +- .../contraption_actor.vert | 4 +- .../flywheel/{shaders => instance}/flap.vert | 4 +- .../{shaders => instance}/rotating.vert | 2 +- .../assets/create/flywheel/programs/belt.json | 4 - .../flywheel/programs/contraption_actor.json | 4 - .../assets/create/flywheel/programs/flap.json | 4 - .../create/flywheel/programs/rotating.json | 4 - 42 files changed, 227 insertions(+), 501 deletions(-) delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorType.java delete mode 100644 src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/UnsafeActorWriter.java rename src/main/java/com/simibubi/create/content/kinetics/base/{flwdata => }/KineticInstance.java (88%) rename src/main/java/com/simibubi/create/content/kinetics/base/{flwdata => }/RotatingInstance.java (78%) delete mode 100644 src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltType.java delete mode 100644 src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltWriter.java delete mode 100644 src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticWriter.java delete mode 100644 src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingType.java delete mode 100644 src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingWriter.java delete mode 100644 src/main/java/com/simibubi/create/content/kinetics/base/flwdata/package-info.java rename src/main/java/com/simibubi/create/content/kinetics/{base/flwdata => belt}/BeltInstance.java (70%) delete mode 100644 src/main/java/com/simibubi/create/content/logistics/flwdata/FlapType.java delete mode 100644 src/main/java/com/simibubi/create/content/logistics/flwdata/FlapWriter.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/AllInstanceLayouts.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/AllInstanceShaders.java rename src/main/resources/assets/create/flywheel/{shaders => }/context/contraption.glsl (100%) rename src/main/resources/assets/create/flywheel/{shaders => instance}/belt.vert (91%) rename src/main/resources/assets/create/flywheel/{shaders => instance}/contraption_actor.vert (89%) rename src/main/resources/assets/create/flywheel/{shaders => instance}/flap.vert (94%) rename src/main/resources/assets/create/flywheel/{shaders => instance}/rotating.vert (94%) delete mode 100644 src/main/resources/assets/create/flywheel/programs/belt.json delete mode 100644 src/main/resources/assets/create/flywheel/programs/contraption_actor.json delete mode 100644 src/main/resources/assets/create/flywheel/programs/flap.json delete mode 100644 src/main/resources/assets/create/flywheel/programs/rotating.json diff --git a/gradle.properties b/gradle.properties index f7efdc5b9..a13bd9319 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,7 +23,7 @@ use_parchment = true # dependency versions registrate_version = MC1.20-1.3.3 flywheel_minecraft_version = 1.20.1 -flywheel_version = 1.0.0-alpha-5 +flywheel_version = 1.0.0-alpha-11 jei_minecraft_version = 1.20.1 jei_version = 15.2.0.22 curios_minecraft_version = 1.20.1 diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorInstance.java index 0f7f82cbe..7a5ee91a0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorInstance.java @@ -10,25 +10,25 @@ import com.jozufozu.flywheel.lib.instance.AbstractInstance; import net.minecraft.core.BlockPos; public class ActorInstance extends AbstractInstance { - float x; - float y; - float z; - byte blockLight; - byte skyLight; - float rotationOffset; - byte rotationAxisX; - byte rotationAxisY; - byte rotationAxisZ; - float qX; - float qY; - float qZ; - float qW; - byte rotationCenterX = 64; - byte rotationCenterY = 64; - byte rotationCenterZ = 64; - float speed; + public float x; + public float y; + public float z; + public byte blockLight; + public byte skyLight; + public float rotationOffset; + public byte rotationAxisX; + public byte rotationAxisY; + public byte rotationAxisZ; + public float qX; + public float qY; + public float qZ; + public float qW; + public byte rotationCenterX = 64; + public byte rotationCenterY = 64; + public byte rotationCenterZ = 64; + public float speed; - protected ActorInstance(InstanceType type, InstanceHandle handle) { + public ActorInstance(InstanceType type, InstanceHandle handle) { super(type, handle); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorType.java b/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorType.java deleted file mode 100644 index 752f9c497..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorType.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.simibubi.create.content.contraptions.actors.flwdata; - -import com.jozufozu.flywheel.api.instance.InstanceHandle; -import com.jozufozu.flywheel.api.instance.InstanceType; -import com.jozufozu.flywheel.api.instance.InstanceWriter; -import com.jozufozu.flywheel.api.layout.Layout; -import com.jozufozu.flywheel.lib.layout.BufferLayout; -import com.simibubi.create.foundation.render.AllInstanceLayouts; -import com.simibubi.create.foundation.render.AllInstanceShaders; - -import net.minecraft.resources.ResourceLocation; - -public class ActorType implements InstanceType { - @Override - public ActorInstance create(InstanceHandle instanceHandle) { - return new ActorInstance(this, instanceHandle); - } - - @Override - public Layout layout() { - return null; - } - - @Override - public InstanceWriter getWriter() { - return UnsafeActorWriter.INSTANCE; - } - - @Override - public ResourceLocation vertexShader() { - return null; - } - - @Override - public ResourceLocation cullShader() { - return null; - } - - @Override - public BufferLayout getLayout() { - return AllInstanceLayouts.ACTOR; - } - - @Override - public ResourceLocation getProgramSpec() { - return AllInstanceShaders.ACTOR; - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/UnsafeActorWriter.java b/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/UnsafeActorWriter.java deleted file mode 100644 index 96a36a1c5..000000000 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/UnsafeActorWriter.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.simibubi.create.content.contraptions.actors.flwdata; - -import org.lwjgl.system.MemoryUtil; - -import com.jozufozu.flywheel.api.instance.InstanceWriter; - -public class UnsafeActorWriter implements InstanceWriter { - public static final UnsafeActorWriter INSTANCE = new UnsafeActorWriter(); - - @Override - public void write(long ptr, ActorInstance d) { - MemoryUtil.memPutFloat(ptr, d.x); - MemoryUtil.memPutFloat(ptr + 4, d.y); - MemoryUtil.memPutFloat(ptr + 8, d.z); - MemoryUtil.memPutByte(ptr + 12, d.blockLight); - MemoryUtil.memPutByte(ptr + 13, d.skyLight); - MemoryUtil.memPutFloat(ptr + 14, d.rotationOffset); - MemoryUtil.memPutByte(ptr + 18, d.rotationAxisX); - MemoryUtil.memPutByte(ptr + 19, d.rotationAxisY); - MemoryUtil.memPutByte(ptr + 20, d.rotationAxisZ); - MemoryUtil.memPutFloat(ptr + 21, d.qX); - MemoryUtil.memPutFloat(ptr + 25, d.qY); - MemoryUtil.memPutFloat(ptr + 29, d.qZ); - MemoryUtil.memPutFloat(ptr + 33, d.qW); - MemoryUtil.memPutByte(ptr + 37, d.rotationCenterX); - MemoryUtil.memPutByte(ptr + 38, d.rotationCenterY); - MemoryUtil.memPutByte(ptr + 39, d.rotationCenterZ); - MemoryUtil.memPutFloat(ptr + 40, d.speed); - } -} diff --git a/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingInstance.java index f3022378d..163001c10 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/bearing/StabilizedBearingInstance.java @@ -11,7 +11,7 @@ import com.mojang.math.Axis; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ActorInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.render.VirtualRenderWorld; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityInstance.java index 3f63c92e4..1c90f8d02 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntityInstance.java @@ -3,7 +3,6 @@ package com.simibubi.create.content.kinetics.base; import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.visual.AbstractBlockEntityVisual; import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; import com.simibubi.create.content.kinetics.simpleRelays.ICogWheel; import com.simibubi.create.content.kinetics.simpleRelays.ShaftBlock; diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/KineticInstance.java similarity index 88% rename from src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticInstance.java rename to src/main/java/com/simibubi/create/content/kinetics/base/KineticInstance.java index 680ca660b..0fe9a8db1 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/KineticInstance.java @@ -1,21 +1,20 @@ -package com.simibubi.create.content.kinetics.base.flwdata; +package com.simibubi.create.content.kinetics.base; import org.joml.Vector3f; import com.jozufozu.flywheel.api.instance.InstanceHandle; import com.jozufozu.flywheel.api.instance.InstanceType; import com.jozufozu.flywheel.lib.instance.ColoredLitInstance; -import com.simibubi.create.content.kinetics.base.KineticBlockEntity; import com.simibubi.create.foundation.utility.Color; import net.minecraft.core.BlockPos; public class KineticInstance extends ColoredLitInstance { - float x; - float y; - float z; - float rotationalSpeed; - float rotationOffset; + public float x; + public float y; + public float z; + public float rotationalSpeed; + public float rotationOffset; protected KineticInstance(InstanceType type, InstanceHandle handle) { super(type, handle); diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/RotatingInstance.java similarity index 78% rename from src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingInstance.java rename to src/main/java/com/simibubi/create/content/kinetics/base/RotatingInstance.java index e1a1dedf6..de84a5885 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/RotatingInstance.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.kinetics.base.flwdata; +package com.simibubi.create.content.kinetics.base; import org.joml.Vector3f; @@ -8,11 +8,11 @@ import com.jozufozu.flywheel.api.instance.InstanceType; import net.minecraft.core.Direction; public class RotatingInstance extends KineticInstance { - byte rotationAxisX; - byte rotationAxisY; - byte rotationAxisZ; + public byte rotationAxisX; + public byte rotationAxisY; + public byte rotationAxisZ; - protected RotatingInstance(InstanceType type, InstanceHandle handle) { + public RotatingInstance(InstanceType type, InstanceHandle handle) { super(type, handle); } diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java index 2d45fb3e6..8ef8ed139 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java @@ -8,7 +8,6 @@ import com.jozufozu.flywheel.api.instance.Instancer; import com.jozufozu.flywheel.api.model.Model; import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.model.Models; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltType.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltType.java deleted file mode 100644 index bbb4c3129..000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltType.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import com.jozufozu.flywheel.api.instance.InstanceHandle; -import com.jozufozu.flywheel.api.instance.InstanceType; -import com.jozufozu.flywheel.api.instance.InstanceWriter; -import com.jozufozu.flywheel.api.layout.Layout; -import com.jozufozu.flywheel.lib.layout.BufferLayout; -import com.simibubi.create.foundation.render.AllInstanceLayouts; -import com.simibubi.create.foundation.render.AllInstanceShaders; - -import net.minecraft.resources.ResourceLocation; - -public class BeltType implements InstanceType { - @Override - public BeltInstance create(InstanceHandle instanceHandle) { - return new BeltInstance(this, instanceHandle); - } - - @Override - public Layout layout() { - return null; - } - - @Override - public InstanceWriter getWriter() { - return BeltWriter.INSTANCE; - } - - @Override - public ResourceLocation vertexShader() { - return null; - } - - @Override - public ResourceLocation cullShader() { - return null; - } - - @Override - public BeltInstance create() { - return new BeltInstance(); - } - - @Override - public BufferLayout getLayout() { - return AllInstanceLayouts.BELT; - } - - @Override - public ResourceLocation getProgramSpec() { - return AllInstanceShaders.BELT; - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltWriter.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltWriter.java deleted file mode 100644 index 1666b7b59..000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltWriter.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.lwjgl.system.MemoryUtil; - -public class BeltWriter extends KineticWriter { - public static final BeltWriter INSTANCE = new BeltWriter(); - - @Override - public void write(long ptr, BeltInstance d) { - super.write(ptr, d); - MemoryUtil.memPutFloat(ptr + 26, d.qX); - MemoryUtil.memPutFloat(ptr + 30, d.qY); - MemoryUtil.memPutFloat(ptr + 34, d.qZ); - MemoryUtil.memPutFloat(ptr + 38, d.qW); - MemoryUtil.memPutFloat(ptr + 42, d.sourceU); - MemoryUtil.memPutFloat(ptr + 46, d.sourceV); - MemoryUtil.memPutFloat(ptr + 50, d.minU); - MemoryUtil.memPutFloat(ptr + 54, d.minV); - MemoryUtil.memPutFloat(ptr + 58, d.maxU); - MemoryUtil.memPutFloat(ptr + 62, d.maxV); - MemoryUtil.memPutByte(ptr + 66, d.scrollMult); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticWriter.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticWriter.java deleted file mode 100644 index 85578c789..000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/KineticWriter.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.lwjgl.system.MemoryUtil; - -import com.jozufozu.flywheel.lib.instance.ColoredLitWriter; - -public abstract class KineticWriter extends ColoredLitWriter { - @Override - public void write(long ptr, D d) { - super.write(ptr, d); - MemoryUtil.memPutFloat(ptr + 6, d.x); - MemoryUtil.memPutFloat(ptr + 10, d.y); - MemoryUtil.memPutFloat(ptr + 14, d.z); - MemoryUtil.memPutFloat(ptr + 18, d.rotationalSpeed); - MemoryUtil.memPutFloat(ptr + 22, d.rotationOffset); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingType.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingType.java deleted file mode 100644 index 4a5a54498..000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingType.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import com.jozufozu.flywheel.api.instance.InstanceHandle; -import com.jozufozu.flywheel.api.instance.InstanceType; -import com.jozufozu.flywheel.api.instance.InstanceWriter; -import com.jozufozu.flywheel.api.layout.Layout; -import com.jozufozu.flywheel.lib.layout.BufferLayout; -import com.simibubi.create.foundation.render.AllInstanceLayouts; -import com.simibubi.create.foundation.render.AllInstanceShaders; - -import net.minecraft.resources.ResourceLocation; - -public class RotatingType implements InstanceType { - - @Override - public RotatingInstance create(InstanceHandle instanceHandle) { - return new RotatingInstance(this, instanceHandle); - } - - @Override - public Layout layout() { - return null; - } - - @Override - public InstanceWriter getWriter() { - return RotatingWriter.INSTANCE; - } - - @Override - public ResourceLocation vertexShader() { - return null; - } - - @Override - public ResourceLocation cullShader() { - return null; - } - - @Override - public BufferLayout getLayout() { - return AllInstanceLayouts.ROTATING; - } - - @Override - public ResourceLocation getProgramSpec() { - return AllInstanceShaders.ROTATING; - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingWriter.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingWriter.java deleted file mode 100644 index 34ebfd86d..000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/RotatingWriter.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.simibubi.create.content.kinetics.base.flwdata; - -import org.lwjgl.system.MemoryUtil; - -public class RotatingWriter extends KineticWriter { - public static final RotatingWriter INSTANCE = new RotatingWriter(); - - @Override - public void write(long ptr, RotatingInstance d) { - super.write(ptr, d); - MemoryUtil.memPutByte(ptr + 26, d.rotationAxisX); - MemoryUtil.memPutByte(ptr + 27, d.rotationAxisY); - MemoryUtil.memPutByte(ptr + 28, d.rotationAxisZ); - } -} diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/package-info.java b/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/package-info.java deleted file mode 100644 index 9e9a5554f..000000000 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -package com.simibubi.create.content.kinetics.base.flwdata; - -import javax.annotation.ParametersAreNonnullByDefault; - -import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java index 7e4c5f77c..a6816196f 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlockEntity.java @@ -37,6 +37,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; +import net.minecraft.core.SectionPos; import net.minecraft.core.Vec3i; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; @@ -613,12 +614,12 @@ public class BeltBlockEntity extends KineticBlockEntity { } @Override - public boolean isListenerInvalid() { + public boolean isInvalid() { return remove; } @Override - public void onLightUpdate(LightLayer type, Box changed) { + public void onLightUpdate(LightLayer type, SectionPos pos) { if (remove) return; if (level == null) @@ -626,7 +627,7 @@ public class BeltBlockEntity extends KineticBlockEntity { Box beltVolume = getVolume(); - if (beltVolume.intersects(changed)) { + if (beltVolume.intersects(MutableBox.from(pos))) { if (type == LightLayer.BLOCK) updateBlockLight(); diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltInstance.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java similarity index 70% rename from src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltInstance.java rename to src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java index 42133eda5..464810bd9 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/flwdata/BeltInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java @@ -1,27 +1,28 @@ -package com.simibubi.create.content.kinetics.base.flwdata; +package com.simibubi.create.content.kinetics.belt; import org.joml.Quaternionf; import com.jozufozu.flywheel.api.instance.InstanceHandle; import com.jozufozu.flywheel.api.instance.InstanceType; +import com.simibubi.create.content.kinetics.base.KineticInstance; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import net.minecraft.client.renderer.texture.TextureAtlasSprite; public class BeltInstance extends KineticInstance { - float qX; - float qY; - float qZ; - float qW; - float sourceU; - float sourceV; - float minU; - float minV; - float maxU; - float maxV; - byte scrollMult; + public float qX; + public float qY; + public float qZ; + public float qW; + public float sourceU; + public float sourceV; + public float minU; + public float minV; + public float maxU; + public float maxV; + public byte scrollMult; - protected BeltInstance(InstanceType type, InstanceHandle handle) { + public BeltInstance(InstanceType type, InstanceHandle handle) { super(type, handle); } diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltVisual.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltVisual.java index a213d5399..4d58e2f20 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltVisual.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltVisual.java @@ -16,8 +16,7 @@ import com.jozufozu.flywheel.lib.transform.TransformStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.BeltInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java index 3e945b672..7f8edbd36 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java @@ -16,7 +16,7 @@ import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.contraptions.render.ActorInstance; import com.simibubi.create.content.kinetics.base.IRotate; import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.render.VirtualRenderWorld; import com.simibubi.create.foundation.utility.AngleHelper; diff --git a/src/main/java/com/simibubi/create/content/kinetics/fan/FanInstance.java b/src/main/java/com/simibubi/create/content/kinetics/fan/FanInstance.java index cccdd7f1b..fdf90a7ae 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/fan/FanInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/fan/FanInstance.java @@ -10,7 +10,7 @@ import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.model.Models; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; import net.minecraft.core.BlockPos; diff --git a/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java b/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java index ef4ddde49..dc8c43806 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java @@ -13,7 +13,7 @@ import com.jozufozu.flywheel.lib.model.Models; import com.jozufozu.flywheel.lib.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/kinetics/gearbox/GearboxInstance.java b/src/main/java/com/simibubi/create/content/kinetics/gearbox/GearboxInstance.java index ed3b17d74..ef4ef7e24 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/gearbox/GearboxInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/gearbox/GearboxInstance.java @@ -6,13 +6,12 @@ import java.util.function.Consumer; import com.jozufozu.flywheel.api.event.RenderStage; import com.jozufozu.flywheel.api.instance.Instance; -import com.jozufozu.flywheel.api.instance.Instancer; import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.instance.AbstractInstance; import com.jozufozu.flywheel.lib.model.Models; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/kinetics/mixer/MixerInstance.java b/src/main/java/com/simibubi/create/content/kinetics/mixer/MixerInstance.java index c886070d7..b7400b2a7 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mixer/MixerInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mixer/MixerInstance.java @@ -12,7 +12,7 @@ import com.jozufozu.flywheel.lib.instance.InstanceTypes; import com.jozufozu.flywheel.lib.instance.OrientedInstance; import com.jozufozu.flywheel.lib.model.Models; import com.simibubi.create.AllPartialModels; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.content.kinetics.simpleRelays.encased.EncasedCogInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.utility.AnimationTickHolder; diff --git a/src/main/java/com/simibubi/create/content/kinetics/saw/SawInstance.java b/src/main/java/com/simibubi/create/content/kinetics/saw/SawInstance.java index 82d7c68de..1791d9ee3 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/saw/SawInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/saw/SawInstance.java @@ -5,7 +5,6 @@ import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.model.Models; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; import net.minecraft.core.Direction; import net.minecraft.world.level.block.Rotation; diff --git a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityInstance.java b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityInstance.java index 2498932b6..0358ed896 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/BracketedKineticBlockEntityInstance.java @@ -14,7 +14,7 @@ import com.mojang.math.Axis; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; import com.simibubi.create.content.kinetics.base.SingleRotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; import net.minecraft.core.BlockPos; diff --git a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogInstance.java b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogInstance.java index aad032053..a153f2f63 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/simpleRelays/encased/EncasedCogInstance.java @@ -5,7 +5,6 @@ import java.util.function.Consumer; import com.jozufozu.flywheel.api.event.RenderStage; import com.jozufozu.flywheel.api.instance.Instance; -import com.jozufozu.flywheel.api.instance.Instancer; import com.jozufozu.flywheel.api.model.Model; import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.instance.AbstractInstance; @@ -18,7 +17,7 @@ import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.IRotate; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.content.kinetics.simpleRelays.BracketedKineticBlockEntityRenderer; import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftInstance.java b/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftInstance.java index ce4f1e3ae..1b59f0cbe 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/transmission/SplitShaftInstance.java @@ -5,20 +5,18 @@ import java.util.function.Consumer; import com.jozufozu.flywheel.api.event.RenderStage; import com.jozufozu.flywheel.api.instance.Instance; -import com.jozufozu.flywheel.api.instance.Instancer; import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.instance.AbstractInstance; import com.jozufozu.flywheel.lib.model.Models; import com.simibubi.create.AllPartialModels; import com.simibubi.create.content.kinetics.base.IRotate; import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.core.Direction; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; public class SplitShaftInstance extends KineticBlockEntityInstance { diff --git a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapData.java b/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapData.java index 142cb039e..254ed5b41 100644 --- a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapData.java +++ b/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapData.java @@ -12,23 +12,23 @@ import net.minecraft.core.BlockPos; public class FlapData extends AbstractInstance implements FlatLit { - float x; - float y; - float z; - byte blockLight; - byte skyLight; - float segmentOffsetX; - float segmentOffsetY; - float segmentOffsetZ; - float pivotX; - float pivotY; - float pivotZ; - float horizontalAngle; - float intensity; - float flapScale; - float flapness; + public float x; + public float y; + public float z; + public byte blockLight; + public byte skyLight; + public float segmentOffsetX; + public float segmentOffsetY; + public float segmentOffsetZ; + public float pivotX; + public float pivotY; + public float pivotZ; + public float horizontalAngle; + public float intensity; + public float flapScale; + public float flapness; - protected FlapData(InstanceType type, InstanceHandle handle) { + public FlapData(InstanceType type, InstanceHandle handle) { super(type, handle); } diff --git a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapType.java b/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapType.java deleted file mode 100644 index f00da1e8f..000000000 --- a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapType.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.simibubi.create.content.logistics.flwdata; - -import com.jozufozu.flywheel.api.instance.InstanceHandle; -import com.jozufozu.flywheel.api.instance.InstanceType; -import com.jozufozu.flywheel.api.instance.InstanceWriter; -import com.jozufozu.flywheel.api.layout.Layout; -import com.jozufozu.flywheel.lib.layout.BufferLayout; -import com.simibubi.create.foundation.render.AllInstanceLayouts; -import com.simibubi.create.foundation.render.AllInstanceShaders; - -import net.minecraft.resources.ResourceLocation; - -public class FlapType implements InstanceType { - @Override - public FlapData create(InstanceHandle instanceHandle) { - return new FlapData(this, instanceHandle); - } - - @Override - public Layout layout() { - return null; - } - - @Override - public InstanceWriter getWriter() { - return FlapWriter.INSTANCE; - } - - @Override - public ResourceLocation vertexShader() { - return null; - } - - @Override - public ResourceLocation cullShader() { - return null; - } - - @Override - public BufferLayout getLayout() { - return AllInstanceLayouts.FLAP; - } - - @Override - public ResourceLocation getProgramSpec() { - return AllInstanceShaders.FLAPS; - } - - - private static float getFlapAngle(float flapness, float intensity, float scale) { - float absFlap = Math.abs(flapness); - - float angle = (float) (Math.sin((1. - absFlap) * Math.PI * intensity) * 30. * flapness * scale); - - if (flapness > 0) { - return angle * 0.5f; - } else { - return angle; - } - } -} diff --git a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapWriter.java b/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapWriter.java deleted file mode 100644 index e26b3d844..000000000 --- a/src/main/java/com/simibubi/create/content/logistics/flwdata/FlapWriter.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.simibubi.create.content.logistics.flwdata; - -import org.lwjgl.system.MemoryUtil; - -import com.jozufozu.flywheel.api.instance.InstanceWriter; - -public class FlapWriter implements InstanceWriter { - public static final FlapWriter INSTANCE = new FlapWriter(); - - @Override - public void write(long ptr, FlapData d) { - MemoryUtil.memPutFloat(ptr, d.x); - MemoryUtil.memPutFloat(ptr + 4, d.y); - MemoryUtil.memPutFloat(ptr + 8, d.z); - MemoryUtil.memPutByte(ptr + 12, (byte) (d.blockLight << 4)); - MemoryUtil.memPutByte(ptr + 13, (byte) (d.skyLight << 4)); - MemoryUtil.memPutFloat(ptr + 14, d.segmentOffsetX); - MemoryUtil.memPutFloat(ptr + 18, d.segmentOffsetY); - MemoryUtil.memPutFloat(ptr + 22, d.segmentOffsetZ); - MemoryUtil.memPutFloat(ptr + 26, d.pivotX); - MemoryUtil.memPutFloat(ptr + 30, d.pivotY); - MemoryUtil.memPutFloat(ptr + 34, d.pivotZ); - MemoryUtil.memPutFloat(ptr + 38, d.horizontalAngle); - MemoryUtil.memPutFloat(ptr + 42, d.intensity); - MemoryUtil.memPutFloat(ptr + 46, d.flapScale); - MemoryUtil.memPutFloat(ptr + 50, d.flapness); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/render/AllInstanceLayouts.java b/src/main/java/com/simibubi/create/foundation/render/AllInstanceLayouts.java deleted file mode 100644 index a1d3e2865..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/AllInstanceLayouts.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.simibubi.create.foundation.render; - -import com.jozufozu.flywheel.lib.layout.BufferLayout; -import com.jozufozu.flywheel.lib.layout.CommonItems; - -public class AllInstanceLayouts { - - public static final BufferLayout ROTATING = kineticInstance() - .addItems(CommonItems.NORMAL) - .build(); - - public static final BufferLayout BELT = kineticInstance() - .addItems(CommonItems.QUATERNION, CommonItems.UV, CommonItems.VEC4, - CommonItems.NORMALIZED_BYTE) - .build(); - - public static final BufferLayout ACTOR = BufferLayout.builder() - .addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.FLOAT, - CommonItems.NORMAL, CommonItems.QUATERNION, CommonItems.NORMAL, - CommonItems.FLOAT) - .build(); - - public static final BufferLayout FLAP = BufferLayout.builder() - .addItems(CommonItems.VEC3, CommonItems.LIGHT, CommonItems.VEC3, CommonItems.VEC3, - CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT, CommonItems.FLOAT) - .build(); - - private static BufferLayout.Builder kineticInstance() { - return BufferLayout.builder() - .addItems(CommonItems.LIGHT, CommonItems.RGBA) - .addItems(CommonItems.VEC3, CommonItems.FLOAT, CommonItems.FLOAT); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/render/AllInstanceShaders.java b/src/main/java/com/simibubi/create/foundation/render/AllInstanceShaders.java deleted file mode 100644 index d39ab7cfe..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/AllInstanceShaders.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.simibubi.create.foundation.render; - -import static com.simibubi.create.Create.asResource; - -import net.minecraft.resources.ResourceLocation; - -public class AllInstanceShaders { - - public static final ResourceLocation ROTATING = asResource("rotating"); - public static final ResourceLocation BELT = asResource("belt"); - public static final ResourceLocation FLAPS = asResource("flap"); - public static final ResourceLocation ACTOR = asResource("contraption_actor"); - -} diff --git a/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java b/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java index 5e74b27aa..faa2a0018 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java @@ -1,32 +1,158 @@ package com.simibubi.create.foundation.render; -import com.jozufozu.flywheel.api.instance.InstanceType; -import com.simibubi.create.Create; -import com.simibubi.create.content.contraptions.actors.flwdata.ActorInstance; -import com.simibubi.create.content.contraptions.actors.flwdata.ActorType; -import com.simibubi.create.content.kinetics.base.flwdata.BeltInstance; -import com.simibubi.create.content.kinetics.base.flwdata.BeltType; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingInstance; -import com.simibubi.create.content.kinetics.base.flwdata.RotatingType; -import com.simibubi.create.content.logistics.flwdata.FlapData; -import com.simibubi.create.content.logistics.flwdata.FlapType; +import static com.simibubi.create.Create.asResource; + +import org.lwjgl.system.MemoryUtil; + +import com.jozufozu.flywheel.api.instance.InstanceType; +import com.jozufozu.flywheel.api.layout.FloatRepr; +import com.jozufozu.flywheel.api.layout.IntegerRepr; +import com.jozufozu.flywheel.api.layout.LayoutBuilder; +import com.jozufozu.flywheel.lib.instance.SimpleInstanceType; +import com.simibubi.create.content.contraptions.actors.flwdata.ActorInstance; +import com.simibubi.create.content.kinetics.belt.BeltInstance; +import com.simibubi.create.content.kinetics.base.RotatingInstance; +import com.simibubi.create.content.logistics.flwdata.FlapData; -import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class AllInstanceTypes { + // FIXME: memory alignment issues and light being represented by bytes - public static final InstanceType ROTATING = new RotatingType(); - public static final InstanceType BELTS = new BeltType(); - public static final InstanceType ACTORS = new ActorType(); - public static final InstanceType FLAPS = new FlapType(); + public static final InstanceType ROTATING = SimpleInstanceType.builder(RotatingInstance::new) + .cullShader(asResource("instance/cull/rotating.glsl")) + .vertexShader(asResource("instance/rotating.vert")) + .layout(LayoutBuilder.create() + .vector("light", IntegerRepr.SHORT, 2) + .vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4) + .vector("pos", FloatRepr.FLOAT, 3) + .scalar("speed", FloatRepr.FLOAT) + .scalar("offset", FloatRepr.FLOAT) + .vector("axis", FloatRepr.NORMALIZED_BYTE, 3) + .build()) + .writer((ptr, instance) -> { + MemoryUtil.memPutShort(ptr, instance.blockLight); + MemoryUtil.memPutShort(ptr + 2, instance.skyLight); + MemoryUtil.memPutByte(ptr + 4, instance.r); + MemoryUtil.memPutByte(ptr + 5, instance.g); + MemoryUtil.memPutByte(ptr + 6, instance.b); + MemoryUtil.memPutByte(ptr + 7, instance.a); + MemoryUtil.memPutFloat(ptr + 6, instance.x); + MemoryUtil.memPutFloat(ptr + 10, instance.y); + MemoryUtil.memPutFloat(ptr + 14, instance.z); + MemoryUtil.memPutFloat(ptr + 18, instance.rotationalSpeed); + MemoryUtil.memPutFloat(ptr + 22, instance.rotationOffset); + MemoryUtil.memPutByte(ptr + 26, instance.rotationAxisX); + MemoryUtil.memPutByte(ptr + 27, instance.rotationAxisY); + MemoryUtil.memPutByte(ptr + 28, instance.rotationAxisZ); + }) + .register(); + public static final InstanceType BELTS = SimpleInstanceType.builder(BeltInstance::new) + .cullShader(asResource("instance/cull/belt.glsl")) + .vertexShader(asResource("instance/belt.vert")) + .layout(LayoutBuilder.create() + .vector("light", IntegerRepr.SHORT, 2) + .vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4) + .vector("pos", FloatRepr.FLOAT, 3) + .scalar("speed", FloatRepr.FLOAT) + .scalar("offset", FloatRepr.FLOAT) + .vector("rotation", FloatRepr.FLOAT, 4) + .vector("sourceTexture", FloatRepr.FLOAT, 2) + .vector("scrollTexture", FloatRepr.FLOAT, 4) + .scalar("scrollMult", FloatRepr.NORMALIZED_BYTE) + .build()) + .writer((ptr, instance) -> { + MemoryUtil.memPutShort(ptr, instance.blockLight); + MemoryUtil.memPutShort(ptr + 2, instance.skyLight); + MemoryUtil.memPutByte(ptr + 4, instance.r); + MemoryUtil.memPutByte(ptr + 5, instance.g); + MemoryUtil.memPutByte(ptr + 6, instance.b); + MemoryUtil.memPutByte(ptr + 7, instance.a); + MemoryUtil.memPutFloat(ptr + 6, instance.x); + MemoryUtil.memPutFloat(ptr + 10, instance.y); + MemoryUtil.memPutFloat(ptr + 14, instance.z); + MemoryUtil.memPutFloat(ptr + 18, instance.rotationalSpeed); + MemoryUtil.memPutFloat(ptr + 22, instance.rotationOffset); + MemoryUtil.memPutFloat(ptr + 26, instance.qX); + MemoryUtil.memPutFloat(ptr + 30, instance.qY); + MemoryUtil.memPutFloat(ptr + 34, instance.qZ); + MemoryUtil.memPutFloat(ptr + 38, instance.qW); + MemoryUtil.memPutFloat(ptr + 42, instance.sourceU); + MemoryUtil.memPutFloat(ptr + 46, instance.sourceV); + MemoryUtil.memPutFloat(ptr + 50, instance.minU); + MemoryUtil.memPutFloat(ptr + 54, instance.minV); + MemoryUtil.memPutFloat(ptr + 58, instance.maxU); + MemoryUtil.memPutFloat(ptr + 62, instance.maxV); + MemoryUtil.memPutByte(ptr + 66, instance.scrollMult); + }) + .register(); + public static final InstanceType ACTORS = SimpleInstanceType.builder(ActorInstance::new) + .cullShader(asResource("instance/cull/contraption_actor.glsl")) + .vertexShader(asResource("instance/contraption_actor.vert")) + .layout(LayoutBuilder.create() + .vector("pos", FloatRepr.FLOAT, 3) + .vector("light", IntegerRepr.SHORT, 2) + .scalar("offset", FloatRepr.FLOAT) + .vector("axis", FloatRepr.NORMALIZED_BYTE, 3) + .vector("rotation", FloatRepr.FLOAT, 4) + .vector("rotationCenter", FloatRepr.NORMALIZED_BYTE, 3) + .scalar("speed", FloatRepr.FLOAT) + .build()) + .writer((ptr, instance) -> { + MemoryUtil.memPutFloat(ptr, instance.x); + MemoryUtil.memPutFloat(ptr + 4, instance.y); + MemoryUtil.memPutFloat(ptr + 8, instance.z); + MemoryUtil.memPutByte(ptr + 12, instance.blockLight); + MemoryUtil.memPutByte(ptr + 13, instance.skyLight); + MemoryUtil.memPutFloat(ptr + 14, instance.rotationOffset); + MemoryUtil.memPutByte(ptr + 18, instance.rotationAxisX); + MemoryUtil.memPutByte(ptr + 19, instance.rotationAxisY); + MemoryUtil.memPutByte(ptr + 20, instance.rotationAxisZ); + MemoryUtil.memPutFloat(ptr + 21, instance.qX); + MemoryUtil.memPutFloat(ptr + 25, instance.qY); + MemoryUtil.memPutFloat(ptr + 29, instance.qZ); + MemoryUtil.memPutFloat(ptr + 33, instance.qW); + MemoryUtil.memPutByte(ptr + 37, instance.rotationCenterX); + MemoryUtil.memPutByte(ptr + 38, instance.rotationCenterY); + MemoryUtil.memPutByte(ptr + 39, instance.rotationCenterZ); + MemoryUtil.memPutFloat(ptr + 40, instance.speed); + }) + .register(); + public static final InstanceType FLAPS = SimpleInstanceType.builder(FlapData::new) + .cullShader(asResource("instance/cull/flap.glsl")) + .vertexShader(asResource("instance/flap.vert")) + .layout(LayoutBuilder.create() + .vector("instancePos", FloatRepr.FLOAT, 3) + .vector("light", IntegerRepr.SHORT, 2) + .vector("segmentOffset", FloatRepr.FLOAT, 3) + .vector("pivot", FloatRepr.FLOAT, 3) + .scalar("horizontalAngle", FloatRepr.FLOAT) + .scalar("intensity", FloatRepr.FLOAT) + .scalar("flapScale", FloatRepr.FLOAT) + .scalar("flapness", FloatRepr.FLOAT) + .build()) + .writer((ptr, instance) -> { + MemoryUtil.memPutFloat(ptr, instance.x); + MemoryUtil.memPutFloat(ptr + 4, instance.y); + MemoryUtil.memPutFloat(ptr + 8, instance.z); + MemoryUtil.memPutByte(ptr + 12, (byte) (instance.blockLight << 4)); + MemoryUtil.memPutByte(ptr + 13, (byte) (instance.skyLight << 4)); + MemoryUtil.memPutFloat(ptr + 14, instance.segmentOffsetX); + MemoryUtil.memPutFloat(ptr + 18, instance.segmentOffsetY); + MemoryUtil.memPutFloat(ptr + 22, instance.segmentOffsetZ); + MemoryUtil.memPutFloat(ptr + 26, instance.pivotX); + MemoryUtil.memPutFloat(ptr + 30, instance.pivotY); + MemoryUtil.memPutFloat(ptr + 34, instance.pivotZ); + MemoryUtil.memPutFloat(ptr + 38, instance.horizontalAngle); + MemoryUtil.memPutFloat(ptr + 42, instance.intensity); + MemoryUtil.memPutFloat(ptr + 46, instance.flapScale); + MemoryUtil.memPutFloat(ptr + 50, instance.flapness); + }) + .register(); - public static class Locations { - public static final ResourceLocation ROTATING = Create.asResource("rotating"); - public static final ResourceLocation BELTS = Create.asResource("belts"); - public static final ResourceLocation ACTORS = Create.asResource("actors"); - public static final ResourceLocation FLAPS = Create.asResource("flaps"); + public static void init() { + // noop } } diff --git a/src/main/resources/assets/create/flywheel/shaders/context/contraption.glsl b/src/main/resources/assets/create/flywheel/context/contraption.glsl similarity index 100% rename from src/main/resources/assets/create/flywheel/shaders/context/contraption.glsl rename to src/main/resources/assets/create/flywheel/context/contraption.glsl diff --git a/src/main/resources/assets/create/flywheel/shaders/belt.vert b/src/main/resources/assets/create/flywheel/instance/belt.vert similarity index 91% rename from src/main/resources/assets/create/flywheel/shaders/belt.vert rename to src/main/resources/assets/create/flywheel/instance/belt.vert index 215958ef6..48cc0a83d 100644 --- a/src/main/resources/assets/create/flywheel/shaders/belt.vert +++ b/src/main/resources/assets/create/flywheel/instance/belt.vert @@ -1,7 +1,7 @@ #define PI 3.1415926538 -#use "flywheel:core/quaternion.glsl" -#use "flywheel:core/matutils.glsl" +#include "flywheel:core/quaternion.glsl" +#include "flywheel:core/matutils.glsl" struct Belt { vec2 light; diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert b/src/main/resources/assets/create/flywheel/instance/contraption_actor.vert similarity index 89% rename from src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert rename to src/main/resources/assets/create/flywheel/instance/contraption_actor.vert index 1cb8335de..eca332180 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_actor.vert +++ b/src/main/resources/assets/create/flywheel/instance/contraption_actor.vert @@ -1,7 +1,7 @@ #define PI 3.1415926538 -#use "flywheel:core/matutils.glsl" -#use "flywheel:core/quaternion.glsl" +#include "flywheel:core/matutils.glsl" +#include "flywheel:core/quaternion.glsl" struct Actor { vec3 pos; diff --git a/src/main/resources/assets/create/flywheel/shaders/flap.vert b/src/main/resources/assets/create/flywheel/instance/flap.vert similarity index 94% rename from src/main/resources/assets/create/flywheel/shaders/flap.vert rename to src/main/resources/assets/create/flywheel/instance/flap.vert index 396672436..ea4ae6fb3 100644 --- a/src/main/resources/assets/create/flywheel/shaders/flap.vert +++ b/src/main/resources/assets/create/flywheel/instance/flap.vert @@ -1,7 +1,7 @@ #define PI 3.1415926538 -#use "flywheel:core/matutils.glsl" -#use "flywheel:core/quaternion.glsl" +#include "flywheel:core/matutils.glsl" +#include "flywheel:core/quaternion.glsl" struct Flap { vec3 instancePos; diff --git a/src/main/resources/assets/create/flywheel/shaders/rotating.vert b/src/main/resources/assets/create/flywheel/instance/rotating.vert similarity index 94% rename from src/main/resources/assets/create/flywheel/shaders/rotating.vert rename to src/main/resources/assets/create/flywheel/instance/rotating.vert index 08a0e331c..e934b3e24 100644 --- a/src/main/resources/assets/create/flywheel/shaders/rotating.vert +++ b/src/main/resources/assets/create/flywheel/instance/rotating.vert @@ -1,6 +1,6 @@ #define PI 3.1415926538 -#use "flywheel:core/matutils.glsl" +#include "flywheel:core/matutils.glsl" struct Rotating { vec2 light; diff --git a/src/main/resources/assets/create/flywheel/programs/belt.json b/src/main/resources/assets/create/flywheel/programs/belt.json deleted file mode 100644 index b94f52d08..000000000 --- a/src/main/resources/assets/create/flywheel/programs/belt.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "vertex": "create:belt.vert", - "fragment": "flywheel:block.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 deleted file mode 100644 index 117122132..000000000 --- a/src/main/resources/assets/create/flywheel/programs/contraption_actor.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "vertex": "create:contraption_actor.vert", - "fragment": "flywheel:block.frag" -} diff --git a/src/main/resources/assets/create/flywheel/programs/flap.json b/src/main/resources/assets/create/flywheel/programs/flap.json deleted file mode 100644 index e1beb3d15..000000000 --- a/src/main/resources/assets/create/flywheel/programs/flap.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "vertex": "create:flap.vert", - "fragment": "flywheel:block.frag" -} diff --git a/src/main/resources/assets/create/flywheel/programs/rotating.json b/src/main/resources/assets/create/flywheel/programs/rotating.json deleted file mode 100644 index 5010535ec..000000000 --- a/src/main/resources/assets/create/flywheel/programs/rotating.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "vertex": "create:rotating.vert", - "fragment": "flywheel:block.frag" -}