From 00e831c8f3f3d7dd2bd800c73cf852c775452d64 Mon Sep 17 00:00:00 2001 From: TomTheFurry Date: Thu, 4 Aug 2022 20:03:43 +0800 Subject: [PATCH] Fixed block color & improve close --- .../lod/common/wrappers/block/BlockStateWrapper.java | 9 +++++++-- .../wrappers/block/cache/ClientBlockStateCache.java | 5 +++++ .../wrappers/block/cache/ServerBlockStateCache.java | 5 +++++ core | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java index 11cd03528..1a0aca554 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockStateWrapper.java @@ -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 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 diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/cache/ClientBlockStateCache.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/cache/ClientBlockStateCache.java index df398faff..422b5ed98 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/cache/ClientBlockStateCache.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/cache/ClientBlockStateCache.java @@ -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; diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/cache/ServerBlockStateCache.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/cache/ServerBlockStateCache.java index cff1905f7..86fd20f53 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/cache/ServerBlockStateCache.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/cache/ServerBlockStateCache.java @@ -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; diff --git a/core b/core index 9a8145ff4..f6e5bdbd2 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 9a8145ff458010450648191493715295e3a8ff39 +Subproject commit f6e5bdbd2f95efce8d8138010329d29a3fc3794c