StructType doesn't need #asBatched and #asInstanced

- More organized this way
 - BatchingTransformer function moved into Batched
This commit is contained in:
Jozufozu 2021-12-20 22:38:34 -08:00
parent 94a160699c
commit 5f46560fb2
5 changed files with 46 additions and 59 deletions

View file

@ -1,11 +1,11 @@
package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.model.ModelTransformer;
import com.jozufozu.flywheel.util.RenderMath;
import com.mojang.math.Quaternion;
import com.simibubi.create.content.contraptions.KineticDebugger;
@ -13,7 +13,6 @@ import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.resources.ResourceLocation;
public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
@ -38,29 +37,26 @@ public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
}
@Override
public BatchingTransformer<BeltData> getTransformer() {
return (d, sbb) -> {
public void transform(BeltData d, ModelTransformer.Params b) {
float spriteHeight = d.maxV - d.minV;
double scroll = d.rotationalSpeed * AnimationTickHolder.getRenderTime() / (31.5 * 16) + d.rotationOffset;
scroll = scroll - Math.floor(scroll);
scroll = scroll * spriteHeight * RenderMath.f(d.scrollMult);
float spriteHeight = d.maxV - d.minV;
double scroll = d.rotationalSpeed * AnimationTickHolder.getRenderTime() / (31.5 * 16) + d.rotationOffset;
scroll = scroll - Math.floor(scroll);
scroll = scroll * spriteHeight * RenderMath.f(d.scrollMult);
float finalScroll = (float) scroll;
b.shiftUV((builder, u, v) -> {
float targetU = u - d.sourceU + d.minU;
float targetV = v - d.sourceV + d.minV
+ finalScroll;
builder.uv(targetU, targetV);
});
float finalScroll = (float) scroll;
sbb.shiftUV((builder, u, v) -> {
float targetU = u - d.sourceU + d.minU;
float targetV = v - d.sourceV + d.minV
+ finalScroll;
builder.uv(targetU, targetV);
});
sbb.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5)
.multiply(new Quaternion(d.qX, d.qY, d.qZ, d.qW))
.unCentre()
.light(d.getPackedLight());
if (KineticDebugger.isActive()) {
sbb.color(d.r, d.g, d.b, d.a);
}
};
b.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5)
.multiply(new Quaternion(d.qX, d.qY, d.qZ, d.qW))
.unCentre()
.light(d.getPackedLight());
if (KineticDebugger.isActive()) {
b.color(d.r, d.g, d.b, d.a);
}
}
}

View file

@ -1,11 +1,11 @@
package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.model.ModelTransformer;
import com.jozufozu.flywheel.util.RenderMath;
import com.mojang.math.Vector3f;
import com.simibubi.create.content.contraptions.KineticDebugger;
@ -13,7 +13,6 @@ import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.resources.ResourceLocation;
public class RotatingType implements Instanced<RotatingData>, Batched<RotatingData> {
@ -38,19 +37,17 @@ public class RotatingType implements Instanced<RotatingData>, Batched<RotatingDa
}
@Override
public BatchingTransformer<RotatingData> getTransformer() {
return (d, b) -> {
float angle = ((AnimationTickHolder.getRenderTime() * d.rotationalSpeed * 3f / 10 + d.rotationOffset) % 360);
public void transform(RotatingData d, ModelTransformer.Params b) {
float angle = ((AnimationTickHolder.getRenderTime() * d.rotationalSpeed * 3f / 10 + d.rotationOffset) % 360);
Vector3f axis = new Vector3f(RenderMath.f(d.rotationAxisX), RenderMath.f(d.rotationAxisY), RenderMath.f(d.rotationAxisZ));
b.light(d.getPackedLight())
.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5)
.multiply(axis.rotationDegrees(angle))
.unCentre();
Vector3f axis = new Vector3f(RenderMath.f(d.rotationAxisX), RenderMath.f(d.rotationAxisY), RenderMath.f(d.rotationAxisZ));
b.light(d.getPackedLight())
.translate(d.x + 0.5, d.y + 0.5, d.z + 0.5)
.multiply(axis.rotationDegrees(angle))
.unCentre();
if (KineticDebugger.isActive()) {
b.color(d.r, d.g, d.b, d.a);
}
};
if (KineticDebugger.isActive()) {
b.color(d.r, d.g, d.b, d.a);
}
}
}

View file

@ -1,11 +1,11 @@
package com.simibubi.create.content.contraptions.components.actors.flwdata;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.model.ModelTransformer;
import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
@ -33,9 +33,7 @@ public class ActorType implements Instanced<ActorData>, Batched<ActorData> {
}
@Override
public BatchingTransformer<ActorData> getTransformer() {
return (d, sbb) -> {
public void transform(ActorData d, ModelTransformer.Params b) {
};
}
}

View file

@ -1,16 +1,14 @@
package com.simibubi.create.content.logistics.block.flap;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.mojang.math.Vector3f;
import com.jozufozu.flywheel.core.model.ModelTransformer;
import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.resources.ResourceLocation;
public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
@ -35,18 +33,16 @@ public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
}
@Override
public BatchingTransformer<FlapData> getTransformer() {
return (d, sbb) -> {
sbb.translate(d.x, d.y, d.z)
.centre()
.rotateY(-d.horizontalAngle)
.unCentre()
.translate(d.pivotX, d.pivotY, d.pivotZ)
.rotateX(getFlapAngle(d.flapness, d.intensity, d.flapScale))
.translateBack(d.pivotX, d.pivotY, d.pivotZ)
.translate(d.segmentOffsetX, d.segmentOffsetY, d.segmentOffsetZ)
.light(d.getPackedLight());
};
public void transform(FlapData d, ModelTransformer.Params b) {
b.translate(d.x, d.y, d.z)
.centre()
.rotateY(-d.horizontalAngle)
.unCentre()
.translate(d.pivotX, d.pivotY, d.pivotZ)
.rotateX(getFlapAngle(d.flapness, d.intensity, d.flapScale))
.translateBack(d.pivotX, d.pivotY, d.pivotZ)
.translate(d.segmentOffsetX, d.segmentOffsetY, d.segmentOffsetZ)
.light(d.getPackedLight());
}
private static float getFlapAngle(float flapness, float intensity, float scale) {

View file

@ -283,9 +283,9 @@ public class ClientEvents {
Level level = Minecraft.getInstance().level;
BlockPos blockPos = info.getBlockPosition();
FluidState fluidstate = level.getFluidState(blockPos);
if (info.getPosition().y > blockPos.getY() + fluidstate.getHeight(level, blockPos))
if (info.getPosition().y > blockPos.getY() + fluidstate.getHeight(level, blockPos))
return;
Fluid fluid = fluidstate.getType();
if (fluid.isSame(AllFluids.CHOCOLATE.get())) {