over 10k less objects per second

This commit is contained in:
Leijurv 2018-11-26 07:58:10 -08:00
parent 6d1130d2c3
commit f25786635b
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
1 changed files with 3 additions and 1 deletions

View File

@ -39,6 +39,8 @@ import java.util.*;
*/
public final class ChunkPacker {
private static final Map<String, Block> resourceCache = new HashMap<>();
private ChunkPacker() {}
public static CachedChunk pack(Chunk chunk) {
@ -120,7 +122,7 @@ public final class ChunkPacker {
}
public static Block stringToBlock(String name) {
return Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name);
return resourceCache.computeIfAbsent(name, n -> Block.getBlockFromName(n.contains(":") ? n : "minecraft:" + n));
}
private static PathingBlockType getPathingBlockType(IBlockState state) {