public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    if (!world.isRemote) {
      FMLNetworkHandler.openGui(player, Plague.instance, 8, world, x, y, z);
    }

    return true;
  }
  // temp
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (world.isRemote) {
      return true;
    }

    FMLNetworkHandler.openGui(
        player, Watercraft.instance, GuiHandler.FREEZER_GUI_ID, world, x, y, z);
    return true;
  }
예제 #3
0
 @Subscribe
 public void constructMod(FMLConstructionEvent event) {
   try {
     ModClassLoader modClassLoader = event.getModClassLoader();
     modClassLoader.addFile(source);
     // MCPC - show users what mod is being loaded in case a crash occurs
     FMLLog.fine("Constructing mod from file source : " + source);
     Class<?> clazz = Class.forName(className, true, modClassLoader);
     ASMDataTable asmHarvestedAnnotations = event.getASMHarvestedData();
     // TODO
     asmHarvestedAnnotations.getAnnotationsFor(this);
     annotations = gatherAnnotations(clazz);
     isNetworkMod =
         FMLNetworkHandler.instance().registerNetworkMod(this, clazz, event.getASMHarvestedData());
     modInstance = clazz.newInstance();
     ProxyInjector.inject(
         this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide());
     processFieldAnnotations(event.getASMHarvestedData());
   } catch (Throwable e) {
     controller.errorOccurred(this, e);
     Throwables.propagateIfPossible(e);
   }
 }
예제 #4
0
  @Subscribe
  public void constructMod(FMLConstructionEvent event) {
    try {
      ModClassLoader modClassLoader = event.getModClassLoader();
      modClassLoader.addFile(source);
      modClassLoader.clearNegativeCacheFor(candidate.getClassList());
      Class<?> clazz = Class.forName(className, true, modClassLoader);

      Certificate[] certificates = clazz.getProtectionDomain().getCodeSource().getCertificates();
      int len = 0;
      if (certificates != null) {
        len = certificates.length;
      }
      Builder<String> certBuilder = ImmutableList.<String>builder();
      for (int i = 0; i < len; i++) {
        certBuilder.add(CertificateHelper.getFingerprint(certificates[i]));
      }

      ImmutableList<String> certList = certBuilder.build();
      sourceFingerprints = ImmutableSet.copyOf(certList);

      String expectedFingerprint = (String) descriptor.get("certificateFingerprint");

      fingerprintNotPresent = true;

      if (expectedFingerprint != null && !expectedFingerprint.isEmpty()) {
        if (!sourceFingerprints.contains(expectedFingerprint)) {
          Level warnLevel = Level.SEVERE;
          if (source.isDirectory()) {
            warnLevel = Level.FINER;
          }
          FMLLog.log(
              getModId(),
              warnLevel,
              "The mod %s is expecting signature %s for source %s, however there is no signature matching that description",
              getModId(),
              expectedFingerprint,
              source.getName());
        } else {
          certificate = certificates[certList.indexOf(expectedFingerprint)];
          fingerprintNotPresent = false;
        }
      }

      CustomProperty[] props = (CustomProperty[]) descriptor.get("customProperties");
      if (props != null && props.length > 0) {
        com.google.common.collect.ImmutableMap.Builder<String, String> builder =
            ImmutableMap.<String, String>builder();
        for (CustomProperty p : props) {
          builder.put(p.k(), p.v());
        }
        customModProperties = builder.build();
      } else {
        customModProperties = EMPTY_PROPERTIES;
      }

      Method factoryMethod = gatherAnnotations(clazz);
      modInstance = getLanguageAdapter().getNewInstance(this, clazz, modClassLoader, factoryMethod);
      isNetworkMod =
          FMLNetworkHandler.instance().registerNetworkMod(this, clazz, event.getASMHarvestedData());
      if (fingerprintNotPresent) {
        eventBus.post(
            new FMLFingerprintViolationEvent(
                source.isDirectory(),
                source,
                ImmutableSet.copyOf(this.sourceFingerprints),
                expectedFingerprint));
      }
      ProxyInjector.inject(
          this,
          event.getASMHarvestedData(),
          FMLCommonHandler.instance().getSide(),
          getLanguageAdapter());
      processFieldAnnotations(event.getASMHarvestedData());
    } catch (Throwable e) {
      controller.errorOccurred(this, e);
      Throwables.propagateIfPossible(e);
    }
  }