Fix client

This commit is contained in:
yuesha-yc 2022-02-21 23:39:28 -08:00
parent eecc7849a8
commit 34da8bd0f5
No known key found for this signature in database
GPG key ID: 009D79A802D4ED01
6 changed files with 62 additions and 67 deletions

View file

@ -21,19 +21,15 @@ package com.teammoeg.steampowered.client.instance;
import com.google.common.collect.Lists;
import com.jozufozu.flywheel.api.InstanceData;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
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.MaterialManager;
import com.jozufozu.flywheel.core.materials.ModelData;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
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.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
import com.simibubi.create.content.contraptions.base.RotatingData;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
@ -52,7 +48,7 @@ import java.util.List;
import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
public class BronzeFlywheelInstance extends KineticTileInstance<FlywheelTileEntity> implements IDynamicInstance {
public class BronzeFlywheelInstance extends KineticTileInstance<FlywheelTileEntity> implements DynamicInstance {
protected final Direction facing;
protected final Direction connection;
@ -71,7 +67,7 @@ public class BronzeFlywheelInstance extends KineticTileInstance<FlywheelTileEnti
protected float lastAngle = Float.NaN;
public BronzeFlywheelInstance(MaterialManager<?> modelManager, FlywheelTileEntity tile) {
public BronzeFlywheelInstance(MaterialManager modelManager, FlywheelTileEntity tile) {
super(modelManager, tile);
facing = blockState.getValue(HORIZONTAL_FACING);
@ -89,7 +85,7 @@ public class BronzeFlywheelInstance extends KineticTileInstance<FlywheelTileEnti
connectorAngleMult = flipAngle ? -1 : 1;
InstanceMaterial<ModelData> mat = getTransformMaterial();
Material<ModelData> mat = getTransformMaterial();
upperRotating = mat.getModel(SPBlockPartials.BRONZE_FLYWHEEL_UPPER_ROTATING, blockState).createInstance();
lowerRotating = mat.getModel(SPBlockPartials.BRONZE_FLYWHEEL_LOWER_ROTATING, blockState).createInstance();
@ -112,7 +108,7 @@ public class BronzeFlywheelInstance extends KineticTileInstance<FlywheelTileEnti
float partialTicks = AnimationTickHolder.getPartialTicks();
// Mixin
FlywheelTileEntityAccess access = (FlywheelTileEntityAccess) tile;
FlywheelTileEntityAccess access = (FlywheelTileEntityAccess) blockEntity;
float speed = access.getVisualSpeed().get(partialTicks) * 3 / 10f;
float angle = access.getAngle() + speed * partialTicks;
@ -125,7 +121,7 @@ public class BronzeFlywheelInstance extends KineticTileInstance<FlywheelTileEnti
private void animate(float angle) {
PoseStack ms = new PoseStack();
MatrixTransformStack msr = MatrixTransformStack.of(ms);
TransformStack msr = TransformStack.cast(ms);
msr.translate(getInstancePosition());
@ -193,7 +189,7 @@ public class BronzeFlywheelInstance extends KineticTileInstance<FlywheelTileEnti
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite);
}
protected void transformConnector(MatrixTransformStack ms, boolean upper, boolean rotating, float angle, boolean flip) {
protected void transformConnector(TransformStack ms, boolean upper, boolean rotating, float angle, boolean flip) {
float shift = upper ? 1 / 4f : -1 / 8f;
float offset = upper ? 1 / 4f : 1 / 4f;
float radians = (float) (angle / 180 * Math.PI);
@ -219,7 +215,7 @@ public class BronzeFlywheelInstance extends KineticTileInstance<FlywheelTileEnti
ms.translate(9 / 16f, 0, 0);
}
protected void rotateToFacing(MatrixTransformStack buffer, Direction facing) {
protected void rotateToFacing(TransformStack buffer, Direction facing) {
buffer.centre()
.rotate(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing)))
.unCentre();

View file

@ -21,15 +21,11 @@ package com.teammoeg.steampowered.client.instance;
import com.google.common.collect.Lists;
import com.jozufozu.flywheel.api.InstanceData;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
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.MaterialManager;
import com.jozufozu.flywheel.core.materials.ModelData;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
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.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
@ -51,7 +47,7 @@ import java.util.List;
import static com.simibubi.create.content.logistics.block.funnel.AbstractHorizontalFunnelBlock.HORIZONTAL_FACING;
public class CastIronFlywheelInstance extends KineticTileInstance<FlywheelTileEntity> implements IDynamicInstance {
public class CastIronFlywheelInstance extends KineticTileInstance<FlywheelTileEntity> implements DynamicInstance {
protected final Direction facing;
protected final Direction connection;
@ -88,7 +84,7 @@ public class CastIronFlywheelInstance extends KineticTileInstance<FlywheelTileEn
connectorAngleMult = flipAngle ? -1 : 1;
InstanceMaterial<ModelData> mat = getTransformMaterial();
Material<ModelData> mat = getTransformMaterial();
upperRotating = mat.getModel(SPBlockPartials.CAST_IRON_FLYWHEEL_UPPER_ROTATING, blockState).createInstance();
lowerRotating = mat.getModel(SPBlockPartials.CAST_IRON_FLYWHEEL_LOWER_ROTATING, blockState).createInstance();
@ -111,7 +107,7 @@ public class CastIronFlywheelInstance extends KineticTileInstance<FlywheelTileEn
float partialTicks = AnimationTickHolder.getPartialTicks();
// Mixin
FlywheelTileEntityAccess access = (FlywheelTileEntityAccess) tile;
FlywheelTileEntityAccess access = (FlywheelTileEntityAccess) blockEntity;
float speed = access.getVisualSpeed().get(partialTicks) * 3 / 10f;
float angle = access.getAngle() + speed * partialTicks;
@ -124,7 +120,7 @@ public class CastIronFlywheelInstance extends KineticTileInstance<FlywheelTileEn
private void animate(float angle) {
PoseStack ms = new PoseStack();
MatrixTransformStack msr = MatrixTransformStack.of(ms);
TransformStack msr = TransformStack.cast(ms);
msr.translate(getInstancePosition());
@ -192,7 +188,7 @@ public class CastIronFlywheelInstance extends KineticTileInstance<FlywheelTileEn
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite);
}
protected void transformConnector(MatrixTransformStack ms, boolean upper, boolean rotating, float angle, boolean flip) {
protected void transformConnector(TransformStack ms, boolean upper, boolean rotating, float angle, boolean flip) {
float shift = upper ? 1 / 4f : -1 / 8f;
float offset = upper ? 1 / 4f : 1 / 4f;
float radians = (float) (angle / 180 * Math.PI);
@ -218,7 +214,7 @@ public class CastIronFlywheelInstance extends KineticTileInstance<FlywheelTileEn
ms.translate(9 / 16f, 0, 0);
}
protected void rotateToFacing(MatrixTransformStack buffer, Direction facing) {
protected void rotateToFacing(TransformStack buffer, Direction facing) {
buffer.centre()
.rotate(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing)))
.unCentre();

View file

@ -21,9 +21,12 @@ package com.teammoeg.steampowered.client.instance;
import com.google.common.collect.Lists;
import com.jozufozu.flywheel.api.InstanceData;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
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.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
@ -45,7 +48,7 @@ import java.util.List;
import static com.simibubi.create.content.contraptions.base.HorizontalKineticBlock.HORIZONTAL_FACING;
public class SteelFlywheelInstance extends KineticTileInstance<FlywheelTileEntity> implements IDynamicInstance {
public class SteelFlywheelInstance extends KineticTileInstance<FlywheelTileEntity> implements DynamicInstance {
protected final Direction facing;
protected final Direction connection;
@ -64,7 +67,7 @@ public class SteelFlywheelInstance extends KineticTileInstance<FlywheelTileEntit
protected float lastAngle = Float.NaN;
public SteelFlywheelInstance(MaterialManager<?> modelManager, FlywheelTileEntity tile) {
public SteelFlywheelInstance(MaterialManager modelManager, FlywheelTileEntity tile) {
super(modelManager, tile);
facing = blockState.getValue(HORIZONTAL_FACING);
@ -82,7 +85,7 @@ public class SteelFlywheelInstance extends KineticTileInstance<FlywheelTileEntit
connectorAngleMult = flipAngle ? -1 : 1;
InstanceMaterial<ModelData> mat = getTransformMaterial();
Material<ModelData> mat = getTransformMaterial();
upperRotating = mat.getModel(SPBlockPartials.STEEL_FLYWHEEL_UPPER_ROTATING, blockState).createInstance();
lowerRotating = mat.getModel(SPBlockPartials.STEEL_FLYWHEEL_LOWER_ROTATING, blockState).createInstance();
@ -105,7 +108,7 @@ public class SteelFlywheelInstance extends KineticTileInstance<FlywheelTileEntit
float partialTicks = AnimationTickHolder.getPartialTicks();
// Mixin
FlywheelTileEntityAccess access = (FlywheelTileEntityAccess) tile;
FlywheelTileEntityAccess access = (FlywheelTileEntityAccess) blockEntity;
float speed = access.getVisualSpeed().get(partialTicks) * 3 / 10f;
float angle = access.getAngle() + speed * partialTicks;
@ -118,7 +121,7 @@ public class SteelFlywheelInstance extends KineticTileInstance<FlywheelTileEntit
private void animate(float angle) {
PoseStack ms = new PoseStack();
MatrixTransformStack msr = MatrixTransformStack.of(ms);
TransformStack msr = TransformStack.cast(ms);
msr.translate(getInstancePosition());
@ -186,7 +189,7 @@ public class SteelFlywheelInstance extends KineticTileInstance<FlywheelTileEntit
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite);
}
protected void transformConnector(MatrixTransformStack ms, boolean upper, boolean rotating, float angle, boolean flip) {
protected void transformConnector(TransformStack ms, boolean upper, boolean rotating, float angle, boolean flip) {
float shift = upper ? 1 / 4f : -1 / 8f;
float offset = upper ? 1 / 4f : 1 / 4f;
float radians = (float) (angle / 180 * Math.PI);
@ -212,7 +215,7 @@ public class SteelFlywheelInstance extends KineticTileInstance<FlywheelTileEntit
ms.translate(9 / 16f, 0, 0);
}
protected void rotateToFacing(MatrixTransformStack buffer, Direction facing) {
protected void rotateToFacing(TransformStack buffer, Direction facing) {
buffer.centre()
.rotate(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing)))
.unCentre();

View file

@ -27,7 +27,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.teammoeg.steampowered.block.SPBlockPartials;
@ -37,20 +37,20 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.util.Mth;
public class BronzeFlywheelRenderer extends KineticTileEntityRenderer {
public BronzeFlywheelRenderer(BlockEntityRenderDispatcher dispatcher) {
super(dispatcher);
public BronzeFlywheelRenderer(Context context) {
super(context);
}
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())) {
BlockState blockState = te.getBlockState();
FlywheelTileEntity wte = (FlywheelTileEntity) te;
// Mixin starts
@ -64,10 +64,10 @@ public class BronzeFlywheelRenderer extends KineticTileEntityRenderer {
light = LevelRenderer.getLightColor(te.getLevel(), blockState, te.getBlockPos().relative(connection));
float rotation = connection.getAxis() == Direction.Axis.X ^ connection.getAxisDirection() == Direction.AxisDirection.NEGATIVE ? -angle : angle;
boolean flip = blockState.getValue(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT;
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.BRONZE_FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.BRONZE_FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.BRONZE_FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.BRONZE_FLYWHEEL_LOWER_SLIDING, blockState), connection), false, false, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.BRONZE_FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.BRONZE_FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.BRONZE_FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.BRONZE_FLYWHEEL_LOWER_SLIDING, blockState), connection), false, false, rotation, flip).light(light).renderInto(ms, vb);
}
this.renderFlywheel(te, ms, light, blockState, angle, vb);
@ -77,13 +77,13 @@ public class BronzeFlywheelRenderer extends KineticTileEntityRenderer {
private void renderFlywheel(KineticTileEntity te, PoseStack ms, int light, BlockState blockState, float angle, VertexConsumer vb) {
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
Direction facing = (Direction) referenceState.getValue(BlockStateProperties.HORIZONTAL_FACING);
SuperByteBuffer wheel = PartialBufferer.getFacing(SPBlockPartials.BRONZE_FLYWHEEL, referenceState, facing);
SuperByteBuffer wheel = CachedBufferer.partialFacing(SPBlockPartials.BRONZE_FLYWHEEL, referenceState, facing);
kineticRotationTransform(wheel, te, ((Direction) blockState.getValue(HorizontalKineticBlock.HORIZONTAL_FACING)).getAxis(), AngleHelper.rad((double) angle), light);
wheel.renderInto(ms, vb);
}
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), ((Direction) te.getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING)).getOpposite());
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), ((Direction) te.getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING)).getOpposite());
}
protected SuperByteBuffer transformConnector(SuperByteBuffer buffer, boolean upper, boolean rotating, float angle, boolean flip) {

View file

@ -27,7 +27,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.teammoeg.steampowered.block.SPBlockPartials;
@ -37,20 +37,20 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.util.Mth;
public class CastIronFlywheelRenderer extends KineticTileEntityRenderer {
public CastIronFlywheelRenderer(BlockEntityRenderDispatcher dispatcher) {
super(dispatcher);
public CastIronFlywheelRenderer(Context context) {
super(context);
}
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())) {
BlockState blockState = te.getBlockState();
FlywheelTileEntity wte = (FlywheelTileEntity) te;
// Mixin starts
@ -64,10 +64,10 @@ public class CastIronFlywheelRenderer extends KineticTileEntityRenderer {
light = LevelRenderer.getLightColor(te.getLevel(), blockState, te.getBlockPos().relative(connection));
float rotation = connection.getAxis() == Direction.Axis.X ^ connection.getAxisDirection() == Direction.AxisDirection.NEGATIVE ? -angle : angle;
boolean flip = blockState.getValue(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT;
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.CAST_IRON_FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.CAST_IRON_FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.CAST_IRON_FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.CAST_IRON_FLYWHEEL_LOWER_SLIDING, blockState), connection), false, false, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.CAST_IRON_FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.CAST_IRON_FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.CAST_IRON_FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.CAST_IRON_FLYWHEEL_LOWER_SLIDING, blockState), connection), false, false, rotation, flip).light(light).renderInto(ms, vb);
}
this.renderFlywheel(te, ms, light, blockState, angle, vb);
@ -77,13 +77,13 @@ public class CastIronFlywheelRenderer extends KineticTileEntityRenderer {
private void renderFlywheel(KineticTileEntity te, PoseStack ms, int light, BlockState blockState, float angle, VertexConsumer vb) {
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
Direction facing = (Direction) referenceState.getValue(BlockStateProperties.HORIZONTAL_FACING);
SuperByteBuffer wheel = PartialBufferer.getFacing(SPBlockPartials.CAST_IRON_FLYWHEEL, referenceState, facing);
SuperByteBuffer wheel = CachedBufferer.partialFacing(SPBlockPartials.CAST_IRON_FLYWHEEL, referenceState, facing);
kineticRotationTransform(wheel, te, ((Direction) blockState.getValue(HorizontalKineticBlock.HORIZONTAL_FACING)).getAxis(), AngleHelper.rad((double) angle), light);
wheel.renderInto(ms, vb);
}
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), ((Direction) te.getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING)).getOpposite());
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), ((Direction) te.getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING)).getOpposite());
}
protected SuperByteBuffer transformConnector(SuperByteBuffer buffer, boolean upper, boolean rotating, float angle, boolean flip) {

View file

@ -27,7 +27,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.teammoeg.steampowered.block.SPBlockPartials;
@ -37,20 +37,20 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.util.Mth;
public class SteelFlywheelRenderer extends KineticTileEntityRenderer {
public SteelFlywheelRenderer(BlockEntityRenderDispatcher dispatcher) {
super(dispatcher);
public SteelFlywheelRenderer(Context context) {
super(context);
}
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())) {
BlockState blockState = te.getBlockState();
FlywheelTileEntity wte = (FlywheelTileEntity) te;
// Mixin starts
@ -64,10 +64,10 @@ public class SteelFlywheelRenderer extends KineticTileEntityRenderer {
light = LevelRenderer.getLightColor(te.getLevel(), blockState, te.getBlockPos().relative(connection));
float rotation = connection.getAxis() == Direction.Axis.X ^ connection.getAxisDirection() == Direction.AxisDirection.NEGATIVE ? -angle : angle;
boolean flip = blockState.getValue(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT;
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.STEEL_FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.STEEL_FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.STEEL_FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(PartialBufferer.get(SPBlockPartials.STEEL_FLYWHEEL_LOWER_SLIDING, blockState), connection), false, false, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.STEEL_FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.STEEL_FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.STEEL_FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light).renderInto(ms, vb);
this.transformConnector(this.rotateToFacing(CachedBufferer.partial(SPBlockPartials.STEEL_FLYWHEEL_LOWER_SLIDING, blockState), connection), false, false, rotation, flip).light(light).renderInto(ms, vb);
}
this.renderFlywheel(te, ms, light, blockState, angle, vb);
@ -77,13 +77,13 @@ public class SteelFlywheelRenderer extends KineticTileEntityRenderer {
private void renderFlywheel(KineticTileEntity te, PoseStack ms, int light, BlockState blockState, float angle, VertexConsumer vb) {
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
Direction facing = (Direction) referenceState.getValue(BlockStateProperties.HORIZONTAL_FACING);
SuperByteBuffer wheel = PartialBufferer.getFacing(SPBlockPartials.STEEL_FLYWHEEL, referenceState, facing);
SuperByteBuffer wheel = CachedBufferer.partialFacing(SPBlockPartials.STEEL_FLYWHEEL, referenceState, facing);
kineticRotationTransform(wheel, te, ((Direction) blockState.getValue(HorizontalKineticBlock.HORIZONTAL_FACING)).getAxis(), AngleHelper.rad((double) angle), light);
wheel.renderInto(ms, vb);
}
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), ((Direction) te.getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING)).getOpposite());
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), ((Direction) te.getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING)).getOpposite());
}
protected SuperByteBuffer transformConnector(SuperByteBuffer buffer, boolean upper, boolean rotating, float angle, boolean flip) {