use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class DeployerRenderer method renderComponents.
protected void renderComponents(DeployerTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
if (!Backend.canUseInstancing(te.getLevel())) {
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light);
}
BlockState blockState = te.getBlockState();
Vec3 offset = getHandOffset(te, partialTicks, blockState);
SuperByteBuffer pole = CachedBufferer.partial(AllBlockPartials.DEPLOYER_POLE, blockState);
SuperByteBuffer hand = CachedBufferer.partial(te.getHandPose(), blockState);
transform(pole.translate(offset.x, offset.y, offset.z), blockState, true).light(light).renderInto(ms, vb);
transform(hand.translate(offset.x, offset.y, offset.z), blockState, false).light(light).renderInto(ms, vb);
}
use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class EncasedFanRenderer method renderSafe.
@Override
protected void renderSafe(KineticTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (Backend.canUseInstancing(te.getLevel()))
return;
Direction direction = te.getBlockState().getValue(FACING);
VertexConsumer vb = buffer.getBuffer(RenderType.cutoutMipped());
int lightBehind = LevelRenderer.getLightColor(te.getLevel(), te.getBlockPos().relative(direction.getOpposite()));
int lightInFront = LevelRenderer.getLightColor(te.getLevel(), te.getBlockPos().relative(direction));
SuperByteBuffer shaftHalf = CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite());
SuperByteBuffer fanInner = CachedBufferer.partialFacing(AllBlockPartials.ENCASED_FAN_INNER, te.getBlockState(), direction.getOpposite());
float time = AnimationTickHolder.getRenderTime(te.getLevel());
float speed = te.getSpeed() * 5;
if (speed > 0)
speed = Mth.clamp(speed, 80, 64 * 20);
if (speed < 0)
speed = Mth.clamp(speed, -64 * 20, -80);
float angle = (time * speed * 3 / 10f) % 360;
angle = angle / 180f * (float) Math.PI;
standardKineticRotationTransform(shaftHalf, te, lightBehind).renderInto(ms, vb);
kineticRotationTransform(fanInner, te, direction.getAxis(), angle, lightInFront).renderInto(ms, vb);
}
use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class KineticTileEntityRenderer method renderRotatingKineticBlock.
public static void renderRotatingKineticBlock(KineticTileEntity te, BlockState renderedState, PoseStack ms, VertexConsumer buffer, int light) {
SuperByteBuffer superByteBuffer = CachedBufferer.block(KINETIC_TILE, renderedState);
renderRotatingBuffer(te, superByteBuffer, ms, buffer, light);
}
use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class BeltRenderer method renderSafe.
@Override
protected void renderSafe(BeltTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
if (!Backend.canUseInstancing(te.getLevel())) {
BlockState blockState = te.getBlockState();
if (!AllBlocks.BELT.has(blockState))
return;
BeltSlope beltSlope = blockState.getValue(BeltBlock.SLOPE);
BeltPart part = blockState.getValue(BeltBlock.PART);
Direction facing = blockState.getValue(BeltBlock.HORIZONTAL_FACING);
AxisDirection axisDirection = facing.getAxisDirection();
boolean downward = beltSlope == BeltSlope.DOWNWARD;
boolean upward = beltSlope == BeltSlope.UPWARD;
boolean diagonal = downward || upward;
boolean start = part == BeltPart.START;
boolean end = part == BeltPart.END;
boolean sideways = beltSlope == BeltSlope.SIDEWAYS;
boolean alongX = facing.getAxis() == Axis.X;
PoseStack localTransforms = new PoseStack();
TransformStack msr = TransformStack.cast(localTransforms);
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
float renderTick = AnimationTickHolder.getRenderTime(te.getLevel());
msr.centre().rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0)).rotateZ(sideways ? 90 : 0).rotateX(!diagonal && beltSlope != BeltSlope.HORIZONTAL ? 90 : 0).unCentre();
if (downward || beltSlope == BeltSlope.VERTICAL && axisDirection == AxisDirection.POSITIVE) {
boolean b = start;
start = end;
end = b;
}
DyeColor color = te.color.orElse(null);
for (boolean bottom : Iterate.trueAndFalse) {
PartialModel beltPartial = getBeltPartial(diagonal, start, end, bottom);
SuperByteBuffer beltBuffer = CachedBufferer.partial(beltPartial, blockState).light(light);
SpriteShiftEntry spriteShift = getSpriteShiftEntry(color, diagonal, bottom);
// UV shift
float speed = te.getSpeed();
if (speed != 0 || te.color.isPresent()) {
float time = renderTick * axisDirection.getStep();
if (diagonal && (downward ^ alongX) || !sideways && !diagonal && alongX || sideways && axisDirection == AxisDirection.NEGATIVE)
speed = -speed;
float scrollMult = diagonal ? 3f / 8f : 0.5f;
float spriteSize = spriteShift.getTarget().getV1() - spriteShift.getTarget().getV0();
double scroll = speed * time / (31.5 * 16) + (bottom ? 0.5 : 0.0);
scroll = scroll - Math.floor(scroll);
scroll = scroll * spriteSize * scrollMult;
beltBuffer.shiftUVScrolling(spriteShift, (float) scroll);
}
beltBuffer.transform(localTransforms).renderInto(ms, vb);
// Diagonal belt do not have a separate bottom model
if (diagonal)
break;
}
if (te.hasPulley()) {
Direction dir = sideways ? Direction.UP : blockState.getValue(BeltBlock.HORIZONTAL_FACING).getClockWise();
Supplier<PoseStack> matrixStackSupplier = () -> {
PoseStack stack = new PoseStack();
TransformStack stacker = TransformStack.cast(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 = CachedBufferer.partialDirectional(AllBlockPartials.BELT_PULLEY, blockState, dir, matrixStackSupplier);
KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
}
}
renderItems(te, partialTicks, ms, buffer, light, overlay);
}
use of com.simibubi.create.foundation.render.SuperByteBuffer in project Create by Creators-of-Create.
the class BlueprintRenderer method render.
@Override
public void render(BlueprintEntity entity, float yaw, float pt, PoseStack ms, MultiBufferSource buffer, int light) {
PartialModel partialModel = entity.size == 3 ? AllBlockPartials.CRAFTING_BLUEPRINT_3x3 : entity.size == 2 ? AllBlockPartials.CRAFTING_BLUEPRINT_2x2 : AllBlockPartials.CRAFTING_BLUEPRINT_1x1;
SuperByteBuffer sbb = CachedBufferer.partial(partialModel, Blocks.AIR.defaultBlockState());
sbb.rotateY(-yaw).rotateX(90.0F + entity.getXRot()).translate(-.5, -1 / 32f, -.5);
if (entity.size == 2)
sbb.translate(.5, 0, -.5);
sbb.forEntityRender().light(light).renderInto(ms, buffer.getBuffer(Sheets.solidBlockSheet()));
super.render(entity, yaw, pt, ms, buffer, light);
ms.pushPose();
float fakeNormalXRotation = -15;
int bl = light >> 4 & 0xf;
int sl = light >> 20 & 0xf;
boolean vertical = entity.getXRot() != 0;
if (entity.getXRot() == -90)
fakeNormalXRotation = -45;
else if (entity.getXRot() == 90 || yaw % 180 != 0) {
bl /= 1.35;
sl /= 1.35;
}
int itemLight = Mth.floor(sl + .5) << 20 | (Mth.floor(bl + .5) & 0xf) << 4;
TransformStack.cast(ms).rotateY(vertical ? 0 : -yaw).rotateX(fakeNormalXRotation);
Matrix3f copy = ms.last().normal().copy();
ms.popPose();
ms.pushPose();
TransformStack.cast(ms).rotateY(-yaw).rotateX(entity.getXRot()).translate(0, 0, 1 / 32f + .001);
if (entity.size == 3)
ms.translate(-1, -1, 0);
PoseStack squashedMS = new PoseStack();
squashedMS.last().pose().multiply(ms.last().pose());
for (int x = 0; x < entity.size; x++) {
squashedMS.pushPose();
for (int y = 0; y < entity.size; y++) {
BlueprintSection section = entity.getSection(x * entity.size + y);
Couple<ItemStack> displayItems = section.getDisplayItems();
squashedMS.pushPose();
squashedMS.scale(.5f, .5f, 1 / 1024f);
displayItems.forEachWithContext((stack, primary) -> {
if (stack.isEmpty())
return;
squashedMS.pushPose();
if (!primary) {
squashedMS.translate(0.325f, -0.325f, 1);
squashedMS.scale(.625f, .625f, 1);
}
squashedMS.last().normal().load(copy);
Minecraft.getInstance().getItemRenderer().renderStatic(stack, TransformType.GUI, itemLight, OverlayTexture.NO_OVERLAY, squashedMS, buffer, 0);
squashedMS.popPose();
});
squashedMS.popPose();
squashedMS.translate(1, 0, 0);
}
squashedMS.popPose();
squashedMS.translate(0, 1, 0);
}
ms.popPose();
}
Aggregations