Revert "Fog"

This reverts commit 6a0b7200b5.
This commit is contained in:
SD 2020-12-12 12:28:48 +05:30
parent b22fb7c375
commit 91dbbea31a
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5
5 changed files with 60 additions and 60 deletions

View file

@ -19,9 +19,9 @@ import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class CustomSkyProvider implements SkyRenderer {
protected final Identifier moon;
protected final Identifier sun;
protected final Vec3i color;
private final Identifier moon;
private final Identifier sun;
private final Vec3i color;
public CustomSkyProvider(Identifier moon, Identifier sun, Vec3i color) {
this.moon = moon;
@ -68,10 +68,10 @@ public class CustomSkyProvider implements SkyRenderer {
RenderSystem.disableBlend();
RenderSystem.enableAlphaTest();
this.renderSkyBox(matrices, tickDelta);
this.renderSkyBox(matrices);
}
protected void renderSkyBox(MatrixStack matrices, float tickDelta) {
protected void renderSkyBox(MatrixStack matrices) {
RenderSystem.disableAlphaTest();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
@ -98,24 +98,24 @@ public class CustomSkyProvider implements SkyRenderer {
RenderSystem.enableAlphaTest();
}
protected void multiply(MatrixStack matrices, int direction) {
if (direction == 1) {
protected void multiply(MatrixStack matrices, int i) {
if (i == 1) {
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90.0F));
}
if (direction == 2) {
if (i == 2) {
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90.0F));
}
if (direction == 3) {
if (i == 3) {
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180.0F));
}
if (direction == 4) {
if (i == 4) {
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(90.0F));
}
if (direction == 5) {
if (i == 5) {
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(-90.0F));
}
}

View file

@ -3,17 +3,15 @@ package org.dimdev.dimdoors.client;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BackgroundRenderer;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.block.entity.EndPortalBlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
@SuppressWarnings("ConstantConditions")
public class LimboSkyProvider extends CustomSkyProvider {
private static final Identifier MOON_RENDER_PATH = new Identifier("dimdoors:textures/other/limbo_moon.png");
private static final Identifier SUN_RENDER_PATH = new Identifier("dimdoors:textures/other/limbo_sun.png");
@ -24,20 +22,14 @@ public class LimboSkyProvider extends CustomSkyProvider {
}
@Override
protected void renderSkyBox(MatrixStack matrices, float tickDelta) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
Vec3d color = MinecraftClient.getInstance().world.method_23777(MinecraftClient.getInstance().gameRenderer.getCamera().getBlockPos(), tickDelta);
BackgroundRenderer.setFogBlack();
RenderSystem.depthMask(false);
RenderSystem.enableFog();
RenderSystem.color3f((float) color.x, (float) color.y, (float) color.z);
RenderSystem.disableFog();
protected void renderSkyBox(MatrixStack matrices) {
RenderSystem.disableAlphaTest();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.depthMask(false);
MinecraftClient.getInstance().getTextureManager().bindTexture(GREY_TEX);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
for (int i = 0; i < 6; ++i) {
matrices.push();
this.multiply(matrices, i);

View file

@ -1,30 +0,0 @@
package org.dimdev.dimdoors.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.world.gen.chunk.NoiseChunkGenerator;
@Mixin(NoiseChunkGenerator.class)
public interface NoiseChunkGeneratorAccessor {
@Accessor
static float[] getNOISE_WEIGHT_TABLE() {
throw new UnsupportedOperationException();
}
@Accessor
static float[] getBIOME_WEIGHT_TABLE() {
throw new UnsupportedOperationException();
}
@Invoker
static double callGetNoiseWeight(int x, int y, int z) {
throw new UnsupportedOperationException();
}
@Invoker
static double callCalculateNoiseWeight(int x, int y, int z) {
throw new UnsupportedOperationException();
}
}

View file

@ -6,13 +6,12 @@ import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import com.mojang.serialization.Codec;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectList;
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
import com.mojang.serialization.Codec;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.mixin.ChunkGeneratorAccessor;
import org.dimdev.dimdoors.mixin.NoiseChunkGeneratorAccessor;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import org.jetbrains.annotations.Nullable;
@ -23,6 +22,7 @@ import net.minecraft.structure.JigsawJunction;
import net.minecraft.structure.PoolStructurePiece;
import net.minecraft.structure.StructurePiece;
import net.minecraft.structure.pool.StructurePool;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
@ -59,8 +59,23 @@ import net.fabricmc.api.Environment;
public class LimboChunkGenerator extends ChunkGenerator {
public static final LimboChunkGenerator INSTANCE = new LimboChunkGenerator(new FixedBiomeSource(() -> ModBiomes.LIMBO_BIOME), new FixedBiomeSource(() -> ModBiomes.LIMBO_BIOME));
public static final Codec<LimboChunkGenerator> CODEC = Codec.unit(INSTANCE);
private static final float[] NOISE_WEIGHT_TABLE = NoiseChunkGeneratorAccessor.getNOISE_WEIGHT_TABLE();
private static final float[] BIOME_WEIGHT_TABLE = NoiseChunkGeneratorAccessor.getBIOME_WEIGHT_TABLE();
private static final float[] NOISE_WEIGHT_TABLE = Util.make(new float[13824], (array) -> {
for (int i = 0; i < 24; ++i) {
for (int j = 0; j < 24; ++j) {
for (int k = 0; k < 24; ++k) {
array[i * 24 * 24 + j * 24 + k] = (float) calculateNoiseWeight(j - 12, k - 12, i - 12);
}
}
}
});
private static final float[] BIOME_WEIGHT_TABLE = Util.make(new float[25], (fs) -> {
for (int i = -2; i <= 2; ++i) {
for (int j = -2; j <= 2; ++j) {
float f = 10.0F / MathHelper.sqrt((float) (i * i + j * j) + 0.2F);
fs[i + 2 + (j + 2) * 5] = f;
}
}
});
protected final ChunkRandom random;
protected final BlockState defaultBlock;
@ -111,6 +126,30 @@ public class LimboChunkGenerator extends ChunkGenerator {
}
}
private static double getNoiseWeight(int x, int y, int z) {
int i = x + 12;
int j = y + 12;
int k = z + 12;
if (i >= 0 && i < 24) {
if (j >= 0 && j < 24) {
return k >= 0 && k < 24 ? (double) NOISE_WEIGHT_TABLE[k * 24 * 24 + i * 24 + j] : 0.0D;
} else {
return 0.0D;
}
} else {
return 0.0D;
}
}
private static double calculateNoiseWeight(int x, int y, int z) {
double d = x * x + z * z;
double e = (double) y + 0.5D;
double f = e * e;
double g = Math.pow(2.718281828459045D, -(f / 16.0D + d / 16.0D));
double h = -e * MathHelper.fastInverseSqrt(f / 2.0D + d / 2.0D) / 2.0D;
return h * g;
}
@Override
public Codec<? extends ChunkGenerator> getCodec() {
return CODEC;
@ -471,7 +510,7 @@ public class LimboChunkGenerator extends ChunkGenerator {
int at;
int au;
int ar;
for (ao = ao / 2.0D - ao * ao * ao / 24.0D; objectListIterator.hasNext(); ao += NoiseChunkGeneratorAccessor.callGetNoiseWeight(at, au, ar) * 0.8D) {
for (ao = ao / 2.0D - ao * ao * ao / 24.0D; objectListIterator.hasNext(); ao += getNoiseWeight(at, au, ar) * 0.8D) {
StructurePiece structurePiece = objectListIterator.next();
BlockBox blockBox = structurePiece.getBoundingBox();
at = Math.max(0, Math.max(blockBox.minX - ae, ae - blockBox.maxX));
@ -486,7 +525,7 @@ public class LimboChunkGenerator extends ChunkGenerator {
int as = ae - jigsawJunction.getSourceX();
at = v - jigsawJunction.getSourceGroundY();
au = ak - jigsawJunction.getSourceZ();
ao += NoiseChunkGeneratorAccessor.callGetNoiseWeight(as, at, au) * 0.4D;
ao += getNoiseWeight(as, at, au) * 0.4D;
}
objectListIterator2.back(jigsawJunctions.size());

View file

@ -12,7 +12,6 @@
"EntityMixin",
"GenerationSettingsAccessor",
"ListTagAccessor",
"NoiseChunkGeneratorAccessor",
"PlayerEntityMixin",
"RedstoneWireBlockAccessor"
],