Compare commits
62 Commits
2.1.2a
..
java_omega
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c8b3f3cda | |||
| a9a6a19307 | |||
| 208fc69eb7 | |||
| eb1a062934 | |||
| 132251341f | |||
| 2bac5f933a | |||
| 2e565aa83a | |||
| 4e9d0f4861 | |||
| 7216b193e8 | |||
| c33a5bf814 | |||
| 97756a5196 | |||
| 377f7d23e3 | |||
| 7005202384 | |||
| 99e8f57bac | |||
| afddf4168e | |||
| fbffdc0c9f | |||
| e6d3647490 | |||
| 13363ff363 | |||
| 7f98e4b1eb | |||
| 408460b0ae | |||
| b69ef5835d | |||
| 0428fa0912 | |||
| 9f3124fa56 | |||
| fbbdab73c6 | |||
| ee9441c521 | |||
| a9e0fd5d9b | |||
| 98464889ca | |||
| eed5fd60c6 | |||
| ac43cd5496 | |||
| 1f16a7c808 | |||
| 39e4c70754 | |||
| 82eb27af4c | |||
| 07a0779ca4 | |||
| 2adba02a38 | |||
| 9dd76db3fc | |||
| 97dacf2429 | |||
| 1c189e162a | |||
| f7a0fff869 | |||
| 2f985d0926 | |||
| 2a3c544fba | |||
| 09d133b994 | |||
| 26a4223ecf | |||
| e2943fdcaf | |||
| f1053251b4 | |||
| be1dcaf43c | |||
| a899d988fc | |||
| 06b5b2c514 | |||
| 864a19b79f | |||
| 8974323406 | |||
| 46c9e0103a | |||
| 02203466ed | |||
| 87b22ea1cc | |||
| d26327a930 | |||
| 469d2bdcb7 | |||
| 5516603a0c | |||
| b737adc3da | |||
| f3a8afeee3 | |||
| a4501f86e9 | |||
| 55d5bca76d | |||
| f81026c707 | |||
| e86af817e0 | |||
| e0fd2b2f7a |
+27
-54
@@ -12,6 +12,8 @@ plugins {
|
||||
|
||||
// Architectury is used here only as a replacement for forge's own loom
|
||||
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
|
||||
|
||||
id 'xyz.wagyourtail.jvmdowngrader' version '0.9.1' apply true
|
||||
}
|
||||
|
||||
|
||||
@@ -102,16 +104,13 @@ subprojects { p ->
|
||||
// Apply plugins
|
||||
apply plugin: "java"
|
||||
apply plugin: "com.github.johnrengelman.shadow"
|
||||
apply plugin: "xyz.wagyourtail.jvmdowngrader"
|
||||
if (isMinecraftSubProject)
|
||||
apply plugin: "systems.manifold.manifold-gradle-plugin"
|
||||
|
||||
// Apply forge's loom
|
||||
if ((findProject(":forge") && p == project(":forge")) ||
|
||||
(findProject(":neoforge") && p == project(":neoforge"))
|
||||
)
|
||||
{
|
||||
if ( (findProject(":forge") && p == project(":forge")) || (findProject(":neoforge") && p == project(":neoforge")) )
|
||||
apply plugin: "dev.architectury.loom"
|
||||
}
|
||||
|
||||
|
||||
// Set the manifold version (may not be required tough)
|
||||
@@ -311,8 +310,21 @@ subprojects { p ->
|
||||
|
||||
mergeServiceFiles()
|
||||
}
|
||||
// Using jar.finalizedBy(shadowJar) causes issues so we do this scuffed bypass
|
||||
jar.dependsOn(shadowJar)
|
||||
|
||||
// For downgrading the Java version of our project to match the minimum Java version required by the selected Minecraft version.
|
||||
task jarDowngrade(type: xyz.wagyourtail.jvmdg.gradle.task.DowngradeJar) {
|
||||
inputFile = tasks.shadowJar.archiveFile
|
||||
downgradeTo = JavaVersion.toVersion(rootProject.java_version as Integer)
|
||||
archiveClassifier = "downgraded-${rootProject.java_version}"
|
||||
}
|
||||
task apiDowngrade(type: xyz.wagyourtail.jvmdg.gradle.task.ShadeJar) {
|
||||
inputFile = jarDowngrade.archiveFile
|
||||
downgradeTo = JavaVersion.toVersion(rootProject.java_version as Integer)
|
||||
archiveClassifier = "downgraded-${rootProject.java_version}-shaded-java-api"
|
||||
}
|
||||
// We're using a custom downgrade task so we disable the original downgrade tasks
|
||||
downgradeJar.enabled = false
|
||||
shadeDowngradedApi.enabled = false
|
||||
|
||||
|
||||
// Put stuff from gradle.properties into the mod info
|
||||
@@ -431,11 +443,9 @@ subprojects { p ->
|
||||
jar {
|
||||
from "LICENSE.txt"
|
||||
manifest {
|
||||
attributes(
|
||||
'Implementation-Title': rootProject.mod_name,
|
||||
'Implementation-Version': rootProject.mod_version,
|
||||
'Main-Class': 'com.seibel.distanthorizons.core.jar.JarMain' // When changing the main of the jar change this line
|
||||
)
|
||||
attributes 'Implementation-Title': rootProject.mod_name,
|
||||
'Implementation-Version': rootProject.mod_version,
|
||||
'Main-Class': 'com.seibel.distanthorizons.core.jar.JarMain' // When changing the main of the jar change this line
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,44 +567,6 @@ allprojects { p ->
|
||||
// TODO: If neoforged is ever needed, should we use that, or call it a forge mod?
|
||||
}
|
||||
|
||||
// Adds some dependencies that are in vanilla but not in core
|
||||
if (p == project(":core")) {
|
||||
OperatingSystem os = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem;
|
||||
|
||||
// Set the OS lwjgl is using to the current os
|
||||
project.ext.lwjglNatives = "natives-" + os.toFamilyName()
|
||||
|
||||
dependencies { // All of these dependencies are in Vanilla Minecraft, but we need to depend on it as we arent importing Minecraft in the core
|
||||
// Imports most of lwjgl's libraries (well, only the ones that we need)
|
||||
implementation platform("org.lwjgl:lwjgl-bom:${rootProject.lwjgl_version}") // TODO: Use Minecraft's version for lwjgl_version (which changes in nearly every version) instead of a hard defined version for all versions
|
||||
|
||||
// REMEMBER: Dont shadow stuff here, these are just the libs that are included in Minecraft so that the core can use
|
||||
implementation "org.lwjgl:lwjgl"
|
||||
implementation "org.lwjgl:lwjgl-assimp"
|
||||
implementation "org.lwjgl:lwjgl-glfw"
|
||||
implementation "org.lwjgl:lwjgl-openal"
|
||||
implementation "org.lwjgl:lwjgl-opengl"
|
||||
implementation "org.lwjgl:lwjgl-stb"
|
||||
implementation "org.lwjgl:lwjgl-tinyfd"
|
||||
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
|
||||
runtimeOnly "org.lwjgl:lwjgl-tinyfd::$lwjglNatives"
|
||||
implementation "org.joml:joml:${rootProject.joml_version}"
|
||||
|
||||
|
||||
// Some other dependencies
|
||||
implementation("org.jetbrains:annotations:16.0.2")
|
||||
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||
implementation("com.google.common:google-collect:0.5")
|
||||
implementation("com.google.guava:guava:31.1-jre")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
task copyCommonLoaderResources(type: Copy) {
|
||||
from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener")
|
||||
into(file(p.file("build/resources/main")))
|
||||
@@ -616,16 +588,17 @@ allprojects { p ->
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
if (isMinecraftSubProject) {
|
||||
options.release = rootProject.java_version as Integer
|
||||
options.release = rootProject.java_version as Integer // Neoforge complains without this
|
||||
options.compilerArgs += ["-Xplugin:Manifold"]
|
||||
} else {
|
||||
options.release = 8; // Core & Api should use Java 8 no matter what
|
||||
//options.release = rootProject.java_version as Integer // But if you want to test some stuff, then this can be enabled
|
||||
}
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
// Sets the project's actual Java version (it's recommended to use this over the `options.release` method above)
|
||||
java {
|
||||
sourceCompatibility = rootProject.java_version
|
||||
targetCompatibility = rootProject.java_version
|
||||
|
||||
withSourcesJar()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public abstract class AbstractModInitializer
|
||||
LOGGER.info(ModInfo.READABLE_NAME + " Initialized");
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null);
|
||||
|
||||
this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandDispatcher = dispatcher; });
|
||||
this.subscribeRegisterCommandsEvent(dispatcher -> this.commandDispatcher = dispatcher);
|
||||
|
||||
this.subscribeServerStartingEvent(server ->
|
||||
{
|
||||
|
||||
+1
-1
@@ -26,6 +26,6 @@ public class DependencySetupDoneCheck
|
||||
// TODO move to DependencySetup
|
||||
public static boolean isDone = false;
|
||||
// TODO why is this here and what is its purpose?
|
||||
public static Supplier<Boolean> getIsCurrentThreadDistantGeneratorThread = (() -> { return false; });
|
||||
public static Supplier<Boolean> getIsCurrentThreadDistantGeneratorThread = (() -> false);
|
||||
|
||||
}
|
||||
|
||||
+11
-27
@@ -26,7 +26,7 @@ import java.util.function.Consumer;
|
||||
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -102,33 +102,17 @@ public class McObjectConverter
|
||||
lodDirections = new EDhDirection[lodDirs.length];
|
||||
for (EDhDirection lodDir : lodDirs)
|
||||
{
|
||||
Direction dir;
|
||||
switch (lodDir.name().toUpperCase())
|
||||
{
|
||||
case "DOWN":
|
||||
dir = Direction.DOWN;
|
||||
break;
|
||||
case "UP":
|
||||
dir = Direction.UP;
|
||||
break;
|
||||
case "NORTH":
|
||||
dir = Direction.NORTH;
|
||||
break;
|
||||
case "SOUTH":
|
||||
dir = Direction.SOUTH;
|
||||
break;
|
||||
case "WEST":
|
||||
dir = Direction.WEST;
|
||||
break;
|
||||
case "EAST":
|
||||
dir = Direction.EAST;
|
||||
break;
|
||||
default:
|
||||
dir = null;
|
||||
break;
|
||||
}
|
||||
Direction dir = switch (lodDir.name().toUpperCase()) {
|
||||
case "DOWN" -> Direction.DOWN;
|
||||
case "UP" -> Direction.UP;
|
||||
case "NORTH" -> Direction.NORTH;
|
||||
case "SOUTH" -> Direction.SOUTH;
|
||||
case "WEST" -> Direction.WEST;
|
||||
case "EAST" -> Direction.EAST;
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if (dir == null)
|
||||
if (dir == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid direction on init mapping: " + lodDir);
|
||||
}
|
||||
|
||||
+35
-15
@@ -55,9 +55,6 @@ import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* This handles creating abstract wrapper objects.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-12-5
|
||||
*/
|
||||
public class WrapperFactory implements IWrapperFactory
|
||||
{
|
||||
@@ -82,6 +79,27 @@ public class WrapperFactory implements IWrapperFactory
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDhApiBiomeWrapper getBiomeWrapper(String resourceLocationString, IDhApiLevelWrapper levelWrapper) throws IOException, ClassCastException
|
||||
{
|
||||
if (!(levelWrapper instanceof ILevelWrapper))
|
||||
{
|
||||
throw new ClassCastException("levelWrapper must be returned by DH and of type ["+ILevelWrapper.class.getName()+"].");
|
||||
}
|
||||
|
||||
return BiomeWrapper.deserialize(resourceLocationString, (ILevelWrapper)levelWrapper);
|
||||
}
|
||||
@Override
|
||||
public IDhApiBlockStateWrapper getDefaultBlockStateWrapper(String resourceLocationString, IDhApiLevelWrapper levelWrapper) throws IOException, ClassCastException
|
||||
{
|
||||
if (!(levelWrapper instanceof ILevelWrapper))
|
||||
{
|
||||
throw new ClassCastException("Invalid ["+IDhApiLevelWrapper.class.getSimpleName()+"] value given. Level wrapper object must be one given by the DH API (it can't be a custom implementation), specifically of type ["+ILevelWrapper.class.getName()+"].");
|
||||
}
|
||||
|
||||
return BlockStateWrapper.deserialize(resourceLocationString, (ILevelWrapper)levelWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBiomeWrapper deserializeBiomeWrapper(String str, ILevelWrapper levelWrapper) throws IOException { return BiomeWrapper.deserialize(str, levelWrapper); }
|
||||
@Override
|
||||
@@ -104,6 +122,13 @@ public class WrapperFactory implements IWrapperFactory
|
||||
|
||||
@Override
|
||||
public HashSet<IBlockStateWrapper> getRendererIgnoredBlocks(ILevelWrapper levelWrapper) { return BlockStateWrapper.getRendererIgnoredBlocks(levelWrapper); }
|
||||
@Override
|
||||
public HashSet<IBlockStateWrapper> getRendererIgnoredCaveBlocks(ILevelWrapper levelWrapper) { return BlockStateWrapper.getRendererIgnoredCaveBlocks(levelWrapper); }
|
||||
|
||||
@Override
|
||||
public void resetRendererIgnoredCaveBlocks() { BlockStateWrapper.clearRendererIgnoredCaveBlocks(); }
|
||||
@Override
|
||||
public void resetRendererIgnoredBlocksSet() { BlockStateWrapper.clearRendererIgnoredBlocks(); }
|
||||
|
||||
|
||||
/**
|
||||
@@ -136,19 +161,17 @@ public class WrapperFactory implements IWrapperFactory
|
||||
// correct number of parameters from the API
|
||||
|
||||
// chunk
|
||||
if (!(objectArray[0] instanceof ChunkAccess))
|
||||
if (!(objectArray[0] instanceof ChunkAccess chunk))
|
||||
{
|
||||
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
||||
}
|
||||
ChunkAccess chunk = (ChunkAccess) objectArray[0];
|
||||
|
||||
// level / light source
|
||||
if (!(objectArray[1] instanceof Level))
|
||||
if (!(objectArray[1] instanceof Level level))
|
||||
{
|
||||
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
|
||||
}
|
||||
// the level is needed for the DH level wrapper...
|
||||
Level level = (Level) objectArray[1];
|
||||
// ...the LevelReader is needed for chunk lighting
|
||||
LevelReader lightSource = level;
|
||||
|
||||
@@ -220,11 +243,10 @@ public class WrapperFactory implements IWrapperFactory
|
||||
public IDhApiBiomeWrapper getBiomeWrapper(Object[] objectArray, IDhApiLevelWrapper levelWrapper)
|
||||
{
|
||||
// confirm the API level wrapper is also a Core wrapper
|
||||
if (!(levelWrapper instanceof ILevelWrapper))
|
||||
if (!(levelWrapper instanceof ILevelWrapper coreLevelWrapper))
|
||||
{
|
||||
throw new ClassCastException("Unable to cast... only DH provided IDhApiLevelWrapper's can be used."); // TODO
|
||||
throw new ClassCastException("Invalid ["+IDhApiLevelWrapper.class.getSimpleName()+"] value given. Level wrapper object must be one given by the DH API (it can't be a custom implementation), specifically of type ["+ILevelWrapper.class.getName()+"].");
|
||||
}
|
||||
ILevelWrapper coreLevelWrapper = (ILevelWrapper) levelWrapper;
|
||||
|
||||
|
||||
|
||||
@@ -279,11 +301,10 @@ public class WrapperFactory implements IWrapperFactory
|
||||
public IDhApiBlockStateWrapper getBlockStateWrapper(Object[] objectArray, IDhApiLevelWrapper levelWrapper)
|
||||
{
|
||||
// confirm the API level wrapper is also a Core wrapper
|
||||
if (!(levelWrapper instanceof ILevelWrapper))
|
||||
if (!(levelWrapper instanceof ILevelWrapper coreLevelWrapper))
|
||||
{
|
||||
throw new ClassCastException("Unable to cast... only DH provided IDhApiLevelWrapper's can be used."); // TODO
|
||||
throw new ClassCastException("Invalid ["+IDhApiLevelWrapper.class.getSimpleName()+"] value given. Level wrapper object must be one given by the DH API (it can't be a custom implementation), specifically of type ["+ILevelWrapper.class.getName()+"].");
|
||||
}
|
||||
ILevelWrapper coreLevelWrapper = (ILevelWrapper) levelWrapper;
|
||||
|
||||
|
||||
|
||||
@@ -292,12 +313,11 @@ public class WrapperFactory implements IWrapperFactory
|
||||
{
|
||||
throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray));
|
||||
}
|
||||
if (!(objectArray[0] instanceof BlockState))
|
||||
if (!(objectArray[0] instanceof BlockState blockState))
|
||||
{
|
||||
throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray));
|
||||
}
|
||||
|
||||
BlockState blockState = (BlockState) objectArray[0];
|
||||
return BlockStateWrapper.fromBlockState(blockState, coreLevelWrapper);
|
||||
#else
|
||||
// See preprocessor comment in createChunkWrapper() for full documentation (not a typo, check createChunkWrapper()'s else statement for full documentation)
|
||||
|
||||
+1
-1
@@ -266,7 +266,7 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
}
|
||||
return EMPTY_WRAPPER;
|
||||
}
|
||||
else if (resourceLocationString.trim().isEmpty() || resourceLocationString.equals(""))
|
||||
else if (resourceLocationString.trim().isEmpty() || resourceLocationString.isEmpty())
|
||||
{
|
||||
LOGGER.warn("Null biome string deserialized.");
|
||||
return EMPTY_WRAPPER;
|
||||
|
||||
+165
-46
@@ -19,7 +19,12 @@
|
||||
|
||||
package com.seibel.distanthorizons.common.wrappers.block;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
@@ -29,10 +34,13 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
|
||||
@@ -72,9 +80,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
|
||||
public static final String DIRT_RESOURCE_LOCATION_STRING = "minecraft:dirt";
|
||||
|
||||
// TODO: Make this changeable through the config
|
||||
public static final String[] RENDERER_IGNORED_BLOCKS_RESOURCE_LOCATIONS = { AIR_STRING, "minecraft:barrier", "minecraft:structure_void", "minecraft:light", "minecraft:tripwire" };
|
||||
public static HashSet<IBlockStateWrapper> rendererIgnoredBlocks = null;
|
||||
public static HashSet<IBlockStateWrapper> rendererIgnoredCaveBlocks = null;
|
||||
|
||||
/** keep track of broken blocks so we don't log every time */
|
||||
private static final HashSet<ResourceLocation> BrokenResourceLocations = new HashSet<>();
|
||||
@@ -89,11 +96,16 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
private final int hashCode;
|
||||
/**
|
||||
* Cached opacity value, -1 if not populated. <br>
|
||||
* Should be between {@link IBlockStateWrapper#FULLY_OPAQUE} and {@link IBlockStateWrapper#FULLY_OPAQUE}
|
||||
* Should be between {@link LodUtil#BLOCK_FULLY_OPAQUE} and {@link LodUtil#BLOCK_FULLY_OPAQUE}
|
||||
*/
|
||||
private int opacity = -1;
|
||||
/** used by the Iris shader mod to determine how each LOD should be rendered */
|
||||
private byte irisBlockMaterialId = 0;
|
||||
private byte blockMaterialId = 0;
|
||||
|
||||
private final boolean isBeaconBlock;
|
||||
private final boolean isBeaconBaseBlock;
|
||||
private final boolean isGlassBlock;
|
||||
private final Color mapColor;
|
||||
|
||||
|
||||
|
||||
@@ -126,16 +138,46 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
this.blockState = blockState;
|
||||
this.serialString = this.serialize(levelWrapper);
|
||||
this.hashCode = Objects.hash(this.serialString);
|
||||
this.irisBlockMaterialId = this.calculateIrisBlockMaterialId();
|
||||
this.blockMaterialId = this.calculateEDhApiBlockMaterialId().index;
|
||||
|
||||
//LOGGER.trace("Created BlockStateWrapper ["+this.serialString+"] for ["+blockState+"] with material ID ["+this.irisBlockMaterialId+"]");
|
||||
String lowercaseSerial = this.serialString.toLowerCase();
|
||||
boolean isBeaconBaseBlock = false;
|
||||
for (int i = 0; i < LodUtil.BEACON_BASE_BLOCK_NAME_LIST.size(); i++)
|
||||
{
|
||||
String baseBlockName = LodUtil.BEACON_BASE_BLOCK_NAME_LIST.get(i);
|
||||
if (lowercaseSerial.contains(baseBlockName))
|
||||
{
|
||||
isBeaconBaseBlock = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.isBeaconBaseBlock = isBeaconBaseBlock;
|
||||
this.isBeaconBlock = lowercaseSerial.contains("minecraft:beacon");
|
||||
this.isGlassBlock = lowercaseSerial.contains("glass");
|
||||
|
||||
int mcColor = 0;
|
||||
if (this.blockState != null)
|
||||
{
|
||||
#if MC_VER < MC_1_20_1
|
||||
mcColor = this.blockState.getMaterial().getColor().col;
|
||||
#else
|
||||
mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col;
|
||||
#endif
|
||||
this.mapColor = ColorUtil.toColorObjRGB(mcColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mapColor = new Color(0,0,0,0);
|
||||
}
|
||||
|
||||
//LOGGER.trace("Created BlockStateWrapper ["+this.serialString+"] for ["+blockState+"] with material ID ["+this.EDhApiBlockMaterialId+"]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// helper methods //
|
||||
//================//
|
||||
//====================//
|
||||
// LodBuilder methods //
|
||||
//====================//
|
||||
|
||||
/**
|
||||
* Requires a {@link ILevelWrapper} since {@link BlockStateWrapper#deserialize(String,ILevelWrapper)} also requires one.
|
||||
@@ -149,37 +191,104 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
return rendererIgnoredBlocks;
|
||||
}
|
||||
|
||||
HashSet<String> baseIgnoredBlock = new HashSet<>();
|
||||
baseIgnoredBlock.add(AIR_STRING);
|
||||
rendererIgnoredBlocks = getBlockWrappers(Config.Client.Advanced.LodBuilding.ignoredRenderBlockCsv, baseIgnoredBlock, levelWrapper);
|
||||
return rendererIgnoredBlocks;
|
||||
}
|
||||
/**
|
||||
* Requires a {@link ILevelWrapper} since {@link BlockStateWrapper#deserialize(String,ILevelWrapper)} also requires one.
|
||||
* This way the method won't accidentally be called before the deserialization can be completed.
|
||||
*/
|
||||
public static HashSet<IBlockStateWrapper> getRendererIgnoredCaveBlocks(ILevelWrapper levelWrapper)
|
||||
{
|
||||
// use the cached version if possible
|
||||
if (rendererIgnoredCaveBlocks != null)
|
||||
{
|
||||
return rendererIgnoredCaveBlocks;
|
||||
}
|
||||
|
||||
HashSet<String> baseIgnoredBlock = new HashSet<>();
|
||||
baseIgnoredBlock.add(AIR_STRING);
|
||||
rendererIgnoredCaveBlocks = getBlockWrappers(Config.Client.Advanced.LodBuilding.ignoredRenderCaveBlockCsv, baseIgnoredBlock, levelWrapper);
|
||||
return rendererIgnoredCaveBlocks;
|
||||
}
|
||||
|
||||
public static void clearRendererIgnoredBlocks() { rendererIgnoredBlocks = null; }
|
||||
public static void clearRendererIgnoredCaveBlocks() { rendererIgnoredCaveBlocks = null; }
|
||||
|
||||
|
||||
|
||||
// lod builder helpers //
|
||||
|
||||
private static HashSet<IBlockStateWrapper> getBlockWrappers(ConfigEntry<String> config, HashSet<String> baseResourceLocations, ILevelWrapper levelWrapper)
|
||||
{
|
||||
// get the base blocks
|
||||
HashSet<String> blockStringList = new HashSet<>();
|
||||
if (baseResourceLocations != null)
|
||||
{
|
||||
blockStringList.addAll(baseResourceLocations);
|
||||
}
|
||||
|
||||
// get the config blocks
|
||||
String ignoreBlockCsv = config.get();
|
||||
if (ignoreBlockCsv != null)
|
||||
{
|
||||
blockStringList.addAll(List.of(ignoreBlockCsv.split(",")));
|
||||
}
|
||||
|
||||
return getBlockWrappers(blockStringList, levelWrapper);
|
||||
}
|
||||
private static HashSet<IBlockStateWrapper> getBlockWrappers(HashSet<String> blockResourceLocationSet, ILevelWrapper levelWrapper)
|
||||
{
|
||||
// deserialize each of the given resource locations
|
||||
HashSet<IBlockStateWrapper> blockStateWrappers = new HashSet<>();
|
||||
for (String blockResourceLocation : RENDERER_IGNORED_BLOCKS_RESOURCE_LOCATIONS)
|
||||
for (String blockResourceLocation : blockResourceLocationSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockStateWrapper DefaultBlockStateToIgnore = (BlockStateWrapper) deserialize(blockResourceLocation, levelWrapper);
|
||||
blockStateWrappers.add(DefaultBlockStateToIgnore);
|
||||
|
||||
if (DefaultBlockStateToIgnore == AIR)
|
||||
if (blockResourceLocation == null)
|
||||
{
|
||||
// shouldn't happen, but just in case
|
||||
continue;
|
||||
}
|
||||
String cleanedResourceLocation = blockResourceLocation.trim();
|
||||
if (cleanedResourceLocation.length() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// add all possible blockstates (to account for light blocks with different light values and such)
|
||||
List<BlockState> blockStatesToIgnore = DefaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates();
|
||||
for (BlockState blockState : blockStatesToIgnore)
|
||||
|
||||
BlockStateWrapper defaultBlockStateToIgnore = (BlockStateWrapper) deserialize(cleanedResourceLocation, levelWrapper);
|
||||
blockStateWrappers.add(defaultBlockStateToIgnore);
|
||||
|
||||
if (defaultBlockStateToIgnore != AIR)
|
||||
{
|
||||
BlockStateWrapper newBlockToIgnore = BlockStateWrapper.fromBlockState(blockState, levelWrapper);
|
||||
blockStateWrappers.add(newBlockToIgnore);
|
||||
// add all possible blockstates (to account for light blocks with different light values and such)
|
||||
List<BlockState> blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates();
|
||||
for (BlockState blockState : blockStatesToIgnore)
|
||||
{
|
||||
BlockStateWrapper newBlockToIgnore = BlockStateWrapper.fromBlockState(blockState, levelWrapper);
|
||||
blockStateWrappers.add(newBlockToIgnore);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// air is a special case so it must be handled separately
|
||||
blockStateWrappers.add(AIR);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warn("Unable to deserialize rendererIgnoredBlock with the resource location: ["+blockResourceLocation+"]. Error: "+e.getMessage(), e);
|
||||
LOGGER.warn("Unable to deserialize block with the resource location: ["+blockResourceLocation+"]. Error: "+e.getMessage(), e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warn("Unexpected error deserializing block with the resource location: ["+blockResourceLocation+"]. Error: "+e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
rendererIgnoredBlocks = blockStateWrappers;
|
||||
return rendererIgnoredBlocks;
|
||||
return blockStateWrappers;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,23 +311,23 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
int opacity;
|
||||
if (this.isAir())
|
||||
{
|
||||
opacity = FULLY_TRANSPARENT;
|
||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
||||
}
|
||||
else if (this.isLiquid() && !this.blockState.canOcclude())
|
||||
{
|
||||
// probably not a waterlogged block (which should block light entirely)
|
||||
|
||||
// +1 to indicate that the block is translucent (in between transparent and opaque)
|
||||
opacity = FULLY_TRANSPARENT + 1;
|
||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT + 1;
|
||||
}
|
||||
else if (this.blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO))
|
||||
{
|
||||
opacity = FULLY_TRANSPARENT;
|
||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
// default for all other blocks
|
||||
opacity = FULLY_OPAQUE;
|
||||
opacity = LodUtil.BLOCK_FULLY_OPAQUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +396,17 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getIrisBlockMaterialId() { return this.irisBlockMaterialId; }
|
||||
public boolean isBeaconBlock() { return this.isBeaconBlock; }
|
||||
@Override
|
||||
public boolean isBeaconBaseBlock() { return this.isBeaconBaseBlock; }
|
||||
@Override
|
||||
public boolean isGlassBlock() { return this.isGlassBlock; }
|
||||
|
||||
@Override
|
||||
public Color getMapColor() { return this.mapColor; }
|
||||
|
||||
@Override
|
||||
public byte getMaterialId() { return this.blockMaterialId; }
|
||||
|
||||
@Override
|
||||
public String toString() { return this.getSerialString(); }
|
||||
@@ -343,7 +462,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
// we need the final string for the concurrent hash map later
|
||||
final String finalResourceStateString = resourceStateString;
|
||||
|
||||
if (finalResourceStateString.equals(AIR_STRING) || finalResourceStateString.equals("")) // the empty string shouldn't normally happen, but just in case
|
||||
if (finalResourceStateString.equals(AIR_STRING) || finalResourceStateString.isEmpty()) // the empty string shouldn't normally happen, but just in case
|
||||
{
|
||||
return AIR;
|
||||
}
|
||||
@@ -484,7 +603,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
|
||||
// alphabetically sort the list so they are always in the same order
|
||||
List<net.minecraft.world.level.block.state.properties.Property<?>> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection);
|
||||
sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName()));
|
||||
sortedBlockPropteryList.sort(Comparator.comparing(Property::getName));
|
||||
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
@@ -512,11 +631,11 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
// Iris methods //
|
||||
//==============//
|
||||
|
||||
private byte calculateIrisBlockMaterialId()
|
||||
private EDhApiBlockMaterial calculateEDhApiBlockMaterialId()
|
||||
{
|
||||
if (this.blockState == null)
|
||||
{
|
||||
return IrisBlockMaterial.AIR;
|
||||
return EDhApiBlockMaterial.AIR;
|
||||
}
|
||||
|
||||
|
||||
@@ -529,15 +648,15 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
|| serialString.contains("mushroom")
|
||||
)
|
||||
{
|
||||
return IrisBlockMaterial.LEAVES;
|
||||
return EDhApiBlockMaterial.LEAVES;
|
||||
}
|
||||
else if (this.blockState.is(Blocks.LAVA))
|
||||
{
|
||||
return IrisBlockMaterial.LAVA;
|
||||
return EDhApiBlockMaterial.LAVA;
|
||||
}
|
||||
else if (this.isLiquid() || this.blockState.is(Blocks.WATER))
|
||||
{
|
||||
return IrisBlockMaterial.WATER;
|
||||
return EDhApiBlockMaterial.WATER;
|
||||
}
|
||||
else if (this.blockState.getSoundType() == SoundType.WOOD
|
||||
|| serialString.contains("root")
|
||||
@@ -546,7 +665,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return IrisBlockMaterial.WOOD;
|
||||
return EDhApiBlockMaterial.WOOD;
|
||||
}
|
||||
else if (this.blockState.getSoundType() == SoundType.METAL
|
||||
#if MC_VER >= MC_1_19_2
|
||||
@@ -558,11 +677,11 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return IrisBlockMaterial.METAL;
|
||||
return EDhApiBlockMaterial.METAL;
|
||||
}
|
||||
else if (serialString.contains("grass_block"))
|
||||
{
|
||||
return IrisBlockMaterial.GRASS;
|
||||
return EDhApiBlockMaterial.GRASS;
|
||||
}
|
||||
else if (
|
||||
serialString.contains("dirt")
|
||||
@@ -572,7 +691,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
|| serialString.contains("mycelium")
|
||||
)
|
||||
{
|
||||
return IrisBlockMaterial.DIRT;
|
||||
return EDhApiBlockMaterial.DIRT;
|
||||
}
|
||||
#if MC_VER >= MC_1_17_1
|
||||
else if (this.blockState.getSoundType() == SoundType.DEEPSLATE
|
||||
@@ -581,37 +700,37 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
|| this.blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE
|
||||
|| serialString.contains("deepslate") )
|
||||
{
|
||||
return IrisBlockMaterial.DEEPSLATE;
|
||||
return EDhApiBlockMaterial.DEEPSLATE;
|
||||
}
|
||||
#endif
|
||||
else if (this.serialString.contains("snow"))
|
||||
{
|
||||
return IrisBlockMaterial.SNOW;
|
||||
return EDhApiBlockMaterial.SNOW;
|
||||
}
|
||||
else if (serialString.contains("sand"))
|
||||
{
|
||||
return IrisBlockMaterial.SAND;
|
||||
return EDhApiBlockMaterial.SAND;
|
||||
}
|
||||
else if (serialString.contains("terracotta"))
|
||||
{
|
||||
return IrisBlockMaterial.TERRACOTTA;
|
||||
return EDhApiBlockMaterial.TERRACOTTA;
|
||||
}
|
||||
else if (this.blockState.is(BlockTags.BASE_STONE_NETHER))
|
||||
{
|
||||
return IrisBlockMaterial.NETHER_STONE;
|
||||
return EDhApiBlockMaterial.NETHER_STONE;
|
||||
}
|
||||
else if (serialString.contains("stone")
|
||||
|| serialString.contains("ore"))
|
||||
{
|
||||
return IrisBlockMaterial.STONE;
|
||||
return EDhApiBlockMaterial.STONE;
|
||||
}
|
||||
else if (this.blockState.getLightEmission() > 0)
|
||||
{
|
||||
return IrisBlockMaterial.ILLUMINATED;
|
||||
return EDhApiBlockMaterial.ILLUMINATED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return IrisBlockMaterial.UNKOWN;
|
||||
return EDhApiBlockMaterial.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -312,12 +312,12 @@ public class ClientBlockStateCache
|
||||
}
|
||||
if (quads != null && !quads.isEmpty())
|
||||
{
|
||||
needPostTinting = quads.get(0).isTinted();
|
||||
needShade = quads.get(0).isShade();
|
||||
tintIndex = quads.get(0).getTintIndex();
|
||||
needPostTinting = quads.getFirst().isTinted();
|
||||
needShade = quads.getFirst().isShade();
|
||||
tintIndex = quads.getFirst().getTintIndex();
|
||||
baseColor = calculateColorFromTexture(
|
||||
#if MC_VER < MC_1_17_1 quads.get(0).sprite,
|
||||
#else quads.get(0).getSprite(), #endif
|
||||
#else quads.getFirst().getSprite(), #endif
|
||||
ColorMode.getColorMode(blockState.getBlock()));
|
||||
}
|
||||
else
|
||||
|
||||
+9
-18
@@ -83,7 +83,7 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
/** can be used for interactions with the underlying chunk where creating new BlockPos objects could cause issues for the garbage collector. */
|
||||
private static final ThreadLocal<BlockPos.MutableBlockPos> MUTABLE_BLOCK_POS_REF = ThreadLocal.withInitial(() -> new BlockPos.MutableBlockPos());
|
||||
private static final ThreadLocal<BlockPos.MutableBlockPos> MUTABLE_BLOCK_POS_REF = ThreadLocal.withInitial(BlockPos.MutableBlockPos::new);
|
||||
|
||||
|
||||
private final ChunkAccess chunk;
|
||||
@@ -223,6 +223,9 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
LevelChunkSection[] sections = this.chunk.getSections();
|
||||
for (int index = sections.length-1; index >= 0; index--)
|
||||
{
|
||||
// update at each position to fix using the max height if the chunk is empty
|
||||
this.maxNonEmptyHeight = this.getChunkSectionMinHeight(index) + 16;
|
||||
|
||||
if (sections[index] == null)
|
||||
{
|
||||
continue;
|
||||
@@ -230,7 +233,7 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
if (!isChunkSectionEmpty(sections[index]))
|
||||
{
|
||||
this.maxNonEmptyHeight = this.getChunkSectionMinHeight(index) + 16;
|
||||
// non-empty section found
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -247,15 +250,7 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
return section.hasOnlyAir();
|
||||
#endif
|
||||
}
|
||||
private int getChunkSectionMinHeight(int index)
|
||||
{
|
||||
// convert from an index to a block coordinate
|
||||
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
|
||||
return this.chunk.getSections()[index].bottomBlockY();
|
||||
#else
|
||||
return this.chunk.getSectionYFromSectionIndex(index) * 16;
|
||||
#endif
|
||||
}
|
||||
private int getChunkSectionMinHeight(int index) { return (index * 16) + this.getMinBuildHeight(); }
|
||||
|
||||
|
||||
@Override
|
||||
@@ -350,9 +345,8 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
|
||||
return false; // MC's lighting engine doesn't work consistently enough to trust for 1.16 or 1.17
|
||||
#else
|
||||
if (this.chunk instanceof LevelChunk)
|
||||
if (this.chunk instanceof LevelChunk levelChunk)
|
||||
{
|
||||
LevelChunk levelChunk = (LevelChunk) this.chunk;
|
||||
if (levelChunk.getLevel() instanceof ClientLevel)
|
||||
{
|
||||
// connected to a server
|
||||
@@ -479,9 +473,7 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
});
|
||||
#else
|
||||
this.chunk.findBlockLightSources((blockPos, blockState) ->
|
||||
{
|
||||
this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
});
|
||||
this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ())));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -512,9 +504,8 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
/** Should be called after client light updates are triggered. */
|
||||
private void updateIsClientLightingCorrect()
|
||||
{
|
||||
if (this.chunk instanceof LevelChunk && ((LevelChunk) this.chunk).getLevel() instanceof ClientLevel)
|
||||
if (this.chunk instanceof LevelChunk levelChunk && ((LevelChunk) this.chunk).getLevel() instanceof ClientLevel)
|
||||
{
|
||||
LevelChunk levelChunk = (LevelChunk) this.chunk;
|
||||
ClientChunkCache clientChunkCache = ((ClientLevel) levelChunk.getLevel()).getChunkSource();
|
||||
this.isMcClientLightingCorrect = clientChunkCache.getChunkForLighting(this.chunk.getPos().x, this.chunk.getPos().z) != null &&
|
||||
#if MC_VER <= MC_1_17_1
|
||||
|
||||
+18
-15
@@ -145,9 +145,9 @@ public class ClassicConfigGUI
|
||||
case 0:
|
||||
((EntryInfo) info.guiValue).error = null; break;
|
||||
case -1:
|
||||
((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cMinimum length is " + ((ConfigEntry) info).getMin())); break;
|
||||
((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cMinimum length is " + ((ConfigEntry<?>) info).getMin())); break;
|
||||
case 1:
|
||||
((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cMaximum length is " + ((ConfigEntry) info).getMax())); break;
|
||||
((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cMaximum length is " + ((ConfigEntry<?>) info).getMax())); break;
|
||||
case 2:
|
||||
((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cValue is invalid")); break;
|
||||
}
|
||||
@@ -158,19 +158,22 @@ public class ClassicConfigGUI
|
||||
// button.active = entries.stream().allMatch(e -> e.inLimits);
|
||||
|
||||
|
||||
if (((ConfigEntry) info).isValid(value) == 0 && info.getType() != List.class)
|
||||
if (info.getType() == String.class
|
||||
|| info.getType() == List.class)
|
||||
{
|
||||
((ConfigEntry) info).uiSetWithoutSaving(stringValue);
|
||||
}
|
||||
else if (((ConfigEntry) info).isValid(value) == 0)
|
||||
{
|
||||
if (!cast)
|
||||
{
|
||||
((ConfigEntry) info).uiSetWithoutSaving(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
((ConfigEntry) info).uiSetWithoutSaving(value.intValue());
|
||||
}
|
||||
}
|
||||
// else if (((ConfigEntry) info).isValidMemoryAddress() == 0)
|
||||
// {
|
||||
// if (((List<String>) info.get()).size() == ((EntryInfo) info.guiValue).index)
|
||||
// info.uiSet(((List<String>) info.get()).add(""));
|
||||
// info.uiSet(((List<String>) info.get()).set(((EntryInfo) info.guiValue).index, Arrays.stream(((EntryInfo) info.guiValue).tempValue.replace("[", "").replace("]", "").split(", ")).collect(Collectors.toList()).get(0)));
|
||||
// }
|
||||
|
||||
return true;
|
||||
};
|
||||
@@ -232,7 +235,7 @@ public class ClassicConfigGUI
|
||||
ConfigBase.INSTANCE.configFileINSTANCE.saveToFile();
|
||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
||||
|
||||
CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
|
||||
CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach(Runnable::run);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -316,7 +319,7 @@ public class ClassicConfigGUI
|
||||
|
||||
|
||||
|
||||
CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
|
||||
CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach(Runnable::run);
|
||||
|
||||
}
|
||||
|
||||
@@ -329,7 +332,7 @@ public class ClassicConfigGUI
|
||||
if (ConfigEntry.class.isAssignableFrom(info.getClass()))
|
||||
{
|
||||
Button.OnPress btnAction = button -> {
|
||||
((ConfigEntry) info).uiSetWithoutSaving(((ConfigEntry) info).getDefaultValue());
|
||||
((ConfigEntry) info).uiSetWithoutSaving(((ConfigEntry<?>) info).getDefaultValue());
|
||||
((EntryInfo) info.guiValue).index = 0;
|
||||
this.reload = true;
|
||||
Objects.requireNonNull(minecraft).setScreen(this);
|
||||
@@ -373,9 +376,7 @@ public class ClassicConfigGUI
|
||||
}
|
||||
if (ConfigUIButton.class.isAssignableFrom(info.getClass()))
|
||||
{
|
||||
Button widget = MakeBtn(name, this.width / 2 - 100, this.height - 28, 100 * 2, 20, (button -> {
|
||||
((ConfigUIButton) info).runAction();
|
||||
}));
|
||||
Button widget = MakeBtn(name, this.width / 2 - 100, this.height - 28, 100 * 2, 20, (button -> ((ConfigUIButton) info).runAction()));
|
||||
this.list.addButton(widget, null, null, null);
|
||||
return;
|
||||
}
|
||||
@@ -443,7 +444,9 @@ public class ClassicConfigGUI
|
||||
String key = translationPrefix + (newInfo.category.isEmpty() ? "" : newInfo.category + ".") + newInfo.getName() + ".@tooltip";
|
||||
|
||||
if (((EntryInfo) newInfo.guiValue).error != null && text.equals(name))
|
||||
{
|
||||
DhRenderTooltip(matrices, font, ((EntryInfo) newInfo.guiValue).error.getValue(), mouseX, mouseY);
|
||||
}
|
||||
else if (I18n.exists(key) && (text != null && text.equals(name)))
|
||||
{
|
||||
List<Component> list = new ArrayList<>();
|
||||
|
||||
+9
-10
@@ -25,19 +25,18 @@ public class GetConfigScreen
|
||||
// This shouldn't be here, but I need a way to test it after Minecraft inits its assets
|
||||
//System.out.println(ConfigBase.INSTANCE.generateLang(false, true));
|
||||
|
||||
switch (useScreen)
|
||||
return switch (useScreen)
|
||||
{
|
||||
case Classic:
|
||||
return ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client");
|
||||
case OpenGL:
|
||||
case Classic -> ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client");
|
||||
case OpenGL ->
|
||||
{
|
||||
MinecraftScreen.getScreen(parent, new OpenGLConfigScreen(), ModInfo.ID + ".title");
|
||||
return null;
|
||||
yield null;
|
||||
}
|
||||
// case JavaFX -> MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new JavaScreenHandlerScreen.ExampleScreen()), ModInfo.ID + ".title");
|
||||
case JavaFX:
|
||||
return MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new ConfigScreen()), ModInfo.ID + ".title");
|
||||
default:
|
||||
throw new IllegalArgumentException("No config screen implementation defined for ["+useScreen+"].");
|
||||
}
|
||||
case JavaFX -> MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new ConfigScreen()), ModInfo.ID + ".title");
|
||||
default -> throw new IllegalArgumentException("No config screen implementation defined for [" + useScreen + "].");
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
+10
-6
@@ -101,11 +101,17 @@ public class ChangelogScreen extends DhScreen
|
||||
this.changelog.add("");
|
||||
this.changelog.add("");
|
||||
|
||||
String changelog = ModrinthGetter.changeLogs.get(versionID);
|
||||
if (changelog == null)
|
||||
{
|
||||
// in case something goes wrong this will prevent null pointers
|
||||
changelog = "";
|
||||
}
|
||||
|
||||
// Get the release changelog and split it by the new lines
|
||||
String[] unwrappedChangelog = // Arrays.asList could be used if a list object is desired here vs List.of which is only available for Java 9+
|
||||
new MarkdownFormatter.MinecraftFormat().convertTo( // This formats markdown to minecraft's "§" characters
|
||||
ModrinthGetter.changeLogs.get(versionID)
|
||||
).split("\\n");
|
||||
// This formats markdown to minecraft's "§" charactersnew MarkdownFormatter.MinecraftFormat().convertTo(
|
||||
new MarkdownFormatter.MinecraftFormat().convertTo(changelog).split("\\n");
|
||||
// Makes the words wrap around to not go off the screen
|
||||
for (String str : unwrappedChangelog)
|
||||
{
|
||||
@@ -128,9 +134,7 @@ public class ChangelogScreen extends DhScreen
|
||||
|
||||
|
||||
this.addBtn( // Close
|
||||
MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> {
|
||||
this.onClose();
|
||||
})
|
||||
MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> this.onClose())
|
||||
);
|
||||
|
||||
|
||||
|
||||
+1
-3
@@ -135,9 +135,7 @@ public class UpdateModScreen extends DhScreen
|
||||
})
|
||||
);
|
||||
this.addBtn( // Later (not now)
|
||||
MakeBtn(Translatable(ModInfo.ID + ".updater.later"), this.width / 2 + 2, this.height / 2 + 70, 100, 20, (btn) -> {
|
||||
this.onClose();
|
||||
})
|
||||
MakeBtn(Translatable(ModInfo.ID + ".updater.later"), this.width / 2 + 2, this.height / 2 + 70, 100, 20, (btn) -> this.onClose())
|
||||
);
|
||||
this.addBtn( // Never
|
||||
MakeBtn(Translatable(ModInfo.ID + ".updater.never"), this.width / 2 - 102, this.height / 2 + 70, 100, 20, (btn) -> {
|
||||
|
||||
+71
-82
@@ -31,6 +31,7 @@ import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ServerLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
||||
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
@@ -43,6 +44,7 @@ import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -59,16 +61,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
* A singleton that wraps the Minecraft object.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 3-5-2022
|
||||
*/
|
||||
//@Environment(EnvType.CLIENT)
|
||||
public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecraftSharedWrapper
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger(MethodHandles.lookup().lookupClass().getSimpleName());
|
||||
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
||||
|
||||
public static final MinecraftClientWrapper INSTANCE = new MinecraftClientWrapper();
|
||||
|
||||
public final Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
|
||||
/**
|
||||
* The lightmap for the current:
|
||||
@@ -99,10 +100,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
* This doesn't affect OpenGL objects in any way.
|
||||
*/
|
||||
@Override
|
||||
public void clearFrameObjectCache()
|
||||
{
|
||||
lightMap = null;
|
||||
}
|
||||
public void clearFrameObjectCache() { this.lightMap = null; }
|
||||
|
||||
|
||||
|
||||
@@ -118,10 +116,10 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
{
|
||||
default:
|
||||
case AUTO:
|
||||
if (this.mc.level != null)
|
||||
if (MINECRAFT.level != null)
|
||||
{
|
||||
Direction mcDir = McObjectConverter.Convert(lodDirection);
|
||||
return this.mc.level.getShade(mcDir, true);
|
||||
return MINECRAFT.level.getShade(mcDir, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -129,20 +127,12 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
}
|
||||
|
||||
case ENABLED:
|
||||
switch (lodDirection)
|
||||
{
|
||||
case DOWN:
|
||||
return 0.5F;
|
||||
default:
|
||||
case UP:
|
||||
return 1.0F;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
return 0.8F;
|
||||
case WEST:
|
||||
case EAST:
|
||||
return 0.6F;
|
||||
}
|
||||
return switch (lodDirection) {
|
||||
case DOWN -> 0.5F;
|
||||
default -> 1.0F;
|
||||
case NORTH, SOUTH -> 0.8F;
|
||||
case WEST, EAST -> 0.6F;
|
||||
};
|
||||
|
||||
case DISABLED:
|
||||
return 1.0F;
|
||||
@@ -150,47 +140,63 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSinglePlayerServer() { return mc.hasSingleplayerServer(); }
|
||||
public boolean hasSinglePlayerServer() { return MINECRAFT.hasSingleplayerServer(); }
|
||||
@Override
|
||||
public boolean clientConnectedToDedicatedServer() { return mc.getCurrentServer() != null && !this.hasSinglePlayerServer(); }
|
||||
public boolean clientConnectedToDedicatedServer() { return MINECRAFT.getCurrentServer() != null && !this.hasSinglePlayerServer(); }
|
||||
@Override
|
||||
public boolean connectedToReplay() { return !MINECRAFT.hasSingleplayerServer() && MINECRAFT.getCurrentServer() == null; }
|
||||
|
||||
@Override
|
||||
public String getCurrentServerName() { return mc.getCurrentServer().name; }
|
||||
public String getCurrentServerName()
|
||||
{
|
||||
if (this.connectedToReplay())
|
||||
{
|
||||
return ClientOnlySaveStructure.REPLAY_SERVER_FOLDER_NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerData server = MINECRAFT.getCurrentServer();
|
||||
return (server != null) ? server.name : "NULL";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentServerIp() { return mc.getCurrentServer().ip; }
|
||||
public String getCurrentServerIp()
|
||||
{
|
||||
if (this.connectedToReplay())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerData server = MINECRAFT.getCurrentServer();
|
||||
return (server != null) ? server.ip : "NA";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentServerVersion()
|
||||
{
|
||||
return mc.getCurrentServer().version.getString();
|
||||
ServerData server = MINECRAFT.getCurrentServer();
|
||||
return (server != null) ? server.version.getString() : "UNKOWN";
|
||||
}
|
||||
|
||||
//=============//
|
||||
// Simple gets //
|
||||
//=============//
|
||||
|
||||
public LocalPlayer getPlayer()
|
||||
{
|
||||
return mc.player;
|
||||
}
|
||||
public LocalPlayer getPlayer() { return MINECRAFT.player; }
|
||||
|
||||
@Override
|
||||
public boolean playerExists()
|
||||
{
|
||||
return mc.player != null;
|
||||
}
|
||||
public boolean playerExists() { return MINECRAFT.player != null; }
|
||||
|
||||
@Override
|
||||
public UUID getPlayerUUID()
|
||||
{
|
||||
return getPlayer().getUUID();
|
||||
}
|
||||
public UUID getPlayerUUID() { return this.getPlayer().getUUID(); }
|
||||
|
||||
@Override
|
||||
public DhBlockPos getPlayerBlockPos()
|
||||
{
|
||||
BlockPos playerPos = getPlayer().blockPosition();
|
||||
BlockPos playerPos = this.getPlayer().blockPosition();
|
||||
return new DhBlockPos(playerPos.getX(), playerPos.getY(), playerPos.getZ());
|
||||
}
|
||||
|
||||
@@ -198,55 +204,47 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
public DhChunkPos getPlayerChunkPos()
|
||||
{
|
||||
#if MC_VER < MC_1_17_1
|
||||
ChunkPos playerPos = new ChunkPos(getPlayer().blockPosition());
|
||||
ChunkPos playerPos = new ChunkPos(this.getPlayer().blockPosition());
|
||||
#else
|
||||
ChunkPos playerPos = getPlayer().chunkPosition();
|
||||
ChunkPos playerPos = this.getPlayer().chunkPosition();
|
||||
#endif
|
||||
return new DhChunkPos(playerPos.x, playerPos.z);
|
||||
}
|
||||
|
||||
public ModelManager getModelManager()
|
||||
{
|
||||
return mc.getModelManager();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IClientLevelWrapper getWrappedClientLevel()
|
||||
{
|
||||
if (this.mc.level == null)
|
||||
if (MINECRAFT.level == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return ClientLevelWrapper.getWrapperIgnoringOverride(this.mc.level);
|
||||
}
|
||||
|
||||
/** Please move over to getInstallationDirectory() */
|
||||
@Deprecated
|
||||
@Override
|
||||
public File getGameDirectory()
|
||||
{
|
||||
return getInstallationDirectory();
|
||||
return ClientLevelWrapper.getWrapperIgnoringOverride(MINECRAFT.level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProfilerWrapper getProfiler()
|
||||
{
|
||||
if (profilerWrapper == null)
|
||||
profilerWrapper = new ProfilerWrapper(mc.getProfiler());
|
||||
else if (mc.getProfiler() != profilerWrapper.profiler)
|
||||
profilerWrapper.profiler = mc.getProfiler();
|
||||
return profilerWrapper;
|
||||
if (this.profilerWrapper == null)
|
||||
{
|
||||
this.profilerWrapper = new ProfilerWrapper(MINECRAFT.getProfiler());
|
||||
}
|
||||
else if (MINECRAFT.getProfiler() != this.profilerWrapper.profiler)
|
||||
{
|
||||
this.profilerWrapper.profiler = MINECRAFT.getProfiler();
|
||||
}
|
||||
|
||||
return this.profilerWrapper;
|
||||
}
|
||||
|
||||
/** Returns all worlds available to the server */
|
||||
@Override
|
||||
public ArrayList<ILevelWrapper> getAllServerWorlds()
|
||||
{
|
||||
ArrayList<ILevelWrapper> worlds = new ArrayList<ILevelWrapper>();
|
||||
ArrayList<ILevelWrapper> worlds = new ArrayList<>();
|
||||
|
||||
Iterable<ServerLevel> serverWorlds = mc.getSingleplayerServer().getAllLevels();
|
||||
Iterable<ServerLevel> serverWorlds = MINECRAFT.getSingleplayerServer().getAllLevels();
|
||||
for (ServerLevel world : serverWorlds)
|
||||
{
|
||||
worlds.add(ServerLevelWrapper.getWrapper(world));
|
||||
@@ -260,12 +258,12 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
@Override
|
||||
public void sendChatMessage(String string)
|
||||
{
|
||||
LocalPlayer p = getPlayer();
|
||||
if (p == null) return;
|
||||
LocalPlayer player = this.getPlayer();
|
||||
if (player == null) return;
|
||||
#if MC_VER < MC_1_19_2
|
||||
p.sendMessage(new TextComponent(string), getPlayer().getUUID());
|
||||
player.sendMessage(new TextComponent(string), getPlayer().getUUID());
|
||||
#else
|
||||
p.sendSystemMessage(net.minecraft.network.chat.Component.translatable(string));
|
||||
player.sendSystemMessage(net.minecraft.network.chat.Component.translatable(string));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -290,24 +288,15 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOptionsObject()
|
||||
{
|
||||
return mc.options;
|
||||
}
|
||||
public Object getOptionsObject() { return MINECRAFT.options; }
|
||||
|
||||
@Override
|
||||
public boolean isDedicatedServer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public boolean isDedicatedServer() { return false; }
|
||||
|
||||
@Override
|
||||
public File getInstallationDirectory()
|
||||
{
|
||||
return mc.gameDirectory;
|
||||
}
|
||||
public File getInstallationDirectory() { return MINECRAFT.gameDirectory; }
|
||||
|
||||
@Override
|
||||
public void executeOnRenderThread(Runnable runnable) { this.mc.execute(runnable); }
|
||||
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.execute(runnable); }
|
||||
|
||||
}
|
||||
|
||||
+5
-8
@@ -21,9 +21,7 @@ package com.seibel.distanthorizons.common.wrappers.minecraft;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -38,10 +36,10 @@ import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.render.DhApiRenderProxy;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
|
||||
#if MC_VER < MC_1_19_4
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
#else
|
||||
import org.joml.Matrix4f;
|
||||
@@ -55,9 +53,9 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOpt
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Vec3d;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Vec3f;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
||||
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
@@ -81,7 +79,6 @@ import net.minecraft.world.level.material.FogType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
|
||||
/**
|
||||
@@ -415,7 +412,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
// so this will have to do for now
|
||||
IDimensionTypeWrapper dimensionType = level.getDimensionType();
|
||||
|
||||
LightMapWrapper wrapper = this.lightmapByDimensionType.compute(dimensionType, (dimType, oldWrapper) -> new LightMapWrapper());
|
||||
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
|
||||
wrapper.uploadLightmap(lightPixels);
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -36,14 +36,6 @@ public class LightMapWrapper implements ILightMapWrapper
|
||||
|
||||
public LightMapWrapper() { }
|
||||
|
||||
private void createLightmap(NativeImage image)
|
||||
{
|
||||
this.textureId = GL32.glGenTextures();
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, this.textureId);
|
||||
GL32.glTexImage2D(GL32.GL_TEXTURE_2D, 0, image.format().glFormat(), image.getWidth(), image.getHeight(),
|
||||
0, image.format().glFormat(), GL32.GL_UNSIGNED_BYTE, (ByteBuffer) null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=========//
|
||||
@@ -53,14 +45,25 @@ public class LightMapWrapper implements ILightMapWrapper
|
||||
public void uploadLightmap(NativeImage image)
|
||||
{
|
||||
int currentBind = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, this.textureId);
|
||||
if (this.textureId == 0)
|
||||
{
|
||||
this.createLightmap(image);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, this.textureId);
|
||||
}
|
||||
image.upload(0, 0, 0, false);
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, currentBind);
|
||||
}
|
||||
private void createLightmap(NativeImage image)
|
||||
{
|
||||
this.textureId = GL32.glGenTextures();
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, this.textureId);
|
||||
GL32.glTexImage2D(GL32.GL_TEXTURE_2D, 0, image.format().glFormat(), image.getWidth(), image.getHeight(),
|
||||
0, image.format().glFormat(), GL32.GL_UNSIGNED_BYTE, (ByteBuffer) null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void bind()
|
||||
|
||||
+41
-8
@@ -1,7 +1,7 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.world;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
||||
import com.seibel.distanthorizons.api.interfaces.world.IDhApiDimensionTypeWrapper;
|
||||
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegister;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
||||
@@ -9,7 +9,7 @@ import com.seibel.distanthorizons.common.wrappers.block.cache.ClientBlockDetailM
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager;
|
||||
import com.seibel.distanthorizons.core.level.*;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
@@ -19,10 +19,9 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkSource;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -41,14 +40,18 @@ import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger(ClientLevelWrapper.class.getSimpleName());
|
||||
private static final ConcurrentHashMap<ClientLevel, ClientLevelWrapper> LEVEL_WRAPPER_BY_CLIENT_LEVEL = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<ClientLevel, ClientLevelWrapper> LEVEL_WRAPPER_BY_CLIENT_LEVEL = new ConcurrentHashMap<>(); // TODO can leak
|
||||
private static final IKeyedClientLevelManager KEYED_CLIENT_LEVEL_MANAGER = SingletonInjector.INSTANCE.get(IKeyedClientLevelManager.class);
|
||||
|
||||
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
||||
|
||||
private final ClientLevel level;
|
||||
private final ClientBlockDetailMap blockMap = new ClientBlockDetailMap(this);
|
||||
|
||||
private BlockStateWrapper dirtBlockWrapper;
|
||||
private BiomeWrapper plainsBiomeWrapper;
|
||||
@Deprecated // TODO circular references are bad
|
||||
private IDhLevel parentDhLevel;
|
||||
|
||||
|
||||
|
||||
@@ -88,7 +91,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
{
|
||||
try
|
||||
{
|
||||
Iterable<ServerLevel> serverLevels = MinecraftClientWrapper.INSTANCE.mc.getSingleplayerServer().getAllLevels();
|
||||
Iterable<ServerLevel> serverLevels = MINECRAFT.getSingleplayerServer().getAllLevels();
|
||||
|
||||
// attempt to find the server level with the same dimension type
|
||||
// TODO this assumes only one level per dimension type, the SubDimensionLevelMatcher will need to be added for supporting multiple levels per dimension
|
||||
@@ -180,7 +183,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
public boolean hasSkyLight() { return this.level.dimensionType().hasSkyLight(); }
|
||||
|
||||
@Override
|
||||
public int getHeight() { return this.level.getHeight(); }
|
||||
public int getMaxHeight() { return this.level.getHeight(); }
|
||||
|
||||
@Override
|
||||
public int getMinHeight()
|
||||
@@ -229,7 +232,37 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
||||
public ClientLevel getWrappedMcObject() { return this.level; }
|
||||
|
||||
@Override
|
||||
public void onUnload() { LEVEL_WRAPPER_BY_CLIENT_LEVEL.remove(this.level); }
|
||||
public void onUnload()
|
||||
{
|
||||
LEVEL_WRAPPER_BY_CLIENT_LEVEL.remove(this.level);
|
||||
this.parentDhLevel = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===================//
|
||||
// generic rendering //
|
||||
//===================//
|
||||
|
||||
@Override
|
||||
public void setParentLevel(IDhLevel parentLevel) { this.parentDhLevel = parentLevel; }
|
||||
|
||||
@Override
|
||||
public IDhApiCustomRenderRegister getRenderRegister()
|
||||
{
|
||||
if (this.parentDhLevel == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.parentDhLevel.getGenericRenderer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// base overrides //
|
||||
//================//
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
|
||||
+28
-22
@@ -23,12 +23,14 @@ import java.io.File;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
||||
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegister;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.block.cache.ServerBlockDetailMap;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
@@ -59,8 +61,9 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
private static final ConcurrentHashMap<ServerLevel, ServerLevelWrapper> LEVEL_WRAPPER_BY_SERVER_LEVEL = new ConcurrentHashMap<>();
|
||||
|
||||
final ServerLevel level;
|
||||
ServerBlockDetailMap blockMap = new ServerBlockDetailMap(this);
|
||||
private final ServerLevel level;
|
||||
@Deprecated // TODO circular references are bad
|
||||
private IDhLevel parentDhLevel;
|
||||
|
||||
|
||||
|
||||
@@ -81,19 +84,6 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
// methods //
|
||||
//=========//
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IClientLevelWrapper tryGetClientLevelWrapper()
|
||||
{
|
||||
MinecraftClientWrapper client = MinecraftClientWrapper.INSTANCE;
|
||||
if (client.mc.level == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return ClientLevelWrapper.getWrapper(client.mc.level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getSaveFolder()
|
||||
{
|
||||
@@ -127,7 +117,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
public int getMaxHeight()
|
||||
{
|
||||
return level.getHeight();
|
||||
}
|
||||
@@ -141,6 +131,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
return level.getMinBuildHeight();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkWrapper tryGetChunk(DhChunkPos pos)
|
||||
{
|
||||
@@ -171,18 +162,33 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerLevel getWrappedMcObject()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
public ServerLevel getWrappedMcObject() { return this.level; }
|
||||
|
||||
@Override
|
||||
public void onUnload() { LEVEL_WRAPPER_BY_SERVER_LEVEL.remove(this.level); }
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
public void setParentLevel(IDhLevel parentLevel) { this.parentDhLevel = parentLevel; }
|
||||
|
||||
@Override
|
||||
public IDhApiCustomRenderRegister getRenderRegister()
|
||||
{
|
||||
return "Wrapped{" + level.toString() + "@" + getDimensionType().getDimensionName() + "}";
|
||||
if (this.parentDhLevel == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.parentDhLevel.getGenericRenderer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// base overrides //
|
||||
//================//
|
||||
|
||||
@Override
|
||||
public String toString() { return "Wrapped{" + this.level.toString() + "@" + this.getDimensionType().getDimensionName() + "}"; }
|
||||
|
||||
}
|
||||
|
||||
+16
-15
@@ -147,7 +147,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
if (index == -1) continue;
|
||||
times.get(index).add(e.timeNs);
|
||||
}
|
||||
times.get(0).add(event.getTotalTimeNs());
|
||||
times.getFirst().add(event.getTotalTimeNs());
|
||||
}
|
||||
|
||||
public String toString()
|
||||
@@ -346,8 +346,11 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
}
|
||||
else if (event.hasTimeout(Config.Client.Advanced.WorldGenerator.worldGenerationTimeoutLengthInSeconds.get(), TimeUnit.SECONDS))
|
||||
{
|
||||
EVENT_LOGGER.error("Batching World Generator: " + event + " timed out and terminated! Please lower your CPU load.");
|
||||
EVENT_LOGGER.info("Dump PrefEvent: " + event.timer);
|
||||
EVENT_LOGGER.warn(
|
||||
"Batching World Generator: [" + event + "] timed out and terminated after ["+Config.Client.Advanced.WorldGenerator.worldGenerationTimeoutLengthInSeconds.get()+"] seconds. " +
|
||||
"\nYour computer might be overloaded or your world gen mods might be causing world gen to take longer than expected. " +
|
||||
"\nEither increase DH's world gen timeout or reduce your computer's CPU load.");
|
||||
EVENT_LOGGER.debug("Dump PrefEvent: " + event.timer);
|
||||
try
|
||||
{
|
||||
if (!event.terminate())
|
||||
@@ -416,12 +419,15 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
CompoundTag chunkData = this.getChunkNbtData(chunkPos);
|
||||
newChunk = this.loadOrMakeChunk(chunkPos, chunkData);
|
||||
|
||||
// get chunk lighting
|
||||
ChunkLoader.CombinedChunkLightStorage combinedLights = ChunkLoader.readLight(newChunk, chunkData);
|
||||
if (combinedLights != null)
|
||||
if (Config.Client.Advanced.LodBuilding.pullLightingForPregeneratedChunks.get())
|
||||
{
|
||||
chunkSkyLightingByDhPos.put(dhChunkPos, combinedLights.skyLightStorage);
|
||||
chunkBlockLightingByDhPos.put(dhChunkPos, combinedLights.blockLightStorage);
|
||||
// attempt to get chunk lighting
|
||||
ChunkLoader.CombinedChunkLightStorage combinedLights = ChunkLoader.readLight(newChunk, chunkData);
|
||||
if (combinedLights != null)
|
||||
{
|
||||
chunkSkyLightingByDhPos.put(dhChunkPos, combinedLights.skyLightStorage);
|
||||
chunkBlockLightingByDhPos.put(dhChunkPos, combinedLights.blockLightStorage);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RuntimeException loadChunkError)
|
||||
@@ -471,7 +477,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
ChunkWrapper chunkWrapper = new ChunkWrapper(chunk, region, this.serverlevel.getLevelWrapper());
|
||||
chunkWrapperList.set(x, z, chunkWrapper);
|
||||
|
||||
// try getting the chunk lighting
|
||||
// try setting the wrapper's lighting
|
||||
if (chunkBlockLightingByDhPos.containsKey(chunkWrapper.getChunkPos()))
|
||||
{
|
||||
chunkWrapper.setBlockLightStorage(chunkBlockLightingByDhPos.get(chunkWrapper.getChunkPos()));
|
||||
@@ -479,10 +485,6 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
chunkWrapper.setUseDhLighting(true);
|
||||
chunkWrapper.setIsDhLightCorrect(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int k = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -651,9 +653,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
|
||||
chunksToGenerate.forEach((chunkWrapper) ->
|
||||
{
|
||||
ChunkAccess chunk = chunkWrapper.getChunk();
|
||||
if (chunk instanceof ProtoChunk)
|
||||
if (chunk instanceof ProtoChunk protoChunk)
|
||||
{
|
||||
ProtoChunk protoChunk = ((ProtoChunk) chunk);
|
||||
|
||||
protoChunk.setLightEngine(region.getLightEngine());
|
||||
}
|
||||
|
||||
+14
-11
@@ -252,8 +252,8 @@ public class ChunkLoader
|
||||
biomes.asHolderIdMap(), biomes.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getHolderOrThrow(Biomes.PLAINS));
|
||||
#endif
|
||||
#endif
|
||||
int i = #if MC_VER < MC_1_17_1 16; #else level.getSectionsCount(); #endif
|
||||
LevelChunkSection[] chunkSections = new LevelChunkSection[i];
|
||||
int sectionYIndex = #if MC_VER < MC_1_17_1 16; #else level.getSectionsCount(); #endif
|
||||
LevelChunkSection[] chunkSections = new LevelChunkSection[sectionYIndex];
|
||||
|
||||
boolean isLightOn = chunkData.getBoolean("isLightOn");
|
||||
boolean hasSkyLight = level.dimensionType().hasSkyLight();
|
||||
@@ -288,13 +288,13 @@ public class ChunkLoader
|
||||
#endif
|
||||
|
||||
blockStateContainer = tagSection.contains("block_states", 10)
|
||||
? BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, tagSection.getCompound("block_states")).promotePartial(string -> logErrors(chunkPos, sectionYPos, string))
|
||||
? BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, tagSection.getCompound("block_states")).promotePartial(string -> logBlockDeserializationWarning(chunkPos, sectionYPos, string))
|
||||
#if MC_VER < MC_1_20_6
|
||||
.getOrThrow(false, LOGGER::error)
|
||||
#else
|
||||
.getOrThrow((message) -> (RuntimeException) LOGGER.errorAndThrow(message, null))
|
||||
#endif
|
||||
: new PalettedContainer<BlockState>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES);
|
||||
: new PalettedContainer<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES);
|
||||
|
||||
#if MC_VER < MC_1_18_2
|
||||
biomeContainer = tagSection.contains("biomes", 10)
|
||||
@@ -303,13 +303,13 @@ public class ChunkLoader
|
||||
#else
|
||||
|
||||
biomeContainer = tagSection.contains("biomes", 10)
|
||||
? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logErrors(chunkPos, i, (String) string))
|
||||
? biomeCodec.parse(NbtOps.INSTANCE, tagSection.getCompound("biomes")).promotePartial(string -> logBiomeDeserializationWarning(chunkPos, sectionYIndex, (String) string))
|
||||
#if MC_VER < MC_1_20_6
|
||||
.getOrThrow(false, LOGGER::error)
|
||||
#else
|
||||
.getOrThrow((message) -> (RuntimeException) LOGGER.errorAndThrow(message, null))
|
||||
#endif
|
||||
: new PalettedContainer<Holder<Biome>>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
|
||||
: new PalettedContainer<>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
|
||||
#endif
|
||||
|
||||
#if MC_VER < MC_1_20_1
|
||||
@@ -434,7 +434,7 @@ public class ChunkLoader
|
||||
for (int sectionIndex = 0; sectionIndex < chunkSectionListTag.size(); sectionIndex++)
|
||||
{
|
||||
Tag chunkSectionTag = chunkSectionListTag.get(sectionIndex);
|
||||
if (!(chunkSectionTag instanceof CompoundTag))
|
||||
if (!(chunkSectionTag instanceof CompoundTag chunkSectionCompoundTag))
|
||||
{
|
||||
if (!lightingSectionErrorLogged)
|
||||
{
|
||||
@@ -443,10 +443,9 @@ public class ChunkLoader
|
||||
}
|
||||
return null;
|
||||
}
|
||||
CompoundTag chunkSectionCompoundTag = (CompoundTag) chunkSectionTag;
|
||||
|
||||
|
||||
// if null all lights = 0
|
||||
// if null all lights = 0
|
||||
byte[] blockLightNibbleArray = chunkSectionCompoundTag.getByteArray("BlockLight");
|
||||
byte[] skyLightNibbleArray = chunkSectionCompoundTag.getByteArray("SkyLight");
|
||||
|
||||
@@ -495,9 +494,13 @@ public class ChunkLoader
|
||||
}
|
||||
}
|
||||
|
||||
private static void logErrors(ChunkPos chunkPos, int i, String string)
|
||||
private static void logBlockDeserializationWarning(ChunkPos chunkPos, int sectionYIndex, String message)
|
||||
{
|
||||
LOGGER.error("Distant Horizons: Recoverable errors when loading section [" + chunkPos.x + ", " + i + ", " + chunkPos.z + "]: " + string);
|
||||
LOGGER.warn("Unable to deserialize blocks for chunk section [" + chunkPos.x + ", " + sectionYIndex + ", " + chunkPos.z + "], error: ["+message+"]. This can probably be ignored, although if your world looks wrong, optimizing it via the single player menu then deleting your DH database(s) should fix the problem.");
|
||||
}
|
||||
private static void logBiomeDeserializationWarning(ChunkPos chunkPos, int sectionYIndex, String message)
|
||||
{
|
||||
LOGGER.warn("Unable to deserialize biomes for chunk section [" + chunkPos.x + ", " + sectionYIndex + ", " + chunkPos.z + "], error: ["+message+"]. This can probably be ignored, although if your world looks wrong, optimizing it via the single player menu then deleting your DH database(s) should fix the problem.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -84,7 +84,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion
|
||||
|
||||
private final ChunkPos firstPos;
|
||||
private final List<ChunkAccess> cache;
|
||||
private final Long2ObjectOpenHashMap<ChunkAccess> chunkMap = new Long2ObjectOpenHashMap<ChunkAccess>();
|
||||
private final Long2ObjectOpenHashMap<ChunkAccess> chunkMap = new Long2ObjectOpenHashMap<>();
|
||||
|
||||
/**
|
||||
* Present to reduce the chance that we accidentally break underlying MC code that isn't thread safe,
|
||||
@@ -142,7 +142,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion
|
||||
centerChunk);
|
||||
|
||||
#endif
|
||||
this.firstPos = chunkList.get(0).getPos();
|
||||
this.firstPos = chunkList.getFirst().getPos();
|
||||
this.generator = generator;
|
||||
this.lightEngine = lightEngine;
|
||||
this.writeRadius = writeRadius;
|
||||
|
||||
+1
-3
@@ -231,11 +231,9 @@ public class WorldGenStructFeatManager extends #if MC_VER < MC_1_19_2 StructureF
|
||||
Map<Structure, LongSet> map = chunk.getAllReferences();
|
||||
|
||||
ImmutableList.Builder<StructureStart> builder = ImmutableList.builder();
|
||||
Iterator<Map.Entry<Structure, LongSet>> var5 = map.entrySet().iterator();
|
||||
|
||||
while (var5.hasNext())
|
||||
for (Map.Entry<Structure, LongSet> entry : map.entrySet())
|
||||
{
|
||||
Map.Entry<Structure, LongSet> entry = var5.next();
|
||||
Structure configuredStructureFeature = entry.getKey();
|
||||
if (predicate.test(configuredStructureFeature))
|
||||
{
|
||||
|
||||
+6
-1
@@ -61,7 +61,12 @@ public final class StepBiomes
|
||||
for (ChunkWrapper chunkWrapper : chunkWrappers)
|
||||
{
|
||||
ChunkAccess chunk = chunkWrapper.getChunk();
|
||||
if (!chunkWrapper.getStatus().isOrAfter(STATUS))
|
||||
if (chunkWrapper.getStatus().isOrAfter(STATUS))
|
||||
{
|
||||
// this chunk has already generated this step
|
||||
continue;
|
||||
}
|
||||
else if (chunk instanceof ProtoChunk)
|
||||
{
|
||||
#if MC_VER < MC_1_21
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
|
||||
+6
-2
@@ -59,8 +59,12 @@ public final class StepFeatures
|
||||
for (ChunkWrapper chunkWrapper : chunkWrappers)
|
||||
{
|
||||
ChunkAccess chunk = chunkWrapper.getChunk();
|
||||
if (!chunkWrapper.getStatus().isOrAfter(STATUS)
|
||||
&& chunk instanceof ProtoChunk)
|
||||
if (chunkWrapper.getStatus().isOrAfter(STATUS))
|
||||
{
|
||||
// this chunk has already generated this step
|
||||
continue;
|
||||
}
|
||||
else if (chunk instanceof ProtoChunk)
|
||||
{
|
||||
#if MC_VER < MC_1_21
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
|
||||
+7
-2
@@ -54,12 +54,17 @@ public final class StepStructureReference
|
||||
List<ChunkWrapper> chunkWrappers)
|
||||
{
|
||||
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<ChunkAccess>();
|
||||
ArrayList<ChunkAccess> chunksToDo = new ArrayList<>();
|
||||
|
||||
for (ChunkWrapper chunkWrapper : chunkWrappers)
|
||||
{
|
||||
ChunkAccess chunk = chunkWrapper.getChunk();
|
||||
if (!chunkWrapper.getStatus().isOrAfter(STATUS))
|
||||
if (chunkWrapper.getStatus().isOrAfter(STATUS))
|
||||
{
|
||||
// this chunk has already generated this step
|
||||
continue;
|
||||
}
|
||||
else if (chunk instanceof ProtoChunk)
|
||||
{
|
||||
#if MC_VER < MC_1_21
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
|
||||
+9
-4
@@ -76,7 +76,12 @@ public final class StepStructureStart
|
||||
for (ChunkWrapper chunkWrapper : chunkWrappers)
|
||||
{
|
||||
ChunkAccess chunk = chunkWrapper.getChunk();
|
||||
if (!chunkWrapper.getStatus().isOrAfter(STATUS))
|
||||
if (chunkWrapper.getStatus().isOrAfter(STATUS))
|
||||
{
|
||||
// this chunk has already generated this step
|
||||
continue;
|
||||
}
|
||||
else if (chunk instanceof ProtoChunk)
|
||||
{
|
||||
#if MC_VER < MC_1_21
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
@@ -88,12 +93,12 @@ public final class StepStructureStart
|
||||
}
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
if (environment.params.worldGenSettings.generateFeatures())
|
||||
if (this.environment.params.worldGenSettings.generateFeatures())
|
||||
{
|
||||
#elif MC_VER < MC_1_19_4
|
||||
if (environment.params.worldGenSettings.generateStructures()) {
|
||||
if (this.environment.params.worldGenSettings.generateStructures()) {
|
||||
#else
|
||||
if (environment.params.worldOptions.generateStructures())
|
||||
if (this.environment.params.worldOptions.generateStructures())
|
||||
{
|
||||
#endif
|
||||
for (ChunkAccess chunk : chunksToDo)
|
||||
|
||||
+6
-1
@@ -58,7 +58,12 @@ public final class StepSurface
|
||||
for (ChunkWrapper chunkWrapper : chunkWrappers)
|
||||
{
|
||||
ChunkAccess chunk = chunkWrapper.getChunk();
|
||||
if (!chunkWrapper.getStatus().isOrAfter(STATUS))
|
||||
if (chunkWrapper.getStatus().isOrAfter(STATUS))
|
||||
{
|
||||
// this chunk has already generated this step
|
||||
continue;
|
||||
}
|
||||
else if (chunk instanceof ProtoChunk)
|
||||
{
|
||||
#if MC_VER < MC_1_21
|
||||
((ProtoChunk) chunk).setStatus(STATUS);
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: 28e1eaae77...f767215ff0
+2
-2
@@ -23,8 +23,8 @@ loom {
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile = shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
inputFile = shadeDowngradedApi.archiveFile
|
||||
dependsOn shadeDowngradedApi
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,16 +29,14 @@ import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pos.DhBlockPos;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.fabric.wrappers.modAccessor.SodiumAccessor;
|
||||
//import io.netty.buffer.ByteBuf;
|
||||
import net.fabricmc.api.EnvType;
|
||||
@@ -55,6 +53,7 @@ import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import java.nio.FloatBuffer;
|
||||
#endif
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -107,7 +106,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
||||
// tick events //
|
||||
//=============//
|
||||
|
||||
ClientTickEvents.START_CLIENT_TICK.register((client) -> { ClientApi.INSTANCE.clientTickEvent(); });
|
||||
ClientTickEvents.START_CLIENT_TICK.register((client) -> ClientApi.INSTANCE.clientTickEvent());
|
||||
|
||||
|
||||
|
||||
@@ -123,6 +122,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
||||
});
|
||||
|
||||
// (kinda) block break event
|
||||
// Since fabric doesn't have a client-side break-block API event, this is the next best thing
|
||||
AttackBlockCallback.EVENT.register((player, level, interactionHand, blockPos, direction) ->
|
||||
{
|
||||
// if we have access to the server, use the chunk save event instead
|
||||
@@ -130,17 +130,26 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
||||
{
|
||||
if (SharedApi.isChunkAtBlockPosAlreadyUpdating(blockPos.getX(), blockPos.getZ()))
|
||||
{
|
||||
// Since fabric doesn't have a client-side break-block API event, this is the next best thing
|
||||
ChunkAccess chunk = level.getChunk(blockPos);
|
||||
if (chunk != null)
|
||||
// executor to prevent locking up the render/event thread
|
||||
// if the getChunk() takes longer than expected
|
||||
// (which can be caused by certain mods)
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor != null)
|
||||
{
|
||||
//LOGGER.trace("attack block at blockPos: " + blockPos);
|
||||
executor.execute(() ->
|
||||
{
|
||||
ChunkAccess chunk = level.getChunk(blockPos);
|
||||
if (chunk != null)
|
||||
{
|
||||
//LOGGER.trace("attack block at blockPos: " + blockPos);
|
||||
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
SharedApi.INSTANCE.chunkBlockChangedEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
SharedApi.INSTANCE.chunkBlockChangedEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,27 +159,37 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
||||
});
|
||||
|
||||
// (kinda) block place event
|
||||
// Since fabric doesn't have a client-side place-block API event, this is the next best thing
|
||||
UseBlockCallback.EVENT.register((player, level, hand, hitResult) ->
|
||||
{
|
||||
// if we have access to the server, use the chunk save event instead
|
||||
if (MC.clientConnectedToDedicatedServer())
|
||||
{
|
||||
if (SharedApi.isChunkAtBlockPosAlreadyUpdating(hitResult.getBlockPos().getX(), hitResult.getBlockPos().getZ()))
|
||||
if (hitResult.getType() == HitResult.Type.BLOCK
|
||||
&& !hitResult.isInside())
|
||||
{
|
||||
// Since fabric doesn't have a client-side place-block API event, this is the next best thing
|
||||
if (hitResult.getType() == HitResult.Type.BLOCK
|
||||
&& !hitResult.isInside())
|
||||
if (SharedApi.isChunkAtBlockPosAlreadyUpdating(hitResult.getBlockPos().getX(), hitResult.getBlockPos().getZ()))
|
||||
{
|
||||
ChunkAccess chunk = level.getChunk(hitResult.getBlockPos());
|
||||
if (chunk != null)
|
||||
// executor to prevent locking up the render/event thread
|
||||
// if the getChunk() takes longer than expected
|
||||
// (which can be caused by certain mods)
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor != null)
|
||||
{
|
||||
//LOGGER.trace("use block at blockPos: " + hitResult.getBlockPos());
|
||||
executor.execute(() ->
|
||||
{
|
||||
ChunkAccess chunk = level.getChunk(hitResult.getBlockPos());
|
||||
if (chunk != null)
|
||||
{
|
||||
//LOGGER.trace("use block at blockPos: " + hitResult.getBlockPos());
|
||||
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
SharedApi.INSTANCE.chunkBlockChangedEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
IClientLevelWrapper wrappedLevel = ClientLevelWrapper.getWrapper((ClientLevel) level);
|
||||
SharedApi.INSTANCE.chunkBlockChangedEvent(
|
||||
new ChunkWrapper(chunk, level, wrappedLevel),
|
||||
wrappedLevel
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-10
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.fabric.mixins.client;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
#if MC_VER < MC_1_19_4
|
||||
import com.mojang.math.Matrix4f;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
#else
|
||||
import org.joml.Matrix4f;
|
||||
#endif
|
||||
@@ -29,23 +30,17 @@ import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@@ -99,7 +94,7 @@ public class MixinLevelRenderer
|
||||
#if MC_VER == MC_1_16_5
|
||||
// get the matrices from the OpenGL fixed pipeline
|
||||
float[] mcProjMatrixRaw = new float[16];
|
||||
GL15.glGetFloatv(GL15.GL_PROJECTION_MATRIX, mcProjMatrixRaw);
|
||||
GL32.glGetFloatv(GL32.GL_PROJECTION_MATRIX, mcProjMatrixRaw);
|
||||
Mat4f mcProjectionMatrix = new Mat4f(mcProjMatrixRaw);
|
||||
mcProjectionMatrix.transpose();
|
||||
|
||||
@@ -110,13 +105,14 @@ public class MixinLevelRenderer
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose());
|
||||
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
#else
|
||||
// get the matrices directly from MC
|
||||
// MC combined the model view and projection matricies
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
Mat4f mcProjectionMatrix = new Mat4f();
|
||||
mcProjectionMatrix.setIdentity();
|
||||
#endif
|
||||
|
||||
if (renderType.equals(RenderType.translucent())) {
|
||||
if (renderType.equals(RenderType.translucent()))
|
||||
{
|
||||
ClientApi.INSTANCE.renderDeferredLods(ClientLevelWrapper.getWrapper(this.level),
|
||||
mcModelViewMatrix,
|
||||
mcProjectionMatrix,
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ public class MixinMinecraft
|
||||
}
|
||||
else
|
||||
{
|
||||
versionId = GitlabGetter.INSTANCE.projectPipelines.get(0).get("sha");
|
||||
versionId = GitlabGetter.INSTANCE.projectPipelines.getFirst().get("sha");
|
||||
}
|
||||
|
||||
Minecraft.getInstance().setScreen(new UpdateModScreen(
|
||||
|
||||
+3
-3
@@ -104,14 +104,14 @@ public class MixinOptionsScreen extends Screen
|
||||
|
||||
// add the button to the correct location in the UI
|
||||
// TODO is there a better way to do this instead of using access transformers to inject into the exact UI elements?
|
||||
LinearLayout layout = (LinearLayout) this.layout.headerFrame.children.get(0).child;
|
||||
LinearLayout layout = (LinearLayout) this.layout.headerFrame.children.getFirst().child;
|
||||
|
||||
// determine how wide the other option buttons are so we can put our botton to the left of them all
|
||||
AtomicInteger width = new AtomicInteger(0);
|
||||
layout.visitChildren(x -> { width.addAndGet(x.getWidth()); });
|
||||
layout.visitChildren(x -> width.addAndGet(x.getWidth()));
|
||||
width.addAndGet(-10); // padding between the DH button and the FOV slider
|
||||
|
||||
layout.wrapped.addChild(this.getOptionsButton(), 1, 2, (settings) -> { settings.paddingLeft(width.get() * -1); });
|
||||
layout.wrapped.addChild(this.getOptionsButton(), 1, 2, (settings) -> settings.paddingLeft(width.get() * -1));
|
||||
layout.arrangeElements();
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class ModMenuIntegration implements ModMenuApi
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory()
|
||||
{
|
||||
return parent -> GetConfigScreen.getScreen(parent);
|
||||
return GetConfigScreen::getScreen;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class ModChecker implements IModChecker
|
||||
@Override
|
||||
public File modLocation(String modid)
|
||||
{
|
||||
return new File(FabricLoader.getInstance().getModContainer(modid).get().getOrigin().getPaths().get(0).toUri());
|
||||
return new File(FabricLoader.getInstance().getModContainer(modid).get().getOrigin().getPaths().getFirst().toUri());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-6
@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
@@ -69,11 +69,9 @@ public class SodiumAccessor implements ISodiumAccessor
|
||||
|
||||
#if MC_VER >= MC_1_20_1
|
||||
// TODO: This is just a tmp solution, use a proper solution later
|
||||
return MC_RENDER.getMaximumRenderedChunks().stream().filter((DhChunkPos chunk) -> {
|
||||
return (renderer.isBoxVisible(
|
||||
chunk.getMinBlockX() + 1, height.getMinBuildHeight() + 1, chunk.getMinBlockZ() + 1,
|
||||
chunk.getMinBlockX() + 15, height.getMaxBuildHeight() - 1, chunk.getMinBlockZ() + 15));
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
return MC_RENDER.getMaximumRenderedChunks().stream().filter((DhChunkPos chunk) -> (renderer.isBoxVisible(
|
||||
chunk.getMinBlockX() + 1, height.getMinBuildHeight() + 1, chunk.getMinBlockZ() + 1,
|
||||
chunk.getMinBlockX() + 15, height.getMaxBuildHeight() - 1, chunk.getMinBlockZ() + 15))).collect(Collectors.toCollection(HashSet::new));
|
||||
#elif MC_VER >= MC_1_18_2
|
||||
// 0b11 = Lighted chunk & loaded chunk
|
||||
return renderer.getChunkTracker().getChunks(0b00).filter(
|
||||
|
||||
+2
-2
@@ -51,8 +51,8 @@ loom {
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile = shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
inputFile = shadeDowngradedApi.archiveFile
|
||||
dependsOn shadeDowngradedApi
|
||||
}
|
||||
|
||||
def addMod(path, enabled) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
@@ -65,6 +66,8 @@ import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* This handles all events sent to the client,
|
||||
* and is the starting point for most of the mod.
|
||||
@@ -186,8 +189,15 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
LevelAccessor level = event.getLevel();
|
||||
#endif
|
||||
|
||||
ChunkAccess chunk = level.getChunk(event.getPos());
|
||||
this.onBlockChangeEvent(level, chunk);
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor != null)
|
||||
{
|
||||
executor.execute(() ->
|
||||
{
|
||||
ChunkAccess chunk = level.getChunk(event.getPos());
|
||||
this.onBlockChangeEvent(level, chunk);
|
||||
});
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void leftClickBlockEvent(PlayerInteractEvent.LeftClickBlock event)
|
||||
@@ -205,8 +215,15 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
LevelAccessor level = event.getLevel();
|
||||
#endif
|
||||
|
||||
ChunkAccess chunk = level.getChunk(event.getPos());
|
||||
this.onBlockChangeEvent(level, chunk);
|
||||
ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor != null)
|
||||
{
|
||||
executor.execute(() ->
|
||||
{
|
||||
ChunkAccess chunk = level.getChunk(event.getPos());
|
||||
this.onBlockChangeEvent(level, chunk);
|
||||
});
|
||||
}
|
||||
}
|
||||
private void onBlockChangeEvent(LevelAccessor level, ChunkAccess chunk)
|
||||
{
|
||||
|
||||
+5
-6
@@ -22,6 +22,10 @@ package com.seibel.distanthorizons.forge.mixins.client;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
#if MC_VER < MC_1_19_4
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
#else
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -34,13 +38,9 @@ import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -50,7 +50,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
#if MC_VER < MC_1_17_1
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ org.gradle.caching=true
|
||||
|
||||
# Mod Info
|
||||
mod_name=DistantHorizons
|
||||
mod_version=2.1.2-a
|
||||
api_version=2.1.0
|
||||
mod_version=2.1.3-a-dev
|
||||
api_version=3.0.0
|
||||
maven_group=com.seibel.distanthorizons
|
||||
mod_readable_name=Distant Horizons
|
||||
mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
+9
-13
@@ -31,7 +31,7 @@ loom {
|
||||
setConfigName("NeoForge Client")
|
||||
ideConfigGenerated(true)
|
||||
runDir("../run")
|
||||
//vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg)
|
||||
// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg)
|
||||
}
|
||||
server {
|
||||
server()
|
||||
@@ -42,7 +42,13 @@ loom {
|
||||
}
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile = apiDowngrade.archiveFile
|
||||
dependsOn apiDowngrade
|
||||
// classifier null
|
||||
|
||||
atAccessWideners.add("distanthorizons.accesswidener")
|
||||
}
|
||||
|
||||
def addMod(path, enabled) {
|
||||
if (enabled == "2")
|
||||
@@ -50,24 +56,21 @@ def addMod(path, enabled) {
|
||||
else if (enabled == "1")
|
||||
dependencies { modCompileOnly(path) }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
mappings loom.layered()
|
||||
{
|
||||
mappings loom.layered() {
|
||||
// Mojmap mappings
|
||||
officialMojangMappings()
|
||||
// Parchment mappings (it adds parameter mappings & javadoc)
|
||||
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
|
||||
}
|
||||
|
||||
|
||||
// Neoforge
|
||||
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
|
||||
addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft)
|
||||
}
|
||||
|
||||
|
||||
|
||||
task deleteResources(type: Delete) {
|
||||
delete file("build/resources/main")
|
||||
}
|
||||
@@ -86,13 +89,6 @@ tasks.named('runClient') {
|
||||
finalizedBy(deleteResources)
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile = shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
|
||||
atAccessWideners.add("distanthorizons.accesswidener")
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
|
||||
+32
-16
@@ -28,14 +28,14 @@ import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
//import io.netty.buffer.ByteBuf;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -129,12 +129,11 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
LOGGER.info("level load");
|
||||
|
||||
LevelAccessor level = event.getLevel();
|
||||
if (!(level instanceof ClientLevel))
|
||||
if (!(level instanceof ClientLevel clientLevel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClientLevel clientLevel = (ClientLevel) level;
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel);
|
||||
// TODO this causes a crash due to level being set to null somewhere
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper);
|
||||
@@ -145,12 +144,11 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
LOGGER.info("level unload");
|
||||
|
||||
LevelAccessor level = event.getLevel();
|
||||
if (!(level instanceof ClientLevel))
|
||||
if (!(level instanceof ClientLevel clientLevel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClientLevel clientLevel = (ClientLevel) level;
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel);
|
||||
ClientApi.INSTANCE.clientLevelUnloadEvent(clientLevelWrapper);
|
||||
}
|
||||
@@ -169,12 +167,21 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
return;
|
||||
}
|
||||
|
||||
//LOGGER.trace("interact or block place event at blockPos: " + event.getPos());
|
||||
// executor to prevent locking up the render/event thread
|
||||
// if the getChunk() takes longer than expected
|
||||
// (which can be caused by certain mods)
|
||||
var executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor != null)
|
||||
{
|
||||
executor.execute(() ->
|
||||
{
|
||||
//LOGGER.trace("interact or block place event at blockPos: " + event.getPos());
|
||||
|
||||
LevelAccessor level = event.getLevel();
|
||||
|
||||
ChunkAccess chunk = level.getChunk(event.getPos());
|
||||
this.onBlockChangeEvent(level, chunk);
|
||||
LevelAccessor level = event.getLevel();
|
||||
ChunkAccess chunk = level.getChunk(event.getPos());
|
||||
this.onBlockChangeEvent(level, chunk);
|
||||
});
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void leftClickBlockEvent(PlayerInteractEvent.LeftClickBlock event)
|
||||
@@ -184,12 +191,21 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
return;
|
||||
}
|
||||
|
||||
//LOGGER.trace("break or block attack at blockPos: " + event.getPos());
|
||||
// executor to prevent locking up the render/event thread
|
||||
// if the getChunk() takes longer than expected
|
||||
// (which can be caused by certain mods)
|
||||
var executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor != null)
|
||||
{
|
||||
executor.execute(() ->
|
||||
{
|
||||
//LOGGER.trace("break or block attack at blockPos: " + event.getPos());
|
||||
|
||||
LevelAccessor level = event.getLevel();
|
||||
|
||||
ChunkAccess chunk = level.getChunk(event.getPos());
|
||||
this.onBlockChangeEvent(level, chunk);
|
||||
LevelAccessor level = event.getLevel();
|
||||
ChunkAccess chunk = level.getChunk(event.getPos());
|
||||
this.onBlockChangeEvent(level, chunk);
|
||||
});
|
||||
}
|
||||
}
|
||||
private void onBlockChangeEvent(LevelAccessor level, ChunkAccess chunk)
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ public class NeoforgeMain extends AbstractModInitializer
|
||||
@Override
|
||||
protected void subscribeRegisterCommandsEvent(Consumer<CommandDispatcher<CommandSourceStack>> eventHandler)
|
||||
{
|
||||
NeoForge.EVENT_BUS.addListener((RegisterCommandsEvent e) -> { eventHandler.accept(e.getDispatcher()); });
|
||||
NeoForge.EVENT_BUS.addListener((RegisterCommandsEvent e) -> eventHandler.accept(e.getDispatcher()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,7 +100,7 @@ public class NeoforgeMain extends AbstractModInitializer
|
||||
@Override
|
||||
protected void subscribeServerStartingEvent(Consumer<MinecraftServer> eventHandler)
|
||||
{
|
||||
NeoForge.EVENT_BUS.addListener((ServerStartingEvent e) -> { eventHandler.accept(e.getServer()); });
|
||||
NeoForge.EVENT_BUS.addListener((ServerStartingEvent e) -> eventHandler.accept(e.getServer()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -24,6 +24,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
#if MC_VER < MC_1_19_4
|
||||
import com.mojang.math.Matrix4f;
|
||||
#else
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.neoforge.NeoforgeClientProxy;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -36,7 +37,6 @@ import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ public class MixinMinecraft
|
||||
}
|
||||
else
|
||||
{
|
||||
versionId = GitlabGetter.INSTANCE.projectPipelines.get(0).get("sha");
|
||||
versionId = GitlabGetter.INSTANCE.projectPipelines.getFirst().get("sha");
|
||||
}
|
||||
|
||||
Minecraft.getInstance().setScreen(new UpdateModScreen(
|
||||
|
||||
+3
-3
@@ -104,14 +104,14 @@ public class MixinOptionsScreen extends Screen
|
||||
|
||||
// add the button to the correct location in the UI
|
||||
// TODO is there a better way to do this instead of using access transformers to inject into the exact UI elements?
|
||||
LinearLayout layout = (LinearLayout) this.layout.headerFrame.children.get(0).child;
|
||||
LinearLayout layout = (LinearLayout) this.layout.headerFrame.children.getFirst().child;
|
||||
|
||||
// determine how wide the other option buttons are so we can put our botton to the left of them all
|
||||
AtomicInteger width = new AtomicInteger(0);
|
||||
layout.visitChildren(x -> { width.addAndGet(x.getWidth()); });
|
||||
layout.visitChildren(x -> width.addAndGet(x.getWidth()));
|
||||
width.addAndGet(-10); // padding between the DH button and the FOV slider
|
||||
|
||||
layout.wrapped.addChild(this.getOptionsButton(), 1, 2, (settings) -> { settings.paddingLeft(width.get() * -1); });
|
||||
layout.wrapped.addChild(this.getOptionsButton(), 1, 2, (settings) -> settings.paddingLeft(width.get() * -1));
|
||||
layout.arrangeElements();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,6 +33,12 @@ pluginManagement {
|
||||
name "ParchmentMC"
|
||||
url "https://maven.parchmentmc.org"
|
||||
}
|
||||
maven { // Used for downgrading Java versions
|
||||
url "https://maven.wagyourtail.xyz/releases"
|
||||
}
|
||||
maven {
|
||||
url "https://maven.wagyourtail.xyz/snapshots"
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user