示例#1
0
 private void hitScreenServer(int x, int y, int module) {
   List<ScreenModule> screenModules = getScreenModules();
   ScreenModule screenModule = screenModules.get(module);
   if (screenModule != null) {
     screenModule.mouseClick(worldObj, x, y, true);
     clickedModules.add(new ActivatedModule(module, 5, x, y));
   }
 }
示例#2
0
 // This is called server side.
 public Map<Integer, Object[]> getScreenData(long millis) {
   Map<Integer, Object[]> map = new HashMap<Integer, Object[]>();
   List<ScreenModule> screenModules = getScreenModules();
   int moduleIndex = 0;
   for (ScreenModule module : screenModules) {
     if (module != null) {
       Object[] data = module.getData(worldObj, millis);
       if (data != null) {
         map.put(moduleIndex, data);
       }
     }
     moduleIndex++;
   }
   return map;
 }
示例#3
0
  // This is called server side.
  public List<ScreenModule> getScreenModules() {
    if (screenModules == null) {
      totalRfPerTick = 0;
      screenModules = new ArrayList<ScreenModule>();
      for (int i = 0; i < inventoryHelper.getCount(); i++) {
        ItemStack itemStack = inventoryHelper.getStackInSlot(i);
        if (itemStack != null && itemStack.getItem() instanceof ModuleProvider) {
          ModuleProvider moduleProvider = (ModuleProvider) itemStack.getItem();
          ScreenModule screenModule;
          try {
            screenModule = moduleProvider.getServerScreenModule().newInstance();
          } catch (InstantiationException e) {
            e.printStackTrace();
            continue;
          } catch (IllegalAccessException e) {
            e.printStackTrace();
            continue;
          }
          screenModule.setupFromNBT(
              itemStack.getTagCompound(), worldObj.provider.dimensionId, xCoord, yCoord, zCoord);
          screenModules.add(screenModule);
          totalRfPerTick += screenModule.getRfPerTick();

          if (screenModule instanceof ComputerScreenModule) {
            ComputerScreenModule computerScreenModule = (ComputerScreenModule) screenModule;
            String tag = computerScreenModule.getTag();
            if (!computerModules.containsKey(tag)) {
              computerModules.put(tag, new ArrayList<ComputerScreenModule>());
            }
            computerModules.get(tag).add(computerScreenModule);
          }
        } else {
          screenModules.add(
              null); // To keep the indexing correct so that the modules correspond with there slot
                     // number.
        }
      }
    }
    return screenModules;
  }