diff options
Diffstat (limited to 'me')
-rw-r--r-- | me/Danker/CoordRenderer.java | 13 | ||||
-rw-r--r-- | me/Danker/TheMod.java | 82 | ||||
-rw-r--r-- | me/Danker/ToggleCommand.java | 55 |
3 files changed, 150 insertions, 0 deletions
diff --git a/me/Danker/CoordRenderer.java b/me/Danker/CoordRenderer.java new file mode 100644 index 0000000..66cdb5e --- /dev/null +++ b/me/Danker/CoordRenderer.java @@ -0,0 +1,13 @@ +package me.Danker;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.ScaledResolution;
+
+public class CoordRenderer extends Gui {
+ public CoordRenderer(Minecraft mc, String text) {
+ ScaledResolution scaled = new ScaledResolution(mc);
+ int height = scaled.getScaledHeight();
+ drawString(mc.fontRendererObj, text, 5, height - 25, Integer.parseInt("FFFFFF", 16));
+ }
+}
diff --git a/me/Danker/TheMod.java b/me/Danker/TheMod.java new file mode 100644 index 0000000..3e9aa3f --- /dev/null +++ b/me/Danker/TheMod.java @@ -0,0 +1,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); + } + + } +} diff --git a/me/Danker/ToggleCommand.java b/me/Danker/ToggleCommand.java new file mode 100644 index 0000000..d24c399 --- /dev/null +++ b/me/Danker/ToggleCommand.java @@ -0,0 +1,55 @@ +package me.Danker;
+
+import net.minecraft.command.CommandBase;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommand;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.ChatComponentText;
+
+public class ToggleCommand extends CommandBase implements ICommand {
+ private static boolean gpartyToggled = true;
+ private static boolean coordsToggled = true;
+
+ public boolean getToggle(String type) {
+ if (type.equals("gparty")) {
+ return gpartyToggled;
+ } else if (type.equals("coords")) {
+ return coordsToggled;
+ }
+ return true;
+ }
+
+ @Override
+ public String getCommandName() {
+ return "toggle";
+ }
+
+ @Override
+ public String getCommandUsage(ICommandSender arg0) {
+ return getCommandName() + " [gparty/coords]";
+ }
+
+ @Override
+ public int getRequiredPermissionLevel() {
+ return 0;
+ }
+
+ @Override
+ public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException {
+ final EntityPlayer player = (EntityPlayer)arg0;
+
+ if (arg1.length == 0) {
+ player.addChatMessage(new ChatComponentText("Usage: /toggle [gparty/coords]"));
+ return;
+ }
+
+ if (arg1[0].equalsIgnoreCase("gparty")) {
+ gpartyToggled = !gpartyToggled;
+ player.addChatMessage(new ChatComponentText("Guild party notifications has been set to " + gpartyToggled + "."));
+ } else if (arg1[0].equalsIgnoreCase("coords")) {
+ coordsToggled = !coordsToggled;
+ player.addChatMessage(new ChatComponentText("Coord/Angle display has been set to " + coordsToggled + "."));
+ }
+ }
+}
|