mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-06-02 10:49:31 +02:00
9098002c17
- add flywheel as a dependency to catnip
63 lines
2.5 KiB
Java
63 lines
2.5 KiB
Java
package com.simibubi.create.content.contraptions.actors.trainControls;
|
|
|
|
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.simibubi.create.AllPartialModels;
|
|
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
|
|
import com.simibubi.create.content.contraptions.render.ContraptionMatrices;
|
|
import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher;
|
|
|
|
import net.createmod.catnip.render.CachedBuffers;
|
|
import net.createmod.catnip.render.SuperByteBuffer;
|
|
import net.createmod.catnip.utility.Iterate;
|
|
import net.createmod.catnip.utility.math.AngleHelper;
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
import net.minecraft.client.renderer.RenderType;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
public class ControlsRenderer {
|
|
|
|
public static void render(MovementContext context, VirtualRenderWorld renderWorld, ContraptionMatrices matrices,
|
|
MultiBufferSource buffer, float equipAnimation, float firstLever, float secondLever) {
|
|
BlockState state = context.state;
|
|
Direction facing = state.getValue(ControlsBlock.FACING);
|
|
|
|
SuperByteBuffer cover = CachedBuffers.partial(AllPartialModels.TRAIN_CONTROLS_COVER, state);
|
|
float hAngle = 180 + AngleHelper.horizontalAngle(facing);
|
|
PoseStack ms = matrices.getModel();
|
|
cover.transform(ms)
|
|
.centre()
|
|
.rotateY(hAngle)
|
|
.unCentre()
|
|
.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
|
|
.renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.cutoutMipped()));
|
|
|
|
double yOffset = Mth.lerp(equipAnimation * equipAnimation, -0.15f, 0.05f);
|
|
|
|
for (boolean first : Iterate.trueAndFalse) {
|
|
float vAngle = (float) Mth.clamp(first ? firstLever * 70 - 25 : secondLever * 15, -45, 45);
|
|
SuperByteBuffer lever = CachedBuffers.partial(AllPartialModels.TRAIN_CONTROLS_LEVER, state);
|
|
ms.pushPose();
|
|
TransformStack.cast(ms)
|
|
.centre()
|
|
.rotateY(hAngle)
|
|
.translate(0, 0, 4 / 16f)
|
|
.rotateX(vAngle - 45)
|
|
.translate(0, yOffset, 0)
|
|
.rotateX(45)
|
|
.unCentre()
|
|
.translate(0, -2 / 16f, -3 / 16f)
|
|
.translate(first ? 0 : 6 / 16f, 0, 0);
|
|
lever.transform(ms)
|
|
.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
|
|
.renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
|
|
ms.popPose();
|
|
}
|
|
|
|
}
|
|
|
|
}
|