コード例 #1
0
  @Override
  public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {

    Player player = (Player) src;

    PlayerGymInfoData playerGymInfoData = player.get(PlayerGymInfoData.class).get();
    List<ItemStackSnapshot> itemStackSnapshots = playerGymInfoData.badgeItems().get();
    InventoryBasic inventoryBasic = new InventoryBasic("Badges", true, 54);

    for (int i = 0; i < itemStackSnapshots.size(); i++) {
      if (i < inventoryBasic.getSizeInventory()) {
        ItemStackSnapshot snapshot = itemStackSnapshots.get(i);
        ItemStack stack = snapshot.createStack();
        inventoryBasic.setInventorySlotContents(i, (net.minecraft.item.ItemStack) stack);
      }
    }
    ((EntityPlayerMP) player).displayGUIChest(inventoryBasic);

    /*
    try {
        GameProfile gameProfile = Sponge.getServer().getGameProfileManager().get("clienthax").get(); // <-- why the hell doesnt this return a optional.. -.-
        System.out.println(gameProfile.getUniqueId());

    } catch (Exception e) {
        e.printStackTrace();
    }*/

    return CommandResult.success();
  }
コード例 #2
0
  public void setInventoryStack(int inv, ItemStack stack) {
    if (stack == null || stack.stackSize <= 0) inventory.setInventorySlotContents(inv, null);
    else inventory.setInventorySlotContents(inv, stack);

    for (int i = 0; i < 6; i++) {
      ForgeDirection d = ForgeDirection.getOrientation(i);
      getSide(d).onInventoryChange(configs[i], inv, this, d, false);
    }
  }
コード例 #3
0
  protected void handleMouseClick(
      Slot p_146984_1_, int p_146984_2_, int p_146984_3_, int p_146984_4_) {
    if (p_146984_1_ != null && p_146984_2_ != -999) {
      Debug.println("p_146984_1_", p_146984_1_.slotNumber + "");
      Debug.println("p_146984_2_", p_146984_2_ + "");
      Debug.println("p_146984_3_", p_146984_3_ + "");
      Debug.println("p_146984_4_", p_146984_4_ + "");

      if (p_146984_1_ != null && p_146984_1_.getHasStack()) {

        ItemStack itemstack = p_146984_1_.getStack();
        ItemStack itemstack2;

        List recipes = CustomCraftingManager.getInstance().getRecipeList();

        for (int j = 0; j < recipes.size(); ++j) {
          IRecipe irecipe = (IRecipe) recipes.get(j);
          itemstack2 = irecipe.getRecipeOutput();
          if (itemstack2 != null) {
            if (itemstack2.getItem() == itemstack.getItem()
                && itemstack.getItemDamage() == itemstack2.getItemDamage()) {

              ItemStack[][] RezeptAr = irecipe.getRecipe(itemstack2);

              Debug.println(
                  irecipe.getClass().getName(),
                  irecipe.getClass().getName() + " " + itemstack2.getItemDamage());

              if (irecipe.getRecipe(itemstack2) != null) {
                craftResult.setInventorySlotContents(0, itemstack2);
                // irecipe.
                for (int i = 0; i < RezeptAr.length; i++) {
                  for (int ii = 0; ii < RezeptAr[i].length; ii++) {
                    recipefield.setInventorySlotContents((i * 3) + ii, null);
                    ItemStack Rezeptitem = RezeptAr[i][ii];
                    if (Rezeptitem != null) {
                      Debug.println(
                          i + "/" + ii,
                          Rezeptitem.getDisplayName() + " " + Rezeptitem.getItemDamage());
                      Rezeptitem.stackSize = 1;
                      recipefield.setInventorySlotContents((i * 3) + ii, Rezeptitem);
                    }
                  }
                }

                Debug.println("itemstack", itemstack.getDisplayName() + "");

                break;
              }
            }
          }
        }
      }
      ((CreativeInv.ContainerCreative) this.inventorySlots).scrollTo(this.currentScroll);
      // this.scrollTo(0.0F);
    }
  }
コード例 #4
0
  @Override
  public void writeToNBT(NBTTagCompound data) {
    super.writeToNBT(data);

    NBTTagList itemList = new NBTTagList();
    NBTTagList sideItemList = new NBTTagList();
    NBTTagCompound configData;

    data.setBoolean("shareRS", isRSShared);

    for (int i = 0; i < 3; i++) {

      if (inventory.getStackInSlot(i) != null) {
        NBTTagCompound itemCompound = new NBTTagCompound();
        itemCompound.setInteger("slot", i);
        inventory.getStackInSlot(i).writeToNBT(itemCompound);
        itemList.appendTag(itemCompound);
      }

      if (tanks[i].getFluid() != null) {
        data.setInteger("tankCap" + i, tanks[i].getCapacity());
        data.setTag("Fluid" + i, tanks[i].getFluid().writeToNBT(new NBTTagCompound()));
      }

      data.setBoolean("rsControl" + i, rsControl[i]);
      data.setBoolean("rsLatch" + i, rsLatch[i]);
    }

    data.setTag("items", itemList);

    for (int i = 0; i < 6; i++) {
      data.setInteger("side" + i, sides[i]);
      configData = new NBTTagCompound();
      configs[i].writeToNBT(configData);
      data.setCompoundTag("config" + i, configData);
      data.setBoolean("rs" + i, sideRS[i]);
      data.setBoolean("lock" + i, sideLocked[i]);
      data.setInteger("facID" + i, facID[i]);
      data.setInteger("facMeta" + i, facMeta[i]);

      if (sideInventory.getStackInSlot(i) != null) {
        NBTTagCompound itemCompound = new NBTTagCompound();
        itemCompound.setInteger("slot", i);
        sideInventory.getStackInSlot(i).writeToNBT(itemCompound);
        sideItemList.appendTag(itemCompound);
      }
    }

    data.setTag("sideItems", sideItemList);

    if (capacitor != null) {
      data.setInteger("realPower", capacitor.getEnergyStored());
      capacitor.writeToNBT(data);
      data.setInteger("powerCap2", capacitor.getMaxEnergyStored());
    }
  }
コード例 #5
0
 public static void compactStacks(ItemStack[] stacks, int start, int max) {
   InventoryBasic inv = new InventoryBasic("temp", true, max);
   for (int i = 0; i < max; i++) {
     ItemStack stack = stacks[i + start];
     if (stack != null) {
       mergeItemStack(inv, stack, 0, max, null);
     }
   }
   for (int i = 0; i < max; i++) {
     ItemStack stack = inv.getStackInSlot(i);
     if (stack != null && stack.stackSize == 0) {
       stack = null;
     }
     stacks[i + start] = stack;
   }
 }
コード例 #6
0
  public void func_70295_k_() {
    if (this.field_70488_a != null) {
      this.field_70488_a.func_70364_a();
    }

    super.func_70295_k_();
  }
コード例 #7
0
  public void func_70305_f() {
    if (this.field_70488_a != null) {
      this.field_70488_a.func_70366_b();
    }

    super.func_70305_f();
    this.field_70488_a = null;
  }
コード例 #8
0
  public int addItemInternal(ItemStack stack, boolean doAdd, int inv) {
    int amntAdded;
    int temp;

    if (inv > -1 && inv < 3) {
      ItemStack currStack = inventory.getStackInSlot(inv);

      if (currStack == null) {
        if (doAdd) {
          inventory.setInventorySlotContents(inv, stack.copy());
          for (int i = 0; i < 6; i++) {
            SocketModule m = getSide(ForgeDirection.getOrientation(i));
            m.onInventoryChange(configs[i], inv, this, ForgeDirection.getOrientation(i), true);
          }
        }

        return stack.stackSize;
      } else if (currStack.isItemEqual(stack)) {
        temp =
            Math.min(
                currStack.stackSize + stack.stackSize, currStack.getItem().getItemStackLimit());
        if (temp == (currStack.stackSize + stack.stackSize)) {
          amntAdded = stack.stackSize;
        } else {
          amntAdded = currStack.getItem().getItemStackLimit() - currStack.stackSize;
        }

        if (doAdd && amntAdded > 0) {
          currStack.stackSize += amntAdded;
          for (int i = 0; i < 6; i++) {
            SocketModule m = getSide(ForgeDirection.getOrientation(i));
            m.onInventoryChange(configs[i], inv, this, ForgeDirection.getOrientation(i), true);
          }
        }

        return amntAdded;
      }
    }

    return 0;
  }
コード例 #9
0
  public ItemStack extractItemInternal(boolean doRemove, int inv, int maxItemCount) {
    ItemStack newStack;

    if (inv > -1 && inv < 3) {
      ItemStack currStack = inventory.getStackInSlot(inv);

      if (currStack != null) {
        newStack = currStack.copy();
        newStack.stackSize = Math.min(currStack.stackSize, maxItemCount);
        if (doRemove) {
          currStack.stackSize -= newStack.stackSize;
          if (currStack.stackSize <= 0) inventory.setInventorySlotContents(inv, null);
          for (int i = 0; i < 6; i++) {
            SocketModule m = getSide(ForgeDirection.getOrientation(i));
            m.onInventoryChange(configs[i], inv, this, ForgeDirection.getOrientation(i), false);
          }
        }

        return newStack;
      }
    }

    return null;
  }
コード例 #10
0
 public void setStack(int index, ItemStack stack) {
   inv.setInventorySlotContents(index, stack);
 }
コード例 #11
0
 public void clearStacks() {
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     inv.setInventorySlotContents(i, null);
   }
 }
コード例 #12
0
 public ItemStack getStackInInventorySlot(int inv) {
   return inventory.getStackInSlot(inv);
 }
コード例 #13
0
 @Override
 public void setInventorySlotContents(int slot, ItemStack item) {
   inventory.setInventorySlotContents(slot, item);
 }
コード例 #14
0
 @Override
 public ItemStack getStackInSlotOnClosing(int slot) {
   return inventory.getStackInSlot(slot);
 }
コード例 #15
0
  @Override
  public void readFromNBT(NBTTagCompound data) {
    super.readFromNBT(data);

    if (data.hasKey("shareRS")) {
      isRSShared = data.getBoolean("shareRS");
    }

    for (int i = 0; i < 3; i++) {
      if (data.hasKey("tankCap" + i)) {
        tanks[i] = new FluidTank(data.getInteger("tankCap" + i));
      }

      if (data.hasKey("Fluid" + i)) {
        tanks[i].setFluid(FluidStack.loadFluidStackFromNBT(data.getCompoundTag("Fluid" + i)));
      }

      if (data.hasKey("rsControl" + i)) rsControl[i] = data.getBoolean("rsControl" + i);
      if (data.hasKey("rsLatch" + i)) rsLatch[i] = data.getBoolean("rsLatch" + i);
    }

    NBTTagList itemList = data.getTagList("items");

    for (int i = 0; i < itemList.tagCount(); i++) {
      NBTTagCompound itemCompound = (NBTTagCompound) itemList.tagAt(i);
      int slot = itemCompound.getInteger("slot");
      inventory.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(itemCompound));
    }

    for (int i = 0; i < 6; i++) {
      if (data.hasKey("side" + i)) {
        sides[i] = data.getInteger("side" + i);
      }
      if (data.hasKey("config" + i)) {
        configs[i] = new SideConfig();
        configs[i].readFromNBT(data.getCompoundTag("config" + i));
      }
      if (data.hasKey("rs" + i)) {
        sideRS[i] = data.getBoolean("rs" + i);
      }
      if (data.hasKey("lock" + i)) {
        sideLocked[i] = data.getBoolean("lock" + i);
      }
      if (data.hasKey("facID" + i)) {
        facID[i] = data.getInteger("facID" + i);
      }
      if (data.hasKey("facMeta" + i)) {
        facMeta[i] = data.getInteger("facMeta" + i);
      }
    }

    itemList = data.getTagList("sideItems");

    for (int i = 0; i < itemList.tagCount(); i++) {
      NBTTagCompound itemCompound = (NBTTagCompound) itemList.tagAt(i);
      int slot = itemCompound.getInteger("slot");
      sideInventory.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(itemCompound));
    }

    capacitor.readFromNBT(data);
    int power = capacitor.getEnergyStored();
    if (data.hasKey("powerCap2")) this.setMaxEnergyStored((int) data.getInteger("powerCap2"));
    if (data.hasKey("realPower")) power = data.getInteger("realPower");
    capacitor.setEnergyStored(power);
  }
コード例 #16
0
 @Override
 public boolean interact(EntityPlayer player) {
   ItemStack itemstack = player.inventory.getCurrentItem();
   if (!this.worldObj.isRemote) {
     // Allow taming in creative mode without items
     if (!this.isTamed() && player.capabilities.isCreativeMode) {
       this.func_152115_b(player.getUniqueID().toString()); // Set owner UUID
       this.setTamed(true);
     }
     // If tamed
     if (this.isTamed()) {
       // If player has item
       if (itemstack != null) {
         // If armour, equip it
         if (itemstack.getItem() instanceof ItemArmor && !player.isSneaking()) {
           int i = EntityLiving.getArmorPosition(itemstack) - 1;
           if (this.getEquipmentInSlot(i + 1) == null) {
             this.setCurrentItemOrArmor(i + 1, itemstack.copy());
             if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
               player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
           } else {
             EntityItem entityItem =
                 new EntityItem(
                     this.worldObj,
                     this.posX,
                     this.posY,
                     this.posZ,
                     this.getEquipmentInSlot(i + 1));
             this.worldObj.spawnEntityInWorld(entityItem);
             this.setCurrentItemOrArmor(i + 1, null);
           }
           return true;
         }
         // If lead and mounted, unmount
         else if (itemstack.getItem() == Items.lead && this.isRiding() && !player.isSneaking())
           this.mountEntity(null);
         // If entity is holding something and player is holding a stick, drop current item
         else if (itemstack.getItem() == Items.stick && this.getHeldItem() != null) {
           EntityItem entityItem =
               new EntityItem(
                   player.worldObj, this.posX, this.posY, this.posZ, this.getHeldItem().copy());
           player.worldObj.spawnEntityInWorld(entityItem);
           this.setCarrying(null);
           // Drop chest contents
           for (int i = 0; i < inventory.getSizeInventory(); i++) {
             ItemStack itemStackToDrop = inventory.getStackInSlot(i);
             if (itemStackToDrop != null) {
               entityItem =
                   new EntityItem(
                       player.worldObj, this.posX, this.posY, this.posZ, itemStackToDrop);
               player.worldObj.spawnEntityInWorld(entityItem);
             }
             inventory.setInventorySlotContents(i, null);
           }
         } else if (this.getHeldItem() == null) {
           ItemStack newItemStack = itemstack.copy();
           newItemStack.stackSize = 1;
           this.setCarrying(newItemStack);
           player.playSound(
               "mob.chickenplop",
               1.0F,
               (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
           if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
             player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
         }
       }
       // If entity is holding something and player isn't, open GUI
       if (this.getHeldItem() != null && !player.isSneaking()) {
         if (Block.getBlockFromItem(this.getHeldItem().getItem()) == Blocks.chest)
           player.openGui(MiniCreatures.instance, 0, player.worldObj, this.getEntityId(), 0, 0);
         else if (Block.getBlockFromItem(this.getHeldItem().getItem()) == Blocks.anvil)
           player.openGui(
               MiniCreatures.instance,
               1,
               player.worldObj,
               (int) this.posX,
               (int) this.posY,
               (int) this.posZ);
       } else if (player.isEntityEqual(this.getOwner()) && !this.worldObj.isRemote) {
         if (this.isRiding()) {
           EntityTameable ridingEntity = (EntityTameable) this.ridingEntity;
           ridingEntity.func_70907_r().setSitting(!ridingEntity.isSitting());
           ridingEntity.setSitting(!ridingEntity.isSitting());
           ridingEntity.setJumping(false);
           ridingEntity.setPathToEntity(null);
           ridingEntity.setTarget(null);
           ridingEntity.setAttackTarget(null);
         } else {
           this.aiSit.setSitting(!this.isSitting());
           this.setSitting(!this.isSitting());
           this.isJumping = false;
           this.setPathToEntity(null);
           this.setTarget(null);
           this.setAttackTarget(null);
         }
       }
     }
   }
   return super.interact(player);
 }