Skip to content

Commit

Permalink
huge optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
nossr50 committed Nov 4, 2024
1 parent f0973f2 commit 3aaff19
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
8 changes: 7 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Version 2.2.024
Fixed a bug where Giga Drill breaker was giving out more drop chance than intended
Large optimizations to most block interactions in mcMMO code
Significant optimizations made to reading new chunks for mcMMO
Significant optimizations to most block interactions in mcMMO code

Notes:
Got a bit carried away and started to optimize stuff.
I was able to make Tree Feller way faster with optimizations in this update, I tested with a custom gigantic tree that had over 200,000 blocks felled (huge) and it only took 4 seconds total, in the previous version of mcMMO this would take over 2-3 minutes.


Version 2.2.023
Compatibility with Minecraft 1.21.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,16 @@ private synchronized boolean isIneligible(int x, int y, int z, @NotNull World wo
ChunkStore check = chunkMap.computeIfAbsent(chunkKey, k -> {
// Load from file
ChunkStore loaded = loadChunk(chunkKey.x, chunkKey.z, world);
if (loaded == null)
return null;
if (loaded != null) {
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
return loaded;
}
// Mark chunk in-use for region tracking
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
return loaded;
// Create a new chunkstore
return new BitSetChunkStore(world, chunkKey.x, chunkKey.z);
});

// No chunk, return false
if (check == null)
return false;

int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;

Expand Down Expand Up @@ -227,19 +226,12 @@ private synchronized void set(int x, int y, int z, @NotNull World world, boolean
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
return loaded;
}
// If setting to false, no need to create an empty chunkstore
if (!value)
return null;
// Mark chunk in-use for region tracking
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
// Create a new chunkstore
return new BitSetChunkStore(world, chunkKey.x, chunkKey.z);
});

// Indicates setting false on empty chunkstore
if (cStore == null)
return;

// Get block offset (offset from chunk corner)
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public boolean isIneligible(@NotNull BlockState blockState) {

@Override
public boolean isEligible(@NotNull Block block) {
return false;
return true;
}

@Override
public boolean isEligible(@NotNull BlockState blockState) {
return false;
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ void setIneligibleShouldThrowIndexOutOfBoundsException() {

// Top Block
final Block illegalHeightBlock = initMockBlock(1337, 256, -1337);
assertFalse(hashChunkManager.isIneligible(illegalHeightBlock));
Assertions.assertThrows(IndexOutOfBoundsException.class, () -> hashChunkManager.setIneligible(illegalHeightBlock));
}

Expand Down

0 comments on commit 3aaff19

Please sign in to comment.