Fixed block color & improve close
This commit is contained in:
@@ -2,28 +2,33 @@ package com.seibel.lod.common.wrappers.block;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BlockStateWrapper implements IBlockStateWrapper {
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
public static final BlockStateWrapper AIR = new BlockStateWrapper(null);
|
||||
|
||||
public static ConcurrentHashMap<BlockState, BlockStateWrapper> cache = new ConcurrentHashMap<>();
|
||||
|
||||
public static BlockStateWrapper fromBlockState(BlockState blockState) {
|
||||
if (blockState == null || blockState.isAir()) return AIR;
|
||||
if (blockState.getFluidState() != null)
|
||||
if (blockState.getFluidState().isEmpty())
|
||||
return cache.computeIfAbsent(blockState, BlockStateWrapper::new);
|
||||
else
|
||||
return cache.computeIfAbsent(blockState.getFluidState().createLegacyBlock(), BlockStateWrapper::new);
|
||||
return cache.computeIfAbsent(blockState, BlockStateWrapper::new);
|
||||
}
|
||||
|
||||
public final BlockState blockState;
|
||||
BlockStateWrapper(BlockState blockState) {
|
||||
this.blockState = blockState;
|
||||
LOGGER.info("Created BlockStateWrapper for {}", blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
@@ -3,6 +3,7 @@ package com.seibel.lod.common.wrappers.block.cache;
|
||||
import com.seibel.lod.common.wrappers.McObjectConverter;
|
||||
import com.seibel.lod.common.wrappers.block.*;
|
||||
import com.seibel.lod.core.config.Config;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.objects.DHBlockPos;
|
||||
import com.seibel.lod.core.util.ColorUtil;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
@@ -21,12 +22,15 @@ import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.util.RandomSource;
|
||||
#endif
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ClientBlockStateCache {
|
||||
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
#if PRE_MC_1_19
|
||||
public static final Random random = new Random(0);
|
||||
#else
|
||||
@@ -41,6 +45,7 @@ public class ClientBlockStateCache {
|
||||
level = (LevelReader) samplingLevel.unwrapLevel();
|
||||
pos = McObjectConverter.Convert(samplingPos);
|
||||
resolveColors();
|
||||
LOGGER.info("ClientBlocKCache created for {}", blockState);
|
||||
}
|
||||
|
||||
boolean isColorResolved = false;
|
||||
|
||||
+5
@@ -1,6 +1,7 @@
|
||||
package com.seibel.lod.common.wrappers.block.cache;
|
||||
|
||||
import com.seibel.lod.common.wrappers.McObjectConverter;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.objects.DHBlockPos;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -9,10 +10,13 @@ import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ServerBlockStateCache {
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
public final BlockState state;
|
||||
public final LevelReader level;
|
||||
public final BlockPos pos;
|
||||
@@ -22,6 +26,7 @@ public class ServerBlockStateCache {
|
||||
level = (LevelReader) samplingLevel.unwrapLevel();
|
||||
pos = McObjectConverter.Convert(samplingPos);
|
||||
resolveShapes();
|
||||
LOGGER.info("ServerBlockState created for {}", blockState);
|
||||
}
|
||||
|
||||
boolean noCollision = false;
|
||||
|
||||
+1
-1
Submodule core updated: 9a8145ff45...f6e5bdbd2f
Reference in New Issue
Block a user