Start to cleanup the AllBlockPartials methods

This commit is contained in:
JozsefA 2021-04-28 22:47:51 -07:00
parent 81b0cf77e1
commit e33ab160ac
52 changed files with 403 additions and 345 deletions

View file

@ -1,26 +1,15 @@
package com.simibubi.create;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes;
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
@ -188,59 +177,4 @@ public class AllBlockPartials {
return bakedModel;
}
public SuperByteBuffer renderOn(BlockState referenceState) {
return CreateClient.bufferCache.renderPartial(this, referenceState);
}
public SuperByteBuffer renderOnDirectionalSouth(BlockState referenceState) {
Direction facing = referenceState.get(FACING);
return renderOnDirectionalSouth(referenceState, facing);
}
public SuperByteBuffer renderOnDirectional(BlockState referenceState) {
Direction facing = referenceState.get(FACING);
return renderOnDirectional(referenceState, facing);
}
public SuperByteBuffer renderOnHorizontal(BlockState referenceState) {
Direction facing = referenceState.get(HORIZONTAL_FACING);
return renderOnDirectionalSouth(referenceState, facing);
}
public SuperByteBuffer renderOnDirectionalSouth(BlockState referenceState, Direction facing) {
MatrixStack ms = new MatrixStack();
// TODO 1.15 find a way to cache this model matrix computation
MatrixStacker.of(ms)
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(AngleHelper.verticalAngle(facing))
.unCentre();
return CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms);
}
public SuperByteBuffer renderOnDirectional(BlockState referenceState, Direction facing) {
MatrixStack ms = new MatrixStack();
// TODO 1.15 find a way to cache this model matrix computation
MatrixStacker.of(ms)
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
.unCentre();
return CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms);
}
public <M extends InstancedModel<?>> M getModel(RenderMaterial<?, M> mat, BlockState referenceState,
Direction facing) {
Supplier<MatrixStack> ms = () -> {
MatrixStack stack = new MatrixStack();
MatrixStacker.of(stack)
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(AngleHelper.verticalAngle(facing))
.unCentre();
return stack;
};
return mat.getModel(this, referenceState, facing, ms);
}
}

View file

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

View file

@ -10,6 +10,7 @@ import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import net.minecraft.block.BlockState;
import net.minecraft.util.Direction;
public class DrillInstance extends SingleRotatingInstance {
@ -20,6 +21,7 @@ public class DrillInstance extends SingleRotatingInstance {
@Override
protected InstancedModel<RotatingData> getModel() {
BlockState referenceState = tile.getBlockState();
return AllBlockPartials.DRILL_HEAD.getModel(getRotatingMaterial(), referenceState, referenceState.get(FACING));
Direction facing = referenceState.get(FACING);
return getRotatingMaterial().getModel(AllBlockPartials.DRILL_HEAD, referenceState, facing);
}
}

View file

@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -25,18 +26,14 @@ public class DrillRenderer extends KineticTileEntityRenderer {
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouth(te.getBlockState());
}
protected static SuperByteBuffer getRotatingModel(BlockState state) {
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouth(state);
return PartialBufferer.getDirectionalSouth(AllBlockPartials.DRILL_HEAD, te.getBlockState());
}
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) {
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal};
BlockState state = context.state;
SuperByteBuffer superBuffer = AllBlockPartials.DRILL_HEAD.renderOn(state);
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.DRILL_HEAD, state);
Direction facing = state.get(DrillBlock.FACING);
float speed = (float) (context.contraption.stalled

View file

@ -6,6 +6,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -31,7 +32,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
protected void renderSafe(HarvesterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) {
BlockState blockState = te.getBlockState();
SuperByteBuffer superBuffer = AllBlockPartials.HARVESTER_BLADE.renderOn(blockState);
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.HARVESTER_BLADE, blockState);
transform(te.getWorld(), blockState.get(HarvesterBlock.HORIZONTAL_FACING), superBuffer,
te.manuallyAnimatedSpeed);
superBuffer.light(light)
@ -42,7 +43,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
IRenderTypeBuffer buffers) {
BlockState blockState = context.state;
Direction facing = blockState.get(HORIZONTAL_FACING);
SuperByteBuffer superBuffer = AllBlockPartials.HARVESTER_BLADE.renderOn(blockState);
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.HARVESTER_BLADE, blockState);
float speed = (float) (!VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite())
? context.getAnimationSpeed()
: 0);

View file

@ -8,6 +8,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -63,8 +64,8 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
for (MatrixStack ms : matrixStacks)
ms.push();
SuperByteBuffer middle = getMiddleForState(blockState, lit).renderOn(blockState);
SuperByteBuffer top = getTopForState(blockState).renderOn(blockState);
SuperByteBuffer middle = PartialBufferer.get(getMiddleForState(blockState, lit), blockState);
SuperByteBuffer top = PartialBufferer.get(getTopForState(blockState), blockState);
Direction facing = blockState.get(PortableStorageInterfaceBlock.FACING);
for (MatrixStack ms : matrixStacks)

View file

@ -6,6 +6,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity.Animation;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -38,8 +39,8 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
// Render Hands
SuperByteBuffer hourHand = AllBlockPartials.CUCKOO_HOUR_HAND.renderOn(blockState);
SuperByteBuffer minuteHand = AllBlockPartials.CUCKOO_MINUTE_HAND.renderOn(blockState);
SuperByteBuffer hourHand = PartialBufferer.get(AllBlockPartials.CUCKOO_HOUR_HAND, blockState);
SuperByteBuffer minuteHand = PartialBufferer.get(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
float hourAngle = clock.hourHand.get(partialTicks);
float minuteAngle = clock.minuteHand.get(partialTicks);
rotateHand(hourHand, hourAngle, direction).light(packedLightmapCoords)
@ -48,8 +49,8 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
.renderInto(ms, vb);
// Doors
SuperByteBuffer leftDoor = AllBlockPartials.CUCKOO_LEFT_DOOR.renderOn(blockState);
SuperByteBuffer rightDoor = AllBlockPartials.CUCKOO_RIGHT_DOOR.renderOn(blockState);
SuperByteBuffer leftDoor = PartialBufferer.get(AllBlockPartials.CUCKOO_LEFT_DOOR, blockState);
SuperByteBuffer rightDoor = PartialBufferer.get(AllBlockPartials.CUCKOO_RIGHT_DOOR, blockState);
float angle = 0;
float offset = 0;
@ -78,9 +79,9 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
// Figure
if (clock.animationType != Animation.NONE) {
offset = -(angle / 135) * 1 / 2f + 10 / 16f;
AllBlockPartials allBlockPartials = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER);
SuperByteBuffer figure =
(clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER)
.renderOn(blockState);
PartialBufferer.get(allBlockPartials, blockState);
figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.rotateYCCW())));
figure.translate(offset, 0, 0);
figure.light(packedLightmapCoords)
@ -95,7 +96,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
}
private SuperByteBuffer transform(AllBlockPartials partial, KineticTileEntity te) {
return partial.renderOnDirectionalSouth(te.getBlockState(), te.getBlockState()
return PartialBufferer.getDirectionalSouth(partial, te.getBlockState(), te.getBlockState()
.get(CuckooClockBlock.HORIZONTAL_FACING)
.getOpposite());
}

View file

@ -9,6 +9,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllSpriteShifts;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase;
import com.simibubi.create.content.contraptions.components.crafter.RecipeGridHandler.GroupedItems;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -155,7 +156,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
if (!FastRenderDispatcher.available(te.getWorld())) {
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
standardKineticRotationTransform(superBuffer, te, light);
superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING).getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
@ -195,7 +196,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
private SuperByteBuffer renderAndTransform(MechanicalCrafterTileEntity te, AllBlockPartials renderBlock,
BlockState crafterState, BlockPos pos) {
SuperByteBuffer buffer = renderBlock.renderOn(crafterState);
SuperByteBuffer buffer = PartialBufferer.get(renderBlock, crafterState);
float xRot = crafterState.get(MechanicalCrafterBlock.POINTING)
.getXRotation();
float yRot = AngleHelper.horizontalAngle(crafterState.get(HORIZONTAL_FACING));

View file

@ -32,7 +32,8 @@ public class HandCrankInstance extends SingleRotatingInstance implements IDynami
return;
facing = blockState.get(BlockStateProperties.FACING);
InstancedModel<ModelData> model = renderedHandle.getModel(getTransformMaterial(), blockState, facing.getOpposite());
Direction opposite = facing.getOpposite();
InstancedModel<ModelData> model = getTransformMaterial().getModel(renderedHandle, blockState, opposite);
crank = model.createInstance();
rotateCrank();

View file

@ -6,6 +6,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
@ -38,7 +39,7 @@ public class HandCrankRenderer extends KineticTileEntityRenderer {
return;
Direction facing = state.get(FACING);
SuperByteBuffer handle = renderedHandle.renderOnDirectionalSouth(state, facing.getOpposite());
SuperByteBuffer handle = PartialBufferer.getDirectionalSouth(renderedHandle, state, facing.getOpposite());
HandCrankTileEntity crank = (HandCrankTileEntity) te;
kineticRotationTransform(handle, te, facing.getAxis(),
(crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light);

View file

@ -11,6 +11,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
@ -117,9 +118,8 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
BlockPos pos = te.getPos();
Vector3d offset = getHandOffset(te, partialTicks, blockState);
SuperByteBuffer pole = AllBlockPartials.DEPLOYER_POLE.renderOn(blockState);
SuperByteBuffer hand = te.getHandPose()
.renderOn(blockState);
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState);
SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState);
transform(te.getWorld(), pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms,
vb);
@ -155,7 +155,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) {
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal};
IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid());
BlockState blockState = context.state;
BlockPos pos = BlockPos.ZERO;
@ -163,8 +163,8 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
World world = context.world;
AllBlockPartials handPose = getHandPose(mode);
SuperByteBuffer pole = AllBlockPartials.DEPLOYER_POLE.renderOn(blockState);
SuperByteBuffer hand = handPose.renderOn(blockState);
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState);
SuperByteBuffer hand = PartialBufferer.get(handPose, blockState);
pole = transform(world, pole, blockState, pos, true);
hand = transform(world, hand, blockState, pos, false);

View file

@ -7,6 +7,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -37,9 +38,9 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer {
int lightInFront = WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getPos().offset(direction));
SuperByteBuffer shaftHalf =
AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), direction.getOpposite());
PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite());
SuperByteBuffer fanInner =
AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectionalSouth(te.getBlockState(), direction.getOpposite());
PartialBufferer.getDirectionalSouth(AllBlockPartials.ENCASED_FAN_INNER, te.getBlockState(), direction.getOpposite());
float time = AnimationTickHolder.getRenderTime(te.getWorld());
float speed = te.getSpeed() * 5;

View file

@ -24,8 +24,8 @@ public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
direction = blockState.get(FACING);
opposite = direction.getOpposite();
shaft = AllBlockPartials.SHAFT_HALF.getModel(getRotatingMaterial(), blockState, opposite).createInstance();
fan = AllBlockPartials.ENCASED_FAN_INNER.getModel(getRotatingMaterial(), blockState, opposite).createInstance();
shaft = getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite).createInstance();
fan = getRotatingMaterial().getModel(AllBlockPartials.ENCASED_FAN_INNER, blockState, opposite).createInstance();
setup(shaft);
setup(fan, getFanSpeed());

View file

@ -53,7 +53,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
shaft = setup(shaftModel().createInstance());
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
wheel = AllBlockPartials.FLYWHEEL.getModel(getTransformMaterial(), referenceState, referenceState.get(HORIZONTAL_FACING)).createInstance();
wheel = getTransformMaterial().getModel(AllBlockPartials.FLYWHEEL, referenceState, facing).createInstance();
connection = FlywheelBlock.getConnection(blockState);
if (connection != null) {
@ -159,7 +159,8 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
}
protected InstancedModel<RotatingData> shaftModel() {
return AllBlockPartials.SHAFT_HALF.getModel(getRotatingMaterial(), blockState, facing.getOpposite());
Direction opposite = facing.getOpposite();
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite);
}
protected void transformConnector(MatrixStacker ms, boolean upper, boolean rotating, float angle, boolean flip) {

View file

@ -8,6 +8,7 @@ import com.simibubi.create.AllBlockPartials;
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.ConnectionState;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -17,6 +18,7 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Direction.AxisDirection;
@ -54,23 +56,23 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT;
transformConnector(
rotateToFacing(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), connection), true, true,
rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true,
rotation, flip).light(light)
.renderInto(ms, vb);
transformConnector(
rotateToFacing(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), connection), false, true,
rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true,
rotation, flip).light(light)
.renderInto(ms, vb);
transformConnector(rotateToFacing(AllBlockPartials.FLYWHEEL_UPPER_SLIDING.renderOn(blockState), connection),
transformConnector(rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_UPPER_SLIDING, blockState), connection),
true, false, rotation, flip).light(light)
.renderInto(ms, vb);
transformConnector(rotateToFacing(AllBlockPartials.FLYWHEEL_LOWER_SLIDING.renderOn(blockState), connection),
transformConnector(rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_LOWER_SLIDING, blockState), connection),
false, false, rotation, flip).light(light)
.renderInto(ms, vb);
}
SuperByteBuffer wheel = AllBlockPartials.FLYWHEEL.renderOnHorizontal(blockState.rotate(Rotation.CLOCKWISE_90));
SuperByteBuffer wheel = PartialBufferer.getHorizontal(AllBlockPartials.FLYWHEEL, blockState.rotate(Rotation.CLOCKWISE_90));
kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING)
.getAxis(), AngleHelper.rad(angle), light);
wheel.renderInto(ms, vb);
@ -78,8 +80,8 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), te.getBlockState()
.get(HORIZONTAL_FACING)
return PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState()
.get(BlockStateProperties.HORIZONTAL_FACING)
.getOpposite());
}

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -34,7 +35,7 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
Direction facing = te.getBlockState()
.get(EngineBlock.HORIZONTAL_FACING);
float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing));
frame.renderOn(te.getBlockState())
PartialBufferer.get(frame, te.getBlockState())
.rotateCentered(Direction.UP, angle)
.translate(0, 0, -1)
.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getBlockState(), te.getPos()))

View file

@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -40,7 +41,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos);
@ -49,12 +50,12 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
float time = AnimationTickHolder.getRenderTime(te.getWorld());
float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI;
SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState);
SuperByteBuffer poleRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState);
poleRender.translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords)
.renderInto(ms, vb);
SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_MIXER_HEAD.renderOn(blockState);
SuperByteBuffer headRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState);
headRender.rotateCentered(Direction.UP, angle)
.translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords)

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.motor;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
@ -15,7 +16,7 @@ public class CreativeMotorRenderer extends KineticTileEntityRenderer {
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState());
return PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState());
}
}

View file

@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
@ -37,7 +38,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos);
float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks);
SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_PRESS_HEAD.renderOnHorizontal(blockState);
SuperByteBuffer headRender = PartialBufferer.getHorizontal(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState);
headRender.translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords)
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));

View file

@ -10,6 +10,7 @@ import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import net.minecraft.block.BlockState;
import net.minecraft.util.Direction;
import net.minecraft.util.Rotation;
public class SawInstance extends SingleRotatingInstance {
@ -22,7 +23,8 @@ public class SawInstance extends SingleRotatingInstance {
protected InstancedModel<RotatingData> getModel() {
if (blockState.get(FACING).getAxis().isHorizontal()) {
BlockState referenceState = blockState.rotate(tile.getWorld(), tile.getPos(), Rotation.CLOCKWISE_180);
return AllBlockPartials.SHAFT_HALF.getModel(getRotatingMaterial(), referenceState, referenceState.get(FACING));
Direction facing = referenceState.get(FACING);
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, referenceState, facing);
} else {
return getRotatingMaterial().getModel(shaft());
}

View file

@ -9,6 +9,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
@ -81,7 +82,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
.rotateY(90)
.unCentre();
}
superBuffer = partial.renderOnDirectionalSouth(blockState);
superBuffer = PartialBufferer.getDirectionalSouth(partial, blockState);
superBuffer.light(light)
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
@ -140,7 +141,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
BlockState state = te.getBlockState();
if (state.get(FACING).getAxis().isHorizontal())
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(state.rotate(te.getWorld(), te.getPos(), Rotation.CLOCKWISE_180));
return PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, state.rotate(te.getWorld(), te.getPos(), Rotation.CLOCKWISE_180));
return CreateClient.bufferCache.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE,
getRenderedBlockState(te));
}
@ -171,14 +172,14 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
if (SawBlock.isHorizontal(state)) {
if (shouldAnimate)
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE.renderOn(state);
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state);
else
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE.renderOn(state);
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE, state);
} else {
if (shouldAnimate)
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE.renderOn(state);
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE, state);
else
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE.renderOn(state);
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state);
}
for (MatrixStack m : matrixStacks) {

View file

@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -33,7 +34,7 @@ public class BearingRenderer extends KineticTileEntityRenderer {
.get(BlockStateProperties.FACING);
AllBlockPartials top =
bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
SuperByteBuffer superBuffer = top.renderOn(te.getBlockState());
SuperByteBuffer superBuffer = PartialBufferer.get(top, te.getBlockState());
float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1);
kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light);
@ -48,7 +49,7 @@ public class BearingRenderer extends KineticTileEntityRenderer {
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), te.getBlockState()
return PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState()
.get(BearingBlock.FACING)
.getOpposite());
}

View file

@ -12,6 +12,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Ori
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -35,7 +36,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
Direction facing = context.state.get(BlockStateProperties.FACING);
AllBlockPartials top = AllBlockPartials.BEARING_TOP;
SuperByteBuffer superBuffer = top.renderOn(context.state);
SuperByteBuffer superBuffer = PartialBufferer.get(top, context.state);
float renderPartialTicks = AnimationTickHolder.getPartialTicks();
// rotate to match blockstate

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -28,7 +29,7 @@ public class StickerRenderer extends SafeTileEntityRenderer<StickerTileEntity> {
if (FastRenderDispatcher.available(te.getWorld())) return;
BlockState state = te.getBlockState();
SuperByteBuffer head = AllBlockPartials.STICKER_HEAD.renderOn(state);
SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.STICKER_HEAD, state);
float offset = te.piston.getValue(AnimationTickHolder.getPartialTicks(te.getWorld()));
if (te.getWorld() != Minecraft.getInstance().world && !te.isVirtual())

View file

@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -54,7 +55,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer {
if (facing == Direction.NORTH || facing == Direction.EAST)
angleForTe *= -1;
SuperByteBuffer cogs = AllBlockPartials.GANTRY_COGS.renderOn(state);
SuperByteBuffer cogs = PartialBufferer.get(AllBlockPartials.GANTRY_COGS, state);
cogs.matrixStacker()
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))

View file

@ -6,6 +6,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -58,8 +59,8 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
BlockState blockState = te.getBlockState();
BlockPos pos = te.getPos();
SuperByteBuffer halfMagnet = this.halfMagnet.renderOn(blockState);
SuperByteBuffer halfRope = this.halfRope.renderOn(blockState);
SuperByteBuffer halfMagnet = PartialBufferer.get(this.halfMagnet, blockState);
SuperByteBuffer halfRope = PartialBufferer.get(this.halfRope, blockState);
SuperByteBuffer magnet = renderMagnet(te);
SuperByteBuffer rope = renderRope(te);
@ -106,8 +107,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) {
BlockState blockState = te.getBlockState();
return getCoil().renderOnDirectionalSouth(blockState,
Direction.getFacingFromAxis(AxisDirection.POSITIVE, getShaftAxis(te)));
return PartialBufferer.getDirectionalSouth(getCoil(), blockState, Direction.getFacingFromAxis(AxisDirection.POSITIVE, getShaftAxis(te)));
}
}

View file

@ -28,7 +28,7 @@ public class HosePulleyInstance extends AbstractPulleyInstance {
}
protected InstancedModel<OrientedData> getCoilModel() {
return AllBlockPartials.HOSE_COIL.getModel(getOrientedMaterial(), blockState, rotatingAbout);
return getOrientedMaterial().getModel(AllBlockPartials.HOSE_COIL, blockState, rotatingAbout);
}
protected InstancedModel<OrientedData> getHalfRopeModel() {

View file

@ -29,7 +29,7 @@ public class RopePulleyInstance extends AbstractPulleyInstance {
}
protected InstancedModel<OrientedData> getCoilModel() {
return AllBlockPartials.ROPE_COIL.getModel(getOrientedMaterial(), blockState, rotatingAbout);
return getOrientedMaterial().getModel(AllBlockPartials.ROPE_COIL, blockState, rotatingAbout);
}
protected InstancedModel<OrientedData> getHalfRopeModel() {

View file

@ -8,6 +8,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.KineticDebugger;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
@ -65,9 +66,9 @@ public class CouplingRenderer {
BlockState renderState = Blocks.AIR.getDefaultState();
IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid());
SuperByteBuffer attachment = AllBlockPartials.COUPLING_ATTACHMENT.renderOn(renderState);
SuperByteBuffer ring = AllBlockPartials.COUPLING_RING.renderOn(renderState);
SuperByteBuffer connector = AllBlockPartials.COUPLING_CONNECTOR.renderOn(renderState);
SuperByteBuffer attachment = PartialBufferer.get(AllBlockPartials.COUPLING_ATTACHMENT, renderState);
SuperByteBuffer ring = PartialBufferer.get(AllBlockPartials.COUPLING_RING, renderState);
SuperByteBuffer connector = PartialBufferer.get(AllBlockPartials.COUPLING_CONNECTOR, renderState);
Vector3d zero = Vector3d.ZERO;
Vector3d firstEndpoint = transforms.getFirst()

View file

@ -10,6 +10,7 @@ import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
import net.minecraft.block.BlockState;
import net.minecraft.util.Direction;
public class PumpCogInstance extends SingleRotatingInstance {
@ -20,6 +21,7 @@ public class PumpCogInstance extends SingleRotatingInstance {
@Override
protected InstancedModel<RotatingData> getModel() {
BlockState referenceState = tile.getBlockState();
return AllBlockPartials.MECHANICAL_PUMP_COG.getModel(getRotatingMaterial(), referenceState, referenceState.get(FACING));
Direction facing = referenceState.get(FACING);
return getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_PUMP_COG, referenceState, facing);
}
}

View file

@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.MatrixStacker;
@ -34,7 +35,7 @@ public class PumpRenderer extends KineticTileEntityRenderer {
float angle = MathHelper.lerp(pump.arrowDirection.getValue(partialTicks), 0, 90) - 90;
for (float yRot : new float[] { 0, 90 }) {
ms.push();
SuperByteBuffer arrow = AllBlockPartials.MECHANICAL_PUMP_ARROW.renderOn(blockState);
SuperByteBuffer arrow = PartialBufferer.get(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState);
Direction direction = blockState.get(PumpBlock.FACING);
MatrixStacker.of(ms)
.centre()
@ -52,7 +53,7 @@ public class PumpRenderer extends KineticTileEntityRenderer {
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return AllBlockPartials.MECHANICAL_PUMP_COG.renderOnDirectionalSouth(te.getBlockState());
return PartialBufferer.getDirectionalSouth(AllBlockPartials.MECHANICAL_PUMP_COG, te.getBlockState());
}
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.fluids.actors;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.AbstractPulleyRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
@ -29,12 +30,12 @@ public class HosePulleyRenderer extends AbstractPulleyRenderer {
@Override
protected SuperByteBuffer renderRope(KineticTileEntity te) {
return AllBlockPartials.HOSE.renderOn(te.getBlockState());
return PartialBufferer.get(AllBlockPartials.HOSE, te.getBlockState());
}
@Override
protected SuperByteBuffer renderMagnet(KineticTileEntity te) {
return AllBlockPartials.HOSE_MAGNET.renderOn(te.getBlockState());
return PartialBufferer.get(AllBlockPartials.HOSE_MAGNET, te.getBlockState());
}
@Override

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.fluids.actors;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.fluid.FluidRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -70,7 +71,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer<SpoutTileEntity> {
ms.push();
for (AllBlockPartials bit : BITS) {
bit.renderOn(te.getBlockState())
PartialBufferer.get(bit, te.getBlockState())
.light(light)
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
ms.translate(0, -3 * squeeze / 32f, 0);

View file

@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -31,7 +32,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
BlockState blockState = te.getBlockState();
SuperByteBuffer pointer = AllBlockPartials.FLUID_VALVE_POINTER.renderOn(blockState);
SuperByteBuffer pointer = PartialBufferer.get(AllBlockPartials.FLUID_VALVE_POINTER, blockState);
Direction facing = blockState.get(FluidValveBlock.FACING);
if (!(te instanceof FluidValveTileEntity))

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.processing.burner;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -31,7 +32,7 @@ public class BlazeBurnerRenderer extends SafeTileEntityRenderer<BlazeBurnerTileE
float offset = (MathHelper.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f;
AllBlockPartials blazeModel = AllBlockPartials.BLAZES.get(heatLevel);
SuperByteBuffer blazeBuffer = blazeModel.renderOn(te.getBlockState());
SuperByteBuffer blazeBuffer = PartialBufferer.get(blazeModel, te.getBlockState());
blazeBuffer.rotateCentered(Direction.UP, AngleHelper.rad(te.headAngle.getValue(partialTicks)));
blazeBuffer.translate(0, offset, 0);
blazeBuffer.light(0xF000F0)

View file

@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
@ -43,7 +44,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedContro
BlockState blockState = tileEntityIn.getBlockState();
boolean alongX = blockState.get(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X;
SuperByteBuffer bracket = AllBlockPartials.SPEED_CONTROLLER_BRACKET.renderOn(blockState);
SuperByteBuffer bracket = PartialBufferer.get(AllBlockPartials.SPEED_CONTROLLER_BRACKET, blockState);
bracket.translate(0, 1, 0);
bracket.rotateCentered(Direction.UP,
(float) (alongX ? Math.PI : Math.PI / 2));

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.contraptions.relays.belt;
import java.util.Random;
import java.util.function.Supplier;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
@ -11,6 +12,7 @@ import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.ShadowRenderHelper;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
@ -95,7 +97,7 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
AllBlockPartials beltPartial = getBeltPartial(diagonal, start, end, bottom);
SuperByteBuffer beltBuffer = beltPartial.renderOn(blockState)
SuperByteBuffer beltBuffer = PartialBufferer.get(beltPartial, blockState)
.light(light);
SpriteShiftEntry spriteShift = getSpriteShiftEntry(color, diagonal, bottom);
@ -127,18 +129,20 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
}
if (te.hasPulley()) {
// TODO 1.15 find a way to cache this model matrix computation
MatrixStack modelTransform = new MatrixStack();
Direction dir = blockState.get(BeltBlock.HORIZONTAL_FACING).rotateY();
if (sideways) dir = Direction.UP;
msr = MatrixStacker.of(modelTransform);
msr.centre();
if (dir.getAxis() == Axis.X) msr.rotateY(90);
if (dir.getAxis() == Axis.Y) msr.rotateX(90);
msr.rotateX(90);
msr.unCentre();
Direction dir = sideways ? Direction.UP : blockState.get(BeltBlock.HORIZONTAL_FACING).rotateY();
SuperByteBuffer superBuffer = CreateClient.bufferCache.renderDirectionalPartial(AllBlockPartials.BELT_PULLEY, blockState, dir, modelTransform);
Supplier<MatrixStack> matrixStackSupplier = () -> {
MatrixStack stack = new MatrixStack();
MatrixStacker stacker = MatrixStacker.of(stack);
stacker.centre();
if (dir.getAxis() == Axis.X) stacker.rotateY(90);
if (dir.getAxis() == Axis.Y) stacker.rotateX(90);
stacker.rotateX(90);
stacker.unCentre();
return stack;
};
SuperByteBuffer superBuffer = CreateClient.bufferCache.renderDirectionalPartial(AllBlockPartials.BELT_PULLEY, blockState, dir, matrixStackSupplier);
KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
}
}

View file

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

View file

@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -51,7 +52,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer {
angle = angle / 180f * (float) Math.PI;
SuperByteBuffer superByteBuffer =
AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), direction);
PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction);
kineticRotationTransform(superByteBuffer, te, axis, angle, light);
superByteBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
}

View file

@ -6,6 +6,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock.Type;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.Iterate;
@ -45,10 +46,10 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
GaugeTileEntity gaugeTE = (GaugeTileEntity) te;
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), gaugeState, te.getPos());
AllBlockPartials allBlockPartials = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS);
SuperByteBuffer headBuffer =
(type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS)
.renderOn(gaugeState);
SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.renderOn(gaugeState);
PartialBufferer.get(allBlockPartials, gaugeState);
SuperByteBuffer dialBuffer = PartialBufferer.get(AllBlockPartials.GAUGE_DIAL, gaugeState);
float dialPivot = 5.75f / 16;
float progress = MathHelper.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState);

View file

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

View file

@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -37,7 +38,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer {
if (boxAxis == axis)
continue;
SuperByteBuffer shaft = AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), direction);
SuperByteBuffer shaft = PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction);
float offset = getRotationOffsetForPosition(te, pos, axis);
float angle = (time * te.getSpeed() * 3f / 10) % 360;

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.belts.tunnel;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
@ -32,7 +33,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
if (FastRenderDispatcher.available(te.getWorld())) return;
SuperByteBuffer flapBuffer = AllBlockPartials.BELT_TUNNEL_FLAP.renderOn(te.getBlockState());
SuperByteBuffer flapBuffer = PartialBufferer.get(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
Vector3d pivot = VecHelper.voxelSpace(0, 10, 1f);
MatrixStacker msr = MatrixStacker.of(ms);

View file

@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -45,7 +46,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer {
float angle = lidProgress * 70;
if (!FastRenderDispatcher.available(te.getWorld())) {
SuperByteBuffer model = AllBlockPartials.EJECTOR_TOP.renderOn(te.getBlockState());
SuperByteBuffer model = PartialBufferer.get(AllBlockPartials.EJECTOR_TOP, te.getBlockState());
applyLidAngle(te, angle, model.matrixStacker());
model.light(light)
.renderInto(ms, vertexBuilder);

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.logistics.block.diodes;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.ColoredOverlayTileEntityRenderer;
import com.simibubi.create.foundation.utility.ColorHelper;
@ -20,7 +21,7 @@ public class AdjustableRepeaterRenderer extends ColoredOverlayTileEntityRenderer
@Override
protected SuperByteBuffer getOverlayBuffer(AdjustableRepeaterTileEntity te) {
return AllBlockPartials.FLEXPEATER_INDICATOR.renderOn(te.getBlockState());
return PartialBufferer.get(AllBlockPartials.FLEXPEATER_INDICATOR, te.getBlockState());
}
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.funnel;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
@ -33,8 +34,9 @@ public class FunnelRenderer extends SmartTileEntityRenderer<FunnelTileEntity> {
BlockState blockState = te.getBlockState();
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
SuperByteBuffer flapBuffer = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP
: AllBlockPartials.BELT_FUNNEL_FLAP).renderOn(blockState);
AllBlockPartials allBlockPartials = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP
: AllBlockPartials.BELT_FUNNEL_FLAP);
SuperByteBuffer flapBuffer = PartialBufferer.get(allBlockPartials, blockState);
Vector3d pivot = VecHelper.voxelSpace(0, 10, 9.5f);
MatrixStacker msr = MatrixStacker.of(ms);

View file

@ -6,6 +6,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity.Phase;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -104,12 +105,12 @@ public class ArmRenderer extends KineticTileEntityRenderer {
}
private void renderArm(IVertexBuilder builder, MatrixStack ms, MatrixStack msLocal, MatrixStacker msr, BlockState blockState, int color, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle, boolean hasItem, boolean isBlockItem, int light) {
SuperByteBuffer base = AllBlockPartials.ARM_BASE.renderOn(blockState).light(light);
SuperByteBuffer lowerBody = AllBlockPartials.ARM_LOWER_BODY.renderOn(blockState).light(light);
SuperByteBuffer upperBody = AllBlockPartials.ARM_UPPER_BODY.renderOn(blockState).light(light);
SuperByteBuffer head = AllBlockPartials.ARM_HEAD.renderOn(blockState).light(light);
SuperByteBuffer claw = AllBlockPartials.ARM_CLAW_BASE.renderOn(blockState).light(light);
SuperByteBuffer clawGrip = AllBlockPartials.ARM_CLAW_GRIP.renderOn(blockState);
SuperByteBuffer base = PartialBufferer.get(AllBlockPartials.ARM_BASE, blockState).light(light);
SuperByteBuffer lowerBody = PartialBufferer.get(AllBlockPartials.ARM_LOWER_BODY, blockState).light(light);
SuperByteBuffer upperBody = PartialBufferer.get(AllBlockPartials.ARM_UPPER_BODY, blockState).light(light);
SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.ARM_HEAD, blockState).light(light);
SuperByteBuffer claw = PartialBufferer.get(AllBlockPartials.ARM_CLAW_BASE, blockState).light(light);
SuperByteBuffer clawGrip = PartialBufferer.get(AllBlockPartials.ARM_CLAW_GRIP, blockState);
transformBase(msr, baseAngle);
base.transform(msLocal)
@ -182,7 +183,7 @@ public class ArmRenderer extends KineticTileEntityRenderer {
@Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return AllBlockPartials.ARM_COG.renderOn(te.getBlockState());
return PartialBufferer.get(AllBlockPartials.ARM_COG, te.getBlockState());
}
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.redstone;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -36,7 +37,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
// Handle
SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState);
SuperByteBuffer handle = PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_HANDLE, leverState);
float angle = (float) ((state / 15) * 90 / 180 * Math.PI);
transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f)
.rotate(Direction.EAST, angle)
@ -46,7 +47,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
// Indicator
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
SuperByteBuffer indicator = transform(AllBlockPartials.ANALOG_LEVER_INDICATOR.renderOn(leverState), leverState);
SuperByteBuffer indicator = transform(PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_INDICATOR, leverState), leverState);
indicator.light(lightCoords)
.color(color)
.renderInto(ms, vb);

View file

@ -7,6 +7,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.schematics.block.LaunchedItem.ForBlockState;
import com.simibubi.create.content.schematics.block.LaunchedItem.ForEntity;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -62,13 +63,13 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
SuperByteBuffer connector = AllBlockPartials.SCHEMATICANNON_CONNECTOR.renderOn(state);
SuperByteBuffer connector = PartialBufferer.get(AllBlockPartials.SCHEMATICANNON_CONNECTOR, state);
connector.translate(.5f, 0, .5f);
connector.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
connector.translate(-.5f, 0, -.5f);
connector.light(lightCoords).renderInto(ms, vb);
SuperByteBuffer pipe = AllBlockPartials.SCHEMATICANNON_PIPE.renderOn(state);
SuperByteBuffer pipe = PartialBufferer.get(AllBlockPartials.SCHEMATICANNON_PIPE, state);
pipe.translate(.5f, 15 / 16f, .5f);
pipe.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
pipe.rotate(Direction.SOUTH, (float) (pitch / 180 * Math.PI));

View file

@ -0,0 +1,68 @@
package com.simibubi.create.foundation.render;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
import java.util.function.Supplier;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.block.BlockState;
import net.minecraft.util.Direction;
public class PartialBufferer {
public static SuperByteBuffer get(AllBlockPartials partial, BlockState referenceState) {
return CreateClient.bufferCache.renderPartial(partial, referenceState);
}
public static SuperByteBuffer getDirectionalSouth(AllBlockPartials partial, BlockState referenceState) {
Direction facing = referenceState.get(FACING);
return getDirectionalSouth(partial, referenceState, facing);
}
public static SuperByteBuffer getDirectional(AllBlockPartials partial, BlockState referenceState) {
Direction facing = referenceState.get(FACING);
return getDirectional(partial, referenceState, facing);
}
public static SuperByteBuffer getHorizontal(AllBlockPartials partial, BlockState referenceState) {
Direction facing = referenceState.get(HORIZONTAL_FACING);
return getDirectionalSouth(partial, referenceState, facing);
}
public static SuperByteBuffer getDirectionalSouth(AllBlockPartials partial, BlockState referenceState, Direction facing) {
return CreateClient.bufferCache.renderDirectionalPartial(partial, referenceState, facing, rotateToFace(facing));
}
public static SuperByteBuffer getDirectional(AllBlockPartials partial, BlockState referenceState, Direction facing) {
Supplier<MatrixStack> ms = () -> {
MatrixStack stack = new MatrixStack();
MatrixStacker.of(stack)
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
.unCentre();
return stack;
};
return CreateClient.bufferCache.renderDirectionalPartial(partial, referenceState, facing, ms);
}
public static Supplier<MatrixStack> rotateToFace(Direction facing) {
return () -> {
MatrixStack stack = new MatrixStack();
MatrixStacker.of(stack)
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(AngleHelper.verticalAngle(facing))
.unCentre();
return stack;
};
}
}

View file

@ -46,9 +46,9 @@ public class SuperByteBufferCache {
}
public SuperByteBuffer renderPartial(AllBlockPartials partial, BlockState referenceState,
MatrixStack modelTransform) {
Supplier<MatrixStack> modelTransform) {
return get(Compartment.PARTIAL, partial,
() -> standardModelRender(partial.get(), referenceState, modelTransform));
() -> standardModelRender(partial.get(), referenceState, modelTransform.get()));
}
public SuperByteBuffer renderDirectionalPartial(AllBlockPartials partial, BlockState referenceState,
@ -58,9 +58,9 @@ public class SuperByteBufferCache {
}
public SuperByteBuffer renderDirectionalPartial(AllBlockPartials partial, BlockState referenceState, Direction dir,
MatrixStack modelTransform) {
Supplier<MatrixStack> modelTransform) {
return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial),
() -> standardModelRender(partial.get(), referenceState, modelTransform));
() -> standardModelRender(partial.get(), referenceState, modelTransform.get()));
}
public SuperByteBuffer renderBlockIn(Compartment<BlockState> compartment, BlockState toRender) {

View file

@ -22,6 +22,8 @@ import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.render.backend.gl.BasicProgram;
import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec;
import com.simibubi.create.foundation.render.backend.gl.shader.ShaderCallback;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
@ -104,8 +106,7 @@ public class RenderMaterial<P extends BasicProgram, MODEL extends InstancedModel
}
public MODEL getModel(AllBlockPartials partial, BlockState referenceState, Direction dir) {
return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial),
() -> buildModel(partial.get(), referenceState));
return getModel(partial, referenceState, dir, rotateToFace(dir));
}
public MODEL getModel(AllBlockPartials partial, BlockState referenceState, Direction dir, Supplier<MatrixStack> modelTransform) {
@ -142,4 +143,15 @@ public class RenderMaterial<P extends BasicProgram, MODEL extends InstancedModel
return factory.makeModel(renderer, builder);
}
public static Supplier<MatrixStack> rotateToFace(Direction facing) {
return () -> {
MatrixStack stack = new MatrixStack();
MatrixStacker.of(stack)
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(AngleHelper.verticalAngle(facing))
.unCentre();
return stack;
};
}
}