Implemented Model Data Initializer to StandardBogeyRenderer

This commit is contained in:
Rabbitminers 2023-03-22 17:03:28 +00:00
parent 6d98a1f469
commit 91727cc84a

View file

@ -1,5 +1,6 @@
package com.simibubi.create.content.logistics.trains;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.util.transform.Transform;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
@ -12,6 +13,13 @@ import net.minecraft.nbt.CompoundTag;
import org.jetbrains.annotations.Nullable;
import static com.simibubi.create.AllBlockPartials.LARGE_BOGEY_WHEELS;
import static com.simibubi.create.AllBlockPartials.BOGEY_PIN;
import static com.simibubi.create.AllBlockPartials.BOGEY_DRIVE;
import static com.simibubi.create.AllBlockPartials.BOGEY_PISTON;
import static com.simibubi.create.AllBlockPartials.SMALL_BOGEY_WHEELS;
import static com.simibubi.create.AllBlockPartials.BOGEY_FRAME;
public class StandardBogeyRenderer extends BogeyRenderer {
public StandardBogeyRenderer() {
@ -19,13 +27,22 @@ public class StandardBogeyRenderer extends BogeyRenderer {
renderers.put(BogeySize.LARGE, this::renderLarge);
}
@Override
public void initialiseContraptionModelData(MaterialManager materialManager, BogeySize size) {
// Large
createModelInstances(materialManager, LARGE_BOGEY_WHEELS, BOGEY_DRIVE, BOGEY_PISTON, BOGEY_PIN);
// Small
createModelInstances(materialManager, SMALL_BOGEY_WHEELS, 2);
createModelInstances(materialManager, BOGEY_FRAME);
}
public void renderSmall(CompoundTag bogeyData, float wheelAngle, PoseStack ms, int light,
@Nullable VertexConsumer vb) {
boolean inContraption = vb != null;
Transform<?> transform = getTransformFromPartial(AllBlockPartials.BOGEY_FRAME, inContraption);
Transform<?> transform = getTransformFromPartial(BOGEY_FRAME, inContraption);
finalize(transform, ms, light, vb);
Transform<?>[] wheels = getTransformsFromPartial(AllBlockPartials.SMALL_BOGEY_WHEELS, inContraption, 2);
Transform<?>[] wheels = getTransformsFromPartial(SMALL_BOGEY_WHEELS, inContraption, 2);
for (int side : Iterate.positiveAndNegative) {
if (!inContraption)
ms.pushPose();
@ -42,22 +59,22 @@ public class StandardBogeyRenderer extends BogeyRenderer {
@Nullable VertexConsumer vb) {
boolean inContraption = vb != null;
Transform<?> bogeyDrive = getTransformFromPartial(AllBlockPartials.BOGEY_DRIVE, inContraption);
Transform<?> bogeyDrive = getTransformFromPartial(BOGEY_DRIVE, inContraption);
finalize(bogeyDrive, ms, light, vb);
Transform<?> bogeyPiston = getTransformFromPartial(AllBlockPartials.BOGEY_PISTON, inContraption)
Transform<?> bogeyPiston = getTransformFromPartial(BOGEY_PISTON, inContraption)
.translate(0, 0, 1 / 4f * Math.sin(AngleHelper.rad(wheelAngle)));
finalize(bogeyPiston, ms, light, vb);
if (!inContraption)
ms.pushPose();
Transform<?> bogeyWheels = getTransformFromPartial(AllBlockPartials.LARGE_BOGEY_WHEELS, inContraption)
Transform<?> bogeyWheels = getTransformFromPartial(LARGE_BOGEY_WHEELS, inContraption)
.translate(0, 1, 0)
.rotateX(wheelAngle);
finalize(bogeyWheels, ms, light, vb);
Transform<?> bogeyPin = getTransformFromPartial(AllBlockPartials.BOGEY_PIN, inContraption)
Transform<?> bogeyPin = getTransformFromPartial(BOGEY_PIN, inContraption)
.translate(0, 1, 0)
.rotateX(wheelAngle)
.translate(0, 1 / 4f, 0)