mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-11 04:22:00 +01:00
Use more generics in BE renderer and instance subclasses
- This makes it unnecessary to cast or store the passed BE in BE renderers and instances
This commit is contained in:
parent
7dc6fc7576
commit
e54ccb853a
57 changed files with 210 additions and 290 deletions
|
@ -23,8 +23,8 @@ import com.simibubi.create.content.contraptions.components.actors.controls.Contr
|
|||
import com.simibubi.create.content.contraptions.components.clock.CuckooClockBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.clock.CuckooClockRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterInstance;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.ShaftlessCogwheelInstance;
|
||||
import com.simibubi.create.content.contraptions.components.crank.HandCrankBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.crank.HandCrankInstance;
|
||||
import com.simibubi.create.content.contraptions.components.crank.HandCrankRenderer;
|
||||
|
@ -37,11 +37,11 @@ import com.simibubi.create.content.contraptions.components.fan.EncasedFanBlockEn
|
|||
import com.simibubi.create.content.contraptions.components.fan.EncasedFanRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.fan.FanInstance;
|
||||
import com.simibubi.create.content.contraptions.components.fan.NozzleBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlyWheelInstance;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelInstance;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.millstone.MillStoneCogInstance;
|
||||
import com.simibubi.create.content.contraptions.components.millstone.MillstoneBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.millstone.MillstoneCogInstance;
|
||||
import com.simibubi.create.content.contraptions.components.millstone.MillstoneRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerRenderer;
|
||||
|
@ -573,14 +573,14 @@ public class AllBlockEntityTypes {
|
|||
|
||||
public static final BlockEntityEntry<FlywheelBlockEntity> FLYWHEEL = REGISTRATE
|
||||
.blockEntity("flywheel", FlywheelBlockEntity::new)
|
||||
.instance(() -> FlyWheelInstance::new, false)
|
||||
.instance(() -> FlywheelInstance::new, false)
|
||||
.validBlocks(AllBlocks.FLYWHEEL)
|
||||
.renderer(() -> FlywheelRenderer::new)
|
||||
.register();
|
||||
|
||||
public static final BlockEntityEntry<MillstoneBlockEntity> MILLSTONE = REGISTRATE
|
||||
.blockEntity("millstone", MillstoneBlockEntity::new)
|
||||
.instance(() -> MillStoneCogInstance::new, false)
|
||||
.instance(() -> MillstoneCogInstance::new, false)
|
||||
.validBlocks(AllBlocks.MILLSTONE)
|
||||
.renderer(() -> MillstoneRenderer::new)
|
||||
.register();
|
||||
|
@ -641,7 +641,7 @@ public class AllBlockEntityTypes {
|
|||
|
||||
public static final BlockEntityEntry<MechanicalCrafterBlockEntity> MECHANICAL_CRAFTER = REGISTRATE
|
||||
.blockEntity("mechanical_crafter", MechanicalCrafterBlockEntity::new)
|
||||
.instance(() -> MechanicalCrafterInstance::new)
|
||||
.instance(() -> ShaftlessCogwheelInstance::new)
|
||||
.validBlocks(AllBlocks.MECHANICAL_CRAFTER)
|
||||
.renderer(() -> MechanicalCrafterRenderer::new)
|
||||
.register();
|
||||
|
@ -838,7 +838,7 @@ public class AllBlockEntityTypes {
|
|||
|
||||
public static final BlockEntityEntry<FlapDisplayBlockEntity> FLAP_DISPLAY = REGISTRATE
|
||||
.blockEntity("flap_display", FlapDisplayBlockEntity::new)
|
||||
.instance(() -> MechanicalCrafterInstance::new)
|
||||
.instance(() -> ShaftlessCogwheelInstance::new)
|
||||
.renderer(() -> FlapDisplayRenderer::new)
|
||||
.validBlocks(AllBlocks.DISPLAY_BOARD)
|
||||
.register();
|
||||
|
|
|
@ -5,8 +5,8 @@ import com.jozufozu.flywheel.api.MaterialManager;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class BackHalfShaftInstance extends HalfShaftInstance {
|
||||
public BackHalfShaftInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public class BackHalfShaftInstance<T extends KineticBlockEntity> extends HalfShaftInstance<T> {
|
||||
public BackHalfShaftInstance(MaterialManager materialManager, T blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import com.jozufozu.flywheel.api.MaterialManager;
|
|||
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
|
||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||
|
||||
public class CutoutRotatingInstance extends SingleRotatingInstance {
|
||||
public CutoutRotatingInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public class CutoutRotatingInstance<T extends KineticBlockEntity> extends SingleRotatingInstance<T> {
|
||||
public CutoutRotatingInstance(MaterialManager materialManager, T blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class HalfShaftInstance extends SingleRotatingInstance {
|
||||
public HalfShaftInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public class HalfShaftInstance<T extends KineticBlockEntity> extends SingleRotatingInstance<T> {
|
||||
public HalfShaftInstance(MaterialManager materialManager, T blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ import com.jozufozu.flywheel.api.MaterialManager;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class HorizontalHalfShaftInstance extends HalfShaftInstance {
|
||||
public class HorizontalHalfShaftInstance<T extends KineticBlockEntity> extends HalfShaftInstance<T> {
|
||||
|
||||
public HorizontalHalfShaftInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public HorizontalHalfShaftInstance(MaterialManager materialManager, T blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import net.minecraft.core.Direction.AxisDirection;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class KineticBlockEntityRenderer extends SafeBlockEntityRenderer<KineticBlockEntity> {
|
||||
public class KineticBlockEntityRenderer<T extends KineticBlockEntity> extends SafeBlockEntityRenderer<T> {
|
||||
|
||||
public static final SuperByteBufferCache.Compartment<BlockState> KINETIC_BLOCK = new SuperByteBufferCache.Compartment<>();
|
||||
public static boolean rainbowMode = false;
|
||||
|
@ -40,7 +40,7 @@ public class KineticBlockEntityRenderer extends SafeBlockEntityRenderer<KineticB
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
if (Backend.canUseInstancing(be.getLevel())) return;
|
||||
|
||||
|
@ -50,18 +50,18 @@ public class KineticBlockEntityRenderer extends SafeBlockEntityRenderer<KineticB
|
|||
renderRotatingBuffer(be, getRotatedModel(be, state), ms, buffer.getBuffer(type), light);
|
||||
}
|
||||
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
protected BlockState getRenderedBlockState(T be) {
|
||||
return be.getBlockState();
|
||||
}
|
||||
|
||||
protected RenderType getRenderType(KineticBlockEntity be, BlockState state) {
|
||||
protected RenderType getRenderType(T be, BlockState state) {
|
||||
for (RenderType type : REVERSED_CHUNK_BUFFER_LAYERS)
|
||||
if (ItemBlockRenderTypes.canRenderInLayer(state, type))
|
||||
return type;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(T be, BlockState state) {
|
||||
return CachedBufferer.block(KINETIC_BLOCK, state);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
|
|||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class SingleRotatingInstance extends KineticBlockEntityInstance<KineticBlockEntity> {
|
||||
public class SingleRotatingInstance<T extends KineticBlockEntity> extends KineticBlockEntityInstance<T> {
|
||||
|
||||
protected RotatingData rotatingModel;
|
||||
|
||||
public SingleRotatingInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public SingleRotatingInstance(MaterialManager materialManager, T blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.components.actors;
|
|||
import com.jozufozu.flywheel.api.Instancer;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
|
||||
|
||||
|
@ -11,9 +10,9 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class DrillInstance extends SingleRotatingInstance {
|
||||
public class DrillInstance extends SingleRotatingInstance<DrillBlockEntity> {
|
||||
|
||||
public DrillInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public DrillInstance(MaterialManager materialManager, DrillBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.components.actors;
|
|||
|
||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||
|
@ -19,14 +18,14 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class DrillRenderer extends KineticBlockEntityRenderer {
|
||||
public class DrillRenderer extends KineticBlockEntityRenderer<DrillBlockEntity> {
|
||||
|
||||
public DrillRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(DrillBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partialFacing(AllBlockPartials.DRILL_HEAD, state);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.jozufozu.flywheel.core.PartialModel;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.clock.CuckooClockBlockEntity.Animation;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
|
@ -18,20 +17,19 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class CuckooClockRenderer extends KineticBlockEntityRenderer {
|
||||
public class CuckooClockRenderer extends KineticBlockEntityRenderer<CuckooClockBlockEntity> {
|
||||
|
||||
public CuckooClockRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(CuckooClockBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
if (!(be instanceof CuckooClockBlockEntity))
|
||||
return;
|
||||
|
||||
CuckooClockBlockEntity clock = (CuckooClockBlockEntity) be;
|
||||
BlockState blockState = be.getBlockState();
|
||||
Direction direction = blockState.getValue(CuckooClockBlock.HORIZONTAL_FACING);
|
||||
|
||||
|
@ -40,8 +38,8 @@ public class CuckooClockRenderer extends KineticBlockEntityRenderer {
|
|||
// Render Hands
|
||||
SuperByteBuffer hourHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_HOUR_HAND, blockState);
|
||||
SuperByteBuffer minuteHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
|
||||
float hourAngle = clock.hourHand.getValue(partialTicks);
|
||||
float minuteAngle = clock.minuteHand.getValue(partialTicks);
|
||||
float hourAngle = be.hourHand.getValue(partialTicks);
|
||||
float minuteAngle = be.minuteHand.getValue(partialTicks);
|
||||
rotateHand(hourHand, hourAngle, direction).light(light)
|
||||
.renderInto(ms, vb);
|
||||
rotateHand(minuteHand, minuteAngle, direction).light(light)
|
||||
|
@ -53,9 +51,9 @@ public class CuckooClockRenderer extends KineticBlockEntityRenderer {
|
|||
float angle = 0;
|
||||
float offset = 0;
|
||||
|
||||
if (clock.animationType != null) {
|
||||
float value = clock.animationProgress.getValue(partialTicks);
|
||||
int step = clock.animationType == Animation.SURPRISE ? 3 : 15;
|
||||
if (be.animationType != null) {
|
||||
float value = be.animationProgress.getValue(partialTicks);
|
||||
int step = be.animationType == Animation.SURPRISE ? 3 : 15;
|
||||
for (int phase = 30; phase <= 60; phase += step) {
|
||||
float local = value - phase;
|
||||
if (local < -step / 3)
|
||||
|
@ -76,9 +74,9 @@ public class CuckooClockRenderer extends KineticBlockEntityRenderer {
|
|||
.renderInto(ms, vb);
|
||||
|
||||
// Figure
|
||||
if (clock.animationType != Animation.NONE) {
|
||||
if (be.animationType != Animation.NONE) {
|
||||
offset = -(angle / 135) * 1 / 2f + 10 / 16f;
|
||||
PartialModel partialModel = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER);
|
||||
PartialModel partialModel = (be.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER);
|
||||
SuperByteBuffer figure =
|
||||
CachedBufferer.partial(partialModel, blockState);
|
||||
figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise())));
|
||||
|
@ -90,7 +88,7 @@ public class CuckooClockRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(CuckooClockBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, state, state
|
||||
.getValue(CuckooClockBlock.HORIZONTAL_FACING)
|
||||
.getOpposite());
|
||||
|
|
|
@ -13,9 +13,9 @@ import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
|
|||
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
public class MechanicalCrafterInstance extends SingleRotatingInstance {
|
||||
public class ShaftlessCogwheelInstance extends SingleRotatingInstance<KineticBlockEntity> {
|
||||
|
||||
public MechanicalCrafterInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public ShaftlessCogwheelInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
|
@ -12,15 +12,13 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class HandCrankInstance extends SingleRotatingInstance implements DynamicInstance {
|
||||
public class HandCrankInstance extends SingleRotatingInstance<HandCrankBlockEntity> implements DynamicInstance {
|
||||
|
||||
private final HandCrankBlockEntity blockEntity;
|
||||
private ModelData crank;
|
||||
private Direction facing;
|
||||
|
||||
public HandCrankInstance(MaterialManager modelManager, HandCrankBlockEntity blockEntity) {
|
||||
super(modelManager, blockEntity);
|
||||
this.blockEntity = blockEntity;
|
||||
|
||||
Block block = blockState.getBlock();
|
||||
PartialModel renderedHandle = null;
|
||||
|
|
|
@ -5,7 +5,6 @@ import static net.minecraft.world.level.block.state.properties.BlockStatePropert
|
|||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -17,14 +16,14 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class HandCrankRenderer extends KineticBlockEntityRenderer {
|
||||
public class HandCrankRenderer extends KineticBlockEntityRenderer<HandCrankBlockEntity> {
|
||||
|
||||
public HandCrankRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(HandCrankBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
|
@ -40,9 +39,8 @@ public class HandCrankRenderer extends KineticBlockEntityRenderer {
|
|||
|
||||
Direction facing = state.getValue(FACING);
|
||||
SuperByteBuffer handle = CachedBufferer.partialFacing(renderedHandle, state, facing.getOpposite());
|
||||
HandCrankBlockEntity crank = (HandCrankBlockEntity) be;
|
||||
kineticRotationTransform(handle, be, facing.getAxis(),
|
||||
(crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light);
|
||||
(be.independentAngle + partialTicks * be.chasingVelocity) / 360, light);
|
||||
handle.renderInto(ms, buffer.getBuffer(RenderType.solid()));
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.jozufozu.flywheel.core.PartialModel;
|
|||
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -20,9 +19,8 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class DeployerInstance extends ShaftInstance implements DynamicInstance, TickableInstance {
|
||||
public class DeployerInstance extends ShaftInstance<DeployerBlockEntity> implements DynamicInstance, TickableInstance {
|
||||
|
||||
final DeployerBlockEntity blockEntity;
|
||||
final Direction facing;
|
||||
final float yRot;
|
||||
final float xRot;
|
||||
|
@ -35,10 +33,9 @@ public class DeployerInstance extends ShaftInstance implements DynamicInstance,
|
|||
PartialModel currentHand;
|
||||
float progress;
|
||||
|
||||
public DeployerInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public DeployerInstance(MaterialManager materialManager, DeployerBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
|
||||
this.blockEntity = (DeployerBlockEntity) super.blockEntity;
|
||||
facing = blockState.getValue(FACING);
|
||||
|
||||
boolean rotatePole = blockState.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z;
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.jozufozu.flywheel.backend.Backend;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -19,14 +18,14 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class EncasedFanRenderer extends KineticBlockEntityRenderer {
|
||||
public class EncasedFanRenderer extends KineticBlockEntityRenderer<EncasedFanBlockEntity> {
|
||||
|
||||
public EncasedFanRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(EncasedFanBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
if (Backend.canUseInstancing(be.getLevel())) return;
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
|||
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
public class FlyWheelInstance extends KineticBlockEntityInstance<FlywheelBlockEntity> implements DynamicInstance {
|
||||
public class FlywheelInstance extends KineticBlockEntityInstance<FlywheelBlockEntity> implements DynamicInstance {
|
||||
|
||||
protected final RotatingData shaft;
|
||||
protected final ModelData wheel;
|
||||
protected float lastAngle = Float.NaN;
|
||||
|
||||
public FlyWheelInstance(MaterialManager materialManager, FlywheelBlockEntity blockEntity) {
|
||||
public FlywheelInstance(MaterialManager materialManager, FlywheelBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
|
||||
shaft = setup(getRotatingMaterial().getModel(shaft())
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.components.flywheel;
|
|||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -14,14 +13,14 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class FlywheelRenderer extends KineticBlockEntityRenderer {
|
||||
public class FlywheelRenderer extends KineticBlockEntityRenderer<FlywheelBlockEntity> {
|
||||
|
||||
public FlywheelRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(FlywheelBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
|
@ -29,16 +28,15 @@ public class FlywheelRenderer extends KineticBlockEntityRenderer {
|
|||
return;
|
||||
|
||||
BlockState blockState = be.getBlockState();
|
||||
FlywheelBlockEntity wte = (FlywheelBlockEntity) be;
|
||||
|
||||
float speed = wte.visualSpeed.getValue(partialTicks) * 3 / 10f;
|
||||
float angle = wte.angle + speed * partialTicks;
|
||||
float speed = be.visualSpeed.getValue(partialTicks) * 3 / 10f;
|
||||
float angle = be.angle + speed * partialTicks;
|
||||
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||
renderFlywheel(be, ms, light, blockState, angle, vb);
|
||||
}
|
||||
|
||||
private void renderFlywheel(KineticBlockEntity be, PoseStack ms, int light, BlockState blockState, float angle,
|
||||
private void renderFlywheel(FlywheelBlockEntity be, PoseStack ms, int light, BlockState blockState, float angle,
|
||||
VertexConsumer vb) {
|
||||
SuperByteBuffer wheel = CachedBufferer.block(blockState);
|
||||
kineticRotationTransform(wheel, be, getRotationAxisOf(be), AngleHelper.rad(angle), light);
|
||||
|
@ -46,7 +44,7 @@ public class FlywheelRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
protected BlockState getRenderedBlockState(FlywheelBlockEntity be) {
|
||||
return shaft(getRotationAxisOf(be));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@ package com.simibubi.create.content.contraptions.components.millstone;
|
|||
import com.jozufozu.flywheel.api.Instancer;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
|
||||
|
||||
public class MillStoneCogInstance extends SingleRotatingInstance {
|
||||
public class MillstoneCogInstance extends SingleRotatingInstance<MillstoneBlockEntity> {
|
||||
|
||||
public MillStoneCogInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public MillstoneCogInstance(MaterialManager materialManager, MillstoneBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.components.millstone;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -9,14 +8,14 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class MillstoneRenderer extends KineticBlockEntityRenderer {
|
||||
public class MillstoneRenderer extends KineticBlockEntityRenderer<MillstoneBlockEntity> {
|
||||
|
||||
public MillstoneRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(MillstoneBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partial(AllBlockPartials.MILLSTONE_COG, state);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.jozufozu.flywheel.backend.Backend;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -16,33 +15,32 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class MechanicalMixerRenderer extends KineticBlockEntityRenderer {
|
||||
public class MechanicalMixerRenderer extends KineticBlockEntityRenderer<MechanicalMixerBlockEntity> {
|
||||
|
||||
public MechanicalMixerRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen(KineticBlockEntity be) {
|
||||
public boolean shouldRenderOffScreen(MechanicalMixerBlockEntity be) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(MechanicalMixerBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
|
||||
if (Backend.canUseInstancing(be.getLevel())) return;
|
||||
|
||||
BlockState blockState = be.getBlockState();
|
||||
MechanicalMixerBlockEntity mixer = (MechanicalMixerBlockEntity) be;
|
||||
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||
|
||||
SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
|
||||
standardKineticRotationTransform(superBuffer, be, light).renderInto(ms, vb);
|
||||
|
||||
float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks);
|
||||
float speed = mixer.getRenderedHeadRotationSpeed(partialTicks);
|
||||
float renderedHeadOffset = be.getRenderedHeadOffset(partialTicks);
|
||||
float speed = be.getRenderedHeadRotationSpeed(partialTicks);
|
||||
float time = AnimationTickHolder.getRenderTime(be.getLevel());
|
||||
float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.components.motor;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -9,14 +8,14 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class CreativeMotorRenderer extends KineticBlockEntityRenderer {
|
||||
public class CreativeMotorRenderer extends KineticBlockEntityRenderer<CreativeMotorBlockEntity> {
|
||||
|
||||
public CreativeMotorRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(CreativeMotorBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, state);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import static net.minecraft.world.level.block.state.properties.BlockStatePropert
|
|||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -15,19 +14,19 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class MechanicalPressRenderer extends KineticBlockEntityRenderer {
|
||||
public class MechanicalPressRenderer extends KineticBlockEntityRenderer<MechanicalPressBlockEntity> {
|
||||
|
||||
public MechanicalPressRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen(KineticBlockEntity be) {
|
||||
public boolean shouldRenderOffScreen(MechanicalPressBlockEntity be) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(MechanicalPressBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
|
@ -35,7 +34,7 @@ public class MechanicalPressRenderer extends KineticBlockEntityRenderer {
|
|||
return;
|
||||
|
||||
BlockState blockState = be.getBlockState();
|
||||
PressingBehaviour pressingBehaviour = ((MechanicalPressBlockEntity) be).getPressingBehaviour();
|
||||
PressingBehaviour pressingBehaviour = be.getPressingBehaviour();
|
||||
float renderedHeadOffset =
|
||||
pressingBehaviour.getRenderedHeadOffset(partialTicks) * pressingBehaviour.mode.headOffset;
|
||||
|
||||
|
@ -47,7 +46,7 @@ public class MechanicalPressRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
protected BlockState getRenderedBlockState(MechanicalPressBlockEntity be) {
|
||||
return shaft(getRotationAxisOf(be));
|
||||
}
|
||||
|
||||
|
|
|
@ -11,14 +11,12 @@ import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
|||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
public class PressInstance extends ShaftInstance implements DynamicInstance {
|
||||
public class PressInstance extends ShaftInstance<MechanicalPressBlockEntity> implements DynamicInstance {
|
||||
|
||||
private final OrientedData pressHead;
|
||||
private final MechanicalPressBlockEntity press;
|
||||
|
||||
public PressInstance(MaterialManager materialManager, MechanicalPressBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
press = blockEntity;
|
||||
|
||||
pressHead = materialManager.defaultSolid()
|
||||
.material(Materials.ORIENTED)
|
||||
|
@ -39,7 +37,7 @@ public class PressInstance extends ShaftInstance implements DynamicInstance {
|
|||
}
|
||||
|
||||
private void transformModels() {
|
||||
float renderedHeadOffset = getRenderedHeadOffset(press);
|
||||
float renderedHeadOffset = getRenderedHeadOffset(blockEntity);
|
||||
|
||||
pressHead.setPosition(getInstancePosition())
|
||||
.nudge(0, -renderedHeadOffset, 0);
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.components.saw;
|
|||
import com.jozufozu.flywheel.api.Instancer;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
|
||||
|
||||
|
@ -12,9 +11,9 @@ import net.minecraft.world.level.block.Rotation;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class SawInstance extends SingleRotatingInstance {
|
||||
public class SawInstance extends SingleRotatingInstance<SawBlockEntity> {
|
||||
|
||||
public SawInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public SawInstance(MaterialManager materialManager, SawBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class BearingInstance<B extends KineticBlockEntity & IBearingBlockEntity> extends BackHalfShaftInstance implements DynamicInstance {
|
||||
final B bearing;
|
||||
|
||||
public class BearingInstance<B extends KineticBlockEntity & IBearingBlockEntity> extends BackHalfShaftInstance<B> implements DynamicInstance {
|
||||
final OrientedData topInstance;
|
||||
|
||||
final Vector3f rotationAxis;
|
||||
|
@ -25,7 +23,6 @@ public class BearingInstance<B extends KineticBlockEntity & IBearingBlockEntity>
|
|||
|
||||
public BearingInstance(MaterialManager materialManager, B blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
this.bearing = blockEntity;
|
||||
|
||||
Direction facing = blockState.getValue(BlockStateProperties.FACING);
|
||||
rotationAxis = Direction.get(Direction.AxisDirection.POSITIVE, axis).step();
|
||||
|
@ -33,7 +30,7 @@ public class BearingInstance<B extends KineticBlockEntity & IBearingBlockEntity>
|
|||
blockOrientation = getBlockStateOrientation(facing);
|
||||
|
||||
PartialModel top =
|
||||
bearing.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
|
||||
blockEntity.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
|
||||
|
||||
topInstance = getOrientedMaterial().getModel(top, blockState).createInstance();
|
||||
|
||||
|
@ -43,7 +40,7 @@ public class BearingInstance<B extends KineticBlockEntity & IBearingBlockEntity>
|
|||
@Override
|
||||
public void beginFrame() {
|
||||
|
||||
float interpolatedAngle = bearing.getInterpolatedAngle(AnimationTickHolder.getPartialTicks() - 1);
|
||||
float interpolatedAngle = blockEntity.getInterpolatedAngle(AnimationTickHolder.getPartialTicks() - 1);
|
||||
Quaternion rot = rotationAxis.rotationDegrees(interpolatedAngle);
|
||||
|
||||
rot.mul(blockOrientation);
|
||||
|
|
|
@ -17,28 +17,27 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class BearingRenderer extends KineticBlockEntityRenderer {
|
||||
public class BearingRenderer<T extends KineticBlockEntity & IBearingBlockEntity> extends KineticBlockEntityRenderer<T> {
|
||||
|
||||
public BearingRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
|
||||
if (Backend.canUseInstancing(be.getLevel())) return;
|
||||
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
IBearingBlockEntity bearingBE = (IBearingBlockEntity) be;
|
||||
final Direction facing = be.getBlockState()
|
||||
.getValue(BlockStateProperties.FACING);
|
||||
PartialModel top =
|
||||
bearingBE.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
|
||||
be.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
|
||||
SuperByteBuffer superBuffer = CachedBufferer.partial(top, be.getBlockState());
|
||||
|
||||
float interpolatedAngle = bearingBE.getInterpolatedAngle(partialTicks - 1);
|
||||
float interpolatedAngle = be.getInterpolatedAngle(partialTicks - 1);
|
||||
kineticRotationTransform(superBuffer, be, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light);
|
||||
|
||||
if (facing.getAxis()
|
||||
|
|
|
@ -3,13 +3,12 @@ package com.simibubi.create.content.contraptions.components.structureMovement.el
|
|||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||
import com.jozufozu.flywheel.light.TickingLightListener;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
|
||||
// TODO
|
||||
public class ElevatorPulleyInstance extends ShaftInstance implements DynamicInstance, TickingLightListener {
|
||||
public class ElevatorPulleyInstance extends ShaftInstance<ElevatorPulleyBlockEntity> implements DynamicInstance, TickingLightListener {
|
||||
|
||||
public ElevatorPulleyInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public ElevatorPulleyInstance(MaterialManager materialManager, ElevatorPulleyBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.simibubi.create.AllSpriteShifts;
|
|||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.AbstractPulleyRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyRenderer;
|
||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
|
@ -21,14 +20,14 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class ElevatorPulleyRenderer extends KineticBlockEntityRenderer {
|
||||
public class ElevatorPulleyRenderer extends KineticBlockEntityRenderer<ElevatorPulleyBlockEntity> {
|
||||
|
||||
public ElevatorPulleyRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(ElevatorPulleyBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
|
||||
// if (Backend.canUseInstancing(be.getLevel()))
|
||||
|
@ -41,7 +40,7 @@ public class ElevatorPulleyRenderer extends KineticBlockEntityRenderer {
|
|||
renderRotatingBuffer(be, getRotatedModel(be, state), ms, buffer.getBuffer(type), light);
|
||||
//
|
||||
|
||||
float offset = PulleyRenderer.getBlockEntityOffset(partialTicks, (PulleyBlockEntity) be);
|
||||
float offset = PulleyRenderer.getBlockEntityOffset(partialTicks, be);
|
||||
boolean running = PulleyRenderer.isPulleyRunning(be);
|
||||
|
||||
SpriteShiftEntry beltShift = AllSpriteShifts.ELEVATOR_BELT;
|
||||
|
@ -100,7 +99,7 @@ public class ElevatorPulleyRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
protected BlockState getRenderedBlockState(ElevatorPulleyBlockEntity be) {
|
||||
return shaft(getRotationAxisOf(be));
|
||||
}
|
||||
|
||||
|
@ -116,7 +115,7 @@ public class ElevatorPulleyRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen(KineticBlockEntity p_188185_1_) {
|
||||
public boolean shouldRenderOffScreen(ElevatorPulleyBlockEntity p_188185_1_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.jozufozu.flywheel.api.MaterialManager;
|
|||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -14,7 +13,7 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class GantryCarriageInstance extends ShaftInstance implements DynamicInstance {
|
||||
public class GantryCarriageInstance extends ShaftInstance<GantryCarriageBlockEntity> implements DynamicInstance {
|
||||
|
||||
private final ModelData gantryCogs;
|
||||
|
||||
|
@ -26,7 +25,7 @@ public class GantryCarriageInstance extends ShaftInstance implements DynamicInst
|
|||
|
||||
private float lastAngle = Float.NaN;
|
||||
|
||||
public GantryCarriageInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public GantryCarriageInstance(MaterialManager materialManager, GantryCarriageBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
|
||||
gantryCogs = getTransformMaterial()
|
||||
|
@ -56,7 +55,7 @@ public class GantryCarriageInstance extends ShaftInstance implements DynamicInst
|
|||
}
|
||||
|
||||
private float getCogAngle() {
|
||||
return GantryCarriageRenderer.getAngleForTe(blockEntity, visualPos, rotationAxis) * rotationMult;
|
||||
return GantryCarriageRenderer.getAngleForBE(blockEntity, visualPos, rotationAxis) * rotationMult;
|
||||
}
|
||||
|
||||
private void animateCogs(float cogAngle) {
|
||||
|
|
|
@ -20,14 +20,14 @@ import net.minecraft.core.Direction.Axis;
|
|||
import net.minecraft.core.Direction.AxisDirection;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class GantryCarriageRenderer extends KineticBlockEntityRenderer {
|
||||
public class GantryCarriageRenderer extends KineticBlockEntityRenderer<GantryCarriageBlockEntity> {
|
||||
|
||||
public GantryCarriageRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(GantryCarriageBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class GantryCarriageRenderer extends KineticBlockEntityRenderer {
|
|||
BlockPos visualPos = facing.getAxisDirection() == AxisDirection.POSITIVE ? be.getBlockPos()
|
||||
: be.getBlockPos()
|
||||
.relative(facing.getOpposite());
|
||||
float angleForBE = getAngleForTe(be, visualPos, rotationAxis);
|
||||
float angleForBE = getAngleForBE(be, visualPos, rotationAxis);
|
||||
|
||||
Axis gantryAxis = Axis.X;
|
||||
for (Axis axis : Iterate.axes)
|
||||
|
@ -69,14 +69,14 @@ public class GantryCarriageRenderer extends KineticBlockEntityRenderer {
|
|||
|
||||
}
|
||||
|
||||
public static float getAngleForTe(KineticBlockEntity be, final BlockPos pos, Axis axis) {
|
||||
public static float getAngleForBE(KineticBlockEntity be, final BlockPos pos, Axis axis) {
|
||||
float time = AnimationTickHolder.getRenderTime(be.getLevel());
|
||||
float offset = getRotationOffsetForPosition(be, pos, axis);
|
||||
return (time * be.getSpeed() * 3f / 20 + offset) % 360;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
protected BlockState getRenderedBlockState(GantryCarriageBlockEntity be) {
|
||||
return shaft(getRotationAxisOf(be));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
package com.simibubi.create.content.contraptions.components.structureMovement.piston;
|
||||
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class MechanicalPistonRenderer extends KineticBlockEntityRenderer {
|
||||
public class MechanicalPistonRenderer extends KineticBlockEntityRenderer<MechanicalPistonBlockEntity> {
|
||||
|
||||
public MechanicalPistonRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
protected BlockState getRenderedBlockState(MechanicalPistonBlockEntity be) {
|
||||
return shaft(getRotationAxisOf(be));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
|
||||
public abstract class AbstractPulleyInstance extends ShaftInstance implements DynamicInstance, TickingLightListener {
|
||||
public abstract class AbstractPulleyInstance<T extends KineticBlockEntity> extends ShaftInstance<T> implements DynamicInstance, TickingLightListener {
|
||||
|
||||
final OrientedData coil;
|
||||
final SelectInstance<OrientedData> magnet;
|
||||
|
@ -34,7 +34,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements Dy
|
|||
private final GridAlignedBB volume = new GridAlignedBB();
|
||||
private final LightVolume light;
|
||||
|
||||
public AbstractPulleyInstance(MaterialManager dispatcher, KineticBlockEntity blockEntity) {
|
||||
public AbstractPulleyInstance(MaterialManager dispatcher, T blockEntity) {
|
||||
super(dispatcher, blockEntity);
|
||||
|
||||
rotatingAbout = Direction.get(Direction.AxisDirection.POSITIVE, axis);
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public abstract class AbstractPulleyRenderer extends KineticBlockEntityRenderer {
|
||||
public abstract class AbstractPulleyRenderer<T extends KineticBlockEntity> extends KineticBlockEntityRenderer<T> {
|
||||
|
||||
private PartialModel halfRope;
|
||||
private PartialModel halfMagnet;
|
||||
|
@ -36,12 +36,12 @@ public abstract class AbstractPulleyRenderer extends KineticBlockEntityRenderer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen(KineticBlockEntity p_188185_1_) {
|
||||
public boolean shouldRenderOffScreen(T p_188185_1_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(T be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
|
||||
if (Backend.canUseInstancing(be.getLevel()))
|
||||
|
@ -89,24 +89,24 @@ public abstract class AbstractPulleyRenderer extends KineticBlockEntityRenderer
|
|||
.renderInto(ms, buffer);
|
||||
}
|
||||
|
||||
protected abstract Axis getShaftAxis(KineticBlockEntity be);
|
||||
protected abstract Axis getShaftAxis(T be);
|
||||
|
||||
protected abstract PartialModel getCoil();
|
||||
|
||||
protected abstract SuperByteBuffer renderRope(KineticBlockEntity be);
|
||||
protected abstract SuperByteBuffer renderRope(T be);
|
||||
|
||||
protected abstract SuperByteBuffer renderMagnet(KineticBlockEntity be);
|
||||
protected abstract SuperByteBuffer renderMagnet(T be);
|
||||
|
||||
protected abstract float getOffset(KineticBlockEntity be, float partialTicks);
|
||||
protected abstract float getOffset(T be, float partialTicks);
|
||||
|
||||
protected abstract boolean isRunning(KineticBlockEntity be);
|
||||
protected abstract boolean isRunning(T be);
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
protected BlockState getRenderedBlockState(T be) {
|
||||
return shaft(getShaftAxis(be));
|
||||
}
|
||||
|
||||
protected SuperByteBuffer getRotatedCoil(KineticBlockEntity be) {
|
||||
protected SuperByteBuffer getRotatedCoil(T be) {
|
||||
BlockState blockState = be.getBlockState();
|
||||
return CachedBufferer.partialFacing(getCoil(), blockState,
|
||||
Direction.get(AxisDirection.POSITIVE, getShaftAxis(be)));
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.content.contraptions.fluids.actors.HosePulleyBlockEntity;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
public class HosePulleyInstance extends AbstractPulleyInstance {
|
||||
public class HosePulleyInstance extends AbstractPulleyInstance<HosePulleyBlockEntity> {
|
||||
|
||||
public HosePulleyInstance(MaterialManager dispatcher, HosePulleyBlockEntity blockEntity) {
|
||||
super(dispatcher, blockEntity);
|
||||
|
@ -39,7 +39,7 @@ public class HosePulleyInstance extends AbstractPulleyInstance {
|
|||
}
|
||||
|
||||
protected float getOffset() {
|
||||
return ((HosePulleyBlockEntity) blockEntity).getInterpolatedOffset(AnimationTickHolder.getPartialTicks());
|
||||
return blockEntity.getInterpolatedOffset(AnimationTickHolder.getPartialTicks());
|
||||
}
|
||||
|
||||
protected boolean isRunning() {
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu
|
|||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -12,14 +11,14 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
|||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class PulleyRenderer extends AbstractPulleyRenderer {
|
||||
public class PulleyRenderer extends AbstractPulleyRenderer<PulleyBlockEntity> {
|
||||
|
||||
public PulleyRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context, AllBlockPartials.ROPE_HALF, AllBlockPartials.ROPE_HALF_MAGNET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Axis getShaftAxis(KineticBlockEntity be) {
|
||||
protected Axis getShaftAxis(PulleyBlockEntity be) {
|
||||
return be.getBlockState()
|
||||
.getValue(PulleyBlock.HORIZONTAL_AXIS);
|
||||
}
|
||||
|
@ -30,29 +29,27 @@ public class PulleyRenderer extends AbstractPulleyRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer renderRope(KineticBlockEntity be) {
|
||||
protected SuperByteBuffer renderRope(PulleyBlockEntity be) {
|
||||
return CachedBufferer.block(AllBlocks.ROPE.getDefaultState());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer renderMagnet(KineticBlockEntity be) {
|
||||
protected SuperByteBuffer renderMagnet(PulleyBlockEntity be) {
|
||||
return CachedBufferer.block(AllBlocks.PULLEY_MAGNET.getDefaultState());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getOffset(KineticBlockEntity be, float partialTicks) {
|
||||
PulleyBlockEntity pulley = (PulleyBlockEntity) be;
|
||||
return getBlockEntityOffset(partialTicks, pulley);
|
||||
protected float getOffset(PulleyBlockEntity be, float partialTicks) {
|
||||
return getBlockEntityOffset(partialTicks, be);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRunning(KineticBlockEntity be) {
|
||||
protected boolean isRunning(PulleyBlockEntity be) {
|
||||
return isPulleyRunning(be);
|
||||
}
|
||||
|
||||
public static boolean isPulleyRunning(KineticBlockEntity be) {
|
||||
PulleyBlockEntity pte = (PulleyBlockEntity) be;
|
||||
return pte.running || pte.mirrorParent != null || be.isVirtual();
|
||||
|
||||
public static boolean isPulleyRunning(PulleyBlockEntity be) {
|
||||
return be.running || be.mirrorParent != null || be.isVirtual();
|
||||
}
|
||||
|
||||
public static float getBlockEntityOffset(float partialTicks, PulleyBlockEntity blockEntity) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
public class RopePulleyInstance extends AbstractPulleyInstance {
|
||||
public class RopePulleyInstance extends AbstractPulleyInstance<PulleyBlockEntity> {
|
||||
public RopePulleyInstance(MaterialManager materialManager, PulleyBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class RopePulleyInstance extends AbstractPulleyInstance {
|
|||
|
||||
protected float getOffset() {
|
||||
float partialTicks = AnimationTickHolder.getPartialTicks();
|
||||
return PulleyRenderer.getBlockEntityOffset(partialTicks, (PulleyBlockEntity) blockEntity);
|
||||
return PulleyRenderer.getBlockEntityOffset(partialTicks, blockEntity);
|
||||
}
|
||||
|
||||
protected boolean isRunning() {
|
||||
|
|
|
@ -16,9 +16,8 @@ import net.minecraft.util.Mth;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class PumpCogInstance extends SingleRotatingInstance implements DynamicInstance {
|
||||
public class PumpCogInstance extends SingleRotatingInstance<PumpBlockEntity> implements DynamicInstance {
|
||||
|
||||
private final PumpBlockEntity blockEntity = (PumpBlockEntity) super.blockEntity;
|
||||
private final ModelData[] arrows = new ModelData[2];
|
||||
private final Direction direction = blockState.getValue(PumpBlock.FACING);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.fluids;
|
|||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -17,22 +16,20 @@ import net.minecraft.util.Mth;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class PumpRenderer extends KineticBlockEntityRenderer {
|
||||
public class PumpRenderer extends KineticBlockEntityRenderer<PumpBlockEntity> {
|
||||
|
||||
public PumpRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(PumpBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
if (Backend.canUseInstancing(be.getLevel())) return;
|
||||
if (!(be instanceof PumpBlockEntity pump))
|
||||
return;
|
||||
Vec3 rotationOffset = new Vec3(.5, 14 / 16f, .5);
|
||||
BlockState blockState = be.getBlockState();
|
||||
float angle = Mth.lerp(pump.arrowDirection.getValue(partialTicks), 0, 90) - 90;
|
||||
float angle = Mth.lerp(be.arrowDirection.getValue(partialTicks), 0, 90) - 90;
|
||||
SuperByteBuffer arrow = CachedBufferer.partial(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState);
|
||||
for (float yRot : new float[] { 0, 90 }) {
|
||||
Direction direction = blockState.getValue(PumpBlock.FACING);
|
||||
|
@ -50,7 +47,7 @@ public class PumpRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(PumpBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partialFacing(AllBlockPartials.MECHANICAL_PUMP_COG, state);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.fluids.actors;
|
|||
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.AbstractPulleyRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -10,14 +9,14 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
|
||||
public class HosePulleyRenderer extends AbstractPulleyRenderer {
|
||||
public class HosePulleyRenderer extends AbstractPulleyRenderer<HosePulleyBlockEntity> {
|
||||
|
||||
public HosePulleyRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context, AllBlockPartials.HOSE_HALF, AllBlockPartials.HOSE_HALF_MAGNET);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Axis getShaftAxis(KineticBlockEntity be) {
|
||||
protected Axis getShaftAxis(HosePulleyBlockEntity be) {
|
||||
return be.getBlockState()
|
||||
.getValue(HosePulleyBlock.HORIZONTAL_FACING)
|
||||
.getClockWise()
|
||||
|
@ -30,22 +29,22 @@ public class HosePulleyRenderer extends AbstractPulleyRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer renderRope(KineticBlockEntity be) {
|
||||
protected SuperByteBuffer renderRope(HosePulleyBlockEntity be) {
|
||||
return CachedBufferer.partial(AllBlockPartials.HOSE, be.getBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer renderMagnet(KineticBlockEntity be) {
|
||||
protected SuperByteBuffer renderMagnet(HosePulleyBlockEntity be) {
|
||||
return CachedBufferer.partial(AllBlockPartials.HOSE_MAGNET, be.getBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getOffset(KineticBlockEntity be, float partialTicks) {
|
||||
return ((HosePulleyBlockEntity) be).getInterpolatedOffset(partialTicks);
|
||||
protected float getOffset(HosePulleyBlockEntity be, float partialTicks) {
|
||||
return be.getInterpolatedOffset(partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRunning(KineticBlockEntity be) {
|
||||
protected boolean isRunning(HosePulleyBlockEntity be) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
|||
import com.jozufozu.flywheel.core.Materials;
|
||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -14,18 +13,16 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class FluidValveInstance extends ShaftInstance implements DynamicInstance {
|
||||
public class FluidValveInstance extends ShaftInstance<FluidValveBlockEntity> implements DynamicInstance {
|
||||
|
||||
private final FluidValveBlockEntity blockEntity;
|
||||
protected ModelData pointer;
|
||||
|
||||
protected final double xRot;
|
||||
protected final double yRot;
|
||||
protected final int pointerRotationOffset;
|
||||
|
||||
public FluidValveInstance(MaterialManager dispatcher, KineticBlockEntity blockEntity) {
|
||||
public FluidValveInstance(MaterialManager dispatcher, FluidValveBlockEntity blockEntity) {
|
||||
super(dispatcher, blockEntity);
|
||||
this.blockEntity = (FluidValveBlockEntity) blockEntity;
|
||||
|
||||
Direction facing = blockState.getValue(FluidValveBlock.FACING);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.fluids.pipes;
|
|||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -17,14 +16,14 @@ import net.minecraft.core.Direction.Axis;
|
|||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class FluidValveRenderer extends KineticBlockEntityRenderer {
|
||||
public class FluidValveRenderer extends KineticBlockEntityRenderer<FluidValveBlockEntity> {
|
||||
|
||||
public FluidValveRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(FluidValveBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
|
||||
if (Backend.canUseInstancing(be.getLevel())) return;
|
||||
|
@ -34,12 +33,9 @@ public class FluidValveRenderer extends KineticBlockEntityRenderer {
|
|||
SuperByteBuffer pointer = CachedBufferer.partial(AllBlockPartials.FLUID_VALVE_POINTER, blockState);
|
||||
Direction facing = blockState.getValue(FluidValveBlock.FACING);
|
||||
|
||||
if (!(be instanceof FluidValveBlockEntity valve))
|
||||
return;
|
||||
|
||||
float pointerRotation = Mth.lerp(valve.pointer.getValue(partialTicks), 0, -90);
|
||||
float pointerRotation = Mth.lerp(be.pointer.getValue(partialTicks), 0, -90);
|
||||
Axis pipeAxis = FluidValveBlock.getPipeAxis(blockState);
|
||||
Axis shaftAxis = KineticBlockEntityRenderer.getRotationAxisOf(be);
|
||||
Axis shaftAxis = getRotationAxisOf(be);
|
||||
|
||||
int pointerRotationOffset = 0;
|
||||
if (pipeAxis.isHorizontal() && shaftAxis == Axis.X || pipeAxis.isVertical())
|
||||
|
@ -55,8 +51,8 @@ public class FluidValveRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
return KineticBlockEntityRenderer.shaft(KineticBlockEntityRenderer.getRotationAxisOf(be));
|
||||
protected BlockState getRenderedBlockState(FluidValveBlockEntity be) {
|
||||
return shaft(getRotationAxisOf(be));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
|
||||
|
@ -16,11 +15,11 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.core.Direction.AxisDirection;
|
||||
|
||||
public class BracketedKineticBlockEntityInstance extends SingleRotatingInstance {
|
||||
public class BracketedKineticBlockEntityInstance extends SingleRotatingInstance<BracketedKineticBlockEntity> {
|
||||
|
||||
protected RotatingData additionalShaft;
|
||||
|
||||
public BracketedKineticBlockEntityInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public BracketedKineticBlockEntityInstance(MaterialManager materialManager, BracketedKineticBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.jozufozu.flywheel.backend.Backend;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -18,14 +17,14 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.core.Direction.AxisDirection;
|
||||
|
||||
public class BracketedKineticBlockEntityRenderer extends KineticBlockEntityRenderer {
|
||||
public class BracketedKineticBlockEntityRenderer extends KineticBlockEntityRenderer<BracketedKineticBlockEntity> {
|
||||
|
||||
public BracketedKineticBlockEntityRenderer(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(BracketedKineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
|
||||
if (Backend.canUseInstancing(be.getLevel()))
|
||||
|
|
|
@ -4,8 +4,8 @@ import com.jozufozu.flywheel.backend.Backend;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.SimpleKineticBlockEntity;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
@ -18,7 +18,7 @@ import net.minecraft.core.Direction.AxisDirection;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class EncasedCogRenderer extends KineticBlockEntityRenderer {
|
||||
public class EncasedCogRenderer extends KineticBlockEntityRenderer<SimpleKineticBlockEntity> {
|
||||
|
||||
private boolean large;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class EncasedCogRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(SimpleKineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
if (Backend.canUseInstancing(be.getLevel()))
|
||||
|
@ -57,7 +57,7 @@ public class EncasedCogRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(SimpleKineticBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partialFacingVertical(
|
||||
large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL, state,
|
||||
Direction.fromAxisAndDirection(state.getValue(EncasedCogwheelBlock.AXIS), AxisDirection.POSITIVE));
|
||||
|
|
|
@ -6,9 +6,9 @@ import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
|||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class ShaftInstance extends SingleRotatingInstance {
|
||||
public class ShaftInstance<T extends KineticBlockEntity> extends SingleRotatingInstance<T> {
|
||||
|
||||
public ShaftInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public ShaftInstance(MaterialManager materialManager, T blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
|||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class ShaftRenderer extends KineticBlockEntityRenderer {
|
||||
public class ShaftRenderer<T extends KineticBlockEntity> extends KineticBlockEntityRenderer<T> {
|
||||
|
||||
public ShaftRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.jozufozu.flywheel.backend.Backend;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -19,14 +18,14 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class SplitShaftRenderer extends KineticBlockEntityRenderer {
|
||||
public class SplitShaftRenderer extends KineticBlockEntityRenderer<SplitShaftBlockEntity> {
|
||||
|
||||
public SplitShaftRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(SplitShaftBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
if (Backend.canUseInstancing(be.getLevel())) return;
|
||||
|
||||
|
@ -42,10 +41,7 @@ public class SplitShaftRenderer extends KineticBlockEntityRenderer {
|
|||
|
||||
float offset = getRotationOffsetForPosition(be, pos, axis);
|
||||
float angle = (time * be.getSpeed() * 3f / 10) % 360;
|
||||
float modifier = 1;
|
||||
|
||||
if (be instanceof SplitShaftBlockEntity)
|
||||
modifier = ((SplitShaftBlockEntity) be).getRotationSpeedModifier(direction);
|
||||
float modifier = be.getRotationSpeedModifier(direction);
|
||||
|
||||
angle *= modifier;
|
||||
angle += offset;
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.jozufozu.flywheel.core.materials.model.ModelData;
|
|||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
|
@ -18,18 +17,17 @@ import com.simibubi.create.foundation.utility.Iterate;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public abstract class GaugeInstance extends ShaftInstance implements DynamicInstance {
|
||||
public abstract class GaugeInstance extends ShaftInstance<GaugeBlockEntity> implements DynamicInstance {
|
||||
|
||||
protected final ArrayList<DialFace> faces;
|
||||
|
||||
protected PoseStack ms;
|
||||
|
||||
protected GaugeInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
protected GaugeInstance(MaterialManager materialManager, GaugeBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
|
||||
faces = new ArrayList<>(2);
|
||||
|
||||
GaugeBlockEntity gaugeBlockEntity = (GaugeBlockEntity) blockEntity;
|
||||
GaugeBlock gaugeBlock = (GaugeBlock) blockState.getBlock();
|
||||
|
||||
Instancer<ModelData> dialModel = getTransformMaterial().getModel(AllBlockPartials.GAUGE_DIAL, blockState);
|
||||
|
@ -39,7 +37,7 @@ public abstract class GaugeInstance extends ShaftInstance implements DynamicInst
|
|||
TransformStack msr = TransformStack.cast(ms);
|
||||
msr.translate(getInstancePosition());
|
||||
|
||||
float progress = Mth.lerp(AnimationTickHolder.getPartialTicks(), gaugeBlockEntity.prevDialState, gaugeBlockEntity.dialState);
|
||||
float progress = Mth.lerp(AnimationTickHolder.getPartialTicks(), blockEntity.prevDialState, blockEntity.dialState);
|
||||
|
||||
for (Direction facing : Iterate.directions) {
|
||||
if (!gaugeBlock.shouldRenderHeadOnFace(world, pos, blockState, facing))
|
||||
|
@ -144,7 +142,7 @@ public abstract class GaugeInstance extends ShaftInstance implements DynamicInst
|
|||
}
|
||||
|
||||
public static class Speed extends GaugeInstance {
|
||||
public Speed(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public Speed(MaterialManager materialManager, GaugeBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
@ -155,7 +153,7 @@ public abstract class GaugeInstance extends ShaftInstance implements DynamicInst
|
|||
}
|
||||
|
||||
public static class Stress extends GaugeInstance {
|
||||
public Stress(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public Stress(MaterialManager materialManager, GaugeBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock.Type;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -19,7 +19,7 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class GaugeRenderer extends KineticBlockEntityRenderer {
|
||||
public class GaugeRenderer extends ShaftRenderer {
|
||||
|
||||
protected GaugeBlock.Type type;
|
||||
|
||||
|
@ -70,11 +70,6 @@ public class GaugeRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
return shaft(getRotationAxisOf(be));
|
||||
}
|
||||
|
||||
protected SuperByteBuffer rotateBufferTowards(SuperByteBuffer buffer, Direction target) {
|
||||
return buffer.rotateCentered(Direction.UP, (float) ((-target.toYRot() - 90) / 180 * Math.PI));
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.simibubi.create.content.contraptions.relays.gearbox;
|
|||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -18,14 +17,14 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
||||
public class GearboxRenderer extends KineticBlockEntityRenderer {
|
||||
public class GearboxRenderer extends KineticBlockEntityRenderer<GearboxBlockEntity> {
|
||||
|
||||
public GearboxRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(GearboxBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
if (Backend.canUseInstancing(be.getLevel())) return;
|
||||
|
||||
|
|
|
@ -2,13 +2,12 @@ package com.simibubi.create.content.curiosities.armor;
|
|||
|
||||
import com.jozufozu.flywheel.api.Instancer;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
|
||||
|
||||
public class BacktankInstance extends SingleRotatingInstance {
|
||||
public class BacktankInstance extends SingleRotatingInstance<BacktankBlockEntity> {
|
||||
|
||||
public BacktankInstance(MaterialManager materialManager, KineticBlockEntity blockEntity) {
|
||||
public BacktankInstance(MaterialManager materialManager, BacktankBlockEntity blockEntity) {
|
||||
super(materialManager, blockEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.jozufozu.flywheel.core.PartialModel;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -17,13 +16,13 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class BacktankRenderer extends KineticBlockEntityRenderer {
|
||||
public class BacktankRenderer extends KineticBlockEntityRenderer<BacktankBlockEntity> {
|
||||
public BacktankRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(BacktankBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
|
@ -41,7 +40,7 @@ public class BacktankRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(BacktankBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partial(getShaftModel(state), state);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
|||
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class EjectorInstance extends ShaftInstance implements DynamicInstance {
|
||||
|
||||
protected final EjectorBlockEntity blockEntity;
|
||||
public class EjectorInstance extends ShaftInstance<EjectorBlockEntity> implements DynamicInstance {
|
||||
|
||||
protected final ModelData plate;
|
||||
|
||||
|
@ -19,7 +17,6 @@ public class EjectorInstance extends ShaftInstance implements DynamicInstance {
|
|||
|
||||
public EjectorInstance(MaterialManager dispatcher, EjectorBlockEntity blockEntity) {
|
||||
super(dispatcher, blockEntity);
|
||||
this.blockEntity = blockEntity;
|
||||
|
||||
plate = getTransformMaterial().getModel(AllBlockPartials.EJECTOR_TOP, blockState).createInstance();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -21,10 +21,9 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class EjectorRenderer extends KineticBlockEntityRenderer {
|
||||
public class EjectorRenderer extends ShaftRenderer<EjectorBlockEntity> {
|
||||
|
||||
static final Vec3 pivot = VecHelper.voxelSpace(0, 11.25, 0.75);
|
||||
|
||||
|
@ -33,18 +32,17 @@ public class EjectorRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen(KineticBlockEntity p_188185_1_) {
|
||||
public boolean shouldRenderOffScreen(EjectorBlockEntity p_188185_1_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(EjectorBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
EjectorBlockEntity ejector = (EjectorBlockEntity) be;
|
||||
VertexConsumer vertexBuilder = buffer.getBuffer(RenderType.solid());
|
||||
float lidProgress = ((EjectorBlockEntity) be).getLidProgress(partialTicks);
|
||||
float lidProgress = be.getLidProgress(partialTicks);
|
||||
float angle = lidProgress * 70;
|
||||
|
||||
if (!Backend.canUseInstancing(be.getLevel())) {
|
||||
|
@ -57,18 +55,18 @@ public class EjectorRenderer extends KineticBlockEntityRenderer {
|
|||
TransformStack msr = TransformStack.cast(ms);
|
||||
|
||||
float maxTime =
|
||||
(float) (ejector.earlyTarget != null ? ejector.earlyTargetTime : ejector.launcher.getTotalFlyingTicks());
|
||||
for (IntAttached<ItemStack> intAttached : ejector.launchedItems) {
|
||||
(float) (be.earlyTarget != null ? be.earlyTargetTime : be.launcher.getTotalFlyingTicks());
|
||||
for (IntAttached<ItemStack> intAttached : be.launchedItems) {
|
||||
float time = intAttached.getFirst() + partialTicks;
|
||||
if (time > maxTime)
|
||||
continue;
|
||||
|
||||
ms.pushPose();
|
||||
Vec3 launchedItemLocation = ejector.getLaunchedItemLocation(time);
|
||||
Vec3 launchedItemLocation = be.getLaunchedItemLocation(time);
|
||||
msr.translate(launchedItemLocation.subtract(Vec3.atLowerCornerOf(be.getBlockPos())));
|
||||
Vec3 itemRotOffset = VecHelper.voxelSpace(0, 3, 0);
|
||||
msr.translate(itemRotOffset);
|
||||
msr.rotateY(AngleHelper.horizontalAngle(ejector.getFacing()));
|
||||
msr.rotateY(AngleHelper.horizontalAngle(be.getFacing()));
|
||||
msr.rotateX(time * 40);
|
||||
msr.translateBack(itemRotOffset);
|
||||
Minecraft.getInstance()
|
||||
|
@ -105,9 +103,4 @@ public class EjectorRenderer extends KineticBlockEntityRenderer {
|
|||
.translateBack(rotationOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState(KineticBlockEntity be) {
|
||||
return shaft(getRotationAxisOf(be));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import net.minecraft.util.Mth;
|
|||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class ArmInstance extends SingleRotatingInstance implements DynamicInstance {
|
||||
public class ArmInstance extends SingleRotatingInstance<ArmBlockEntity> implements DynamicInstance {
|
||||
|
||||
final ModelData base;
|
||||
final ModelData lowerBody;
|
||||
|
@ -34,7 +34,6 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
|
|||
private final ArrayList<ModelData> clawGrips;
|
||||
|
||||
private final ArrayList<ModelData> models;
|
||||
private final ArmBlockEntity arm;
|
||||
private final Boolean ceiling;
|
||||
|
||||
private boolean firstRender = true;
|
||||
|
@ -66,7 +65,6 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
|
|||
|
||||
clawGrips = Lists.newArrayList(clawGrip1, clawGrip2);
|
||||
models = Lists.newArrayList(base, lowerBody, upperBody, head, claw, clawGrip1, clawGrip2);
|
||||
arm = blockEntity;
|
||||
ceiling = blockState.getValue(ArmBlock.CEILING);
|
||||
|
||||
animateArm(false);
|
||||
|
@ -74,7 +72,7 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
|
|||
|
||||
@Override
|
||||
public void beginFrame() {
|
||||
if (arm.phase == ArmBlockEntity.Phase.DANCING && blockEntity.getSpeed() != 0) {
|
||||
if (blockEntity.phase == ArmBlockEntity.Phase.DANCING && blockEntity.getSpeed() != 0) {
|
||||
animateArm(true);
|
||||
firstRender = true;
|
||||
return;
|
||||
|
@ -82,10 +80,10 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
|
|||
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
|
||||
float baseAngleNow = arm.baseAngle.getValue(pt);
|
||||
float lowerArmAngleNow = arm.lowerArmAngle.getValue(pt);
|
||||
float upperArmAngleNow = arm.upperArmAngle.getValue(pt);
|
||||
float headAngleNow = arm.headAngle.getValue(pt);
|
||||
float baseAngleNow = blockEntity.baseAngle.getValue(pt);
|
||||
float lowerArmAngleNow = blockEntity.lowerArmAngle.getValue(pt);
|
||||
float upperArmAngleNow = blockEntity.upperArmAngle.getValue(pt);
|
||||
float headAngleNow = blockEntity.headAngle.getValue(pt);
|
||||
|
||||
boolean settled = Mth.equal(baseAngle, baseAngleNow) && Mth.equal(lowerArmAngle, lowerArmAngleNow)
|
||||
&& Mth.equal(upperArmAngle, upperArmAngleNow) && Mth.equal(headAngle, headAngleNow);
|
||||
|
@ -110,7 +108,7 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
|
|||
int color;
|
||||
|
||||
if (rave) {
|
||||
float renderTick = AnimationTickHolder.getRenderTime(this.arm.getLevel()) + (blockEntity.hashCode() % 64);
|
||||
float renderTick = AnimationTickHolder.getRenderTime(blockEntity.getLevel()) + (blockEntity.hashCode() % 64);
|
||||
baseAngle = (renderTick * 10) % 360;
|
||||
lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15);
|
||||
upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95);
|
||||
|
@ -150,7 +148,7 @@ public class ArmInstance extends SingleRotatingInstance implements DynamicInstan
|
|||
ArmRenderer.transformClaw(msr);
|
||||
claw.setTransform(msLocal);
|
||||
|
||||
ItemStack item = this.arm.heldItem;
|
||||
ItemStack item = blockEntity.heldItem;
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance()
|
||||
.getItemRenderer();
|
||||
boolean hasItem = !item.isEmpty();
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.jozufozu.flywheel.util.transform.TransformStack;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmBlockEntity.Phase;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
|
@ -25,19 +24,18 @@ import net.minecraft.world.item.BlockItem;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class ArmRenderer extends KineticBlockEntityRenderer {
|
||||
public class ArmRenderer extends KineticBlockEntityRenderer<ArmBlockEntity> {
|
||||
|
||||
public ArmRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float pt, PoseStack ms, MultiBufferSource buffer, int light,
|
||||
protected void renderSafe(ArmBlockEntity be, float pt, PoseStack ms, MultiBufferSource buffer, int light,
|
||||
int overlay) {
|
||||
super.renderSafe(be, pt, ms, buffer, light, overlay);
|
||||
|
||||
ArmBlockEntity arm = (ArmBlockEntity) be;
|
||||
ItemStack item = arm.heldItem;
|
||||
ItemStack item = be.heldItem;
|
||||
boolean hasItem = !item.isEmpty();
|
||||
boolean usingFlywheel = Backend.canUseInstancing(be.getLevel());
|
||||
|
||||
|
@ -63,7 +61,7 @@ public class ArmRenderer extends KineticBlockEntityRenderer {
|
|||
float headAngle;
|
||||
int color;
|
||||
|
||||
boolean rave = arm.phase == Phase.DANCING && be.getSpeed() != 0;
|
||||
boolean rave = be.phase == Phase.DANCING && be.getSpeed() != 0;
|
||||
if (rave) {
|
||||
float renderTick = AnimationTickHolder.getRenderTime(be.getLevel()) + (be.hashCode() % 64);
|
||||
baseAngle = (renderTick * 10) % 360;
|
||||
|
@ -73,10 +71,10 @@ public class ArmRenderer extends KineticBlockEntityRenderer {
|
|||
color = Color.rainbowColor(AnimationTickHolder.getTicks() * 100)
|
||||
.getRGB();
|
||||
} else {
|
||||
baseAngle = arm.baseAngle.getValue(pt);
|
||||
lowerArmAngle = arm.lowerArmAngle.getValue(pt) - 135;
|
||||
upperArmAngle = arm.upperArmAngle.getValue(pt) - 90;
|
||||
headAngle = arm.headAngle.getValue(pt);
|
||||
baseAngle = be.baseAngle.getValue(pt);
|
||||
lowerArmAngle = be.lowerArmAngle.getValue(pt) - 135;
|
||||
upperArmAngle = be.upperArmAngle.getValue(pt) - 90;
|
||||
headAngle = be.headAngle.getValue(pt);
|
||||
color = 0xFFFFFF;
|
||||
}
|
||||
|
||||
|
@ -197,12 +195,12 @@ public class ArmRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen(KineticBlockEntity be) {
|
||||
public boolean shouldRenderOffScreen(ArmBlockEntity be) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(ArmBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partial(AllBlockPartials.ARM_COG, state);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.mojang.blaze3d.vertex.PoseStack.Pose;
|
|||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticBlockEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
@ -34,14 +33,14 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class FlapDisplayRenderer extends KineticBlockEntityRenderer {
|
||||
public class FlapDisplayRenderer extends KineticBlockEntityRenderer<FlapDisplayBlockEntity> {
|
||||
|
||||
public FlapDisplayRenderer(BlockEntityRendererProvider.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
protected void renderSafe(FlapDisplayBlockEntity be, float partialTicks, PoseStack ms, MultiBufferSource buffer,
|
||||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
|
@ -50,13 +49,10 @@ public class FlapDisplayRenderer extends KineticBlockEntityRenderer {
|
|||
|
||||
float scale = 1 / 32f;
|
||||
|
||||
if (!(be instanceof FlapDisplayBlockEntity flapTe))
|
||||
if (!be.isController)
|
||||
return;
|
||||
|
||||
if (!flapTe.isController)
|
||||
return;
|
||||
|
||||
List<FlapDisplayLayout> lines = flapTe.getLines();
|
||||
List<FlapDisplayLayout> lines = be.getLines();
|
||||
|
||||
ms.pushPose();
|
||||
TransformStack.cast(ms)
|
||||
|
@ -74,17 +70,17 @@ public class FlapDisplayRenderer extends KineticBlockEntityRenderer {
|
|||
for (int j = 0; j < lines.size(); j++) {
|
||||
List<FlapDisplaySection> line = lines.get(j)
|
||||
.getSections();
|
||||
int color = flapTe.getLineColor(j);
|
||||
int color = be.getLineColor(j);
|
||||
ms.pushPose();
|
||||
|
||||
float w = 0;
|
||||
for (FlapDisplaySection section : line)
|
||||
w += section.getSize() + (section.hasGap ? 8 : 1);
|
||||
ms.translate(flapTe.xSize * 16 - w / 2 + 1, 4.5f, 0);
|
||||
ms.translate(be.xSize * 16 - w / 2 + 1, 4.5f, 0);
|
||||
|
||||
Pose transform = ms.last();
|
||||
FlapDisplayRenderOutput renderOutput = new FlapDisplayRenderOutput(buffer, color, transform.pose(), light,
|
||||
j, !be.isSpeedRequirementFulfilled(), be.getLevel(), flapTe.isLineGlowing(j));
|
||||
j, !be.isSpeedRequirementFulfilled(), be.getLevel(), be.isLineGlowing(j));
|
||||
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
FlapDisplaySection section = line.get(i);
|
||||
|
@ -231,14 +227,14 @@ public class FlapDisplayRenderer extends KineticBlockEntityRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticBlockEntity be, BlockState state) {
|
||||
protected SuperByteBuffer getRotatedModel(FlapDisplayBlockEntity be, BlockState state) {
|
||||
return CachedBufferer.partialFacingVertical(AllBlockPartials.SHAFTLESS_COGWHEEL, state,
|
||||
state.getValue(FlapDisplayBlock.HORIZONTAL_FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderOffScreen(KineticBlockEntity pBlockEntity) {
|
||||
return ((FlapDisplayBlockEntity) pBlockEntity).isController;
|
||||
public boolean shouldRenderOffScreen(FlapDisplayBlockEntity be) {
|
||||
return be.isController;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue