No more material spec, everything is StructType

This commit is contained in:
Jozufozu 2021-12-09 16:34:33 -08:00
parent ef5afd42c3
commit 2efbcdbd6b
16 changed files with 96 additions and 64 deletions

View file

@ -19,7 +19,7 @@ parchment_version = 2021.10.31
# dependency versions # dependency versions
registrate_version = MC1.18-1.0.21 registrate_version = MC1.18-1.0.21
flywheel_version = 1.18-0.4.0.9 flywheel_version = 1.18-0.4.0.11
jei_version = 9.0.0.40 jei_version = 9.0.0.40
# curseforge information # curseforge information

View file

@ -2,14 +2,17 @@ package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.Batched; import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.backend.struct.BatchingTransformer; import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.backend.struct.StructWriter; import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.struct.Writeable; import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.core.model.Model; import com.jozufozu.flywheel.core.model.Model;
import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
public class BeltType implements Writeable<BeltData>, Batched<BeltData> { import net.minecraft.resources.ResourceLocation;
public class BeltType implements Instanced<BeltData>, Batched<BeltData> {
@Override @Override
public BeltData create() { public BeltData create() {
return new BeltData(); return new BeltData();
@ -25,6 +28,11 @@ public class BeltType implements Writeable<BeltData>, Batched<BeltData> {
return new UnsafeBeltWriter(backing, this); return new UnsafeBeltWriter(backing, this);
} }
@Override
public ResourceLocation getProgramSpec() {
return AllProgramSpecs.BELT;
}
@Override @Override
public BatchingTransformer<BeltData> getTransformer(Model model) { public BatchingTransformer<BeltData> getTransformer(Model model) {
return null; return null;

View file

@ -2,14 +2,17 @@ package com.simibubi.create.content.contraptions.base.flwdata;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.Batched; import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.backend.struct.BatchingTransformer; import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.backend.struct.StructWriter; import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.struct.Writeable; import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.core.model.Model; import com.jozufozu.flywheel.core.model.Model;
import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
public class RotatingType implements Writeable<RotatingData>, Batched<RotatingData> { import net.minecraft.resources.ResourceLocation;
public class RotatingType implements Instanced<RotatingData>, Batched<RotatingData> {
@Override @Override
public RotatingData create() { public RotatingData create() {
return new RotatingData(); return new RotatingData();
@ -25,6 +28,11 @@ public class RotatingType implements Writeable<RotatingData>, Batched<RotatingDa
return new UnsafeRotatingWriter(backing, this); return new UnsafeRotatingWriter(backing, this);
} }
@Override
public ResourceLocation getProgramSpec() {
return AllProgramSpecs.ROTATING;
}
@Override @Override
public BatchingTransformer<RotatingData> getTransformer(Model model) { public BatchingTransformer<RotatingData> getTransformer(Model model) {
return null; return null;

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.base.flwdata;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType; import com.jozufozu.flywheel.api.struct.StructType;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
public class UnsafeBeltWriter extends UnsafeBufferWriter<BeltData> { public class UnsafeBeltWriter extends UnsafeBufferWriter<BeltData> {

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.base.flwdata;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType; import com.jozufozu.flywheel.api.struct.StructType;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
public class UnsafeRotatingWriter extends UnsafeBufferWriter<RotatingData> { public class UnsafeRotatingWriter extends UnsafeBufferWriter<RotatingData> {

View file

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

View file

@ -2,14 +2,17 @@ package com.simibubi.create.content.contraptions.components.actors.flwdata;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.Batched; import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.backend.struct.BatchingTransformer; import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.backend.struct.StructWriter; import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.struct.Writeable; import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.core.model.Model; import com.jozufozu.flywheel.core.model.Model;
import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
public class ActorType implements Writeable<ActorData>, Batched<ActorData> { import net.minecraft.resources.ResourceLocation;
public class ActorType implements Instanced<ActorData>, Batched<ActorData> {
@Override @Override
public ActorData create() { public ActorData create() {
return new ActorData(); return new ActorData();
@ -25,6 +28,11 @@ public class ActorType implements Writeable<ActorData>, Batched<ActorData> {
return new UnsafeActorWriter(backing, this); return new UnsafeActorWriter(backing, this);
} }
@Override
public ResourceLocation getProgramSpec() {
return AllProgramSpecs.ACTOR;
}
@Override @Override
public BatchingTransformer<ActorData> getTransformer(Model model) { public BatchingTransformer<ActorData> getTransformer(Model model) {
return null; return null;

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.actors.flwdata;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType; import com.jozufozu.flywheel.api.struct.StructType;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
public class UnsafeActorWriter extends UnsafeBufferWriter<ActorData> { public class UnsafeActorWriter extends UnsafeBufferWriter<ActorData> {

View file

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

View file

@ -141,14 +141,9 @@ public class SuperGlueEntity extends Entity
double depth = 2 - 1 / 128f; double depth = 2 - 1 / 128f;
switch (axis) { switch (axis) {
case X: case X -> w = depth;
w = depth; case Y -> h = depth;
break; case Z -> l = depth;
case Y:
h = depth;
break;
case Z:
l = depth;
} }
w = w / 32.0D; w = w / 32.0D;
@ -423,16 +418,12 @@ public class SuperGlueEntity extends Entity
} }
float f = Mth.wrapDegrees(this.getYRot()); float f = Mth.wrapDegrees(this.getYRot());
switch (transformRotation) { return switch (transformRotation) {
case CLOCKWISE_180: case CLOCKWISE_180 -> f + 180.0F;
return f + 180.0F; case COUNTERCLOCKWISE_90 -> f + 90.0F;
case COUNTERCLOCKWISE_90: case CLOCKWISE_90 -> f + 270.0F;
return f + 90.0F; default -> f;
case CLOCKWISE_90: };
return f + 270.0F;
default:
return f;
}
} }
public BlockPos getHangingPosition() { public BlockPos getHangingPosition() {
@ -490,9 +481,4 @@ public class SuperGlueEntity extends Entity
public boolean isIgnoringBlockTriggers() { public boolean isIgnoringBlockTriggers() {
return true; return true;
} }
@Override
public Level getWorld() {
return level;
}
} }

View file

@ -98,7 +98,7 @@ public class ToolboxInventory extends ItemStackHandler {
if (blockItem.getBlock() instanceof ShulkerBoxBlock) if (blockItem.getBlock() instanceof ShulkerBoxBlock)
return false; return false;
} }
if (slot < 0 || slot >= getSlots()) if (slot < 0 || slot >= getSlots())
return false; return false;
int compartment = slot / STACKS_PER_COMPARTMENT; int compartment = slot / STACKS_PER_COMPARTMENT;
@ -144,7 +144,7 @@ public class ToolboxInventory extends ItemStackHandler {
@Override @Override
protected void onContentsChanged(int slot) { protected void onContentsChanged(int slot) {
if (!settling && !te.getWorld().isClientSide) if (!settling && !te.getLevel().isClientSide)
settle(slot / STACKS_PER_COMPARTMENT); settle(slot / STACKS_PER_COMPARTMENT);
te.sendData(); te.sendData();
super.onContentsChanged(slot); super.onContentsChanged(slot);

View file

@ -2,14 +2,17 @@ package com.simibubi.create.content.logistics.block.flap;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.Batched; import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.backend.struct.BatchingTransformer; import com.jozufozu.flywheel.api.struct.BatchingTransformer;
import com.jozufozu.flywheel.backend.struct.StructWriter; import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.backend.struct.Writeable; import com.jozufozu.flywheel.api.struct.Instanced;
import com.jozufozu.flywheel.core.model.Model; import com.jozufozu.flywheel.core.model.Model;
import com.simibubi.create.foundation.render.AllInstanceFormats; import com.simibubi.create.foundation.render.AllInstanceFormats;
import com.simibubi.create.foundation.render.AllProgramSpecs;
public class FlapType implements Writeable<FlapData>, Batched<FlapData> { import net.minecraft.resources.ResourceLocation;
public class FlapType implements Instanced<FlapData>, Batched<FlapData> {
@Override @Override
public FlapData create() { public FlapData create() {
return new FlapData(); return new FlapData();
@ -25,6 +28,11 @@ public class FlapType implements Writeable<FlapData>, Batched<FlapData> {
return new UnsafeFlapWriter(backing, this); return new UnsafeFlapWriter(backing, this);
} }
@Override
public ResourceLocation getProgramSpec() {
return AllProgramSpecs.FLAPS;
}
@Override @Override
public BatchingTransformer<FlapData> getTransformer(Model model) { public BatchingTransformer<FlapData> getTransformer(Model model) {
return null; return null;

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.logistics.block.flap;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.StructType; import com.jozufozu.flywheel.api.struct.StructType;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter; import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
public class UnsafeFlapWriter extends UnsafeBufferWriter<FlapData> { public class UnsafeFlapWriter extends UnsafeBufferWriter<FlapData> {

View file

@ -0,0 +1,6 @@
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault
package com.simibubi.create.content.logistics.block.flap;
import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -1,6 +1,6 @@
package com.simibubi.create.foundation.render; package com.simibubi.create.foundation.render;
import com.jozufozu.flywheel.api.MaterialSpec; import com.jozufozu.flywheel.api.struct.StructType;
import com.jozufozu.flywheel.event.GatherContextEvent; import com.jozufozu.flywheel.event.GatherContextEvent;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.base.flwdata.BeltData; import com.simibubi.create.content.contraptions.base.flwdata.BeltData;
@ -22,16 +22,16 @@ public class AllMaterialSpecs {
// noop, make sure the static field are loaded. // noop, make sure the static field are loaded.
} }
public static final MaterialSpec<RotatingData> ROTATING = new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, new RotatingType()); public static final StructType<RotatingData> ROTATING = new RotatingType();
public static final MaterialSpec<BeltData> BELTS = new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, new BeltType()); public static final StructType<BeltData> BELTS = new BeltType();
public static final MaterialSpec<ActorData> ACTORS = new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, new ActorType()); public static final StructType<ActorData> ACTORS = new ActorType();
public static final MaterialSpec<FlapData> FLAPS = new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, new FlapType()); public static final StructType<FlapData> FLAPS = new FlapType();
public static void flwInit(GatherContextEvent event) { public static void flwInit(GatherContextEvent event) {
event.getBackend().register(ROTATING); event.getBackend().register(Locations.ROTATING, ROTATING);
event.getBackend().register(BELTS); event.getBackend().register(Locations.BELTS, BELTS);
event.getBackend().register(ACTORS); event.getBackend().register(Locations.ACTORS, ACTORS);
event.getBackend().register(FLAPS); event.getBackend().register(Locations.FLAPS, FLAPS);
} }
public static class Locations { public static class Locations {

View file

@ -85,7 +85,7 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements IParti
behaviourList.forEach(TileEntityBehaviour::initialize); behaviourList.forEach(TileEntityBehaviour::initialize);
lazyTick(); lazyTick();
} }
@Override @Override
public final void saveAdditional(CompoundTag compound) { public final void saveAdditional(CompoundTag compound) {
write(compound, false); write(compound, false);
@ -226,8 +226,4 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements IParti
public void refreshBlockState() { public void refreshBlockState() {
setBlockState(getLevel().getBlockState(getBlockPos())); setBlockState(getLevel().getBlockState(getBlockPos()));
} }
public Level getWorld() {
return getLevel();
}
} }