import com.irtimaled.bbor.common.messages.InitializeClient;
import com.irtimaled.bbor.common.messages.PayloadBuilder;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
+import com.irtimaled.bbor.common.models.DimensionId;
import com.irtimaled.bbor.common.models.ServerPlayer;
import java.util.HashMap;
public class CommonProxy {
private final Map<Integer, ServerPlayer> players = new ConcurrentHashMap<>();
private final Map<Integer, Set<AbstractBoundingBox>> playerBoundingBoxesCache = new HashMap<>();
- private final Map<Integer, StructureProcessor> structureProcessors = new HashMap<>();
- private final Map<Integer, BoundingBoxCache> dimensionCache = new ConcurrentHashMap<>();
+ private final Map<DimensionId, StructureProcessor> structureProcessors = new HashMap<>();
+ private final Map<DimensionId, BoundingBoxCache> dimensionCache = new ConcurrentHashMap<>();
private Long seed = null;
private Integer spawnX = null;
private Integer spawnZ = null;
}
private void worldLoaded(WorldLoaded event) {
- int dimensionId = event.getDimensionId();
+ DimensionId dimensionId = event.getDimensionId();
long seed = event.getSeed();
- if (dimensionId == Dimensions.OVERWORLD) {
+ if (dimensionId == DimensionId.OVERWORLD) {
setSeed(seed);
setWorldSpawn(event.getSpawnX(), event.getSpawnZ());
}
}
private void structuresLoaded(StructuresLoaded event) {
- int dimensionId = event.getDimensionId();
+ DimensionId dimensionId = event.getDimensionId();
StructureProcessor structureProcessor = getStructureProcessor(dimensionId);
structureProcessor.process(event.getStructures());
}
- private StructureProcessor getStructureProcessor(int dimensionId) {
+ private StructureProcessor getStructureProcessor(DimensionId dimensionId) {
StructureProcessor structureProcessor = structureProcessors.get(dimensionId);
if (structureProcessor == null) {
structureProcessor = new StructureProcessor(getOrCreateCache(dimensionId));
}
private void sendToPlayer(int playerId, ServerPlayer player) {
- for (Map.Entry<Integer, BoundingBoxCache> entry : dimensionCache.entrySet()) {
- int dimensionId = entry.getKey();
+ for (Map.Entry<DimensionId, BoundingBoxCache> entry : dimensionCache.entrySet()) {
+ DimensionId dimensionId = entry.getKey();
BoundingBoxCache boundingBoxCache = entry.getValue();
if (boundingBoxCache == null) return;
}
}
- protected BoundingBoxCache getCache(int dimensionId) {
+ protected BoundingBoxCache getCache(DimensionId dimensionId) {
return dimensionCache.get(dimensionId);
}
- protected BoundingBoxCache getOrCreateCache(int dimensionId) {
+ protected BoundingBoxCache getOrCreateCache(DimensionId dimensionId) {
return dimensionCache.computeIfAbsent(dimensionId, dt -> new BoundingBoxCache());
}