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.
This commit is contained in:
Jozufozu 2024-01-08 16:36:41 -08:00
parent 458f63820b
commit 8d54e9268a
42 changed files with 227 additions and 501 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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<ActorInstance> {
@Override
public ActorInstance create(InstanceHandle instanceHandle) {
return new ActorInstance(this, instanceHandle);
}
@Override
public Layout layout() {
return null;
}
@Override
public InstanceWriter<ActorInstance> 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;
}
}

View file

@ -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<ActorInstance> {
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);
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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<? extends KineticInstance> type, InstanceHandle handle) {
super(type, handle);

View file

@ -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<? extends KineticInstance> type, InstanceHandle handle) {
public RotatingInstance(InstanceType<? extends KineticInstance> type, InstanceHandle handle) {
super(type, handle);
}

View file

@ -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;

View file

@ -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<BeltInstance> {
@Override
public BeltInstance create(InstanceHandle instanceHandle) {
return new BeltInstance(this, instanceHandle);
}
@Override
public Layout layout() {
return null;
}
@Override
public InstanceWriter<BeltInstance> 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;
}
}

View file

@ -1,23 +0,0 @@
package com.simibubi.create.content.kinetics.base.flwdata;
import org.lwjgl.system.MemoryUtil;
public class BeltWriter extends KineticWriter<BeltInstance> {
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);
}
}

View file

@ -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<D extends KineticInstance> extends ColoredLitWriter<D> {
@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);
}
}

View file

@ -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<RotatingInstance> {
@Override
public RotatingInstance create(InstanceHandle instanceHandle) {
return new RotatingInstance(this, instanceHandle);
}
@Override
public Layout layout() {
return null;
}
@Override
public InstanceWriter<RotatingInstance> 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;
}
}

View file

@ -1,15 +0,0 @@
package com.simibubi.create.content.kinetics.base.flwdata;
import org.lwjgl.system.MemoryUtil;
public class RotatingWriter extends KineticWriter<RotatingInstance> {
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);
}
}

View file

@ -1,6 +0,0 @@
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault
package com.simibubi.create.content.kinetics.base.flwdata;
import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -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();

View file

@ -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<? extends KineticInstance> type, InstanceHandle handle) {
public BeltInstance(InstanceType<? extends KineticInstance> type, InstanceHandle handle) {
super(type, handle);
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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<SplitShaftBlockEntity> {

View file

@ -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);
}

View file

@ -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<FlapData> {
@Override
public FlapData create(InstanceHandle instanceHandle) {
return new FlapData(this, instanceHandle);
}
@Override
public Layout layout() {
return null;
}
@Override
public InstanceWriter<FlapData> 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;
}
}
}

View file

@ -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<FlapData> {
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);
}
}

View file

@ -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);
}
}

View file

@ -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");
}

View file

@ -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<RotatingInstance> ROTATING = new RotatingType();
public static final InstanceType<BeltInstance> BELTS = new BeltType();
public static final InstanceType<ActorInstance> ACTORS = new ActorType();
public static final InstanceType<FlapData> FLAPS = new FlapType();
public static final InstanceType<RotatingInstance> 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<BeltInstance> 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<ActorInstance> 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<FlapData> 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
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -1,6 +1,6 @@
#define PI 3.1415926538
#use "flywheel:core/matutils.glsl"
#include "flywheel:core/matutils.glsl"
struct Rotating {
vec2 light;

View file

@ -1,4 +0,0 @@
{
"vertex": "create:belt.vert",
"fragment": "flywheel:block.frag"
}

View file

@ -1,4 +0,0 @@
{
"vertex": "create:contraption_actor.vert",
"fragment": "flywheel:block.frag"
}

View file

@ -1,4 +0,0 @@
{
"vertex": "create:flap.vert",
"fragment": "flywheel:block.frag"
}

View file

@ -1,4 +0,0 @@
{
"vertex": "create:rotating.vert",
"fragment": "flywheel:block.frag"
}