From 85b1b8688359caa5921948a28bf5ddc01ddc3a0f Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Thu, 2 Dec 2021 19:26:33 -0800 Subject: [PATCH] Unsafe writers for StructTypes - Bump flywheel build --- gradle.properties | 2 +- .../base/CutoutRotatingInstance.java | 1 + .../contraptions/base/HalfShaftInstance.java | 1 + .../base/KineticTileInstance.java | 1 + .../base/ShaftlessCogInstance.java | 1 + .../base/ShaftlessLargeCogInstance.java | 1 + .../base/SingleRotatingInstance.java | 5 ++- .../belt => base/flwdata}/BeltData.java | 25 ++++++----- .../contraptions/base/flwdata/BeltType.java | 24 +++++++++++ .../base/{ => flwdata}/KineticData.java | 13 +++--- .../base/{ => flwdata}/RotatingData.java | 8 ++-- .../base/flwdata/RotatingType.java | 24 +++++++++++ .../base/flwdata/UnsafeBeltWriter.java | 42 +++++++++++++++++++ .../base/flwdata/UnsafeRotatingWriter.java | 34 +++++++++++++++ .../components/actors/DrillActorInstance.java | 1 + .../components/actors/DrillInstance.java | 2 +- .../actors/{ => flwdata}/ActorData.java | 37 ++++++++-------- .../components/actors/flwdata/ActorType.java | 24 +++++++++++ .../actors/flwdata/UnsafeActorWriter.java | 36 ++++++++++++++++ .../crafter/MechanicalCrafterInstance.java | 2 +- .../deployer/DeployerActorInstance.java | 2 +- .../components/fan/FanInstance.java | 2 +- .../components/flywheel/FlyWheelInstance.java | 2 +- .../millstone/MillStoneCogInstance.java | 2 +- .../components/mixer/MixerInstance.java | 4 +- .../components/saw/SawInstance.java | 2 +- .../render/ContraptionProgram.java | 7 +--- .../contraptions/fluids/PumpCogInstance.java | 2 +- .../relays/belt/BeltInstance.java | 3 +- .../BracketedKineticTileInstance.java | 2 +- .../relays/encased/SplitShaftInstance.java | 2 +- .../relays/gearbox/GearboxInstance.java | 2 +- .../armor/CopperBacktankInstance.java | 2 +- .../belts/tunnel/BeltTunnelInstance.java | 2 +- .../logistics/block/{ => flap}/FlapData.java | 36 +++++++--------- .../logistics/block/flap/FlapType.java | 24 +++++++++++ .../block/flap/UnsafeFlapWriter.java | 35 ++++++++++++++++ .../block/funnel/FunnelInstance.java | 2 +- .../block/mechanicalArm/ArmInstance.java | 2 +- .../foundation/render/AllMaterialSpecs.java | 27 ++++++------ .../foundation/render/CreateContexts.java | 4 +- 41 files changed, 345 insertions(+), 105 deletions(-) rename src/main/java/com/simibubi/create/content/contraptions/{relays/belt => base/flwdata}/BeltData.java (76%) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java rename src/main/java/com/simibubi/create/content/contraptions/base/{ => flwdata}/KineticData.java (88%) rename src/main/java/com/simibubi/create/content/contraptions/base/{ => flwdata}/RotatingData.java (86%) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java create mode 100644 src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java create mode 100644 src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java rename src/main/java/com/simibubi/create/content/contraptions/components/actors/{ => flwdata}/ActorData.java (84%) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java create mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/UnsafeActorWriter.java rename src/main/java/com/simibubi/create/content/logistics/block/{ => flap}/FlapData.java (82%) create mode 100644 src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java create mode 100644 src/main/java/com/simibubi/create/content/logistics/block/flap/UnsafeFlapWriter.java diff --git a/gradle.properties b/gradle.properties index 72694d60a..5d48e1217 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ parchment_version = 2021.10.31 # dependency versions registrate_version = MC1.17.1-1.0.14 -flywheel_version = 1.17-0.3.0.17 +flywheel_version = 1.17-0.3.0.19 jei_version = 8.2.0.36 # curseforge information diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/CutoutRotatingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/CutoutRotatingInstance.java index c8c720bd1..66bc4ba36 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/CutoutRotatingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/CutoutRotatingInstance.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.material.Material; import com.jozufozu.flywheel.backend.material.MaterialManager; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.foundation.render.AllMaterialSpecs; public class CutoutRotatingInstance extends SingleRotatingInstance { 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 7b09360e2..3eef396e8 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 @@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import net.minecraft.core.Direction; import net.minecraft.world.level.block.state.properties.BlockStateProperties; 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 0046630ef..5a220c586 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 @@ -4,6 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.material.Material; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.AllBlocks; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock; import com.simibubi.create.foundation.render.AllMaterialSpecs; 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 be7b4f7b9..5f5dcaa51 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 @@ -7,6 +7,7 @@ import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Vector3f; import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import net.minecraft.core.Direction; import net.minecraft.core.Direction.AxisDirection; diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessLargeCogInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessLargeCogInstance.java index 2d722039c..eafc26d72 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessLargeCogInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/ShaftlessLargeCogInstance.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.foundation.render.AllMaterialSpecs; public class ShaftlessLargeCogInstance 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 7e90d602d..471332966 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 @@ -2,17 +2,18 @@ package com.simibubi.create.content.contraptions.base; import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import net.minecraft.world.level.block.state.BlockState; public class SingleRotatingInstance extends KineticTileInstance { protected RotatingData rotatingModel; - + public SingleRotatingInstance(MaterialManager modelManager, KineticTileEntity tile) { super(modelManager, tile); } - + @Override public void init() { rotatingModel = setup(getModel().createInstance()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltData.java similarity index 76% rename from src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java rename to src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltData.java index e91471995..c4473493c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltData.java @@ -1,24 +1,23 @@ -package com.simibubi.create.content.contraptions.relays.belt; +package com.simibubi.create.content.contraptions.base.flwdata; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.mojang.math.Quaternion; -import com.simibubi.create.content.contraptions.base.KineticData; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import net.minecraft.client.renderer.texture.TextureAtlasSprite; public class BeltData extends KineticData { - private float qX; - private float qY; - private float qZ; - private float qW; - private float sourceU; - private float sourceV; - private float minU; - private float minV; - private float maxU; - private float maxV; - private byte scrollMult; + float qX; + float qY; + float qZ; + float qW; + float sourceU; + float sourceV; + float minU; + float minV; + float maxU; + float maxV; + byte scrollMult; public BeltData setRotation(Quaternion q) { this.qX = q.i(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java new file mode 100644 index 000000000..e0d9455af --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/BeltType.java @@ -0,0 +1,24 @@ +package com.simibubi.create.content.contraptions.base.flwdata; + +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.StructWriter; +import com.simibubi.create.foundation.render.AllInstanceFormats; + +public class BeltType implements StructType { + @Override + public BeltData create() { + return new BeltData(); + } + + @Override + public VertexFormat format() { + return AllInstanceFormats.BELT; + } + + @Override + public StructWriter getWriter(VecBuffer backing) { + return new UnsafeBeltWriter(backing, this); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/KineticData.java similarity index 88% rename from src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java rename to src/main/java/com/simibubi/create/content/contraptions/base/flwdata/KineticData.java index 6a6f14e89..7d65ef741 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/KineticData.java @@ -1,18 +1,19 @@ -package com.simibubi.create.content.contraptions.base; +package com.simibubi.create.content.contraptions.base.flwdata; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.core.materials.BasicData; import com.mojang.math.Vector3f; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.utility.Color; import net.minecraft.core.BlockPos; public class KineticData extends BasicData { - private float x; - private float y; - private float z; - private float rotationalSpeed; - private float rotationOffset; + float x; + float y; + float z; + float rotationalSpeed; + float rotationOffset; public KineticData setPosition(BlockPos pos) { return setPosition(pos.getX(), pos.getY(), pos.getZ()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingData.java similarity index 86% rename from src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java rename to src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingData.java index 7bc57147f..b019c775f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/RotatingData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingData.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.contraptions.base; +package com.simibubi.create.content.contraptions.base.flwdata; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.mojang.math.Vector3f; @@ -6,9 +6,9 @@ import com.mojang.math.Vector3f; import net.minecraft.core.Direction; public class RotatingData extends KineticData { - private byte rotationAxisX; - private byte rotationAxisY; - private byte rotationAxisZ; + byte rotationAxisX; + byte rotationAxisY; + byte rotationAxisZ; public RotatingData setRotationAxis(Direction.Axis axis) { Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis); diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java new file mode 100644 index 000000000..0f4bf4d48 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/RotatingType.java @@ -0,0 +1,24 @@ +package com.simibubi.create.content.contraptions.base.flwdata; + +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.StructWriter; +import com.simibubi.create.foundation.render.AllInstanceFormats; + +public class RotatingType implements StructType { + @Override + public RotatingData create() { + return new RotatingData(); + } + + @Override + public VertexFormat format() { + return AllInstanceFormats.ROTATING; + } + + @Override + public StructWriter getWriter(VecBuffer backing) { + return new UnsafeRotatingWriter(backing, this); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java new file mode 100644 index 000000000..5774892d2 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeBeltWriter.java @@ -0,0 +1,42 @@ +package com.simibubi.create.content.contraptions.base.flwdata; + +import org.lwjgl.system.MemoryUtil; + +import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; + +public class UnsafeBeltWriter extends UnsafeBufferWriter { + public UnsafeBeltWriter(VecBuffer backingBuffer, StructType vertexType) { + super(backingBuffer, vertexType); + } + + @Override + public void write(BeltData d) { + long addr = writePointer; + MemoryUtil.memPutByte(addr, d.blockLight); + MemoryUtil.memPutByte(addr + 1, d.skyLight); + MemoryUtil.memPutByte(addr + 2, d.r); + MemoryUtil.memPutByte(addr + 3, d.g); + MemoryUtil.memPutByte(addr + 4, d.b); + MemoryUtil.memPutByte(addr + 5, d.a); + MemoryUtil.memPutFloat(addr + 6, d.x); + MemoryUtil.memPutFloat(addr + 10, d.y); + MemoryUtil.memPutFloat(addr + 14, d.z); + MemoryUtil.memPutFloat(addr + 18, d.rotationalSpeed); + MemoryUtil.memPutFloat(addr + 22, d.rotationOffset); + MemoryUtil.memPutFloat(addr + 26, d.qX); + MemoryUtil.memPutFloat(addr + 30, d.qY); + MemoryUtil.memPutFloat(addr + 34, d.qZ); + MemoryUtil.memPutFloat(addr + 38, d.qW); + MemoryUtil.memPutFloat(addr + 42, d.sourceU); + MemoryUtil.memPutFloat(addr + 46, d.sourceV); + MemoryUtil.memPutFloat(addr + 50, d.minU); + MemoryUtil.memPutFloat(addr + 54, d.minV); + MemoryUtil.memPutFloat(addr + 58, d.maxU); + MemoryUtil.memPutFloat(addr + 62, d.maxV); + MemoryUtil.memPutByte(addr + 66, d.scrollMult); + + advance(); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java new file mode 100644 index 000000000..fbbc58c8c --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/base/flwdata/UnsafeRotatingWriter.java @@ -0,0 +1,34 @@ +package com.simibubi.create.content.contraptions.base.flwdata; + +import org.lwjgl.system.MemoryUtil; + +import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; + +public class UnsafeRotatingWriter extends UnsafeBufferWriter { + public UnsafeRotatingWriter(VecBuffer backingBuffer, StructType vertexType) { + super(backingBuffer, vertexType); + } + + @Override + public void write(RotatingData d) { + long addr = writePointer; + MemoryUtil.memPutByte(addr, d.blockLight); + MemoryUtil.memPutByte(addr + 1, d.skyLight); + MemoryUtil.memPutByte(addr + 2, d.r); + MemoryUtil.memPutByte(addr + 3, d.g); + MemoryUtil.memPutByte(addr + 4, d.b); + MemoryUtil.memPutByte(addr + 5, d.a); + MemoryUtil.memPutFloat(addr + 6, d.x); + MemoryUtil.memPutFloat(addr + 10, d.y); + MemoryUtil.memPutFloat(addr + 14, d.z); + MemoryUtil.memPutFloat(addr + 18, d.rotationalSpeed); + MemoryUtil.memPutFloat(addr + 22, d.rotationOffset); + MemoryUtil.memPutByte(addr + 26, d.rotationAxisX); + MemoryUtil.memPutByte(addr + 27, d.rotationAxisY); + MemoryUtil.memPutByte(addr + 28, d.rotationAxisZ); + + advance(); + } +} 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 f5292ebff..f45ad82e3 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 @@ -6,6 +6,7 @@ import com.mojang.math.Quaternion; 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.actors.flwdata.ActorData; import com.simibubi.create.foundation.render.AllMaterialSpecs; 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 14fac8502..92148ac01 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 @@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; 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.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import net.minecraft.core.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/flwdata/ActorData.java similarity index 84% rename from src/main/java/com/simibubi/create/content/contraptions/components/actors/ActorData.java rename to src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorData.java index fe981607a..d2bb2c151 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/flwdata/ActorData.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.contraptions.components.actors; +package com.simibubi.create.content.contraptions.components.actors.flwdata; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; @@ -8,24 +8,23 @@ import com.mojang.math.Vector3f; import net.minecraft.core.BlockPos; public class ActorData extends InstanceData { - private float x; - private float y; - private float z; - private byte blockLight; - private byte skyLight; - private float rotationOffset; - private byte rotationAxisX; - private byte rotationAxisY; - private byte rotationAxisZ; - private float qX; - private float qY; - private float qZ; - private float qW; - private byte rotationCenterX = 64; - private byte rotationCenterY = 64; - private byte rotationCenterZ = 64; - - private float speed; + 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 ActorData setPosition(BlockPos pos) { this.x = pos.getX(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java new file mode 100644 index 000000000..a39f78bf1 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/ActorType.java @@ -0,0 +1,24 @@ +package com.simibubi.create.content.contraptions.components.actors.flwdata; + +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.StructWriter; +import com.simibubi.create.foundation.render.AllInstanceFormats; + +public class ActorType implements StructType { + @Override + public ActorData create() { + return new ActorData(); + } + + @Override + public VertexFormat format() { + return AllInstanceFormats.BELT; + } + + @Override + public StructWriter getWriter(VecBuffer backing) { + return new UnsafeActorWriter(backing, this); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/UnsafeActorWriter.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/UnsafeActorWriter.java new file mode 100644 index 000000000..08e700930 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/flwdata/UnsafeActorWriter.java @@ -0,0 +1,36 @@ +package com.simibubi.create.content.contraptions.components.actors.flwdata; + +import org.lwjgl.system.MemoryUtil; + +import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; + +public class UnsafeActorWriter extends UnsafeBufferWriter { + public UnsafeActorWriter(VecBuffer backingBuffer, StructType vertexType) { + super(backingBuffer, vertexType); + } + + @Override + public void write(ActorData d) { + long addr = writePointer; + MemoryUtil.memPutFloat(addr, d.x); + MemoryUtil.memPutFloat(addr + 4, d.y); + MemoryUtil.memPutFloat(addr + 8, d.z); + MemoryUtil.memPutByte(addr + 12, d.blockLight); + MemoryUtil.memPutByte(addr + 13, d.skyLight); + MemoryUtil.memPutFloat(addr + 14, d.rotationOffset); + MemoryUtil.memPutByte(addr + 18, d.rotationAxisX); + MemoryUtil.memPutByte(addr + 19, d.rotationAxisY); + MemoryUtil.memPutByte(addr + 20, d.rotationAxisZ); + MemoryUtil.memPutFloat(addr + 21, d.qX); + MemoryUtil.memPutFloat(addr + 25, d.qY); + MemoryUtil.memPutFloat(addr + 29, d.qZ); + MemoryUtil.memPutFloat(addr + 33, d.qW); + MemoryUtil.memPutByte(addr + 37, d.rotationCenterX); + MemoryUtil.memPutByte(addr + 38, d.rotationCenterY); + MemoryUtil.memPutByte(addr + 39, d.rotationCenterZ); + MemoryUtil.memPutFloat(addr + 40, d.speed); + advance(); + } +} 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 9a52923b1..f6718472b 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 @@ -8,7 +8,7 @@ import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; 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.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import net.minecraft.core.Direction; 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 adbf567b4..38cba5220 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 @@ -12,7 +12,7 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack; 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.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.foundation.render.AllMaterialSpecs; 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 59e3610d5..c883fca04 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 @@ -5,7 +5,7 @@ import static net.minecraft.world.level.block.state.properties.BlockStatePropert import com.jozufozu.flywheel.backend.material.MaterialManager; 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.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.foundation.render.AllMaterialSpecs; import net.minecraft.core.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 87133b5c0..3f4804556 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 @@ -16,7 +16,7 @@ import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; 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.content.contraptions.base.flwdata.RotatingData; 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/millstone/MillStoneCogInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillStoneCogInstance.java index e216429bc..c665ad385 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 @@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; 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.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; public class MillStoneCogInstance extends SingleRotatingInstance { 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 7ad3b6b36..a126aafdb 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 @@ -5,7 +5,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.materials.oriented.OrientedData; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.content.contraptions.base.RotatingData; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.ShaftlessCogInstance; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -37,7 +37,7 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta transformPole(renderedHeadOffset); transformHead(renderedHeadOffset); } - + @Override protected Instancer getModel() { return materialManager.defaultSolid() 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 8a44690e6..865cdbfa1 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 @@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; 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.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import net.minecraft.core.Direction; 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 47b165d4a..c1c6e7f91 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,11 +1,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; -import java.util.List; - import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.core.shader.WorldProgram; -import com.jozufozu.flywheel.core.shader.extension.IProgramExtension; import com.mojang.math.Matrix4f; import net.minecraft.resources.ResourceLocation; @@ -18,8 +15,8 @@ public class ContraptionProgram extends WorldProgram { protected int uLightVolume; - public ContraptionProgram(ResourceLocation name, int handle, List extensions) { - super(name, handle, extensions); + public ContraptionProgram(ResourceLocation name, int handle) { + super(name, handle); uLightBoxSize = getUniformLocation("uLightBoxSize"); uLightBoxMin = getUniformLocation("uLightBoxMin"); uModel = getUniformLocation("uModel"); 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 471e33b31..b6b663f9d 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 @@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; 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.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import net.minecraft.core.Direction; 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 ad82749ba..0e42b215e 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 @@ -13,7 +13,8 @@ import com.mojang.math.Quaternion; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.KineticTileInstance; -import com.simibubi.create.content.contraptions.base.RotatingData; +import com.simibubi.create.content.contraptions.base.flwdata.BeltData; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileInstance.java index ab179d0dd..7bb06cdc4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileInstance.java @@ -8,7 +8,7 @@ import com.mojang.math.Vector3f; 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.base.RotatingData; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import net.minecraft.core.BlockPos; 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 85c167541..b446836cf 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 @@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; 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.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.core.Direction; 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 0c8a29c9c..b77eb4e33 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 @@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.material.Material; import com.jozufozu.flywheel.backend.material.MaterialManager; 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.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.core.BlockPos; diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankInstance.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankInstance.java index 8482f2279..e6e6d4f27 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankInstance.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankInstance.java @@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.material.MaterialManager; 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.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; public class CopperBacktankInstance extends SingleRotatingInstance { 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 22a11ad9c..74e8cbc1e 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,7 +11,7 @@ import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.content.logistics.block.FlapData; +import com.simibubi.create.content.logistics.block.flap.FlapData; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.animation.InterpolatedValue; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapData.java similarity index 82% rename from src/main/java/com/simibubi/create/content/logistics/block/FlapData.java rename to src/main/java/com/simibubi/create/content/logistics/block/flap/FlapData.java index 2cfc43c9d..890e38203 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/FlapData.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapData.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block; +package com.simibubi.create.content.logistics.block.flap; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; @@ -9,25 +9,21 @@ import net.minecraft.core.BlockPos; public class FlapData extends InstanceData implements IFlatLight { - private float x; - private float y; - private float z; - private byte blockLight; - private byte skyLight; - - private float segmentOffsetX; - private float segmentOffsetY; - private float segmentOffsetZ; - - private float pivotX; - private float pivotY; - private float pivotZ; - - private float horizontalAngle; - private float intensity; - private float flapScale; - - private float flapness; + 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 FlapData setPosition(BlockPos pos) { return setPosition(pos.getX(), pos.getY(), pos.getZ()); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java new file mode 100644 index 000000000..8e93f90b3 --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/block/flap/FlapType.java @@ -0,0 +1,24 @@ +package com.simibubi.create.content.logistics.block.flap; + +import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; +import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.StructWriter; +import com.simibubi.create.foundation.render.AllInstanceFormats; + +public class FlapType implements StructType { + @Override + public FlapData create() { + return new FlapData(); + } + + @Override + public VertexFormat format() { + return AllInstanceFormats.FLAP; + } + + @Override + public StructWriter getWriter(VecBuffer backing) { + return new UnsafeFlapWriter(backing, this); + } +} diff --git a/src/main/java/com/simibubi/create/content/logistics/block/flap/UnsafeFlapWriter.java b/src/main/java/com/simibubi/create/content/logistics/block/flap/UnsafeFlapWriter.java new file mode 100644 index 000000000..5b1e22afd --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/block/flap/UnsafeFlapWriter.java @@ -0,0 +1,35 @@ +package com.simibubi.create.content.logistics.block.flap; + +import org.lwjgl.system.MemoryUtil; + +import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; +import com.jozufozu.flywheel.backend.struct.StructType; +import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; + +public class UnsafeFlapWriter extends UnsafeBufferWriter { + public UnsafeFlapWriter(VecBuffer backingBuffer, StructType vertexType) { + super(backingBuffer, vertexType); + } + + @Override + public void write(FlapData d) { + long addr = writePointer; + MemoryUtil.memPutFloat(addr, d.x); + MemoryUtil.memPutFloat(addr + 4, d.y); + MemoryUtil.memPutFloat(addr + 8, d.z); + MemoryUtil.memPutByte(addr + 12, d.blockLight); + MemoryUtil.memPutByte(addr + 13, d.skyLight); + MemoryUtil.memPutFloat(addr + 14, d.segmentOffsetX); + MemoryUtil.memPutFloat(addr + 18, d.segmentOffsetY); + MemoryUtil.memPutFloat(addr + 22, d.segmentOffsetZ); + MemoryUtil.memPutFloat(addr + 26, d.pivotX); + MemoryUtil.memPutFloat(addr + 30, d.pivotY); + MemoryUtil.memPutFloat(addr + 34, d.pivotZ); + MemoryUtil.memPutFloat(addr + 38, d.horizontalAngle); + MemoryUtil.memPutFloat(addr + 42, d.intensity); + MemoryUtil.memPutFloat(addr + 46, d.flapScale); + MemoryUtil.memPutFloat(addr + 50, d.flapness); + + advance(); + } +} 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 c7b7e46cb..838b156b9 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,7 +9,7 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.content.logistics.block.FlapData; +import com.simibubi.create.content.logistics.block.flap.FlapData; import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.utility.AnimationTickHolder; 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 9a8169d04..fb9b19db5 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 @@ -12,7 +12,7 @@ import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.content.contraptions.base.RotatingData; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; 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 52f3ff7b2..9c88aadeb 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllMaterialSpecs.java @@ -1,15 +1,17 @@ package com.simibubi.create.foundation.render; import com.jozufozu.flywheel.backend.material.MaterialSpec; -import com.jozufozu.flywheel.backend.struct.BasicStructType; -import com.jozufozu.flywheel.backend.struct.StructType; import com.jozufozu.flywheel.core.Formats; import com.jozufozu.flywheel.event.GatherContextEvent; import com.simibubi.create.Create; -import com.simibubi.create.content.contraptions.base.RotatingData; -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.content.contraptions.components.actors.flwdata.ActorType; +import com.simibubi.create.content.contraptions.base.flwdata.BeltType; +import com.simibubi.create.content.logistics.block.flap.FlapType; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingData; +import com.simibubi.create.content.contraptions.base.flwdata.RotatingType; +import com.simibubi.create.content.contraptions.components.actors.flwdata.ActorData; +import com.simibubi.create.content.contraptions.base.flwdata.BeltData; +import com.simibubi.create.content.logistics.block.flap.FlapData; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; @@ -21,15 +23,10 @@ public class AllMaterialSpecs { // noop, make sure the static field are loaded. } - public static final StructType ROTATING_TYPE = new BasicStructType<>(RotatingData::new, AllInstanceFormats.ROTATING); - public static final StructType BELTS_TYPE = new BasicStructType<>(BeltData::new, AllInstanceFormats.BELT); - public static final StructType ACTORS_TYPE = new BasicStructType<>(ActorData::new, AllInstanceFormats.ACTOR); - public static final StructType FLAPS_TYPE = new BasicStructType<>(FlapData::new, AllInstanceFormats.FLAP); - - public static final MaterialSpec ROTATING = new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, Formats.UNLIT_MODEL, ROTATING_TYPE); - public static final MaterialSpec BELTS = new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, Formats.UNLIT_MODEL, BELTS_TYPE); - public static final MaterialSpec ACTORS = new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, Formats.UNLIT_MODEL, ACTORS_TYPE); - public static final MaterialSpec FLAPS = new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, Formats.UNLIT_MODEL, FLAPS_TYPE); + public static final MaterialSpec ROTATING = new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, Formats.UNLIT_MODEL, new RotatingType()); + public static final MaterialSpec BELTS = new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, Formats.UNLIT_MODEL, new BeltType()); + public static final MaterialSpec ACTORS = new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, Formats.UNLIT_MODEL, new ActorType()); + public static final MaterialSpec FLAPS = new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, Formats.UNLIT_MODEL, new FlapType()); public static void flwInit(GatherContextEvent event) { event.getBackend().register(ROTATING); diff --git a/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java b/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java index 12342701b..c65b8cd25 100644 --- a/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java +++ b/src/main/java/com/simibubi/create/foundation/render/CreateContexts.java @@ -3,7 +3,7 @@ package com.simibubi.create.foundation.render; import java.util.stream.Stream; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.SpecMetaRegistry; +import com.jozufozu.flywheel.backend.GameStateRegistry; import com.jozufozu.flywheel.backend.pipeline.IShaderPipeline; import com.jozufozu.flywheel.backend.pipeline.InstancingTemplate; import com.jozufozu.flywheel.backend.pipeline.OneShotTemplate; @@ -30,7 +30,7 @@ public class CreateContexts { public static void flwInit(GatherContextEvent event) { Backend backend = event.getBackend(); - SpecMetaRegistry.register(RainbowDebugStateProvider.INSTANCE); + GameStateRegistry.register(RainbowDebugStateProvider.INSTANCE); FileResolution header = Resolver.INSTANCE.findShader(ResourceUtil.subPath(CONTRAPTION, ".glsl")); IShaderPipeline instancing = new WorldShaderPipeline<>(ContraptionProgram::new, InstancingTemplate.INSTANCE, header);