Package mekanism.common.inventory

Examples of mekanism.common.inventory.InventoryElectricChest


      else {
        ItemStack stack = entityplayer.getCurrentEquippedItem();

        if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST)
        {
          InventoryElectricChest inventory = new InventoryElectricChest(entityplayer);
          FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, inventory));
          entityplayer.openContainer.windowId = windowId;
        }
      }
    }
View Full Code Here


   
    if(type == MachineType.ELECTRIC_CHEST)
    {
      if(world != null && !world.isRemote)
      {
        InventoryElectricChest inv = new InventoryElectricChest(itemstack);

        if(inv.getStackInSlot(54) != null && getEnergy(itemstack) < getMaxEnergy(itemstack))
        {
          if(inv.getStackInSlot(54).getItem() instanceof IEnergizedItem)
          {
            setEnergy(itemstack, getEnergy(itemstack) + EnergizedItemManager.discharge(inv.getStackInSlot(54), getMaxEnergy(itemstack) - getEnergy(itemstack)));
          }
          else if(MekanismUtils.useIC2() && inv.getStackInSlot(54).getItem() instanceof IElectricItem)
          {
            IElectricItem item = (IElectricItem)inv.getStackInSlot(54).getItem();

            if(item.canProvideEnergy(inv.getStackInSlot(54)))
            {
              double gain = ElectricItem.manager.discharge(inv.getStackInSlot(54), (int)((getMaxEnergy(itemstack) - getEnergy(itemstack))*Mekanism.TO_IC2), 3, false, true, false)*Mekanism.FROM_IC2;
              setEnergy(itemstack, getEnergy(itemstack) + gain);
            }
          }
          else if(MekanismUtils.useRF() && inv.getStackInSlot(54).getItem() instanceof IEnergyContainerItem)
          {
            ItemStack itemStack = inv.getStackInSlot(54);
            IEnergyContainerItem item = (IEnergyContainerItem)inv.getStackInSlot(54).getItem();

            int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getEnergyStored(itemStack)));
            int toTransfer = (int)Math.round(Math.min(itemEnergy, ((getMaxEnergy(itemstack) - getEnergy(itemstack))*Mekanism.TO_TE)));

            setEnergy(itemstack, getEnergy(itemstack) + (item.extractEnergy(itemStack, toTransfer, false)*Mekanism.FROM_TE));
          }
          else if(inv.getStackInSlot(54).getItem() == Items.redstone && getEnergy(itemstack)+Mekanism.ENERGY_PER_REDSTONE <= getMaxEnergy(itemstack))
          {
            setEnergy(itemstack, getEnergy(itemstack) + Mekanism.ENERGY_PER_REDSTONE);
            inv.getStackInSlot(54).stackSize--;

            if(inv.getStackInSlot(54).stackSize <= 0)
            {
              inv.setInventorySlotContents(54, null);
            }
          }

          inv.write();
        }
      }
    }
    else if(type == MachineType.PORTABLE_TANK)
    {
View Full Code Here

        else if(getLocked(itemstack) && getEnergy(itemstack) > 0)
        {
          Mekanism.packetHandler.sendTo(new ElectricChestMessage(ElectricChestPacketType.CLIENT_OPEN, false, false, 1, 0, null, null), (EntityPlayerMP)entityplayer);
        }
        else {
          InventoryElectricChest inventory = new InventoryElectricChest(entityplayer);
          MekanismUtils.openElectricChestGui((EntityPlayerMP)entityplayer, null, inventory, false);
        }
      }
    }
    else if(type == MachineType.PORTABLE_TANK && getBucketMode(itemstack))
View Full Code Here

            if(message.useEnergy)
            {
              ((IEnergizedItem)stack.getItem()).setEnergy(stack, ((IEnergizedItem)stack.getItem()).getEnergy(stack) - 100);
            }

            InventoryElectricChest inventory = new InventoryElectricChest(player);
            MekanismUtils.openElectricChestGui((EntityPlayerMP)player, null, inventory, false);
          }
        }
      } catch(Exception e) {
        Mekanism.logger.error("Error while handling electric chest open packet.");
View Full Code Here

TOP

Related Classes of mekanism.common.inventory.InventoryElectricChest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.