Java 类net.minecraft.inventory.SlotCrafting 实例源码

项目:EZStorage    文件:ContainerStorageCoreCrafting.java   
public ContainerStorageCoreCrafting(EntityPlayer player, World world,
        int x, int y, int z) {
    super(player, world, x, y, z);
    this.worldObj = world;
    this.addSlotToContainer(new SlotCrafting(player, this.craftMatrix, this.craftResult, 0, 116, 117));
       int i;
       int j;

       for (i = 0; i < 3; ++i)
       {
           for (j = 0; j < 3; ++j)
           {
               this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 44 + j * 18, 99 + i * 18));
           }
       }
       this.onCraftMatrixChanged(this.craftMatrix);
}
项目:EZStorage    文件:ContainerStorageCoreCrafting.java   
@Override
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer playerIn) {

    if (mode == 0 && clickedButton == 0) {      
        if (slotId >= 0 && inventorySlots.size() > slotId) {
            Slot slotObject = inventorySlots.get(slotId);
            if (slotObject != null) {
                if (slotObject instanceof SlotCrafting) {
                    ItemStack[] recipe = new ItemStack[9];
                    for (int i=0; i<9; i++) {
                        recipe[i] = this.craftMatrix.getStackInSlot(i);
                    }
                    ItemStack result = super.slotClick(slotId, clickedButton, mode, playerIn);
                    if (result != null) {
                        tryToPopulateCraftingGrid(recipe, playerIn);
                    }
                    return result;
                }
            }
        }

    }
    return super.slotClick(slotId, clickedButton, mode, playerIn);
}
项目:EZStorage2    文件:ContainerStorageCoreCrafting.java   
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
    // if (clickTypeIn == ClickType.QUICK_CRAFT) {
    if (slotId >= 0 && slotId < inventorySlots.size()) {
        Slot slotObject = inventorySlots.get(slotId);
        if (slotObject != null && slotObject instanceof SlotCrafting) { // user clicked on result slot
            ItemStack[] recipe = new ItemStack[9];
            for (int i = 0; i < 9; i++) {
                recipe[i] = this.craftMatrix.getStackInSlot(i);
            }

            ItemStack result = super.slotClick(slotId, dragType, clickTypeIn, player);
            if (result != null) {
                tryToPopulateCraftingGrid(recipe, player);
            }
            return result;
        }
    }
    // }
    return super.slotClick(slotId, dragType, clickTypeIn, player);
}
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot. Args: Container, slot number, slot contents
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot. Args: Container, slot number, slot contents
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:BaseClient    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot. Args: Container, slot number, slot contents
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:BaseClient    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot. Args: Container, slot number, slot contents
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot.
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot.
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:BetterBeginningsReborn    文件:ContainerSimpleWorkbench.java   
public ContainerSimpleWorkbench(InventoryPlayer invPlayer, World world, BlockPos loc)
{
    worldObj = world;
    pos = loc;

    addSlotToContainer(new SlotCrafting(invPlayer.player, craftMatrix, craftResult, 0, 124, 35));
    int l;
    int i1;

    for (l = 0; l < 3; ++l)
    {
        for (i1 = 0; i1 < 3; ++i1)
        {
            addSlotToContainer(new Slot(craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18));
        }
    }

    for (l = 0; l < 3; ++l)
    {
        for (i1 = 0; i1 < 9; ++i1)
        {
            addSlotToContainer(new Slot(invPlayer, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18));
        }
    }

    for (l = 0; l < 9; ++l)
    {
        addSlotToContainer(new Slot(invPlayer, l, 8 + l * 18, 142));
    }

    onCraftMatrixChanged(craftMatrix);
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot.
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:Aether-Legacy    文件:ContainerAccessories.java   
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber)
{
    Slot slot = (Slot) this.inventorySlots.get(slotNumber);

    if (slot != null && slot.getHasStack())
    {
        ItemStack stack = slot.getStack();

        if (!(slot instanceof SlotAccessory) && !(slot instanceof SlotCrafting))
        {
            int newSlotIndex = -1;

            if (AetherAPI.getInstance().isAccessory(stack))
            {
                newSlotIndex = this.getAccessorySlot(AetherAPI.getInstance().getAccessory(stack).getAccessoryType());
            }

            if (newSlotIndex != -1)
            {
                Slot accessorySlot = this.inventorySlots.get(newSlotIndex);

                if (accessorySlot.isItemValid(stack))
                {
                    accessorySlot.putStack(stack);
                    slot.putStack((ItemStack) null);
                }

                return stack;
            }
        }
    }

    return super.transferStackInSlot(player, slotNumber);
}
项目:Inventory-Power    文件:GoCraftContainer.java   
public GoCraftContainer(InventoryPlayer playerInventory, World worldIn, BlockPos posIn)
{
    this.worldObj = worldIn;
    this.pos = posIn;
    this.addSlotToContainer(new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 124, 35));

    for (int i = 0; i < 3; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 30 + j * 18, 17 + i * 18));
        }
    }

    for (int k = 0; k < 3; ++k)
    {
        for (int i1 = 0; i1 < 9; ++i1)
        {
            this.addSlotToContainer(new Slot(playerInventory, i1 + k * 9 + 9, 8 + i1 * 18, 84 + k * 18));
        }
    }

    for (int l = 0; l < 9; ++l)
    {
        this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142));
    }

    this.onCraftMatrixChanged(this.craftMatrix);
}
项目:EZStorage2    文件:ContainerStorageCoreCrafting.java   
public ContainerStorageCoreCrafting(EntityPlayer player, World world, int x, int y, int z) {
    super(player, world, x, y, z);
    this.worldObj = world;
    this.addSlotToContainer(new SlotCrafting(player, this.craftMatrix, this.craftResult, 0, 116, 117));
    int i;
    int j;

    for (i = 0; i < 3; ++i) {
        for (j = 0; j < 3; ++j) {
            this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 44 + j * 18, 99 + i * 18));
        }
    }
    this.onCraftMatrixChanged(this.craftMatrix);
}
项目:TCInventoryScanning    文件:HandlerScanSlot.java   
@Override
public IMessage onMessage(MessageScanSlot message, MessageContext ctx) {
    EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;
    Container container = entityPlayer.openContainer;
    if (container != null && message.getSlotNumber() >= 0 && message.getSlotNumber() < container.inventorySlots.size()) {
        Slot slot = (Slot) container.inventorySlots.get(message.getSlotNumber());
        if (slot.getStack() != null && slot.canTakeStack(entityPlayer) && !(slot instanceof SlotCrafting)) {
            ItemStack itemStack = slot.getStack();
            ScanResult scan = new ScanResult((byte) 1, Item.getIdFromItem(itemStack.getItem()), itemStack.getItemDamage(), null, "");
            ScanManager.completeScan(entityPlayer, scan, "@");
        }
    }
    return null;
}
项目:NOVA-Core    文件:MCCraftingGrid.java   
private MCCraftingGrid(InventoryCrafting inventory) {
    this.inventory = inventory;
    width = height = (int) Math.sqrt(inventory.getSizeInventory());
    items = new nova.core.item.Item[width * height];
    original = new ItemStack[items.length];
    itemCount = 0;
    update();

    Container container = ReflectionUtil.getCraftingContainer(inventory);
    if (container != null) {
        @SuppressWarnings("unchecked")
        List<Slot> slots = container.inventorySlots;

        EntityPlayer playerOrig = null;
        Optional<Player> player = Optional.empty();

        for (Slot slot : slots) {
            if (slot instanceof SlotCrafting) {
                playerOrig = ReflectionUtil.getCraftingSlotPlayer((SlotCrafting) slot);
                player = WrapUtility.getNovaPlayer(playerOrig);

                if (player.isPresent()) {
                    break;
                }
            }
        }

        this.playerOrig = playerOrig;
        this.player = player;
    } else {
        playerOrig = null;
        player = Optional.empty();
    }
}
项目:NOVA-Core    文件:ReflectionUtil.java   
public static EntityPlayer getCraftingSlotPlayer(SlotCrafting slot) {
    try {
        return (EntityPlayer) SLOTCRAFTING_PLAYER.get(slot);
    } catch (IllegalAccessException ex) {
        Game.logger().error("could not get inventory eventhandler");
        return null;
    }
}
项目:NOVA-Core    文件:MCCraftingGrid.java   
private MCCraftingGrid(InventoryCrafting inventory) {
    this.inventory = inventory;
    width = height = (int) Math.sqrt(inventory.getSizeInventory());
    items = new nova.core.item.Item[width * height];
    original = new net.minecraft.item.ItemStack[items.length];
    itemCount = 0;
    update();

    Container container = ReflectionUtil.getCraftingContainer(inventory);
    if (container != null) {
        @SuppressWarnings("unchecked")
        List<Slot> slots = container.inventorySlots;

        EntityPlayer playerOrig = null;
        Optional<Player> player = Optional.empty();

        for (Slot slot : slots) {
            if (slot instanceof SlotCrafting) {
                playerOrig = ReflectionUtil.getCraftingSlotPlayer((SlotCrafting) slot);
                player = WrapUtility.getNovaPlayer(playerOrig);

                if (player.isPresent()) {
                    break;
                }
            }
        }

        this.playerOrig = playerOrig;
        this.player = player;
    } else {
        playerOrig = null;
        player = Optional.empty();
    }
}
项目:NOVA-Core    文件:ReflectionUtil.java   
public static EntityPlayer getCraftingSlotPlayer(SlotCrafting slot) {
    try {
        return (EntityPlayer) SLOTCRAFTING_PLAYER.get(slot);
    } catch (IllegalAccessException ex) {
        Game.logger().error("could not get inventory eventhandler");
        return null;
    }
}
项目:Cyclic    文件:ContainerWorkBench.java   
public ContainerWorkBench(InventoryPlayer inventoryPlayer, TileEntityWorkbench te) {
  craftMatrix = new InventoryWorkbench(this, te);
  this.world = inventoryPlayer.player.world;
  this.player = inventoryPlayer.player;
  this.setTile(te);
  tileEntity = te;
  this.addSlotToContainer(new SlotCrafting(player, this.craftMatrix, this.craftResult, 0, 136, 35));
  int slot = 0;
  //inpt on left
  int xPrefix = Const.PAD, yPrefix = 27;
  int rows = TileEntityWorkbench.ROWS;
  int cols = TileEntityWorkbench.COLS;
  //crafting in the middle
  rows = cols = 3;
  xPrefix = (screenSize.width() / 2 - (Const.SQ * 3) / 2);//(GuiWorkbench.WIDTH / 2 - (Const.SQ * 3) / 2);
  yPrefix = 20;
  for (int i = 0; i < rows; i++) {
    for (int j = 0; j < cols; j++) {
      addSlotToContainer(new Slot(this.craftMatrix, slot,
          xPrefix + j * Const.SQ,
          yPrefix + i * Const.SQ));
      slot++;
    }
  }
  // commonly used vanilla code that adds the player's inventory
  bindPlayerInventory(inventoryPlayer);
  this.onCraftMatrixChanged(this.craftMatrix);
}
项目:Resilience-Client-Source    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot. Args: Container, slot number, slot contents
 */
public void sendSlotContents(Container par1Container, int par2, ItemStack par3ItemStack)
{
    if (!(par1Container.getSlot(par2) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(par1Container.windowId, par2, par3ItemStack));
        }
    }
}
项目:TectoCraft    文件:ContainerTectoCrafter.java   
public ContainerTectoCrafter(InventoryPlayer invPlayer, World world, int x, int y, int z) {
    craftMatrix = new InventoryCrafting(this, 5, 5);
    craftResult = new InventoryCraftResult();
    worldObj = world;
    posX = x; posY = y; posZ = z;

    // Output slot
    this.addSlotToContainer(new SlotCrafting(invPlayer.player, craftMatrix, craftResult, 0, 141, 36));

    // 5x5 Crafting Area
    for(int i = 0; i < 5; i++) {
        for(int j = 0; j < 5; j++) {
            this.addSlotToContainer(new Slot(craftMatrix, j + i * 5, 10 + j * 18, 18 + i * 18));
        }
    }

    // Player Inventory
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 9; j++) {
            this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 116 + i * 18));
        }
    }

    // Hotbar
    for(int i = 0; i < 9; i++) {
        this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 174));
    }

    onCraftMatrixChanged(craftMatrix);
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot.
 */
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
    if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.connection.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
        }
    }
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void sendSlotContents(Container p_71111_1_, int p_71111_2_, ItemStack p_71111_3_)
{
    if (!(p_71111_1_.getSlot(p_71111_2_) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(p_71111_1_.windowId, p_71111_2_, p_71111_3_));
        }
    }
}
项目:Cauldron    文件:EntityPlayerMP.java   
public void sendSlotContents(Container p_71111_1_, int p_71111_2_, ItemStack p_71111_3_)
{
    if (!(p_71111_1_.getSlot(p_71111_2_) instanceof SlotCrafting))
    {
        if (!this.isChangingQuantityOnly)
        {
            this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(p_71111_1_.windowId, p_71111_2_, p_71111_3_));
        }
    }
}
项目:Exoskeleton    文件:ContainerAssembler.java   
private void createCraftingMatrix(InventoryPlayer playerInv){
    for(int x = 0; x < 3; x++){
        for(int y = 0; y < 3; y++){
            this.addSlotToContainer(new Slot(this.CRAFT_MATRIX, (x + y * 3), (17 + y * 18), (17 + x * 18)));
        }
    }

    this.addSlotToContainer(new Slot(this.CRAFT_MATRIX, 9, 84, 35));

    this.addSlotToContainer(new SlotCrafting(playerInv.player, this.CRAFT_MATRIX, this.CRAFT_RESULT, 0, 142, 35));
}
项目:RuneCraftery    文件:EntityPlayerMP.java   
public void func_71111_a(Container p_71111_1_, int p_71111_2_, ItemStack p_71111_3_) {
   if(!(p_71111_1_.func_75139_a(p_71111_2_) instanceof SlotCrafting)) {
      if(!this.field_71137_h) {
         this.field_71135_a.func_72567_b(new Packet103SetSlot(p_71111_1_.field_75152_c, p_71111_2_, p_71111_3_));
      }
   }
}
项目:RuneCraftery    文件:ContainerPlayer.java   
public ContainerPlayer(InventoryPlayer p_i1819_1_, boolean p_i1819_2_, EntityPlayer p_i1819_3_) {
   this.field_75180_g = p_i1819_2_;
   this.field_82862_h = p_i1819_3_;
   this.func_75146_a(new SlotCrafting(p_i1819_1_.field_70458_d, this.field_75181_e, this.field_75179_f, 0, 144, 36));

   int var4;
   int var5;
   for(var4 = 0; var4 < 2; ++var4) {
      for(var5 = 0; var5 < 2; ++var5) {
         this.func_75146_a(new Slot(this.field_75181_e, var5 + var4 * 2, 88 + var5 * 18, 26 + var4 * 18));
      }
   }

   for(var4 = 0; var4 < 4; ++var4) {
      this.func_75146_a(new SlotArmor(this, p_i1819_1_, p_i1819_1_.func_70302_i_() - 1 - var4, 8, 8 + var4 * 18, var4));
   }

   for(var4 = 0; var4 < 3; ++var4) {
      for(var5 = 0; var5 < 9; ++var5) {
         this.func_75146_a(new Slot(p_i1819_1_, var5 + (var4 + 1) * 9, 8 + var5 * 18, 84 + var4 * 18));
      }
   }

   for(var4 = 0; var4 < 9; ++var4) {
      this.func_75146_a(new Slot(p_i1819_1_, var4, 8 + var4 * 18, 142));
   }

   this.func_75130_a(this.field_75181_e);
}
项目:RuneCraftery    文件:ContainerWorkbench.java   
public ContainerWorkbench(InventoryPlayer p_i1808_1_, World p_i1808_2_, int p_i1808_3_, int p_i1808_4_, int p_i1808_5_) {
   this.field_75161_g = p_i1808_2_;
   this.field_75164_h = p_i1808_3_;
   this.field_75165_i = p_i1808_4_;
   this.field_75163_j = p_i1808_5_;
   this.func_75146_a(new SlotCrafting(p_i1808_1_.field_70458_d, this.field_75162_e, this.field_75160_f, 0, 124, 35));

   int var6;
   int var7;
   for(var6 = 0; var6 < 3; ++var6) {
      for(var7 = 0; var7 < 3; ++var7) {
         this.func_75146_a(new Slot(this.field_75162_e, var7 + var6 * 3, 30 + var7 * 18, 17 + var6 * 18));
      }
   }

   for(var6 = 0; var6 < 3; ++var6) {
      for(var7 = 0; var7 < 9; ++var7) {
         this.func_75146_a(new Slot(p_i1808_1_, var7 + var6 * 9 + 9, 8 + var7 * 18, 84 + var6 * 18));
      }
   }

   for(var6 = 0; var6 < 9; ++var6) {
      this.func_75146_a(new Slot(p_i1808_1_, var6, 8 + var6 * 18, 142));
   }

   this.func_75130_a(this.field_75162_e);
}
项目:RuneCraftery    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot. Args: Container, slot number, slot contents
 */
public void sendSlotContents(Container par1Container, int par2, ItemStack par3ItemStack)
{
    if (!(par1Container.getSlot(par2) instanceof SlotCrafting))
    {
        if (!this.playerInventoryBeingManipulated)
        {
            this.playerNetServerHandler.sendPacketToPlayer(new Packet103SetSlot(par1Container.windowId, par2, par3ItemStack));
        }
    }
}
项目:BetterNutritionMod    文件:EntityPlayerMP.java   
/**
 * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
 * contents of that slot. Args: Container, slot number, slot contents
 */
public void sendSlotContents(Container par1Container, int par2, ItemStack par3ItemStack)
{
    if (!(par1Container.getSlot(par2) instanceof SlotCrafting))
    {
        if (!this.playerInventoryBeingManipulated)
        {
            this.playerNetServerHandler.sendPacketToPlayer(new Packet103SetSlot(par1Container.windowId, par2, par3ItemStack));
        }
    }
}
项目:FullmetalAlchemy-Dev    文件:ContainerChalkCircle.java   
public ContainerChalkCircle(InventoryPlayer par1InventoryPlayer, ItemStack stack, World par2World, int par3, int par4, int par5)
{
    this.worldObj = par2World;
    this.posX = par3;
    this.posY = par4;
    this.posZ = par5;
    this.addSlotToContainer(new SlotCrafting(par1InventoryPlayer.player, this.craftMatrix, this.craftResult, 0, 128, 44));

    for (int i = 0; i < 25; i++) {
        if (stack != null) {
            craftMatrix.setInventorySlotContents(i, stack.copy());
        }
    }

    for (int l = 0; l < 3; ++l)
    {
        for (int i1 = 0; i1 < 9; ++i1)
        {
            this.addSlotToContainer(new Slot(par1InventoryPlayer, i1 + l * 9 + 9, 8 + i1 * 18, 102 + l * 18));
        }
    }

    for (int l1 = 0; l1 < 9; ++l1)
    {
        this.addSlotToContainer(new Slot(par1InventoryPlayer, l1, 8 + l1 * 18, 160));
    }
    this.onCraftMatrixChanged(this.craftMatrix);
}
项目:Exoskeleton    文件:ContainerAssembler.java   
private void createCraftingMatrix(InventoryPlayer playerInv){
    for(int x = 0; x < 3; x++){
        for(int y = 0; y < 3; y++){
            this.addSlotToContainer(new Slot(this.CRAFT_MATRIX, (x + y * 3), (17 + y * 18), (17 + x * 18)));
        }
    }

    this.addSlotToContainer(new Slot(this.CRAFT_MATRIX, 9, 84, 35));

    this.addSlotToContainer(new SlotCrafting(playerInv.player, this.CRAFT_MATRIX, this.CRAFT_RESULT, 0, 142, 35));
}
项目:4Space-5    文件:NEIController.java   
@Override
public boolean handleSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier, boolean eventconsumed) {
    if (eventconsumed ||
            !NEIClientConfig.isEnabled() ||
            isSpreading(gui))
        return eventconsumed;

    if (deleteMode && slotIndex >= 0 && slot != null) {
        if (NEIClientUtils.shiftKey() && button == 0) {
            ItemStack itemstack1 = slot.getStack();
            if (itemstack1 != null)
                NEIClientUtils.deleteItemsOfType(itemstack1);

        } else if (button == 1)
            NEIClientUtils.decreaseSlotStack(slot.slotNumber);
        else
            NEIClientUtils.deleteSlotStack(slot.slotNumber);
        return true;
    }

    if (button == 1 && slot instanceof SlotCrafting)//right click
    {
        for (int i1 = 0; i1 < 64; i1++)//click this slot 64 times
            manager.handleSlotClick(slot.slotNumber, button, 0);
        return true;
    }

    if (NEIClientUtils.controlKey()
            && slot != null && slot.getStack() != null
            && slot.isItemValid(slot.getStack())) {
        NEIClientUtils.cheatItem(slot.getStack(), button, 1);
        return true;
    }

    if(GuiInfo.hasCustomSlots(gui))
        return false;

    if (slotIndex >= 0 && NEIClientUtils.shiftKey() && NEIClientUtils.getHeldItem() != null && !slot.getHasStack()) {
        ItemStack held = NEIClientUtils.getHeldItem();
        manager.handleSlotClick(slot.slotNumber, button, 0);
        if (slot.isItemValid(held) && !ItemInfo.fastTransferExemptions.contains(slot.getClass()))
            fastTransferManager.performMassTransfer(gui, pickedUpFromSlot, slotIndex, held);

        return true;
    }

    if (slotIndex == -999 && NEIClientUtils.shiftKey() && button == 0) {
        fastTransferManager.throwAll(gui, pickedUpFromSlot);
        return true;
    }

    return false;
}
项目:CrystalMod    文件:ContainerCrystalWorkbench.java   
public ContainerCrystalWorkbench(final InventoryPlayer playerInventory, World worldIn, TileEntityCrystalWorkbench tile)
{
    this.worldObj = worldIn;
    bench = tile;
    this.pos = tile.getPos();

    craftResult = new InventoryCraftResult();
    craftMatrix = new InventoryCraftingPersistent(this, tile, 3, 3);

    this.addSlotToContainer(new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 124, 35){
        @Override
        public ItemStack onTake(EntityPlayer playerIn, ItemStack stack)
        {
            //net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
            this.onCrafting(stack);
            //net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
            NonNullList<ItemStack> aitemstack = CrystalCraftingManager.getInstance().getRemainingItems(craftMatrix, playerIn.getEntityWorld());
            //net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);

            for (int i = 0; i < aitemstack.size(); ++i)
            {
                ItemStack itemstack = craftMatrix.getStackInSlot(i);
                ItemStack itemstack1 = aitemstack.get(i);

                if (!ItemStackTools.isNullStack(itemstack))
                {
                    craftMatrix.decrStackSize(i, 1);
                }

                if (!ItemStackTools.isNullStack(itemstack1))
                {
                    if (ItemStackTools.isNullStack(craftMatrix.getStackInSlot(i)))
                    {
                        craftMatrix.setInventorySlotContents(i, itemstack1);
                    }
                    else if (!playerInventory.player.inventory.addItemStackToInventory(itemstack1))
                    {
                        playerInventory.player.dropItem(itemstack1, false);
                    }
                }
            }
            return stack;
        }
    });

    for (int i = 0; i < 3; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 30 + j * 18, 17 + i * 18));
        }
    }

    for (int k = 0; k < 3; ++k)
    {
        for (int i1 = 0; i1 < 9; ++i1)
        {
            this.addSlotToContainer(new Slot(playerInventory, i1 + k * 9 + 9, 8 + i1 * 18, 84 + k * 18));
        }
    }

    for (int l = 0; l < 9; ++l)
    {
        this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142));
    }

    this.onCraftMatrixChanged(this.craftMatrix);
}
项目:BIGB    文件:NEIController.java   
@Override
public boolean handleSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier, boolean eventconsumed) {
    if (eventconsumed ||
            !NEIClientConfig.isEnabled() ||
            isSpreading(gui))
        return eventconsumed;

    if (deleteMode && slotIndex >= 0 && slot != null) {
        if (NEIClientUtils.shiftKey() && button == 0) {
            ItemStack itemstack1 = slot.getStack();
            if (itemstack1 != null)
                NEIClientUtils.deleteItemsOfType(itemstack1);

        } else if (button == 1)
            NEIClientUtils.decreaseSlotStack(slot.slotNumber);
        else
            NEIClientUtils.deleteSlotStack(slot.slotNumber);
        return true;
    }

    if (button == 1 && slot instanceof SlotCrafting)//right click
    {
        for (int i1 = 0; i1 < 64; i1++)//click this slot 64 times
            manager.handleSlotClick(slot.slotNumber, button, 0);
        return true;
    }

    if (NEIClientUtils.controlKey()
            && slot != null && slot.getStack() != null
            && slot.isItemValid(slot.getStack())) {
        NEIClientUtils.cheatItem(slot.getStack(), button, 1);
        return true;
    }

    if(GuiInfo.hasCustomSlots(gui))
        return false;

    if (slotIndex >= 0 && NEIClientUtils.shiftKey() && NEIClientUtils.getHeldItem() != null && !slot.getHasStack()) {
        ItemStack held = NEIClientUtils.getHeldItem();
        manager.handleSlotClick(slot.slotNumber, button, 0);
        if (slot.isItemValid(held) && !ItemInfo.fastTransferExemptions.contains(slot.getClass()))
            fastTransferManager.performMassTransfer(gui, pickedUpFromSlot, slotIndex, held);

        return true;
    }

    if (slotIndex == -999 && NEIClientUtils.shiftKey() && button == 0) {
        fastTransferManager.throwAll(gui, pickedUpFromSlot);
        return true;
    }

    return false;
}
项目:EZStorage    文件:ContainerStorageCoreCrafting.java   
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
       Slot slotObject = (Slot) inventorySlots.get(index);
       if (slotObject != null && slotObject.getHasStack()) {
        if (slotObject instanceof SlotCrafting) {
            ItemStack[] recipe = new ItemStack[9];
            for (int i=0; i<9; i++) {
                recipe[i] = this.craftMatrix.getStackInSlot(i);
            }

            ItemStack itemstack1 = slotObject.getStack();
            ItemStack itemstack = null;
            ItemStack original = itemstack1.copy();
            int crafted = 0;
            int maxStackSize = itemstack1.getMaxStackSize();
            int crafting = itemstack1.stackSize;
               for (int i=0; i < itemstack1.getMaxStackSize(); i++) {
                if (slotObject.getHasStack() && slotObject.getStack().isItemEqual(itemstack1)) {
                    if (crafting >= maxStackSize) {
                        return null;
                    }
                    itemstack1 = slotObject.getStack();
                    itemstack = itemstack1.copy();
                    if (crafted + itemstack1.stackSize > itemstack1.getMaxStackSize()) {
                        return null;
                    }
                    boolean merged = this.mergeItemStack(itemstack1, this.rowCount()*9, this.rowCount()*9+36, true);
                    if (!merged) {
                        return null;
                    } else {

                        //It merged! grab another
                        crafted += itemstack.stackSize;
                        slotObject.onSlotChange(itemstack1, itemstack);
                        slotObject.onPickupFromSlot(playerIn, itemstack1);

                        if (original.isItemEqual(slotObject.getStack())) {
                            continue;
                        }

                        tryToPopulateCraftingGrid(recipe, playerIn);
                    }
                } else {
                    break;
                }
               }

               if (itemstack1.stackSize == itemstack.stackSize) {
                   return null;
               }


               return itemstack;
        } else {
            ItemStack stackInSlot = slotObject.getStack();
            slotObject.putStack(this.tileEntity.inventory.input(stackInSlot));
        }
       }
       return null;
}
项目:EZStorage2    文件:ContainerStorageCoreCrafting.java   
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {

    // make sure there's no multiclicking shenanigans going on
    if (playerIn instanceof EntityPlayerMP) {
        if (CoreEvents.serverTicks == lastTick) {
            EntityPlayerMP mp = (EntityPlayerMP) playerIn;
            mp.sendContainerToPlayer(this); // send an inventory sync
                                            // message just in case
            return null;
        }
        lastTick = CoreEvents.serverTicks; // keep track of server ticks
    } else {
        if (CoreEvents.clientTicks == lastTick)
            return null;
        lastTick = CoreEvents.clientTicks; // keep track of client ticks
    }

    // now do shift-click processing
    Slot slotObject = inventorySlots.get(index);
    if (slotObject != null && slotObject.getHasStack()) {
        if (slotObject instanceof SlotCrafting) {
            ItemStack[] recipe = new ItemStack[9];
            for (int i = 0; i < 9; i++) {
                recipe[i] = this.craftMatrix.getStackInSlot(i);
            }

            ItemStack itemstack1 = slotObject.getStack();
            ItemStack itemstack = null;
            ItemStack original = itemstack1.copy();
            int crafted = 0;
            int maxStackSize = itemstack1.getMaxStackSize();
            int crafting = itemstack1.stackSize;
            for (int i = 0; i < itemstack1.getMaxStackSize(); i++) {

                if (slotObject.getHasStack() && slotObject.getStack().isItemEqual(itemstack1)) {
                    if (crafting > maxStackSize) {
                        return null;
                    }
                    itemstack1 = slotObject.getStack();
                    itemstack = itemstack1.copy();
                    if (crafted + itemstack1.stackSize > itemstack1.getMaxStackSize()) {
                        return null;
                    }
                    boolean merged = this.mergeItemStack(itemstack1, this.rowCount() * 9, this.rowCount() * 9 + 36, true);
                    if (!merged) {
                        return null;
                    } else {

                        // It merged! grab another
                        crafted += itemstack.stackSize;
                        slotObject.onSlotChange(itemstack1, itemstack);
                        slotObject.onPickupFromSlot(playerIn, itemstack1);

                        if (original.isItemEqual(slotObject.getStack())) {
                            continue;
                        }

                        tryToPopulateCraftingGrid(recipe, playerIn);
                    }
                } else {
                    break;
                }
            }

            if (itemstack1.stackSize == itemstack.stackSize) {
                return null;
            }

            return itemstack;
        } else {
            ItemStack stackInSlot = slotObject.getStack();
            slotObject.putStack(this.tileEntity.inventory.input(stackInSlot));
        }
    }
    return null;
}
项目:Progression    文件:TransferHelper.java   
public boolean isAcceptable(Object object, Slot slot, EntityPlayer player, ItemStack stack) {
    return (slot.getSlotIndex() == 0 && slot instanceof SlotCrafting);
}
项目:NausicaaMod    文件:ContainerBetterTable.java   
public ContainerBetterTable(InventoryPlayer inventoryplayer, TileEntityDeviceCraftingTable tileEntity, World world, int i, int j, int k) {
    craftMatrix = new SchematicCrafting(this, tileEntity, 5, 5);


    craftResult = new InventoryCraftResult();
    schematicSlot = new InventoryBasic("schematicSlot", false, 1);
    worldObj = world;
    posX = i;
    posY = j;
    posZ = k;

    // crafting grid
    for (int page = 0; page < 5; page++)
        for (int l = 0; l < 5; l++) {
            for (int k1 = 0; k1 < 5; k1++) {
                this.addDualSlotToContainer(new ActiveSlot(craftMatrix, k1 + l * 5 + page * 25, 8 + k1 * 18, 18 + l * 18, page == 0));
                // active if first page
            }

        }

    // slot for the skematics
    this.addSlotToContainer(new Slot(schematicSlot, 0, 131, 56));
    // output slot
    this.addSlotToContainer(new SlotCrafting(inventoryplayer.player, craftMatrix, craftResult, 0, 131, 94));

    // player inventory
    for (int i1 = 0; i1 < 3; i1++) {
        for (int l1 = 0; l1 < 9; l1++) {
            this.addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 94 + 21 + i1 * 18));
        }

    }

    for (int j1 = 0; j1 < 9; j1++) {
        this.addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 148 + 25));
    }

    // System.out.println("active: " + this.activeInventorySlots.size());
    // System.out.println("slots: " + this.inventorySlots.size());

    setActivePage(1);

    onCraftMatrixChanged(craftMatrix);
    // System.out.println("active: " + this.activeInventorySlots.size());
    // System.out.println("slots: " + this.inventorySlots.size());
}