This commit is contained in:
gnembon committed 2025-09-04 02:08:10 +02:00
1 parent 6533716c93
commit f371e2e8bd
29 files changed
+222 -153

No files matched your search

@@ -1,14 +1,16 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.fakes.PistonHeadRenderStateInterface;
import carpet.fakes.PistonBlockEntityInterface;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.blockentity.PistonHeadRenderer;
import net.minecraft.client.renderer.blockentity.state.BlockEntityRenderState;
import net.minecraft.client.renderer.blockentity.state.PistonHeadRenderState;
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
@@ -17,48 +19,51 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(PistonHeadRenderer.class)
public abstract class PistonHeadRenderer_movableBEMixin implements BlockEntityRenderer<PistonMovingBlockEntity>
public abstract class PistonHeadRenderer_movableBEMixin implements BlockEntityRenderer<PistonMovingBlockEntity, PistonHeadRenderState>
{
BlockEntityRenderDispatcher dispatcher;
@Inject(method = "<init>", at = @At("TAIL"))
private void onInitCM(BlockEntityRendererProvider.Context arguments, CallbackInfo ci)
private void onInitCM(CallbackInfo ci)
{
dispatcher = arguments.blockEntityRenderDispatcher();
dispatcher = Minecraft.getInstance().getBlockEntityRenderDispatcher();
}
@Inject(method = "submit(Lnet/minecraft/world/level/block/piston/PistonMovingBlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;IILnet/minecraft/world/phys/Vec3;Lnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;Lnet/minecraft/client/renderer/SubmitNodeCollector;)V", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/renderer/blockentity/PistonHeadRenderer;submitMovingBlock(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Holder;Lnet/minecraft/world/level/Level;)V",
ordinal = 3))
private void updateRenderBool(PistonMovingBlockEntity pistonBlockEntity_1, float f, PoseStack poseStack, int i, int j, Vec3 vec3, ModelFeatureRenderer.CrumblingOverlay crumblingOverlay, SubmitNodeCollector submitNodeCollector, CallbackInfo ci)
//private void updateRenderBool(PistonBlockEntity pistonBlockEntity_1, double double_1, double double_2, double double_3, float float_1, class_4587 class_4587_1, class_4597 class_4597_1, int int_1, CallbackInfo ci)
@Inject(method = "extractRenderState(Lnet/minecraft/world/level/block/piston/PistonMovingBlockEntity;Lnet/minecraft/client/renderer/blockentity/state/PistonHeadRenderState;FLnet/minecraft/world/phys/Vec3;Lnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;)V",
at = @At("RETURN"))
private void addBE(PistonMovingBlockEntity pistonMovingBlockEntity, PistonHeadRenderState pistonHeadRenderState, float f, Vec3 vec3, ModelFeatureRenderer.CrumblingOverlay crumblingOverlay, CallbackInfo ci)
{
if (!((PistonBlockEntityInterface) pistonBlockEntity_1).isRenderModeSet())
((PistonBlockEntityInterface) pistonBlockEntity_1).setRenderCarriedBlockEntity(CarpetSettings.movableBlockEntities && ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity() != null);
}
@Inject(method = "submit(Lnet/minecraft/world/level/block/piston/PistonMovingBlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;IILnet/minecraft/world/phys/Vec3;Lnet/minecraft/client/renderer/feature/ModelFeatureRenderer$CrumblingOverlay;Lnet/minecraft/client/renderer/SubmitNodeCollector;)V", at = @At("RETURN"), locals = LocalCapture.NO_CAPTURE)
private void endMethod(PistonMovingBlockEntity pistonBlockEntity_1, float partialTicks, PoseStack matrixStack_1, int i, int j, Vec3 vec3, ModelFeatureRenderer.CrumblingOverlay crumblingOverlay, SubmitNodeCollector submitNodeCollector, CallbackInfo ci)
//private void endMethod3576(PistonMovingBlockEntity pistonBlockEntity_1, float partialTicks, PoseStack matrixStack_1, MultiBufferSource layeredVertexConsumerStorage_1, int int_1, int init_2, Vec3 cameraPos, CallbackInfo ci)
{
if (((PistonBlockEntityInterface) pistonBlockEntity_1).getRenderCarriedBlockEntity())
if (CarpetSettings.movableBlockEntities)
{
BlockEntity carriedBlockEntity = ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity();
if (carriedBlockEntity != null)
BlockEntity be = ((PistonBlockEntityInterface) pistonMovingBlockEntity).getCarriedBlockEntity();
if (be != null)
{
// maybe ??? carriedBlockEntity.setPos(pistonBlockEntity_1.getPos());
//((BlockEntityRenderDispatcherInterface) BlockEntityRenderDispatcher.INSTANCE).renderBlockEntityOffset(carriedBlockEntity, float_1, int_1, BlockRenderLayer.field_20799, bufferBuilder_1, pistonBlockEntity_1.getRenderOffsetX(float_1), pistonBlockEntity_1.getRenderOffsetY(float_1), pistonBlockEntity_1.getRenderOffsetZ(float_1));
matrixStack_1.translate(
pistonBlockEntity_1.getXOff(partialTicks),
pistonBlockEntity_1.getYOff(partialTicks),
pistonBlockEntity_1.getZOff(partialTicks)
);
dispatcher.submit(carriedBlockEntity, partialTicks, matrixStack_1, crumblingOverlay, submitNodeCollector);
float progress = pistonMovingBlockEntity.getProgress(f);
//System.out.println("progress: " + progress);
//if (progress != 0) {
BlockEntityRenderState res = dispatcher.tryExtractRenderState(be, f, crumblingOverlay);
if (res != null) {
((PistonHeadRenderStateInterface) pistonHeadRenderState).setMovedBERenderState(res);
}
//}
}
}
}
@Inject(method = "submit(Lnet/minecraft/client/renderer/blockentity/state/PistonHeadRenderState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/SubmitNodeCollector;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/SubmitNodeCollector;submitMovingBlock(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/block/MovingBlockRenderState;)V",
ordinal = 0))
private void endMethod(PistonHeadRenderState pistonHeadRenderState, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CallbackInfo ci)
//private void endMethod(PistonMovingBlockEntity pistonBlockEntity_1, float partialTicks, PoseStack matrixStack_1, int i, int j, Vec3 vec3, ModelFeatureRenderer.CrumblingOverlay crumblingOverlay, SubmitNodeCollector submitNodeCollector, CallbackInfo ci)
//private void endMethod3576(PistonMovingBlockEntity pistonBlockEntity_1, float partialTicks, PoseStack matrixStack_1, MultiBufferSource layeredVertexConsumerStorage_1, int int_1, int init_2, Vec3 cameraPos, CallbackInfo ci)
{
if (pistonHeadRenderState instanceof PistonHeadRenderStateInterface mbrsi && pistonHeadRenderState.block != null)
if (mbrsi.getMovedBERenderState() != null) {
BlockEntityRenderState res = mbrsi.getMovedBERenderState();
if (res != null) {
dispatcher.submit(res, poseStack, submitNodeCollector);
}
}
}
}