|
| 1 | +package net.modfest.fireblanket.mixin.client.bakery.sign; |
| 2 | + |
| 3 | +import com.mojang.blaze3d.vertex.PoseStack; |
| 4 | +import net.minecraft.client.Minecraft; |
| 5 | +import net.minecraft.client.model.Model; |
| 6 | +import net.minecraft.client.renderer.SubmitNodeCollector; |
| 7 | +import net.minecraft.client.renderer.blockentity.AbstractSignRenderer; |
| 8 | +import net.minecraft.client.renderer.blockentity.state.SignRenderState; |
| 9 | +import net.minecraft.client.renderer.feature.ModelFeatureRenderer; |
| 10 | +import net.minecraft.client.renderer.state.level.CameraRenderState; |
| 11 | +import net.minecraft.client.resources.model.sprite.SpriteId; |
| 12 | +import net.minecraft.core.BlockPos; |
| 13 | +import net.minecraft.world.level.block.SignBlock; |
| 14 | +import net.minecraft.world.level.block.entity.SignBlockEntity; |
| 15 | +import net.minecraft.world.level.block.state.properties.WoodType; |
| 16 | +import net.minecraft.world.phys.Vec3; |
| 17 | +import net.modfest.fireblanket.mixinsupport.client.RetrofitBakery; |
| 18 | +import org.jetbrains.annotations.MustBeInvokedByOverriders; |
| 19 | +import org.jetbrains.annotations.Nullable; |
| 20 | +import org.spongepowered.asm.mixin.Mixin; |
| 21 | +import org.spongepowered.asm.mixin.Overwrite; |
| 22 | +import org.spongepowered.asm.mixin.Shadow; |
| 23 | + |
| 24 | +/** |
| 25 | + * @author Ampflower |
| 26 | + * @since ${version} |
| 27 | + **/ |
| 28 | +@Mixin(AbstractSignRenderer.class) |
| 29 | +public class MixinAbstractSignRenderer<E extends SignBlockEntity, S extends SignRenderState> implements RetrofitBakery<E, S> { |
| 30 | + |
| 31 | + /** |
| 32 | + * @vanilla-copy {@link AbstractSignRenderer#extractRenderState(SignBlockEntity, SignRenderState, float, Vec3, ModelFeatureRenderer.CrumblingOverlay)} |
| 33 | + */ |
| 34 | + @Override |
| 35 | + public void extractBakingRenderState(final E blockEntity, final S state, final int light) { |
| 36 | + RetrofitBakery.super.extractBakingRenderState(blockEntity, state, light); |
| 37 | + state.maxTextLineWidth = blockEntity.getMaxTextLineWidth(); |
| 38 | + state.textLineHeight = blockEntity.getTextLineHeight(); |
| 39 | + state.frontText = blockEntity.getFrontText(); |
| 40 | + state.backText = blockEntity.getBackText(); |
| 41 | + state.isTextFilteringEnabled = Minecraft.getInstance().isTextFilteringEnabled(); |
| 42 | + // PARITY CHANGE: Bake as if we're always in range or scoping. |
| 43 | + // We're baking it down, we cannot use any distance check. |
| 44 | + state.drawOutline = true; |
| 45 | + state.woodType = SignBlock.getWoodType(blockEntity.getBlockState().getBlock()); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @author Ampflower |
| 50 | + * @reason intentionally break other mixins into here, minimize stuff copied to the render state |
| 51 | + */ |
| 52 | + @Override |
| 53 | + @Overwrite |
| 54 | + @MustBeInvokedByOverriders |
| 55 | + public void extractRenderState( |
| 56 | + final E blockEntity, |
| 57 | + final S state, |
| 58 | + final float partialTicks, |
| 59 | + final Vec3 cameraPosition, |
| 60 | + final ModelFeatureRenderer.CrumblingOverlay breakProgress |
| 61 | + ) { |
| 62 | + RetrofitBakery.super.extractRenderState(blockEntity, state, partialTicks, cameraPosition, breakProgress); |
| 63 | + state.woodType = SignBlock.getWoodType(blockEntity.getBlockState().getBlock()); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @author Ampflower |
| 68 | + * @reason Delegate to crumbling, intentionally break other mixins into here. |
| 69 | + */ |
| 70 | + @Override |
| 71 | + @Overwrite |
| 72 | + public void submit( |
| 73 | + final S state, |
| 74 | + final PoseStack poseStack, |
| 75 | + final SubmitNodeCollector submitNodeCollector, |
| 76 | + final CameraRenderState camera |
| 77 | + ) { |
| 78 | + if (state.breakProgress == null) { |
| 79 | + return; |
| 80 | + } |
| 81 | + poseStack.pushPose(); |
| 82 | + poseStack.mulPose(state.transformations.body()); |
| 83 | + Model.Simple bodyModel = this.getSignModel(state); |
| 84 | + this.submitSign( |
| 85 | + poseStack, |
| 86 | + state.lightCoords, |
| 87 | + state.woodType, |
| 88 | + bodyModel, |
| 89 | + state.breakProgress, |
| 90 | + submitNodeCollector |
| 91 | + ); |
| 92 | + poseStack.popPose(); |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public void submitForBaking( |
| 97 | + final S state, |
| 98 | + final PoseStack poseStack, |
| 99 | + final SubmitNodeCollector submitNodeCollector |
| 100 | + ) { |
| 101 | + this.submitSignWithText(state, poseStack, /* Always send */ null, submitNodeCollector); |
| 102 | + } |
| 103 | + |
| 104 | + @Shadow |
| 105 | + private void submitSignWithText( |
| 106 | + final S state, |
| 107 | + final PoseStack poseStack, |
| 108 | + @Nullable final ModelFeatureRenderer.CrumblingOverlay breakProgress, |
| 109 | + final SubmitNodeCollector submitNodeCollector |
| 110 | + ) { |
| 111 | + throw new AssertionError(); |
| 112 | + } |
| 113 | + |
| 114 | + @Shadow |
| 115 | + protected void submitSign( |
| 116 | + final PoseStack poseStack, |
| 117 | + final int lightCoords, |
| 118 | + final WoodType type, |
| 119 | + final Model.Simple signModel, |
| 120 | + final ModelFeatureRenderer.CrumblingOverlay breakProgress, |
| 121 | + final SubmitNodeCollector submitNodeCollector |
| 122 | + ) { |
| 123 | + throw new AssertionError(); |
| 124 | + } |
| 125 | + |
| 126 | + @Shadow |
| 127 | + protected Model.Simple getSignModel(S state) { |
| 128 | + throw new AssertionError(); |
| 129 | + } |
| 130 | + |
| 131 | + @Shadow |
| 132 | + protected SpriteId getSignSprite(WoodType type) { |
| 133 | + throw new AssertionError(); |
| 134 | + } |
| 135 | + |
| 136 | + @Shadow |
| 137 | + private static boolean isOutlineVisible(final BlockPos pos) { |
| 138 | + throw new AssertionError(); |
| 139 | + } |
| 140 | +} |
0 commit comments