@@ -87,6 +87,8 @@ public interface Extension<T extends ResourcePackExtension> extends Keyed {
8787
8888 @ Getter private final BlockColorCalculatorFactory colorCalculatorFactory ;
8989 private final BlockPropertiesConfig blockPropertiesConfig ;
90+
91+ private final LoadingCache <de .bluecolored .bluemap .core .world .BlockState , BlockState > blockStateCache ;
9092 private final LoadingCache <de .bluecolored .bluemap .core .world .BlockState , BlockProperties > blockPropertiesCache ;
9193
9294 private final Map <Extension <?>, ResourcePackExtension > extensions ;
@@ -104,6 +106,11 @@ public ResourcePack(PackVersion packVersion) {
104106 this .colorCalculatorFactory = new BlockColorCalculatorFactory ();
105107 this .blockPropertiesConfig = new BlockPropertiesConfig ();
106108
109+ this .blockStateCache = Caffeine .newBuilder ()
110+ .executor (BlueMap .THREAD_POOL )
111+ .maximumSize (10000 )
112+ .expireAfterAccess (1 , TimeUnit .MINUTES )
113+ .build (this ::loadBlockState );
107114 this .blockPropertiesCache = Caffeine .newBuilder ()
108115 .executor (BlueMap .THREAD_POOL )
109116 .maximumSize (10000 )
@@ -355,15 +362,36 @@ private Atlas getBlocksAtlas() {
355362 return new Atlas ();
356363 }
357364
365+ public BlockState getBlockState (de .bluecolored .bluemap .core .world .BlockState blockState ) {
366+ return blockStateCache .get (blockState );
367+ }
368+
369+ private BlockState loadBlockState (de .bluecolored .bluemap .core .world .BlockState blockState ) {
370+ Key key = blockState .getId ();
371+ for (ResourcePackExtension extension : extensions .values ()) {
372+ key = extension .getBlockStateKey (key );
373+ }
374+ return blockStates .get (key );
375+ }
376+
358377 public BlockProperties getBlockProperties (de .bluecolored .bluemap .core .world .BlockState state ) {
359378 return blockPropertiesCache .get (state );
360379 }
361380
362381 private BlockProperties loadBlockProperties (de .bluecolored .bluemap .core .world .BlockState state ) {
363- BlockProperties .Builder props = blockPropertiesConfig .getBlockProperties (state ).toBuilder ();
382+ BlockProperties .Builder props = BlockProperties .builder ();
383+
384+ // collect properties from extensions
385+ for (ResourcePackExtension extension : extensions .values ()) {
386+ extension .getBlockProperties (state , props );
387+ }
388+
389+ // explicitly configured properties always have priority -> overwrite
390+ props .from (blockPropertiesConfig .getBlockProperties (state ));
364391
392+ // calculate culling and occlusion from model if UNDEFINED
365393 if (props .isOccluding () == Tristate .UNDEFINED || props .isCulling () == Tristate .UNDEFINED ) {
366- BlockState resource = blockStates . get (state . getId () );
394+ BlockState resource = getBlockState (state );
367395 if (resource != null ) {
368396 resource .forEach (state ,0 , 0 , 0 , variant -> {
369397 Model model = variant .getModel ().getResource (models ::get );
0 commit comments