EventHandlerClient.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:Blocksteps 作者:
@SubscribeEvent
public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent event)
{
    Blocksteps.eventHandler.targetAngleX = Blocksteps.eventHandler.prevAngleX = Blocksteps.eventHandler.angleX = Blocksteps.config.camStartVertical;
    Blocksteps.eventHandler.targetAngleY = Blocksteps.eventHandler.prevAngleY = Blocksteps.eventHandler.angleY = Blocksteps.eventHandler.oriAngleY = Blocksteps.config.camStartHorizontal;
    Blocksteps.eventHandler.targetScale = Blocksteps.config.camStartScale;
    Blocksteps.eventHandler.prevScale = Blocksteps.eventHandler.scale = 0;
    saveTimeout = Blocksteps.config.saveInterval;

    String connectionName = event.getManager().getRemoteAddress().toString();
    if(connectionName.contains("/") && !connectionName.startsWith("/192.168.")) //probably a public server
    {
        saveLocation = new File(new File(ResourceHelper.getModsFolder(), "/blocksteps/"), connectionName.substring(0, connectionName.indexOf("/")) + "_" + connectionName.substring(connectionName.indexOf(":") + 1, connectionName.length()) + ".bsv");
        if(saveLocation.exists())
        {
            try
            {
                byte[] data = new byte[(int)saveLocation.length()];
                FileInputStream stream = new FileInputStream(saveLocation);
                stream.read(data);
                stream.close();
                MapSaveFile save = (new Gson()).fromJson(IOUtil.decompress(data), MapSaveFile.class);
                save.load();
            }
            catch(Exception e)
            {
                Blocksteps.LOGGER.warn("Error loading save file: " + saveLocation);
            };
        }
    }
    else if(connectionName.startsWith("local") || connectionName.startsWith("/192.168."))
    {
        attemptLocalLoad = true;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号