From ffe670b39110712e186d6b78f76b13e32e9b74df Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 6 Dec 2021 01:47:53 -0800 Subject: [PATCH] Vanillaization - IModels now accept a VertexConsumer - IRenderState -> RenderType - AbstractInstancer for dealing with InstanceData tidyness - Bump flywheel version --- gradle.properties | 2 +- .../contraptions/base/flwdata/BeltType.java | 4 +-- .../base/flwdata/RotatingType.java | 4 +-- .../components/actors/flwdata/ActorType.java | 4 +-- .../structureMovement/glue/GlueInstance.java | 25 +++++++++---------- .../render/ContraptionGroup.java | 7 +++--- .../render/FlwContraptionManager.java | 4 ++- .../logistics/block/flap/FlapType.java | 4 +-- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9f7211edc..957927e15 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.20 +flywheel_version = 1.17-0.3.0.21 jei_version = 8.2.0.36 # curseforge information 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 index e0d9455af..f7ae4eabb 100644 --- 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 @@ -2,11 +2,11 @@ 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.jozufozu.flywheel.backend.struct.Writeable; import com.simibubi.create.foundation.render.AllInstanceFormats; -public class BeltType implements StructType { +public class BeltType implements Writeable { @Override public BeltData create() { return new BeltData(); 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 index 0f4bf4d48..e87343e37 100644 --- 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 @@ -2,11 +2,11 @@ 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.jozufozu.flywheel.backend.struct.Writeable; import com.simibubi.create.foundation.render.AllInstanceFormats; -public class RotatingType implements StructType { +public class RotatingType implements Writeable { @Override public RotatingData create() { return new RotatingData(); 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 index a39f78bf1..1f18bc8ab 100644 --- 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 @@ -2,11 +2,11 @@ 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.jozufozu.flywheel.backend.struct.Writeable; import com.simibubi.create.foundation.render.AllInstanceFormats; -public class ActorType implements StructType { +public class ActorType implements Writeable { @Override public ActorData create() { return new ActorData(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java index e56e7f577..dab4f81ee 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java @@ -1,18 +1,17 @@ package com.simibubi.create.content.contraptions.components.structureMovement.glue; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; -import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.instancing.ITickableInstance; import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; import com.jozufozu.flywheel.backend.material.MaterialGroup; import com.jozufozu.flywheel.backend.material.MaterialManager; -import com.jozufozu.flywheel.backend.state.TextureRenderState; import com.jozufozu.flywheel.core.Formats; import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.instancing.ConditionalInstance; import com.jozufozu.flywheel.core.materials.oriented.OrientedData; import com.jozufozu.flywheel.core.model.IModel; +import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Quaternion; import com.simibubi.create.AllItems; import com.simibubi.create.AllStitchedTextures; @@ -21,6 +20,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -52,7 +52,7 @@ public class GlueInstance extends EntityInstance implements ITi } private Instancer getInstancer(MaterialManager materialManager, SuperGlueEntity entity) { - MaterialGroup group = USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(TextureRenderState.get(TEXTURE)); + MaterialGroup group = USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(RenderType.entityCutout(TEXTURE)); return group.material(Materials.ORIENTED).model(entity.getType(), GlueModel::new); } @@ -103,7 +103,7 @@ public class GlueInstance extends EntityInstance implements ITi } @Override - public void buffer(VecBuffer buffer) { + public void buffer(VertexConsumer buffer) { Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal()); Vec3 extension = diff.normalize() .scale(1 / 32f - 1 / 128f); @@ -144,17 +144,16 @@ public class GlueInstance extends EntityInstance implements ITi maxU = maxV = 1; } - // pos normal uv // inside quad - buffer.putVec3((float) a1.x, (float) a1.y, (float) a1.z).putVec3((byte) 0, (byte) 0, (byte) -127).putVec2(maxU, minV); - buffer.putVec3((float) a2.x, (float) a2.y, (float) a2.z).putVec3((byte) 0, (byte) 0, (byte) -127).putVec2(maxU, maxV); - buffer.putVec3((float) a3.x, (float) a3.y, (float) a3.z).putVec3((byte) 0, (byte) 0, (byte) -127).putVec2(minU, maxV); - buffer.putVec3((float) a4.x, (float) a4.y, (float) a4.z).putVec3((byte) 0, (byte) 0, (byte) -127).putVec2(minU, minV); + buffer.vertex(a1.x, a1.y, a1.z).normal(0, 0, -1f).uv(maxU, minV).endVertex(); + buffer.vertex(a2.x, a2.y, a2.z).normal(0, 0, -1f).uv(maxU, maxV).endVertex(); + buffer.vertex(a3.x, a3.y, a3.z).normal(0, 0, -1f).uv(minU, maxV).endVertex(); + buffer.vertex(a4.x, a4.y, a4.z).normal(0, 0, -1f).uv(minU, minV).endVertex(); // outside quad - buffer.putVec3((float) b4.x, (float) b4.y, (float) b4.z).putVec3((byte) 0, (byte) 0, (byte) 127).putVec2(minU, minV); - buffer.putVec3((float) b3.x, (float) b3.y, (float) b3.z).putVec3((byte) 0, (byte) 0, (byte) 127).putVec2(minU, maxV); - buffer.putVec3((float) b2.x, (float) b2.y, (float) b2.z).putVec3((byte) 0, (byte) 0, (byte) 127).putVec2(maxU, maxV); - buffer.putVec3((float) b1.x, (float) b1.y, (float) b1.z).putVec3((byte) 0, (byte) 0, (byte) 127).putVec2(maxU, minV); + buffer.vertex(b4.x, b4.y, b4.z).normal(0, 0, 1f).uv(minU, minV).endVertex(); + buffer.vertex(b3.x, b3.y, b3.z).normal(0, 0, 1f).uv(minU, maxV).endVertex(); + buffer.vertex(b2.x, b2.y, b2.z).normal(0, 0, 1f).uv(maxU, maxV).endVertex(); + buffer.vertex(b1.x, b1.y, b1.z).normal(0, 0, 1f).uv(maxU, minV).endVertex(); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionGroup.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionGroup.java index f3ac4460a..eef3943fe 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionGroup.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionGroup.java @@ -2,14 +2,13 @@ package com.simibubi.create.content.contraptions.components.structureMovement.re import com.jozufozu.flywheel.backend.material.MaterialGroupImpl; import com.jozufozu.flywheel.backend.material.MaterialManagerImpl; -import com.jozufozu.flywheel.backend.state.IRenderState; public class ContraptionGroup

extends MaterialGroupImpl

{ private final RenderedContraption contraption; - public ContraptionGroup(RenderedContraption contraption, MaterialManagerImpl

owner, IRenderState state) { - super(owner, state); + public ContraptionGroup(RenderedContraption contraption, MaterialManagerImpl

owner) { + super(owner); this.contraption = contraption; } @@ -20,6 +19,6 @@ public class ContraptionGroup

extends MaterialGrou } public static

MaterialManagerImpl.GroupFactory

forContraption(RenderedContraption c) { - return (materialManager, state) -> new ContraptionGroup<>(c, materialManager, state); + return (materialManager) -> new ContraptionGroup<>(c, materialManager); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java index af83a58e6..680da8945 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java @@ -37,6 +37,8 @@ public class FlwContraptionManager extends ContraptionRenderManager { +public class FlapType implements Writeable { @Override public FlapData create() { return new FlapData();