use of org.terasology.world.WorldProvider in project Terasology by MovingBlocks.
the class ReadWriteStorageManager method addGameManifestToSaveTransaction.
private void addGameManifestToSaveTransaction(SaveTransactionBuilder saveTransactionBuilder) {
BlockManager blockManager = CoreRegistry.get(BlockManager.class);
BiomeManager biomeManager = CoreRegistry.get(BiomeManager.class);
WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
Time time = CoreRegistry.get(Time.class);
Game game = CoreRegistry.get(Game.class);
GameManifest gameManifest = new GameManifest(game.getName(), game.getSeed(), time.getGameTimeInMs());
for (Module module : CoreRegistry.get(ModuleManager.class).getEnvironment()) {
gameManifest.addModule(module.getId(), module.getVersion());
}
List<String> registeredBlockFamilies = Lists.newArrayList();
for (BlockFamily family : blockManager.listRegisteredBlockFamilies()) {
registeredBlockFamilies.add(family.getURI().toString());
}
gameManifest.setRegisteredBlockFamilies(registeredBlockFamilies);
gameManifest.setBlockIdMap(blockManager.getBlockIdMap());
List<Biome> biomes = biomeManager.getBiomes();
Map<String, Short> biomeIdMap = new HashMap<>(biomes.size());
for (Biome biome : biomes) {
short shortId = biomeManager.getBiomeShortId(biome);
String id = biomeManager.getBiomeId(biome);
biomeIdMap.put(id, shortId);
}
gameManifest.setBiomeIdMap(biomeIdMap);
gameManifest.addWorld(worldProvider.getWorldInfo());
saveTransactionBuilder.setGameManifest(gameManifest);
}
use of org.terasology.world.WorldProvider in project Terasology by MovingBlocks.
the class NetClient method disconnect.
@Override
public void disconnect() {
super.disconnect();
if (channel.isOpen()) {
channel.close().awaitUninterruptibly();
}
WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
if (worldProvider != null) {
worldProvider.unregisterListener(this);
}
}
use of org.terasology.world.WorldProvider in project Terasology by MovingBlocks.
the class ServerImpl method processBiomeChanges.
private void processBiomeChanges(NetData.NetMessage message) {
for (NetData.BiomeChangeMessage biomeChange : message.getBiomeChangeList()) {
logger.debug("Received block change to {}", blockManager.getBlock((short) biomeChange.getNewBiome()));
// TODO: Store changes to blocks that aren't ready to be modified (the surrounding chunks aren't available)
WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
Vector3i pos = NetMessageUtil.convert(biomeChange.getPos());
if (worldProvider.isBlockRelevant(pos)) {
Biome newBiome = biomeManager.getBiomeByShortId((short) biomeChange.getNewBiome());
worldProvider.setBiome(pos, newBiome);
} else {
awaitingChunkReadyBiomeUpdates.put(ChunkMath.calcChunkPos(pos), biomeChange);
}
}
}
use of org.terasology.world.WorldProvider in project Terasology by MovingBlocks.
the class ServerImpl method processBlockChanges.
private void processBlockChanges(NetData.NetMessage message) {
for (NetData.BlockChangeMessage blockChange : message.getBlockChangeList()) {
Block newBlock = blockManager.getBlock((short) blockChange.getNewBlock());
logger.debug("Received block change to {}", newBlock);
// TODO: Store changes to blocks that aren't ready to be modified (the surrounding chunks aren't available)
WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
Vector3i pos = NetMessageUtil.convert(blockChange.getPos());
if (worldProvider.isBlockRelevant(pos)) {
worldProvider.setBlock(pos, newBlock);
} else {
awaitingChunkReadyBlockUpdates.put(ChunkMath.calcChunkPos(pos), blockChange);
}
}
}
use of org.terasology.world.WorldProvider in project Terasology by MovingBlocks.
the class InitialiseRemoteWorld method step.
@Override
public boolean step() {
// TODO: These shouldn't be done here, nor so strongly tied to the world renderer
LocalPlayer localPlayer = new LocalPlayer();
context.put(LocalPlayer.class, localPlayer);
BlockManager blockManager = context.get(BlockManager.class);
RemoteChunkProvider chunkProvider = new RemoteChunkProvider(blockManager, localPlayer);
WorldProviderCoreImpl worldProviderCore = new WorldProviderCoreImpl(gameManifest.getWorldInfo(TerasologyConstants.MAIN_WORLD), chunkProvider, blockManager.getBlock(BlockManager.UNLOADED_ID), context);
EntityAwareWorldProvider entityWorldProvider = new EntityAwareWorldProvider(worldProviderCore, context);
WorldProvider worldProvider = new WorldProviderWrapper(entityWorldProvider);
context.put(WorldProvider.class, worldProvider);
context.put(BlockEntityRegistry.class, entityWorldProvider);
context.get(ComponentSystemManager.class).register(entityWorldProvider, "engine:BlockEntityRegistry");
DefaultCelestialSystem celestialSystem = new DefaultCelestialSystem(new BasicCelestialModel(), context);
context.put(CelestialSystem.class, celestialSystem);
context.get(ComponentSystemManager.class).register(celestialSystem);
// Init. a new world
Skysphere skysphere = new Skysphere(context);
BackdropProvider backdropProvider = skysphere;
BackdropRenderer backdropRenderer = skysphere;
context.put(BackdropProvider.class, backdropProvider);
context.put(BackdropRenderer.class, backdropRenderer);
RenderingSubsystemFactory engineSubsystemFactory = context.get(RenderingSubsystemFactory.class);
WorldRenderer worldRenderer = engineSubsystemFactory.createWorldRenderer(context);
float reflectionHeight = context.get(NetworkSystem.class).getServer().getInfo().getReflectionHeight();
worldRenderer.getActiveCamera().setReflectionHeight(reflectionHeight);
context.put(WorldRenderer.class, worldRenderer);
// TODO: These shouldn't be done here, nor so strongly tied to the world renderer
context.put(Camera.class, worldRenderer.getActiveCamera());
context.get(NetworkSystem.class).setRemoteWorldProvider(chunkProvider);
return true;
}
Aggregations