diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockDetailMap.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockDetailMap.java
deleted file mode 100644
index 6fb510855..000000000
--- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockDetailMap.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * This file is part of the Distant Horizons mod
- * licensed under the GNU LGPL v3 License.
- *
- * Copyright (C) 2020-2023 James Seibel
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- */
-
-package com.seibel.distanthorizons.common.wrappers.block.cache;
-
-import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
-import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
-import com.seibel.distanthorizons.core.pos.DhBlockPos;
-import net.minecraft.world.level.block.state.BlockState;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-public class ClientBlockDetailMap
-{
- private final ConcurrentHashMap blockCache = new ConcurrentHashMap<>();
- private final ClientLevelWrapper level;
-
-
-
- //=============//
- // constructor //
- //=============//
-
- public ClientBlockDetailMap(ClientLevelWrapper level) { this.level = level; }
-
-
-
- //=========//
- // methods //
- //=========//
-
- public ClientBlockStateCache getBlockStateData(BlockState blockState)
- { return this.blockCache.computeIfAbsent(blockState, (block) -> new ClientBlockStateCache(block, this.level)); }
-
- public int getColor(BlockState state, BiomeWrapper biome, DhBlockPos pos)
- { return this.getBlockStateData(state).getAndResolveFaceColor(biome, pos); }
-
- public void clear() { this.blockCache.clear(); }
-
-
-}
diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateColorCache.java
similarity index 98%
rename from common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java
rename to common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateColorCache.java
index 673d975cb..99d77e592 100644
--- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java
+++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateColorCache.java
@@ -31,7 +31,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapp
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
-import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
@@ -50,11 +49,13 @@ import java.util.HashSet;
import java.util.List;
/**
- * This keeps track of the color each block state should be for a given level.
+ * This stores and calculates the colors
+ * the given {@link BlockState} should have based
+ * on the given {@link IClientLevelWrapper}.
*
* @see ColorUtil
*/
-public class ClientBlockStateCache
+public class ClientBlockStateColorCache
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
@@ -154,7 +155,7 @@ public class ClientBlockStateCache
// constructor //
//=============//
- public ClientBlockStateCache(BlockState blockState, IClientLevelWrapper samplingLevel)
+ public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper samplingLevel)
{
this.blockState = blockState;
this.levelWrapper = samplingLevel;
@@ -371,7 +372,7 @@ public class ClientBlockStateCache
// public getter //
//===============//
- public int getAndResolveFaceColor(BiomeWrapper biome, DhBlockPos pos)
+ public int getColor(BiomeWrapper biome, DhBlockPos pos)
{
// only get the tint if the block needs to be tinted
if (!this.needPostTinting)
diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java
index c2fb642a6..df01f165c 100644
--- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java
+++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/world/ClientLevelWrapper.java
@@ -5,9 +5,8 @@ import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegist
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.ClientBlockDetailMap;
+import com.seibel.distanthorizons.common.wrappers.block.cache.ClientBlockStateColorCache;
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.*;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -22,6 +21,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapp
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkSource;
import org.apache.logging.log4j.Logger;
@@ -46,7 +46,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
private static final Minecraft MINECRAFT = Minecraft.getInstance();
private final ClientLevel level;
- private final ClientBlockDetailMap blockMap = new ClientBlockDetailMap(this);
+ private final ConcurrentHashMap blockCache = new ConcurrentHashMap<>();
private BlockStateWrapper dirtBlockWrapper;
private BiomeWrapper plainsBiomeWrapper;
@@ -111,7 +111,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
}
catch (Exception e)
{
- LOGGER.error("Failed to get server side wrapper for client level: " + level);
+ LOGGER.error("Failed to get server side wrapper for client level: " + this.level);
return null;
}
}
@@ -123,9 +123,13 @@ public class ClientLevelWrapper implements IClientLevelWrapper
//====================//
@Override
- public int computeBaseColor(DhBlockPos pos, IBiomeWrapper biome, IBlockStateWrapper blockState)
+ public int getBlockColor(DhBlockPos pos, IBiomeWrapper biome, IBlockStateWrapper blockWrapper)
{
- return this.blockMap.getColor(((BlockStateWrapper) blockState).blockState, (BiomeWrapper) biome, pos);
+ ClientBlockStateColorCache blockColorCache = this.blockCache.computeIfAbsent(
+ ((BlockStateWrapper) blockWrapper).blockState,
+ (block) -> new ClientBlockStateColorCache(block, this));
+
+ return blockColorCache.getColor((BiomeWrapper) biome, pos);
}
@Override
@@ -145,7 +149,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
}
}
- return this.blockMap.getColor(this.dirtBlockWrapper.blockState, BiomeWrapper.EMPTY_WRAPPER, DhBlockPos.ZERO);
+ return this.getBlockColor(DhBlockPos.ZERO,BiomeWrapper.EMPTY_WRAPPER, this.dirtBlockWrapper);
}
@Override