Skip to content

Commit 9198031

Browse files
committed
Merge 1.16 into 1.18
2 parents 4c737e3 + 8383053 commit 9198031

File tree

1 file changed

+7
-1
lines changed
  • common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/deduplicate_wall_shapes

1 file changed

+7
-1
lines changed

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/deduplicate_wall_shapes/WallBlockMixin.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@ private synchronized void useCachedShapeMap(float f1, float f2, float f3, float
4040
return;
4141
ImmutableMap.Builder<BlockState, VoxelShape> builder = ImmutableMap.builder();
4242
for(BlockState state : this.stateDefinition.getPossibleStates()) {
43-
builder.put(state, cache.getFirst().get(state.getValues()));
43+
VoxelShape shape = cache.getFirst().get(state.getValues());
44+
if(shape == null)
45+
return; // fallback to vanilla logic
46+
builder.put(state, shape);
4447
}
4548
cir.setReturnValue(builder.build());
4649
}
4750

4851
@Inject(method = "makeShapes", at = @At("RETURN"))
4952
private synchronized void storeCachedShapesByProperty(float f1, float f2, float f3, float f4, float f5, float f6, CallbackInfoReturnable<Map<BlockState, VoxelShape>> cir) {
53+
// never populate cache as a non-vanilla block
54+
if((Class<?>)this.getClass() != WallBlock.class)
55+
return;
5056
ImmutableList<Float> key = ImmutableList.of(f1, f2, f3, f4, f5, f6);
5157
if(!CACHE_BY_SHAPE_VALS.containsKey(key)) {
5258
Map<ImmutableMap<Property<?>, Comparable<?>>, VoxelShape> cacheByProperties = new HashMap<>();

0 commit comments

Comments
 (0)