Skip to content

Commit b2a4069

Browse files
committed
Merge pull request #71 from TPPI-Dev/Dev
Merge for TPPI 1.0.4
2 parents d0f0439 + 43727d3 commit b2a4069

File tree

18 files changed

+373
-109
lines changed

18 files changed

+373
-109
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ if (System.getenv().ARTIFACT_VERSION != null) {
4848

4949
version = "MC${config.minecraft_version}-${artifact_version}-${buildInfo.buildNum}"
5050
def actualVersion = "${artifact_version}-${buildInfo.buildNum}"
51+
archivesBaseName = "TPPI-Tweaks"
5152

5253
minecraft {
5354
version = "1.6.4-9.11.1.964"
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package tppitweaks.client.gui;
2+
3+
import java.util.List;
4+
5+
import net.minecraft.client.Minecraft;
6+
import net.minecraft.client.gui.GuiButton;
7+
import net.minecraft.client.gui.GuiScreen;
8+
import net.minecraft.util.ResourceLocation;
9+
10+
import org.lwjgl.opengl.GL11;
11+
12+
import tppitweaks.TPPITweaks;
13+
import tppitweaks.config.ConfigurationHandler;
14+
15+
public class IRCGui extends GuiScreen
16+
{
17+
private boolean configState;
18+
private static final ResourceLocation bg = new ResourceLocation("tppitweaks", "textures/gui/TPPI.png");
19+
20+
@SuppressWarnings("unchecked")
21+
@Override
22+
public void initGui()
23+
{
24+
this.buttonList.add(new GuiButton(0, this.width / 2 - 144, this.height / 2 + 40, 140, 20, "Enable this Feature"));
25+
this.buttonList.add(new GuiButton(1, this.width / 2 + 4, this.height / 2 + 40, 140, 20, "Disable this Feature"));
26+
this.buttonList.add(new GuiButton(2, this.width / 2 - 144, this.height / 2 + 68, 140, 20, "Exit the Game"));
27+
this.buttonList.add(new GuiButton(3, this.width / 2 + 4, this.height / 2 + 68, 140, 20, "Continue to the Game"));
28+
this.buttonList.add(new GuiButton(4, this.width / 2 - 144, this.height / 2 + 96, 288, 20, "Don't Show this Again"));
29+
30+
((GuiButton) this.buttonList.get(2)).enabled = false;
31+
configState = Boolean.parseBoolean(ConfigurationHandler.manuallyGetConfigValue("EiraIRC.cfg", "B:autoConnect"));
32+
((GuiButton) this.buttonList.get(0)).enabled = !configState;
33+
((GuiButton) this.buttonList.get(1)).enabled = configState;
34+
}
35+
36+
@Override
37+
public void drawScreen(int par1, int par2, float par3)
38+
{
39+
drawCustomBackground(0);
40+
41+
this.drawCenteredString(this.mc.fontRenderer, "This version of TPPI adds a new IRC feature!", this.width / 2, this.height / 2 - 105, 0xFFFFFF);
42+
this.drawCenteredString(this.mc.fontRenderer, "Anyone playing the pack is able to live chat", this.width / 2, this.height / 2 - 90, 0xFFFFFF);
43+
this.drawCenteredString(this.mc.fontRenderer, "with anyone else simultaneously.", this.width / 2, this.height / 2 - 80, 0xFFFFFF);
44+
this.drawCenteredString(this.mc.fontRenderer, "If you do not desire this feature,", this.width / 2, this.height / 2 - 65, 0xFFFFFF);
45+
this.drawCenteredString(this.mc.fontRenderer, "this is your chance to opt-out.", this.width / 2, this.height / 2 - 55, 0xFFFFFF);
46+
this.drawCenteredString(this.mc.fontRenderer, "To do this, hit \"Disable this Feature\",", this.width / 2, this.height / 2 - 40, 0xFFFFFF);
47+
this.drawCenteredString(this.mc.fontRenderer, "and then restart the game.", this.width / 2, this.height / 2 - 30, 0xFFFFFF);
48+
this.drawCenteredString(this.mc.fontRenderer, "If you wish to leave this feature enabled,", this.width / 2, this.height / 2 - 15, 0xFFFFFF);
49+
this.drawCenteredString(this.mc.fontRenderer, "simply hit \"Continue to the Game\"", this.width / 2, this.height / 2 - 5, 0xFFFFFF);
50+
this.drawCenteredString(this.mc.fontRenderer, "\"Don't show this again\" will prevent this GUI", this.width / 2, this.height / 2 + 10, 0xFFFFFF);
51+
this.drawCenteredString(this.mc.fontRenderer, "from showing in the future.", this.width / 2, this.height / 2 + 20, 0xFFFFFF);
52+
super.drawScreen(par1, par2, par3);
53+
}
54+
55+
@SuppressWarnings("unchecked")
56+
@Override
57+
protected void actionPerformed(GuiButton button)
58+
{
59+
switch (button.id)
60+
{
61+
case 0:
62+
button.enabled = false;
63+
if (ConfigurationHandler.manuallyChangeConfigValue("EiraIRC.cfg", "B:autoConnect", "false", "true"))
64+
{
65+
((GuiButton) buttonList.get(3)).enabled = configState;
66+
((GuiButton) buttonList.get(2)).enabled = !configState;
67+
}
68+
((GuiButton) buttonList.get(1)).enabled = true;
69+
break;
70+
case 1:
71+
button.enabled = false;
72+
if (ConfigurationHandler.manuallyChangeConfigValue("EiraIRC.cfg", "B:autoConnect", "true", "false"))
73+
{
74+
((GuiButton) buttonList.get(3)).enabled = !configState;
75+
((GuiButton) buttonList.get(2)).enabled = configState;
76+
}
77+
((GuiButton) buttonList.get(0)).enabled = true;
78+
break;
79+
case 2:
80+
TPPITweaks.logger.info("Shutting down!");
81+
Minecraft.getMinecraft().shutdown();
82+
break;
83+
case 3:
84+
this.mc.displayGuiScreen(null);
85+
break;
86+
case 4:
87+
dontShowAgain();
88+
for (GuiButton b : (List<GuiButton>) buttonList)
89+
{
90+
if (b.id != 3 && b.id != 2)
91+
b.enabled = false;
92+
}
93+
break;
94+
default:
95+
return;
96+
}
97+
}
98+
99+
@Override
100+
protected void keyTyped(char par1, int par2)
101+
{
102+
; // do nothing
103+
}
104+
105+
private void dontShowAgain()
106+
{
107+
TPPITweaks.logger.info("Disabling IRC GUI...");
108+
ConfigurationHandler.manuallyChangeConfigValue("B:showIRCGui", "true", "false");
109+
}
110+
111+
private void drawCustomBackground(int par1)
112+
{
113+
GL11.glDisable(GL11.GL_LIGHTING);
114+
GL11.glDisable(GL11.GL_FOG);
115+
this.mc.getTextureManager().bindTexture(bg);
116+
GL11.glColor4f(0.18f, 0.18f, 0.18f, 1.0F);
117+
this.drawTexturedModalRect(0, 0, 240, 240, this.width, this.height);
118+
}
119+
}

src/main/java/tppitweaks/client/gui/UpdateGui.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,10 @@ public void initGui()
6161
{
6262
if (noShow)
6363
{
64-
System.out.println("not opening GUI");
64+
TPPITweaks.logger.info("not opening GUI");
6565
this.mc.displayGuiScreen(this.parentScreen);
6666
return;
6767
}
68-
else
69-
{
70-
71-
}
7268

7369
// Unsure exactly what this does but...it seems necessary
7470
Keyboard.enableRepeatEvents(true);

src/main/java/tppitweaks/command/CommandTPPI.java

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void initValidCommandArguments(InputStream file)
4545
validCommands.add("changelog");
4646
validCommands.add("guide");
4747
validCommands.add("removeBooks");
48-
48+
4949
supportedModsAndList.add("list");
5050

5151
supportedModsAndList.addAll(TxtParser.getSupportedMods(file));
@@ -72,7 +72,7 @@ public String getCommandUsage(ICommandSender icommandsender)
7272
{
7373
return "tppi <arg>";
7474
}
75-
75+
7676
@Override
7777
public boolean canCommandSenderUseCommand(ICommandSender par1iCommandSender)
7878
{
@@ -111,15 +111,25 @@ public void processCommand(ICommandSender icommandsender, String[] astring)
111111
else if (astring[0].equalsIgnoreCase("mods"))
112112
{
113113
processCommandMods(icommandsender, astring);
114-
}else if(astring[0].equalsIgnoreCase("ores")) {
114+
}
115+
else if (astring[0].equalsIgnoreCase("ores"))
116+
{
115117
processVanillaBookCommand("TPPI Ore Generation Guide", "OreGen.txt", icommandsender, astring);
116-
}else if(astring[0].equalsIgnoreCase("getInvolved")) {
118+
}
119+
else if (astring[0].equalsIgnoreCase("getInvolved"))
120+
{
117121
processVanillaBookCommand("Getting Involved In TPPI", "GetInvolved.txt", icommandsender, astring);
118-
}else if(astring[0].equalsIgnoreCase("changelog")) {
122+
}
123+
else if (astring[0].equalsIgnoreCase("changelog"))
124+
{
119125
processCommandChangelog(icommandsender);
120-
}else if(astring[0].equalsIgnoreCase("guide")) {
126+
}
127+
else if (astring[0].equalsIgnoreCase("guide"))
128+
{
121129
processCommandGuide(icommandsender);
122-
}else if(astring[0].equalsIgnoreCase("removeBooks")) {
130+
}
131+
else if (astring[0].equalsIgnoreCase("removeBooks"))
132+
{
123133
removeGuideBooks(icommandsender);
124134
}
125135

@@ -141,34 +151,39 @@ else if (astring[0].equalsIgnoreCase("mods"))
141151

142152
}
143153

144-
private void removeGuideBooks(ICommandSender command) {
154+
private void removeGuideBooks(ICommandSender command)
155+
{
145156
EntityPlayer player = command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName());
146157
ItemStack[] inv = player.inventory.mainInventory;
147158
for (int i = 0; i < inv.length; i++)
148159
{
149160
if (inv[i] != null && // no null itemstack
150-
inv[i].stackTagCompound != null && // no null stack tag
151-
inv[i].stackTagCompound.toString().contains(ConfigurationHandler.bookAuthor) && // has the author
152-
inv[i].itemID == Item.writtenBook.itemID) // is a vanilla book
153-
154-
inv[i] = null;
161+
inv[i].stackTagCompound != null && // no null stack tag
162+
inv[i].stackTagCompound.toString().contains(ConfigurationHandler.bookAuthor) && // has
163+
// the
164+
// author
165+
inv[i].itemID == Item.writtenBook.itemID) // is a vanilla
166+
// book
167+
168+
inv[i] = null;
155169
}
156170
}
157171

158172
private void processCommandGuide(ICommandSender command)
159173
{
160174
ItemStack stack = new ItemStack(ModItems.tppiBook, 1, 2);
161-
175+
162176
if (!command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).inventory.addItemStackToInventory(stack))
163177
command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).entityDropItem(stack, 0);
164178
}
165179

166-
private void processVanillaBookCommand(String title, String textFileName, ICommandSender command, String[] astring) {
167-
168-
InputStream file = TPPITweaks.class.getResourceAsStream("/assets/tppitweaks/lang/"+textFileName);
180+
private void processVanillaBookCommand(String title, String textFileName, ICommandSender command, String[] astring)
181+
{
182+
183+
InputStream file = TPPITweaks.class.getResourceAsStream("/assets/tppitweaks/lang/" + textFileName);
169184
List<String> vanillaBookText = file == null ? new ArrayList<String>() : TxtParser.parseFileMain(file);
170185
ItemStack book = new ItemStack(Item.writtenBook);
171-
186+
172187
book.setTagInfo("author", new NBTTagString("author", ConfigurationHandler.bookAuthor));
173188
book.setTagInfo("title", new NBTTagString("title", title));
174189

@@ -182,10 +197,10 @@ private void processVanillaBookCommand(String title, String textFileName, IComma
182197

183198
nbttagcompound.setTag("pages", bookPages);
184199
nbttagcompound.setString("version", TPPITweaks.VERSION);
185-
200+
186201
if (!command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).inventory.addItemStackToInventory(book))
187202
command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).entityDropItem(book, 0);
188-
203+
189204
}
190205

191206
private boolean processCommandMods(ICommandSender command, String[] args)
@@ -233,20 +248,21 @@ private boolean processCommandDownload(ICommandSender command, String[] args)
233248
PacketDispatcher.sendPacketToPlayer(packet, (Player) command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()));
234249
return true;
235250
}
236-
251+
237252
return false;
238253
}
239-
254+
240255
private boolean processCommandChangelog(ICommandSender command)
241256
{
242257
ItemStack changelog = ModItems.tppiBook.getChangelog();
243-
258+
244259
if (changelog == null)
245260
return false;
246-
247-
if (!command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).inventory.addItemStackToInventory(changelog));
248-
command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).entityDropItem(changelog, 0);
249-
261+
262+
if (!command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).inventory.addItemStackToInventory(changelog))
263+
;
264+
command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).entityDropItem(changelog, 0);
265+
250266
return true;
251267
}
252268

@@ -283,7 +299,7 @@ private void giveModBook(String modName, ICommandSender command)
283299
NBTTagList bookPages = new NBTTagList("pages");
284300

285301
ArrayList<String> pages;
286-
302+
287303
pages = TxtParser.parseFileMods(FileLoader.getSupportedModsFile(), modName + ", " + properName);
288304

289305
if (pages.get(0).startsWith("<") && pages.get(0).endsWith("> "))
@@ -302,21 +318,18 @@ private void giveModBook(String modName, ICommandSender command)
302318
if (!command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).inventory.addItemStackToInventory(stack))
303319
command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).entityDropItem(stack, 0);
304320
}
305-
321+
306322
public static String getProperName(String modid)
307323
{
308324
return modProperNames.get(modid);
309325
}
310-
311-
@Override
312-
public int compareTo(Object arg0)
313-
{
314-
return this.compareTo((ICommand) arg0);
315-
}
316326

317327
@Override
318-
public boolean equals(Object obj)
319-
{
320-
return this.compareTo(obj) == 0;
321-
}
328+
public int compareTo(Object o) {
329+
if (o instanceof ICommand) {
330+
return this.compareTo((ICommand) o);
331+
} else {
332+
return 0;
333+
}
334+
}
322335
}

0 commit comments

Comments
 (0)