public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { DMPedestalTile tile = ((DMPedestalTile) world.getTileEntity(x, y, z)); if (player.isSneaking()) { player.openGui(PECore.instance, Constants.PEDESTAL_GUI, world, x, y, z); } else { if (tile.getItemStack() != null && tile.getItemStack().getItem() instanceof IPedestalItem) { tile.setActive(!tile.getActive()); } PELogger.logDebug("Pedestal: " + (tile.getActive() ? "ON" : "OFF")); } PacketHandler.sendToAllAround( new ClientSyncPedestalPKT(tile), new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32)); } return true; }
@Override public void run() { HttpURLConnection connection = null; BufferedReader reader = null; try { connection = (HttpURLConnection) new URL(changelogURL).openConnection(); connection.connect(); reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line = reader.readLine(); if (line == null) { PELogger.logFatal("Update check failed!"); throw new IOException("No data from github changelog!"); } String latestVersion; List<String> changes = Lists.newArrayList(); latestVersion = line.substring(11); latestVersion = latestVersion.trim(); while ((line = reader.readLine()) != null) { if (line.startsWith("###Version")) { break; } if (!line.isEmpty()) { line = line.substring(1).trim(); changes.add(line); } } if (!PECore.VERSION.equals(latestVersion)) { PELogger.logInfo( "Mod is outdated! Check " + curseURL + " to get the latest version (" + latestVersion + ")."); for (String s : changes) { PELogger.logInfo(s); } if (isServerSide) { ChangelogCMD.changelog.addAll(changes); } else { Minecraft.getMinecraft() .thePlayer .addChatMessage( new ChatComponentText( String.format( StatCollector.translateToLocal("pe.update.available"), latestVersion))); Minecraft.getMinecraft() .thePlayer .addChatMessage( new ChatComponentText(StatCollector.translateToLocal("pe.update.getit"))); IChatComponent link = new ChatComponentText(curseURL); link.getChatStyle() .setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, curseURL)); Minecraft.getMinecraft().thePlayer.addChatMessage(link); Minecraft.getMinecraft() .thePlayer .addChatMessage( new ChatComponentText(StatCollector.translateToLocal("pe.update.changelog"))); } } else { PELogger.logInfo("Mod is updated."); } } catch (Exception e) { PELogger.logFatal("Caught exception in Update Checker thread!"); e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { PELogger.logFatal("Caught exception in Update Checker thread!"); e.printStackTrace(); } } if (connection != null) { connection.disconnect(); } if (isServerSide) { hasRunServer = true; } else { hasRunClient = true; } } }