Exemplo n.º 1
0
 private static void sendPacket(Packet230ModLoader packet230modloader) {
   if (packet230Received
       && ModLoader.getMinecraftInstance().field_71441_e != null
       && ModLoader.getMinecraftInstance().field_71441_e.field_72995_K) {
     ModLoader.getMinecraftInstance().func_71391_r().func_72552_c(packet230modloader);
   }
 }
Exemplo n.º 2
0
 private static void handleTileEntityPacket(Packet230ModLoader packet230modloader) {
   if (packet230modloader.dataInt == null || packet230modloader.dataInt.length < 5) {
     log("Bad TileEntityPacket received.");
   } else {
     int i = packet230modloader.dataInt[0];
     int j = packet230modloader.dataInt[1];
     int k = packet230modloader.dataInt[2];
     int l = packet230modloader.dataInt[3];
     int i1 = packet230modloader.dataInt[4];
     int ai[] = new int[packet230modloader.dataInt.length - 5];
     System.arraycopy(packet230modloader.dataInt, 5, ai, 0, packet230modloader.dataInt.length - 5);
     float af[] = packet230modloader.dataFloat;
     String as[] = packet230modloader.dataString;
     for (int j1 = 0; j1 < ModLoader.getLoadedMods().size(); j1++) {
       BaseMod basemod = (BaseMod) ModLoader.getLoadedMods().get(j1);
       if (!(basemod instanceof BaseModMp)) {
         continue;
       }
       BaseModMp basemodmp = (BaseModMp) basemod;
       if (basemodmp.getId() != i) {
         continue;
       }
       basemodmp.handleTileEntityPacket(j, k, l, i1, ai, af, as);
       break;
     }
   }
 }
Exemplo n.º 3
0
  private static void handleModCheck(Packet230ModLoader packet230modloader) {
    Packet230ModLoader packet230modloader1 = new Packet230ModLoader();
    packet230modloader1.modId = "ModLoaderMP".hashCode();
    packet230modloader1.packetType = 0;
    packet230modloader1.dataString = new String[ModLoader.getLoadedMods().size()];
    for (int i = 0; i < ModLoader.getLoadedMods().size(); i++) {
      packet230modloader1.dataString[i] = ((BaseMod) ModLoader.getLoadedMods().get(i)).toString();
    }

    sendPacket(packet230modloader1);
  }
Exemplo n.º 4
0
 public static void handleGUI(Packet100OpenWindow packet100openwindow) {
   if (!hasInit) {
     initializePrivate();
   }
   BaseModMp basemodmp =
       (BaseModMp) guiModMap.get(Integer.valueOf(packet100openwindow.field_73429_b));
   GuiScreen guiscreen = basemodmp.handleGUI(packet100openwindow.field_73429_b);
   if (guiscreen != null) {
     ModLoader.openGUI(ModLoader.getMinecraftInstance().field_71439_g, guiscreen);
     ModLoader.getMinecraftInstance().field_71439_g.field_71070_bA.field_75152_c =
         packet100openwindow.field_73431_a;
   }
 }
Exemplo n.º 5
0
  public static BaseModMp getModInstance(Class class1) {
    for (int i = 0; i < ModLoader.getLoadedMods().size(); i++) {
      BaseMod basemod = (BaseMod) ModLoader.getLoadedMods().get(i);
      if (!(basemod instanceof BaseModMp)) {
        continue;
      }
      BaseModMp basemodmp = (BaseModMp) basemod;
      if (class1.isInstance(basemodmp)) {
        return (BaseModMp) ModLoader.getLoadedMods().get(i);
      }
    }

    return null;
  }
Exemplo n.º 6
0
 public static void sendPacket(BaseModMp basemodmp, Packet230ModLoader packet230modloader) {
   if (!hasInit) {
     initializePrivate();
   }
   if (basemodmp == null) {
     IllegalArgumentException illegalargumentexception =
         new IllegalArgumentException("baseModMp cannot be null.");
     ModLoader.getLogger().throwing("ModLoaderMp", "SendPacket", illegalargumentexception);
     ModLoader.throwException("baseModMp cannot be null.", illegalargumentexception);
   } else {
     packet230modloader.modId = basemodmp.getId();
     sendPacket(packet230modloader);
   }
 }
Exemplo n.º 7
0
 public static void sendKey(BaseModMp basemodmp, int i) {
   if (!hasInit) {
     initializePrivate();
   }
   if (basemodmp == null) {
     IllegalArgumentException illegalargumentexception =
         new IllegalArgumentException("baseModMp cannot be null.");
     ModLoader.getLogger().throwing("ModLoaderMp", "SendKey", illegalargumentexception);
     ModLoader.throwException("baseModMp cannot be null.", illegalargumentexception);
   } else {
     Packet230ModLoader packet230modloader = new Packet230ModLoader();
     packet230modloader.modId = "ModLoaderMP".hashCode();
     packet230modloader.packetType = 1;
     packet230modloader.dataInt = (new int[] {basemodmp.getId(), i});
     sendPacket(packet230modloader);
   }
 }
Exemplo n.º 8
0
 private static void initializePrivate() {
   hasInit = true;
   try {
     Method method;
     try {
       method =
           (net.minecraft.src.Packet.class)
               .getDeclaredMethod(
                   "a",
                   new Class[] {Integer.TYPE, Boolean.TYPE, Boolean.TYPE, java.lang.Class.class});
     } catch (NoSuchMethodException nosuchmethodexception1) {
       method =
           (net.minecraft.src.Packet.class)
               .getDeclaredMethod(
                   "addIdClassMapping",
                   new Class[] {Integer.TYPE, Boolean.TYPE, Boolean.TYPE, java.lang.Class.class});
     }
     method.setAccessible(true);
     method.invoke(
         null,
         new Object[] {
           Integer.valueOf(230),
           Boolean.valueOf(true),
           Boolean.valueOf(true),
           net.minecraft.src.Packet230ModLoader.class
         });
   } catch (IllegalAccessException illegalaccessexception) {
     ModLoader.getLogger().throwing("ModLoaderMp", "init", illegalaccessexception);
     ModLoader.throwException("An impossible error has occurred!", illegalaccessexception);
   } catch (IllegalArgumentException illegalargumentexception) {
     ModLoader.getLogger().throwing("ModLoaderMp", "init", illegalargumentexception);
     ModLoader.throwException("An impossible error has occurred!", illegalargumentexception);
   } catch (InvocationTargetException invocationtargetexception) {
     ModLoader.getLogger().throwing("ModLoaderMp", "init", invocationtargetexception);
     ModLoader.throwException("An impossible error has occurred!", invocationtargetexception);
   } catch (NoSuchMethodException nosuchmethodexception) {
     ModLoader.getLogger().throwing("ModLoaderMp", "init", nosuchmethodexception);
     ModLoader.throwException("An impossible error has occurred!", nosuchmethodexception);
   } catch (SecurityException securityexception) {
     ModLoader.getLogger().throwing("ModLoaderMp", "init", securityexception);
     ModLoader.throwException("An impossible error has occurred!", securityexception);
   }
   log("ModLoaderMP 1.3.1v1 Initialized");
 }
Exemplo n.º 9
0
  public static void handleAllPackets(Packet230ModLoader packet230modloader) {
    if (!hasInit) {
      initializePrivate();
    }
    packet230Received = true;
    if (packet230modloader.modId == "ModLoaderMP".hashCode()) {
      switch (packet230modloader.packetType) {
        case 0: // '\0'
          handleModCheck(packet230modloader);
          break;

        case 1: // '\001'
          handleTileEntityPacket(packet230modloader);
          break;
      }
    } else if (packet230modloader.modId == "Spawn".hashCode()) {
      NetClientHandlerEntity netclienthandlerentity =
          handleNetClientHandlerEntities(packet230modloader.packetType);
      if (netclienthandlerentity != null
          && (net.minecraft.src.ISpawnable.class)
              .isAssignableFrom(netclienthandlerentity.entityClass)) {
        try {
          Entity entity =
              (Entity)
                  netclienthandlerentity
                      .entityClass
                      .getConstructor(new Class[] {net.minecraft.src.World.class})
                      .newInstance(new Object[] {ModLoader.getMinecraftInstance().field_71441_e});
          ((ISpawnable) entity).spawn(packet230modloader);
          ModLoader.getMinecraftInstance().field_71441_e.func_73027_a(entity.field_70157_k, entity);
        } catch (Exception exception) {
          ModLoader.getLogger().throwing("ModLoader", "handleCustomSpawn", exception);
          ModLoader.throwException(
              String.format(
                  "Error initializing entity of type %s.",
                  new Object[] {Integer.valueOf(packet230modloader.packetType)}),
              exception);
          return;
        }
      }
    } else {
      for (int i = 0; i < ModLoader.getLoadedMods().size(); i++) {
        BaseMod basemod = (BaseMod) ModLoader.getLoadedMods().get(i);
        if (!(basemod instanceof BaseModMp)) {
          continue;
        }
        BaseModMp basemodmp = (BaseModMp) basemod;
        if (basemodmp.getId() != packet230modloader.modId) {
          continue;
        }
        basemodmp.handlePacket(packet230modloader);
        break;
      }
    }
  }
Exemplo n.º 10
0
 public static void log(String s) {
   System.out.println(s);
   ModLoader.getLogger().fine(s);
 }