aboutsummaryrefslogtreecommitdiff
path: root/me/Danker/TheMod.java
blob: 3e9aa3fd09b9eb796df4061ea3bde16b5da83744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package me.Danker;

import java.awt.Image;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod(modid = TheMod.MODID, version = TheMod.VERSION)
public class TheMod
{
    public static final String MODID = "Danker's Skyblock Mod";
    public static final String VERSION = "1.1";
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
		FMLCommonHandler.instance().bus().register(this);
		MinecraftForge.EVENT_BUS.register(this);
    }
    
    @EventHandler
    public void preInit(final FMLPreInitializationEvent event) {
    	ClientCommandHandler.instance.registerCommand(new ToggleCommand());
    }
    
    @SubscribeEvent
    public void onChat(final ClientChatReceivedEvent event) {
    	final ToggleCommand tc = new ToggleCommand();
    	final boolean isGPartyToggled = tc.getToggle("gparty");
    	String message = event.message.getUnformattedText();
    	String messagelc = message.toLowerCase();
    	
    	if (isGPartyToggled) {
    		if (messagelc.contains(" has invited all members of ")) {
    			try {
    				final SystemTray tray = SystemTray.getSystemTray();
    				final Image image = Toolkit.getDefaultToolkit().createImage("icon.png");
    				final TrayIcon trayIcon = new TrayIcon(image, "Guild Party Notifier");
    				trayIcon.setImageAutoSize(true);
    				trayIcon.setToolTip("Guild Party Notifier");
    				tray.add(trayIcon);
    				trayIcon.displayMessage("Guild Party", message, TrayIcon.MessageType.INFO);
    				tray.remove(trayIcon);
    			} catch (Exception ex) {
    				System.err.print(ex);
    			}
    		}
    	}
    	
    }
    
    @SubscribeEvent
    public void renderPlayerInfo(final RenderGameOverlayEvent.Post event) {
    	if (event.type != RenderGameOverlayEvent.ElementType.EXPERIENCE) return;
    	final ToggleCommand tc = new ToggleCommand();
    	final boolean isCoordsToggled = tc.getToggle("coords");
    	
    	if (isCoordsToggled) {
    		EntityPlayer player = Minecraft.getMinecraft().thePlayer;
        	double xDir = (player.rotationYaw % 360 + 360) % 360;
        	if (xDir > 180) xDir -= 360;
        	xDir = (double) Math.round(xDir * 10d) / 10d;
        	double yDir = (double) Math.round(player.rotationPitch * 10d) / 10d;
        	String text = (int) player.posX + " / " + (int) player.posY + " / " + (int) player.posZ + " (" + xDir + " / " + yDir + ")";
        	new CoordRenderer(Minecraft.getMinecraft(), text);
    	}
    	
    }
}