Material refactor pt 1

- PartialModels don't actually need reference states, use air instead
 - Bump flywheel build
This commit is contained in:
Jozufozu 2022-04-10 17:37:13 -07:00
parent c48c28cd2f
commit 343c0fab62
46 changed files with 106 additions and 106 deletions

View file

@ -19,7 +19,7 @@ parchment_version = 2022.03.13
# dependency versions # dependency versions
registrate_version = MC1.18.2-1.0.25 registrate_version = MC1.18.2-1.0.25
flywheel_version = 1.18-0.6.2.64 flywheel_version = 1.18-0.7.0.67
jei_minecraft_version = 1.18.2 jei_minecraft_version = 1.18.2
jei_version = 9.5.3.143 jei_version = 9.5.3.143

View file

@ -16,7 +16,7 @@ public class HalfShaftInstance extends SingleRotatingInstance {
@Override @Override
protected Instancer<RotatingData> getModel() { protected Instancer<RotatingData> getModel() {
Direction dir = getShaftDirection(); Direction dir = getShaftDirection();
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, dir); return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, dir);
} }
protected Direction getShaftDirection() { protected Direction getShaftDirection() {

View file

@ -39,9 +39,9 @@ public class DrillActorInstance extends ActorInstance {
else else
eulerY = facing.toYRot() + ((axis == Direction.Axis.X) ? 180 : 0); eulerY = facing.toYRot() + ((axis == Direction.Axis.X) ? 180 : 0);
drillHead = material.getModel(AllBlockPartials.DRILL_HEAD, state).createInstance(); drillHead = material.getModel(AllBlockPartials.DRILL_HEAD)
.createInstance()
drillHead.setPosition(context.localPos) .setPosition(context.localPos)
.setBlockLight(localBlockLight()) .setBlockLight(localBlockLight())
.setRotationOffset(0) .setRotationOffset(0)
.setRotationAxis(0, 0, 1) .setRotationAxis(0, 0, 1)

View file

@ -21,6 +21,6 @@ public class DrillInstance extends SingleRotatingInstance {
protected Instancer<RotatingData> getModel() { protected Instancer<RotatingData> getModel() {
BlockState referenceState = blockEntity.getBlockState(); BlockState referenceState = blockEntity.getBlockState();
Direction facing = referenceState.getValue(BlockStateProperties.FACING); Direction facing = referenceState.getValue(BlockStateProperties.FACING);
return getRotatingMaterial().getModel(AllBlockPartials.DRILL_HEAD, referenceState, facing); return getRotatingMaterial().getModel(AllBlockPartials.DRILL_HEAD, facing);
} }
} }

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.actors;
import com.jozufozu.flywheel.api.Material; import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager; import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.Models;
import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
@ -41,7 +42,8 @@ public class HarvesterActorInstance extends ActorInstance {
facing = state.getValue(BlockStateProperties.HORIZONTAL_FACING); facing = state.getValue(BlockStateProperties.HORIZONTAL_FACING);
harvester = material.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance(); harvester = material.model(Models.partial(AllBlockPartials.HARVESTER_BLADE))
.createInstance();
horizontalAngle = facing.toYRot() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0); horizontalAngle = facing.toYRot() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0);

View file

@ -33,11 +33,11 @@ public class PIInstance {
this.lit = lit; this.lit = lit;
middle = materialManager.defaultSolid() middle = materialManager.defaultSolid()
.material(Materials.TRANSFORMED) .material(Materials.TRANSFORMED)
.getModel(PortableStorageInterfaceRenderer.getMiddleForState(blockState, lit), blockState) .getModel(PortableStorageInterfaceRenderer.getMiddleForState(blockState, lit))
.createInstance(); .createInstance();
top = materialManager.defaultSolid() top = materialManager.defaultSolid()
.material(Materials.TRANSFORMED) .material(Materials.TRANSFORMED)
.getModel(PortableStorageInterfaceRenderer.getTopForState(blockState), blockState) .getModel(PortableStorageInterfaceRenderer.getTopForState(blockState))
.createInstance(); .createInstance();
} }
@ -66,7 +66,7 @@ public class PIInstance {
this.lit = lit; this.lit = lit;
materialManager.defaultSolid() materialManager.defaultSolid()
.material(Materials.TRANSFORMED) .material(Materials.TRANSFORMED)
.getModel(PortableStorageInterfaceRenderer.getMiddleForState(blockState, lit), blockState) .getModel(PortableStorageInterfaceRenderer.getMiddleForState(blockState, lit))
.stealInstance(middle); .stealInstance(middle);
} }
} }

View file

@ -23,7 +23,7 @@ public class MechanicalCrafterInstance extends SingleRotatingInstance {
protected Instancer<RotatingData> getModel() { protected Instancer<RotatingData> getModel() {
Direction facing = blockState.getValue(MechanicalCrafterBlock.HORIZONTAL_FACING); Direction facing = blockState.getValue(MechanicalCrafterBlock.HORIZONTAL_FACING);
return getRotatingMaterial().getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState, facing, rotateToFace(facing)); return getRotatingMaterial().getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, facing, rotateToFace(facing));
} }
private Supplier<PoseStack> rotateToFace(Direction facing) { private Supplier<PoseStack> rotateToFace(Direction facing) {

View file

@ -31,7 +31,7 @@ public class HandCrankInstance extends SingleRotatingInstance implements Dynamic
facing = blockState.getValue(BlockStateProperties.FACING); facing = blockState.getValue(BlockStateProperties.FACING);
Direction opposite = facing.getOpposite(); Direction opposite = facing.getOpposite();
Instancer<ModelData> model = getTransformMaterial().getModel(renderedHandle, blockState, opposite); Instancer<ModelData> model = getTransformMaterial().getModel(renderedHandle, opposite);
crank = model.createInstance(); crank = model.createInstance();
rotateCrank(); rotateCrank();

View file

@ -61,8 +61,8 @@ public class DeployerActorInstance extends ActorInstance {
xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0;
zRot = rotatePole ? 90 : 0; zRot = rotatePole ? 90 : 0;
pole = mat.getModel(AllBlockPartials.DEPLOYER_POLE, state).createInstance(); pole = mat.getModel(AllBlockPartials.DEPLOYER_POLE).createInstance();
hand = mat.getModel(handPose, state).createInstance(); hand = mat.getModel(handPose).createInstance();
Direction.Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state); Direction.Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state);
shaft = materialManager.defaultSolid() shaft = materialManager.defaultSolid()

View file

@ -47,11 +47,11 @@ public class DeployerInstance extends ShaftInstance implements DynamicInstance,
xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0;
zRot = rotatePole ? 90 : 0; zRot = rotatePole ? 90 : 0;
pole = getOrientedMaterial().getModel(AllBlockPartials.DEPLOYER_POLE, blockState).createInstance(); pole = getOrientedMaterial().getModel(AllBlockPartials.DEPLOYER_POLE).createInstance();
currentHand = this.tile.getHandPose(); currentHand = this.tile.getHandPose();
hand = getOrientedMaterial().getModel(currentHand, blockState).createInstance(); hand = getOrientedMaterial().getModel(currentHand).createInstance();
progress = getProgress(AnimationTickHolder.getPartialTicks()); progress = getProgress(AnimationTickHolder.getPartialTicks());
updateRotation(pole, hand, yRot, xRot, zRot); updateRotation(pole, hand, yRot, xRot, zRot);
@ -64,7 +64,7 @@ public class DeployerInstance extends ShaftInstance implements DynamicInstance,
if (currentHand != handPose) { if (currentHand != handPose) {
currentHand = handPose; currentHand = handPose;
getOrientedMaterial().getModel(currentHand, blockState) getOrientedMaterial().getModel(currentHand)
.stealInstance(hand); .stealInstance(hand);
} }
} }

View file

@ -25,10 +25,10 @@ public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
direction = blockState.getValue(FACING); direction = blockState.getValue(FACING);
opposite = direction.getOpposite(); opposite = direction.getOpposite();
shaft = getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite).createInstance(); shaft = getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, opposite).createInstance();
fan = modelManager.defaultCutout() fan = modelManager.defaultCutout()
.material(AllMaterialSpecs.ROTATING) .material(AllMaterialSpecs.ROTATING)
.getModel(AllBlockPartials.ENCASED_FAN_INNER, blockState, opposite) .getModel(AllBlockPartials.ENCASED_FAN_INNER, opposite)
.createInstance(); .createInstance();
setup(shaft); setup(shaft);

View file

@ -54,7 +54,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90); BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
wheel = getTransformMaterial() wheel = getTransformMaterial()
.getModel(AllBlockPartials.FLYWHEEL, referenceState, referenceState.getValue(HORIZONTAL_FACING)) .getModel(AllBlockPartials.FLYWHEEL, referenceState.getValue(HORIZONTAL_FACING))
.createInstance(); .createInstance();
connection = FlywheelBlock.getConnection(blockState); connection = FlywheelBlock.getConnection(blockState);
@ -68,13 +68,13 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
Material<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState) upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING)
.createInstance(); .createInstance();
lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState) lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING)
.createInstance(); .createInstance();
upperSliding = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_SLIDING, blockState) upperSliding = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_SLIDING)
.createInstance(); .createInstance();
lowerSliding = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_SLIDING, blockState) lowerSliding = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_SLIDING)
.createInstance(); .createInstance();
connectors = Lists.newArrayList(upperRotating, lowerRotating, upperSliding, lowerSliding); connectors = Lists.newArrayList(upperRotating, lowerRotating, upperSliding, lowerSliding);
@ -168,7 +168,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
protected Instancer<RotatingData> shaftModel() { protected Instancer<RotatingData> shaftModel() {
Direction opposite = facing.getOpposite(); Direction opposite = facing.getOpposite();
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite); return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, opposite);
} }
protected void transformConnector(TransformStack ms, boolean upper, boolean rotating, float angle, protected void transformConnector(TransformStack ms, boolean upper, boolean rotating, float angle,

View file

@ -84,7 +84,6 @@ public abstract class EngineBlock extends HorizontalDirectionalBlock implements
return pos.relative(state.getValue(FACING).getOpposite()); return pos.relative(state.getValue(FACING).getOpposite());
} }
@Nullable
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public abstract PartialModel getFrameModel(); public abstract PartialModel getFrameModel();

View file

@ -2,8 +2,10 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine;
import com.jozufozu.flywheel.api.MaterialManager; import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance; import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.core.model.ModelUtil;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -26,7 +28,7 @@ public class EngineInstance extends BlockEntityInstance<EngineTileEntity> {
Direction facing = blockState.getValue(BlockStateProperties.HORIZONTAL_FACING); Direction facing = blockState.getValue(BlockStateProperties.HORIZONTAL_FACING);
this.frame = getTransformMaterial().getModel(frame, blockState).createInstance(); this.frame = getTransformMaterial().getModel(frame).createInstance();
float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing)); float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing));

View file

@ -15,6 +15,6 @@ public class MillStoneCogInstance extends SingleRotatingInstance {
@Override @Override
protected Instancer<RotatingData> getModel() { protected Instancer<RotatingData> getModel() {
return getRotatingMaterial().getModel(AllBlockPartials.MILLSTONE_COG, blockEntity.getBlockState()); return getRotatingMaterial().getModel(AllBlockPartials.MILLSTONE_COG);
} }
} }

View file

@ -22,13 +22,13 @@ public class MixerInstance extends EncasedCogInstance implements DynamicInstance
super(dispatcher, tile, false); super(dispatcher, tile, false);
this.mixer = tile; this.mixer = tile;
mixerHead = getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState) mixerHead = getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_MIXER_HEAD)
.createInstance(); .createInstance();
mixerHead.setRotationAxis(Direction.Axis.Y); mixerHead.setRotationAxis(Direction.Axis.Y);
mixerPole = getOrientedMaterial() mixerPole = getOrientedMaterial()
.getModel(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState) .getModel(AllBlockPartials.MECHANICAL_MIXER_POLE)
.createInstance(); .createInstance();
@ -42,7 +42,7 @@ public class MixerInstance extends EncasedCogInstance implements DynamicInstance
protected Instancer<RotatingData> getCogModel() { protected Instancer<RotatingData> getCogModel() {
return materialManager.defaultSolid() return materialManager.defaultSolid()
.material(AllMaterialSpecs.ROTATING) .material(AllMaterialSpecs.ROTATING)
.getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, blockEntity.getBlockState()); .getModel(AllBlockPartials.SHAFTLESS_COGWHEEL);
} }
@Override @Override

View file

@ -22,7 +22,7 @@ public class PressInstance extends ShaftInstance implements DynamicInstance {
pressHead = dispatcher.defaultSolid() pressHead = dispatcher.defaultSolid()
.material(Materials.ORIENTED) .material(Materials.ORIENTED)
.getModel(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState) .getModel(AllBlockPartials.MECHANICAL_PRESS_HEAD)
.createInstance(); .createInstance();
Quaternion q = Vector3f.YP.rotationDegrees(AngleHelper.horizontalAngle(blockState.getValue(MechanicalPressBlock.HORIZONTAL_FACING))); Quaternion q = Vector3f.YP.rotationDegrees(AngleHelper.horizontalAngle(blockState.getValue(MechanicalPressBlock.HORIZONTAL_FACING)));

View file

@ -25,7 +25,7 @@ public class SawInstance extends SingleRotatingInstance {
.isHorizontal()) { .isHorizontal()) {
BlockState referenceState = blockState.rotate(blockEntity.getLevel(), blockEntity.getBlockPos(), Rotation.CLOCKWISE_180); BlockState referenceState = blockState.rotate(blockEntity.getLevel(), blockEntity.getBlockPos(), Rotation.CLOCKWISE_180);
Direction facing = referenceState.getValue(BlockStateProperties.FACING); Direction facing = referenceState.getValue(BlockStateProperties.FACING);
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, referenceState, facing); return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, facing);
} else { } else {
return getRotatingMaterial().getModel(shaft()); return getRotatingMaterial().getModel(shaft());
} }

View file

@ -35,7 +35,7 @@ public class BearingInstance<B extends KineticTileEntity & IBearingTileEntity> e
PartialModel top = PartialModel top =
bearing.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP; bearing.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
topInstance = getOrientedMaterial().getModel(top, blockState).createInstance(); topInstance = getOrientedMaterial().getModel(top).createInstance();
topInstance.setPosition(getInstancePosition()).setRotation(blockOrientation); topInstance.setPosition(getInstancePosition()).setRotation(blockOrientation);
} }

View file

@ -38,7 +38,7 @@ public class StabilizedBearingInstance extends ActorInstance {
topInstance = materialManager.defaultSolid() topInstance = materialManager.defaultSolid()
.material(Materials.ORIENTED) .material(Materials.ORIENTED)
.getModel(AllBlockPartials.BEARING_TOP, blockState) .getModel(AllBlockPartials.BEARING_TOP)
.createInstance(); .createInstance();
int blockLight = localBlockLight(); int blockLight = localBlockLight();
@ -48,7 +48,7 @@ public class StabilizedBearingInstance extends ActorInstance {
shaft = materialManager.defaultSolid() shaft = materialManager.defaultSolid()
.material(AllMaterialSpecs.ROTATING) .material(AllMaterialSpecs.ROTATING)
.getModel(AllBlockPartials.SHAFT_HALF, blockState, blockState.getValue(BlockStateProperties.FACING).getOpposite()) .getModel(AllBlockPartials.SHAFT_HALF, blockState.getValue(BlockStateProperties.FACING).getOpposite())
.createInstance(); .createInstance();
// not rotating so no need to set speed, axis, etc. // not rotating so no need to set speed, axis, etc.

View file

@ -17,20 +17,20 @@ public class StickerInstance extends BlockEntityInstance<StickerTileEntity> impl
float lastOffset = Float.NaN; float lastOffset = Float.NaN;
final Direction facing; final Direction facing;
final boolean fakeWorld; final boolean fakeWorld;
final int offset; final int extended;
private final ModelData head; private final ModelData head;
public StickerInstance(MaterialManager modelManager, StickerTileEntity tile) { public StickerInstance(MaterialManager modelManager, StickerTileEntity tile) {
super(modelManager, tile); super(modelManager, tile);
head = getTransformMaterial().getModel(AllBlockPartials.STICKER_HEAD, blockState).createInstance(); head = getTransformMaterial().getModel(AllBlockPartials.STICKER_HEAD).createInstance();
fakeWorld = tile.getLevel() != Minecraft.getInstance().level; fakeWorld = tile.getLevel() != Minecraft.getInstance().level;
facing = blockState.getValue(StickerBlock.FACING); facing = blockState.getValue(StickerBlock.FACING);
offset = blockState.getValue(StickerBlock.EXTENDED) ? 1 : 0; extended = blockState.getValue(StickerBlock.EXTENDED) ? 1 : 0;
animateHead(offset); animateHead(extended);
} }
@Override @Override
@ -38,7 +38,7 @@ public class StickerInstance extends BlockEntityInstance<StickerTileEntity> impl
float offset = blockEntity.piston.getValue(AnimationTickHolder.getPartialTicks()); float offset = blockEntity.piston.getValue(AnimationTickHolder.getPartialTicks());
if (fakeWorld) if (fakeWorld)
offset = this.offset; offset = this.extended;
if (Mth.equal(offset, lastOffset)) if (Mth.equal(offset, lastOffset))
return; return;

View file

@ -30,7 +30,7 @@ public class GantryCarriageInstance extends ShaftInstance implements DynamicInst
super(dispatcher, tile); super(dispatcher, tile);
gantryCogs = getTransformMaterial() gantryCogs = getTransformMaterial()
.getModel(AllBlockPartials.GANTRY_COGS, blockState) .getModel(AllBlockPartials.GANTRY_COGS)
.createInstance(); .createInstance();
facing = blockState.getValue(GantryCarriageBlock.FACING); facing = blockState.getValue(GantryCarriageBlock.FACING);

View file

@ -31,7 +31,7 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements Tic
public GlueInstance(MaterialManager materialManager, SuperGlueEntity entity) { public GlueInstance(MaterialManager materialManager, SuperGlueEntity entity) {
super(materialManager, entity); super(materialManager, entity);
Instancer<OrientedData> instancer = getInstancer(materialManager, entity); Instancer<OrientedData> instancer = getInstancer(materialManager);
Direction face = entity.getFacingDirection(); Direction face = entity.getFacingDirection();
rotation = new Quaternion(AngleHelper.verticalAngle(face), AngleHelper.horizontalAngle(face), 0, true); rotation = new Quaternion(AngleHelper.verticalAngle(face), AngleHelper.horizontalAngle(face), 0, true);
@ -42,10 +42,10 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements Tic
.update(); .update();
} }
private Instancer<OrientedData> getInstancer(MaterialManager materialManager, SuperGlueEntity entity) { private Instancer<OrientedData> getInstancer(MaterialManager materialManager) {
MaterialGroup group = GlueModel.USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(RenderType.entityCutout(TEXTURE)); MaterialGroup group = GlueModel.USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(RenderType.entityCutout(TEXTURE));
return group.material(Materials.ORIENTED).model(entity.getType(), GlueModel::get); return group.material(Materials.ORIENTED).model(GlueModel.INSTANCE);
} }
@Override @Override

View file

@ -1,7 +1,9 @@
package com.simibubi.create.content.contraptions.components.structureMovement.glue; package com.simibubi.create.content.contraptions.components.structureMovement.glue;
import com.jozufozu.flywheel.api.ModelSupplier;
import com.jozufozu.flywheel.api.vertex.VertexList; import com.jozufozu.flywheel.api.vertex.VertexList;
import com.jozufozu.flywheel.core.Formats; import com.jozufozu.flywheel.core.Formats;
import com.jozufozu.flywheel.core.SimpleModelSupplier;
import com.jozufozu.flywheel.core.model.Model; import com.jozufozu.flywheel.core.model.Model;
import com.jozufozu.flywheel.core.vertex.PosTexNormalWriterUnsafe; import com.jozufozu.flywheel.core.vertex.PosTexNormalWriterUnsafe;
import com.mojang.blaze3d.platform.MemoryTracker; import com.mojang.blaze3d.platform.MemoryTracker;
@ -14,16 +16,12 @@ import net.minecraft.world.phys.Vec3;
public class GlueModel implements Model { public class GlueModel implements Model {
public static final GlueModel INSTANCE = new GlueModel(); public static final ModelSupplier INSTANCE = new SimpleModelSupplier(GlueModel::new);
static final boolean USE_ATLAS = false; static final boolean USE_ATLAS = false;
public static GlueModel get() {
return INSTANCE;
}
private final VertexList reader; private final VertexList reader;
private GlueModel() { protected GlueModel() {
PosTexNormalWriterUnsafe writer = Formats.POS_TEX_NORMAL.createWriter(MemoryTracker.create(size())); PosTexNormalWriterUnsafe writer = Formats.POS_TEX_NORMAL.createWriter(MemoryTracker.create(size()));
createGlueModel(writer); createGlueModel(writer);
reader = writer.intoReader(); reader = writer.intoReader();

View file

@ -15,27 +15,27 @@ public class HosePulleyInstance extends AbstractPulleyInstance {
} }
protected Instancer<OrientedData> getRopeModel() { protected Instancer<OrientedData> getRopeModel() {
return getOrientedMaterial().getModel(AllBlockPartials.HOSE, blockState); return getOrientedMaterial().getModel(AllBlockPartials.HOSE);
} }
protected Instancer<OrientedData> getMagnetModel() { protected Instancer<OrientedData> getMagnetModel() {
return materialManager.defaultCutout() return materialManager.defaultCutout()
.material(Materials.ORIENTED) .material(Materials.ORIENTED)
.getModel(AllBlockPartials.HOSE_MAGNET, blockState); .getModel(AllBlockPartials.HOSE_MAGNET);
} }
protected Instancer<OrientedData> getHalfMagnetModel() { protected Instancer<OrientedData> getHalfMagnetModel() {
return materialManager.defaultCutout() return materialManager.defaultCutout()
.material(Materials.ORIENTED) .material(Materials.ORIENTED)
.getModel(AllBlockPartials.HOSE_HALF_MAGNET, blockState); .getModel(AllBlockPartials.HOSE_HALF_MAGNET);
} }
protected Instancer<OrientedData> getCoilModel() { protected Instancer<OrientedData> getCoilModel() {
return getOrientedMaterial().getModel(AllBlockPartials.HOSE_COIL, blockState, rotatingAbout); return getOrientedMaterial().getModel(AllBlockPartials.HOSE_COIL, rotatingAbout);
} }
protected Instancer<OrientedData> getHalfRopeModel() { protected Instancer<OrientedData> getHalfRopeModel() {
return getOrientedMaterial().getModel(AllBlockPartials.HOSE_HALF, blockState); return getOrientedMaterial().getModel(AllBlockPartials.HOSE_HALF);
} }
protected float getOffset() { protected float getOffset() {

View file

@ -22,15 +22,15 @@ public class RopePulleyInstance extends AbstractPulleyInstance {
} }
protected Instancer<OrientedData> getHalfMagnetModel() { protected Instancer<OrientedData> getHalfMagnetModel() {
return getOrientedMaterial().getModel(AllBlockPartials.ROPE_HALF_MAGNET, blockState); return getOrientedMaterial().getModel(AllBlockPartials.ROPE_HALF_MAGNET);
} }
protected Instancer<OrientedData> getCoilModel() { protected Instancer<OrientedData> getCoilModel() {
return getOrientedMaterial().getModel(AllBlockPartials.ROPE_COIL, blockState, rotatingAbout); return getOrientedMaterial().getModel(AllBlockPartials.ROPE_COIL, rotatingAbout);
} }
protected Instancer<OrientedData> getHalfRopeModel() { protected Instancer<OrientedData> getHalfRopeModel() {
return getOrientedMaterial().getModel(AllBlockPartials.ROPE_HALF, blockState); return getOrientedMaterial().getModel(AllBlockPartials.ROPE_HALF);
} }
protected float getOffset() { protected float getOffset() {

View file

@ -181,7 +181,7 @@ public class FlwContraption extends ContraptionRenderInfo {
private final ContraptionInstanceManager tileInstanceManager; private final ContraptionInstanceManager tileInstanceManager;
public ContraptionInstanceWorld(FlwContraption parent) { public ContraptionInstanceWorld(FlwContraption parent) {
switch (Backend.getEngine()) { switch (Backend.getBackendType()) {
case INSTANCING -> { case INSTANCING -> {
InstancingEngine<ContraptionProgram> engine = InstancingEngine.builder(CreateContexts.CWORLD) InstancingEngine<ContraptionProgram> engine = InstancingEngine.builder(CreateContexts.CWORLD)
.setGroupFactory(ContraptionGroup.forContraption(parent)) .setGroupFactory(ContraptionGroup.forContraption(parent))

View file

@ -4,10 +4,10 @@ import static org.lwjgl.opengl.GL11.glBindTexture;
import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D; import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D;
import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.RenderLayer; import com.jozufozu.flywheel.api.RenderLayer;
import com.jozufozu.flywheel.backend.gl.GlStateTracker; import com.jozufozu.flywheel.backend.gl.GlStateTracker;
import com.jozufozu.flywheel.backend.gl.GlTextureUnit; import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
import com.jozufozu.flywheel.config.FlwEngine; import com.jozufozu.flywheel.config.BackendType;
import com.jozufozu.flywheel.core.Formats; import com.jozufozu.flywheel.core.Formats;
import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.compile.ProgramContext; import com.jozufozu.flywheel.core.compile.ProgramContext;
@ -43,7 +43,7 @@ public class FlwContraptionManager extends ContraptionRenderingWorld<FlwContrapt
GlStateTracker.State restoreState = GlStateTracker.getRestoreState(); GlStateTracker.State restoreState = GlStateTracker.getRestoreState();
GlTextureUnit active = GlTextureUnit.getActive(); GlTextureUnit active = GlTextureUnit.getActive();
if (Backend.getEngine() != FlwEngine.BATCHING) { if (Backend.getBackendType() != BackendType.BATCHING) {
renderStructures(event); renderStructures(event);
} }

View file

@ -32,7 +32,7 @@ public class PumpCogInstance extends SingleRotatingInstance implements DynamicIn
materialManager.defaultSolid() materialManager.defaultSolid()
.material(Materials.TRANSFORMED) .material(Materials.TRANSFORMED)
.getModel(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState) .getModel(AllBlockPartials.MECHANICAL_PUMP_ARROW)
.createInstances(arrows); .createInstances(arrows);
} }
@ -63,7 +63,7 @@ public class PumpCogInstance extends SingleRotatingInstance implements DynamicIn
protected Instancer<RotatingData> getModel() { protected Instancer<RotatingData> getModel() {
BlockState referenceState = blockEntity.getBlockState(); BlockState referenceState = blockEntity.getBlockState();
Direction facing = referenceState.getValue(BlockStateProperties.FACING); Direction facing = referenceState.getValue(BlockStateProperties.FACING);
return getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_PUMP_COG, referenceState, facing); return getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_PUMP_COG, facing);
} }
@Override @Override

View file

@ -40,7 +40,7 @@ public class FluidValveInstance extends ShaftInstance implements DynamicInstance
pointer = materialManager.defaultSolid() pointer = materialManager.defaultSolid()
.material(Materials.TRANSFORMED) .material(Materials.TRANSFORMED)
.getModel(AllBlockPartials.FLUID_VALVE_POINTER, blockState).createInstance(); .getModel(AllBlockPartials.FLUID_VALVE_POINTER).createInstance();
transformPointer(); transformPointer();
} }

View file

@ -64,7 +64,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
Instancer<BeltData> beltModel = materialManager.defaultSolid() Instancer<BeltData> beltModel = materialManager.defaultSolid()
.material(AllMaterialSpecs.BELTS) .material(AllMaterialSpecs.BELTS)
.getModel(beltPartial, blockState); .getModel(beltPartial);
keys.add(setup(beltModel.createInstance(), bottom, spriteShift)); keys.add(setup(beltModel.createInstance(), bottom, spriteShift));
@ -143,7 +143,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
return modelTransform; return modelTransform;
}; };
return getRotatingMaterial().getModel(AllBlockPartials.BELT_PULLEY, blockState, dir, ms); return getRotatingMaterial().getModel(AllBlockPartials.BELT_PULLEY, dir, ms);
} }
private Direction getOrientation() { private Direction getOrientation() {

View file

@ -38,8 +38,7 @@ public class BracketedKineticTileInstance extends SingleRotatingInstance {
BlockPos pos = blockEntity.getBlockPos(); BlockPos pos = blockEntity.getBlockPos();
float offset = BracketedKineticTileRenderer.getShaftAngleOffset(axis, pos); float offset = BracketedKineticTileRenderer.getShaftAngleOffset(axis, pos);
Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
Instancer<RotatingData> half = getRotatingMaterial().getModel(AllBlockPartials.COGWHEEL_SHAFT, blockState, Instancer<RotatingData> half = getRotatingMaterial().getModel(AllBlockPartials.COGWHEEL_SHAFT, facing, () -> this.rotateToAxis(axis));
facing, () -> this.rotateToAxis(axis));
additionalShaft = setup(half.createInstance(), speed); additionalShaft = setup(half.createInstance(), speed);
additionalShaft.setRotationOffset(offset); additionalShaft.setRotationOffset(offset);
@ -52,7 +51,7 @@ public class BracketedKineticTileInstance extends SingleRotatingInstance {
Axis axis = KineticTileEntityRenderer.getRotationAxisOf(blockEntity); Axis axis = KineticTileEntityRenderer.getRotationAxisOf(blockEntity);
Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
return getRotatingMaterial().getModel(AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL, blockState, facing, return getRotatingMaterial().getModel(AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL, facing,
() -> this.rotateToAxis(axis)); () -> this.rotateToAxis(axis));
} }

View file

@ -58,7 +58,7 @@ public class EncasedCogInstance extends KineticTileInstance<KineticTileEntity> {
for (Direction d : Iterate.directionsInAxis(axis)) { for (Direction d : Iterate.directionsInAxis(axis)) {
if (!def.hasShaftTowards(blockEntity.getLevel(), blockEntity.getBlockPos(), blockState, d)) if (!def.hasShaftTowards(blockEntity.getLevel(), blockEntity.getBlockPos(), blockState, d))
continue; continue;
RotatingData data = setup(getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, d) RotatingData data = setup(getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, d)
.createInstance()); .createInstance());
if (d.getAxisDirection() == AxisDirection.POSITIVE) if (d.getAxisDirection() == AxisDirection.POSITIVE)
rotatingTopShaft = Optional.of(data); rotatingTopShaft = Optional.of(data);
@ -94,7 +94,7 @@ public class EncasedCogInstance extends KineticTileInstance<KineticTileEntity> {
Direction.fromAxisAndDirection(referenceState.getValue(BlockStateProperties.AXIS), AxisDirection.POSITIVE); Direction.fromAxisAndDirection(referenceState.getValue(BlockStateProperties.AXIS), AxisDirection.POSITIVE);
PartialModel partial = large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL; PartialModel partial = large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL;
return getRotatingMaterial().getModel(partial, referenceState, facing, () -> { return getRotatingMaterial().getModel(partial, facing, () -> {
PoseStack poseStack = new PoseStack(); PoseStack poseStack = new PoseStack();
TransformStack.cast(poseStack) TransformStack.cast(poseStack)
.centre() .centre()

View file

@ -30,7 +30,7 @@ public class SplitShaftInstance extends KineticTileInstance<SplitShaftTileEntity
for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) { for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) {
Instancer<RotatingData> half = rotatingMaterial.getModel(AllBlockPartials.SHAFT_HALF, blockState, dir); Instancer<RotatingData> half = rotatingMaterial.getModel(AllBlockPartials.SHAFT_HALF, dir);
float splitSpeed = speed * tile.getRotationSpeedModifier(dir); float splitSpeed = speed * tile.getRotationSpeedModifier(dir);

View file

@ -32,7 +32,7 @@ public abstract class GaugeInstance extends ShaftInstance implements DynamicInst
GaugeTileEntity gaugeTile = (GaugeTileEntity) tile; GaugeTileEntity gaugeTile = (GaugeTileEntity) tile;
GaugeBlock gaugeBlock = (GaugeBlock) blockState.getBlock(); GaugeBlock gaugeBlock = (GaugeBlock) blockState.getBlock();
Instancer<ModelData> dialModel = getTransformMaterial().getModel(AllBlockPartials.GAUGE_DIAL, blockState); Instancer<ModelData> dialModel = getTransformMaterial().getModel(AllBlockPartials.GAUGE_DIAL);
Instancer<ModelData> headModel = getHeadModel(); Instancer<ModelData> headModel = getHeadModel();
ms = new PoseStack(); ms = new PoseStack();
@ -150,7 +150,7 @@ public abstract class GaugeInstance extends ShaftInstance implements DynamicInst
@Override @Override
protected Instancer<ModelData> getHeadModel() { protected Instancer<ModelData> getHeadModel() {
return getTransformMaterial().getModel(AllBlockPartials.GAUGE_HEAD_SPEED, blockState); return getTransformMaterial().getModel(AllBlockPartials.GAUGE_HEAD_SPEED);
} }
} }
@ -161,7 +161,7 @@ public abstract class GaugeInstance extends ShaftInstance implements DynamicInst
@Override @Override
protected Instancer<ModelData> getHeadModel() { protected Instancer<ModelData> getHeadModel() {
return getTransformMaterial().getModel(AllBlockPartials.GAUGE_HEAD_STRESS, blockState); return getTransformMaterial().getModel(AllBlockPartials.GAUGE_HEAD_STRESS);
} }
} }
} }

View file

@ -40,7 +40,7 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
if (boxAxis == axis) if (boxAxis == axis)
continue; continue;
Instancer<RotatingData> shaft = rotatingMaterial.getModel(AllBlockPartials.SHAFT_HALF, blockState, direction); Instancer<RotatingData> shaft = rotatingMaterial.getModel(AllBlockPartials.SHAFT_HALF, direction);
RotatingData key = shaft.createInstance(); RotatingData key = shaft.createInstance();

View file

@ -15,7 +15,7 @@ public class CopperBacktankInstance extends SingleRotatingInstance {
@Override @Override
protected Instancer<RotatingData> getModel() { protected Instancer<RotatingData> getModel() {
return getRotatingMaterial().getModel(AllBlockPartials.COPPER_BACKTANK_SHAFT, blockState); return getRotatingMaterial().getModel(AllBlockPartials.COPPER_BACKTANK_SHAFT);
} }
} }

View file

@ -32,12 +32,12 @@ public class ToolBoxInstance extends BlockEntityInstance<ToolboxTileEntity> impl
Instancer<ModelData> drawerModel = materialManager.defaultSolid() Instancer<ModelData> drawerModel = materialManager.defaultSolid()
.material(Materials.TRANSFORMED) .material(Materials.TRANSFORMED)
.getModel(AllBlockPartials.TOOLBOX_DRAWER, blockState); .getModel(AllBlockPartials.TOOLBOX_DRAWER);
drawers = new ModelData[]{drawerModel.createInstance(), drawerModel.createInstance()}; drawers = new ModelData[]{drawerModel.createInstance(), drawerModel.createInstance()};
lid = materialManager.defaultCutout() lid = materialManager.defaultCutout()
.material(Materials.TRANSFORMED) .material(Materials.TRANSFORMED)
.getModel(AllBlockPartials.TOOLBOX_LIDS.get(blockEntity.getColor()), blockState) .getModel(AllBlockPartials.TOOLBOX_LIDS.get(blockEntity.getColor()))
.createInstance(); .createInstance();
} }

View file

@ -30,7 +30,7 @@ public class BeltTunnelInstance extends BlockEntityInstance<BeltTunnelTileEntity
Instancer<FlapData> model = modelManager.defaultSolid() Instancer<FlapData> model = modelManager.defaultSolid()
.material(AllMaterialSpecs.FLAPS) .material(AllMaterialSpecs.FLAPS)
.getModel(AllBlockPartials.BELT_TUNNEL_FLAP, blockState); .getModel(AllBlockPartials.BELT_TUNNEL_FLAP);
int blockLight = world.getBrightness(LightLayer.BLOCK, pos); int blockLight = world.getBrightness(LightLayer.BLOCK, pos);
int skyLight = world.getBrightness(LightLayer.SKY, pos); int skyLight = world.getBrightness(LightLayer.SKY, pos);

View file

@ -21,7 +21,7 @@ public class EjectorInstance extends ShaftInstance implements DynamicInstance {
super(dispatcher, tile); super(dispatcher, tile);
this.tile = tile; this.tile = tile;
plate = getTransformMaterial().getModel(AllBlockPartials.EJECTOR_TOP, blockState).createInstance(); plate = getTransformMaterial().getModel(AllBlockPartials.EJECTOR_TOP).createInstance();
pivotPlate(); pivotPlate();
} }

View file

@ -19,7 +19,7 @@ public class BrassDiodeInstance extends BlockEntityInstance<BrassDiodeTileEntity
indicator = modelManager.defaultSolid() indicator = modelManager.defaultSolid()
.material(Materials.TRANSFORMED) .material(Materials.TRANSFORMED)
.getModel(AllBlockPartials.FLEXPEATER_INDICATOR, blockState).createInstance(); .getModel(AllBlockPartials.FLEXPEATER_INDICATOR).createInstance();
indicator.loadIdentity() indicator.loadIdentity()
.translate(getInstancePosition()) .translate(getInstancePosition())

View file

@ -31,7 +31,7 @@ public class FunnelInstance extends BlockEntityInstance<FunnelTileEntity> implem
: AllBlockPartials.BELT_FUNNEL_FLAP); : AllBlockPartials.BELT_FUNNEL_FLAP);
Instancer<FlapData> model = modelManager.defaultSolid() Instancer<FlapData> model = modelManager.defaultSolid()
.material(AllMaterialSpecs.FLAPS) .material(AllMaterialSpecs.FLAPS)
.getModel(flapPartial, blockState); .getModel(flapPartial);
int blockLight = world.getBrightness(LightLayer.BLOCK, pos); int blockLight = world.getBrightness(LightLayer.BLOCK, pos);
int skyLight = world.getBrightness(LightLayer.SKY, pos); int skyLight = world.getBrightness(LightLayer.SKY, pos);

View file

@ -49,13 +49,13 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
Material<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
base = mat.getModel(AllBlockPartials.ARM_BASE, blockState).createInstance(); base = mat.getModel(AllBlockPartials.ARM_BASE).createInstance();
lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState).createInstance(); lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY).createInstance();
upperBody = mat.getModel(AllBlockPartials.ARM_UPPER_BODY, blockState).createInstance(); upperBody = mat.getModel(AllBlockPartials.ARM_UPPER_BODY).createInstance();
head = mat.getModel(AllBlockPartials.ARM_HEAD, blockState).createInstance(); head = mat.getModel(AllBlockPartials.ARM_HEAD).createInstance();
claw = mat.getModel(AllBlockPartials.ARM_CLAW_BASE, blockState).createInstance(); claw = mat.getModel(AllBlockPartials.ARM_CLAW_BASE).createInstance();
Instancer<ModelData> clawHalfModel = mat.getModel(AllBlockPartials.ARM_CLAW_GRIP, blockState); Instancer<ModelData> clawHalfModel = mat.getModel(AllBlockPartials.ARM_CLAW_GRIP);
ModelData clawGrip1 = clawHalfModel.createInstance(); ModelData clawGrip1 = clawHalfModel.createInstance();
ModelData clawGrip2 = clawHalfModel.createInstance(); ModelData clawGrip2 = clawHalfModel.createInstance();
@ -172,7 +172,7 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
@Override @Override
protected Instancer<RotatingData> getModel() { protected Instancer<RotatingData> getModel() {
return getRotatingMaterial().getModel(AllBlockPartials.ARM_COG, blockEntity.getBlockState()); return getRotatingMaterial().getModel(AllBlockPartials.ARM_COG);
} }
@Override @Override

View file

@ -28,8 +28,8 @@ public class AnalogLeverInstance extends BlockEntityInstance<AnalogLeverTileEnti
Material<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState).createInstance(); handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE).createInstance();
indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState).createInstance(); indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR).createInstance();
transform(indicator); transform(indicator);

View file

@ -22,8 +22,8 @@ public class SchematicannonInstance extends BlockEntityInstance<SchematicannonTi
Material<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
connector = mat.getModel(AllBlockPartials.SCHEMATICANNON_CONNECTOR, blockState).createInstance(); connector = mat.getModel(AllBlockPartials.SCHEMATICANNON_CONNECTOR).createInstance();
pipe = mat.getModel(AllBlockPartials.SCHEMATICANNON_PIPE, blockState).createInstance(); pipe = mat.getModel(AllBlockPartials.SCHEMATICANNON_PIPE).createInstance();
} }
@Override @Override

View file

@ -32,6 +32,6 @@ Technology that empowers the player.'''
[[dependencies.create]] [[dependencies.create]]
modId="flywheel" modId="flywheel"
mandatory=true mandatory=true
versionRange="[1.18-0.6.2,1.18-0.6.3)" versionRange="[1.18-0.7.0,1.18-0.7.1)"
ordering="AFTER" ordering="AFTER"
side="CLIENT" side="CLIENT"