示例#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;
 }
示例#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);
 }
示例#3
0
 public void updateModuleData(int slot, NBTTagCompound tagCompound) {
   ItemStack stack = inventoryHelper.getStackInSlot(slot);
   stack.setTagCompound(tagCompound);
   screenModules = null;
   clientScreenModules = null;
   computerModules.clear();
   markDirty();
 }
示例#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();
 }
示例#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;
  }
示例#6
0
 @Override
 public void setInventorySlotContents(int index, ItemStack stack) {
   inventoryHelper.setInventorySlotContents(getInventoryStackLimit(), index, stack);
   resetModules();
 }
示例#7
0
 @Override
 public ItemStack decrStackSize(int index, int amount) {
   resetModules();
   return inventoryHelper.decrStackSize(index, amount);
 }
示例#8
0
 @Override
 public ItemStack getStackInSlot(int index) {
   return inventoryHelper.getStackInSlot(index);
 }
示例#9
0
 @Override
 public int getSizeInventory() {
   return inventoryHelper.getCount();
 }