mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-26 06:24:54 +02:00
Micro cleanup
This commit is contained in:
parent
a8a9f59715
commit
98f645b344
|
@ -58,13 +58,12 @@ public class DynamicChunk extends Chunk {
|
|||
final NBTCompound nbt = block.nbt();
|
||||
if (handler != null || nbt != null) {
|
||||
this.entries.put(index, block);
|
||||
// Block tick
|
||||
if (handler != null && handler.isTickable()) {
|
||||
this.tickableMap.put(index, block);
|
||||
}
|
||||
} else {
|
||||
this.entries.remove(index);
|
||||
}
|
||||
// Tickable
|
||||
if (handler != null && handler.isTickable()) {
|
||||
this.tickableMap.put(index, block);
|
||||
} else {
|
||||
this.tickableMap.remove(index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,15 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
class BlockImpl implements Block {
|
||||
private static final Cache<NBTCompound, NBTCompound> NBT_CACHE = Caffeine.newBuilder()
|
||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
||||
.expireAfterWrite(Duration.ofMinutes(5))
|
||||
.weakValues()
|
||||
.build();
|
||||
|
||||
|
@ -56,7 +56,8 @@ class BlockImpl implements Block {
|
|||
public @NotNull <T> Block withTag(@NotNull Tag<T> tag, @Nullable T value) {
|
||||
var compound = Objects.requireNonNullElseGet(nbt(), NBTCompound::new);
|
||||
tag.write(compound, value);
|
||||
return new BlockImpl(registry, properties, NBT_CACHE.get(compound, c -> compound), handler);
|
||||
final var nbt = compound.getSize() > 0 ? NBT_CACHE.get(compound, c -> compound) : null;
|
||||
return new BlockImpl(registry, properties, nbt, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user