diff --git a/Readme.txt b/Readme.txt index 2f289b9f6..f1a6b586d 100644 --- a/Readme.txt +++ b/Readme.txt @@ -4,14 +4,13 @@ allowing for an increased view distance without harming performance. Or in other words: this mod let's you see farther without turning your game into a slide show. If you want to see a quick demo, check out the video I made here: -https://youtu.be/v61iOYZQWCs +https://youtu.be/CCT-3s02tYA -Forge version: 1.16.4-35.1.4 +Forge version: 1.16.5-36.1.0 Notes: -This version has been confirmed to work in Eclipse and retail Minecraft. -(retail running forge 1.16.4-35.1.37) +This version has been confirmed to work in Eclipse. ======================== @@ -64,3 +63,7 @@ Note to self The Minecraft source code is NOT added to your workspace in a editable way. Minecraft is treated like a normal Library. Sources are there for documentation and research purposes only. +Source code uses mcp mappings not Mojangs. + +The source code can be 'created' with the ./eclipse command and can be found in the following path: +minecraft-lod-mod\build\fg_cache\mcp\ VERSION \joined\ RANDOM_STRING \patch\output.jar diff --git a/build.gradle b/build.gradle index 50bd2ca4d..f33da808e 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ apply plugin: 'maven-publish' version = 'a1.2' group = 'com.backsun.lod' -archivesBaseName = 'lod_1.16.4' +archivesBaseName = 'lod_1.16.5' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. @@ -31,7 +31,7 @@ minecraft { // stable_# Stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'snapshot', version: '20201028-1.16.3' + mappings channel: 'official', version: '1.16.5' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. @@ -45,9 +45,15 @@ minecraft { arg "-mixin.config=lod.mixins.json" // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + // The markers can be changed as needed. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property 'forge.logging.markers', 'REGISTRIES' // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'debug' mods { @@ -62,9 +68,15 @@ minecraft { arg "-mixin.config=lod.mixins.json" // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + // The markers can be changed as needed. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property 'forge.logging.markers', 'REGISTRIES' // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'debug' mods { @@ -78,9 +90,15 @@ minecraft { workingDirectory project.file('run') // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + // The markers can be changed as needed. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property 'forge.logging.markers', 'REGISTRIES' // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'debug' // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. @@ -102,7 +120,7 @@ dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.16.4-35.1.4' + minecraft 'net.minecraftforge:forge:1.16.5-36.1.0' // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" @@ -131,7 +149,7 @@ jar { "Specification-Title": "Levels of Detail", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, - "Implementation-Version": "1.0", + "Implementation-Version": "{version}", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "MixinConfigs": "lod.mixins.json", ]) diff --git a/src/main/java/com/seibel/lod/LodMain.java b/src/main/java/com/seibel/lod/LodMain.java index 7c598d7d6..ec371c728 100644 --- a/src/main/java/com/seibel/lod/LodMain.java +++ b/src/main/java/com/seibel/lod/LodMain.java @@ -3,7 +3,6 @@ package com.seibel.lod; import com.seibel.lod.handlers.LodConfig; import com.seibel.lod.proxy.ClientProxy; -import net.minecraft.client.Minecraft; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; @@ -33,7 +32,6 @@ public class LodMain private void init(final FMLCommonSetupEvent event) { - Minecraft.getInstance().getFramebuffer().enableStencil(); ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, LodConfig.clientSpec); } diff --git a/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java b/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java index a08aac698..1bc334eb2 100644 --- a/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java +++ b/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java @@ -212,7 +212,7 @@ public class LodBufferBuilder } // TODO add a way for a server side mod to generate chunks requested here - if(mc.isIntegratedServerRunning()) + if(mc.hasSingleplayerServer()) { ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(lodDim.dimension); @@ -239,8 +239,8 @@ public class LodBufferBuilder } // finish the buffer building - buildableNearBuffer.finishDrawing(); - buildableFarBuffer.finishDrawing(); + buildableNearBuffer.end(); + buildableFarBuffer.end(); // mark that the buildable buffers as ready to swap generatingBuffers = false; @@ -271,11 +271,11 @@ public class LodBufferBuilder */ private boolean isCoordInCenterArea(int i, int j, int centerCoordinate) { - return (i >= centerCoordinate - mc.gameSettings.renderDistanceChunks - && i <= centerCoordinate + mc.gameSettings.renderDistanceChunks) + return (i >= centerCoordinate - mc.options.renderDistance + && i <= centerCoordinate + mc.options.renderDistance) && - (j >= centerCoordinate - mc.gameSettings.renderDistanceChunks - && j <= centerCoordinate + mc.gameSettings.renderDistanceChunks); + (j >= centerCoordinate - mc.options.renderDistance + && j <= centerCoordinate + mc.options.renderDistance); } diff --git a/src/main/java/com/seibel/lod/builders/LodBuilder.java b/src/main/java/com/seibel/lod/builders/LodBuilder.java index 4965177d4..1f4f18142 100644 --- a/src/main/java/com/seibel/lod/builders/LodBuilder.java +++ b/src/main/java/com/seibel/lod/builders/LodBuilder.java @@ -71,7 +71,7 @@ public class LodBuilder { try { - DimensionType dim = world.getDimensionType(); + DimensionType dim = world.dimensionType(); LodChunk lod = generateLodFromChunk(chunk, config); @@ -153,7 +153,7 @@ public class LodBuilder } else { - height = determineHeightPoint(chunk.getHeightmap(LodChunk.DEFAULT_HEIGHTMAP), startX, startZ, endX, endZ); + height = determineHeightPoint(chunk.getOrCreateHeightmapUnprimed(LodChunk.DEFAULT_HEIGHTMAP), startX, startZ, endX, endZ); depth = 0; } @@ -292,7 +292,7 @@ public class LodBuilder { for(int z = startZ; z < endZ; z++) { - short newHeight = (short) heightmap.getHeight(x, z); + short newHeight = (short) heightmap.getFirstAvailable(x, z); if (newHeight > highest) highest = newHeight; } @@ -343,7 +343,7 @@ public class LodBuilder if (chunkSections[i] != null) { blockState = chunkSections[i].getBlockState(x, y, z); - colorInt = blockState.materialColor.colorValue; + colorInt = blockState.materialColor.col; } if(colorInt == 0 && config.useSolidBlocksInColorGen) @@ -356,22 +356,22 @@ public class LodBuilder { Biome biome = chunk.getBiomes().getNoiseBiome(x, y + i * chunkSections.length, z); - if (biome.getCategory() == Biome.Category.OCEAN || - biome.getCategory() == Biome.Category.RIVER) + if (biome.getBiomeCategory() == Biome.Category.OCEAN || + biome.getBiomeCategory() == Biome.Category.RIVER) { colorInt = biome.getWaterColor(); } - else if (biome.getCategory() == Biome.Category.EXTREME_HILLS) + else if (biome.getBiomeCategory() == Biome.Category.EXTREME_HILLS) { - colorInt = Blocks.STONE.getMaterialColor().colorValue; + colorInt = Blocks.STONE.defaultMaterialColor().col; } - else if (biome.getCategory() == Biome.Category.ICY) + else if (biome.getBiomeCategory() == Biome.Category.ICY) { colorInt = LodUtil.colorToInt(Color.WHITE); } - else if (biome.getCategory() == Biome.Category.THEEND) + else if (biome.getBiomeCategory() == Biome.Category.THEEND) { - colorInt = Blocks.END_STONE.getDefaultState().materialColor.colorValue; + colorInt = Blocks.END_STONE.defaultBlockState().materialColor.col; } else if (config.useSolidBlocksInColorGen) { @@ -427,7 +427,7 @@ public class LodBuilder { int colorInt = 0; - if (blockState == Blocks.AIR.getDefaultState()) + if (blockState == Blocks.AIR.defaultBlockState()) { colorInt = biome.getGrassColor(x, z); } @@ -447,7 +447,7 @@ public class LodBuilder } else { - colorInt = blockState.materialColor.colorValue; + colorInt = blockState.materialColor.col; } return colorInt; diff --git a/src/main/java/com/seibel/lod/builders/lodTemplates/AbstractLodTemplate.java b/src/main/java/com/seibel/lod/builders/lodTemplates/AbstractLodTemplate.java index a4f7031e2..0c3b79600 100644 --- a/src/main/java/com/seibel/lod/builders/lodTemplates/AbstractLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/lodTemplates/AbstractLodTemplate.java @@ -25,7 +25,7 @@ public abstract class AbstractLodTemplate double x, double y, double z, int red, int green, int blue, int alpha) { - buffer.pos(x, y, z).color(red, green, blue, alpha).endVertex(); + buffer.vertex(x, y, z).color(red, green, blue, alpha).endVertex(); } /** Returns in bytes how much buffer memory is required diff --git a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java index 77f065b09..c5200df5d 100644 --- a/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/lodTemplates/CubicLodTemplate.java @@ -80,7 +80,7 @@ public class CubicLodTemplate extends AbstractLodTemplate height++; } - return new AxisAlignedBB(0, depth, 0, width, height, width).offset(xOffset, yOffset, zOffset); + return new AxisAlignedBB(0, depth, 0, width, height, width).move(xOffset, yOffset, zOffset); } diff --git a/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java b/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java index 99b97a57f..91fe4d418 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodChunkGenWorker.java @@ -43,6 +43,7 @@ import net.minecraft.world.gen.placement.ConfiguredPlacement; import net.minecraft.world.gen.placement.DecoratedPlacementConfig; import net.minecraft.world.gen.placement.IPlacementConfig; import net.minecraft.world.gen.placement.NoiseDependant; +import net.minecraft.world.server.ServerChunkProvider; import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorldLightManager; import net.minecraftforge.common.WorldWorkerManager.IWorker; @@ -194,13 +195,15 @@ public class LodChunkGenWorker implements IWorker ChunkPrimer chunk = new ChunkPrimer(pos, UpgradeData.EMPTY); chunkList.add(chunk); - ChunkGenerator chunkGen = serverWorld.getWorld().getChunkProvider().getChunkGenerator(); + ServerChunkProvider chunkSource = serverWorld.getChunkSource(); + ChunkGenerator chunkGen = chunkSource.generator; + // generate the terrain (this is thread safe) - ChunkStatus.EMPTY.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); + ChunkStatus.EMPTY.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); // override the chunk status so we can run the next generator stage chunk.setStatus(ChunkStatus.STRUCTURE_REFERENCES); - ChunkStatus.BIOMES.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); + ChunkStatus.BIOMES.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); chunk.setStatus(ChunkStatus.STRUCTURE_REFERENCES); @@ -222,31 +225,31 @@ public class LodChunkGenWorker implements IWorker // these heights are of course aren't super accurate, // they are just to simulate height data where there isn't any - switch(chunk.getBiomes().getNoiseBiome(x, seaLevel, z).getCategory()) + switch(chunk.getBiomes().getNoiseBiome(x, seaLevel, z).getBiomeCategory()) { case NETHER: - heightmap.set(x, z, serverWorld.getHeight() / 2); + heightmap.setHeight(x, z, serverWorld.getHeight() / 2); break; case EXTREME_HILLS: - heightmap.set(x, z, seaLevel + 30); + heightmap.setHeight(x, z, seaLevel + 30); break; case MESA: - heightmap.set(x, z, seaLevel + 20); + heightmap.setHeight(x, z, seaLevel + 20); break; case JUNGLE: - heightmap.set(x, z, seaLevel + 20); + heightmap.setHeight(x, z, seaLevel + 20); break; case BEACH: - heightmap.set(x, z, seaLevel + 5); + heightmap.setHeight(x, z, seaLevel + 5); break; case NONE: - heightmap.set(x, z, 0); + heightmap.setHeight(x, z, 0); break; case OCEAN: case RIVER: - heightmap.set(x, z, seaLevel); + heightmap.setHeight(x, z, seaLevel); break; case THEEND: @@ -262,7 +265,7 @@ public class LodChunkGenWorker implements IWorker // TAIGA // PLAINS default: - heightmap.set(x, z, seaLevel + 10); + heightmap.setHeight(x, z, seaLevel + 10); break; }// heightmap switch } @@ -270,12 +273,12 @@ public class LodChunkGenWorker implements IWorker { // we aren't simulating height // always use sea level - heightmap.set(x, z, seaLevel); + heightmap.setHeight(x, z, seaLevel); } }// z }// x - chunk.setHeightmap(LodChunk.DEFAULT_HEIGHTMAP, heightmap.getDataArray()); + chunk.setHeightmap(LodChunk.DEFAULT_HEIGHTMAP, heightmap.getRawData()); LodChunk lod; @@ -304,20 +307,22 @@ public class LodChunkGenWorker implements IWorker chunkList.add(chunk); LodServerWorld lodServerWorld = new LodServerWorld(chunk); - ChunkGenerator chunkGen = serverWorld.getWorld().getChunkProvider().getChunkGenerator(); + ServerChunkProvider chunkSource = serverWorld.getChunkSource(); + ChunkGenerator chunkGen = chunkSource.generator; + // generate the terrain (this is thread safe) - ChunkStatus.EMPTY.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); + ChunkStatus.EMPTY.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); // override the chunk status so we can run the next generator stage chunk.setStatus(ChunkStatus.STRUCTURE_REFERENCES); - ChunkStatus.BIOMES.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); - ChunkStatus.NOISE.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); - ChunkStatus.SURFACE.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); + ChunkStatus.BIOMES.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); + ChunkStatus.NOISE.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); + ChunkStatus.SURFACE.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); // this feature has proved to be thread safe // so we will add it - IceAndSnowFeature snowFeature = new IceAndSnowFeature(NoFeatureConfig.field_236558_a_); - snowFeature.generate(lodServerWorld, chunkGen, serverWorld.rand, chunk.getPos().asBlockPos(), null); + IceAndSnowFeature snowFeature = new IceAndSnowFeature(NoFeatureConfig.CODEC); + snowFeature.place(lodServerWorld, chunkGen, serverWorld.random, chunk.getPos().getWorldPosition(), null); LodChunk lod = lodBuilder.generateLodFromChunk(chunk, new LodBuilderConfig(false, true, true)); @@ -338,16 +343,17 @@ public class LodChunkGenWorker implements IWorker chunkList.add(chunk); LodServerWorld lodServerWorld = new LodServerWorld(chunk); - ChunkGenerator chunkGen = serverWorld.getWorld().getChunkProvider().getChunkGenerator(); + ServerChunkProvider chunkSource = serverWorld.getChunkSource(); + ChunkGenerator chunkGen = chunkSource.generator; // generate the terrain (this is thread safe) - ChunkStatus.EMPTY.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); + ChunkStatus.EMPTY.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); // override the chunk status so we can run the next generator stage chunk.setStatus(ChunkStatus.STRUCTURE_REFERENCES); - ChunkStatus.BIOMES.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); - ChunkStatus.NOISE.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); - ChunkStatus.SURFACE.doGenerationWork(serverWorld, chunkGen, serverWorld.getStructureTemplateManager(), (ServerWorldLightManager) serverWorld.getLightManager(), null, chunkList); + ChunkStatus.BIOMES.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); + ChunkStatus.NOISE.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); + ChunkStatus.SURFACE.generate(serverWorld, chunkGen, serverWorld.getStructureManager(), (ServerWorldLightManager) serverWorld.getLightEngine(), null, chunkList); // get all the biomes in the chunk @@ -367,7 +373,7 @@ public class LodChunkGenWorker implements IWorker // this may or may not be thread safe for (Biome biome : biomes) { - List>>> featuresForState = biome.biomeGenerationSettings.getFeatures(); + List>>> featuresForState = biome.generationSettings.features(); for(int featureStateToGenerate = 0; featureStateToGenerate < featuresForState.size(); featureStateToGenerate++) { @@ -390,7 +396,7 @@ public class LodChunkGenWorker implements IWorker try { - configuredfeature.generate(lodServerWorld, chunkGen, serverWorld.rand, chunk.getPos().asBlockPos()); + configuredfeature.place(lodServerWorld, chunkGen, serverWorld.random, chunk.getPos().getWorldPosition()); } catch(ConcurrentModificationException e) { @@ -462,28 +468,28 @@ public class LodChunkGenWorker implements IWorker { IPlacementConfig placementConfig = null; - Class oldConfigClass = config.decorator.func_242877_b().getClass(); + Class oldConfigClass = config.decorator.config().getClass(); if (oldConfigClass == FeatureSpreadConfig.class) { - FeatureSpreadConfig oldPlacementConfig = (FeatureSpreadConfig) config.decorator.func_242877_b(); - FeatureSpread oldSpread = oldPlacementConfig.func_242799_a(); + FeatureSpreadConfig oldPlacementConfig = (FeatureSpreadConfig) config.decorator.config(); + FeatureSpread oldSpread = oldPlacementConfig.count(); placementConfig = new FeatureSpreadConfig(oldSpread); } else if(oldConfigClass == DecoratedPlacementConfig.class) { - DecoratedPlacementConfig oldPlacementConfig = (DecoratedPlacementConfig) config.decorator.func_242877_b(); - placementConfig = new DecoratedPlacementConfig(oldPlacementConfig.getInner(), oldPlacementConfig.getOuter()); + DecoratedPlacementConfig oldPlacementConfig = (DecoratedPlacementConfig) config.decorator.config(); + placementConfig = new DecoratedPlacementConfig(oldPlacementConfig.inner(), oldPlacementConfig.outer()); } else if(oldConfigClass == NoiseDependant.class) { - NoiseDependant oldPlacementConfig = (NoiseDependant) config.decorator.func_242877_b(); + NoiseDependant oldPlacementConfig = (NoiseDependant) config.decorator.config(); placementConfig = new NoiseDependant(oldPlacementConfig.noiseLevel, oldPlacementConfig.belowNoise, oldPlacementConfig.aboveNoise); } else { -// ClientProxy.LOGGER.debug("unkown decorated placement config: \"" + config.decorator.func_242877_b().getClass() + "\""); +// ClientProxy.LOGGER.debug("unkown decorated placement config: \"" + config.decorator.config().getClass() + "\""); return config; } @@ -497,8 +503,8 @@ public class LodChunkGenWorker implements IWorker private BlockClusterFeatureConfig cloneBlockClusterFeatureConfig(BlockClusterFeatureConfig config) { WeightedBlockStateProvider provider = new WeightedBlockStateProvider(); - for(Entry state : ((WeightedBlockStateProvider) config.stateProvider).weightedStates.field_220658_a) - provider.weightedStates.field_220658_a.add(state); + for(Entry state : ((WeightedBlockStateProvider) config.stateProvider).weightedList.entries) + provider.weightedList.entries.add(state); HashSet whitelist = new HashSet<>(); for(Block block : config.whitelist) @@ -512,13 +518,13 @@ public class LodChunkGenWorker implements IWorker BlockClusterFeatureConfig.Builder builder = new BlockClusterFeatureConfig.Builder(provider, config.blockPlacer); builder.whitelist(whitelist); builder.blacklist(blacklist); - builder.xSpread(config.xSpread); - builder.ySpread(config.ySpread); - builder.zSpread(config.zSpread); - if(config.isReplaceable) { builder.replaceable(); } - if(config.requiresWater) { builder.requiresWater(); } - if(config.field_227298_k_) { builder.func_227317_b_(); } - builder.tries(config.tryCount); + builder.xspread(config.xspread); + builder.yspread(config.yspread); + builder.zspread(config.zspread); + if(config.canReplace) { builder.canReplace(); } + if(config.needWater) { builder.needWater(); } + if(config.project) { builder.noProjection(); } + builder.tries(config.tries); return builder.build(); diff --git a/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java b/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java index add98028d..3d7d664b3 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java @@ -28,7 +28,6 @@ import net.minecraft.world.DimensionType; import net.minecraft.world.EmptyTickList; import net.minecraft.world.ISeedReader; import net.minecraft.world.ITickList; -import net.minecraft.world.LightType; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeManager; import net.minecraft.world.border.WorldBorder; @@ -76,7 +75,7 @@ public class LodServerWorld implements ISeedReader { z = z % LodChunk.WIDTH; z = (z < 0) ? z + 16 : z; - return chunk.getHeightmap(LodChunk.DEFAULT_HEIGHTMAP).getHeight(x, z); + return chunk.getOrCreateHeightmapUnprimed(LodChunk.DEFAULT_HEIGHTMAP).getFirstAvailable(x, z); } @Override @@ -86,7 +85,7 @@ public class LodServerWorld implements ISeedReader { } @Override - public boolean setBlockState(BlockPos pos, BlockState state, int flags, int recursionLeft) + public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { return chunk.setBlockState(pos, state, false) == state; } @@ -103,23 +102,23 @@ public class LodServerWorld implements ISeedReader { return chunk.getFluidState(pos); } - @Override - public int getLightFor(LightType type, BlockPos pos) - { - // this needs to be low for snow generation to work - return 0; - } +// @Override +// public int getLightFor(LightType type, BlockPos pos) +// { +// // this needs to be low for snow generation to work +// return 0; +// } @Override - public boolean hasBlockState(BlockPos pos, Predicate state) + public boolean isStateAtPosition(BlockPos pos, Predicate state) { return state.test(chunk.getBlockState(pos)); } @Override - public ITickList getPendingBlockTicks() + public ITickList getBlockTicks() { - return EmptyTickList.get(); + return EmptyTickList.empty(); } @Override @@ -139,31 +138,6 @@ public class LodServerWorld implements ISeedReader { - @Override - public ServerWorld getWorld() { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public ITickList getPendingFluidTicks() { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public IWorldInfo getWorldInfo() { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public DifficultyInstance getDifficultyForLocation(BlockPos pos) { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public AbstractChunkProvider getChunkProvider() { - throw new UnsupportedOperationException("Not Implemented"); - } - @Override public Random getRandom() { throw new UnsupportedOperationException("Not Implemented"); @@ -180,76 +154,21 @@ public class LodServerWorld implements ISeedReader { double zSpeed) { throw new UnsupportedOperationException("Not Implemented"); } - @Override - public void playEvent(PlayerEntity player, int type, BlockPos pos, int data) { + public DynamicRegistries registryAccess() { throw new UnsupportedOperationException("Not Implemented"); } - - @Override - public DynamicRegistries func_241828_r() { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public List getEntitiesInAABBexcluding(Entity entityIn, AxisAlignedBB boundingBox, - Predicate predicate) { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public List getEntitiesWithinAABB(Class clazz, AxisAlignedBB aabb, - Predicate filter) { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public List getPlayers() { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public int getSkylightSubtracted() { - throw new UnsupportedOperationException("Not Implemented"); - } - @Override public BiomeManager getBiomeManager() { throw new UnsupportedOperationException("Not Implemented"); } - - @Override - public Biome getNoiseBiomeRaw(int x, int y, int z) { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public boolean isRemote() { - throw new UnsupportedOperationException("Not Implemented"); - } - @Override public int getSeaLevel() { throw new UnsupportedOperationException("Not Implemented"); } @Override - public DimensionType getDimensionType() { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public float func_230487_a_(Direction p_230487_1_, boolean p_230487_2_) { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public WorldLightManager getLightManager() { - throw new UnsupportedOperationException("Not Implemented"); - } - - @Override - public TileEntity getTileEntity(BlockPos pos) { + public float getShade(Direction p_230487_1_, boolean p_230487_2_) { throw new UnsupportedOperationException("Not Implemented"); } @@ -274,7 +193,115 @@ public class LodServerWorld implements ISeedReader { } @Override - public Stream> func_241827_a(SectionPos p_241827_1_, Structure p_241827_2_) { + public Stream> startsForFeature(SectionPos p_241827_1_, Structure p_241827_2_) { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public ServerWorld getLevel() { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + + @Override + public AbstractChunkProvider getChunkSource() { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public DifficultyInstance getCurrentDifficultyAt(BlockPos arg0) { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public IWorldInfo getLevelData() { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public ITickList getLiquidTicks() { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public void levelEvent(PlayerEntity arg0, int arg1, BlockPos arg2, int arg3) { + throw new UnsupportedOperationException("Not Implemented"); + + } + + + + @Override + public List getEntities(Entity arg0, AxisAlignedBB arg1, Predicate arg2) { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public List getEntitiesOfClass(Class arg0, AxisAlignedBB arg1, + Predicate arg2) { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public List players() { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public int getSkyDarken() { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public Biome getUncachedNoiseBiome(int p_225604_1_, int p_225604_2_, int p_225604_3_) { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public boolean isClientSide() { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public DimensionType dimensionType() { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public WorldLightManager getLightEngine() { + throw new UnsupportedOperationException("Not Implemented"); + } + + + + @Override + public TileEntity getBlockEntity(BlockPos p_175625_1_) { throw new UnsupportedOperationException("Not Implemented"); } diff --git a/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java b/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java index f902bedc9..fd3f320be 100644 --- a/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java +++ b/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java @@ -34,7 +34,7 @@ public class ReflectionHandler private void setupFogField() { // get every variable from the entity renderer - Field[] vars = mc.gameSettings.getClass().getDeclaredFields(); + Field[] vars = mc.options.getClass().getDeclaredFields(); // try and find the ofFogType variable in gameSettings for(Field f : vars) @@ -73,7 +73,7 @@ public class ReflectionHandler try { - returnNum = (int)ofFogField.get(mc.gameSettings); + returnNum = (int)ofFogField.get(mc.options); } catch (IllegalArgumentException | IllegalAccessException e) { diff --git a/src/main/java/com/seibel/lod/mixin/MixinWorldRenderer.java b/src/main/java/com/seibel/lod/mixin/MixinWorldRenderer.java index af07c1a4d..6ccf8c82a 100644 --- a/src/main/java/com/seibel/lod/mixin/MixinWorldRenderer.java +++ b/src/main/java/com/seibel/lod/mixin/MixinWorldRenderer.java @@ -34,12 +34,12 @@ public class MixinWorldRenderer previousPartialTicks = partialTicks; } - @Inject(at = @At("HEAD"), method = "renderBlockLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/matrix/MatrixStack;DDD)V", cancellable = false) - private void renderBlockLayer(RenderType renderType, MatrixStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback) + @Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/matrix/MatrixStack;DDD)V", cancellable = false) + private void renderChunkLayer(RenderType renderType, MatrixStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback) { // only render if LODs are enabled and // only render before solid blocks - if (LodConfig.CLIENT.drawLODs.get() && renderType.equals(RenderType.getSolid())) + if (LodConfig.CLIENT.drawLODs.get() && renderType.equals(RenderType.solid())) LodMain.client_proxy.renderLods(previousPartialTicks); } } diff --git a/src/main/java/com/seibel/lod/objects/LodChunk.java b/src/main/java/com/seibel/lod/objects/LodChunk.java index 2b6aacbcb..faeb62902 100644 --- a/src/main/java/com/seibel/lod/objects/LodChunk.java +++ b/src/main/java/com/seibel/lod/objects/LodChunk.java @@ -69,6 +69,11 @@ public class LodChunk detail = LodDetail.SINGLE; dataPoints = new LodDataPoint[detail.dataPointLengthCount][detail.dataPointLengthCount]; + + // fill with dummy data, to prevent null pointers + for(int i = 0; i < detail.dataPointLengthCount; i++) + for(int j = 0; j < detail.dataPointLengthCount; j++) + dataPoints[i][j] = new LodDataPoint(); } /** diff --git a/src/main/java/com/seibel/lod/objects/LodDimension.java b/src/main/java/com/seibel/lod/objects/LodDimension.java index 48b654d49..b87aaa956 100644 --- a/src/main/java/com/seibel/lod/objects/LodDimension.java +++ b/src/main/java/com/seibel/lod/objects/LodDimension.java @@ -45,22 +45,22 @@ public class LodDimension Minecraft mc = Minecraft.getInstance(); File saveDir; - if(mc.isIntegratedServerRunning()) + if(mc.hasSingleplayerServer()) { // local world ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(newDimension); // provider needs a separate variable to prevent // the compiler from complaining - ServerChunkProvider provider = serverWorld.getChunkProvider(); - saveDir = new File(provider.getSavedData().folder.getCanonicalFile().getPath() + File.separatorChar + "lod"); + ServerChunkProvider provider = serverWorld.getChunkSource(); + saveDir = new File(provider.dataStorage.dataFolder.getCanonicalFile().getPath() + File.separatorChar + "lod"); } else { // connected to server - saveDir = new File(mc.gameDir.getCanonicalFile().getPath() + - File.separatorChar + "lod server data" + File.separatorChar + LodUtil.getDimensionIDFromWorld(mc.world)); + saveDir = new File(mc.gameDirectory.getCanonicalFile().getPath() + + File.separatorChar + "lod server data" + File.separatorChar + LodUtil.getDimensionIDFromWorld(mc.level)); } fileHandler = new LodDimensionFileHandler(saveDir, this); diff --git a/src/main/java/com/seibel/lod/proxy/ClientProxy.java b/src/main/java/com/seibel/lod/proxy/ClientProxy.java index df01917bd..e7d2e148d 100644 --- a/src/main/java/com/seibel/lod/proxy/ClientProxy.java +++ b/src/main/java/com/seibel/lod/proxy/ClientProxy.java @@ -63,7 +63,7 @@ public class ClientProxy // update each regions' width to match the new render distance int newWidth = Math.max(4, // TODO is this logic good? - (mc.gameSettings.renderDistanceChunks * LodChunk.WIDTH * 2 * LodConfig.CLIENT.lodChunkRadiusMultiplier.get()) / LodRegion.SIZE + (mc.options.renderDistance * LodChunk.WIDTH * 2 * LodConfig.CLIENT.lodChunkRadiusMultiplier.get()) / LodRegion.SIZE ); if (lodBuilder.regionWidth != newWidth) { @@ -75,14 +75,14 @@ public class ClientProxy return; } - LodDimension lodDim = lodWorld.getLodDimension(mc.player.world.getDimensionType()); + LodDimension lodDim = lodWorld.getLodDimension(mc.player.level.dimensionType()); if (lodDim == null) return; // offset the regions - double playerX = mc.player.getPosX(); - double playerZ = mc.player.getPosZ(); + double playerX = mc.player.getX(); + double playerZ = mc.player.getZ(); int xOffset = ((int)playerX / (LodChunk.WIDTH * LodRegion.SIZE)) - lodDim.getCenterX(); int zOffset = ((int)playerZ / (LodChunk.WIDTH * LodRegion.SIZE)) - lodDim.getCenterZ(); @@ -99,19 +99,20 @@ public class ClientProxy // LodConfig.CLIENT.lodColorStyle.set(LodColorStyle.INDIVIDUAL_SIDES); // LodConfig.CLIENT.lodChunkRadiusMultiplier.set(12); // LodConfig.CLIENT.distanceGenerationMode.set(DistanceGenerationMode.FEATURES); +// LodConfig.CLIENT.fogDistance.set(FogDistance.FAR); // Note to self: // if "unspecified" shows up in the pie chart, it is // possibly because the amount of time between sections // is too small for the profile to measure IProfiler profiler = mc.getProfiler(); - profiler.endSection(); // get out of "terrain" - profiler.startSection("LOD"); + profiler.pop(); // get out of "terrain" + profiler.push("LOD"); renderer.drawLODs(lodDim, partialTicks, mc.getProfiler()); - profiler.endSection(); // end LOD - profiler.startSection("terrain"); // restart terrain + profiler.pop(); // end LOD + profiler.push("terrain"); // restart terrain } @@ -143,7 +144,7 @@ public class ClientProxy { // the player just unloaded a world/dimension - if(mc.getConnection().getWorld() == null) + if(mc.getConnection().getLevel() == null) { lodBufferBuilder.numberOfChunksWaitingToGenerate = 0; // the player has disconnected from a server diff --git a/src/main/java/com/seibel/lod/render/LodRenderer.java b/src/main/java/com/seibel/lod/render/LodRenderer.java index efa05894d..b6d84f4c5 100644 --- a/src/main/java/com/seibel/lod/render/LodRenderer.java +++ b/src/main/java/com/seibel/lod/render/LodRenderer.java @@ -148,21 +148,21 @@ public class LodRenderer //===============// profiler = newProfiler; - profiler.startSection("LOD setup"); + profiler.push("LOD setup"); ClientPlayerEntity player = mc.player; // should LODs be regenerated? - if ((int)player.getPosX() / LodChunk.WIDTH != prevChunkX || - (int)player.getPosZ() / LodChunk.WIDTH != prevChunkZ || - previousChunkRenderDistance != mc.gameSettings.renderDistanceChunks || + if ((int)player.getX() / LodChunk.WIDTH != prevChunkX || + (int)player.getZ() / LodChunk.WIDTH != prevChunkZ || + previousChunkRenderDistance != mc.options.renderDistance || prevFogDistance != LodConfig.CLIENT.fogDistance.get()) { // yes regen = true; - prevChunkX = (int)player.getPosX() / LodChunk.WIDTH; - prevChunkZ = (int)player.getPosZ() / LodChunk.WIDTH; + prevChunkX = (int)player.getX() / LodChunk.WIDTH; + prevChunkZ = (int)player.getZ() / LodChunk.WIDTH; prevFogDistance = LodConfig.CLIENT.fogDistance.get(); } else @@ -181,7 +181,7 @@ public class LodRenderer // determine how far the game's render distance is currently set - int renderDistWidth = mc.gameSettings.renderDistanceChunks; + int renderDistWidth = mc.options.renderDistance; farPlaneDistance = renderDistWidth * LodChunk.WIDTH; // set how big the LODs will be and how far they will go @@ -189,7 +189,7 @@ public class LodRenderer int numbChunksWide = (totalLength / LodChunk.WIDTH); // determine which LODs should not be rendered close to the player - HashSet chunkPosToSkip = getNearbyLodChunkPosToSkip(lodDim, player.getPosition()); + HashSet chunkPosToSkip = getNearbyLodChunkPosToSkip(lodDim, player.blockPosition()); // see if the chunks Minecraft is going to render are the // same as last time @@ -216,11 +216,11 @@ public class LodRenderer { // this will mainly happen when the view distance is changed if (drawableNearBuffer == null || drawableFarBuffer == null || - previousChunkRenderDistance != mc.gameSettings.renderDistanceChunks) + previousChunkRenderDistance != mc.options.renderDistance) setupBuffers(numbChunksWide); // generate the LODs on a separate thread to prevent stuttering or freezing - lodBufferBuilder.generateLodBuffersAsync(this, lodDim, player.getPosX(), player.getPosZ(), numbChunksWide); + lodBufferBuilder.generateLodBuffersAsync(this, lodDim, player.getX(), player.getZ(), numbChunksWide); // the regen process has been started, // it will be done when lodBufferBuilder.newBuffersAvaliable @@ -283,7 +283,7 @@ public class LodRenderer //===========// // rendering // //===========// - profiler.endStartSection("LOD draw"); + profiler.popPush("LOD draw"); setupFog(fogSetting.nearFogSetting, reflectionHandler.getFogQuality()); sendLodsToGpuAndDraw(nearVbo, modelViewMatrix); @@ -299,7 +299,7 @@ public class LodRenderer // cleanup // //=========// - profiler.endStartSection("LOD cleanup"); + profiler.popPush("LOD cleanup"); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glEnable(GL11.GL_TEXTURE_2D); @@ -311,7 +311,7 @@ public class LodRenderer // this can't be called until after the buffers are built // because otherwise the buffers may be set to the wrong size - previousChunkRenderDistance = mc.gameSettings.renderDistanceChunks; + previousChunkRenderDistance = mc.options.renderDistance; // reset the fog settings so the normal chunks // will be drawn correctly @@ -331,7 +331,7 @@ public class LodRenderer // end of internal LOD profiling - profiler.endSection(); + profiler.pop(); } @@ -346,13 +346,13 @@ public class LodRenderer if (vbo == null) return; - vbo.bindBuffer(); + vbo.bind(); // 0L is the starting pointer LOD_VERTEX_FORMAT.setupBufferState(0L); vbo.draw(modelViewMatrix, GL11.GL_QUADS); - VertexBuffer.unbindBuffer(); + VertexBuffer.unbind(); LOD_VERTEX_FORMAT.clearBufferState(); } @@ -371,7 +371,7 @@ public class LodRenderer { if(fogQuality == FogQuality.OFF) { - FogRenderer.resetFog(); + FogRenderer.setupNoFog(); RenderSystem.disableFog(); return; } @@ -432,26 +432,26 @@ public class LodRenderer private Matrix4f generateModelViewMatrix(float partialTicks) { // get all relevant camera info - ActiveRenderInfo renderInfo = mc.gameRenderer.getActiveRenderInfo(); - Vector3d projectedView = renderInfo.getProjectedView(); + ActiveRenderInfo renderInfo = mc.gameRenderer.getMainCamera(); + Vector3d projectedView = renderInfo.getPosition(); // generate the model view matrix MatrixStack matrixStack = new MatrixStack(); - matrixStack.push(); + matrixStack.pushPose(); // translate and rotate to the current camera location - matrixStack.rotate(Vector3f.XP.rotationDegrees(renderInfo.getPitch())); - matrixStack.rotate(Vector3f.YP.rotationDegrees(renderInfo.getYaw() + 180)); + matrixStack.mulPose(Vector3f.XP.rotationDegrees(renderInfo.getXRot())); + matrixStack.mulPose(Vector3f.YP.rotationDegrees(renderInfo.getYRot() + 180)); matrixStack.translate(-projectedView.x, -projectedView.y, -projectedView.z); - return matrixStack.getLast().getMatrix(); + return matrixStack.last().pose(); } /** * create a new projection matrix and send it over to the GPU *

- * A lot of this code is copied from renderWorld (line 578) + * A lot of this code is copied from renderLevel (line 567) * in the GameRender class. The code copied is anything with * a matrixStack and is responsible for making sure the LOD * objects distort correctly relative to the rest of the world. @@ -467,25 +467,25 @@ public class LodRenderer // all the transformations in renderWorld are here too MatrixStack matrixStack = new MatrixStack(); - matrixStack.push(); + matrixStack.pushPose(); - gameRender.hurtCameraEffect(matrixStack, partialTicks); - if (this.mc.gameSettings.viewBobbing) { - gameRender.applyBobbing(matrixStack, partialTicks); + gameRender.bobHurt(matrixStack, partialTicks); + if (this.mc.options.bobView) { + gameRender.bobView(matrixStack, partialTicks); } // potion and nausea effects - float f = MathHelper.lerp(partialTicks, mc.player.prevTimeInPortal, mc.player.timeInPortal) * mc.gameSettings.screenEffectScale * mc.gameSettings.screenEffectScale; - if (f > 0.0F) { - int i = this.mc.player.isPotionActive(Effects.NAUSEA) ? 7 : 20; - float f1 = 5.0F / (f * f + 5.0F) - f * 0.04F; - f1 = f1 * f1; - Vector3f vector3f = new Vector3f(0.0F, MathHelper.SQRT_2 / 2.0F, MathHelper.SQRT_2 / 2.0F); - matrixStack.rotate(vector3f.rotationDegrees((gameRender.rendererUpdateCount + partialTicks) * i)); - matrixStack.scale(1.0F / f1, 1.0F, 1.0F); - float f2 = -(gameRender.rendererUpdateCount + partialTicks) * i; - matrixStack.rotate(vector3f.rotationDegrees(f2)); - } + float f = MathHelper.lerp(partialTicks, this.mc.player.oPortalTime, this.mc.player.portalTime) * this.mc.options.screenEffectScale * this.mc.options.screenEffectScale; + if (f > 0.0F) { + int i = this.mc.player.hasEffect(Effects.CONFUSION) ? 7 : 20; + float f1 = 5.0F / (f * f + 5.0F) - f * 0.04F; + f1 = f1 * f1; + Vector3f vector3f = new Vector3f(0.0F, MathHelper.SQRT_OF_TWO / 2.0F, MathHelper.SQRT_OF_TWO / 2.0F); + matrixStack.mulPose(vector3f.rotationDegrees((gameRender.tick + partialTicks) * i)); + matrixStack.scale(1.0F / f1, 1.0F, 1.0F); + float f2 = -(gameRender.tick + partialTicks) * i; + matrixStack.mulPose(vector3f.rotationDegrees(f2)); + } @@ -494,12 +494,12 @@ public class LodRenderer Matrix4f projectionMatrix = Matrix4f.perspective( getFov(partialTicks, true), - (float)this.mc.getMainWindow().getFramebufferWidth() / (float)this.mc.getMainWindow().getFramebufferHeight(), + (float)this.mc.getWindow().getScreenWidth() / (float)this.mc.getWindow().getScreenHeight(), 0.5F, this.farPlaneDistance * LodConfig.CLIENT.lodChunkRadiusMultiplier.get() * 2); // add the screen space distortions - projectionMatrix.mul(matrixStack.getLast().getMatrix()); + projectionMatrix.multiply(matrixStack.last().pose()); gameRender.resetProjectionMatrix(projectionMatrix); return; } @@ -510,8 +510,8 @@ public class LodRenderer */ private void setupLighting(LodDimension lodDimension, float partialTicks) { - float sunBrightness = lodDimension.dimension.hasSkyLight() ? mc.world.getSunBrightness(partialTicks) : 0.2f; - float gammaMultiplyer = (float)mc.gameSettings.gamma - 0.5f; + float sunBrightness = lodDimension.dimension.hasSkyLight() ? mc.level.getSkyDarken(partialTicks) : 0.2f; + float gammaMultiplyer = (float)mc.options.gamma - 0.5f; float lightStrength = ((sunBrightness / 2f) - 0.2f) + (gammaMultiplyer * 0.2f); float lightAmbient[] = {lightStrength, lightStrength, lightStrength, 1.0f}; @@ -609,7 +609,7 @@ public class LodRenderer private double getFov(float partialTicks, boolean useFovSetting) { - return mc.gameRenderer.getFOVModifier(mc.gameRenderer.getActiveRenderInfo(), partialTicks, useFovSetting); + return mc.gameRenderer.getFov(mc.gameRenderer.getMainCamera(), partialTicks, useFovSetting); } @@ -686,7 +686,7 @@ public class LodRenderer */ private HashSet getNearbyLodChunkPosToSkip(LodDimension lodDim, BlockPos playerPos) { - int chunkRenderDist = mc.gameSettings.renderDistanceChunks; + int chunkRenderDist = mc.options.renderDistance; int blockRenderDist = chunkRenderDist * 16; ChunkPos centerChunk = new ChunkPos(playerPos); @@ -739,13 +739,12 @@ public class LodRenderer // Wow those are some long names! // go through every RenderInfo to get the compiled chunks - for(WorldRenderer.LocalRenderInformationContainer - worldrenderer$localrenderinformationcontainer : mc.worldRenderer.renderInfos) + for(WorldRenderer.LocalRenderInformationContainer worldrenderer$localrenderinformationcontainer : mc.levelRenderer.renderChunks) { - if (!worldrenderer$localrenderinformationcontainer.renderChunk.getCompiledChunk().isEmpty()) + if (!worldrenderer$localrenderinformationcontainer.chunk.getCompiledChunk().hasNoRenderableLayers()) { // add the ChunkPos for every empty compiled chunk - BlockPos bpos = worldrenderer$localrenderinformationcontainer.renderChunk.getPosition(); + BlockPos bpos = worldrenderer$localrenderinformationcontainer.chunk.getOrigin(); loadedPos.add(new ChunkPos(bpos.getX() / 16, bpos.getZ() / 16)); } diff --git a/src/main/java/com/seibel/lod/render/RenderUtil.java b/src/main/java/com/seibel/lod/render/RenderUtil.java index 1a9b9d506..d575d7eda 100644 --- a/src/main/java/com/seibel/lod/render/RenderUtil.java +++ b/src/main/java/com/seibel/lod/render/RenderUtil.java @@ -27,11 +27,11 @@ public class RenderUtil { Minecraft mc = Minecraft.getInstance(); - return (pos.x >= center.x - mc.gameSettings.renderDistanceChunks - && pos.x <= center.x + mc.gameSettings.renderDistanceChunks) + return (pos.x >= center.x - mc.options.renderDistance + && pos.x <= center.x + mc.options.renderDistance) && - (pos.z >= center.z - mc.gameSettings.renderDistanceChunks - && pos.z <= center.z + mc.gameSettings.renderDistanceChunks); + (pos.z >= center.z - mc.options.renderDistance + && pos.z <= center.z + mc.options.renderDistance); } /** @@ -42,11 +42,11 @@ public class RenderUtil { Minecraft mc = Minecraft.getInstance(); - return (i >= centerCoordinate - mc.gameSettings.renderDistanceChunks - && i <= centerCoordinate + mc.gameSettings.renderDistanceChunks) + return (i >= centerCoordinate - mc.options.renderDistance + && i <= centerCoordinate + mc.options.renderDistance) && - (j >= centerCoordinate - mc.gameSettings.renderDistanceChunks - && j <= centerCoordinate + mc.gameSettings.renderDistanceChunks); + (j >= centerCoordinate - mc.options.renderDistance + && j <= centerCoordinate + mc.options.renderDistance); } @@ -71,7 +71,7 @@ public class RenderUtil */ public static int getBufferMemoryForRadiusMultiplier(int radiusMultiplier) { - int numbChunksWide = mc.gameSettings.renderDistanceChunks * + int numbChunksWide = mc.options.renderDistance * radiusMultiplier * 2; // calculate the max amount of buffer memory needed (in bytes) @@ -89,6 +89,6 @@ public class RenderUtil int maxNumberOfLods = LodRenderer.MAX_ALOCATEABLE_DIRECT_MEMORY / lodTemplate.getBufferMemoryForSingleLod(lodDetail); int numbLodsWide = (int) Math.sqrt(maxNumberOfLods); - return numbLodsWide / (2 * mc.gameSettings.renderDistanceChunks); + return numbLodsWide / (2 * mc.options.renderDistance); } } diff --git a/src/main/java/com/seibel/lod/util/LodUtil.java b/src/main/java/com/seibel/lod/util/LodUtil.java index 754f608da..a36df9819 100644 --- a/src/main/java/com/seibel/lod/util/LodUtil.java +++ b/src/main/java/com/seibel/lod/util/LodUtil.java @@ -36,10 +36,10 @@ public class LodUtil */ public static ServerWorld getFirstValidServerWorld() { - if (mc.getIntegratedServer() == null) + if (mc.hasSingleplayerServer()) return null; - Iterable worlds = mc.getIntegratedServer().getWorlds(); + Iterable worlds = mc.getSingleplayerServer().getAllLevels(); for (ServerWorld world : worlds) return world; @@ -54,16 +54,16 @@ public class LodUtil */ public static ServerWorld getServerWorldFromDimension(DimensionType dimension) { - IntegratedServer server = mc.getIntegratedServer(); + IntegratedServer server = mc.getSingleplayerServer(); if (server == null) return null; - Iterable worlds = server.getWorlds(); + Iterable worlds = server.getAllLevels(); ServerWorld returnWorld = null; for (ServerWorld world : worlds) { - if(world.getDimensionType() == dimension) + if(world.dimensionType() == dimension) { returnWorld = world; break; @@ -121,31 +121,31 @@ public class LodUtil Minecraft mc = Minecraft.getInstance(); - if(mc.isIntegratedServerRunning()) + if(mc.hasSingleplayerServer()) { // this will return the world save location // and the dimension folder - if(mc.world == null) + if(mc.level == null) return ""; - ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(mc.world.getDimensionType()); + ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(mc.level.dimensionType()); if(serverWorld == null) return ""; - ServerChunkProvider provider = serverWorld.getChunkProvider(); + ServerChunkProvider provider = serverWorld.getChunkSource(); if(provider == null) return ""; - return provider.getSavedData().folder.toString(); + return provider.dataStorage.dataFolder.toString(); } else { - ServerData server = mc.getCurrentServerData(); - return server.serverName + ", IP " + - server.serverIP + ", GameVersion " + - server.gameVersion.getString() + File.separatorChar - + "dim_" + mc.world.getDimensionType().getEffects().getPath() + File.separatorChar; + ServerData server = mc.getCurrentServer(); + return server.name + ", IP " + + server.ip + ", GameVersion " + + server.version.getString() + File.separatorChar + + "dim_" + mc.level.dimensionType().effectsLocation().getPath() + File.separatorChar; } } @@ -162,28 +162,28 @@ public class LodUtil { Minecraft mc = Minecraft.getInstance(); - if(mc.isIntegratedServerRunning()) + if(mc.hasSingleplayerServer()) { // this will return the world save location // and the dimension folder - ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(world.getDimensionType()); + ServerWorld serverWorld = LodUtil.getServerWorldFromDimension(world.dimensionType()); if(serverWorld == null) - throw new NullPointerException("getDimensionIDFromWorld wasn't able to get the ServerWorld for the dimension " + world.getDimensionType().getEffects().getPath()); + throw new NullPointerException("getDimensionIDFromWorld wasn't able to get the ServerWorld for the dimension " + world.dimensionType().effectsLocation().getPath()); - ServerChunkProvider provider = serverWorld.getChunkProvider(); + ServerChunkProvider provider = serverWorld.getChunkSource(); if(provider == null) - throw new NullPointerException("getDimensionIDFromWorld wasn't able to get the ServerChunkProvider for the dimension " + world.getDimensionType().getEffects().getPath()); + throw new NullPointerException("getDimensionIDFromWorld wasn't able to get the ServerChunkProvider for the dimension " + world.dimensionType().effectsLocation().getPath()); - return provider.getSavedData().folder.toString(); + return provider.dataStorage.dataFolder.toString(); } else { - ServerData server = mc.getCurrentServerData(); - return server.serverName + ", IP " + - server.serverIP + ", GameVersion " + - server.gameVersion.getString() + File.separatorChar - + "dim_" + world.getDimensionType().getEffects().getPath() + File.separatorChar; + ServerData server = mc.getCurrentServer(); + return server.name + ", IP " + + server.ip + ", GameVersion " + + server.version.getString() + File.separatorChar + + "dim_" + world.dimensionType().effectsLocation().getPath() + File.separatorChar; } } @@ -194,7 +194,7 @@ public class LodUtil */ public static String getWorldID(IWorld world) { - if(mc.isIntegratedServerRunning()) + if(mc.hasSingleplayerServer()) { // chop off the dimension ID as it is not needed/wanted String dimId = getDimensionIDFromWorld(world); @@ -207,10 +207,10 @@ public class LodUtil } else { - ServerData server = mc.getCurrentServerData(); - return server.serverName + ", IP " + - server.serverIP + ", GameVersion " + - server.gameVersion.getString(); + ServerData server = mc.getCurrentServer(); + return server.name + ", IP " + + server.ip + ", GameVersion " + + server.version.getString(); } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 8dcb70209..6340723c7 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -38,6 +38,8 @@ public net.minecraft.world.gen.placement.ConfiguredPlacement field_215097_b # co public net.minecraft.util.WeightedList field_220658_a # weightedEntries public net.minecraft.world.gen.feature.FeatureSpread field_242250_b # base public net.minecraft.world.gen.feature.FeatureSpread field_242251_c # spread +public net.minecraft.world.gen.feature.ConfiguredFeature func_242765_a(Lnet/minecraft/world/ISeedReader;Lnet/minecraft/world/gen/ChunkGenerator;Ljava/util/Random;Lnet/minecraft/util/math/BlockPos;)Z # place +public net.minecraft.world.server.ServerChunkProvider field_217244_j # dataStorage diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 30367326a..2ee5315a0 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -7,7 +7,7 @@ modLoader="javafml" #mandatory #// A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[35,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[36,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. #// The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. #// Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.