|
3 | 3 | import com.mojang.blaze3d.systems.RenderSystem; |
4 | 4 | import com.mojang.blaze3d.vertex.*; |
5 | 5 | import com.mojang.math.Axis; |
| 6 | +import net.neoforged.api.distmarker.Dist; |
| 7 | +import net.neoforged.api.distmarker.OnlyIn; |
6 | 8 | import org.joml.Matrix4f; |
7 | 9 | import org.joml.Vector3f; |
8 | 10 | import net.minecraft.client.Camera; |
|
13 | 15 | import net.minecraft.core.BlockPos; |
14 | 16 | import net.minecraft.resources.ResourceLocation; |
15 | 17 | import net.minecraft.world.phys.Vec3; |
16 | | -import net.minecraftforge.api.distmarker.Dist; |
17 | | -import net.minecraftforge.api.distmarker.OnlyIn; |
18 | 18 |
|
19 | 19 | public abstract class CustomDimensionEffects extends DimensionSpecialEffects { |
| 20 | + //TODO replace with ResourceLocation.parse(), or CreatingSpace.resource() |
20 | 21 | private static final ResourceLocation SPACE_SKY_LOCATION = new ResourceLocation("creatingspace", "textures/environment/space_sky.png"); |
21 | 22 | private static final ResourceLocation EARTH_LOCATION = new ResourceLocation("creatingspace", "textures/environment/earth.png"); |
22 | 23 | private static final ResourceLocation MOON_LOCATION = new ResourceLocation("creatingspace", "textures/environment/moon.png"); |
@@ -44,9 +45,7 @@ private static BufferBuilder renderSpaceSky(PoseStack poseStack) { |
44 | 45 | RenderSystem.setShader(GameRenderer::getPositionTexColorShader); |
45 | 46 | RenderSystem.setShaderTexture(0, SPACE_SKY_LOCATION); |
46 | 47 | Tesselator tesselator = Tesselator.getInstance(); |
47 | | - BufferBuilder bufferbuilder = tesselator.getBuilder(); |
48 | | - |
49 | | - |
| 48 | + BufferBuilder bufferbuilder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);//Only position and uv to set. |
50 | 49 | for(int i = 0; i < 6; ++i) { |
51 | 50 | poseStack.pushPose(); |
52 | 51 | //make all the face |
@@ -79,13 +78,14 @@ private static BufferBuilder renderSpaceSky(PoseStack poseStack) { |
79 | 78 |
|
80 | 79 | float size = 100.0F; |
81 | 80 | float distance = 100.0F; |
| 81 | + //this is the standard brut force way to draw a square with a texture |
| 82 | + // uv is the coordinates on the texture and the addVertex takes the perspective matrix and the 3 position |
82 | 83 | Matrix4f matrix4f = poseStack.last().pose(); |
83 | | - bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); |
84 | | - bufferbuilder.vertex(matrix4f, -size, -distance, -size).uv(col_end, l_end).color(255,255,255,255).endVertex(); |
85 | | - bufferbuilder.vertex(matrix4f, -size, -distance, size).uv(col_begin, l_end).color(255,255,255,255).endVertex(); |
86 | | - bufferbuilder.vertex(matrix4f, size, -distance, size).uv(col_begin, l_begin).color(255,255,255,255).endVertex(); |
87 | | - bufferbuilder.vertex(matrix4f, size, -distance, -size).uv(col_end, l_begin).color(255,255,255,255).endVertex(); |
88 | | - BufferUploader.drawWithShader(bufferbuilder.end()); |
| 84 | + bufferbuilder.addVertex(matrix4f, -size, -distance, -size).setUv(col_end, l_end); |
| 85 | + bufferbuilder.addVertex(matrix4f, -size, -distance, size).setUv(col_begin, l_end); |
| 86 | + bufferbuilder.addVertex(matrix4f, size, -distance, size).setUv(col_begin, l_begin); |
| 87 | + bufferbuilder.addVertex(matrix4f, size, -distance, -size).setUv(col_end, l_begin); |
| 88 | + BufferUploader.drawWithShader(bufferbuilder.buildOrThrow()); |
89 | 89 | //tesselator.end(); |
90 | 90 | poseStack.popPose(); |
91 | 91 | } |
@@ -233,6 +233,7 @@ protected void renderAstralBody(PoseStack poseStack, BufferBuilder bufferbuilder |
233 | 233 | Matrix4f matrix4f = poseStack.last().pose(); |
234 | 234 | RenderSystem.setShader(GameRenderer::getPositionTexShader); |
235 | 235 | RenderSystem.setShaderTexture(0, bodyTexture); |
| 236 | + //TODO same as end of renderSpaceSky |
236 | 237 | bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); |
237 | 238 | bufferbuilder.vertex(matrix4f, -bodySize, bodyDistance, -bodySize).uv(f15, f14).endVertex(); |
238 | 239 | bufferbuilder.vertex(matrix4f, bodySize, bodyDistance, -bodySize).uv(f13, f14).endVertex(); |
|
0 commit comments