import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-public class CommonProxy implements IEventHandler {
+public class CommonProxy {
public Map<Integer, BoundingBoxCache> boundingBoxCacheMap = new ConcurrentHashMap<Integer, BoundingBoxCache>();
public ConfigManager configManager;
protected WorldData worldData;
+ private IEventHandler eventHandler = null;
public void init(ConfigManager configManager) {
this.configManager = configManager;
setWorldData(new WorldData(world.getSeed(), world.getWorldInfo().getSpawnX(), world.getWorldInfo().getSpawnZ()));
int dimensionId = world.provider.getDimensionId();
Logger.info("create world dimension: %d, %s (chunkprovider: %s) (seed: %d)", dimensionId, world.getClass().toString(), chunkProvider.getClass().toString(), worldData.getSeed());
- boundingBoxCacheMap.put(dimensionId, new DimensionProcessor(this, configManager, world, dimensionId, chunkProvider));
+ boundingBoxCacheMap.put(dimensionId, new DimensionProcessor(eventHandler, configManager, world, dimensionId, chunkProvider));
}
}
}
}
- public void boundingBoxRemoved(BoundingBox bb) {
- }
-
public WorldData getWorldData() {
return worldData;
}
public void setWorldData(WorldData worldData) {
this.worldData = worldData;
}
+
+ public void setEventHandler(IEventHandler eventHandler) {
+ this.eventHandler = eventHandler;
+ }
}
private void processDelta(Map<Integer, BoundingBoxVillage> oldVillages, Map<Integer, BoundingBoxVillage> newVillages) {
for (BoundingBox village : oldVillages.values()) {
removeBoundingBox(village);
- eventHandler.boundingBoxRemoved(village);
+ if(eventHandler!=null) {
+ eventHandler.boundingBoxRemoved(village);
+ }
}
for (BoundingBox village : newVillages.values()) {
if (!isCached(village))
private CommonProxy commonProxy;
public void init(ConfigManager configManager) {
- getProxy().init(configManager);
+ CommonProxy proxy = getProxy();
+ proxy.setEventHandler(this);
+ proxy.init(configManager);
network = NetworkRegistry.INSTANCE.newSimpleChannel("bbor");
network.registerMessage(AddBoundingBoxMessageHandler.class, AddBoundingBoxMessage.class, 0, Side.CLIENT);
network.registerMessage(RemoveBoundingBoxMessageHandler.class, RemoveBoundingBoxMessage.class, 1, Side.CLIENT);
getProxy().setWorldData(worldData);
}
- public void setConfigManager(ConfigManager configManager) {
- getProxy().configManager = configManager;
- }
-
public void addBoundingBox(int dimension, BoundingBox key, Set<BoundingBox> boundingBoxes) {
Map<Integer, BoundingBoxCache> boundingBoxCacheMap = getProxy().boundingBoxCacheMap;
if (!boundingBoxCacheMap.containsKey(dimension)) {