66import java .awt .TrayIcon ;
77import java .util .List ;
88
9+ import me .Danker .commands .DisplayCommand ;
10+ import me .Danker .commands .GetkeyCommand ;
11+ import me .Danker .commands .LootCommand ;
12+ import me .Danker .commands .ReloadConfigCommand ;
13+ import me .Danker .commands .SetkeyCommand ;
14+ import me .Danker .commands .ToggleCommand ;
15+ import me .Danker .handlers .ConfigHandler ;
16+ import me .Danker .handlers .ScoreboardHandler ;
17+ import me .Danker .handlers .TextRenderer ;
918import net .minecraft .client .Minecraft ;
1019import net .minecraft .client .gui .ScaledResolution ;
20+ import net .minecraft .entity .item .EntityItem ;
1121import net .minecraft .entity .player .EntityPlayer ;
22+ import net .minecraft .util .AxisAlignedBB ;
23+ import net .minecraft .util .ChatComponentText ;
24+ import net .minecraft .util .EnumChatFormatting ;
25+ import net .minecraft .util .StringUtils ;
1226import net .minecraftforge .client .ClientCommandHandler ;
1327import net .minecraftforge .client .event .ClientChatReceivedEvent ;
1428import net .minecraftforge .client .event .RenderGameOverlayEvent ;
29+ import net .minecraftforge .client .event .sound .PlaySoundEvent ;
1530import net .minecraftforge .common .MinecraftForge ;
16- import net .minecraftforge .event .entity .living .LivingDropsEvent ;
1731import net .minecraftforge .fml .common .FMLCommonHandler ;
1832import net .minecraftforge .fml .common .Mod ;
1933import net .minecraftforge .fml .common .Mod .EventHandler ;
2034import net .minecraftforge .fml .common .event .FMLInitializationEvent ;
2135import net .minecraftforge .fml .common .event .FMLPreInitializationEvent ;
2236import net .minecraftforge .fml .common .eventhandler .SubscribeEvent ;
2337
24- @ Mod (modid = TheMod .MODID , version = TheMod .VERSION )
38+ @ Mod (modid = TheMod .MODID , version = TheMod .VERSION , clientSideOnly = true )
2539public class TheMod
2640{
2741 public static final String MODID = "Danker's Skyblock Mod" ;
28- public static final String VERSION = "1.3" ;
42+ public static final String VERSION = "1.4" ;
43+
44+ static int checkItemsNow = 0 ;
45+ static int itemsChecked = 0 ;
2946
3047 @ EventHandler
3148 public void init (FMLInitializationEvent event )
3249 {
3350 FMLCommonHandler .instance ().bus ().register (this );
3451 MinecraftForge .EVENT_BUS .register (this );
3552
36- // Config init
3753 final ConfigHandler cf = new ConfigHandler ();
38- if (!cf .hasKey ("toggles" , "GParty" )) cf .writeBooleanConfig ("toggles" , "GParty" , true );
39- if (!cf .hasKey ("toggles" , "Coords" )) cf .writeBooleanConfig ("toggles" , "Coords" , true );
40- if (!cf .hasKey ("api" , "APIKey" )) cf .writeStringConfig ("api" , "APIKey" , "" );
41-
42- // Wolf Loot
43- if (!cf .hasKey ("wolf" , "svens" )) cf .writeIntConfig ("wolf" , "svens" , 0 );
44- if (!cf .hasKey ("wolf" , "spirit" )) cf .writeIntConfig ("wolf" , "spirit" , 0 );
45- if (!cf .hasKey ("wolf" , "book" )) cf .writeIntConfig ("wolf" , "book" , 0 );
46- if (!cf .hasKey ("wolf" , "egg" )) cf .writeIntConfig ("wolf" , "egg" , 0 );
47- if (!cf .hasKey ("wolf" , "couture" )) cf .writeIntConfig ("wolf" , "couture" , 0 );
48- if (!cf .hasKey ("wolf" , "bait" )) cf .writeIntConfig ("wolf" , "bait" , 0 );
49- if (!cf .hasKey ("wolf" , "flux" )) cf .writeIntConfig ("wolf" , "flux" , 0 );
50- if (!cf .hasKey ("wolf" , "timeRNG" )) cf .writeIntConfig ("wolf" , "timeRNG" , -1 );
51- if (!cf .hasKey ("wolf" , "bossRNG" )) cf .writeIntConfig ("wolf" , "bossRNG" , -1 );
52- // Spider Loot
53- if (!cf .hasKey ("spider" , "tarantulas" )) cf .writeIntConfig ("spider" , "tarantulas" , 0 );
54- if (!cf .hasKey ("spider" , "bite" )) cf .writeIntConfig ("spider" , "bite" , 0 );
55- if (!cf .hasKey ("spider" , "catalyst" )) cf .writeIntConfig ("spider" , "catalyst" , 0 );
56- if (!cf .hasKey ("spider" , "book" )) cf .writeIntConfig ("spider" , "book" , 0 );
57- if (!cf .hasKey ("spider" , "swatter" )) cf .writeIntConfig ("spider" , "swatter" , 0 );
58- if (!cf .hasKey ("spider" , "talisman" )) cf .writeIntConfig ("spider" , "talisman" , 0 );
59- if (!cf .hasKey ("spider" , "mosquito" )) cf .writeIntConfig ("spider" , "mosquito" , 0 );
60- if (!cf .hasKey ("spider" , "timeRNG" )) cf .writeIntConfig ("spider" , "timeRNG" , -1 );
61- if (!cf .hasKey ("spider" , "bossRNG" )) cf .writeIntConfig ("spider" , "bossRNG" , -1 );
62- // Zombie Loot
63- if (!cf .hasKey ("zombie" , "revs" )) cf .writeIntConfig ("zombie" , "revs" , 0 );
64- if (!cf .hasKey ("zombie" , "pestilence" )) cf .writeIntConfig ("zombie" , "pestilence" , 0 );
65- if (!cf .hasKey ("zombie" , "undeadCatalyst" )) cf .writeIntConfig ("zombie" , "undeadCatalyst" , 0 );
66- if (!cf .hasKey ("zombie" , "book" )) cf .writeIntConfig ("zombie" , "book" , 0 );
67- if (!cf .hasKey ("zombie" , "beheaded" )) cf .writeIntConfig ("zombie" , "beheaded" , 0 );
68- if (!cf .hasKey ("zombie" , "revCatalyst" )) cf .writeIntConfig ("zombie" , "revCatalyst" , 0 );
69- if (!cf .hasKey ("zombie" , "snake" )) cf .writeIntConfig ("zombie" , "snake" , 0 );
70- if (!cf .hasKey ("zombie" , "scythe" )) cf .writeIntConfig ("zombie" , "scythe" , 0 );
71- if (!cf .hasKey ("zombie" , "timeRNG" )) cf .writeIntConfig ("zombie" , "timeRNG" , -1 );
72- if (!cf .hasKey ("zombie" , "bossRNG" )) cf .writeIntConfig ("zombie" , "bossRNG" , -1 );
73-
74- final ToggleCommand tf = new ToggleCommand ();
75- tf .gpartyToggled = cf .getBoolean ("toggles" , "GParty" );
76- tf .coordsToggled = cf .getBoolean ("toggles" , "Coords" );
77-
78- final LootCommand lc = new LootCommand ();
79- // Wolf
80- lc .wolfSvens = cf .getInt ("wolf" , "svens" );
81- lc .wolfSpirits = cf .getInt ("wolf" , "spirit" );
82- lc .wolfBooks = cf .getInt ("wolf" , "book" );
83- lc .wolfEggs = cf .getInt ("wolf" , "egg" );
84- lc .wolfCoutures = cf .getInt ("wolf" , "couture" );
85- lc .wolfBaits = cf .getInt ("wolf" , "bait" );
86- lc .wolfFluxes = cf .getInt ("wolf" , "flux" );
87- lc .wolfTime = cf .getInt ("wolf" , "timeRNG" );
88- lc .wolfBosses = cf .getInt ("wolf" , "bossRNG" );
89- // Spider
90- lc .spiderTarantulas = cf .getInt ("spider" , "tarantulas" );
91- lc .spiderBites = cf .getInt ("spider" , "bite" );
92- lc .spiderCatalysts = cf .getInt ("spider" , "catalyst" );
93- lc .spiderBooks = cf .getInt ("spider" , "book" );
94- lc .spiderSwatters = cf .getInt ("spider" , "swatter" );
95- lc .spiderTalismans = cf .getInt ("spider" , "talisman" );
96- lc .spiderMosquitos = cf .getInt ("spider" , "mosquito" );
97- lc .spiderTime = cf .getInt ("spider" , "timeRNG" );
98- lc .spiderBosses = cf .getInt ("spider" , "bossRNG" );
99- // Zombie
100- lc .zombieRevs = cf .getInt ("zombie" , "revs" );
101- lc .zombiePestilences = cf .getInt ("zombie" , "pestilence" );
102- lc .zombieUndeadCatas = cf .getInt ("zombie" , "undeadCatalyst" );
103- lc .zombieBooks = cf .getInt ("zombie" , "book" );
104- lc .zombieBeheadeds = cf .getInt ("zombie" , "beheaded" );
105- lc .zombieRevCatas = cf .getInt ("zombie" , "revCatalyst" );
106- lc .zombieSnakes = cf .getInt ("zombie" , "snake" );
107- lc .zombieScythes = cf .getInt ("zombie" , "scythe" );
108- lc .zombieTime = cf .getInt ("zombie" , "timeRNG" );
109- lc .zombieBosses = cf .getInt ("zombie" , "bossRNG" );
110-
54+ cf .reloadConfig ();
11155 }
11256
11357 @ EventHandler
@@ -116,6 +60,8 @@ public void preInit(final FMLPreInitializationEvent event) {
11660 ClientCommandHandler .instance .registerCommand (new SetkeyCommand ());
11761 ClientCommandHandler .instance .registerCommand (new GetkeyCommand ());
11862 ClientCommandHandler .instance .registerCommand (new LootCommand ());
63+ ClientCommandHandler .instance .registerCommand (new ReloadConfigCommand ());
64+ ClientCommandHandler .instance .registerCommand (new DisplayCommand ());
11965 }
12066
12167 @ SubscribeEvent
@@ -143,8 +89,6 @@ public void onChat(final ClientChatReceivedEvent event) {
14389 }
14490 }
14591
146- // Time is stored as a 32-bit int in seconds, so if Skyblock
147- // survives until 2038, I'll just update it then
14892 final LootCommand lc = new LootCommand ();
14993 final ConfigHandler cf = new ConfigHandler ();
15094 boolean wolfRNG = false ;
@@ -270,6 +214,8 @@ public void onChat(final ClientChatReceivedEvent event) {
270214 cf .writeIntConfig ("zombie" , "scythe" , lc .zombieScythes );
271215 }
272216
217+ // Time is stored in seconds, so if Skyblock
218+ // survives until 2038, I'll just update it then
273219 if (wolfRNG ) {
274220 lc .wolfTime = (int ) System .currentTimeMillis () / 1000 ;
275221 lc .wolfBosses = 0 ;
@@ -325,6 +271,170 @@ public void renderPlayerInfo(final RenderGameOverlayEvent.Post event) {
325271 int height = scaled .getScaledHeight ();
326272 new TextRenderer (Minecraft .getMinecraft (), coordText , 5 , height - 25 , Integer .parseInt ("FFFFFF" , 16 ));
327273 }
274+
275+ final DisplayCommand ds = new DisplayCommand ();
276+ final String displayToggle = ds .display ;
277+
278+ if (!displayToggle .equals ("off" )) {
279+ final LootCommand lc = new LootCommand ();
280+ String dropsText = "" ;
281+ String countText = "" ;
282+ String timeBetween = "Never" ;
283+ String bossesBetween = "Never" ;
284+ int timeNow = (int ) System .currentTimeMillis () / 1000 ;
285+
286+ if (displayToggle .equals ("wolf" )) {
287+ if (lc .wolfTime == -1 ) {
288+ timeBetween = "Never" ;
289+ } else {
290+ timeBetween = lc .getTimeBetween (lc .wolfTime , timeNow );
291+ }
292+ if (lc .wolfBosses == -1 ) {
293+ bossesBetween = "Never" ;
294+ } else {
295+ bossesBetween = Integer .toString (lc .wolfBosses );
296+ }
297+
298+ dropsText = EnumChatFormatting .GOLD + "Svens Killed:\n " +
299+ EnumChatFormatting .GREEN + "Wolf Teeth:\n " +
300+ EnumChatFormatting .BLUE + "Hamster Wheels:\n " +
301+ EnumChatFormatting .AQUA + "Spirit Runes:\n " +
302+ EnumChatFormatting .WHITE + "Critical VI Books:\n " +
303+ EnumChatFormatting .DARK_RED + "Red Claw Eggs:\n " +
304+ EnumChatFormatting .GOLD + "Couture Runes:\n " +
305+ EnumChatFormatting .AQUA + "Grizzly Baits:\n " +
306+ EnumChatFormatting .DARK_PURPLE + "Overfluxes:\n " +
307+ EnumChatFormatting .AQUA + "Time Since RNG:\n " +
308+ EnumChatFormatting .AQUA + "Bosses Since RNG:\n " ;
309+ countText = EnumChatFormatting .GOLD + "" + lc .wolfSvens + "\n " +
310+ EnumChatFormatting .GREEN + lc .wolfTeeth + "\n " +
311+ EnumChatFormatting .BLUE + lc .wolfWheels + "\n " +
312+ EnumChatFormatting .AQUA + lc .wolfSpirits + "\n " +
313+ EnumChatFormatting .WHITE + lc .wolfBooks + "\n " +
314+ EnumChatFormatting .DARK_RED + lc .wolfEggs + "\n " +
315+ EnumChatFormatting .GOLD + lc .wolfCoutures + "\n " +
316+ EnumChatFormatting .AQUA + lc .wolfBaits + "\n " +
317+ EnumChatFormatting .DARK_PURPLE + lc .wolfFluxes + "\n " +
318+ EnumChatFormatting .AQUA + timeBetween + "\n " +
319+ EnumChatFormatting .AQUA + bossesBetween + "\n " ;
320+ } else if (displayToggle .equals ("spider" )) {
321+ if (lc .spiderTime == -1 ) {
322+ timeBetween = "Never" ;
323+ } else {
324+ timeBetween = lc .getTimeBetween (lc .spiderTime , timeNow );
325+ }
326+ if (lc .spiderBosses == -1 ) {
327+ bossesBetween = "Never" ;
328+ } else {
329+ bossesBetween = Integer .toString (lc .spiderBosses );
330+ }
331+
332+ dropsText = EnumChatFormatting .GOLD + "Tarantulas Killed:\n " +
333+ EnumChatFormatting .GREEN + "Tarantula Webs:\n " +
334+ EnumChatFormatting .DARK_GREEN + "Arrow Poison:\n " +
335+ EnumChatFormatting .DARK_GRAY + "Bite Runes:\n " +
336+ EnumChatFormatting .WHITE + "Bane VI Books:\n " +
337+ EnumChatFormatting .AQUA + "Spider Catalysts:\n " +
338+ EnumChatFormatting .DARK_PURPLE + "Tarantula Talismans:\n " +
339+ EnumChatFormatting .LIGHT_PURPLE + "Fly Swatters:\n " +
340+ EnumChatFormatting .GOLD + "Digested Mosquitos:\n " +
341+ EnumChatFormatting .AQUA + "Time Since RNG:\n " +
342+ EnumChatFormatting .AQUA + "Bosses Since RNG:\n " ;
343+ countText = EnumChatFormatting .GOLD + "" + lc .spiderTarantulas + "\n " +
344+ EnumChatFormatting .GREEN + lc .spiderWebs + "\n " +
345+ EnumChatFormatting .DARK_GREEN + lc .spiderTAP + "\n " +
346+ EnumChatFormatting .DARK_GRAY + lc .spiderBites + "\n " +
347+ EnumChatFormatting .WHITE + lc .spiderBooks + "\n " +
348+ EnumChatFormatting .AQUA + lc .spiderCatalysts + "\n " +
349+ EnumChatFormatting .DARK_PURPLE + lc .spiderTalismans + "\n " +
350+ EnumChatFormatting .LIGHT_PURPLE + lc .spiderSwatters + "\n " +
351+ EnumChatFormatting .GOLD + lc .spiderMosquitos + "\n " +
352+ EnumChatFormatting .AQUA + timeBetween + "\n " +
353+ EnumChatFormatting .AQUA + bossesBetween + "\n " ;
354+ } else {
355+ // Zombie
356+ dropsText = EnumChatFormatting .GOLD + "Revs Killed:\n " +
357+ EnumChatFormatting .GREEN + "Revenant Flesh:\n " +
358+ EnumChatFormatting .BLUE + "Foul Flesh:\n " +
359+ EnumChatFormatting .DARK_GREEN + "Pestilence Runes:\n " +
360+ EnumChatFormatting .WHITE + "Smite VI Books:\n " +
361+ EnumChatFormatting .AQUA + "Undead Catalysts:\n " +
362+ EnumChatFormatting .DARK_PURPLE + "Beheaded Horrors:\n " +
363+ EnumChatFormatting .RED + "Revenant Catalysts:\n " +
364+ EnumChatFormatting .DARK_GREEN + "Snake Runes:\n " +
365+ EnumChatFormatting .GOLD + "Scythe Blades:\n " +
366+ EnumChatFormatting .AQUA + "Time Since RNG:\n " +
367+ EnumChatFormatting .AQUA + "Bosses Since RNG:\n " ;
368+ countText = EnumChatFormatting .GOLD + "" + lc .zombieRevs + "\n " +
369+ EnumChatFormatting .GREEN + lc .zombieRevFlesh + "\n " +
370+ EnumChatFormatting .BLUE + lc .zombieFoulFlesh + "\n " +
371+ EnumChatFormatting .DARK_GREEN + lc .zombiePestilences + "\n " +
372+ EnumChatFormatting .WHITE + lc .zombieBooks + "\n " +
373+ EnumChatFormatting .AQUA + lc .zombieUndeadCatas + "\n " +
374+ EnumChatFormatting .DARK_PURPLE + lc .zombieBeheadeds + "\n " +
375+ EnumChatFormatting .RED + lc .zombieRevCatas + "\n " +
376+ EnumChatFormatting .DARK_GREEN + lc .zombieSnakes + "\n " +
377+ EnumChatFormatting .GOLD + lc .zombieScythes + "\n " +
378+ EnumChatFormatting .AQUA + timeBetween + "\n " +
379+ EnumChatFormatting .AQUA + bossesBetween + "\n " ;
380+ }
381+ new TextRenderer (Minecraft .getMinecraft (), dropsText , 80 , 5 , Integer .parseInt ("FFFFFF" , 16 ));
382+ new TextRenderer (Minecraft .getMinecraft (), countText , 190 , 5 , Integer .parseInt ("FFFFFF" , 16 ));
383+ }
384+ }
385+
386+ @ SubscribeEvent
387+ public void onSound (final PlaySoundEvent event ) {
388+ if (event .name .equals ("note.pling" )) {
389+ // Don't check twice within 5 seconds
390+ checkItemsNow = (int ) System .currentTimeMillis () / 1000 ;
391+ if (checkItemsNow - itemsChecked <= 5 ) return ;
392+
393+ final ScoreboardHandler sc = new ScoreboardHandler ();
394+ List <String > scoreboard = sc .getSidebarLines ();
395+
396+ for (String line : scoreboard ) {
397+ String cleanedLine = sc .cleanSB (line );
398+ if (cleanedLine .contains ("Boss slain!" )) {
399+ final LootCommand lc = new LootCommand ();
400+ final ConfigHandler cf = new ConfigHandler ();
401+
402+ itemsChecked = (int ) System .currentTimeMillis () / 1000 ;
403+
404+ lc .wolfTeeth += getItems ("Wolf Teeth" );
405+ lc .wolfWheels += getItems ("Hamster Wheel" );
406+ lc .spiderWebs += getItems ("Tarantula Web" );
407+ lc .spiderTAP += getItems ("Toxic Arrow Poison" );
408+ lc .zombieRevFlesh += getItems ("Revenant Flesh" );
409+ lc .zombieFoulFlesh += getItems ("Foul Flesh" );
410+
411+ cf .writeIntConfig ("wolf" , "teeth" , lc .wolfTeeth );
412+ cf .writeIntConfig ("wolf" , "wheel" , lc .wolfWheels );
413+ cf .writeIntConfig ("spider" , "web" , lc .spiderWebs );
414+ cf .writeIntConfig ("spider" , "tap" , lc .spiderTAP );
415+ cf .writeIntConfig ("zombie" , "revFlesh" , lc .zombieRevFlesh );
416+ cf .writeIntConfig ("zombie" , "foulFlesh" , lc .zombieFoulFlesh );
417+ }
418+ }
419+ }
420+ }
421+
422+ public int getItems (String item ) {
423+ Minecraft mc = Minecraft .getMinecraft ();
424+ EntityPlayer player = mc .thePlayer ;
425+
426+ double x = player .posX ;
427+ double y = player .posY ;
428+ double z = player .posZ ;
429+ AxisAlignedBB scan = new AxisAlignedBB (x - 6 , y - 6 , z - 6 , x + 6 , y + 6 , z + 6 );
430+ List <EntityItem > items = mc .theWorld .getEntitiesWithinAABB (EntityItem .class , scan );
431+
432+ for (EntityItem i : items ) {
433+ String itemName = StringUtils .stripControlCodes (i .getEntityItem ().getDisplayName ());
434+ if (itemName .equals (item )) return i .getEntityItem ().stackSize ;
435+ }
436+ // No items found
437+ return 0 ;
328438 }
329439
330440}
0 commit comments