Пример #1
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");
 }
Пример #2
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;
      }
    }
  }
Пример #3
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);
   }
 }
Пример #4
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);
   }
 }