Merge remote-tracking branch 'upstream-core/main'

This commit is contained in:
Steveplays28
2023-08-14 15:40:41 +02:00
3 changed files with 50 additions and 16 deletions
@@ -179,6 +179,13 @@ public class DhLightingEngine
continue;
}
if (relNeighbourBlockPos.y < neighbourChunk.getMinBuildHeight() || relNeighbourBlockPos.y > neighbourChunk.getMaxBuildHeight())
{
// the light pos is outside the chunk's min/max height,
// this can happen if given a chunk that hasn't finished generating
continue;
}
int currentBlockLight = getLightFunc.getLight(neighbourChunk, relNeighbourBlockPos);
if (currentBlockLight >= (lightValue - 1))
@@ -3,6 +3,8 @@ package com.seibel.distanthorizons.core.jar;
import com.electronwill.nightconfig.core.Config;
import com.electronwill.nightconfig.core.io.ParsingMode;
import com.electronwill.nightconfig.json.JsonFormat;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Get info on the git for the mod <br>
@@ -10,17 +12,37 @@ import com.electronwill.nightconfig.json.JsonFormat;
*
* @author coolGi
*/
public final class ModGitInfo {
static {
// Warning: Atm, this file is in the common subproject as the processResources task in gradle doesnt work for core
String s = JarUtils.convertInputStreamToString(JarUtils.accessFile("build_info.json"));
public final class ModGitInfo
{
private static final Logger LOGGER = LogManager.getLogger();
private static final String FILE_NAME = "build_info.json";
static
{
String gitMainCommit = "UNKNOWN";
String gitMainBranch = "UNKNOWN";
String gitCoreCommit = "UNKNOWN";
try
{
// Warning: Atm, this file is in the common subproject as the processResources task in gradle doesn't work for core
String jsonString = JarUtils.convertInputStreamToString(JarUtils.accessFile(FILE_NAME));
Config jsonObject = Config.inMemory();
JsonFormat.minimalInstance().createParser().parse(jsonString, jsonObject, ParsingMode.REPLACE);
gitMainCommit = jsonObject.get("git_main_commit");
gitMainBranch = jsonObject.get("git_core_commit");
gitCoreCommit = jsonObject.get("git_main_branch");
}
catch (Exception | Error e)
{
LOGGER.warn("Unable to get the Git information from "+FILE_NAME);
}
Config jsonObject = Config.inMemory();
JsonFormat.minimalInstance().createParser().parse(s, jsonObject, ParsingMode.REPLACE);
Git_Main_Commit = jsonObject.get("git_main_commit");
Git_Core_Commit = jsonObject.get("git_core_commit");
Git_Main_Branch = jsonObject.get("git_main_branch");
Git_Main_Commit = gitMainCommit;
Git_Core_Commit = gitMainBranch;
Git_Main_Branch = gitCoreCommit;
}
public static final String Git_Main_Commit;
@@ -25,23 +25,28 @@ public class DhChunkPos
{
public final int x; // Low 32 bits
public final int z; // High 32 bits
/** cached to improve hashing speed */
public final int hashCode;
public DhChunkPos(int x, int z)
{
this.x = x;
this.z = z;
// custom hash, 7309 is a random prime
this.hashCode = this.x * 7309 + this.z;
}
public DhChunkPos(DhBlockPos blockPos)
{
this.x = blockPos.x >> 4; // Same as div 16
this.z = blockPos.z >> 4; // Same as div 16
// >> 4 is the Same as div 16
this(blockPos.x >> 4, blockPos.z >> 4);
}
public DhChunkPos(DhBlockPos2D blockPos)
{
this.x = blockPos.x >> 4; // Same as div 16
this.z = blockPos.z >> 4; // Same as div 16
// >> 4 is the Same as div 16
this(blockPos.x >> 4, blockPos.z >> 4);
}
public DhChunkPos(long packed) { this(getX(packed), getZ(packed)); }
@@ -86,7 +91,7 @@ public class DhChunkPos
}
@Override
public int hashCode() { return Objects.hash(x, z); }
public int hashCode() { return this.hashCode; }
@Override
public String toString() { return "C["+x+","+z+"]"; }