mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-25 20:16:00 +01:00
Merge branch 'base'
This commit is contained in:
commit
669b04ed7b
@ -33,6 +33,9 @@ build.dependsOn shadowJar {
|
||||
relocate 'org.apache.commons.lang3', 'de.bluecolored.shadow.apache.commons.lang3'
|
||||
relocate 'org.bstats.bukkit', 'de.bluecolored.shadow.bstats.bukkit'
|
||||
relocate 'com.mojang.brigadier', 'de.bluecolored.shadow.mojang.brigadier'
|
||||
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
|
||||
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
|
||||
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -25,4 +25,7 @@ build.dependsOn shadowJar {
|
||||
relocate 'org.apache.commons.lang3', 'de.bluecolored.shadow.apache.commons.lang3'
|
||||
relocate 'org.bstats.bukkit', 'de.bluecolored.shadow.bstats.bukkit'
|
||||
relocate 'org.yaml.snakeyaml', 'de.bluecolored.shadow.yaml.snakeyaml'
|
||||
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
|
||||
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
|
||||
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
|
||||
}
|
@ -29,7 +29,6 @@
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
@ -65,8 +64,8 @@ public void optimizeQueue() {
|
||||
Vector2d sortGridSize = new Vector2d(20, 20).div(mapType.getTileRenderer().getHiresModelManager().getTileSize().toDouble().div(16)).ceil().max(1, 1);
|
||||
|
||||
synchronized (renderTiles) {
|
||||
Vector2i[] array = renderTiles.toArray(new Vector2i[renderTiles.size()]);
|
||||
Arrays.sort(array, (v1, v2) -> {
|
||||
ArrayList<Vector2i> tileList = new ArrayList<>(renderTiles);
|
||||
tileList.sort((v1, v2) -> {
|
||||
Vector2i v1SortGridPos = v1.toDouble().div(sortGridSize).floor().toInt();
|
||||
Vector2i v2SortGridPos = v2.toDouble().div(sortGridSize).floor().toInt();
|
||||
|
||||
@ -90,8 +89,9 @@ public void optimizeQueue() {
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
renderTiles.clear();
|
||||
for (Vector2i tile : array) {
|
||||
for (Vector2i tile : tileList) {
|
||||
renderTiles.add(tile);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.github.ben-manes.caffeine:caffeine:2.8.5'
|
||||
compile 'com.google.guava:guava:21.0'
|
||||
compile 'com.google.code.gson:gson:2.8.0'
|
||||
compile 'org.apache.commons:commons-lang3:3.6'
|
||||
|
@ -26,11 +26,9 @@
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.common.collect.Multimaps;
|
||||
@ -80,22 +78,14 @@ public BlockPropertiesConfig(ConfigurationNode node, ResourcePack resourcePack,
|
||||
}
|
||||
}
|
||||
|
||||
mappingCache = CacheBuilder.newBuilder()
|
||||
.concurrencyLevel(8)
|
||||
mappingCache = Caffeine.newBuilder()
|
||||
.maximumSize(10000)
|
||||
.build(new CacheLoader<BlockState, BlockProperties>(){
|
||||
@Override public BlockProperties load(BlockState key) { return mapNoCache(key); }
|
||||
});
|
||||
.build(key -> mapNoCache(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockProperties get(BlockState from){
|
||||
try {
|
||||
return mappingCache.get(from);
|
||||
} catch (ExecutionException neverHappens) {
|
||||
//should never happen, since the CacheLoader does not throw any exceptions
|
||||
throw new RuntimeException("Unexpected error while trying to map a BlockState's properties", neverHappens.getCause());
|
||||
}
|
||||
return mappingCache.get(from);
|
||||
}
|
||||
|
||||
private BlockProperties mapNoCache(BlockState bs){
|
||||
|
@ -26,8 +26,8 @@
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
public abstract class AbstractLogger extends Logger {
|
||||
|
||||
@ -36,8 +36,7 @@ public abstract class AbstractLogger extends Logger {
|
||||
private Cache<String, Object> noFloodCache;
|
||||
|
||||
public AbstractLogger() {
|
||||
noFloodCache = CacheBuilder.newBuilder()
|
||||
.concurrencyLevel(4)
|
||||
noFloodCache = Caffeine.newBuilder()
|
||||
.expireAfterWrite(1, TimeUnit.HOURS)
|
||||
.maximumSize(10000)
|
||||
.build();
|
||||
|
@ -39,16 +39,15 @@
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.mca.extensions.BlockStateExtension;
|
||||
@ -82,7 +81,6 @@
|
||||
|
||||
public class MCAWorld implements World {
|
||||
|
||||
private static final Cache<WorldChunkHash, Chunk> CHUNK_CACHE = CacheBuilder.newBuilder().maximumSize(500).build();
|
||||
private static final Multimap<String, BlockStateExtension> BLOCK_STATE_EXTENSIONS = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
|
||||
static {
|
||||
@ -106,6 +104,8 @@ public class MCAWorld implements World {
|
||||
private int seaLevel;
|
||||
private Vector3i spawnPoint;
|
||||
|
||||
private final LoadingCache<Vector2i, Chunk> chunkCache;
|
||||
|
||||
private BlockIdMapper blockIdMapper;
|
||||
private BlockPropertiesMapper blockPropertiesMapper;
|
||||
private BiomeMapper biomeMapper;
|
||||
@ -139,6 +139,11 @@ private MCAWorld(
|
||||
this.ignoreMissingLightData = ignoreMissingLightData;
|
||||
|
||||
this.forgeBlockMappings = new HashMap<>();
|
||||
|
||||
this.chunkCache = Caffeine.newBuilder()
|
||||
.maximumSize(500)
|
||||
.expireAfterWrite(1, TimeUnit.MINUTES)
|
||||
.build(chunkPos -> this.loadChunkOrEmpty(chunkPos, 2, 1000));
|
||||
}
|
||||
|
||||
public BlockState getBlockState(Vector3i pos) {
|
||||
@ -191,11 +196,11 @@ private BlockState getExtendedBlockState(Chunk chunk, Vector3i pos) {
|
||||
|
||||
public Chunk getChunk(Vector2i chunkPos) {
|
||||
try {
|
||||
Chunk chunk = CHUNK_CACHE.get(new WorldChunkHash(this, chunkPos), () -> this.loadChunkOrEmpty(chunkPos, 2, 1000));
|
||||
Chunk chunk = chunkCache.get(chunkPos);
|
||||
return chunk;
|
||||
} catch (UncheckedExecutionException | ExecutionException e) {
|
||||
} catch (RuntimeException e) {
|
||||
if (e.getCause() instanceof InterruptedException) Thread.currentThread().interrupt();
|
||||
throw new RuntimeException(e.getCause());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,12 +346,12 @@ public Vector3i getSpawnPoint() {
|
||||
|
||||
@Override
|
||||
public void invalidateChunkCache() {
|
||||
CHUNK_CACHE.invalidateAll();
|
||||
chunkCache.invalidateAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateChunkCache(Vector2i chunk) {
|
||||
CHUNK_CACHE.invalidate(new WorldChunkHash(this, chunk));
|
||||
chunkCache.invalidate(chunk);
|
||||
}
|
||||
|
||||
public BlockIdMapper getBlockIdMapper() {
|
||||
@ -422,9 +427,6 @@ public static MCAWorld load(Path worldFolder, UUID uuid, BlockIdMapper blockIdMa
|
||||
levelData.getInt("SpawnZ")
|
||||
);
|
||||
|
||||
|
||||
CHUNK_CACHE.invalidateAll();
|
||||
|
||||
MCAWorld world = new MCAWorld(
|
||||
worldFolder,
|
||||
uuid,
|
||||
@ -487,32 +489,4 @@ public static void registerBlockStateExtension(BlockStateExtension extension) {
|
||||
}
|
||||
}
|
||||
|
||||
private static class WorldChunkHash {
|
||||
|
||||
private final UUID world;
|
||||
private final Vector2i chunk;
|
||||
|
||||
public WorldChunkHash(MCAWorld world, Vector2i chunk) {
|
||||
this.world = world.getUUID();
|
||||
this.chunk = chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (world.hashCode() * 31 + chunk.getX()) * 31 + chunk.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (obj instanceof WorldChunkHash) {
|
||||
WorldChunkHash other = (WorldChunkHash) obj;
|
||||
return other.chunk.equals(chunk) && world.equals(other.world);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,8 +51,8 @@
|
||||
|
||||
public class BlockStateResource {
|
||||
|
||||
private List<Variant> variants = new ArrayList<>();
|
||||
private Collection<Variant> multipart = new ArrayList<>();
|
||||
private List<Variant> variants = new ArrayList<>(0);
|
||||
private Collection<Variant> multipart = new ArrayList<>(0);
|
||||
|
||||
private BlockStateResource() {
|
||||
}
|
||||
@ -62,7 +62,7 @@ public Collection<TransformedBlockModelResource> getModels(BlockState blockState
|
||||
}
|
||||
|
||||
public Collection<TransformedBlockModelResource> getModels(BlockState blockState, Vector3i pos) {
|
||||
Collection<TransformedBlockModelResource> models = new ArrayList<>();
|
||||
Collection<TransformedBlockModelResource> models = new ArrayList<>(1);
|
||||
|
||||
Variant allMatch = null;
|
||||
for (Variant variant : variants) {
|
||||
|
@ -45,8 +45,9 @@ shadowJar {
|
||||
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
|
||||
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
|
||||
relocate 'org.yaml.snakeyaml', 'de.bluecolored.shadow.yaml.snakeyaml'
|
||||
|
||||
//exclude '/mappings/*'
|
||||
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
|
||||
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
|
||||
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
|
||||
}
|
||||
|
||||
task ramappedShadowJar(type: RemapJarTask) {
|
||||
|
@ -34,13 +34,11 @@
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
|
||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
||||
import de.bluecolored.bluemap.common.plugin.commands.Commands;
|
||||
@ -84,15 +82,10 @@ public FabricMod() {
|
||||
|
||||
this.worldUUIDs = new ConcurrentHashMap<>();
|
||||
this.eventForwarder = new FabricEventForwarder(this);
|
||||
this.worldUuidCache = CacheBuilder.newBuilder()
|
||||
this.worldUuidCache = Caffeine.newBuilder()
|
||||
.weakKeys()
|
||||
.maximumSize(1000)
|
||||
.build(new CacheLoader<ServerWorld, UUID>() {
|
||||
@Override
|
||||
public UUID load(ServerWorld key) throws Exception {
|
||||
return loadUUIDForWorld(key);
|
||||
}
|
||||
});
|
||||
.build(this::loadUUIDForWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -158,7 +151,7 @@ public UUID getUUIDForWorld(File worldFolder) throws IOException {
|
||||
public UUID getUUIDForWorld(ServerWorld world) throws IOException {
|
||||
try {
|
||||
return worldUuidCache.get(world);
|
||||
} catch (ExecutionException e) {
|
||||
} catch (RuntimeException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof IOException) throw (IOException) cause;
|
||||
else throw new IOException(cause);
|
||||
|
@ -43,6 +43,9 @@ build.dependsOn shadowJar {
|
||||
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
|
||||
relocate 'ninja.leaping.configurate', 'de.bluecolored.shadow.ninja.leaping.configurate'
|
||||
relocate 'org.yaml.snakeyaml', 'de.bluecolored.shadow.yaml.snakeyaml'
|
||||
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
|
||||
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
|
||||
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -34,13 +34,11 @@
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
|
||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
||||
import de.bluecolored.bluemap.common.plugin.commands.Commands;
|
||||
@ -88,15 +86,10 @@ public ForgeMod() {
|
||||
|
||||
this.worldUUIDs = new ConcurrentHashMap<>();
|
||||
this.eventForwarder = new ForgeEventForwarder(this);
|
||||
this.worldUuidCache = CacheBuilder.newBuilder()
|
||||
this.worldUuidCache = Caffeine.newBuilder()
|
||||
.weakKeys()
|
||||
.maximumSize(1000)
|
||||
.build(new CacheLoader<ServerWorld, UUID>() {
|
||||
@Override
|
||||
public UUID load(ServerWorld key) throws Exception {
|
||||
return loadUUIDForWorld(key);
|
||||
}
|
||||
});
|
||||
.build(this::loadUUIDForWorld);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
@ -158,7 +151,7 @@ public UUID getUUIDForWorld(File worldFolder) throws IOException {
|
||||
public UUID getUUIDForWorld(ServerWorld world) throws IOException {
|
||||
try {
|
||||
return worldUuidCache.get(world);
|
||||
} catch (ExecutionException e) {
|
||||
} catch (RuntimeException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof IOException) throw (IOException) cause;
|
||||
else throw new IOException(cause);
|
||||
|
@ -22,8 +22,9 @@ build.dependsOn shadowJar {
|
||||
relocate 'net.querz.nbt', 'de.bluecolored.shadow.querz.nbt'
|
||||
relocate 'org.apache.commons.io', 'de.bluecolored.shadow.apache.commons.io'
|
||||
relocate 'com.mojang.brigadier', 'de.bluecolored.shadow.mojang.brigadier'
|
||||
|
||||
minimize()
|
||||
relocate 'com.github.benmanes.caffeine', 'de.bluecolored.shadow.benmanes.caffeine'
|
||||
relocate 'com.google.errorprone', 'de.bluecolored.shadow.google.errorprone'
|
||||
relocate 'org.checkerframework', 'de.bluecolored.shadow.checkerframework'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -1,6 +1,6 @@
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
coreVersion=0.10.3
|
||||
coreVersion=0.11.0
|
||||
|
||||
targetVersion=mc1.16
|
||||
|
Loading…
Reference in New Issue
Block a user