Exemplo n.º 1
0
 // This is called client side.
 public List<ClientScreenModule> getClientScreenModules() {
   if (clientScreenModules == null) {
     needsServerData = false;
     clientScreenModules = new ArrayList<ClientScreenModule>();
     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();
         ClientScreenModule clientScreenModule;
         try {
           clientScreenModule = moduleProvider.getClientScreenModule().newInstance();
         } catch (InstantiationException e) {
           e.printStackTrace();
           continue;
         } catch (IllegalAccessException e) {
           e.printStackTrace();
           continue;
         }
         clientScreenModule.setupFromNBT(
             itemStack.getTagCompound(), worldObj.provider.dimensionId, xCoord, yCoord, zCoord);
         clientScreenModules.add(clientScreenModule);
         if (clientScreenModule.needsServerData()) {
           needsServerData = true;
         }
       } else {
         clientScreenModules.add(
             null); // To keep the indexing correct so that the modules correspond with there slot
                    // number.
       }
     }
   }
   return clientScreenModules;
 }
Exemplo n.º 2
0
 private void writeBufferToNBT(NBTTagCompound tagCompound) {
   NBTTagList bufferTagList = new NBTTagList();
   for (int i = ScreenContainer.SLOT_MODULES; i < inventoryHelper.getCount(); i++) {
     ItemStack stack = inventoryHelper.getStackInSlot(i);
     NBTTagCompound nbtTagCompound = new NBTTagCompound();
     if (stack != null) {
       stack.writeToNBT(nbtTagCompound);
     }
     bufferTagList.appendTag(nbtTagCompound);
   }
   tagCompound.setTag("Items", bufferTagList);
 }
Exemplo n.º 3
0
 public void updateModuleData(int slot, NBTTagCompound tagCompound) {
   ItemStack stack = inventoryHelper.getStackInSlot(slot);
   stack.setTagCompound(tagCompound);
   screenModules = null;
   clientScreenModules = null;
   computerModules.clear();
   markDirty();
 }
Exemplo n.º 4
0
 private void readBufferFromNBT(NBTTagCompound tagCompound) {
   NBTTagList bufferTagList = tagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
   for (int i = 0; i < bufferTagList.tagCount(); i++) {
     NBTTagCompound nbtTagCompound = bufferTagList.getCompoundTagAt(i);
     inventoryHelper.setStackInSlot(
         i + ScreenContainer.SLOT_MODULES, ItemStack.loadItemStackFromNBT(nbtTagCompound));
   }
   resetModules();
 }
Exemplo n.º 5
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;
  }
Exemplo n.º 6
0
 @Override
 public void setInventorySlotContents(int index, ItemStack stack) {
   inventoryHelper.setInventorySlotContents(getInventoryStackLimit(), index, stack);
   resetModules();
 }
Exemplo n.º 7
0
 @Override
 public ItemStack decrStackSize(int index, int amount) {
   resetModules();
   return inventoryHelper.decrStackSize(index, amount);
 }
Exemplo n.º 8
0
 @Override
 public ItemStack getStackInSlot(int index) {
   return inventoryHelper.getStackInSlot(index);
 }
Exemplo n.º 9
0
 @Override
 public int getSizeInventory() {
   return inventoryHelper.getCount();
 }