Send Dimension Data earlier to ensure players in spatial cells can login without crashing.
This commit is contained in:
parent
05974153d7
commit
333a0a653d
2 changed files with 27 additions and 12 deletions
|
@ -1,5 +1,7 @@
|
|||
package appeng.core;
|
||||
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -14,6 +16,7 @@ import java.util.WeakHashMap;
|
|||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
@ -280,23 +283,28 @@ public class WorldSettings extends Configuration
|
|||
return instance;
|
||||
}
|
||||
|
||||
public void sendToPlayer(EntityPlayerMP player)
|
||||
public void sendToPlayer(NetworkManager manager, EntityPlayerMP player)
|
||||
{
|
||||
if ( manager != null )
|
||||
{
|
||||
for (int newDim : get( "DimensionManager", "StorageCells", new int[0] ).getIntList())
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketNewStorageDimension( newDim ), player );
|
||||
manager.scheduleOutboundPacket( (new PacketNewStorageDimension( newDim )).getProxy(), new GenericFutureListener[0] );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
for (PlayerColor pc : TickHandler.instance.getPlayerColors().values())
|
||||
NetworkHandler.instance.sendToAll( pc.getPacket() );
|
||||
}
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|||
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
||||
import cpw.mods.fml.common.network.FMLEventChannel;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
|
@ -56,11 +57,17 @@ public class NetworkHandler
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConection(ServerConnectionFromClientEvent ev)
|
||||
{
|
||||
WorldSettings.getInstance().sendToPlayer( ev.manager, null );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConection(PlayerLoggedInEvent loginEvent)
|
||||
{
|
||||
if ( loginEvent.player instanceof EntityPlayerMP )
|
||||
WorldSettings.getInstance().sendToPlayer( (EntityPlayerMP) loginEvent.player );
|
||||
WorldSettings.getInstance().sendToPlayer( null, (EntityPlayerMP) loginEvent.player );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
Loading…
Reference in a new issue