Permalink
Browse files

Initial idea/commit

  • Loading branch information...
1 parent 28562b6 commit 47cc4e17d9500cc0eba0302fcd13ba2b37834b98 @DerFlash DerFlash committed Nov 6, 2012
Showing with 126 additions and 0 deletions.
  1. +25 −0 VanishPotionEffect.java
  2. +101 −0 mod_VanishStatus.java
View
@@ -0,0 +1,25 @@
+package net.minecraft.src;
+
+public class VanishPotionEffect extends PotionEffect {
+
+ static int specialAmp = 3;
+
+ public VanishPotionEffect() {
+ super(Potion.invisibility.getId(), 0, specialAmp);
+ }
+
+ public String getEffectName()
+ {
+ return "Vanish";
+ }
+
+ public String toString() {
+ return "Vanish";
+ }
+
+ public int getAmplifier()
+ {
+ return specialAmp;
+ }
+
+}
View
@@ -0,0 +1,101 @@
+package net.minecraft.src;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Scanner;
+import java.util.logging.Level;
+import org.lwjgl.opengl.GL11;
+import net.minecraft.client.Minecraft;
+
+public class mod_VanishStatus extends BaseMod
+{
+
+ boolean isVanished = false;
+
+ public mod_VanishStatus()
+ {
+ }
+
+ public String getName()
+ {
+ return "VanishStatus";
+ }
+
+ public String getVersion()
+ {
+ return "v1.0";
+ }
+
+ public void load()
+ {
+ ModLoader.setInGameHook(this, true, false);
+ ModLoader.registerPacketChannel(this, "vanishStatus");
+
+ }
+
+ public boolean onTickInGame(float f, Minecraft mc)
+ {
+ if((mc.inGameHasFocus || mc.currentScreen == null) && !mc.gameSettings.showDebugInfo && !mc.gameSettings.keyBindPlayerList.pressed)
+ {
+
+ int potionFakeIndex = 1337;
+ boolean hasVanishPotion = mc.thePlayer.activePotionsMap.containsKey(potionFakeIndex);
+
+ if (isVanished && !hasVanishPotion)
+ {
+ mc.thePlayer.activePotionsMap.put(potionFakeIndex, new VanishPotionEffect());
+ }
+ else if (!isVanished && hasVanishPotion)
+ {
+ mc.thePlayer.activePotionsMap.remove(potionFakeIndex);
+ }
+
+ }
+ return true;
+ }
+
+ public static void sendMessage(String channel, String message) {
+ Packet250CustomPayload plugin = new Packet250CustomPayload();
+ plugin.channel = channel;
+ plugin.data = message.getBytes();
+ plugin.length = message.length();
+ ModLoader.getMinecraftInstance().getSendQueue().addToSendQueue(plugin);
+ }
+
+
+ // ModLoader @ MC 1.2.5
+ public void receiveCustomPacket(Packet250CustomPayload packet250custompayload)
+ {
+ if (packet250custompayload.channel.equalsIgnoreCase("vanishStatus"))
+ {
+ handleMCMessage(new String(packet250custompayload.data));
+ }
+ }
+
+ // ModLoader @ MC 1.3+
+ public void clientCustomPayload(NetClientHandler clientHandler, Packet250CustomPayload packet250custompayload)
+ {
+ receiveCustomPacket(packet250custompayload);
+ }
+
+ private void handleMCMessage(String message)
+ {
+ System.out.println("[VanishStatus] Got a message: " + message);
+ isVanished = message.equalsIgnoreCase("vanishActive");
+ }
+
+ // ModLoader @ MC 1.2.5
+ public void serverConnect(NetClientHandler netclienthandler) {
+ sendMessage("vanishStatus", "check");
+ }
+
+ // ModLoader @ MC 1.3+
+ public void clientConnect(NetClientHandler netclienthandler) {
+ serverConnect(netclienthandler);
+ }
+
+}

0 comments on commit 47cc4e1

Please sign in to comment.