|
4 | 4 | import com.mojang.blaze3d.vertex.IVertexBuilder; |
5 | 5 | import dev.compactmods.crafting.CompactCrafting; |
6 | 6 | import dev.compactmods.crafting.api.field.IMiniaturizationField; |
| 7 | +import dev.compactmods.crafting.api.field.MiniaturizationFieldSize; |
7 | 8 | import dev.compactmods.crafting.client.ClientConfig; |
8 | 9 | import dev.compactmods.crafting.projector.EnumProjectorColorType; |
9 | 10 | import dev.compactmods.crafting.projector.FieldProjectorBlock; |
|
23 | 24 | import net.minecraft.util.Direction; |
24 | 25 | import net.minecraft.util.ResourceLocation; |
25 | 26 | import net.minecraft.util.math.AxisAlignedBB; |
| 27 | +import net.minecraft.util.math.BlockPos; |
26 | 28 | import net.minecraft.util.math.BlockRayTraceResult; |
27 | 29 | import net.minecraft.util.math.RayTraceResult; |
28 | 30 | import net.minecraft.util.math.vector.Vector3d; |
@@ -64,19 +66,23 @@ public void render(FieldProjectorTile tile, float partialTicks, MatrixStack matr |
64 | 66 |
|
65 | 67 | renderDish(tile, matrixStack, buffers, combinedLightIn, combinedOverlayIn, gameTime); |
66 | 68 |
|
67 | | - tile.getField().ifPresent(field -> { |
| 69 | + AxisAlignedBB bounds = tile.getField().map(field -> { |
68 | 70 | double scale = MathUtil.calculateFieldScale(field); |
| 71 | + return field.getBounds().deflate((1 - scale) * (field.getFieldSize().getSize() / 2.0)); |
| 72 | + }).orElseGet(() -> { |
| 73 | + BlockState state = tile.getBlockState(); |
| 74 | + final MiniaturizationFieldSize fieldSize = state.getValue(FieldProjectorBlock.SIZE); |
| 75 | + final BlockPos center = fieldSize.getCenterFromProjector(tile.getBlockPos(), state.getValue(FieldProjectorBlock.FACING)); |
| 76 | + return fieldSize.getBoundsAtPosition(center); |
| 77 | + }); |
69 | 78 |
|
70 | | - AxisAlignedBB bounds = field.getBounds().deflate((1 - scale) * (field.getFieldSize().getSize() / 2.0)); |
71 | | - |
72 | | - matrixStack.pushPose(); |
| 79 | + matrixStack.pushPose(); |
73 | 80 |
|
74 | | - drawScanLine(tile, matrixStack, buffers, bounds, gameTime); |
75 | | - drawProjectorArcs(tile, matrixStack, buffers, bounds, gameTime); |
76 | | - drawFieldFace(tile, matrixStack, buffers, bounds); |
| 81 | + drawScanLine(tile, matrixStack, buffers, bounds, gameTime); |
| 82 | + drawProjectorArcs(tile, matrixStack, buffers, bounds, gameTime); |
| 83 | + drawFieldFace(tile, matrixStack, buffers, bounds); |
77 | 84 |
|
78 | | - matrixStack.popPose(); |
79 | | - }); |
| 85 | + matrixStack.popPose(); |
80 | 86 | } |
81 | 87 |
|
82 | 88 | private IBakedModel getModel() { |
@@ -111,7 +117,7 @@ private void renderDish(FieldProjectorTile te, MatrixStack mx, IRenderTypeBuffer |
111 | 117 | // double yaw = Math.random(); |
112 | 118 |
|
113 | 119 | Direction facing = state.getValue(FieldProjectorBlock.FACING); |
114 | | - if(facing != Direction.WEST) { |
| 120 | + if (facing != Direction.WEST) { |
115 | 121 | float angle = facing.toYRot() - 90; |
116 | 122 | mx.mulPose(Vector3f.YN.rotationDegrees(angle)); |
117 | 123 | } |
|
0 commit comments