Search in sources :

Example 1 with PlayerBorderListener

use of org.spongepowered.common.world.border.PlayerBorderListener in project SpongeCommon by SpongePowered.

the class MixinWorldServer method onConstruct.

@Inject(method = "<init>", at = @At("RETURN"))
private void onConstruct(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn, CallbackInfo callbackInfo) {
    if (info == null) {
        SpongeImpl.getLogger().warn("World constructed without a WorldInfo! This will likely cause problems. Subsituting dummy info.", new RuntimeException("Stack trace:"));
        this.worldInfo = new WorldInfo(new WorldSettings(0, GameType.NOT_SET, false, false, WorldType.DEFAULT), "sponge$dummy_world");
    }
    // Checks to make sure no mod has changed our worldInfo and if so, reverts back to original.
    // Mods such as FuturePack replace worldInfo with a custom one for separate world time.
    // This change is not needed as all worlds use separate save handlers.
    this.worldInfo = info;
    this.timings = new WorldTimingsHandler((WorldServer) (Object) this);
    this.dimensionId = dimensionId;
    this.prevWeather = getWeather();
    this.weatherStartTime = this.worldInfo.getWorldTotalTime();
    ((World) (Object) this).getWorldBorder().addListener(new PlayerBorderListener(this.getMinecraftServer(), dimensionId));
    PortalAgentType portalAgentType = ((WorldProperties) this.worldInfo).getPortalAgentType();
    if (!portalAgentType.equals(PortalAgentTypes.DEFAULT)) {
        try {
            this.worldTeleporter = (Teleporter) portalAgentType.getPortalAgentClass().getConstructor(new Class<?>[] { WorldServer.class }).newInstance(new Object[] { this });
        } catch (Exception e) {
            SpongeImpl.getLogger().log(Level.ERROR, "Could not create PortalAgent of type " + portalAgentType.getId() + " for world " + this.getName() + ": " + e.getMessage() + ". Falling back to default...");
        }
    }
    // Turn on capturing
    updateWorldGenerator();
    // Need to set the active config before we call it.
    this.chunkGCLoadThreshold = SpongeHooks.getActiveConfig((WorldServer) (Object) this).getConfig().getWorld().getChunkLoadThreadhold();
    this.chunkGCTickInterval = this.getActiveConfig().getConfig().getWorld().getTickInterval();
    this.weatherIceAndSnowEnabled = this.getActiveConfig().getConfig().getWorld().getWeatherIceAndSnow();
    this.weatherThunderEnabled = this.getActiveConfig().getConfig().getWorld().getWeatherThunder();
    this.updateEntityTick = 0;
    this.mixinChunkProviderServer = ((IMixinChunkProviderServer) this.getChunkProvider());
    this.setMemoryViewDistance(this.chooseViewDistanceValue(this.getActiveConfig().getConfig().getWorld().getViewDistance()));
}
Also used : WorldTimingsHandler(co.aikar.timings.WorldTimingsHandler) PlayerBorderListener(org.spongepowered.common.world.border.PlayerBorderListener) PortalAgentType(org.spongepowered.api.world.PortalAgentType) WorldInfo(net.minecraft.world.storage.WorldInfo) IMixinWorldInfo(org.spongepowered.common.interfaces.world.IMixinWorldInfo) WorldServer(net.minecraft.world.WorldServer) IMixinWorldServer(org.spongepowered.common.interfaces.world.IMixinWorldServer) WorldSettings(net.minecraft.world.WorldSettings) IMixinChunkProviderServer(org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer) WorldProperties(org.spongepowered.api.world.storage.WorldProperties) ReportedException(net.minecraft.util.ReportedException) MinecraftException(net.minecraft.world.MinecraftException) IOException(java.io.IOException) PositionOutOfBoundsException(org.spongepowered.api.util.PositionOutOfBoundsException) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

WorldTimingsHandler (co.aikar.timings.WorldTimingsHandler)1 IOException (java.io.IOException)1 ReportedException (net.minecraft.util.ReportedException)1 MinecraftException (net.minecraft.world.MinecraftException)1 WorldServer (net.minecraft.world.WorldServer)1 WorldSettings (net.minecraft.world.WorldSettings)1 WorldInfo (net.minecraft.world.storage.WorldInfo)1 PositionOutOfBoundsException (org.spongepowered.api.util.PositionOutOfBoundsException)1 PortalAgentType (org.spongepowered.api.world.PortalAgentType)1 WorldProperties (org.spongepowered.api.world.storage.WorldProperties)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 IMixinWorldInfo (org.spongepowered.common.interfaces.world.IMixinWorldInfo)1 IMixinWorldServer (org.spongepowered.common.interfaces.world.IMixinWorldServer)1 IMixinChunkProviderServer (org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer)1 PlayerBorderListener (org.spongepowered.common.world.border.PlayerBorderListener)1