Merge branch 'master' of https://github.com/paulevsGitch/BetterEnd
This commit is contained in:
commit
2f202068e2
35 changed files with 1025 additions and 58 deletions
49
src/main/java/ru/betterend/blocks/BlockUmbrellaMoss.java
Normal file
49
src/main/java/ru/betterend/blocks/BlockUmbrellaMoss.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.blocks.basis.BlockDoublePlant;
|
||||
import ru.betterend.blocks.basis.BlockPlant;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class BlockUmbrellaMoss extends BlockPlant {
|
||||
public BlockUmbrellaMoss() {
|
||||
super(11);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isTerrain(BlockState state) {
|
||||
return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public boolean hasEmissiveLighting(BlockView world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public float getAmbientOcclusionLightLevel(BlockView world, BlockPos pos) {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
|
||||
return world.isAir(pos.up());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
||||
int rot = world.random.nextInt(4);
|
||||
BlockState bs = BlockRegistry.UMBRELLA_MOSS_TALL.getDefaultState().with(BlockDoublePlant.ROTATION, rot);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, bs);
|
||||
BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(BlockDoublePlant.TOP, true));
|
||||
}
|
||||
}
|
|
@ -9,8 +9,10 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.TrapdoorBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import ru.betterend.client.ERenderLayer;
|
||||
import ru.betterend.client.IRenderTypeable;
|
||||
|
||||
public class BlockTrapdoor extends TrapdoorBlock {
|
||||
public class BlockTrapdoor extends TrapdoorBlock implements IRenderTypeable {
|
||||
public BlockTrapdoor(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).nonOpaque());
|
||||
}
|
||||
|
@ -19,4 +21,9 @@ public class BlockTrapdoor extends TrapdoorBlock {
|
|||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ERenderLayer getRenderLayer() {
|
||||
return ERenderLayer.CUTOUT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biome.Category;
|
||||
import ru.betterend.registry.BiomeRegistry;
|
||||
import ru.betterend.util.BackgroundInfo;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.world.biome.EndBiome;
|
||||
|
||||
@Mixin(BackgroundRenderer.class)
|
||||
public class BackgroundRendererMixin {
|
||||
private static float lastFogStart;
|
||||
private static float lastFogEnd;
|
||||
private static float fogStart;
|
||||
private static float fogEnd;
|
||||
private static float lastFogDensity;
|
||||
private static float fogDensity;
|
||||
private static float lerp;
|
||||
|
||||
//private static final float SKY_RED = 21F / 255F;
|
||||
|
@ -63,6 +63,10 @@ public class BackgroundRendererMixin {
|
|||
blue *= 4;
|
||||
}
|
||||
}
|
||||
|
||||
BackgroundInfo.red = red;
|
||||
BackgroundInfo.green = green;
|
||||
BackgroundInfo.blue = blue;
|
||||
}
|
||||
|
||||
@Inject(method = "applyFog", at = @At("HEAD"), cancellable = true)
|
||||
|
@ -73,22 +77,20 @@ public class BackgroundRendererMixin {
|
|||
if (biome.getCategory() == Category.THEEND && fluidState.isEmpty()) {
|
||||
EndBiome endBiome = BiomeRegistry.getFromBiome(biome);
|
||||
|
||||
if (fogEnd == 0) {
|
||||
fogStart = viewDistance * 0.75F / endBiome.getFogDensity();
|
||||
fogEnd = viewDistance / endBiome.getFogDensity();
|
||||
lastFogStart = fogStart;
|
||||
lastFogEnd = fogEnd;
|
||||
if (fogDensity == 0) {
|
||||
fogDensity = endBiome.getFogDensity();
|
||||
lastFogDensity = fogDensity;
|
||||
}
|
||||
if (lerp == 1) {
|
||||
lastFogStart = fogStart;
|
||||
lastFogEnd = fogEnd;
|
||||
fogStart = viewDistance * 0.75F / endBiome.getFogDensity();
|
||||
fogEnd = viewDistance / endBiome.getFogDensity();
|
||||
lastFogDensity = fogDensity;
|
||||
fogDensity = endBiome.getFogDensity();
|
||||
lerp = 0;
|
||||
}
|
||||
|
||||
RenderSystem.fogStart(MathHelper.lerp(lerp, lastFogStart, fogStart));
|
||||
RenderSystem.fogEnd(MathHelper.lerp(lerp, lastFogEnd, fogEnd));
|
||||
float fog = MathHelper.lerp(lerp, lastFogDensity, fogDensity);
|
||||
BackgroundInfo.fog = fog;
|
||||
RenderSystem.fogStart(viewDistance * 0.75F / fog);
|
||||
RenderSystem.fogEnd(viewDistance / fog);
|
||||
RenderSystem.fogMode(GlStateManager.FogMode.LINEAR);
|
||||
RenderSystem.setupNvFogDistance();
|
||||
info.cancel();
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.client.world.ClientWorld;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.util.BackgroundInfo;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
|
@ -35,13 +36,15 @@ public class WorldRendererMixin {
|
|||
private static final Identifier NEBULA_1 = new Identifier(BetterEnd.MOD_ID, "textures/sky/nebula_2.png");
|
||||
private static final Identifier NEBULA_2 = new Identifier(BetterEnd.MOD_ID, "textures/sky/nebula_3.png");
|
||||
private static final Identifier HORIZON = new Identifier(BetterEnd.MOD_ID, "textures/sky/nebula_1.png");
|
||||
private static final Identifier FOG = new Identifier(BetterEnd.MOD_ID, "textures/sky/fog.png");
|
||||
|
||||
private static VertexBuffer customStarsBuffer1;
|
||||
private static VertexBuffer customStarsBuffer2;
|
||||
private static VertexBuffer customStarsBuffer3;
|
||||
private static VertexBuffer nebulas_1;
|
||||
private static VertexBuffer nebulas_2;
|
||||
private static VertexBuffer stars1;
|
||||
private static VertexBuffer stars2;
|
||||
private static VertexBuffer stars3;
|
||||
private static VertexBuffer nebulas1;
|
||||
private static VertexBuffer nebulas2;
|
||||
private static VertexBuffer horizon;
|
||||
private static VertexBuffer fog;
|
||||
private static Vector3f axis1;
|
||||
private static Vector3f axis2;
|
||||
private static Vector3f axis3;
|
||||
|
@ -92,30 +95,37 @@ public class WorldRendererMixin {
|
|||
matrices.push();
|
||||
matrices.multiply(new Quaternion(0, -time, 0, true));
|
||||
textureManager.bindTexture(NEBULA_1);
|
||||
renderBuffer(matrices, nebulas_1, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F);
|
||||
renderBuffer(matrices, nebulas1, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F);
|
||||
matrices.pop();
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(new Quaternion(0, time * 2, 0, true));
|
||||
textureManager.bindTexture(NEBULA_2);
|
||||
renderBuffer(matrices, nebulas_2, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F);
|
||||
renderBuffer(matrices, nebulas2, VertexFormats.POSITION_TEXTURE, 0.77F, 0.31F, 0.73F, 0.2F);
|
||||
matrices.pop();
|
||||
|
||||
float a = (BackgroundInfo.fog - 1F);
|
||||
if (a > 0) {
|
||||
if (a > 1) a = 1;
|
||||
textureManager.bindTexture(FOG);
|
||||
renderBuffer(matrices, fog, VertexFormats.POSITION_TEXTURE, BackgroundInfo.red, BackgroundInfo.green, BackgroundInfo.blue, a);
|
||||
}
|
||||
|
||||
RenderSystem.disableTexture();
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(new Quaternion(axis1, time * 3, true));
|
||||
renderBuffer(matrices, customStarsBuffer1, VertexFormats.POSITION, 1, 1, 1, 0.6F);
|
||||
renderBuffer(matrices, stars1, VertexFormats.POSITION, 1, 1, 1, 0.6F);
|
||||
matrices.pop();
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(new Quaternion(axis2, time * 2, true));
|
||||
renderBuffer(matrices, customStarsBuffer2, VertexFormats.POSITION, 0.95F, 0.64F, 0.93F, 0.6F);
|
||||
renderBuffer(matrices, stars2, VertexFormats.POSITION, 0.95F, 0.64F, 0.93F, 0.6F);
|
||||
matrices.pop();
|
||||
|
||||
matrices.push();
|
||||
matrices.multiply(new Quaternion(axis3, time, true));
|
||||
renderBuffer(matrices, customStarsBuffer3, VertexFormats.POSITION, 0.77F, 0.31F, 0.73F, 0.6F);
|
||||
renderBuffer(matrices, stars3, VertexFormats.POSITION, 0.77F, 0.31F, 0.73F, 0.6F);
|
||||
matrices.pop();
|
||||
|
||||
RenderSystem.enableTexture();
|
||||
|
@ -136,12 +146,13 @@ public class WorldRendererMixin {
|
|||
|
||||
private void initStars() {
|
||||
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
|
||||
customStarsBuffer1 = buildBuffer(buffer, customStarsBuffer1, 0.1, 0.30, 3500, 41315);
|
||||
customStarsBuffer2 = buildBuffer(buffer, customStarsBuffer2, 0.1, 0.35, 2000, 35151);
|
||||
customStarsBuffer3 = buildBuffer(buffer, customStarsBuffer3, 0.1, 0.40, 1500, 61354);
|
||||
nebulas_1 = buildBufferFarFog(buffer, nebulas_1, 40, 60, 30, 11515);
|
||||
nebulas_2 = buildBufferFarFog(buffer, nebulas_2, 40, 60, 10, 14151);
|
||||
stars1 = buildBuffer(buffer, stars1, 0.1, 0.30, 3500, 41315);
|
||||
stars2 = buildBuffer(buffer, stars2, 0.1, 0.35, 2000, 35151);
|
||||
stars3 = buildBuffer(buffer, stars3, 0.1, 0.40, 1500, 61354);
|
||||
nebulas1 = buildBufferFarFog(buffer, nebulas1, 40, 60, 30, 11515);
|
||||
nebulas2 = buildBufferFarFog(buffer, nebulas2, 40, 60, 10, 14151);
|
||||
horizon = buildBufferHorizon(buffer, horizon);
|
||||
fog = buildBufferFog(buffer, fog);
|
||||
}
|
||||
|
||||
private VertexBuffer buildBuffer(BufferBuilder bufferBuilder, VertexBuffer buffer, double minSize, double maxSize, int count, long seed) {
|
||||
|
@ -176,7 +187,20 @@ public class WorldRendererMixin {
|
|||
}
|
||||
|
||||
buffer = new VertexBuffer(VertexFormats.POSITION_TEXTURE);
|
||||
makeHorizon(bufferBuilder, 16, 50);
|
||||
makeCylinder(bufferBuilder, 16, 50, 100);
|
||||
bufferBuilder.end();
|
||||
buffer.upload(bufferBuilder);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private VertexBuffer buildBufferFog(BufferBuilder bufferBuilder, VertexBuffer buffer) {
|
||||
if (buffer != null) {
|
||||
buffer.close();
|
||||
}
|
||||
|
||||
buffer = new VertexBuffer(VertexFormats.POSITION_TEXTURE);
|
||||
makeCylinder(bufferBuilder, 16, 50, 70);
|
||||
bufferBuilder.end();
|
||||
buffer.upload(bufferBuilder);
|
||||
|
||||
|
@ -277,16 +301,16 @@ public class WorldRendererMixin {
|
|||
}
|
||||
}
|
||||
|
||||
private void makeHorizon(BufferBuilder buffer, int segments, double height) {
|
||||
private void makeCylinder(BufferBuilder buffer, int segments, double height, double radius) {
|
||||
buffer.begin(7, VertexFormats.POSITION_TEXTURE);
|
||||
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) * 100;
|
||||
double pz1 = Math.cos(a1) * 100;
|
||||
double px2 = Math.sin(a2) * 100;
|
||||
double pz2 = Math.cos(a2) * 100;
|
||||
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;
|
||||
|
|
|
@ -15,6 +15,7 @@ import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
|
|||
import ru.betterend.blocks.BlockMossyGlowshroomSapling;
|
||||
import ru.betterend.blocks.BlockOre;
|
||||
import ru.betterend.blocks.BlockTerrain;
|
||||
import ru.betterend.blocks.BlockUmbrellaMoss;
|
||||
import ru.betterend.blocks.BlockUmbrellaMossTall;
|
||||
import ru.betterend.blocks.EndStoneSmelter;
|
||||
import ru.betterend.blocks.EnderBlock;
|
||||
|
@ -36,7 +37,7 @@ public class BlockRegistry {
|
|||
public static final WoodenMaterial MOSSY_GLOWSHROOM = new WoodenMaterial("mossy_glowshroom", MaterialColor.GRAY, MaterialColor.WOOD);
|
||||
|
||||
// Small Plants //
|
||||
public static final Block UMBRELLA_MOSS = registerBlock("umbrella_moss", new BlockGlowingMoss(10));
|
||||
public static final Block UMBRELLA_MOSS = registerBlock("umbrella_moss", new BlockUmbrellaMoss());
|
||||
public static final Block UMBRELLA_MOSS_TALL = registerBlock("umbrella_moss_tall", new BlockUmbrellaMossTall());
|
||||
public static final Block CREEPING_MOSS = registerBlock("creeping_moss", new BlockGlowingMoss(10));
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import ru.betterend.world.features.SinglePlantFeature;
|
|||
|
||||
public class FeatureRegistry {
|
||||
// Trees //
|
||||
public static final EndFeature MOSSY_GLOWSHROOM = new EndFeature("mossy_glowshroom", new MossyGlowshroomFeature(), 1);
|
||||
public static final EndFeature MOSSY_GLOWSHROOM = new EndFeature("mossy_glowshroom", new MossyGlowshroomFeature(), 2);
|
||||
|
||||
// Plants //
|
||||
public static final EndFeature UMBRELLA_MOSS = new EndFeature("umbrella_moss", new DoublePlantFeature(BlockRegistry.UMBRELLA_MOSS, BlockRegistry.UMBRELLA_MOSS_TALL, 5), 5);
|
||||
|
|
8
src/main/java/ru/betterend/util/BackgroundInfo.java
Normal file
8
src/main/java/ru/betterend/util/BackgroundInfo.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package ru.betterend.util;
|
||||
|
||||
public class BackgroundInfo {
|
||||
public static float red;
|
||||
public static float green;
|
||||
public static float blue;
|
||||
public static float fog = 1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue