Package net.minecraft.item

Examples of net.minecraft.item.Item


        Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < itemsMapping.tagCount(); ++i) {
      NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
      String name = sub.getString("name");
      Item item = (Item) Item.itemRegistry.getObject(name);
      registerItem (item);
    }

    NBTTagList entitiesMapping = nbt.getTagList("entitiesMapping",
        Constants.NBT.TAG_COMPOUND);
View Full Code Here


        stack.stackSize = 0;
      }
    }

    if (stack.stackSize == 0 && stack.getItem().getContainerItem() != null) {
      Item container = stack.getItem().getContainerItem();
      ItemStack newStack = new ItemStack(container);
      slot.setStackInSlot(newStack);
    } else if (stack.stackSize == 0) {
      slot.setStackInSlot(null);
    }
View Full Code Here

    NBTTagList list = nbt.getTagList(nbtName,
        Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < list.tagCount(); ++i) {
            NBTTagCompound invSlot = list.getCompoundTagAt(i);
            Item item = Item.getItemById(invSlot.getInteger ("id"));
            invSlot.setInteger("id", registry.getIdForItem(item));
    }
  }
View Full Code Here

    NBTTagList list = nbt.getTagList(nbtName,
        Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < list.tagCount(); ++i) {
            NBTTagCompound invSlot = list.getCompoundTagAt(i);
            Item item = registry.getItemForId(invSlot.getInteger ("id"));
            invSlot.setInteger("id", Item.getIdFromItem(item));
    }
  }
View Full Code Here

            }
          }
          blockRegistry.put(clazz, blockList);

                    if (((ITTinkererBlock) newBlock).getItemBlock() != null) {
                        Item newItem = ((ITTinkererBlock) newBlock).getItemBlock().getConstructor(Block.class).newInstance(newBlock);
                        newItem.setUnlocalizedName(((ITTinkererItem) newItem).getItemName());
                        ArrayList<Item> itemList = new ArrayList<Item>();
                        itemList.add(newItem);
                        itemRegistry.put(((ITTinkererBlock) newBlock).getItemBlock(), itemList);

                    }
        }
      } catch (InstantiationException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (NoSuchMethodException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      }
    }
    for (Class clazz : itemClasses) {
      try {
        Item newItem = (Item) clazz.newInstance();
        if (((ITTinkererItem) newItem).shouldRegister()) {
          newItem.setUnlocalizedName(((ITTinkererItem) newItem).getItemName());
          ArrayList<Item> itemList = new ArrayList<Item>();
          itemList.add(newItem);
          if (newItem == null) {
                        ThaumicTinkerer.log.debug(clazz.getName() + " Returned a null item upon registration");
            continue;
          }
          if (((ITTinkererItem) newItem).getSpecialParameters() != null) {
            for (Object param : ((ITTinkererItem) newItem).getSpecialParameters()) {
              for (Constructor constructor : clazz.getConstructors()) {
                if (constructor.getParameterTypes().length > 0 && constructor.getParameterTypes()[0].isAssignableFrom(param.getClass())) {
                  Item nextItem = (Item) constructor.newInstance(param);
                  nextItem.setUnlocalizedName(((ITTinkererItem) nextItem).getItemName());
                  itemList.add(nextItem);
                  break;
                }
              }
            }
View Full Code Here

  }

  public void swingHit() {
    ChunkCoordinates coords = getTargetLoc();
    ItemStack stack = getStackInSlot(0);
    Item item = stack.getItem();
    Block block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ);

    player.setCurrentItemOrArmor(0, stack);
    //EntityPlayer realPlayer=MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(Owner);
    //NBTTagCompound data=realPlayer.getEntityData().getCompoundTag("PlayerPersisted");
    //player.getEntityData().setCompoundTag("PlayerPersisted",data);
    //NBTTagCompound cmp=player.getEntityData().getCompoundTag("PlayerPersisted");
    //System.out.println(cmp.getCompoundTag("TCResearch").getTagList("TCResearchList").tagCount());

    boolean done = false;

    if (leftClick) {
      Entity entity = detectedEntities.isEmpty() ? null : detectedEntities.get(worldObj.rand.nextInt(detectedEntities.size()));
      if (entity != null) {
        player.getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers()); // Set attack strenght
        player.attackTargetEntityWithCurrentItem(entity);
        done = true;
      } else if (!isBreaking) {
        if (block != Blocks.air && !block.isAir(worldObj, coords.posX, coords.posY, coords.posZ) && block.getBlockHardness(worldObj, coords.posX, coords.posY, coords.posZ) >= 0) {
          isBreaking = true;
          startBreaking(block, worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ));
          done = true;
        }
      }
    } else {
      int side = SIDES[(getBlockMetadata() & 7) - 2].getOpposite().ordinal();

      if (!(block != Blocks.air && !block.isAir(worldObj, coords.posX, coords.posY, coords.posZ))) {
        coords.posY -= 1;
        side = ForgeDirection.UP.ordinal();
        block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ);
      }

      try {
        ForgeEventFactory.onPlayerInteract(player, Action.RIGHT_CLICK_AIR, coords.posX, coords.posY, coords.posZ, side,worldObj);
        Entity entity = detectedEntities.isEmpty() ? null : detectedEntities.get(worldObj.rand.nextInt(detectedEntities.size()));
        done = entity != null && entity instanceof EntityLiving && (item.itemInteractionForEntity(stack, player, (EntityLivingBase) entity) || (!(entity instanceof EntityAnimal) || ((EntityAnimal) entity).interact(player)));

        if (!done)
          item.onItemUseFirst(stack, player, worldObj, coords.posX, coords.posY, coords.posZ, side, 0F, 0F, 0F);
        if (!done)
          done = block != null && block.onBlockActivated(worldObj, coords.posX, coords.posY, coords.posZ, player, side, 0F, 0F, 0F);
        if (!done)
          done = item.onItemUse(stack, player, worldObj, coords.posX, coords.posY, coords.posZ, side, 0F, 0F, 0F);
        if (!done) {
          item.onItemRightClick(stack, worldObj, player);
          done = true;
        }

      } catch (Throwable e) {
        e.printStackTrace();
View Full Code Here

    super(par1iInventory, par2, par3, par4);
  }

  @Override
  public boolean isItemValid(ItemStack par1ItemStack) {
    Item item = par1ItemStack.getItem();
    return !(item instanceof ItemFocusPouch);
  }
View Full Code Here

      String[] parts = ((String)id).split(":");
      Preconditions.checkArgument(parts.length == 2, "Invalid item id");
      String modId = parts[0];
      String name = parts[1];
      Item item = GameRegistry.findItem(modId, name);

      int quantity = getIntValue(m, "qty", 1);
      int dmg = getIntValue(m, "dmg", 0);

      return new ItemStack(item, quantity, dmg);
View Full Code Here

          if (slot2 != null && slot2.canTakeStack(player)) {
            itemstack3 = this.transferStackInSlot(player, slotIndex);

            if (itemstack3 != null) {
              Item item = itemstack3.getItem();
              stack = itemstack3.copy();

              if (slot2.getStack() != null && slot2.getStack().getItem() == item) {
                this.retrySlotClick(slotIndex, p_75144_2_, true, player);
              }
View Full Code Here

    return stack.stackTagCompound.getCompoundTag("display").getString("Name");
  }

  public static ItemStack consumeItem(ItemStack stack) {

    Item item = stack.getItem();
    boolean largerStack = stack.stackSize > 1;
    // vanilla only alters the stack passed to hasContainerItem/etc. when the size is >1

    if (largerStack) {
      stack.stackSize -= 1;
    }

    if (item.hasContainerItem(stack)) {
      ItemStack ret = item.getContainerItem(stack);

      if (ret == null) {
        return null;
      }
      if (ret.isItemStackDamageable() && ret.getItemDamage() > ret.getMaxDamage()) {
View Full Code Here

TOP

Related Classes of net.minecraft.item.Item

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.