This commit is contained in:
p455w0rd committed 2016-05-25 00:50:04 -04:00
1 parent 2b106a5075
commit 8616616891
7 files changed
+77 -52

No files matched your search

@@ -0,0 +1,69 @@
package net.p455w0rd.wirelesscraftingterminal.handlers;
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 cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
public class VersionCheckHandler {
int timer = 150;
public VersionCheckHandler() {
FMLCommonHandler.instance().bus().register(this);
}
@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);
}
else {
FMLCommonHandler.instance().bus().unregister(this);
}
}
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/latestversionrv3.txt")).openStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
return r.readLine();
}
catch (MalformedURLException ignored) {
return Reference.VERSION;
}
catch (IOException ignored) {
return Reference.VERSION;
}
}
}
@@ -6,6 +6,7 @@ import java.util.List;
import appeng.api.AEApi;
import appeng.api.storage.data.IAEItemStack;
import appeng.integration.modules.NEIHelpers.NEIAEShapelessRecipeHandler;
import appeng.util.Platform;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -61,6 +62,7 @@ public class NEI implements INEI, IContainerTooltipHandler, IIntegrationModule {
API.registerGuiOverlay(net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal.class, "crafting", new WCTSlotPositioner());
API.registerGuiOverlayHandler(net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal.class, new WCTOverlayHandler(), "crafting");
API.registerRecipeHandler(new NEIAEShapedRecipeHandler());
API.registerRecipeHandler( new NEIAEShapelessRecipeHandler() );
/*
final Method registerGuiOverlay = this.apiClass.getDeclaredMethod("registerGuiOverlay", Class.class, String.class, IStackPositioner.class);
@@ -1,9 +1,7 @@
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;
@@ -17,24 +15,16 @@ 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);
@@ -54,45 +44,6 @@ 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/latestversionrv3.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) {
@@ -27,6 +27,7 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketConfigSync;
import net.p455w0rd.wirelesscraftingterminal.handlers.AchievementHandler;
import net.p455w0rd.wirelesscraftingterminal.handlers.ConfigHandler;
import net.p455w0rd.wirelesscraftingterminal.handlers.VersionCheckHandler;
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
import net.p455w0rd.wirelesscraftingterminal.items.ItemMagnet;
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
@@ -134,6 +135,7 @@ public class CommonProxy {
* AchievementHandler.addAchievementToPage(AchievementHandler.
* boosterAch, true, e.player); }
*/
new VersionCheckHandler();
}
else {
final PacketConfigSync p = new PacketConfigSync(Reference.WCT_MAX_POWER, Reference.WCT_EASYMODE_ENABLED, Reference.WCT_BOOSTER_ENABLED, Reference.WCT_BOOSTER_DROPCHANCE, Reference.WCT_MINETWEAKER_OVERRIDE);