mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-25 14:36:29 +01:00
Add Flywheel visuals for bogey block entities
This commit is contained in:
parent
1935b790dd
commit
d48a504486
9 changed files with 179 additions and 40 deletions
|
@ -199,6 +199,7 @@ import com.simibubi.create.content.schematics.cannon.SchematicannonRenderer;
|
||||||
import com.simibubi.create.content.schematics.cannon.SchematicannonVisual;
|
import com.simibubi.create.content.schematics.cannon.SchematicannonVisual;
|
||||||
import com.simibubi.create.content.schematics.table.SchematicTableBlockEntity;
|
import com.simibubi.create.content.schematics.table.SchematicTableBlockEntity;
|
||||||
import com.simibubi.create.content.trains.bogey.BogeyBlockEntityRenderer;
|
import com.simibubi.create.content.trains.bogey.BogeyBlockEntityRenderer;
|
||||||
|
import com.simibubi.create.content.trains.bogey.BogeyBlockEntityVisual;
|
||||||
import com.simibubi.create.content.trains.bogey.StandardBogeyBlockEntity;
|
import com.simibubi.create.content.trains.bogey.StandardBogeyBlockEntity;
|
||||||
import com.simibubi.create.content.trains.display.FlapDisplayBlockEntity;
|
import com.simibubi.create.content.trains.display.FlapDisplayBlockEntity;
|
||||||
import com.simibubi.create.content.trains.display.FlapDisplayRenderer;
|
import com.simibubi.create.content.trains.display.FlapDisplayRenderer;
|
||||||
|
@ -844,6 +845,7 @@ public class AllBlockEntityTypes {
|
||||||
|
|
||||||
public static final BlockEntityEntry<StandardBogeyBlockEntity> BOGEY = REGISTRATE
|
public static final BlockEntityEntry<StandardBogeyBlockEntity> BOGEY = REGISTRATE
|
||||||
.blockEntity("bogey", StandardBogeyBlockEntity::new)
|
.blockEntity("bogey", StandardBogeyBlockEntity::new)
|
||||||
|
.visual(() -> BogeyBlockEntityVisual::new, false)
|
||||||
.renderer(() -> BogeyBlockEntityRenderer::new)
|
.renderer(() -> BogeyBlockEntityRenderer::new)
|
||||||
.validBlocks(AllBlocks.SMALL_BOGEY, AllBlocks.LARGE_BOGEY)
|
.validBlocks(AllBlocks.SMALL_BOGEY, AllBlocks.LARGE_BOGEY)
|
||||||
.register();
|
.register();
|
||||||
|
|
|
@ -113,6 +113,6 @@ public abstract class AbstractBogeyBlockEntity extends CachedRenderBBBlockEntity
|
||||||
setChanged();
|
setChanged();
|
||||||
Level level = getLevel();
|
Level level = getLevel();
|
||||||
if (level != null)
|
if (level != null)
|
||||||
getLevel().sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), 3);
|
level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,9 @@ import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRender
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
public class BogeyBlockEntityRenderer<T extends BlockEntity> extends SafeBlockEntityRenderer<T> {
|
public class BogeyBlockEntityRenderer<T extends AbstractBogeyBlockEntity> extends SafeBlockEntityRenderer<T> {
|
||||||
public BogeyBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
|
public BogeyBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,14 +17,16 @@ public class BogeyBlockEntityRenderer<T extends BlockEntity> extends SafeBlockEn
|
||||||
protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light,
|
protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light,
|
||||||
int overlay) {
|
int overlay) {
|
||||||
BlockState blockState = be.getBlockState();
|
BlockState blockState = be.getBlockState();
|
||||||
if (be instanceof AbstractBogeyBlockEntity sbbe) {
|
if (!(blockState.getBlock() instanceof AbstractBogeyBlock<?> bogey)) {
|
||||||
float angle = sbbe.getVirtualAngle(partialTicks);
|
return;
|
||||||
if (blockState.getBlock() instanceof AbstractBogeyBlock<?> bogey) {
|
|
||||||
ms.translate(.5f, .5f, .5f);
|
|
||||||
if (blockState.getValue(AbstractBogeyBlock.AXIS) == Direction.Axis.X)
|
|
||||||
ms.mulPose(Axis.YP.rotationDegrees(90));
|
|
||||||
sbbe.getStyle().render(bogey.getSize(), partialTicks, ms, buffer, light, overlay, angle, sbbe.getBogeyData(), false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float angle = be.getVirtualAngle(partialTicks);
|
||||||
|
ms.pushPose();
|
||||||
|
ms.translate(.5f, .5f, .5f);
|
||||||
|
if (blockState.getValue(AbstractBogeyBlock.AXIS) == Direction.Axis.X)
|
||||||
|
ms.mulPose(Axis.YP.rotationDegrees(90));
|
||||||
|
be.getStyle().render(bogey.getSize(), partialTicks, ms, buffer, light, overlay, angle, be.getBogeyData(), false);
|
||||||
|
ms.popPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.simibubi.create.content.trains.bogey;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import com.mojang.math.Axis;
|
||||||
|
import com.simibubi.create.content.trains.bogey.BogeySizes.BogeySize;
|
||||||
|
|
||||||
|
import dev.engine_room.flywheel.api.instance.Instance;
|
||||||
|
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
||||||
|
import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual;
|
||||||
|
import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
|
public class BogeyBlockEntityVisual extends AbstractBlockEntityVisual<AbstractBogeyBlockEntity> implements SimpleDynamicVisual {
|
||||||
|
private final PoseStack poseStack = new PoseStack();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private final BogeySize bogeySize;
|
||||||
|
private BogeyStyle lastStyle;
|
||||||
|
@Nullable
|
||||||
|
private BogeyVisual bogey;
|
||||||
|
|
||||||
|
public BogeyBlockEntityVisual(VisualizationContext ctx, AbstractBogeyBlockEntity blockEntity, float partialTick) {
|
||||||
|
super(ctx, blockEntity, partialTick);
|
||||||
|
|
||||||
|
lastStyle = blockEntity.getStyle();
|
||||||
|
|
||||||
|
if (!(blockState.getBlock() instanceof AbstractBogeyBlock<?> block)) {
|
||||||
|
bogeySize = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bogeySize = block.getSize();
|
||||||
|
|
||||||
|
BlockPos visualPos = getVisualPosition();
|
||||||
|
poseStack.translate(visualPos.getX(), visualPos.getY(), visualPos.getZ());
|
||||||
|
poseStack.translate(.5f, .5f, .5f);
|
||||||
|
if (blockState.getValue(AbstractBogeyBlock.AXIS) == Direction.Axis.X)
|
||||||
|
poseStack.mulPose(Axis.YP.rotationDegrees(90));
|
||||||
|
poseStack.translate(0, -1.5 - 1 / 128f, 0);
|
||||||
|
|
||||||
|
bogey = lastStyle.createVisual(bogeySize, visualizationContext, partialTick, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beginFrame(Context context) {
|
||||||
|
if (bogeySize == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BogeyStyle style = blockEntity.getStyle();
|
||||||
|
if (style != lastStyle) {
|
||||||
|
if (bogey != null) {
|
||||||
|
bogey.delete();
|
||||||
|
bogey = null;
|
||||||
|
}
|
||||||
|
lastStyle = style;
|
||||||
|
bogey = lastStyle.createVisual(bogeySize, visualizationContext, context.partialTick(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bogey == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag bogeyData = blockEntity.getBogeyData();
|
||||||
|
float angle = blockEntity.getVirtualAngle(context.partialTick());
|
||||||
|
bogey.update(bogeyData, angle, poseStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectCrumblingInstances(Consumer<@Nullable Instance> consumer) {
|
||||||
|
if (bogey != null) {
|
||||||
|
bogey.collectCrumblingInstances(consumer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateLight(float partialTick) {
|
||||||
|
if (bogey != null) {
|
||||||
|
bogey.updateLight(computePackedLight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void _delete() {
|
||||||
|
if (bogey != null) {
|
||||||
|
bogey.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,6 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.simibubi.create.AllBogeyStyles;
|
import com.simibubi.create.AllBogeyStyles;
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
import com.simibubi.create.content.trains.bogey.BogeySizes.BogeySize;
|
import com.simibubi.create.content.trains.bogey.BogeySizes.BogeySize;
|
||||||
import com.simibubi.create.content.trains.entity.CarriageBogey;
|
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
||||||
|
@ -96,10 +95,10 @@ public class BogeyStyle {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Nullable
|
@Nullable
|
||||||
public BogeyVisual createVisual(VisualizationContext ctx, CarriageBogey bogey, float partialTick) {
|
public BogeyVisual createVisual(BogeySize size, VisualizationContext ctx, float partialTick, boolean inContraption) {
|
||||||
SizeRenderer renderer = sizeRenderers.get(bogey.getSize());
|
SizeRenderer renderer = sizeRenderers.get(size);
|
||||||
if (renderer != null) {
|
if (renderer != null) {
|
||||||
return renderer.visualizer.createVisual(ctx, bogey, partialTick);
|
return renderer.visualizer.createVisual(ctx, partialTick, inContraption);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
package com.simibubi.create.content.trains.bogey;
|
package com.simibubi.create.content.trains.bogey;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
|
import dev.engine_room.flywheel.api.instance.Instance;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
public interface BogeyVisual {
|
public interface BogeyVisual {
|
||||||
void update(float wheelAngle, PoseStack poseStack);
|
void update(CompoundTag bogeyData, float wheelAngle, PoseStack poseStack);
|
||||||
|
|
||||||
void hide();
|
void hide();
|
||||||
|
|
||||||
void updateLight(int packedLight);
|
void updateLight(int packedLight);
|
||||||
|
|
||||||
|
void collectCrumblingInstances(Consumer<@Nullable Instance> consumer);
|
||||||
|
|
||||||
void delete();
|
void delete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package com.simibubi.create.content.trains.bogey;
|
package com.simibubi.create.content.trains.bogey;
|
||||||
|
|
||||||
import com.simibubi.create.content.trains.entity.CarriageBogey;
|
|
||||||
|
|
||||||
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface BogeyVisualizer {
|
public interface BogeyVisualizer {
|
||||||
BogeyVisual createVisual(VisualizationContext ctx, CarriageBogey bogey, float partialTick);
|
BogeyVisual createVisual(VisualizationContext ctx, float partialTick, boolean inContraption);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,29 @@
|
||||||
package com.simibubi.create.content.trains.bogey;
|
package com.simibubi.create.content.trains.bogey;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllPartialModels;
|
import com.simibubi.create.AllPartialModels;
|
||||||
import com.simibubi.create.content.kinetics.simpleRelays.ShaftBlock;
|
import com.simibubi.create.content.kinetics.simpleRelays.ShaftBlock;
|
||||||
import com.simibubi.create.content.trains.entity.CarriageBogey;
|
|
||||||
import com.simibubi.create.foundation.render.VirtualRenderHelper;
|
import com.simibubi.create.foundation.render.VirtualRenderHelper;
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
|
|
||||||
|
import dev.engine_room.flywheel.api.instance.Instance;
|
||||||
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
||||||
import dev.engine_room.flywheel.lib.instance.InstanceTypes;
|
import dev.engine_room.flywheel.lib.instance.InstanceTypes;
|
||||||
import dev.engine_room.flywheel.lib.instance.TransformedInstance;
|
import dev.engine_room.flywheel.lib.instance.TransformedInstance;
|
||||||
import dev.engine_room.flywheel.lib.model.Models;
|
import dev.engine_room.flywheel.lib.model.Models;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
public class StandardBogeyVisual implements BogeyVisual {
|
public class StandardBogeyVisual implements BogeyVisual {
|
||||||
private final TransformedInstance shaft1;
|
private final TransformedInstance shaft1;
|
||||||
private final TransformedInstance shaft2;
|
private final TransformedInstance shaft2;
|
||||||
|
|
||||||
public StandardBogeyVisual(VisualizationContext ctx, CarriageBogey bogey, float partialTick) {
|
public StandardBogeyVisual(VisualizationContext ctx, float partialTick, boolean inContraption) {
|
||||||
var shaftInstancer = ctx.instancerProvider()
|
var shaftInstancer = ctx.instancerProvider()
|
||||||
.instancer(InstanceTypes.TRANSFORMED, VirtualRenderHelper.blockModel(AllBlocks.SHAFT.getDefaultState()
|
.instancer(InstanceTypes.TRANSFORMED, VirtualRenderHelper.blockModel(AllBlocks.SHAFT.getDefaultState()
|
||||||
.setValue(ShaftBlock.AXIS, Direction.Axis.Z)));
|
.setValue(ShaftBlock.AXIS, Direction.Axis.Z)));
|
||||||
|
@ -27,7 +32,7 @@ public class StandardBogeyVisual implements BogeyVisual {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float wheelAngle, PoseStack poseStack) {
|
public void update(CompoundTag bogeyData, float wheelAngle, PoseStack poseStack) {
|
||||||
shaft1.setTransform(poseStack)
|
shaft1.setTransform(poseStack)
|
||||||
.translate(-.5f, .25f, 0)
|
.translate(-.5f, .25f, 0)
|
||||||
.center()
|
.center()
|
||||||
|
@ -54,6 +59,12 @@ public class StandardBogeyVisual implements BogeyVisual {
|
||||||
shaft2.light(packedLight).setChanged();
|
shaft2.light(packedLight).setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectCrumblingInstances(Consumer<@Nullable Instance> consumer) {
|
||||||
|
consumer.accept(shaft1);
|
||||||
|
consumer.accept(shaft2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
shaft1.delete();
|
shaft1.delete();
|
||||||
|
@ -65,8 +76,8 @@ public class StandardBogeyVisual implements BogeyVisual {
|
||||||
private final TransformedInstance wheel1;
|
private final TransformedInstance wheel1;
|
||||||
private final TransformedInstance wheel2;
|
private final TransformedInstance wheel2;
|
||||||
|
|
||||||
public Small(VisualizationContext ctx, CarriageBogey bogey, float partialTick) {
|
public Small(VisualizationContext ctx, float partialTick, boolean inContraption) {
|
||||||
super(ctx, bogey, partialTick);
|
super(ctx, partialTick, inContraption);
|
||||||
var wheelInstancer = ctx.instancerProvider()
|
var wheelInstancer = ctx.instancerProvider()
|
||||||
.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.SMALL_BOGEY_WHEELS));
|
.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.SMALL_BOGEY_WHEELS));
|
||||||
frame = ctx.instancerProvider()
|
frame = ctx.instancerProvider()
|
||||||
|
@ -77,8 +88,8 @@ public class StandardBogeyVisual implements BogeyVisual {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float wheelAngle, PoseStack poseStack) {
|
public void update(CompoundTag bogeyData, float wheelAngle, PoseStack poseStack) {
|
||||||
super.update(wheelAngle, poseStack);
|
super.update(bogeyData, wheelAngle, poseStack);
|
||||||
wheel1.setTransform(poseStack)
|
wheel1.setTransform(poseStack)
|
||||||
.translate(0, 12 / 16f, -1)
|
.translate(0, 12 / 16f, -1)
|
||||||
.rotateXDegrees(wheelAngle)
|
.rotateXDegrees(wheelAngle)
|
||||||
|
@ -108,6 +119,14 @@ public class StandardBogeyVisual implements BogeyVisual {
|
||||||
wheel2.light(packedLight).setChanged();
|
wheel2.light(packedLight).setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectCrumblingInstances(Consumer<@Nullable Instance> consumer) {
|
||||||
|
super.collectCrumblingInstances(consumer);
|
||||||
|
consumer.accept(frame);
|
||||||
|
consumer.accept(wheel1);
|
||||||
|
consumer.accept(wheel2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
super.delete();
|
super.delete();
|
||||||
|
@ -125,8 +144,8 @@ public class StandardBogeyVisual implements BogeyVisual {
|
||||||
private final TransformedInstance wheels;
|
private final TransformedInstance wheels;
|
||||||
private final TransformedInstance pin;
|
private final TransformedInstance pin;
|
||||||
|
|
||||||
public Large(VisualizationContext ctx, CarriageBogey bogey, float partialTick) {
|
public Large(VisualizationContext ctx, float partialTick, boolean inContraption) {
|
||||||
super(ctx, bogey, partialTick);
|
super(ctx, partialTick, inContraption);
|
||||||
var secondaryShaftInstancer = ctx.instancerProvider()
|
var secondaryShaftInstancer = ctx.instancerProvider()
|
||||||
.instancer(InstanceTypes.TRANSFORMED, VirtualRenderHelper.blockModel(AllBlocks.SHAFT.getDefaultState()
|
.instancer(InstanceTypes.TRANSFORMED, VirtualRenderHelper.blockModel(AllBlocks.SHAFT.getDefaultState()
|
||||||
.setValue(ShaftBlock.AXIS, Direction.Axis.X)));
|
.setValue(ShaftBlock.AXIS, Direction.Axis.X)));
|
||||||
|
@ -147,8 +166,8 @@ public class StandardBogeyVisual implements BogeyVisual {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float wheelAngle, PoseStack poseStack) {
|
public void update(CompoundTag bogeyData, float wheelAngle, PoseStack poseStack) {
|
||||||
super.update(wheelAngle, poseStack);
|
super.update(bogeyData, wheelAngle, poseStack);
|
||||||
secondaryShaft1.setTransform(poseStack)
|
secondaryShaft1.setTransform(poseStack)
|
||||||
.translate(-.5f, .25f, .5f)
|
.translate(-.5f, .25f, .5f)
|
||||||
.center()
|
.center()
|
||||||
|
@ -201,6 +220,17 @@ public class StandardBogeyVisual implements BogeyVisual {
|
||||||
pin.light(packedLight).setChanged();
|
pin.light(packedLight).setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectCrumblingInstances(Consumer<@Nullable Instance> consumer) {
|
||||||
|
super.collectCrumblingInstances(consumer);
|
||||||
|
consumer.accept(secondaryShaft1);
|
||||||
|
consumer.accept(secondaryShaft2);
|
||||||
|
consumer.accept(wheels);
|
||||||
|
consumer.accept(drive);
|
||||||
|
consumer.accept(piston);
|
||||||
|
consumer.accept(pin);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
super.delete();
|
super.delete();
|
||||||
|
|
|
@ -12,9 +12,10 @@ import com.simibubi.create.foundation.utility.Iterate;
|
||||||
import dev.engine_room.flywheel.api.visual.DynamicVisual;
|
import dev.engine_room.flywheel.api.visual.DynamicVisual;
|
||||||
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
||||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
public class CarriageContraptionVisual extends ContraptionVisual<CarriageContraptionEntity> {
|
public class CarriageContraptionVisual extends ContraptionVisual<CarriageContraptionEntity> {
|
||||||
private final PoseStack ms = new PoseStack();
|
private final PoseStack poseStack = new PoseStack();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Carriage carriage;
|
private Carriage carriage;
|
||||||
|
@ -59,10 +60,10 @@ public class CarriageContraptionVisual extends ContraptionVisual<CarriageContrap
|
||||||
float viewXRot = entity.getViewXRot(partialTick);
|
float viewXRot = entity.getViewXRot(partialTick);
|
||||||
int bogeySpacing = carriage.bogeySpacing;
|
int bogeySpacing = carriage.bogeySpacing;
|
||||||
|
|
||||||
ms.pushPose();
|
poseStack.pushPose();
|
||||||
|
|
||||||
Vector3f visualPosition = getVisualPosition(partialTick);
|
Vector3f visualPosition = getVisualPosition(partialTick);
|
||||||
TransformStack.of(ms)
|
TransformStack.of(poseStack)
|
||||||
.translate(visualPosition);
|
.translate(visualPosition);
|
||||||
|
|
||||||
for (boolean current : Iterate.trueAndFalse) {
|
for (boolean current : Iterate.trueAndFalse) {
|
||||||
|
@ -75,17 +76,21 @@ public class CarriageContraptionVisual extends ContraptionVisual<CarriageContrap
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.pushPose();
|
poseStack.pushPose();
|
||||||
CarriageBogey bogey = visualizedBogey.bogey;
|
CarriageBogey bogey = visualizedBogey.bogey;
|
||||||
|
|
||||||
CarriageContraptionEntityRenderer.translateBogey(ms, bogey, bogeySpacing, viewYRot, viewXRot, partialTick);
|
CarriageContraptionEntityRenderer.translateBogey(poseStack, bogey, bogeySpacing, viewYRot, viewXRot, partialTick);
|
||||||
ms.translate(0, -1.5 - 1 / 128f, 0);
|
poseStack.translate(0, -1.5 - 1 / 128f, 0);
|
||||||
|
|
||||||
visualizedBogey.visual.update(bogey.wheelAngle.getValue(partialTick), ms);
|
CompoundTag bogeyData = bogey.bogeyData;
|
||||||
ms.popPose();
|
if (bogeyData == null) {
|
||||||
|
bogeyData = new CompoundTag();
|
||||||
|
}
|
||||||
|
visualizedBogey.visual.update(bogeyData, bogey.wheelAngle.getValue(partialTick), poseStack);
|
||||||
|
poseStack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.popPose();
|
poseStack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,7 +125,7 @@ public class CarriageContraptionVisual extends ContraptionVisual<CarriageContrap
|
||||||
private record VisualizedBogey(CarriageBogey bogey, BogeyVisual visual) {
|
private record VisualizedBogey(CarriageBogey bogey, BogeyVisual visual) {
|
||||||
@Nullable
|
@Nullable
|
||||||
static VisualizedBogey of(VisualizationContext ctx, CarriageBogey bogey, float partialTick) {
|
static VisualizedBogey of(VisualizationContext ctx, CarriageBogey bogey, float partialTick) {
|
||||||
BogeyVisual visual = bogey.getStyle().createVisual(ctx, bogey, partialTick);
|
BogeyVisual visual = bogey.getStyle().createVisual(bogey.getSize(), ctx, partialTick, true);
|
||||||
if (visual == null) {
|
if (visual == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue