Better config/backend to account for multiple engines

- Rename probably too many things
 - Needs to be tested with Optifine
This commit is contained in:
Jozufozu 2021-12-22 21:35:49 -08:00
parent 97490e51ca
commit 748c25b3ec
38 changed files with 47 additions and 53 deletions

View file

@ -38,7 +38,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
for (RenderType type : RenderType.chunkBufferLayers())
if (ItemBlockRenderTypes.canRenderInLayer(te.getBlockState(), type))
@ -97,7 +97,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
float offset = ICogWheel.isLargeCog(te.getBlockState()) ? 11.25f : 0;
double d = (((axis == Axis.X) ? 0 : pos.getX()) + ((axis == Axis.Y) ? 0 : pos.getY())
+ ((axis == Axis.Z) ? 0 : pos.getZ())) % 2;
if (d == 0)
if (d == 0)
offset = 22.5f;
return offset;
}

View file

@ -37,7 +37,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
@OnlyIn(value = Dist.CLIENT)
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
if (!Backend.getInstance().canUseInstancing())
if (!Backend.isOn())
DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer);
}

View file

@ -58,8 +58,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
@Override
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffers) {
if (!Backend.getInstance()
.canUseInstancing())
if (!Backend.isOn())
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
}

View file

@ -169,8 +169,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
BlockState blockState = te.getBlockState();
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
if (!Backend.getInstance()
.canUseInstancing(te.getLevel())) {
if (!Backend.canUseInstancing(te.getLevel())) {
SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
standardKineticRotationTransform(superBuffer, te, light);
superBuffer.rotateCentered(Direction.UP, (float) (blockState.getValue(HORIZONTAL_FACING)

View file

@ -28,7 +28,7 @@ public class HandCrankRenderer extends KineticTileEntityRenderer {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState state = te.getBlockState();
Block block = state.getBlock();

View file

@ -257,7 +257,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
@Override
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffers) {
if (!Backend.getInstance().canUseInstancing())
if (!Backend.isOn())
DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers);
}

View file

@ -54,7 +54,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
renderItem(te, partialTicks, ms, buffer, light, overlay);
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
renderComponents(te, partialTicks, ms, buffer, light, overlay);
}
@ -113,7 +113,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
protected void renderComponents(DeployerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
if (!Backend.canUseInstancing(te.getLevel())) {
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light);
}
@ -193,10 +193,10 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
IRotate def = (IRotate) context.state.getBlock();
axis = def.getRotationAxis(context.state);
}
float time = AnimationTickHolder.getRenderTime(context.world) / 20;
float angle = (time * speed) % 360;
new MatrixTransformStack(m)
.centre()
.rotateY(axis == Axis.Z ? 90 : 0)

View file

@ -28,7 +28,7 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer {
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
Direction direction = te.getBlockState()
.getValue(FACING);

View file

@ -36,7 +36,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState blockState = te.getBlockState();
FlywheelTileEntity wte = (FlywheelTileEntity) te;

View file

@ -22,7 +22,7 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light,
int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
Block block = te.getBlockState()
.getBlock();

View file

@ -31,7 +31,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState blockState = te.getBlockState();
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;

View file

@ -31,7 +31,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState blockState = te.getBlockState();
float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks);

View file

@ -46,8 +46,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
renderItems(te, partialTicks, ms, buffer, light, overlay);
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance()
.canUseInstancing(te.getLevel()))
if (Backend.canUseInstancing(te.getLevel()))
return;
renderShaft(te, ms, buffer, light, overlay);

View file

@ -26,7 +26,7 @@ public class BearingRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);

View file

@ -34,7 +34,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
@OnlyIn(Dist.CLIENT)
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
if (Backend.getInstance().canUseInstancing()) return;
if (Backend.isOn()) return;
Direction facing = context.state.getValue(BlockStateProperties.FACING);
PartialModel top = AllBlockPartials.BEARING_TOP;

View file

@ -25,7 +25,7 @@ public class StickerRenderer extends SafeTileEntityRenderer<StickerTileEntity> {
protected void renderSafe(StickerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState state = te.getBlockState();
SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.STICKER_HEAD, state);

View file

@ -31,7 +31,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState state = te.getBlockState();
Direction facing = state.getValue(GantryCarriageBlock.FACING);

View file

@ -44,8 +44,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance()
.canUseInstancing(te.getLevel()))
if (Backend.canUseInstancing(te.getLevel()))
return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);

View file

@ -178,7 +178,7 @@ public class ContraptionRenderDispatcher {
public static void reset() {
WORLDS.empty(ContraptionRenderManager::delete);
if (Backend.getInstance().available()) {
if (Backend.isOn()) {
WORLDS = new WorldAttached<>(FlwContraptionManager::new);
} else {
WORLDS = new WorldAttached<>(SBBContraptionManager::new);

View file

@ -58,7 +58,7 @@ public class FlwContraptionManager extends ContraptionRenderManager<RenderedCont
GlVertexArray.unbind();
if (Backend.getInstance().canUseInstancing()) {
if (Backend.isOn()) {
RenderLayer renderLayer = event.getLayer();
if (renderLayer != null) {
for (RenderedContraption renderer : visible) {

View file

@ -55,7 +55,7 @@ public class RenderedContraption extends ContraptionRenderInfo {
this.engine.addListener(this.kinetics);
buildLayers();
if (Backend.getInstance().canUseInstancing()) {
if (Backend.isOn()) {
buildInstancedTiles();
buildActors();
}

View file

@ -27,7 +27,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
BlockState blockState = te.getBlockState();

View file

@ -31,7 +31,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedContro
super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay);
VertexConsumer builder = buffer.getBuffer(RenderType.solid());
if (!Backend.getInstance().canUseInstancing(tileEntityIn.getLevel())) {
if (!Backend.canUseInstancing(tileEntityIn.getLevel())) {
KineticTileEntityRenderer.renderRotatingBuffer(tileEntityIn, getRotatedModel(tileEntityIn), ms, builder, light);
}

View file

@ -55,7 +55,7 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
protected void renderSafe(BeltTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
if (!Backend.canUseInstancing(te.getLevel())) {
BlockState blockState = te.getBlockState();
if (!AllBlocks.BELT.has(blockState)) return;

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.relays.elementary;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials;
@ -59,10 +59,11 @@ public class BracketedKineticTileInstance extends SingleRotatingInstance {
private PoseStack rotateToAxis(Axis axis) {
Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
PoseStack poseStack = new PoseStack();
new MatrixTransformStack(poseStack).centre()
.rotateToFace(facing)
.multiply(Vector3f.XN.rotationDegrees(-90))
.unCentre();
TransformStack.cast(poseStack)
.centre()
.rotateToFace(facing)
.multiply(Vector3f.XN.rotationDegrees(-90))
.unCentre();
return poseStack;
}

View file

@ -28,8 +28,7 @@ public class BracketedKineticTileRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance()
.canUseInstancing(te.getLevel()))
if (Backend.canUseInstancing(te.getLevel()))
return;
if (!AllBlocks.LARGE_COGWHEEL.has(te.getBlockState())) {

View file

@ -39,8 +39,7 @@ public class EncasedCogRenderer extends KineticTileEntityRenderer {
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance()
.canUseInstancing(te.getLevel()))
if (Backend.canUseInstancing(te.getLevel()))
return;
BlockState blockState = te.getBlockState();

View file

@ -28,7 +28,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer {
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
Block block = te.getBlockState().getBlock();
final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState());

View file

@ -39,7 +39,7 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);

View file

@ -27,7 +27,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer {
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
final Axis boxAxis = te.getBlockState().getValue(BlockStateProperties.AXIS);
final BlockPos pos = te.getBlockPos();

View file

@ -31,7 +31,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
SuperByteBuffer flapBuffer = CachedBufferer.partial(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
VertexConsumer vb = buffer.getBuffer(RenderType.solid());

View file

@ -47,7 +47,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer {
float lidProgress = ((EjectorTileEntity) te).getLidProgress(partialTicks);
float angle = lidProgress * 70;
if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
if (!Backend.canUseInstancing(te.getLevel())) {
SuperByteBuffer model = CachedBufferer.partial(AllBlockPartials.EJECTOR_TOP, te.getBlockState());
applyLidAngle(te, angle, model);
model.light(light)

View file

@ -30,7 +30,7 @@ public class FunnelRenderer extends SmartTileEntityRenderer<FunnelTileEntity> {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (!te.hasFlap() || Backend.getInstance().canUseInstancing(te.getLevel()))
if (!te.hasFlap() || Backend.canUseInstancing(te.getLevel()))
return;
BlockState blockState = te.getBlockState();

View file

@ -44,7 +44,7 @@ public class ArmRenderer extends KineticTileEntityRenderer {
ArmTileEntity arm = (ArmTileEntity) te;
ItemStack item = arm.heldItem;
boolean hasItem = !item.isEmpty();
boolean usingFlywheel = Backend.getInstance().canUseInstancing(te.getLevel());
boolean usingFlywheel = Backend.canUseInstancing(te.getLevel());
if (usingFlywheel && !hasItem) return;

View file

@ -26,7 +26,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
BlockState leverState = te.getBlockState();
float state = te.clientState.get(partialTicks);

View file

@ -43,8 +43,7 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
if (blocksLaunching)
renderLaunchedBlocks(tileEntity, partialTicks, ms, buffer, light, overlay);
if (Backend.getInstance()
.canUseInstancing(tileEntity.getLevel()))
if (Backend.canUseInstancing(tileEntity.getLevel()))
return;
BlockPos pos = tileEntity.getBlockPos();

View file

@ -48,7 +48,7 @@ public class TileEntityRenderHelper {
Iterator<BlockEntity> iterator = customRenderTEs.iterator();
while (iterator.hasNext()) {
BlockEntity tileEntity = iterator.next();
if (Backend.getInstance().canUseInstancing(renderWorld) && InstancedRenderRegistry.getInstance()
if (Backend.canUseInstancing(renderWorld) && InstancedRenderRegistry.getInstance()
.shouldSkipRender(tileEntity)) continue;
BlockEntityRenderer<BlockEntity> renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(tileEntity);

View file

@ -18,7 +18,7 @@ public abstract class ColoredOverlayTileEntityRenderer<T extends BlockEntity> ex
protected void renderSafe(T te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
if (Backend.canUseInstancing(te.getLevel())) return;
SuperByteBuffer render = render(getOverlayBuffer(te), getColor(te, partialTicks), light);
render.renderInto(ms, buffer.getBuffer(RenderType.solid()));