mirror of
https://github.com/GTNewHorizons/WirelessCraftingTerminal.git
synced 2026-11-20 03:59:42 +00:00
1 parent
0c3d978885
commit
3cc6dc7bd0
15 files changed
+175
-18
No files matched your search
@@ -1,7 +1,9 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.proxy;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
@@ -15,16 +17,24 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.p455w0rd.wirelesscraftingterminal.handlers.KeybindHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.handlers.LocaleHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
int timer = 150;
|
||||
|
||||
public ClientProxy() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
@@ -44,6 +54,45 @@ public class ClientProxy extends CommonProxy {
|
||||
// No renderers...yet =]
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void tickStart(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) {
|
||||
return;
|
||||
}
|
||||
if (Reference.WCT_DOVERSIONCHECK && !Reference.WCT_HASCHECKEDVERSION) {
|
||||
if (timer > 0) {
|
||||
timer--;
|
||||
return;
|
||||
}
|
||||
checkVersion(event.player);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkVersion(EntityPlayer player) {
|
||||
if (!fetchVersion().equals(Reference.VERSION) && !Reference.WCT_HASCHECKEDVERSION) {
|
||||
Reference.WCT_HASCHECKEDVERSION = true;
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + "-=-=-=-=-=[" + EnumChatFormatting.WHITE + "Wireless Crafting Terminal" + EnumChatFormatting.BLUE + "]=-=-=-=-=-"));
|
||||
player.addChatMessage(new ChatComponentText(LocaleHandler.NewVersionAvailable.getLocal()));
|
||||
IChatComponent component = IChatComponent.Serializer.func_150699_a(LocaleHandler.ClickString.getLocal());
|
||||
player.addChatComponentMessage(component);
|
||||
player.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"));
|
||||
}
|
||||
}
|
||||
|
||||
private String fetchVersion() {
|
||||
try {
|
||||
InputStream in = new URL(new String("https://raw.githubusercontent.com/p455w0rd/WirelessCraftingTerminal/master/latestversion.txt")).openStream();
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(in));
|
||||
return r.readLine();
|
||||
}
|
||||
catch (MalformedURLException ignored) {
|
||||
return Reference.VERSION;
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
return Reference.VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderPlayer(RenderPlayerEvent.Specials.Pre event) {
|
||||
if (Reference.WCT_DIDTHEDIDDLE) {
|
||||
|
||||
Reference in new issue
Block a user