Java Code Examples for net.minecraft.item.Item
The following examples show how to use
net.minecraft.item.Item. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: enderutilities Source File: ClientProxy.java License: GNU Lesser General Public License v3.0 | 7 votes |
@SubscribeEvent public void registerItemColorHandlers(ColorHandlerEvent.Item event) { ItemColors colors = event.getItemColors(); if (EnderUtilitiesBlocks.ELEVATOR.isEnabled()) { colors.registerItemColorHandler(new ItemColorHandlerDyes(1, 0xFFFFFF), Item.getItemFromBlock(EnderUtilitiesBlocks.ELEVATOR)); } if (EnderUtilitiesBlocks.ELEVATOR_SLAB.isEnabled()) { colors.registerItemColorHandler(new ItemColorHandlerDyes(1, 0xFFFFFF), Item.getItemFromBlock(EnderUtilitiesBlocks.ELEVATOR_SLAB)); } if (EnderUtilitiesBlocks.ELEVATOR_LAYER.isEnabled()) { colors.registerItemColorHandler(new ItemColorHandlerDyes(1, 0xFFFFFF), Item.getItemFromBlock(EnderUtilitiesBlocks.ELEVATOR_LAYER)); } }
Example 2
Source Project: ToroQuest Source File: EntityMage.java License: GNU General Public License v3.0 | 6 votes |
private void dropLootItem(Item item, int amount) { if (amount == 0) { return; } for (int i = 0; i < amount; i++) { ItemStack stack = new ItemStack(item); EntityItem dropItem = new EntityItem(world, posX, posY, posZ, stack.copy()); dropItem.setNoPickupDelay(); dropItem.motionY = rand.nextDouble(); dropItem.motionZ = rand.nextDouble() - 0.5d; dropItem.motionX = rand.nextDouble() - 0.5d; world.spawnEntity(dropItem); } }
Example 3
Source Project: GregTech Source File: ModHandler.java License: GNU Lesser General Public License v3.0 | 6 votes |
public static Object finalizeIngredient(Object ingredient) { if (ingredient instanceof MetaItem.MetaValueItem) { ingredient = ((MetaItem<?>.MetaValueItem) ingredient).getStackForm(); } else if (ingredient instanceof Enum) { ingredient = ((Enum<?>) ingredient).name(); } else if (ingredient instanceof UnificationEntry) { ingredient = ingredient.toString(); } else if (!(ingredient instanceof ItemStack || ingredient instanceof Item || ingredient instanceof Block || ingredient instanceof String || ingredient instanceof Character || ingredient instanceof Boolean)) { throw new IllegalArgumentException(ingredient.getClass().getSimpleName() + " type is not suitable for crafting input."); } return ingredient; }
Example 4
Source Project: bartworks Source File: OreDictHandler.java License: MIT License | 6 votes |
public static void adaptCacheForWorld(){ Set<String> used = new HashSet<>(OreDictHandler.cache.keySet()); OreDictHandler.cache.clear(); OreDictHandler.cacheNonBW.clear(); for (String s : used) { if (!OreDictionary.getOres(s).isEmpty()) { ItemStack tmpstack = OreDictionary.getOres(s).get(0).copy(); Pair<Integer, Short> p = new Pair<>(Item.getIdFromItem(tmpstack.getItem()), (short) tmpstack.getItemDamage()); OreDictHandler.cache.put(s, p); for (ItemStack tmp : OreDictionary.getOres(s)) { Pair<Integer, Short> p2 = new Pair<>(Item.getIdFromItem(tmp.getItem()), (short) tmp.getItemDamage()); GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(tmp.getItem()); if (UI == null) UI = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(tmp.getItem())); if (!UI.modId.equals(MainMod.MOD_ID) && !UI.modId.equals(BartWorksCrossmod.MOD_ID) && !UI.modId.equals("BWCore")) { OreDictHandler.cacheNonBW.add(p2); } } } } }
Example 5
Source Project: Wurst7 Source File: AuthorCmd.java License: GNU General Public License v3.0 | 6 votes |
@Override public void call(String[] args) throws CmdException { if(args.length == 0) throw new CmdSyntaxError(); if(!MC.player.abilities.creativeMode) throw new CmdError("Creative mode only."); ItemStack heldItem = MC.player.inventory.getMainHandStack(); int heldItemID = Item.getRawId(heldItem.getItem()); int writtenBookID = Item.getRawId(Items.WRITTEN_BOOK); if(heldItemID != writtenBookID) throw new CmdError( "You must hold a written book in your main hand."); String author = String.join(" ", args); heldItem.putSubTag("author", StringTag.of(author)); }
Example 6
Source Project: OpenModsLib Source File: Utils.java License: MIT License | 6 votes |
static Matcher<ItemStack> containsItem(final Item item, final int size) { return new BaseMatcher<ItemStack>() { @Override public boolean matches(Object o) { if (o instanceof ItemStack) { ItemStack stack = (ItemStack)o; return stack.getItem() == item && stack.getCount() == size; } return false; } @Override public void describeTo(Description arg0) { arg0.appendText(String.format("%dx%s", size, item.getUnlocalizedName())); } }; }
Example 7
Source Project: GardenCollection Source File: ThaumcraftApi.java License: MIT License | 6 votes |
/** * Checks to see if the passed item/block already has aspects associated with it. * @param id * @param meta * @return */ public static boolean exists(Item item, int meta) { AspectList tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,meta)); if (tmp==null) { tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,OreDictionary.WILDCARD_VALUE)); if (meta==OreDictionary.WILDCARD_VALUE && tmp==null) { int index=0; do { tmp = ThaumcraftApi.objectTags.get(Arrays.asList(item,index)); index++; } while (index<16 && tmp==null); } if (tmp==null) return false; } return true; }
Example 8
Source Project: OpenModsLib Source File: EntityBlock.java License: MIT License | 6 votes |
private void dropBlock() { final Block block = blockState.getBlock(); Random rand = world.rand; final int count = block.quantityDropped(blockState, 0, rand); for (int i = 0; i < count; i++) { final Item item = block.getItemDropped(blockState, rand, 0); if (item != null) { ItemStack toDrop = new ItemStack(item, 1, block.damageDropped(blockState)); entityDropItem(toDrop, 0.1f); } } if (tileEntity instanceof IInventory) { IInventory inv = (IInventory)tileEntity; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack is = inv.getStackInSlot(i); if (is != null) entityDropItem(is, 0.1f); } } }
Example 9
Source Project: EnderStorage Source File: EnderStorageClientProxy.java License: MIT License | 6 votes |
@Override public void init() { if(config.getTag("checkUpdates").getBooleanValue(true)) CCUpdateChecker.updateCheck("EnderStorage"); ClientUtils.enhanceSupportersList("EnderStorage"); super.init(); PacketCustom.assignHandler(EnderStorageCPH.channel, new EnderStorageCPH()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(blockEnderChest), new ItemEnderStorageRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEnderChest.class, new EnderChestRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEnderTank.class, new EnderTankRenderer()); }
Example 10
Source Project: EmergingTechnology Source File: ProcessorRecipes.java License: MIT License | 6 votes |
private static void registerThirdPartyRecipes() { List<ItemStack> plasticInputs = new ArrayList<ItemStack>(); List<ItemStack> clearPlasticInputs = new ArrayList<ItemStack>(); List<ItemStack> paperInputs = new ArrayList<ItemStack>(); List<ItemStack> fertilizerInputs = new ArrayList<ItemStack>(); if (ModLoader.isDumpsterDivingLoaded()) { fertilizerInputs.add(new ItemStack(Item.getByNameOrId("dumpsterdiving:mold_apple"))); fertilizerInputs.add(new ItemStack(Item.getByNameOrId("dumpsterdiving:mold_pumpkin"))); fertilizerInputs.add(new ItemStack(Item.getByNameOrId("dumpsterdiving:slop_rand"))); fertilizerInputs.add(new ItemStack(Item.getByNameOrId("dumpsterdiving:mold_bread"))); fertilizerInputs.add(new ItemStack(Item.getByNameOrId("dumpsterdiving:mold_stew"))); paperInputs.add(new ItemStack(Item.getByNameOrId("dumpsterdiving:scrap_wooddust"))); } registerProcessorRecipes(new ItemStack(ModItems.plasticblock), plasticInputs); registerProcessorRecipes(new ItemStack(ModItems.clearplasticblock), clearPlasticInputs); registerProcessorRecipes(new ItemStack(ModItems.paperpulp), paperInputs); registerProcessorRecipes(new ItemStack(ModItems.fertilizer), fertilizerInputs); }
Example 11
Source Project: Wurst7 Source File: AutoSwordHack.java License: GNU General Public License v3.0 | 6 votes |
private float getValue(Item item) { switch(priority.getSelected()) { case SPEED: if(item instanceof SwordItem) return ((ISwordItem)item).fuckMcAfee(); else if(item instanceof MiningToolItem) return ((IMiningToolItem)item).fuckMcAfee2(); break; case DAMAGE: if(item instanceof SwordItem) return ((SwordItem)item).getAttackDamage(); else if(item instanceof MiningToolItem) return ((IMiningToolItem)item).fuckMcAfee1(); break; } return Integer.MIN_VALUE; }
Example 12
Source Project: GardenCollection Source File: BlockGardenProxy.java License: MIT License | 5 votes |
private Block getPlantBlock (TileEntityGarden tileEntity, Item item) { if (item == null) return null; if (item instanceof IPlantable) return ((IPlantable)item).getPlant(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); if (item instanceof ItemBlock) return Block.getBlockFromItem(item); return null; }
Example 13
Source Project: NotEnoughItems Source File: PositionedStack.java License: MIT License | 5 votes |
public boolean contains(Item ingred) { for (ItemStack item : items) { if (item.getItem() == ingred) { return true; } } return false; }
Example 14
Source Project: BigReactors Source File: BlockTurbinePart.java License: MIT License | 5 votes |
@Override public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { for(int i = 0; i < _subBlocks.length; i++) { par3List.add(new ItemStack(this, 1, i)); } }
Example 15
Source Project: EnderStorage Source File: EnderStorage.java License: MIT License | 5 votes |
private void loadPersonalItem() { ConfigTag tag = config.getTag("personalItemID") .setComment("The name of the item used to set the chest to personal. Diamond by default"); String name = tag.getValue("diamond"); personalItem = (Item) Item.itemRegistry.getObject(name); if (personalItem == null) { personalItem = Items.diamond; tag.setValue("diamond"); } }
Example 16
Source Project: PneumaticCraft Source File: ThaumcraftApi.java License: GNU General Public License v3.0 | 5 votes |
public static Object[] getCraftingRecipeKey(EntityPlayer player, ItemStack stack) { int[] key = new int[] {Item.getIdFromItem(stack.getItem()),stack.getItemDamage()}; if (keyCache.containsKey(key)) { if (keyCache.get(key)==null) return null; if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), (String)(keyCache.get(key))[0])) return keyCache.get(key); else return null; } for (ResearchCategoryList rcl:ResearchCategories.researchCategories.values()) { for (ResearchItem ri:rcl.research.values()) { if (ri.getPages()==null) continue; for (int a=0;a<ri.getPages().length;a++) { ResearchPage page = ri.getPages()[a]; if (page.recipe!=null && page.recipe instanceof CrucibleRecipe[]) { CrucibleRecipe[] crs = (CrucibleRecipe[]) page.recipe; for (CrucibleRecipe cr:crs) { if (cr.getRecipeOutput().isItemEqual(stack)) { keyCache.put(key,new Object[] {ri.key,a}); if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key)) return new Object[] {ri.key,a}; } } } else if (page.recipeOutput!=null && stack !=null && page.recipeOutput.isItemEqual(stack)) { keyCache.put(key,new Object[] {ri.key,a}); if (ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), ri.key)) return new Object[] {ri.key,a}; else return null; } } } } keyCache.put(key,null); return null; }
Example 17
Source Project: mocreaturesdev Source File: MoCEntityPetScorpion.java License: GNU General Public License v3.0 | 5 votes |
@Override protected int getDropItemId() { if (!getIsAdult()) { return Item.silk.itemID; } boolean flag = (rand.nextInt(2) == 0); switch (getType()) { case 1: if (flag) { return MoCreatures.stingDirt.itemID; } return MoCreatures.chitinDirt.itemID; case 2: if (flag) { return MoCreatures.stingCave.itemID; } return MoCreatures.chitinCave.itemID; case 3: if (flag) { return MoCreatures.stingNether.itemID; } return MoCreatures.chitinNether.itemID; case 4: if (flag) { return MoCreatures.stingFrost.itemID; } return MoCreatures.chitinFrost.itemID; case 5: return Item.rottenFlesh.itemID; default: return Item.silk.itemID; } }
Example 18
Source Project: TofuCraftReload Source File: BlockTofuGemOre.java License: MIT License | 5 votes |
/** * Get the quantity dropped based on the given fortune level */ public int quantityDroppedWithBonus(int fortune, Random random) { if (fortune > 0 && Item.getItemFromBlock(this) != this.getItemDropped((IBlockState) this.getBlockState().getValidStates().iterator().next(), random, fortune)) { int i = random.nextInt(fortune + 2) - 1; if (i < 0) { i = 0; } return this.quantityDropped(random) * (i + 1); } else { return this.quantityDropped(random); } }
Example 19
Source Project: litematica Source File: ItemUtils.java License: GNU Lesser General Public License v3.0 | 5 votes |
public static String getStackString(ItemStack stack) { if (stack.isEmpty() == false) { ResourceLocation rl = Item.REGISTRY.getNameForObject(stack.getItem()); return String.format("[%s @ %d - display: %s - NBT: %s] (%s)", rl != null ? rl.toString() : "null", stack.getMetadata(), stack.getDisplayName(), stack.getTagCompound() != null ? stack.getTagCompound().toString() : "<no NBT>", stack.toString()); } return "<empty>"; }
Example 20
Source Project: OpenPeripheral-Addons Source File: TerminalIdAccess.java License: MIT License | 5 votes |
@Override public Optional<Long> getFor(ItemStack stack) { final Item item = stack.getItem(); if (item instanceof ITerminalItem) { final ITerminalItem terminalItem = (ITerminalItem)item; return Optional.fromNullable(terminalItem.getTerminalGuid(stack)); } return Optional.absent(); }
Example 21
Source Project: Hyperium Source File: MixinLayerArmorBase.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Inject(method = "renderLayer", at = @At("HEAD"), cancellable = true) private void preRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, int armorSlot, CallbackInfo ci) { ItemStack itemstack = this.getCurrentArmor(entitylivingbaseIn, armorSlot); if (itemstack != null && itemstack.getItem() instanceof ItemArmor) { Item item = itemstack.getItem(); if (Settings.HIDE_LEATHER_ARMOR && (item == Items.leather_boots || item == Items.leather_leggings || item == Items.leather_chestplate || item == Items.leather_helmet)) { ci.cancel(); } } }
Example 22
Source Project: Valkyrien-Skies Source File: ClientProxy.java License: Apache License 2.0 | 5 votes |
private static void registerBlockItem(Block toRegister) { Item item = Item.getItemFromBlock(toRegister); Minecraft.getMinecraft() .getRenderItem() .getItemModelMesher() .register(item, 0, new ModelResourceLocation(ValkyrienSkiesMod.MOD_ID + ":" + item.getTranslationKey() .substring(5), "inventory")); }
Example 23
Source Project: GregTech Source File: FacadeHelper.java License: GNU Lesser General Public License v3.0 | 5 votes |
private static ImmutableList<ItemStack> retrieveValidItemsList() { return StreamSupport.stream(Item.REGISTRY.spliterator(), false) .filter(item -> item instanceof ItemBlock) .flatMap(item -> getSubItems(item).stream()) .filter(FacadeHelper::isValidFacade) .collect(GTUtility.toImmutableList()); }
Example 24
Source Project: GardenCollection Source File: BlockLantern.java License: MIT License | 5 votes |
@Override public ArrayList<ItemStack> getDrops (World world, int x, int y, int z, int metadata, int fortune) { TileEntityLantern tile = getTileEntity(world, x, y, z); ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); int count = quantityDropped(metadata, fortune, world.rand); for(int i = 0; i < count; i++) { Item item = getItemDropped(metadata, world.rand, fortune); if (item != null) { boolean glass = false; String source = null; int sourceMeta = 0; if (tile != null) { glass = tile.hasGlass(); source = tile.getLightSource(); sourceMeta = tile.getLightSourceMeta(); } ItemStack stack = ((ItemLantern)Item.getItemFromBlock(this)).makeItemStack(1, metadata, glass, source, sourceMeta); ret.add(stack); } } return ret; }
Example 25
Source Project: Electro-Magic-Tools Source File: ItemElectricThorHammer.java License: GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { ItemStack itemStack = new ItemStack(this, 1); if (getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); itemList.add(charged); } if (getEmptyItem(itemStack) == this) { itemList.add(new ItemStack(this, 1, getMaxDamage())); } }
Example 26
Source Project: NotEnoughItems Source File: FurnaceRecipeHandler.java License: MIT License | 5 votes |
private static Set<Item> excludedFuels() { Set<Item> efuels = new HashSet<Item>(); efuels.add(Item.getItemFromBlock(Blocks.brown_mushroom)); efuels.add(Item.getItemFromBlock(Blocks.red_mushroom)); efuels.add(Item.getItemFromBlock(Blocks.standing_sign)); efuels.add(Item.getItemFromBlock(Blocks.wall_sign)); efuels.add(Item.getItemFromBlock(Blocks.trapped_chest)); return efuels; }
Example 27
Source Project: OpenPeripheral Source File: ItemStackMetadataBuilder.java License: MIT License | 5 votes |
@Override public IMetaProviderProxy createProxy(final ItemStack stack) { final Item item = stack.getItem(); if (item == null) return null; final Map<String, IItemStackMetaProvider<?>> providers = getProviders(item, stack); return new Proxy(providers, stack, item); }
Example 28
Source Project: OpenPeripheral-Integration Source File: AdapterWritingDesk.java License: MIT License | 5 votes |
private NotebookWrapper createInventoryWrapper(TileEntity tile, Index slot) { ItemStack notebook = GET_NOTEBOOK.call(tile, slot.byteValue()); Preconditions.checkState(notebook != null, "Empty slot"); Item item = notebook.getItem(); Preconditions.checkState(item instanceof IItemPageCollection, "Invalid item in slot"); return new NotebookWrapper((WorldServer)tile.getWorldObj(), (IItemPageCollection)item, notebook); }
Example 29
Source Project: Sakura_mod Source File: BlockDoorBase.java License: MIT License | 5 votes |
private Item getItem() { if(this == BlockLoader.BAMBOODOOR){ return ItemLoader.BAMBOO_DOOR; } return ItemLoader.BAMBOO_DOOR; }
Example 30
Source Project: ExtraCells1 Source File: LPHelper.java License: MIT License | 5 votes |
public LPHelper() { try { Class LPMain = Class.forName("logisticspipes.LogisticsPipes"); Field field = LPMain.getDeclaredField("LogisticsFluidContainer"); LPFluidItem = (Item) field.get(Item.appleGold); } catch (Throwable e) { LPInstalled = false; } LPInstalled = LPFluidItem != null; }