Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -11,37 +11,36 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexBuffer;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gl.VertexBuffer;
|
||||
import net.minecraft.client.render.BackgroundRenderer;
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
import net.minecraft.client.render.BufferBuilderStorage;
|
||||
import net.minecraft.client.render.SkyProperties;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexFormat;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.RenderBuffers;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.client.ClientOptions;
|
||||
import ru.betterend.util.BackgroundInfo;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
@Mixin(LevelRenderer.class)
|
||||
public class WorldRendererMixin {
|
||||
private static final ResourceLocation NEBULA_1 = BetterEnd.makeID("textures/sky/nebula_2.png");
|
||||
private static final ResourceLocation NEBULA_2 = BetterEnd.makeID("textures/sky/nebula_3.png");
|
||||
private static final ResourceLocation HORIZON = BetterEnd.makeID("textures/sky/nebula_1.png");
|
||||
private static final ResourceLocation STARS = BetterEnd.makeID("textures/sky/stars.png");
|
||||
private static final ResourceLocation FOG = BetterEnd.makeID("textures/sky/fog.png");
|
||||
|
||||
|
||||
private static VertexBuffer stars1;
|
||||
private static VertexBuffer stars2;
|
||||
private static VertexBuffer stars3;
|
||||
|
@ -60,23 +59,23 @@ public class WorldRendererMixin {
|
|||
private static float blind02;
|
||||
private static float blind06;
|
||||
private static boolean directOpenGL = false;
|
||||
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Minecraft client;
|
||||
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private TextureManager textureManager;
|
||||
|
||||
|
||||
@Shadow
|
||||
private ClientLevel world;
|
||||
|
||||
|
||||
@Shadow
|
||||
private int ticks;
|
||||
|
||||
|
||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||
private void be_onInit(Minecraft client, BufferBuilderStorage bufferBuilders, CallbackInfo info) {
|
||||
private void be_onInit(Minecraft client, RenderBuffers bufferBuilders, CallbackInfo info) {
|
||||
be_initStars();
|
||||
Random random = new Random(131);
|
||||
axis1 = new Vector3f(random.nextFloat(), random.nextFloat(), random.nextFloat());
|
||||
|
@ -87,110 +86,107 @@ public class WorldRendererMixin {
|
|||
axis2.normalize();
|
||||
axis3.normalize();
|
||||
axis4.normalize();
|
||||
|
||||
directOpenGL = FabricLoader.getInstance().isModLoaded("optifabric")
|
||||
|| FabricLoader.getInstance().isModLoaded("immersive_portals");
|
||||
|
||||
directOpenGL = FabricLoader.getInstance().isModLoaded("optifabric") || FabricLoader.getInstance().isModLoaded("immersive_portals");
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "renderSky", at = @At("HEAD"), cancellable = true)
|
||||
private void be_renderBetterEndSky(MatrixStack matrices, float tickDelta, CallbackInfo info) {
|
||||
if (ClientOptions.isCustomSky() && client.world.getSkyProperties().getSkyType() == SkyProperties.SkyType.END) {
|
||||
private void be_renderBetterEndSky(PoseStack matrices, float tickDelta, CallbackInfo info) {
|
||||
if (ClientOptions.isCustomSky() && client.level.effects().skyType() == DimensionSpecialEffects.SkyType.END) {
|
||||
time = (ticks % 360000) * 0.000017453292F;
|
||||
time2 = time * 2;
|
||||
time3 = time * 3;
|
||||
|
||||
BackgroundRenderer.setFogBlack();
|
||||
|
||||
FogRenderer.levelFogColor();
|
||||
RenderSystem.enableTexture();
|
||||
|
||||
|
||||
if (directOpenGL) {
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glAlphaFunc(516, 0.0F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
RenderSystem.depthMask(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.alphaFunc(516, 0.0F);
|
||||
RenderSystem.enableBlend();
|
||||
}
|
||||
|
||||
|
||||
float blindA = 1F - BackgroundInfo.blindness;
|
||||
blind02 = blindA * 0.2F;
|
||||
blind06 = blindA * 0.6F;
|
||||
|
||||
|
||||
if (blindA > 0) {
|
||||
matrices.push();
|
||||
matrices.multiply(new Quaternion(0, time, 0, false));
|
||||
textureManager.bindTexture(HORIZON);
|
||||
be_renderBuffer(matrices, horizon, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.7F * blindA);
|
||||
matrices.pop();
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(new Quaternion(0, -time, 0, false));
|
||||
textureManager.bindTexture(NEBULA_1);
|
||||
be_renderBuffer(matrices, nebulas1, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, blind02);
|
||||
matrices.pop();
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(new Quaternion(0, time2, 0, false));
|
||||
textureManager.bindTexture(NEBULA_2);
|
||||
be_renderBuffer(matrices, nebulas2, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, blind02);
|
||||
matrices.pop();
|
||||
|
||||
textureManager.bindTexture(STARS);
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(axis3.getRadialQuaternion(time));
|
||||
be_renderBuffer(matrices, stars3, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, blind06);
|
||||
matrices.pop();
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(axis4.getRadialQuaternion(time2));
|
||||
be_renderBuffer(matrices, stars4, VertexFormats.POSITION_TEXTURE, 1F, 1F, 1F, blind06);
|
||||
matrices.pop();
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(new Quaternion(0, time, 0, false));
|
||||
textureManager.bind(HORIZON);
|
||||
be_renderBuffer(matrices, horizon, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, 0.7F * blindA);
|
||||
matrices.popPose();
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(new Quaternion(0, -time, 0, false));
|
||||
textureManager.bind(NEBULA_1);
|
||||
be_renderBuffer(matrices, nebulas1, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, blind02);
|
||||
matrices.popPose();
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(new Quaternion(0, time2, 0, false));
|
||||
textureManager.bind(NEBULA_2);
|
||||
be_renderBuffer(matrices, nebulas2, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, blind02);
|
||||
matrices.popPose();
|
||||
|
||||
textureManager.bind(STARS);
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(axis3.rotation(time));
|
||||
be_renderBuffer(matrices, stars3, DefaultVertexFormat.POSITION_TEX, 0.77F, 0.31F, 0.73F, blind06);
|
||||
matrices.popPose();
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(axis4.rotation(time2));
|
||||
be_renderBuffer(matrices, stars4, DefaultVertexFormat.POSITION_TEX, 1F, 1F, 1F, blind06);
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
|
||||
float a = (BackgroundInfo.fog - 1F);
|
||||
if (a > 0) {
|
||||
if (a > 1)
|
||||
a = 1;
|
||||
textureManager.bindTexture(FOG);
|
||||
be_renderBuffer(matrices, fog, VertexFormats.POSITION_TEXTURE, BackgroundInfo.red, BackgroundInfo.green,
|
||||
BackgroundInfo.blue, a);
|
||||
if (a > 1) a = 1;
|
||||
textureManager.bind(FOG);
|
||||
be_renderBuffer(matrices, fog, DefaultVertexFormat.POSITION_TEX, BackgroundInfo.red, BackgroundInfo.green, BackgroundInfo.blue, a);
|
||||
}
|
||||
|
||||
RenderSystem.disableTexture();
|
||||
|
||||
|
||||
if (blindA > 0) {
|
||||
matrices.push();
|
||||
matrices.multiply(axis1.getRadialQuaternion(time3));
|
||||
be_renderBuffer(matrices, stars1, VertexFormats.POSITION, 1, 1, 1, blind06);
|
||||
matrices.pop();
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(axis2.getRadialQuaternion(time2));
|
||||
be_renderBuffer(matrices, stars2, VertexFormats.POSITION, 0.95F, 0.64F, 0.93F, blind06);
|
||||
matrices.pop();
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(axis1.rotation(time3));
|
||||
be_renderBuffer(matrices, stars1, DefaultVertexFormat.POSITION, 1, 1, 1, blind06);
|
||||
matrices.popPose();
|
||||
|
||||
matrices.pushPose();
|
||||
matrices.mulPose(axis2.rotation(time2));
|
||||
be_renderBuffer(matrices, stars2, DefaultVertexFormat.POSITION, 0.95F, 0.64F, 0.93F, blind06);
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.depthMask(true);
|
||||
|
||||
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void be_renderBuffer(MatrixStack matrices, VertexBuffer buffer, VertexFormat format, float r, float g,
|
||||
float b, float a) {
|
||||
|
||||
private void be_renderBuffer(PoseStack matrices, VertexBuffer buffer, VertexFormat format, float r, float g, float b, float a) {
|
||||
RenderSystem.color4f(r, g, b, a);
|
||||
buffer.bind();
|
||||
format.startDrawing(0L);
|
||||
buffer.draw(matrices.peek().getModel(), 7);
|
||||
VertexBuffer.unbind();
|
||||
format.endDrawing();
|
||||
format.setupBufferState(0L);
|
||||
buffer.draw(matrices.last().pose(), 7);
|
||||
VertexBuffer.unbind();
|
||||
format.clearBufferState();
|
||||
}
|
||||
|
||||
private void be_initStars() {
|
||||
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
|
||||
BufferBuilder buffer = Tesselator.getInstance().getBuilder();
|
||||
stars1 = be_buildBufferStars(buffer, stars1, 0.1, 0.30, 3500, 41315);
|
||||
stars2 = be_buildBufferStars(buffer, stars2, 0.1, 0.35, 2000, 35151);
|
||||
stars3 = be_buildBufferUVStars(buffer, stars3, 0.4, 1.2, 1000, 61354);
|
||||
|
@ -200,78 +196,75 @@ public class WorldRendererMixin {
|
|||
horizon = be_buildBufferHorizon(buffer, horizon);
|
||||
fog = be_buildBufferFog(buffer, fog);
|
||||
}
|
||||
|
||||
private VertexBuffer be_buildBufferStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize,
|
||||
double maxSize, int count, long seed) {
|
||||
|
||||
private VertexBuffer be_buildBufferStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
||||
if (buffer != null) {
|
||||
buffer.close();
|
||||
}
|
||||
|
||||
buffer = new VertexBuffer(VertexFormats.POSITION);
|
||||
buffer = new VertexBuffer(DefaultVertexFormat.POSITION);
|
||||
be_makeStars(bufferBuilder, minSize, maxSize, count, seed);
|
||||
bufferBuilder.end();
|
||||
buffer.upload(bufferBuilder);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private VertexBuffer be_buildBufferUVStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize,
|
||||
double maxSize, int count, long seed) {
|
||||
|
||||
private VertexBuffer be_buildBufferUVStars(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
||||
if (buffer != null) {
|
||||
buffer.close();
|
||||
}
|
||||
|
||||
buffer = new VertexBuffer(VertexFormats.POSITION_TEXTURE);
|
||||
buffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEX);
|
||||
be_makeUVStars(bufferBuilder, minSize, maxSize, count, seed);
|
||||
bufferBuilder.end();
|
||||
buffer.upload(bufferBuilder);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private VertexBuffer be_buildBufferFarFog(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize,
|
||||
double maxSize, int count, long seed) {
|
||||
|
||||
private VertexBuffer be_buildBufferFarFog(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
||||
if (buffer != null) {
|
||||
buffer.close();
|
||||
}
|
||||
|
||||
buffer = new VertexBuffer(VertexFormats.POSITION_TEXTURE);
|
||||
buffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEX);
|
||||
be_makeFarFog(bufferBuilder, minSize, maxSize, count, seed);
|
||||
bufferBuilder.end();
|
||||
buffer.upload(bufferBuilder);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
private VertexBuffer be_buildBufferHorizon(BufferBuilder bufferBuilder, VertexBuffer buffer) {
|
||||
if (buffer != null) {
|
||||
buffer.close();
|
||||
}
|
||||
|
||||
buffer = new VertexBuffer(VertexFormats.POSITION_TEXTURE);
|
||||
buffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEX);
|
||||
be_makeCylinder(bufferBuilder, 16, 50, 100);
|
||||
bufferBuilder.end();
|
||||
buffer.upload(bufferBuilder);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
private VertexBuffer be_buildBufferFog(BufferBuilder bufferBuilder, VertexBuffer buffer) {
|
||||
if (buffer != null) {
|
||||
buffer.close();
|
||||
}
|
||||
|
||||
buffer = new VertexBuffer(VertexFormats.POSITION_TEXTURE);
|
||||
buffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEX);
|
||||
be_makeCylinder(bufferBuilder, 16, 50, 70);
|
||||
bufferBuilder.end();
|
||||
buffer.upload(bufferBuilder);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
private void be_makeStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
|
||||
Random random = new Random(seed);
|
||||
buffer.begin(7, VertexFormats.POSITION);
|
||||
buffer.begin(7, DefaultVertexFormat.POSITION);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
double posX = random.nextDouble() * 2.0 - 1.0;
|
||||
|
@ -306,15 +299,15 @@ public class WorldRendererMixin {
|
|||
double ae = 0.0 * q - aa * r;
|
||||
double af = ae * n - ab * o;
|
||||
double ah = ab * n + ae * o;
|
||||
buffer.vertex(j + af, k + ad, l + ah).next();
|
||||
buffer.vertex(j + af, k + ad, l + ah).endVertex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void be_makeUVStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
|
||||
Random random = new Random(seed);
|
||||
buffer.begin(7, VertexFormats.POSITION_TEXTURE);
|
||||
buffer.begin(7, DefaultVertexFormat.POSITION_TEX);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
double posX = random.nextDouble() * 2.0 - 1.0;
|
||||
|
@ -353,16 +346,16 @@ public class WorldRendererMixin {
|
|||
double ah = ab * n + ae * o;
|
||||
float texU = (pos >> 1) & 1;
|
||||
float texV = (((pos + 1) >> 1) & 1) / 4F + minV;
|
||||
pos++;
|
||||
buffer.vertex(j + af, k + ad, l + ah).texture(texU, texV).next();
|
||||
pos ++;
|
||||
buffer.vertex(j + af, k + ad, l + ah).uv(texU, texV).endVertex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void be_makeFarFog(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
|
||||
Random random = new Random(seed);
|
||||
buffer.begin(7, VertexFormats.POSITION_TEXTURE);
|
||||
buffer.begin(7, DefaultVertexFormat.POSITION_TEX);
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
double posX = random.nextDouble() * 2.0 - 1.0;
|
||||
|
@ -404,30 +397,30 @@ public class WorldRendererMixin {
|
|||
double ah = ab * n + ae * o;
|
||||
float texU = (pos >> 1) & 1;
|
||||
float texV = ((pos + 1) >> 1) & 1;
|
||||
pos++;
|
||||
buffer.vertex(j + af, k + ad, l + ah).texture(texU, texV).next();
|
||||
pos ++;
|
||||
buffer.vertex(j + af, k + ad, l + ah).uv(texU, texV).endVertex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void be_makeCylinder(BufferBuilder buffer, int segments, double height, double radius) {
|
||||
buffer.begin(7, VertexFormats.POSITION_TEXTURE);
|
||||
for (int i = 0; i < segments; i++) {
|
||||
buffer.begin(7, DefaultVertexFormat.POSITION_TEX);
|
||||
for (int i = 0; i < segments; i ++) {
|
||||
double a1 = (double) i * Math.PI * 2.0 / (double) segments;
|
||||
double a2 = (double) (i + 1) * Math.PI * 2.0 / (double) segments;
|
||||
double px1 = Math.sin(a1) * radius;
|
||||
double pz1 = Math.cos(a1) * radius;
|
||||
double px2 = Math.sin(a2) * radius;
|
||||
double pz2 = Math.cos(a2) * radius;
|
||||
|
||||
|
||||
float u0 = (float) i / (float) segments;
|
||||
float u1 = (float) (i + 1) / (float) segments;
|
||||
|
||||
buffer.vertex(px1, -height, pz1).texture(u0, 0).next();
|
||||
buffer.vertex(px1, height, pz1).texture(u0, 1).next();
|
||||
buffer.vertex(px2, height, pz2).texture(u1, 1).next();
|
||||
buffer.vertex(px2, -height, pz2).texture(u1, 0).next();
|
||||
|
||||
buffer.vertex(px1, -height, pz1).uv(u0, 0).endVertex();
|
||||
buffer.vertex(px1, height, pz1).uv(u0, 1).endVertex();
|
||||
buffer.vertex(px2, height, pz2).uv(u1, 1).endVertex();
|
||||
buffer.vertex(px2, -height, pz2).uv(u1, 0).endVertex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue