Merge remote-tracking branch 'origin/flw/next' into mc1.17/dev
This commit is contained in:
commit
8f1fd1c94e
81 changed files with 433 additions and 488 deletions
|
@ -6,7 +6,7 @@ import net.minecraft.state.properties.BlockStateProperties;
|
|||
import net.minecraft.util.Direction;
|
||||
|
||||
public class BackHalfShaftInstance extends HalfShaftInstance {
|
||||
public BackHalfShaftInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public BackHalfShaftInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||
|
||||
public class CutoutRotatingInstance extends SingleRotatingInstance {
|
||||
public CutoutRotatingInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public CutoutRotatingInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
protected InstanceMaterial<RotatingData> getRotatingMaterial() {
|
||||
protected Material<RotatingData> getRotatingMaterial() {
|
||||
return materialManager.defaultCutout()
|
||||
.material(AllMaterialSpecs.ROTATING);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.state.properties.BlockStateProperties;
|
|||
import net.minecraft.util.Direction;
|
||||
|
||||
public class HalfShaftInstance extends SingleRotatingInstance {
|
||||
public HalfShaftInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public HalfShaftInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.util.Direction;
|
|||
|
||||
public class HorizontalHalfShaftInstance extends HalfShaftInstance {
|
||||
|
||||
public HorizontalHalfShaftInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public HorizontalHalfShaftInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
import com.jozufozu.flywheel.core.materials.BasicData;
|
||||
import com.simibubi.create.foundation.utility.Color;
|
||||
|
||||
|
@ -15,10 +14,6 @@ public class KineticData extends BasicData {
|
|||
private float rotationalSpeed;
|
||||
private float rotationOffset;
|
||||
|
||||
protected KineticData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
public KineticData setPosition(BlockPos pos) {
|
||||
return setPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
@ -68,15 +63,13 @@ public class KineticData extends BasicData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(MappedBuffer buf) {
|
||||
public void write(VecBuffer buf) {
|
||||
super.write(buf);
|
||||
|
||||
buf.putFloatArray(new float[]{
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
rotationalSpeed,
|
||||
rotationOffset
|
||||
});
|
||||
buf.putFloat(x);
|
||||
buf.putFloat(y);
|
||||
buf.putFloat(z);
|
||||
buf.putFloat(rotationalSpeed);
|
||||
buf.putFloat(rotationOffset);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel;
|
||||
|
@ -15,7 +15,7 @@ public abstract class KineticTileInstance<T extends KineticTileEntity> extends T
|
|||
|
||||
protected final Direction.Axis axis;
|
||||
|
||||
public KineticTileInstance(MaterialManager<?> modelManager, T tile) {
|
||||
public KineticTileInstance(MaterialManager modelManager, T tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
axis = ((IRotate) blockState.getBlock()).getRotationAxis(blockState);
|
||||
|
@ -84,7 +84,7 @@ public abstract class KineticTileInstance<T extends KineticTileEntity> extends T
|
|||
return shaft(getRotationAxis());
|
||||
}
|
||||
|
||||
protected InstanceMaterial<RotatingData> getRotatingMaterial() {
|
||||
protected Material<RotatingData> getRotatingMaterial() {
|
||||
return materialManager.defaultSolid()
|
||||
.material(AllMaterialSpecs.ROTATING);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
|
@ -11,19 +10,13 @@ public class RotatingData extends KineticData {
|
|||
private byte rotationAxisY;
|
||||
private byte rotationAxisZ;
|
||||
|
||||
public RotatingData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
public RotatingData setRotationAxis(Direction.Axis axis) {
|
||||
Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis);
|
||||
setRotationAxis(orientation.step());
|
||||
return this;
|
||||
return setRotationAxis(orientation.step());
|
||||
}
|
||||
|
||||
public RotatingData setRotationAxis(Vector3f axis) {
|
||||
setRotationAxis(axis.x(), axis.y(), axis.z());
|
||||
return this;
|
||||
return setRotationAxis(axis.x(), axis.y(), axis.z());
|
||||
}
|
||||
|
||||
public RotatingData setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) {
|
||||
|
@ -35,7 +28,7 @@ public class RotatingData extends KineticData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(MappedBuffer buf) {
|
||||
public void write(VecBuffer buf) {
|
||||
super.write(buf);
|
||||
|
||||
buf.putVec3(rotationAxisX, rotationAxisY, rotationAxisZ);
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
|||
|
||||
public class ShaftlessCogInstance extends SingleRotatingInstance {
|
||||
|
||||
public ShaftlessCogInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public ShaftlessCogInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ public class SingleRotatingInstance extends KineticTileInstance<KineticTileEntit
|
|||
|
||||
protected final RotatingData rotatingModel;
|
||||
|
||||
public SingleRotatingInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public SingleRotatingInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
rotatingModel = setup(getModel().createInstance());
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.components.actors;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
|
@ -28,11 +27,6 @@ public class ActorData extends InstanceData {
|
|||
|
||||
private float speed;
|
||||
|
||||
public ActorData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
|
||||
public ActorData setPosition(BlockPos pos) {
|
||||
this.x = pos.getX();
|
||||
this.y = pos.getY();
|
||||
|
@ -101,7 +95,7 @@ public class ActorData extends InstanceData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(MappedBuffer buf) {
|
||||
public void write(VecBuffer buf) {
|
||||
buf.putVec3(x, y, z);
|
||||
buf.putVec2(blockLight, skyLight);
|
||||
buf.putFloat(rotationOffset);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.components.actors;
|
||||
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
|
@ -19,10 +19,10 @@ public class DrillActorInstance extends ActorInstance {
|
|||
ActorData drillHead;
|
||||
private final Direction facing;
|
||||
|
||||
public DrillActorInstance(MaterialManager<?> materialManager, PlacementSimulationWorld contraption, MovementContext context) {
|
||||
public DrillActorInstance(MaterialManager materialManager, PlacementSimulationWorld contraption, MovementContext context) {
|
||||
super(materialManager, contraption, context);
|
||||
|
||||
InstanceMaterial<ActorData> instanceMaterial = materialManager.defaultSolid()
|
||||
Material<ActorData> material = materialManager.defaultSolid()
|
||||
.material(AllMaterialSpecs.ACTORS);
|
||||
|
||||
BlockState state = context.state;
|
||||
|
@ -38,7 +38,7 @@ public class DrillActorInstance extends ActorInstance {
|
|||
else
|
||||
eulerY = facing.toYRot() + ((axis == Direction.Axis.X) ? 180 : 0);
|
||||
|
||||
drillHead = instanceMaterial.getModel(AllBlockPartials.DRILL_HEAD, state).createInstance();
|
||||
drillHead = material.getModel(AllBlockPartials.DRILL_HEAD, state).createInstance();
|
||||
|
||||
drillHead.setPosition(context.localPos)
|
||||
.setBlockLight(localBlockLight())
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.util.Direction;
|
|||
|
||||
public class DrillInstance extends SingleRotatingInstance {
|
||||
|
||||
public DrillInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public DrillInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
return new DrillActorInstance(materialManager, simulationWorld, context);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ package com.simibubi.create.content.contraptions.components.actors;
|
|||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -34,17 +34,17 @@ public class HarvesterActorInstance extends ActorInstance {
|
|||
private double rotation;
|
||||
private double previousRotation;
|
||||
|
||||
public HarvesterActorInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
public HarvesterActorInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
super(materialManager, simulationWorld, context);
|
||||
|
||||
InstanceMaterial<ModelData> instanceMaterial = materialManager.defaultCutout()
|
||||
Material<ModelData> material = materialManager.defaultCutout()
|
||||
.material(Materials.TRANSFORMED);
|
||||
|
||||
BlockState state = context.state;
|
||||
|
||||
facing = state.getValue(HORIZONTAL_FACING);
|
||||
|
||||
harvester = instanceMaterial.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance();
|
||||
harvester = material.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance();
|
||||
|
||||
horizontalAngle = facing.toYRot() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld,
|
||||
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld,
|
||||
MovementContext context) {
|
||||
return new HarvesterActorInstance(materialManager, simulationWorld, context);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.util.Direction;
|
|||
|
||||
public class MechanicalCrafterInstance extends SingleRotatingInstance {
|
||||
|
||||
public MechanicalCrafterInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public MechanicalCrafterInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
|||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
|
@ -20,7 +20,7 @@ public class HandCrankInstance extends SingleRotatingInstance implements IDynami
|
|||
private ModelData crank;
|
||||
private Direction facing;
|
||||
|
||||
public HandCrankInstance(MaterialManager<?> modelManager, HandCrankTileEntity tile) {
|
||||
public HandCrankInstance(MaterialManager modelManager, HandCrankTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
this.tile = tile;
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ package com.simibubi.create.content.contraptions.components.deployer;
|
|||
import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
|
||||
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
|
||||
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -42,10 +42,10 @@ public class DeployerActorInstance extends ActorInstance {
|
|||
ModelData hand;
|
||||
RotatingData shaft;
|
||||
|
||||
public DeployerActorInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
public DeployerActorInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
super(materialManager, simulationWorld, context);
|
||||
|
||||
InstanceMaterial<ModelData> mat = materialManager.defaultSolid()
|
||||
Material<ModelData> mat = materialManager.defaultSolid()
|
||||
.material(Materials.TRANSFORMED);
|
||||
|
||||
BlockState state = context.state;
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
|||
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
|
@ -36,7 +36,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
|
|||
float progress;
|
||||
private boolean newHand = false;
|
||||
|
||||
public DeployerInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||
public DeployerInstance(MaterialManager dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
|
||||
this.tile = (DeployerTileEntity) super.tile;
|
||||
|
|
|
@ -268,7 +268,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
return new DeployerActorInstance(materialManager, simulationWorld, context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
|
|||
final Direction direction;
|
||||
private final Direction opposite;
|
||||
|
||||
public FanInstance(MaterialManager<?> modelManager, EncasedFanTileEntity tile) {
|
||||
public FanInstance(MaterialManager modelManager, EncasedFanTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
direction = blockState.getValue(FACING);
|
||||
|
|
|
@ -9,9 +9,9 @@ import com.google.common.collect.Lists;
|
|||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -45,7 +45,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
|
|||
|
||||
protected float lastAngle = Float.NaN;
|
||||
|
||||
public FlyWheelInstance(MaterialManager<?> modelManager, FlywheelTileEntity tile) {
|
||||
public FlyWheelInstance(MaterialManager modelManager, FlywheelTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
facing = blockState.getValue(HORIZONTAL_FACING);
|
||||
|
@ -63,7 +63,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
|
|||
|
||||
connectorAngleMult = flipAngle ? -1 : 1;
|
||||
|
||||
InstanceMaterial<ModelData> mat = getTransformMaterial();
|
||||
Material<ModelData> mat = getTransformMaterial();
|
||||
|
||||
upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState).createInstance();
|
||||
lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState).createInstance();
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
|||
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -16,7 +16,7 @@ public class EngineInstance extends TileEntityInstance<EngineTileEntity> {
|
|||
|
||||
protected ModelData frame;
|
||||
|
||||
public EngineInstance(MaterialManager<?> modelManager, EngineTileEntity tile) {
|
||||
public EngineInstance(MaterialManager modelManager, EngineTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
Block block = blockState
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
|||
|
||||
public class MillStoneCogInstance extends SingleRotatingInstance {
|
||||
|
||||
public MillStoneCogInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public MillStoneCogInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.mixer;
|
|||
|
||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||
import com.simibubi.create.content.contraptions.base.ShaftlessCogInstance;
|
||||
|
@ -16,7 +16,7 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta
|
|||
private final OrientedData mixerPole;
|
||||
private final MechanicalMixerTileEntity mixer;
|
||||
|
||||
public MixerInstance(MaterialManager<?> dispatcher, MechanicalMixerTileEntity tile) {
|
||||
public MixerInstance(MaterialManager dispatcher, MechanicalMixerTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
this.mixer = tile;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.press;
|
|||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -17,7 +17,7 @@ public class PressInstance extends ShaftInstance implements IDynamicInstance {
|
|||
private final OrientedData pressHead;
|
||||
private final MechanicalPressTileEntity press;
|
||||
|
||||
public PressInstance(MaterialManager<?> dispatcher, MechanicalPressTileEntity tile) {
|
||||
public PressInstance(MaterialManager dispatcher, MechanicalPressTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
press = tile;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.util.Rotation;
|
|||
|
||||
public class SawInstance extends SingleRotatingInstance {
|
||||
|
||||
public SawInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public SawInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
|
||||
import com.jozufozu.flywheel.backend.IFlywheelWorld;
|
||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||
import com.jozufozu.flywheel.light.ImmutableBox;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllMovementBehaviours;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
|
@ -1171,16 +1172,16 @@ public abstract class Contraption {
|
|||
|
||||
GridAlignedBB betterBounds = GridAlignedBB.ofRadius(radius);
|
||||
|
||||
GridAlignedBB contraptionBounds = GridAlignedBB.from(bounds);
|
||||
ImmutableBox contraptionBounds = GridAlignedBB.from(bounds);
|
||||
if (axis == Direction.Axis.X) {
|
||||
betterBounds.maxX = contraptionBounds.maxX;
|
||||
betterBounds.minX = contraptionBounds.minX;
|
||||
betterBounds.setMaxX(contraptionBounds.getMaxX());
|
||||
betterBounds.setMinX(contraptionBounds.getMinX());
|
||||
} else if (axis == Direction.Axis.Y) {
|
||||
betterBounds.maxY = contraptionBounds.maxY;
|
||||
betterBounds.minY = contraptionBounds.minY;
|
||||
betterBounds.setMaxY(contraptionBounds.getMaxY());
|
||||
betterBounds.setMinY(contraptionBounds.getMinY());
|
||||
} else if (axis == Direction.Axis.Z) {
|
||||
betterBounds.maxZ = contraptionBounds.maxZ;
|
||||
betterBounds.minZ = contraptionBounds.minZ;
|
||||
betterBounds.setMaxZ(contraptionBounds.getMaxZ());
|
||||
betterBounds.setMinZ(contraptionBounds.getMinZ());
|
||||
}
|
||||
|
||||
bounds = betterBounds.toAABB();
|
||||
|
|
|
@ -1,69 +1,63 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement;
|
||||
|
||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||
import com.jozufozu.flywheel.light.ILightUpdateListener;
|
||||
import com.jozufozu.flywheel.light.LightUpdater;
|
||||
import com.jozufozu.flywheel.light.LightVolume;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
|
||||
import com.jozufozu.flywheel.light.*;
|
||||
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
public abstract class ContraptionLighter<C extends Contraption> implements ILightUpdateListener {
|
||||
protected final C contraption;
|
||||
public final LightVolume lightVolume;
|
||||
public final GPULightVolume lightVolume;
|
||||
protected final LightUpdater lightUpdater;
|
||||
|
||||
protected GridAlignedBB bounds;
|
||||
protected final GridAlignedBB bounds;
|
||||
|
||||
protected boolean scheduleRebuild;
|
||||
|
||||
protected ContraptionLighter(C contraption) {
|
||||
this.contraption = contraption;
|
||||
lightUpdater = LightUpdater.get(contraption.entity.level);
|
||||
|
||||
bounds = getContraptionBounds();
|
||||
bounds = getContraptionBounds();
|
||||
growBoundsForEdgeData();
|
||||
|
||||
lightVolume = new LightVolume(contraptionBoundsToVolume(bounds.copy()));
|
||||
lightVolume = new GPULightVolume(bounds);
|
||||
|
||||
lightVolume.initialize(contraption.entity.level);
|
||||
scheduleRebuild = true;
|
||||
lightVolume.initialize(lightUpdater.getProvider());
|
||||
scheduleRebuild = true;
|
||||
|
||||
startListening();
|
||||
}
|
||||
lightUpdater.addListener(this);
|
||||
}
|
||||
|
||||
public void tick(RenderedContraption owner) {
|
||||
if (scheduleRebuild) {
|
||||
lightVolume.initialize(owner.contraption.entity.level);
|
||||
scheduleRebuild = false;
|
||||
}
|
||||
}
|
||||
public abstract GridAlignedBB getContraptionBounds();
|
||||
|
||||
public abstract GridAlignedBB getContraptionBounds();
|
||||
@Override
|
||||
public ListenerStatus status() {
|
||||
return ListenerStatus.OKAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLightUpdate(IBlockDisplayReader world, LightType type, GridAlignedBB changed) {
|
||||
lightVolume.notifyLightUpdate(world, type, changed);
|
||||
return false;
|
||||
@Override
|
||||
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changed) {
|
||||
lightVolume.onLightUpdate(world, type, changed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLightPacket(IBlockDisplayReader world, int chunkX, int chunkZ) {
|
||||
lightVolume.notifyLightPacket(world, chunkX, chunkZ);
|
||||
return false;
|
||||
public void onLightPacket(LightProvider world, int chunkX, int chunkZ) {
|
||||
lightVolume.onLightPacket(world, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
protected void startListening() {
|
||||
LightUpdater.getInstance().startListening(bounds, this);
|
||||
}
|
||||
|
||||
protected GridAlignedBB contraptionBoundsToVolume(GridAlignedBB bounds) {
|
||||
protected void growBoundsForEdgeData() {
|
||||
bounds.grow(2); // so we have at least enough data on the edges to avoid artifacts and have smooth lighting
|
||||
bounds.minY = Math.max(bounds.minY, 0);
|
||||
bounds.maxY = Math.min(bounds.maxY, 255);
|
||||
bounds.setMinY(Math.max(bounds.getMinY(), 0));
|
||||
bounds.setMaxY(Math.min(bounds.getMaxY(), 255));
|
||||
}
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public GridAlignedBB getBounds() {
|
||||
@Override
|
||||
public ImmutableBox getVolume() {
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
lightUpdater.removeListener(this);
|
||||
lightVolume.delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public abstract class MovementBehaviour {
|
|||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Nullable
|
||||
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,35 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement;
|
||||
|
||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.RenderedContraption;
|
||||
import com.jozufozu.flywheel.light.IMovingListener;
|
||||
import com.jozufozu.flywheel.light.LightProvider;
|
||||
import com.jozufozu.flywheel.light.ImmutableBox;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
|
||||
public class NonStationaryLighter<C extends Contraption> extends ContraptionLighter<C> {
|
||||
public class NonStationaryLighter<C extends Contraption> extends ContraptionLighter<C> implements IMovingListener {
|
||||
public NonStationaryLighter(C contraption) {
|
||||
super(contraption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(RenderedContraption owner) {
|
||||
super.tick(owner);
|
||||
GridAlignedBB contraptionBounds = getContraptionBounds();
|
||||
@Override
|
||||
public boolean update(LightProvider provider) {
|
||||
if (getVolume().volume() > AllConfigs.CLIENT.maxContraptionLightVolume.get())
|
||||
return false;
|
||||
|
||||
if (!contraptionBounds.sameAs(bounds)) {
|
||||
lightVolume.move(contraption.entity.level, contraptionBoundsToVolume(contraptionBounds));
|
||||
bounds = contraptionBounds;
|
||||
ImmutableBox contraptionBounds = getContraptionBounds();
|
||||
|
||||
startListening();
|
||||
}
|
||||
}
|
||||
if (bounds.sameAs(contraptionBounds)) {
|
||||
return false;
|
||||
}
|
||||
bounds.assign(contraptionBounds);
|
||||
growBoundsForEdgeData();
|
||||
|
||||
@Override
|
||||
lightVolume.move(provider, bounds);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GridAlignedBB getContraptionBounds() {
|
||||
GridAlignedBB bb = GridAlignedBB.from(contraption.bounds);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be
|
|||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.BackHalfShaftInstance;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
|
@ -23,7 +23,7 @@ public class BearingInstance<B extends KineticTileEntity & IBearingTileEntity> e
|
|||
final Vector3f rotationAxis;
|
||||
final Quaternion blockOrientation;
|
||||
|
||||
public BearingInstance(MaterialManager<?> modelManager, B tile) {
|
||||
public BearingInstance(MaterialManager modelManager, B tile) {
|
||||
super(modelManager, tile);
|
||||
this.bearing = tile;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be
|
|||
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||
|
@ -23,7 +23,7 @@ public class StabilizedBearingInstance extends ActorInstance {
|
|||
final Vector3f rotationAxis;
|
||||
final Quaternion blockOrientation;
|
||||
|
||||
public StabilizedBearingInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
public StabilizedBearingInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
super(materialManager, simulationWorld, context);
|
||||
|
||||
BlockState blockState = context.state;
|
||||
|
|
|
@ -70,7 +70,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||
return new StabilizedBearingInstance(materialManager, simulationWorld, context);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch
|
|||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -23,7 +23,7 @@ public class StickerInstance extends TileEntityInstance<StickerTileEntity> imple
|
|||
|
||||
private final ModelData head;
|
||||
|
||||
public StickerInstance(MaterialManager<?> modelManager, StickerTileEntity tile) {
|
||||
public StickerInstance(MaterialManager modelManager, StickerTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
head = getTransformMaterial().getModel(AllBlockPartials.STICKER_HEAD, blockState).createInstance();
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ga
|
|||
|
||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -29,7 +29,7 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns
|
|||
|
||||
private float lastAngle = Float.NaN;
|
||||
|
||||
public GantryCarriageInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||
public GantryCarriageInstance(MaterialManager dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
|
||||
gantryCogs = getTransformMaterial()
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.jozufozu.flywheel.backend.state.TextureRenderState;
|
|||
import com.jozufozu.flywheel.core.Formats;
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.jozufozu.flywheel.core.model.IModel;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllStitchedTextures;
|
||||
|
@ -37,7 +37,7 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
|
|||
private final Quaternion rotation;
|
||||
protected ConditionalInstance<OrientedData> model;
|
||||
|
||||
public GlueInstance(MaterialManager<?> materialManager, SuperGlueEntity entity) {
|
||||
public GlueInstance(MaterialManager materialManager, SuperGlueEntity entity) {
|
||||
super(materialManager, entity);
|
||||
|
||||
Instancer<OrientedData> instancer = getInstancer(materialManager, entity);
|
||||
|
@ -51,8 +51,8 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
|
|||
.update();
|
||||
}
|
||||
|
||||
private Instancer<OrientedData> getInstancer(MaterialManager<?> materialManager, SuperGlueEntity entity) {
|
||||
MaterialGroup<?> group = USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(TextureRenderState.get(TEXTURE));
|
||||
private Instancer<OrientedData> getInstancer(MaterialManager materialManager, SuperGlueEntity entity) {
|
||||
MaterialGroup group = USE_ATLAS ? materialManager.defaultCutout() : materialManager.cutout(TextureRenderState.get(TEXTURE));
|
||||
|
||||
return group.material(Materials.ORIENTED).model(entity.getType(), GlueModel::new);
|
||||
}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement.pulley;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
|
||||
import com.jozufozu.flywheel.core.instancing.GroupInstance;
|
||||
import com.jozufozu.flywheel.core.instancing.SelectInstance;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||
import com.jozufozu.flywheel.light.ILightUpdateListener;
|
||||
import com.jozufozu.flywheel.light.IMovingListener;
|
||||
import com.jozufozu.flywheel.light.LightPacking;
|
||||
import com.jozufozu.flywheel.light.LightProvider;
|
||||
import com.jozufozu.flywheel.light.ImmutableBox;
|
||||
import com.jozufozu.flywheel.light.LightUpdater;
|
||||
import com.jozufozu.flywheel.light.LightVolume;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
public abstract class AbstractPulleyInstance extends ShaftInstance implements IDynamicInstance, ILightUpdateListener {
|
||||
public abstract class AbstractPulleyInstance extends ShaftInstance implements IDynamicInstance, IMovingListener {
|
||||
|
||||
final OrientedData coil;
|
||||
final SelectInstance<OrientedData> magnet;
|
||||
|
@ -33,18 +33,16 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
|
|||
protected final Direction rotatingAbout;
|
||||
protected final Vector3f rotationAxis;
|
||||
|
||||
private byte[] bLight = new byte[1];
|
||||
private byte[] sLight = new byte[1];
|
||||
private GridAlignedBB volume;
|
||||
private final GridAlignedBB volume = new GridAlignedBB();
|
||||
private final LightVolume light;
|
||||
|
||||
public AbstractPulleyInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||
public AbstractPulleyInstance(MaterialManager dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
|
||||
rotatingAbout = Direction.get(Direction.AxisDirection.POSITIVE, axis);
|
||||
rotationAxis = rotatingAbout.step();
|
||||
|
||||
coil = getCoilModel()
|
||||
.createInstance()
|
||||
coil = getCoilModel().createInstance()
|
||||
.setPosition(getInstancePosition());
|
||||
|
||||
magnet = new SelectInstance<>(this::getMagnetModelIndex);
|
||||
|
@ -52,49 +50,60 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
|
|||
.addModel(getHalfMagnetModel());
|
||||
|
||||
rope = new GroupInstance<>(getRopeModel());
|
||||
halfRope = new ConditionalInstance<>(getHalfRopeModel())
|
||||
.withCondition(this::shouldRenderHalfRope);
|
||||
halfRope = new ConditionalInstance<>(getHalfRopeModel()).withCondition(this::shouldRenderHalfRope);
|
||||
|
||||
updateOffset();
|
||||
updateVolume();
|
||||
|
||||
light = new LightVolume(volume);
|
||||
light.initialize(LightUpdater.get(world).getProvider());
|
||||
|
||||
beginFrame();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginFrame() {
|
||||
updateOffset();
|
||||
|
||||
transformModels();
|
||||
}
|
||||
|
||||
private void transformModels() {
|
||||
resizeRope();
|
||||
|
||||
coil.setRotation(rotationAxis.rotationDegrees(offset * 180));
|
||||
magnet.update().get().ifPresent(data ->
|
||||
{
|
||||
int index = Math.max(0, MathHelper.floor(offset));
|
||||
|
||||
int neededRopeCount = getNeededRopeCount();
|
||||
rope.resize(neededRopeCount);
|
||||
|
||||
magnet.update()
|
||||
.get()
|
||||
.ifPresent(data -> {
|
||||
int i = Math.max(0, MathHelper.floor(offset));
|
||||
short packed = light.getPackedLight(pos.getX(), pos.getY() - i, pos.getZ());
|
||||
data.setPosition(getInstancePosition())
|
||||
.nudge(0, -offset, 0)
|
||||
.setBlockLight(bLight[index])
|
||||
.setSkyLight(sLight[index]);
|
||||
}
|
||||
);
|
||||
.setBlockLight(LightPacking.getBlock(packed))
|
||||
.setSkyLight(LightPacking.getSky(packed));
|
||||
});
|
||||
|
||||
halfRope.update().get().ifPresent(rope -> {
|
||||
float f = offset % 1;
|
||||
float halfRopeNudge = f > .75f ? f - 1 : f;
|
||||
halfRope.update()
|
||||
.get()
|
||||
.ifPresent(rope1 -> {
|
||||
float f = offset % 1;
|
||||
float halfRopeNudge = f > .75f ? f - 1 : f;
|
||||
|
||||
rope.setPosition(getInstancePosition())
|
||||
.nudge(0, -halfRopeNudge, 0)
|
||||
.setBlockLight(bLight[0])
|
||||
.setSkyLight(sLight[0]);
|
||||
});
|
||||
short packed = light.getPackedLight(pos.getX(), pos.getY(), pos.getZ());
|
||||
rope1.setPosition(getInstancePosition())
|
||||
.nudge(0, -halfRopeNudge, 0)
|
||||
.setBlockLight(LightPacking.getBlock(packed))
|
||||
.setSkyLight(LightPacking.getSky(packed));
|
||||
});
|
||||
|
||||
if (isRunning()) {
|
||||
int size = rope.size();
|
||||
int bottomY = pos.getY() - size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
short packed = light.getPackedLight(pos.getX(), bottomY + i, pos.getZ());
|
||||
|
||||
rope.get(i)
|
||||
.setPosition(getInstancePosition())
|
||||
.nudge(0, -offset + i + 1, 0)
|
||||
.setBlockLight(bLight[size - i])
|
||||
.setSkyLight(sLight[size - i]);
|
||||
.setBlockLight(LightPacking.getBlock(packed))
|
||||
.setSkyLight(LightPacking.getSky(packed));
|
||||
}
|
||||
} else {
|
||||
rope.clear();
|
||||
|
@ -114,6 +123,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
|
|||
magnet.delete();
|
||||
rope.clear();
|
||||
halfRope.delete();
|
||||
light.delete();
|
||||
}
|
||||
|
||||
protected abstract Instancer<OrientedData> getRopeModel();
|
||||
|
@ -130,23 +140,24 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
|
|||
|
||||
protected abstract boolean isRunning();
|
||||
|
||||
protected void resizeRope() {
|
||||
int neededRopeCount = getNeededRopeCount();
|
||||
rope.resize(neededRopeCount);
|
||||
|
||||
int length = MathHelper.ceil(offset);
|
||||
|
||||
if (volume == null || bLight.length < length + 1) {
|
||||
volume = GridAlignedBB.from(pos.below(length), pos);
|
||||
volume.fixMinMax();
|
||||
|
||||
bLight = Arrays.copyOf(bLight, length + 1);
|
||||
sLight = Arrays.copyOf(sLight, length + 1);
|
||||
|
||||
initLight(world, volume);
|
||||
|
||||
LightUpdater.getInstance().startListening(volume, this);
|
||||
@Override
|
||||
public boolean update(LightProvider provider) {
|
||||
if (updateVolume()) {
|
||||
light.move(provider, volume);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean updateVolume() {
|
||||
int length = MathHelper.ceil(offset) + 2;
|
||||
|
||||
if (volume.sizeY() < length) {
|
||||
volume.assign(pos.below(length), pos)
|
||||
.fixMinMax();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateOffset() {
|
||||
|
@ -164,7 +175,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
|
|||
|
||||
private int getMagnetModelIndex() {
|
||||
if (isRunning() || offset == 0) {
|
||||
return offset > .25f ? 0 : 1;
|
||||
return offset > .25f ? 0 : 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
@ -176,26 +187,13 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onLightUpdate(IBlockDisplayReader world, LightType type, GridAlignedBB changed) {
|
||||
changed.intersectAssign(volume);
|
||||
|
||||
initLight(world, changed);
|
||||
|
||||
return false;
|
||||
public ImmutableBox getVolume() {
|
||||
return volume;
|
||||
}
|
||||
|
||||
private void initLight(IBlockDisplayReader world, GridAlignedBB changed) {
|
||||
int top = this.pos.getY();
|
||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
changed.forEachContained((x, y, z) -> {
|
||||
pos.set(x, y, z);
|
||||
byte block = (byte) world.getBrightness(LightType.BLOCK, pos);
|
||||
byte sky = (byte) world.getBrightness(LightType.SKY, pos);
|
||||
|
||||
int i = top - y;
|
||||
|
||||
bLight[i] = block;
|
||||
sLight[i] = sky;
|
||||
});
|
||||
@Override
|
||||
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changed) {
|
||||
super.onLightUpdate(world, type, changed);
|
||||
light.onLightUpdate(world, type, changed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,15 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu
|
|||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.fluids.actors.HosePulleyTileEntity;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
public class HosePulleyInstance extends AbstractPulleyInstance {
|
||||
final HosePulleyTileEntity tile = (HosePulleyTileEntity) super.tile;
|
||||
|
||||
public HosePulleyInstance(MaterialManager<?> dispatcher, HosePulleyTileEntity tile) {
|
||||
public HosePulleyInstance(MaterialManager dispatcher, HosePulleyTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
beginFrame();
|
||||
}
|
||||
|
||||
protected Instancer<OrientedData> getRopeModel() {
|
||||
|
@ -41,7 +39,7 @@ public class HosePulleyInstance extends AbstractPulleyInstance {
|
|||
}
|
||||
|
||||
protected float getOffset() {
|
||||
return tile.getInterpolatedOffset(AnimationTickHolder.getPartialTicks());
|
||||
return ((HosePulleyTileEntity) tile).getInterpolatedOffset(AnimationTickHolder.getPartialTicks());
|
||||
}
|
||||
|
||||
protected boolean isRunning() {
|
||||
|
|
|
@ -25,7 +25,7 @@ public class PulleyLighter extends ContraptionLighter<PulleyContraption> {
|
|||
}
|
||||
|
||||
bounds.translate(pos);
|
||||
bounds.minY = 1; // the super constructor will take care of making this 0
|
||||
bounds.setMinY(1); // the super constructor will take care of making this 0
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
|
|
@ -3,17 +3,14 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu
|
|||
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
public class RopePulleyInstance extends AbstractPulleyInstance {
|
||||
final PulleyTileEntity tile = (PulleyTileEntity) super.tile;
|
||||
|
||||
public RopePulleyInstance(MaterialManager<?> dispatcher, PulleyTileEntity tile) {
|
||||
public RopePulleyInstance(MaterialManager dispatcher, PulleyTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
beginFrame();
|
||||
}
|
||||
|
||||
protected Instancer<OrientedData> getRopeModel() {
|
||||
|
@ -38,10 +35,10 @@ public class RopePulleyInstance extends AbstractPulleyInstance {
|
|||
|
||||
protected float getOffset() {
|
||||
float partialTicks = AnimationTickHolder.getPartialTicks();
|
||||
return PulleyRenderer.getTileOffset(partialTicks, tile);
|
||||
return PulleyRenderer.getTileOffset(partialTicks, (PulleyTileEntity) tile);
|
||||
}
|
||||
|
||||
protected boolean isRunning() {
|
||||
return tile.running || tile.isVirtual();
|
||||
return ((PulleyTileEntity) tile).running || tile.isVirtual();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationW
|
|||
import net.minecraft.world.LightType;
|
||||
|
||||
public abstract class ActorInstance {
|
||||
protected final MaterialManager<?> materialManager;
|
||||
protected final MaterialManager materialManager;
|
||||
protected final PlacementSimulationWorld simulationWorld;
|
||||
protected final MovementContext context;
|
||||
|
||||
public ActorInstance(MaterialManager<?> materialManager, PlacementSimulationWorld world, MovementContext context) {
|
||||
public ActorInstance(MaterialManager materialManager, PlacementSimulationWorld world, MovementContext context) {
|
||||
this.materialManager = materialManager;
|
||||
this.simulationWorld = world;
|
||||
this.context = context;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
||||
|
||||
import com.jozufozu.flywheel.backend.material.MaterialGroup;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialGroupImpl;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
||||
import com.jozufozu.flywheel.backend.state.IRenderState;
|
||||
|
||||
public class ContraptionGroup<P extends ContraptionProgram> extends MaterialGroup<P> {
|
||||
public class ContraptionGroup<P extends ContraptionProgram> extends MaterialGroupImpl<P> {
|
||||
|
||||
private final RenderedContraption contraption;
|
||||
|
||||
public ContraptionGroup(RenderedContraption contraption, MaterialManager<P> owner, IRenderState state) {
|
||||
public ContraptionGroup(RenderedContraption contraption, MaterialManagerImpl<P> owner, IRenderState state) {
|
||||
super(owner, state);
|
||||
|
||||
this.contraption = contraption;
|
||||
|
@ -19,7 +19,7 @@ public class ContraptionGroup<P extends ContraptionProgram> extends MaterialGrou
|
|||
contraption.setup(program);
|
||||
}
|
||||
|
||||
public static <P extends ContraptionProgram> MaterialManager.GroupFactory<P> forContraption(RenderedContraption c) {
|
||||
public static <P extends ContraptionProgram> MaterialManagerImpl.GroupFactory<P> forContraption(RenderedContraption c) {
|
||||
return (materialManager, state) -> new ContraptionGroup<>(c, materialManager, state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import javax.annotation.Nullable;
|
|||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
||||
import com.simibubi.create.AllMovementBehaviours;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
|
@ -23,7 +23,7 @@ public class ContraptionInstanceManager extends TileInstanceManager {
|
|||
|
||||
private final WeakReference<RenderedContraption> contraption;
|
||||
|
||||
ContraptionInstanceManager(RenderedContraption contraption, MaterialManager<?> materialManager) {
|
||||
ContraptionInstanceManager(RenderedContraption contraption, MaterialManagerImpl<?> materialManager) {
|
||||
super(materialManager);
|
||||
this.contraption = new WeakReference<>(contraption);
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ import java.util.List;
|
|||
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.jozufozu.flywheel.backend.loading.Program;
|
||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
|
||||
|
@ -18,8 +18,8 @@ public class ContraptionProgram extends WorldProgram {
|
|||
|
||||
protected int uLightVolume;
|
||||
|
||||
public ContraptionProgram(Program program, List<IProgramExtension> extensions) {
|
||||
super(program, extensions);
|
||||
public ContraptionProgram(ResourceLocation name, int handle, List<IProgramExtension> extensions) {
|
||||
super(name, handle, extensions);
|
||||
uLightBoxSize = getUniformLocation("uLightBoxSize");
|
||||
uLightBoxMin = getUniformLocation("uLightBoxMin");
|
||||
uModel = getUniformLocation("uModel");
|
||||
|
|
|
@ -28,10 +28,6 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
|
|||
super.tick();
|
||||
|
||||
for (RenderedContraption contraption : visible) {
|
||||
ContraptionLighter<?> lighter = contraption.getLighter();
|
||||
if (lighter.getBounds().volume() < AllConfigs.CLIENT.maxContraptionLightVolume.get())
|
||||
lighter.tick(contraption);
|
||||
|
||||
contraption.kinetics.tick();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
||||
|
||||
public class LightVolumeDebugger {
|
||||
public static void render(MatrixStack ms, SuperRenderTypeBuffer buffer) {
|
||||
// ContraptionRenderDispatcher.RENDERERS.values()
|
||||
// .stream()
|
||||
// .flatMap(r -> {
|
||||
// GridAlignedBB texture = r.getLighter().lightVolume.getTextureVolume();
|
||||
// GridAlignedBB sample = r.getLighter().lightVolume.getSampleVolume();
|
||||
//
|
||||
// ArrayList<Pair<GridAlignedBB, Integer>> pairs = new ArrayList<>(2);
|
||||
//
|
||||
// pairs.add(Pair.of(texture, 0xFFFFFF));
|
||||
// pairs.add(Pair.of(sample, 0xFFFF00));
|
||||
//
|
||||
// return pairs.stream();
|
||||
// })
|
||||
// .map(pair -> {
|
||||
// AABBOutline outline = new AABBOutline(GridAlignedBB.toAABB(pair.getFirst()));
|
||||
//
|
||||
// outline.getParams().colored(pair.getSecond());
|
||||
// return outline;
|
||||
// })
|
||||
// .forEach(outline -> outline.render(ms, buffer, AnimationTickHolder.getPartialTicks()));
|
||||
}
|
||||
}
|
|
@ -8,13 +8,12 @@ import java.util.function.Supplier;
|
|||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
||||
import com.jozufozu.flywheel.backend.model.ArrayModelRenderer;
|
||||
import com.jozufozu.flywheel.backend.model.ModelRenderer;
|
||||
import com.jozufozu.flywheel.core.model.IModel;
|
||||
import com.jozufozu.flywheel.core.model.WorldModel;
|
||||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
||||
|
@ -36,7 +35,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
|||
|
||||
private final ContraptionLighter<?> lighter;
|
||||
|
||||
public final MaterialManager<ContraptionProgram> materialManager;
|
||||
public final MaterialManagerImpl<ContraptionProgram> materialManager;
|
||||
public final ContraptionInstanceManager kinetics;
|
||||
|
||||
private final Map<RenderType, ModelRenderer> renderLayers = new HashMap<>();
|
||||
|
@ -48,7 +47,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
|||
public RenderedContraption(Contraption contraption, PlacementSimulationWorld renderWorld) {
|
||||
super(contraption, renderWorld);
|
||||
this.lighter = contraption.makeLighter();
|
||||
this.materialManager = MaterialManager.builder(CreateContexts.CWORLD)
|
||||
this.materialManager = MaterialManagerImpl.builder(CreateContexts.CWORLD)
|
||||
.setGroupFactory(ContraptionGroup.forContraption(this))
|
||||
.setIgnoreOriginCoordinate(true)
|
||||
.build();
|
||||
|
@ -85,7 +84,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
|||
|
||||
Vector3d cameraPos = event.getCameraPos();
|
||||
|
||||
lightBox = GridAlignedBB.toAABB(lighter.lightVolume.getTextureVolume())
|
||||
lightBox = lighter.lightVolume.toAABB()
|
||||
.move(-cameraPos.x, -cameraPos.y, -cameraPos.z);
|
||||
}
|
||||
|
||||
|
@ -111,7 +110,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
|
|||
}
|
||||
renderLayers.clear();
|
||||
|
||||
lighter.lightVolume.delete();
|
||||
lighter.delete();
|
||||
|
||||
materialManager.delete();
|
||||
kinetics.invalidate();
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.util.Direction;
|
|||
|
||||
public class PumpCogInstance extends SingleRotatingInstance {
|
||||
|
||||
public PumpCogInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public PumpCogInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.fluids.pipes;
|
|||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -24,7 +24,7 @@ public class FluidValveInstance extends ShaftInstance implements IDynamicInstanc
|
|||
protected final double yRot;
|
||||
protected final int pointerRotationOffset;
|
||||
|
||||
public FluidValveInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||
public FluidValveInstance(MaterialManager dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
|
||||
Direction facing = blockState.getValue(FluidValveBlock.FACING);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.relays.belt;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
import com.simibubi.create.content.contraptions.base.KineticData;
|
||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||
|
||||
|
@ -21,10 +20,6 @@ public class BeltData extends KineticData {
|
|||
private float maxV;
|
||||
private byte scrollMult;
|
||||
|
||||
public BeltData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
public BeltData setRotation(Quaternion q) {
|
||||
this.qX = q.i();
|
||||
this.qY = q.j();
|
||||
|
@ -56,7 +51,7 @@ public class BeltData extends KineticData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(MappedBuffer buf) {
|
||||
public void write(VecBuffer buf) {
|
||||
super.write(buf);
|
||||
|
||||
buf.putVec4(qX, qY, qZ, qW);
|
||||
|
|
|
@ -35,7 +35,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
|
|||
protected ArrayList<BeltData> keys;
|
||||
protected RotatingData pulleyKey;
|
||||
|
||||
public BeltInstance(MaterialManager<?> materialManager, BeltTileEntity tile) {
|
||||
public BeltInstance(MaterialManager materialManager, BeltTileEntity tile) {
|
||||
super(materialManager, tile);
|
||||
|
||||
if (!AllBlocks.BELT.has(blockState))
|
||||
|
|
|
@ -15,7 +15,10 @@ import java.util.function.Function;
|
|||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||
import com.jozufozu.flywheel.light.ILightUpdateListener;
|
||||
import com.jozufozu.flywheel.light.LightProvider;
|
||||
import com.jozufozu.flywheel.light.LightUpdater;
|
||||
import com.jozufozu.flywheel.light.ListenerStatus;
|
||||
import com.jozufozu.flywheel.light.ImmutableBox;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
|
@ -48,7 +51,6 @@ import net.minecraft.util.math.AxisAlignedBB;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
@ -118,8 +120,8 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis
|
|||
|
||||
if (light == null && level.isClientSide) {
|
||||
initializeLight();
|
||||
LightUpdater.getInstance()
|
||||
.startListening(getBeltVolume(), this);
|
||||
LightUpdater.get(level)
|
||||
.addListener(this);
|
||||
}
|
||||
|
||||
getInventory().tick();
|
||||
|
@ -533,14 +535,26 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis
|
|||
return state != null && state.hasProperty(BeltBlock.PART) && state.getValue(BeltBlock.PART) == BeltPart.START;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLightUpdate(IBlockDisplayReader world, LightType type, GridAlignedBB changed) {
|
||||
if (this.remove)
|
||||
return true;
|
||||
if (this.level == null || this.light == null)
|
||||
return false;
|
||||
public GridAlignedBB getVolume() {
|
||||
BlockPos endPos = BeltHelper.getPositionForOffset(this, beltLength - 1);
|
||||
GridAlignedBB bb = GridAlignedBB.from(worldPosition, endPos);
|
||||
bb.fixMinMax();
|
||||
return bb;
|
||||
}
|
||||
|
||||
GridAlignedBB beltVolume = getBeltVolume();
|
||||
@Override
|
||||
public ListenerStatus status() {
|
||||
return remove ? ListenerStatus.REMOVE : ListenerStatus.OKAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightUpdate(LightProvider world, LightType type, ImmutableBox changed) {
|
||||
if (this.remove)
|
||||
return;
|
||||
if (this.level == null)
|
||||
return;
|
||||
|
||||
GridAlignedBB beltVolume = getVolume();
|
||||
|
||||
if (beltVolume.intersects(changed)) {
|
||||
if (type == LightType.BLOCK)
|
||||
|
@ -549,16 +563,6 @@ public class BeltTileEntity extends KineticTileEntity implements ILightUpdateLis
|
|||
if (type == LightType.SKY)
|
||||
updateSkyLight();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private GridAlignedBB getBeltVolume() {
|
||||
BlockPos endPos = BeltHelper.getPositionForOffset(this, beltLength - 1);
|
||||
|
||||
GridAlignedBB bb = GridAlignedBB.from(worldPosition, endPos);
|
||||
bb.fixMinMax();
|
||||
return bb;
|
||||
}
|
||||
|
||||
private void initializeLight() {
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.block.BlockState;
|
|||
|
||||
public class ShaftInstance extends SingleRotatingInstance {
|
||||
|
||||
public ShaftInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||
public ShaftInstance(MaterialManager dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
|
@ -19,14 +19,14 @@ public class SplitShaftInstance extends KineticTileInstance<SplitShaftTileEntity
|
|||
|
||||
protected final ArrayList<RotatingData> keys;
|
||||
|
||||
public SplitShaftInstance(MaterialManager<?> modelManager, SplitShaftTileEntity tile) {
|
||||
public SplitShaftInstance(MaterialManager modelManager, SplitShaftTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
keys = new ArrayList<>(2);
|
||||
|
||||
float speed = tile.getSpeed();
|
||||
|
||||
InstanceMaterial<RotatingData> rotatingMaterial = getRotatingMaterial();
|
||||
Material<RotatingData> rotatingMaterial = getRotatingMaterial();
|
||||
|
||||
for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.ArrayList;
|
|||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
@ -25,7 +25,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns
|
|||
|
||||
protected MatrixStack ms;
|
||||
|
||||
protected GaugeInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||
protected GaugeInstance(MaterialManager dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
|
||||
faces = new ArrayList<>(2);
|
||||
|
@ -145,7 +145,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns
|
|||
}
|
||||
|
||||
public static class Speed extends GaugeInstance {
|
||||
public Speed(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||
public Speed(MaterialManager dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns
|
|||
}
|
||||
|
||||
public static class Stress extends GaugeInstance {
|
||||
public Stress(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||
public Stress(MaterialManager dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Map;
|
|||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||
|
@ -22,7 +22,7 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
|
|||
protected final EnumMap<Direction, RotatingData> keys;
|
||||
protected Direction sourceFacing;
|
||||
|
||||
public GearboxInstance(MaterialManager<?> modelManager, GearboxTileEntity tile) {
|
||||
public GearboxInstance(MaterialManager modelManager, GearboxTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
keys = new EnumMap<>(Direction.class);
|
||||
|
@ -33,7 +33,7 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
|
|||
int skyLight = world.getBrightness(LightType.SKY, pos);
|
||||
updateSourceFacing();
|
||||
|
||||
InstanceMaterial<RotatingData> rotatingMaterial = getRotatingMaterial();
|
||||
Material<RotatingData> rotatingMaterial = getRotatingMaterial();
|
||||
|
||||
for (Direction direction : Iterate.directions) {
|
||||
final Direction.Axis axis = direction.getAxis();
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
|||
|
||||
public class CopperBacktankInstance extends SingleRotatingInstance {
|
||||
|
||||
public CopperBacktankInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||
public CopperBacktankInstance(MaterialManager modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.simibubi.create.content.logistics.block;
|
||||
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.core.materials.IFlatLight;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -30,10 +29,6 @@ public class FlapData extends InstanceData implements IFlatLight<FlapData> {
|
|||
|
||||
private float flapness;
|
||||
|
||||
public FlapData(Instancer<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
public FlapData setPosition(BlockPos pos) {
|
||||
return setPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
@ -105,7 +100,7 @@ public class FlapData extends InstanceData implements IFlatLight<FlapData> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void write(MappedBuffer buf) {
|
||||
public void write(VecBuffer buf) {
|
||||
buf.putVec3(x, y, z);
|
||||
buf.putVec2(blockLight, skyLight);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class BeltTunnelInstance extends TileEntityInstance<BeltTunnelTileEntity>
|
|||
|
||||
private final Map<Direction, ArrayList<FlapData>> tunnelFlaps;
|
||||
|
||||
public BeltTunnelInstance(MaterialManager<?> modelManager, BeltTunnelTileEntity tile) {
|
||||
public BeltTunnelInstance(MaterialManager modelManager, BeltTunnelTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
tunnelFlaps = new EnumMap<>(Direction.class);
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.logistics.block.depot;
|
|||
|
||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -19,7 +19,7 @@ public class EjectorInstance extends ShaftInstance implements IDynamicInstance {
|
|||
|
||||
private float lastProgress = Float.NaN;
|
||||
|
||||
public EjectorInstance(MaterialManager<?> dispatcher, EjectorTileEntity tile) {
|
||||
public EjectorInstance(MaterialManager dispatcher, EjectorTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
this.tile = tile;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
|||
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -16,7 +16,7 @@ public class AdjustableRepeaterInstance extends TileEntityInstance<AdjustableRep
|
|||
|
||||
protected int previousState;
|
||||
|
||||
public AdjustableRepeaterInstance(MaterialManager<?> modelManager, AdjustableRepeaterTileEntity tile) {
|
||||
public AdjustableRepeaterInstance(MaterialManager modelManager, AdjustableRepeaterTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
indicator = modelManager.defaultSolid()
|
||||
|
|
|
@ -20,7 +20,7 @@ public class FunnelInstance extends TileEntityInstance<FunnelTileEntity> impleme
|
|||
|
||||
private final ArrayList<FlapData> flaps;
|
||||
|
||||
public FunnelInstance(MaterialManager<?> modelManager, FunnelTileEntity tile) {
|
||||
public FunnelInstance(MaterialManager modelManager, FunnelTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
flaps = new ArrayList<>(4);
|
||||
|
|
|
@ -6,9 +6,9 @@ import com.google.common.collect.Lists;
|
|||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -44,10 +44,10 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
|
|||
private float upperArmAngle = Float.NaN;
|
||||
private float headAngle = Float.NaN;
|
||||
|
||||
public ArmInstance(MaterialManager<?> modelManager, ArmTileEntity tile) {
|
||||
public ArmInstance(MaterialManager modelManager, ArmTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
InstanceMaterial<ModelData> mat = getTransformMaterial();
|
||||
Material<ModelData> mat = getTransformMaterial();
|
||||
|
||||
base = mat.getModel(AllBlockPartials.ARM_BASE, blockState).createInstance();
|
||||
lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState).createInstance();
|
||||
|
|
|
@ -2,9 +2,9 @@ package com.simibubi.create.content.logistics.block.redstone;
|
|||
|
||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -23,10 +23,10 @@ public class AnalogLeverInstance extends TileEntityInstance<AnalogLeverTileEntit
|
|||
final float rX;
|
||||
final float rY;
|
||||
|
||||
public AnalogLeverInstance(MaterialManager<?> modelManager, AnalogLeverTileEntity tile) {
|
||||
public AnalogLeverInstance(MaterialManager modelManager, AnalogLeverTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
InstanceMaterial<ModelData> mat = getTransformMaterial();
|
||||
Material<ModelData> mat = getTransformMaterial();
|
||||
|
||||
handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState).createInstance();
|
||||
indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState).createInstance();
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.simibubi.create.content.schematics.block;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||
import com.jozufozu.flywheel.backend.material.InstanceMaterial;
|
||||
import com.jozufozu.flywheel.backend.material.Material;
|
||||
import com.jozufozu.flywheel.backend.material.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -17,10 +17,10 @@ public class SchematicannonInstance extends TileEntityInstance<SchematicannonTil
|
|||
private final ModelData connector;
|
||||
private final ModelData pipe;
|
||||
|
||||
public SchematicannonInstance(MaterialManager<?> modelManager, SchematicannonTileEntity tile) {
|
||||
public SchematicannonInstance(MaterialManager modelManager, SchematicannonTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
||||
InstanceMaterial<ModelData> mat = getTransformMaterial();
|
||||
Material<ModelData> mat = getTransformMaterial();
|
||||
|
||||
connector = mat.getModel(AllBlockPartials.SCHEMATICANNON_CONNECTOR, blockState).createInstance();
|
||||
pipe = mat.getModel(AllBlockPartials.SCHEMATICANNON_PIPE, blockState).createInstance();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import com.jozufozu.flywheel.backend.material.MaterialSpec;
|
||||
import com.jozufozu.flywheel.backend.struct.BasicStructType;
|
||||
import com.jozufozu.flywheel.backend.struct.StructType;
|
||||
import com.jozufozu.flywheel.core.Formats;
|
||||
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||
import com.simibubi.create.Create;
|
||||
|
@ -19,10 +21,15 @@ public class AllMaterialSpecs {
|
|||
// noop, make sure the static field are loaded.
|
||||
}
|
||||
|
||||
public static final MaterialSpec<RotatingData> ROTATING = new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, Formats.UNLIT_MODEL, AllInstanceFormats.ROTATING, RotatingData::new);
|
||||
public static final MaterialSpec<BeltData> BELTS = new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, Formats.UNLIT_MODEL, AllInstanceFormats.BELT, BeltData::new);
|
||||
public static final MaterialSpec<ActorData> ACTORS = new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, Formats.UNLIT_MODEL, AllInstanceFormats.ACTOR, ActorData::new);
|
||||
public static final MaterialSpec<FlapData> FLAPS = new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, Formats.UNLIT_MODEL, AllInstanceFormats.FLAP, FlapData::new);
|
||||
public static final StructType<RotatingData> ROTATING_TYPE = new BasicStructType<>(RotatingData::new, AllInstanceFormats.ROTATING);
|
||||
public static final StructType<BeltData> BELTS_TYPE = new BasicStructType<>(BeltData::new, AllInstanceFormats.BELT);
|
||||
public static final StructType<ActorData> ACTORS_TYPE = new BasicStructType<>(ActorData::new, AllInstanceFormats.ACTOR);
|
||||
public static final StructType<FlapData> FLAPS_TYPE = new BasicStructType<>(FlapData::new, AllInstanceFormats.FLAP);
|
||||
|
||||
public static final MaterialSpec<RotatingData> ROTATING = new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, Formats.UNLIT_MODEL, ROTATING_TYPE);
|
||||
public static final MaterialSpec<BeltData> BELTS = new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, Formats.UNLIT_MODEL, BELTS_TYPE);
|
||||
public static final MaterialSpec<ActorData> ACTORS = new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, Formats.UNLIT_MODEL, ACTORS_TYPE);
|
||||
public static final MaterialSpec<FlapData> FLAPS = new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, Formats.UNLIT_MODEL, FLAPS_TYPE);
|
||||
|
||||
public static void flwInit(GatherContextEvent event) {
|
||||
event.getBackend().register(ROTATING);
|
||||
|
|
|
@ -3,9 +3,14 @@ package com.simibubi.create.foundation.render;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.source.FileResolution;
|
||||
import com.jozufozu.flywheel.util.ResourceUtil;
|
||||
import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||
import com.jozufozu.flywheel.backend.loading.ModelTemplate;
|
||||
import com.jozufozu.flywheel.backend.pipeline.IShaderPipeline;
|
||||
import com.jozufozu.flywheel.backend.pipeline.InstancingTemplate;
|
||||
import com.jozufozu.flywheel.backend.pipeline.OneShotTemplate;
|
||||
import com.jozufozu.flywheel.backend.pipeline.WorldShaderPipeline;
|
||||
import com.jozufozu.flywheel.backend.source.Resolver;
|
||||
import com.jozufozu.flywheel.core.WorldContext;
|
||||
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram;
|
||||
|
@ -25,17 +30,17 @@ public class CreateContexts {
|
|||
Backend backend = event.getBackend();
|
||||
|
||||
SpecMetaRegistry.register(RainbowDebugStateProvider.INSTANCE);
|
||||
FileResolution header = Resolver.INSTANCE.findShader(ResourceUtil.subPath(CONTRAPTION, ".glsl"));
|
||||
|
||||
CWORLD = backend.register(contraptionContext(backend));
|
||||
STRUCTURE = backend.register(contraptionContext(backend)
|
||||
.withSpecStream(() -> Stream.of(AllProgramSpecs.STRUCTURE))
|
||||
.withTemplateFactory(ModelTemplate::new));
|
||||
IShaderPipeline<ContraptionProgram> instancing = new WorldShaderPipeline<>(ContraptionProgram::new, InstancingTemplate.INSTANCE, header);
|
||||
IShaderPipeline<ContraptionProgram> structure = new WorldShaderPipeline<>(ContraptionProgram::new, OneShotTemplate.INSTANCE, header);
|
||||
|
||||
CWORLD = backend.register(WorldContext.builder(backend, CONTRAPTION)
|
||||
.build(instancing));
|
||||
|
||||
STRUCTURE = backend.register(WorldContext.builder(backend, CONTRAPTION)
|
||||
.setSpecStream(() -> Stream.of(AllProgramSpecs.STRUCTURE))
|
||||
.build(structure));
|
||||
}
|
||||
|
||||
private static WorldContext<ContraptionProgram> contraptionContext(Backend backend) {
|
||||
return new WorldContext<>(backend, ContraptionProgram::new)
|
||||
.withName(CONTRAPTION)
|
||||
.withBuiltin(ShaderType.FRAGMENT, CONTRAPTION, "/builtin.frag")
|
||||
.withBuiltin(ShaderType.VERTEX, CONTRAPTION, "/builtin.vert");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"vert": "create:belt.vert",
|
||||
"frag": "flywheel:block.frag",
|
||||
"source": "create:belt.vert",
|
||||
"states": [
|
||||
{
|
||||
"when": "create:rainbow_debug",
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"vert": "create:contraption_actor.vert",
|
||||
"frag": "flywheel:block.frag",
|
||||
"source": "create:contraption_actor.vert",
|
||||
"states": [
|
||||
{
|
||||
"when": {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"vert": "create:contraption_structure.vert",
|
||||
"frag": "flywheel:block.frag",
|
||||
"source": "create:contraption_structure.vert",
|
||||
"states": [
|
||||
{
|
||||
"when": {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"vert": "create:flap.vert",
|
||||
"frag": "flywheel:block.frag",
|
||||
"source": "create:flap.vert",
|
||||
"states": [
|
||||
{
|
||||
"when": {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"vert": "create:rotating.vert",
|
||||
"frag": "flywheel:block.frag",
|
||||
"source": "create:rotating.vert",
|
||||
"states": [
|
||||
{
|
||||
"when": "create:rainbow_debug",
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#define PI 3.1415926538
|
||||
|
||||
#flwbuiltins
|
||||
#flwinclude <"flywheel:core/quaternion.glsl">
|
||||
#flwinclude <"flywheel:core/matutils.glsl">
|
||||
#flwinclude <"flywheel:core/diffuse.glsl">
|
||||
#use "flywheel:core/quaternion.glsl"
|
||||
#use "flywheel:core/matutils.glsl"
|
||||
#use "flywheel:core/diffuse.glsl"
|
||||
|
||||
#[InstanceData]
|
||||
struct Belt {
|
||||
vec2 light;
|
||||
vec4 color;
|
||||
|
@ -18,10 +16,11 @@ struct Belt {
|
|||
float scrollMult;
|
||||
};
|
||||
|
||||
#flwinclude <"flywheel:data/modelvertex.glsl">
|
||||
#flwinclude <"flywheel:data/blockfragment.glsl">
|
||||
#use "flywheel:data/modelvertex.glsl"
|
||||
#use "flywheel:block.frag"
|
||||
|
||||
BlockFrag FLWMain(Vertex v, Belt instance) {
|
||||
#if defined(VERTEX_SHADER)
|
||||
BlockFrag vertex(Vertex v, Belt instance) {
|
||||
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
|
||||
|
||||
vec4 worldPos = vec4(rotated, 1.);
|
||||
|
@ -49,3 +48,4 @@ BlockFrag FLWMain(Vertex v, Belt instance) {
|
|||
|
||||
return b;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
#use "flywheel:context/fog.glsl"
|
||||
|
||||
varying vec3 BoxCoord;
|
||||
|
||||
uniform sampler3D uLightVolume;
|
||||
|
||||
uniform sampler2D uBlockAtlas;
|
||||
uniform sampler2D uLightMap;
|
||||
|
||||
uniform vec3 uLightBoxSize;
|
||||
uniform vec3 uLightBoxMin;
|
||||
uniform mat4 uModel;
|
||||
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
uniform vec2 uWindowSize;
|
||||
|
||||
void FLWFinalizeNormal(inout vec3 normal) {
|
||||
mat3 m;
|
||||
m[0] = uModel[0].xyz;
|
||||
m[1] = uModel[1].xyz;
|
||||
m[2] = uModel[2].xyz;
|
||||
normal = m * normal;
|
||||
}
|
||||
|
||||
#if defined(VERTEX_SHADER)
|
||||
|
||||
void FLWFinalizeWorldPos(inout vec4 worldPos) {
|
||||
worldPos = uModel * worldPos;
|
||||
|
||||
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
|
||||
|
||||
#if defined(USE_FOG)
|
||||
FragDistance = length(worldPos.xyz);
|
||||
#endif
|
||||
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT_SHADER)
|
||||
#use "flywheel:core/lightutil.glsl"
|
||||
|
||||
vec4 FLWBlockTexture(vec2 texCoords) {
|
||||
return texture2D(uBlockAtlas, texCoords);
|
||||
}
|
||||
|
||||
void FLWFinalizeColor(vec4 color) {
|
||||
#if defined(USE_FOG)
|
||||
float a = color.a;
|
||||
float fog = clamp(FLWFogFactor(), 0., 1.);
|
||||
|
||||
color = mix(uFogColor, color, fog);
|
||||
color.a = a;
|
||||
#endif
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
||||
vec4 FLWLight(vec2 lightCoords) {
|
||||
lightCoords = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg);
|
||||
|
||||
return texture2D(uLightMap, shiftLight(lightCoords));
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||
#flwinclude <"flywheel:context/world/fog.glsl">
|
||||
#flwinclude <"flywheel:core/lightutil.glsl">
|
||||
|
||||
varying vec3 BoxCoord;
|
||||
varying vec2 BoxLight;
|
||||
uniform sampler3D uLightVolume;
|
||||
|
||||
uniform sampler2D uBlockAtlas;
|
||||
uniform sampler2D uLightMap;
|
||||
|
||||
vec4 FLWBlockTexture(vec2 texCoords) {
|
||||
return texture2D(uBlockAtlas, texCoords);
|
||||
}
|
||||
|
||||
void FLWFinalizeColor(vec4 color) {
|
||||
#if defined(USE_FOG)
|
||||
float a = color.a;
|
||||
float fog = clamp(FLWFogFactor(), 0., 1.);
|
||||
|
||||
color = mix(uFogColor, color, fog);
|
||||
color.a = a;
|
||||
#endif
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
||||
vec4 FLWLight(vec2 lightCoords) {
|
||||
lightCoords = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg);
|
||||
|
||||
return texture2D(uLightMap, shiftLight(lightCoords));
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
#if defined(USE_FOG)
|
||||
varying float FragDistance;
|
||||
#endif
|
||||
|
||||
varying vec3 BoxCoord;
|
||||
|
||||
uniform vec3 uLightBoxSize;
|
||||
uniform vec3 uLightBoxMin;
|
||||
uniform mat4 uModel;
|
||||
|
||||
uniform float uTime;
|
||||
uniform mat4 uViewProjection;
|
||||
uniform vec3 uCameraPos;
|
||||
|
||||
void FLWFinalizeWorldPos(inout vec4 worldPos) {
|
||||
worldPos = uModel * worldPos;
|
||||
|
||||
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
|
||||
|
||||
#if defined(USE_FOG)
|
||||
FragDistance = length(worldPos.xyz);
|
||||
#endif
|
||||
|
||||
gl_Position = uViewProjection * worldPos;
|
||||
}
|
||||
|
||||
void FLWFinalizeNormal(inout vec3 normal) {
|
||||
mat3 m;
|
||||
m[0] = uModel[0].xyz;
|
||||
m[1] = uModel[1].xyz;
|
||||
m[2] = uModel[2].xyz;
|
||||
normal = m * normal;
|
||||
}
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
#define PI 3.1415926538
|
||||
|
||||
#flwbuiltins
|
||||
#flwinclude <"flywheel:core/matutils.glsl">
|
||||
#flwinclude <"flywheel:core/quaternion.glsl">
|
||||
#flwinclude <"flywheel:core/diffuse.glsl">
|
||||
#use "flywheel:core/matutils.glsl"
|
||||
#use "flywheel:core/quaternion.glsl"
|
||||
#use "flywheel:core/diffuse.glsl"
|
||||
|
||||
#[InstanceData]
|
||||
struct Actor {
|
||||
vec3 pos;
|
||||
vec2 light;
|
||||
|
@ -16,10 +14,11 @@ struct Actor {
|
|||
float speed;
|
||||
};
|
||||
|
||||
#flwinclude <"flywheel:data/modelvertex.glsl">
|
||||
#flwinclude <"flywheel:data/blockfragment.glsl">
|
||||
#use "flywheel:data/modelvertex.glsl"
|
||||
#use "flywheel:block.frag"
|
||||
|
||||
BlockFrag FLWMain(Vertex v, Actor instance) {
|
||||
#if defined(VERTEX_SHADER)
|
||||
BlockFrag vertex(Vertex v, Actor instance) {
|
||||
float degrees = instance.offset + uTime * instance.speed / 20.;
|
||||
//float angle = fract(degrees / 360.) * PI * 2.;
|
||||
|
||||
|
@ -45,3 +44,4 @@ BlockFrag FLWMain(Vertex v, Actor instance) {
|
|||
|
||||
return b;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#define PI 3.1415926538
|
||||
|
||||
#flwbuiltins
|
||||
#flwinclude <"flywheel:core/matutils.glsl">
|
||||
#flwinclude <"flywheel:core/diffuse.glsl">
|
||||
#use "flywheel:core/matutils.glsl"
|
||||
#use "flywheel:core/diffuse.glsl"
|
||||
|
||||
#[VertexData]
|
||||
struct Vertex {
|
||||
vec3 pos;
|
||||
vec3 normal;
|
||||
|
@ -13,9 +11,10 @@ struct Vertex {
|
|||
vec2 modelLight;
|
||||
};
|
||||
|
||||
#flwinclude <"flywheel:data/blockfragment.glsl">
|
||||
#use "flywheel:block.frag"
|
||||
|
||||
BlockFrag FLWMain(Vertex v) {
|
||||
#if defined(VERTEX_SHADER)
|
||||
BlockFrag vertex(Vertex v) {
|
||||
vec4 worldPos = vec4(v.pos, 1.);
|
||||
vec3 norm = v.normal;
|
||||
|
||||
|
@ -35,3 +34,4 @@ BlockFrag FLWMain(Vertex v) {
|
|||
|
||||
return b;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#define PI 3.1415926538
|
||||
|
||||
#flwbuiltins
|
||||
#flwinclude <"flywheel:core/matutils.glsl">
|
||||
#flwinclude <"flywheel:core/quaternion.glsl">
|
||||
#flwinclude <"flywheel:core/diffuse.glsl">
|
||||
#use "flywheel:core/matutils.glsl"
|
||||
#use "flywheel:core/quaternion.glsl"
|
||||
#use "flywheel:core/diffuse.glsl"
|
||||
|
||||
#[InstanceData]
|
||||
struct Flap {
|
||||
vec3 instancePos;
|
||||
vec2 light;
|
||||
|
@ -17,9 +15,10 @@ struct Flap {
|
|||
float flapness;
|
||||
};
|
||||
|
||||
#flwinclude <"flywheel:data/modelvertex.glsl">
|
||||
#flwinclude <"flywheel:data/blockfragment.glsl">
|
||||
#use "flywheel:data/modelvertex.glsl"
|
||||
#use "flywheel:block.frag"
|
||||
|
||||
#if defined(VERTEX_SHADER)
|
||||
|
||||
float toRad(float degrees) {
|
||||
return fract(degrees / 360.) * PI * 2.;
|
||||
|
@ -38,7 +37,7 @@ float getFlapAngle(float flapness, float intensity, float scale) {
|
|||
return degrees;
|
||||
}
|
||||
|
||||
BlockFrag FLWMain(Vertex v, Flap flap) {
|
||||
BlockFrag vertex(Vertex v, Flap flap) {
|
||||
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
|
||||
|
||||
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
|
||||
|
@ -64,3 +63,4 @@ BlockFrag FLWMain(Vertex v, Flap flap) {
|
|||
#endif
|
||||
return b;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#define PI 3.1415926538
|
||||
|
||||
#flwbuiltins
|
||||
#flwinclude <"flywheel:core/matutils.glsl">
|
||||
#flwinclude <"flywheel:core/diffuse.glsl">
|
||||
#use "flywheel:core/matutils.glsl"
|
||||
#use "flywheel:core/diffuse.glsl"
|
||||
|
||||
#[InstanceData]
|
||||
struct Rotating {
|
||||
vec2 light;
|
||||
vec4 color;
|
||||
|
@ -14,8 +12,8 @@ struct Rotating {
|
|||
vec3 axis;
|
||||
};
|
||||
|
||||
#flwinclude <"flywheel:data/modelvertex.glsl">
|
||||
#flwinclude <"flywheel:data/blockfragment.glsl">
|
||||
#use "flywheel:data/modelvertex.glsl"
|
||||
#use "flywheel:block.frag"
|
||||
|
||||
mat4 kineticRotation(float offset, float speed, vec3 axis) {
|
||||
float degrees = offset + uTime * speed * 3./10.;
|
||||
|
@ -24,7 +22,8 @@ mat4 kineticRotation(float offset, float speed, vec3 axis) {
|
|||
return rotate(axis, angle);
|
||||
}
|
||||
|
||||
BlockFrag FLWMain(Vertex v, Rotating instance) {
|
||||
#if defined(VERTEX_SHADER)
|
||||
BlockFrag vertex(Vertex v, Rotating instance) {
|
||||
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
|
||||
|
||||
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
|
||||
|
@ -50,3 +49,4 @@ BlockFrag FLWMain(Vertex v, Rotating instance) {
|
|||
|
||||
return b;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue