More logging & fix 1.16 getminbuildheight & improve blockdetailmap caching for waterlogged blocks

This commit is contained in:
TomTheFurry
2022-04-13 13:38:37 +08:00
parent 0e1017111e
commit 1952f91540
4 changed files with 18 additions and 8 deletions
@@ -21,6 +21,7 @@ package com.seibel.lod.common.wrappers.block;
import java.util.concurrent.ConcurrentHashMap;
import com.seibel.lod.core.api.ApiShared;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
@@ -33,13 +34,13 @@ public class BlockDetailMap
private BlockDetailMap() {}
public static BlockDetailWrapper getOrMakeBlockDetailCache(BlockState bs, BlockPos pos, LevelReader getter) {
if (!bs.getFluidState().isEmpty()) {
bs = bs.getFluidState().createLegacyBlock();
}
BlockDetailWrapper cache = map.get(bs);
if (cache != null) return cache;
if (bs.getFluidState().isEmpty()) {
cache = BlockDetailWrapper.make(bs, pos, getter);
} else {
cache = BlockDetailWrapper.make(bs.getFluidState().createLegacyBlock(), pos, getter);
}
cache = BlockDetailWrapper.make(bs, pos, getter);
//ApiShared.LOGGER.info("New blockDetail cache for {} to {} ", bs, cache);
BlockDetailWrapper cacheCAS = map.putIfAbsent(bs, cache);
return cacheCAS==null ? cache : cacheCAS;
}
@@ -193,6 +193,7 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
this.state = state;
this.samplePos = pos;
this.sampleGetter = getter;
//ApiShared.LOGGER.info("Created BlockDetailWrapper for blockstate {} at {}", state, pos);
}
private BlockDetailWrapper() {
@@ -343,5 +344,8 @@ public class BlockDetailWrapper extends IBlockDetailWrapper
{
return ((BlockDetailWrapper)iBlockDetail).state.getBlock().equals(state.getBlock());
}
public String toString() {
return "BlockDetail{" + state + "}";
}
}
@@ -77,7 +77,7 @@ public class ChunkWrapper implements IChunkWrapper
public int getMinBuildHeight()
{
#if PRE_MC_1_17_1
return 255;
return 0;
#else
return chunk.getMinBuildHeight();
#endif
@@ -242,5 +242,10 @@ public class ChunkWrapper implements IChunkWrapper
{
return lightSource;
}
@Override
public String toString() {
return chunk.getClass().getSimpleName() + chunk.getPos();
}
}
+1 -1
Submodule core updated: ee803e10b5...633b229d2e