mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
huge optimizations
This commit is contained in:
parent
f0973f2500
commit
3aaff1911b
@ -1,6 +1,12 @@
|
|||||||
Version 2.2.024
|
Version 2.2.024
|
||||||
Fixed a bug where Giga Drill breaker was giving out more drop chance than intended
|
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
|
Version 2.2.023
|
||||||
Compatibility with Minecraft 1.21.3
|
Compatibility with Minecraft 1.21.3
|
||||||
|
@ -159,17 +159,16 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
ChunkStore check = chunkMap.computeIfAbsent(chunkKey, k -> {
|
ChunkStore check = chunkMap.computeIfAbsent(chunkKey, k -> {
|
||||||
// Load from file
|
// Load from file
|
||||||
ChunkStore loaded = loadChunk(chunkKey.x, chunkKey.z, world);
|
ChunkStore loaded = loadChunk(chunkKey.x, chunkKey.z, world);
|
||||||
if (loaded == null)
|
if (loaded != null) {
|
||||||
return null;
|
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
|
||||||
|
return loaded;
|
||||||
|
}
|
||||||
// Mark chunk in-use for region tracking
|
// Mark chunk in-use for region tracking
|
||||||
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
|
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 ix = Math.abs(x) % 16;
|
||||||
int iz = Math.abs(z) % 16;
|
int iz = Math.abs(z) % 16;
|
||||||
|
|
||||||
@ -227,19 +226,12 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
|
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
// If setting to false, no need to create an empty chunkstore
|
|
||||||
if (!value)
|
|
||||||
return null;
|
|
||||||
// Mark chunk in-use for region tracking
|
// Mark chunk in-use for region tracking
|
||||||
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
|
chunkUsageMap.computeIfAbsent(toRegionKey(chunkKey.worldID, chunkKey.x, chunkKey.z), j -> new HashSet<>()).add(chunkKey);
|
||||||
// Create a new chunkstore
|
// Create a new chunkstore
|
||||||
return new BitSetChunkStore(world, chunkKey.x, chunkKey.z);
|
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)
|
// Get block offset (offset from chunk corner)
|
||||||
int ix = Math.abs(x) % 16;
|
int ix = Math.abs(x) % 16;
|
||||||
int iz = Math.abs(z) % 16;
|
int iz = Math.abs(z) % 16;
|
||||||
|
@ -28,12 +28,12 @@ public class NullChunkManager implements ChunkManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEligible(@NotNull Block block) {
|
public boolean isEligible(@NotNull Block block) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEligible(@NotNull BlockState blockState) {
|
public boolean isEligible(@NotNull BlockState blockState) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,7 +75,6 @@ class UserBlockTrackerTest {
|
|||||||
|
|
||||||
// Top Block
|
// Top Block
|
||||||
final Block illegalHeightBlock = initMockBlock(1337, 256, -1337);
|
final Block illegalHeightBlock = initMockBlock(1337, 256, -1337);
|
||||||
assertFalse(hashChunkManager.isIneligible(illegalHeightBlock));
|
|
||||||
Assertions.assertThrows(IndexOutOfBoundsException.class, () -> hashChunkManager.setIneligible(illegalHeightBlock));
|
Assertions.assertThrows(IndexOutOfBoundsException.class, () -> hashChunkManager.setIneligible(illegalHeightBlock));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user