implemented #48 & #49

This commit is contained in:
p455w0rd committed 2016-05-24 12:22:44 -04:00
1 parent 0c3d978885
commit 3cc6dc7bd0
15 files changed
+175 -18

No files matched your search

@@ -6,13 +6,11 @@ import net.minecraft.stats.Achievement;
import net.minecraft.stats.AchievementList;
import net.minecraftforge.common.AchievementPage;
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
import net.p455w0rd.wirelesscraftingterminal.items.ItemInfinityBooster;
public class AchievementHandler {
private static ItemInfinityBooster booster = (ItemInfinityBooster) ItemEnum.BOOSTER_ICON.getItem();
public static final Achievement wctAch = new Achievement("achievement.wctAchievement", "wctAchievement", 0, 0, new ItemStack(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem(), 1), (Achievement) null);
public static final Achievement boosterAch = new Achievement("achievment.boosterAchievement", "boosterAchievement", 0, 2, booster.hasEffect(true), wctAch);
public static final Achievement boosterAch = new Achievement("achievment.boosterAchievement", "boosterAchievement", 0, 2, ItemEnum.BOOSTER_ICON.getItem(), wctAch);
public static final Achievement magnetAch = new Achievement("achievement.magnetAchievement", "magnetAchievement", 2, 0, ItemEnum.MAGNET_CARD.getItem(), wctAch);
private static final AchievementPage achPage = new AchievementPage("Wireless Crafting Term", wctAch, boosterAch, magnetAch);
@@ -24,6 +24,7 @@ public class ConfigHandler {
public static int boosterDropChance = Reference.WCT_BOOSTER_DROPCHANCE;
public static boolean boosterDropsEnabled = Reference.WCT_BOOSTERDROP_ENABLED;
public static boolean mineTweakerOverride = Reference.WCT_MINETWEAKER_OVERRIDE;
public static boolean doVersionCheck = Reference.WCT_DOVERSIONCHECK;
private static boolean doSave;
public static boolean firstLoad = true;
private static int pwrInCfgFile, boosterDropInCfgFile;
@@ -51,10 +52,12 @@ public class ConfigHandler {
String boosterDropDesc = LocaleHandler.BoosterDropChance.getLocal();
String boosterDropEnabledDesc = LocaleHandler.DisableBoosterDrop.getLocal();
String mineTweakerOverrideDesc = LocaleHandler.MineTweakerOverride.getLocal();
String doVersionCheckDesc = LocaleHandler.DoVersionCheck.getLocal();
enableInfinityBooster = config.getBoolean("enableInfinityBooster", Configuration.CATEGORY_GENERAL, true, boosterDesc);
enableEasyMode = config.getBoolean("enableEasyMode", Configuration.CATEGORY_GENERAL, false, easyModeDesc);
boosterDropsEnabled = config.getBoolean("boosterDropsEnabled", Configuration.CATEGORY_GENERAL, true, boosterDropEnabledDesc);
mineTweakerOverride = config.getBoolean("mineTweakerOverride", Configuration.CATEGORY_GENERAL, false, mineTweakerOverrideDesc);
doVersionCheck = config.getBoolean("doVersionCheck", Configuration.CATEGORY_GENERAL, true, doVersionCheckDesc);
/*
* I did the max power cfg loading like this because while using
* Configuration#getInt did enforce the min/max values in-game, it
@@ -105,6 +108,7 @@ public class ConfigHandler {
Reference.WCT_BOOSTER_DROPCHANCE = boosterDropChance;
Reference.WCT_BOOSTERDROP_ENABLED = boosterDropsEnabled;
Reference.WCT_MINETWEAKER_OVERRIDE = mineTweakerOverride;
Reference.WCT_DOVERSIONCHECK = doVersionCheck;
if (config.hasChanged() || doSave) {
config.save();
@@ -4,12 +4,13 @@ import net.minecraft.util.StatCollector;
public enum LocaleHandler {
TitleDesc, InfinityBoosterDesc, WirelessTermLabel("gui.labels.ae2wct"),
MaxPowerDesc("config.ae2wct"), InfinityBoosterCfgDesc("config.ae2wct"), EasyModeDesc("config.ae2wct"),
TitleDesc, InfinityBoosterDesc, WirelessTermLabel("gui.labels.ae2wct"), DoVersionCheck("config.ae2wct"), NewVersionAvailable("config.ae2wct"),
MaxPowerDesc("config.ae2wct"), InfinityBoosterCfgDesc("config.ae2wct"), EasyModeDesc("config.ae2wct"), ClickString("config.ae2wct"),
MagnetDesc, MagnetDesc2, PressShift, OnlyWorks, LinkStatus, Installed, NotInstalled, Active, Inactive,
Status, EmptyTrash, EmptyTrashDesc, MagnetFilterTitle, NoNetworkPower("chatmessages.ae2wct"), InitializeMagnet("chatmessages.ae2wct"), FilterMode,
Whitelisting, Blacklisting, MagnetMode1("chatmessages.ae2wct"), MagnetMode2("chatmessages.ae2wct"), MagnetMode3("chatmessages.ae2wct"),
MagnetActiveDesc1, MagnetActiveDesc2, BoosterDropChance("config.ae2wct"), DisableBoosterDrop("config.ae2wct"), MineTweakerOverride("config.ae2wct");
MagnetActiveDesc1, MagnetActiveDesc2, BoosterDropChance("config.ae2wct"), DisableBoosterDrop("config.ae2wct"), MineTweakerOverride("config.ae2wct"),
Not, Using, Ignore, Ignoring, NBTData, MetaData, OreDict, FilteredItems, OrPress, Press, ToSwitchMode;
private final String root;
@@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
public enum ItemEnum {
BOOSTER_CARD("infinityBoosterCard", new ItemInfinityBooster().setUnlocalizedName("infinityBoosterCard")),
BOOSTER_ICON("infinityBoosterIcon", new ItemInfinityBooster().setUnlocalizedName("infinityBoosterIcon")),
BOOSTER_ICON("infinityBoosterIcon", new ItemInfinityBooster().hasEffect(true)),
WIRELESS_CRAFTING_TERMINAL("wirelessCraftingTerminal", new ItemWirelessCraftingTerminal()),
MAGNET_CARD("magnetCard", new ItemMagnet().setUnlocalizedName("magnetCard")),
WCT_BOOSTER_BG_ICON("boosterBG", new ItemBoosterBGIcon());
@@ -46,12 +46,13 @@ import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketMagnetFilter;
import net.p455w0rd.wirelesscraftingterminal.handlers.KeybindHandler;
import net.p455w0rd.wirelesscraftingterminal.handlers.LocaleHandler;
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
/**
* Jotato's amazing magnet item from QuantumFlux adpated for use in the Wireless
* Jotato's amazing magnet item from QuantumFlux adapted for use in the Wireless
* Crafting Terminal
*
* @author p455w0rd, Jotato
@@ -105,7 +106,7 @@ public class ItemMagnet extends Item {
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack is, EntityPlayer player, List list, boolean par4) {
list.add(color("aqua") + "==============================");
String shift = LocaleHandler.PressShift.getLocal().replace("Shift", color("yellow") + "" + color("bold") + "" + color("italics") + "Shift" + color("gray"));
String shift = LocaleHandler.PressShift.getLocal().replace("Shift", color("yellow") + color("bold") + color("italics") + "Shift" + color("gray"));
if (isShiftKeyDown()) {
String info = LocaleHandler.MagnetDesc.getLocal();
for (String line : Splitter.on("\n").split(WordUtils.wrap(info, 37, "\n", false))) {
@@ -113,10 +114,21 @@ public class ItemMagnet extends Item {
}
list.add("");
list.add(LocaleHandler.MagnetDesc2.getLocal());
list.add(color("italics") + "" + LocaleHandler.MagnetDesc2.getLocal());
if (isActivated(getItemStack())) {
String boundKey = Keyboard.getKeyName(KeybindHandler.openMagnetFilter.getKeyCode());
if (!boundKey.equals("NONE")) {
list.add(color("italics") + LocaleHandler.OrPress.getLocal() + " " + color("yellow") + color("bold") + "[" + boundKey + "]");
}
String boundKey2 = Keyboard.getKeyName(KeybindHandler.changeMagnetMode.getKeyCode());
if (!boundKey2.equals("NONE")) {
list.add(color("italics") + LocaleHandler.Press.getLocal() + " " + color("yellow") + color("bold") + "[" + boundKey2 + "] " + color("gray") + color("italics") + LocaleHandler.ToSwitchMode.getLocal());
}
}
list.add("");
list.add(LocaleHandler.Status.getLocal() + ": " + (isActivated(is) ? color("green") + "" + LocaleHandler.Active.getLocal() : color("red") + "" + LocaleHandler.Inactive.getLocal()));
list.add(LocaleHandler.Status.getLocal() + ": " + (isActivated(is) ? color("green") + LocaleHandler.Active.getLocal() : color("red") + LocaleHandler.Inactive.getLocal()));
if (is.getItemDamage() == 1) {
list.add(color("white") + " " + LocaleHandler.MagnetActiveDesc1.getLocal());
}
@@ -127,12 +139,31 @@ public class ItemMagnet extends Item {
String white = LocaleHandler.Whitelisting.getLocal();
String black = LocaleHandler.Blacklisting.getLocal();
list.add(LocaleHandler.FilterMode.getLocal() + ": " + color("white") + "" + (getMode(is) ? white : black));
list.add("");
list.add(LocaleHandler.FilterMode.getLocal() + ": " + color("white") + (getMode(is) ? white : black));
String not = LocaleHandler.Not.getLocal();
String ignoring = LocaleHandler.Ignoring.getLocal();
String nbtData = LocaleHandler.NBTData.getLocal();
String metaData = LocaleHandler.MetaData.getLocal();
String usingOreDict = LocaleHandler.Using.getLocal() + " " + LocaleHandler.OreDict.getLocal();
list.add((!doesMagnetUseOreDict() ? " " + not : color("green")) + " " + usingOreDict);
list.add((!doesMagnetIgnoreNBT() ? " " + not : color("green")) + " " + ignoring + " " + nbtData);
list.add((!doesMagnetIgnoreMeta() ? " " + not : color("green")) + " " + ignoring + " " + metaData);
List<ItemStack> filteredItems = getFilteredItems(getItemStack());
if (filteredItems != null) {
list.add("");
list.add(color("gray") + LocaleHandler.FilteredItems.getLocal() + ":");
for (int i = 0; i < filteredItems.size(); i++) {
list.add(" " + filteredItems.get(i).getDisplayName());
}
}
list.add("");
String onlyWorks = LocaleHandler.OnlyWorks.getLocal();
for (String line : Splitter.on("\n").split(WordUtils.wrap(onlyWorks, 27, "\n", false))) {
list.add(color("white") + "" + color("bold") + "" + color("italics") + "" + line.trim());
list.add(color("white") + color("bold") + color("italics") + line.trim());
}
}
@@ -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) {
@@ -1,7 +1,6 @@
package net.p455w0rd.wirelesscraftingterminal.proxy;
import java.util.Random;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -140,6 +139,7 @@ public class CommonProxy {
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);
NetworkHandler.instance.sendTo((WCTPacket) p, (EntityPlayerMP) e.player);
}
}
@SubscribeEvent
@@ -185,7 +185,7 @@ public class CommonProxy {
if (event.crafting.getItem() == ItemEnum.MAGNET_CARD.getItem()) {
AchievementHandler.triggerAch(magnetAch, event.player);
}
/*
* if (event.crafting.getItem() ==
* ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem()) {
@@ -17,6 +17,8 @@ public class Reference {
public static int WCT_BOOSTER_DROPCHANCE = 50;
public static boolean WCT_BOOSTERDROP_ENABLED = true;
public static boolean WCT_MINETWEAKER_OVERRIDE = false;
public static boolean WCT_DOVERSIONCHECK = true;
public static boolean WCT_HASCHECKEDVERSION = false;
// Gui IDs
private static int ae2wctGuiIndex = 0;