Push Sky renderer for pockets
This commit is contained in:
parent
9d39908183
commit
ff5804fc6f
4 changed files with 78 additions and 56 deletions
|
@ -9,9 +9,9 @@ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
|
||||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockEntityProvider;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
import net.minecraft.client.render.SkyProperties;
|
||||||
import net.minecraft.client.texture.Sprite;
|
import net.minecraft.client.texture.Sprite;
|
||||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
|
@ -20,6 +20,8 @@ import net.minecraft.resource.ResourceManager;
|
||||||
import net.minecraft.resource.ResourceType;
|
import net.minecraft.resource.ResourceType;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.util.math.Vec3i;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.BlockRenderView;
|
import net.minecraft.world.BlockRenderView;
|
||||||
import org.dimdev.dimdoors.block.ModBlocks;
|
import org.dimdev.dimdoors.block.ModBlocks;
|
||||||
|
@ -42,7 +44,7 @@ public class DimensionalDoorsClientInitializer implements ClientModInitializer {
|
||||||
|
|
||||||
setupFluidRendering(ModFluids.ETERNAL_FLUID, ModFluids.FLOWING_ETERNAL_FLUID, new Identifier("dimdoors:eternal_fluid"));
|
setupFluidRendering(ModFluids.ETERNAL_FLUID, ModFluids.FLOWING_ETERNAL_FLUID, new Identifier("dimdoors:eternal_fluid"));
|
||||||
|
|
||||||
OpenWorlds.registerSkyRenderer(ModDimensions.POCKET_TYPE, new CustomSkyProvider());
|
OpenWorlds.registerSkyRenderer(ModDimensions.POCKET_TYPE, new CustomSkyProvider(null, null, new Vec3i(0, 0, 0)));
|
||||||
OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE, new LimboSkyProvider());
|
OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE, new LimboSkyProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +61,6 @@ public class DimensionalDoorsClientInitializer implements ClientModInitializer {
|
||||||
registry.register(stillSpriteId);
|
registry.register(stillSpriteId);
|
||||||
registry.register(flowingSpriteId);
|
registry.register(flowingSpriteId);
|
||||||
});
|
});
|
||||||
BlockEntityProvider
|
|
||||||
|
|
||||||
final Identifier fluidId = Registry.FLUID.getId(still);
|
final Identifier fluidId = Registry.FLUID.getId(still);
|
||||||
final Identifier listenerId = new Identifier(fluidId.getNamespace(), fluidId.getPath() + "_reload_listener");
|
final Identifier listenerId = new Identifier(fluidId.getNamespace(), fluidId.getPath() + "_reload_listener");
|
||||||
|
|
|
@ -1,55 +1,44 @@
|
||||||
package org.dimdev.dimdoors.client;
|
package org.dimdev.dimdoors.client;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import io.github.waterpicker.openworlds.renderer.SkyRenderer;
|
import io.github.waterpicker.openworlds.renderer.SkyRenderer;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.*;
|
import net.minecraft.client.render.BufferBuilder;
|
||||||
|
import net.minecraft.client.render.BufferRenderer;
|
||||||
|
import net.minecraft.client.render.Tessellator;
|
||||||
|
import net.minecraft.client.render.VertexFormats;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.Matrix4f;
|
import net.minecraft.util.math.Matrix4f;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
public class CustomSkyProvider implements SkyRenderer {
|
public class CustomSkyProvider implements SkyRenderer {
|
||||||
|
private final Identifier moon;
|
||||||
|
private final Identifier sun;
|
||||||
|
private final Vec3i color;
|
||||||
|
|
||||||
private static final Identifier locationEndSkyPng = new Identifier("textures/environment/end_sky.png");
|
public CustomSkyProvider(Identifier moon, Identifier sun, Vec3i color) {
|
||||||
|
this.moon = moon;
|
||||||
public Identifier getMoonRenderPath() {
|
this.sun = sun;
|
||||||
return null;
|
this.color = color;
|
||||||
}
|
|
||||||
|
|
||||||
public Identifier getSunRenderPath() {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MinecraftClient client, MatrixStack matrices, float tickDelta) {
|
public void render(MinecraftClient client, MatrixStack matrices, float tickDelta) {
|
||||||
RenderSystem.disableTexture();
|
|
||||||
|
|
||||||
Vec3d vec3d = client.world.method_23777(client.gameRenderer.getCamera().getBlockPos(), tickDelta);
|
|
||||||
float f = (float)vec3d.x;
|
|
||||||
float g = (float)vec3d.y;
|
|
||||||
float h = (float)vec3d.z;
|
|
||||||
BackgroundRenderer.setFogBlack();
|
|
||||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
||||||
|
RenderSystem.disableAlphaTest();
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.defaultBlendFunc();
|
RenderSystem.defaultBlendFunc();
|
||||||
|
RenderSystem.depthMask(false);
|
||||||
|
|
||||||
float r;
|
|
||||||
float s;
|
|
||||||
|
|
||||||
RenderSystem.enableTexture();
|
|
||||||
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
r = 1.0F - client.world.getRainGradient(tickDelta);
|
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, r);
|
|
||||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90.0F));
|
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90.0F));
|
||||||
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(client.world.getSkyAngle(tickDelta) * 360.0F));
|
|
||||||
Matrix4f matrix4f2 = matrices.peek().getModel();
|
Matrix4f matrix4f2 = matrices.peek().getModel();
|
||||||
s = 30.0F;
|
|
||||||
client.getTextureManager().bindTexture(getSunRenderPath());
|
float s = 30.0F;
|
||||||
|
client.getTextureManager().bindTexture(sun);
|
||||||
bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE);
|
bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE);
|
||||||
bufferBuilder.vertex(matrix4f2, -s, 100.0F, -s).texture(0.0F, 0.0F).next();
|
bufferBuilder.vertex(matrix4f2, -s, 100.0F, -s).texture(0.0F, 0.0F).next();
|
||||||
bufferBuilder.vertex(matrix4f2, s, 100.0F, -s).texture(1.0F, 0.0F).next();
|
bufferBuilder.vertex(matrix4f2, s, 100.0F, -s).texture(1.0F, 0.0F).next();
|
||||||
|
@ -57,8 +46,8 @@ public class CustomSkyProvider implements SkyRenderer {
|
||||||
bufferBuilder.vertex(matrix4f2, -s, 100.0F, s).texture(0.0F, 1.0F).next();
|
bufferBuilder.vertex(matrix4f2, -s, 100.0F, s).texture(0.0F, 1.0F).next();
|
||||||
bufferBuilder.end();
|
bufferBuilder.end();
|
||||||
BufferRenderer.draw(bufferBuilder);
|
BufferRenderer.draw(bufferBuilder);
|
||||||
s = 20.0F;
|
|
||||||
client.getTextureManager().bindTexture(getMoonRenderPath());
|
client.getTextureManager().bindTexture(moon);
|
||||||
bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE);
|
bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE);
|
||||||
bufferBuilder.vertex(matrix4f2, -s, -100.0F, s).texture(0f, 0f).next();
|
bufferBuilder.vertex(matrix4f2, -s, -100.0F, s).texture(0f, 0f).next();
|
||||||
bufferBuilder.vertex(matrix4f2, s, -100.0F, s).texture(1f, 0f).next();
|
bufferBuilder.vertex(matrix4f2, s, -100.0F, s).texture(1f, 0f).next();
|
||||||
|
@ -66,25 +55,61 @@ public class CustomSkyProvider implements SkyRenderer {
|
||||||
bufferBuilder.vertex(matrix4f2, -s, -100.0F, -s).texture(0f, 1f).next();
|
bufferBuilder.vertex(matrix4f2, -s, -100.0F, -s).texture(0f, 1f).next();
|
||||||
bufferBuilder.end();
|
bufferBuilder.end();
|
||||||
BufferRenderer.draw(bufferBuilder);
|
BufferRenderer.draw(bufferBuilder);
|
||||||
RenderSystem.disableTexture();
|
|
||||||
|
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
matrices.pop();
|
||||||
|
|
||||||
|
RenderSystem.depthMask(true);
|
||||||
|
RenderSystem.enableTexture();
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
RenderSystem.enableAlphaTest();
|
RenderSystem.enableAlphaTest();
|
||||||
RenderSystem.enableFog();
|
|
||||||
|
renderSkyBox(matrices);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderSkyBox(MatrixStack matrices) {
|
||||||
|
RenderSystem.disableAlphaTest();
|
||||||
|
RenderSystem.enableBlend();
|
||||||
|
RenderSystem.defaultBlendFunc();
|
||||||
|
RenderSystem.depthMask(false);
|
||||||
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
|
BufferBuilder bufferBuilder = tessellator.getBuffer();
|
||||||
|
|
||||||
|
for(int i = 0; i < 6; ++i) {
|
||||||
|
matrices.push();
|
||||||
|
if (i == 1) {
|
||||||
|
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 2) {
|
||||||
|
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 3) {
|
||||||
|
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 4) {
|
||||||
|
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(90.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == 5) {
|
||||||
|
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(-90.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix4f matrix4f = matrices.peek().getModel();
|
||||||
|
bufferBuilder.begin(7, VertexFormats.POSITION_COLOR);
|
||||||
|
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).color(color.getX(), color.getY(), color.getZ(), 255).next();
|
||||||
|
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).color(color.getX(), color.getY(), color.getZ(), 255).next();
|
||||||
|
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).color(color.getX(), color.getY(), color.getZ(), 255).next();
|
||||||
|
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).color(color.getX(), color.getY(), color.getZ(), 255).next();
|
||||||
|
tessellator.draw();
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
RenderSystem.disableTexture();
|
|
||||||
RenderSystem.color3f(0.0F, 0.0F, 0.0F);
|
|
||||||
|
|
||||||
if (client.world.getSkyProperties().isAlternateSkyColor()) {
|
|
||||||
RenderSystem.color3f(f * 0.2F + 0.04F, g * 0.2F + 0.04F, h * 0.6F + 0.1F);
|
|
||||||
} else {
|
|
||||||
RenderSystem.color3f(f, g, h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem.enableTexture();
|
|
||||||
RenderSystem.depthMask(true);
|
RenderSystem.depthMask(true);
|
||||||
RenderSystem.disableFog();
|
RenderSystem.enableTexture();
|
||||||
|
RenderSystem.disableBlend();
|
||||||
|
RenderSystem.enableAlphaTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,19 +1,14 @@
|
||||||
package org.dimdev.dimdoors.client;
|
package org.dimdev.dimdoors.client;
|
||||||
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
public class LimboSkyProvider extends CustomSkyProvider {
|
public class LimboSkyProvider extends CustomSkyProvider {
|
||||||
|
|
||||||
private static final Identifier moonRenderPath = new Identifier("dimdoors:textures/other/limbo_moon.png");
|
private static final Identifier moonRenderPath = new Identifier("dimdoors:textures/other/limbo_moon.png");
|
||||||
private static final Identifier sunRenderPath = new Identifier("dimdoors:textures/other/limbo_sun.png");
|
private static final Identifier sunRenderPath = new Identifier("dimdoors:textures/other/limbo_sun.png");
|
||||||
|
|
||||||
@Override
|
public LimboSkyProvider() {
|
||||||
public Identifier getMoonRenderPath() {
|
super(moonRenderPath, sunRenderPath, new Vec3i(255, 255, 255));
|
||||||
return moonRenderPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Identifier getSunRenderPath() {
|
|
||||||
return sunRenderPath;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,6 +27,7 @@ public final class ModDimensions {
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
Registry.register(Registry.CHUNK_GENERATOR, new Identifier("dimdoors", "blank"), BlankChunkGenerator.CODEC);
|
Registry.register(Registry.CHUNK_GENERATOR, new Identifier("dimdoors", "blank"), BlankChunkGenerator.CODEC);
|
||||||
|
|
||||||
// just loads the class
|
// just loads the class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue