On the client these fields can change randomly so are not reliable - instead we send to the client from the server during initialize
private Set<BoundingBox> getClientBoundingBoxes() {
Set<BoundingBox> boundingBoxes = new HashSet<BoundingBox>();
- World world = Minecraft.getMinecraft().theWorld;
- int dimensionId = world.provider.getDimensionId();
- if (dimensionId == 0) {
- if (configManager.drawWorldSpawn.getBoolean()) {
- int spawnX = world.getWorldInfo().getSpawnX();
- int spawnZ = world.getWorldInfo().getSpawnZ();
- boundingBoxes.add(getSpawnBoundingBox(spawnX, spawnZ));
- boundingBoxes.add(getSpawnChunksBoundingBox(spawnX, spawnZ));
+ if (initialized) {
+ World world = Minecraft.getMinecraft().theWorld;
+ int dimensionId = world.provider.getDimensionId();
+ if (dimensionId == 0) {
+ if (configManager.drawWorldSpawn.getBoolean()) {
+ int spawnX = world.getWorldInfo().getSpawnX();
+ int spawnZ = world.getWorldInfo().getSpawnZ();
+ boundingBoxes.add(getSpawnBoundingBox(spawnX, spawnZ));
+ boundingBoxes.add(getSpawnChunksBoundingBox(spawnX, spawnZ));
- }
+ }
- if (initialized &&
- configManager.drawSlimeChunks.getBoolean()) {
- Set<ChunkCoordIntPair> activeChunks = getActiveChunks(world);
- for (ChunkCoordIntPair chunk : activeChunks) {
- if (isSlimeChunk(chunk.chunkXPos, chunk.chunkZPos)) {
- boundingBoxes.add(BoundingBoxSlimeChunk.from(chunk, Color.GREEN));
+ if (configManager.drawSlimeChunks.getBoolean()) {
+ Set<ChunkCoordIntPair> activeChunks = getActiveChunks(world);
+ for (ChunkCoordIntPair chunk : activeChunks) {
+ if (isSlimeChunk(chunk.chunkXPos, chunk.chunkZPos)) {
+ boundingBoxes.add(BoundingBoxSlimeChunk.from(chunk, Color.GREEN));
+ }
}
}
}
public ConfigManager configManager;
protected SimpleNetworkWrapper network;
protected long seed;
+ protected int spawnX;
+ protected int spawnZ;
protected boolean initialized;
public void init() {
IChunkProvider chunkProvider = event.world.getChunkProvider();
if (chunkProvider instanceof ChunkProviderServer) {
chunkProvider = ((ChunkProviderServer) chunkProvider).serverChunkGenerator;
- setSeed(event.world.getSeed());
+ setWorldData(event.world.getSeed(), event.world.getWorldInfo().getSpawnX(), event.world.getWorldInfo().getSpawnZ());
int dimensionId = event.world.provider.getDimensionId();
FMLLog.info("create world dimension: %d, %s (chunkprovider: %s) (seed: %d)", dimensionId, event.world.getClass().toString(), chunkProvider.getClass().toString(), seed);
boundingBoxCacheMap.put(dimensionId, new DimensionProcessor(configManager, event.world, dimensionId, chunkProvider));
}
private void initializeClient(EntityPlayerMP player) {
- network.sendTo(InitializeClientMessage.from(seed), player);
+ network.sendTo(InitializeClientMessage.from(seed, spawnX, spawnZ), player);
}
private void sendToPlayer(EntityPlayerMP player, BoundingBoxCache boundingBoxCache) {
}
}
- public void setSeed(long seed) {
+ public void setWorldData(long seed, int spawnX, int spawnZ) {
this.seed = seed;
+ this.spawnX = spawnX;
+ this.spawnZ = spawnZ;
this.initialized = true;
}
+
+ public void setWorldData(IWorldData worldData) {
+ setWorldData(worldData.getSeed(), worldData.getSpawnX(), worldData.getSpawnZ());
+ }
}
--- /dev/null
+package com.irtimaled.bbor;
+
+/**
+ * Created by richard on 04/02/15.
+ */
+public interface IWorldData {
+ long getSeed();
+
+ int getSpawnX();
+
+ int getSpawnZ();
+}
package com.irtimaled.bbor.messages;
+import com.irtimaled.bbor.IWorldData;
import io.netty.buffer.ByteBuf;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
-public class InitializeClientMessage implements IMessage {
+public class InitializeClientMessage implements IMessage, IWorldData {
private long seed;
+ private int spawnX;
+ private int spawnZ;
- public static InitializeClientMessage from(long seed) {
+ public static InitializeClientMessage from(long seed, int spawnX, int spawnZ) {
InitializeClientMessage message = new InitializeClientMessage();
message.seed = seed;
+ message.spawnX = spawnX;
+ message.spawnZ = spawnZ;
return message;
}
@Override
public void fromBytes(ByteBuf buf) {
seed = buf.readLong();
+ spawnX = buf.readInt();
+ spawnZ = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeLong(seed);
+ buf.writeInt(spawnX);
+ buf.writeInt(spawnZ);
}
+ @Override
public long getSeed() {
return seed;
}
+
+ @Override
+ public int getSpawnX() { return spawnX; }
+
+ @Override
+ public int getSpawnZ() { return spawnZ; }
}
public class InitializeClientMessageHandler implements IMessageHandler<InitializeClientMessage, IMessage> {
@Override
public IMessage onMessage(InitializeClientMessage message, MessageContext ctx) {
- BoundingBoxOutlineReloaded.proxy.setSeed(message.getSeed());
+ BoundingBoxOutlineReloaded.proxy.setWorldData(message);
return null;
}
}