Java Code Examples for net.minecraft.item.Item

The following are top voted examples for showing how to use net.minecraft.item.Item. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Backmemed   File: EnchantmentHelper.java   Source Code and License 6 votes vote down vote up
public static List<EnchantmentData> getEnchantmentDatas(int p_185291_0_, ItemStack p_185291_1_, boolean allowTreasure)
{
    List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
    Item item = p_185291_1_.getItem();
    boolean flag = p_185291_1_.getItem() == Items.BOOK;

    for (Enchantment enchantment : Enchantment.REGISTRY)
    {
        if ((!enchantment.isTreasureEnchantment() || allowTreasure) && (enchantment.type.canEnchantItem(item) || flag))
        {
            for (int i = enchantment.getMaxLevel(); i > enchantment.getMinLevel() - 1; --i)
            {
                if (p_185291_0_ >= enchantment.getMinEnchantability(i) && p_185291_0_ <= enchantment.getMaxEnchantability(i))
                {
                    list.add(new EnchantmentData(enchantment, i));
                    break;
                }
            }
        }
    }

    return list;
}
 
Example 2
Project: pnc-repressurized   File: RenderTarget.java   Source Code and License 6 votes vote down vote up
public RenderTarget(Entity entity) {
    this.entity = entity;
    trackEntries = EntityTrackHandler.getTrackersForEntity(entity);
    circle1 = new RenderTargetCircle();
    circle2 = new RenderTargetCircle();
    Item droppedItem = null;
    if (entity instanceof EntityLiving) {
        try {
            droppedItem = null;//TODO 1.8 EntityUtils.getLivingDrop((EntityLiving)entity);
        } catch (Throwable e) {
        }
    }
    if (droppedItem != null) {
        stat = new GuiAnimatedStat(null, entity.getName(), new ItemStack(droppedItem, 1, 0), 20, -20, 0x3000AA00, null, false);
    } else {
        stat = new GuiAnimatedStat(null, entity.getName(), "", 20, -20, 0x3000AA00, null, false);
    }
    stat.setMinDimensionsAndReset(0, 0);
}
 
Example 3
Project: CustomWorldGen   File: StatList.java   Source Code and License 6 votes vote down vote up
private static void initStats()
{
    for (Item item : net.minecraftforge.fml.common.registry.GameData.getItemRegistry().typeSafeIterable())
    {
        if (item != null)
        {
            int i = Item.getIdFromItem(item);
            String s = getItemName(item);

            if (s != null)
            {
                OBJECT_USE_STATS[i] = (new StatCrafting("stat.useItem.", s, new TextComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat();

                if (!(item instanceof ItemBlock))
                {
                    USE_ITEM_STATS.add((StatCrafting)OBJECT_USE_STATS[i]);
                }
            }
        }
    }

    replaceAllSimilarBlocks(OBJECT_USE_STATS, true);
}
 
Example 4
Project: Wurst-MC-1.12   File: AuthorCmd.java   Source Code and License 6 votes vote down vote up
@Override
public void call(String[] args) throws CmdException
{
	if(args.length == 0)
		throw new CmdSyntaxError();
	if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
		throw new CmdError("Creative mode only.");
	ItemStack item = WMinecraft.getPlayer().inventory.getCurrentItem();
	if(item == null || Item.getIdFromItem(item.getItem()) != 387)
		throw new CmdError(
			"You are not holding a written book in your hand.");
	String author = args[0];
	for(int i = 1; i < args.length; i++)
		author += " " + args[i];
	item.setTagInfo("author", new NBTTagString(author));
}
 
Example 5
Project: CustomWorldGen   File: GameRegistry.java   Source Code and License 5 votes vote down vote up
/**
 * Makes an {@link ItemStack} based on the itemName reference, with supplied meta, stackSize and nbt, if possible
 * <p/>
 * Will return null if the item doesn't exist (because it's not from a loaded mod for example)
 * Will throw a {@link RuntimeException} if the nbtString is invalid for use in an {@link ItemStack}
 *
 * @param itemName  a registry name reference
 * @param meta      the meta
 * @param stackSize the stack size
 * @param nbtString an nbt stack as a string, will be processed by {@link JsonToNBT}
 * @return a new itemstack
 */
public static ItemStack makeItemStack(String itemName, int meta, int stackSize, String nbtString)
{
    if (itemName == null)
    {
        throw new IllegalArgumentException("The itemName cannot be null");
    }
    Item item = GameData.getItemRegistry().getObject(new ResourceLocation(itemName));
    if (item == null)
    {
        FMLLog.getLogger().log(Level.TRACE, "Unable to find item with name {}", itemName);
        return null;
    }
    ItemStack is = new ItemStack(item, stackSize, meta);
    if (!Strings.isNullOrEmpty(nbtString))
    {
        NBTBase nbttag = null;
        try
        {
            nbttag = JsonToNBT.getTagFromJson(nbtString);
        } catch (NBTException e)
        {
            FMLLog.getLogger().log(Level.WARN, "Encountered an exception parsing ItemStack NBT string {}", nbtString, e);
            throw Throwables.propagate(e);
        }
        if (!(nbttag instanceof NBTTagCompound))
        {
            FMLLog.getLogger().log(Level.WARN, "Unexpected NBT string - multiple values {}", nbtString);
            throw new RuntimeException("Invalid NBT JSON");
        }
        else
        {
            is.setTagCompound((NBTTagCompound)nbttag);
        }
    }
    return is;
}
 
Example 6
Project: Backmemed   File: EntityLivingBase.java   Source Code and License 5 votes vote down vote up
/**
 * Plays sounds and makes particles for item in use state
 */
protected void updateItemUse(ItemStack stack, int eatingParticleCount)
{
    if (!stack.func_190926_b() && this.isHandActive())
    {
        if (stack.getItemUseAction() == EnumAction.DRINK)
        {
            this.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
        }

        if (stack.getItemUseAction() == EnumAction.EAT)
        {
            for (int i = 0; i < eatingParticleCount; ++i)
            {
                Vec3d vec3d = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
                vec3d = vec3d.rotatePitch(-this.rotationPitch * 0.017453292F);
                vec3d = vec3d.rotateYaw(-this.rotationYaw * 0.017453292F);
                double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
                Vec3d vec3d1 = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
                vec3d1 = vec3d1.rotatePitch(-this.rotationPitch * 0.017453292F);
                vec3d1 = vec3d1.rotateYaw(-this.rotationYaw * 0.017453292F);
                vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);

                if (stack.getHasSubtypes())
                {
                    this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem()), stack.getMetadata()});
                }
                else
                {
                    this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem())});
                }
            }

            this.playSound(SoundEvents.ENTITY_GENERIC_EAT, 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
        }
    }
}
 
Example 7
Project: Backmemed   File: BlockStoneSlab.java   Source Code and License 5 votes vote down vote up
/**
 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
 */
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list)
{
    if (itemIn != Item.getItemFromBlock(Blocks.DOUBLE_STONE_SLAB))
    {
        for (BlockStoneSlab.EnumType blockstoneslab$enumtype : BlockStoneSlab.EnumType.values())
        {
            if (blockstoneslab$enumtype != BlockStoneSlab.EnumType.WOOD)
            {
                list.add(new ItemStack(itemIn, 1, blockstoneslab$enumtype.getMetadata()));
            }
        }
    }
}
 
Example 8
Project: ExPetrum   File: ClientRegistry.java   Source Code and License 5 votes vote down vote up
public static void registerToolModels()
{
    List<Item> toolsList = Arrays.asList(ExPItems.knife, ExPItems.pickaxe, ExPItems.axe, ExPItems.shovel, ExPItems.hoe, ExPItems.sword, ExPItems.scythe, ExPItems.battleaxe, ExPItems.hammer, ExPItems.spear, ExPItems.watering_can, ExPItems.gardening_spade);
    toolsList.forEach(tool -> ModelLoader.setCustomMeshDefinition(tool, stack -> new ModelResourceLocation(new ResourceLocation(tool.getRegistryName().getResourceDomain(), "tools/" + tool.getRegistryName().getResourcePath()), "material=" + EnumToolStats.values()[stack.getMetadata()].getName())));
    for (int i = 0; i < EnumToolStats.values().length; ++i)
    {
        Integer lambdaCaptureInt = i;
        toolsList.forEach(tool -> ModelLoader.registerItemVariants(tool, new ModelResourceLocation(new ResourceLocation(tool.getRegistryName().getResourceDomain(), "tools/" + tool.getRegistryName().getResourcePath()), "material=" + EnumToolStats.values()[lambdaCaptureInt].getName())));
    }
}
 
Example 9
Project: CustomWorldGen   File: FMLMissingMappingsEvent.java   Source Code and License 5 votes vote down vote up
/**
 * Remap the missing item to the specified Item.
 *
 * Use this if you have renamed an Item.
 * Existing references using the old name will point to the new one.
 *
 * @param target Item to remap to.
 */
public void remap(Item target)
{
    if (type != GameRegistry.Type.ITEM) throw new IllegalArgumentException("Can't remap a block to an item.");
    if (target == null) throw new NullPointerException("remap target is null");
    if (GameData.getItemRegistry().getId(target) < 0) throw new IllegalArgumentException(String.format("The specified item %s hasn't been registered at startup.", target));

    action = Action.REMAP;
    this.target = target;
}
 
Example 10
Project: Backmemed   File: PotionHelper.java   Source Code and License 5 votes vote down vote up
public static ItemStack doReaction(ItemStack reagent, ItemStack potionIn)
{
    if (!potionIn.func_190926_b())
    {
        PotionType potiontype = PotionUtils.getPotionFromItem(potionIn);
        Item item = potionIn.getItem();
        int i = 0;

        for (int j = POTION_ITEM_CONVERSIONS.size(); i < j; ++i)
        {
            PotionHelper.MixPredicate<Item> mixpredicate = (PotionHelper.MixPredicate)POTION_ITEM_CONVERSIONS.get(i);

            if (mixpredicate.input == item && mixpredicate.reagent.apply(reagent))
            {
                return PotionUtils.addPotionToItemStack(new ItemStack((Item)mixpredicate.output), potiontype);
            }
        }

        i = 0;

        for (int k = POTION_TYPE_CONVERSIONS.size(); i < k; ++i)
        {
            PotionHelper.MixPredicate<PotionType> mixpredicate1 = (PotionHelper.MixPredicate)POTION_TYPE_CONVERSIONS.get(i);

            if (mixpredicate1.input == potiontype && mixpredicate1.reagent.apply(reagent))
            {
                return PotionUtils.addPotionToItemStack(new ItemStack(item), (PotionType)mixpredicate1.output);
            }
        }
    }

    return potionIn;
}
 
Example 11
Project: Firma   File: MetaItem.java   Source Code and License 5 votes vote down vote up
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
	for (int c = 0; c < subs.size(); c++) {
		ItemStack is = new ItemStack(this, 1, c);
		subItems.add(is);
	}
}
 
Example 12
Project: CustomWorldGen   File: BlockSandStone.java   Source Code and License 5 votes vote down vote up
/**
 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
 */
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
    for (BlockSandStone.EnumType blocksandstone$enumtype : BlockSandStone.EnumType.values())
    {
        list.add(new ItemStack(itemIn, 1, blocksandstone$enumtype.getMetadata()));
    }
}
 
Example 13
Project: modName   File: ModRegistry.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public void onItemRegistry(RegistryEvent.Register<Item> e) 
{
	e.getRegistry().registerAll(Ref.ITEMS.toArray(new Item[0]));
	for (Block block : Ref.BLOCKS)
		e.getRegistry().register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
}
 
Example 14
Project: Backmemed   File: BlockWall.java   Source Code and License 5 votes vote down vote up
/**
 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
 */
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list)
{
    for (BlockWall.EnumType blockwall$enumtype : BlockWall.EnumType.values())
    {
        list.add(new ItemStack(itemIn, 1, blockwall$enumtype.getMetadata()));
    }
}
 
Example 15
Project: BaseClient   File: EntityVillager.java   Source Code and License 5 votes vote down vote up
public ItemAndEmeraldToItem(Item p_i45813_1_, EntityVillager.PriceInfo p_i45813_2_, Item p_i45813_3_, EntityVillager.PriceInfo p_i45813_4_)
{
    this.field_179411_a = new ItemStack(p_i45813_1_);
    this.field_179409_b = p_i45813_2_;
    this.field_179410_c = new ItemStack(p_i45813_3_);
    this.field_179408_d = p_i45813_4_;
}
 
Example 16
Project: CustomWorldGen   File: Items.java   Source Code and License 5 votes vote down vote up
private static Item getRegisteredItem(String name)
{
    Item item = (Item)Item.REGISTRY.getObject(new ResourceLocation(name));

    if (item == null)
    {
        throw new IllegalStateException("Invalid Item requested: " + name);
    }
    else
    {
        return item;
    }
}
 
Example 17
Project: customstuff4   File: ContentBlockBase.java   Source Code and License 5 votes vote down vote up
protected void initItem(Item item, ContentHelper helper)
{
    this.item = item;

    item.setUnlocalizedName(helper.getModId() + "." + id);
    item.setRegistryName(id);
}
 
Example 18
Project: BaseClient   File: BlockNewLeaf.java   Source Code and License 5 votes vote down vote up
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 19
Project: BaseClient   File: BlockRedstoneOre.java   Source Code and License 5 votes vote down vote up
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Items.redstone;
}
 
Example 20
Project: Aeon-Horizons   File: BlockOre.java   Source Code and License 5 votes vote down vote up
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
    int meta = getMetaFromState(state);

    if (meta == EnumOreType.STARDUST.getMetadata())
        {
        return ModItems.resource;
        }

    return super.getItemDropped(state, rand, fortune);
    }
 
Example 21
Project: CustomWorldGen   File: BlockSponge.java   Source Code and License 5 votes vote down vote up
/**
 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
 */
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
    list.add(new ItemStack(itemIn, 1, 0));
    list.add(new ItemStack(itemIn, 1, 1));
}
 
Example 22
Project: Bewitchment   File: BlockModLeaves.java   Source Code and License 5 votes vote down vote up
@Override
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) {
	if (!worldIn.isRemote && stack.getItem() instanceof ItemShears) {
		player.addStat(StatList.getBlockStats(this));
		spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this)));
	} else {
		super.harvestBlock(worldIn, player, pos, state, te, stack);
	}
}
 
Example 23
Project: Backmemed   File: ModelBakery.java   Source Code and License 5 votes vote down vote up
private void loadItemModels()
{
    this.registerVariantNames();

    for (Item item : Item.REGISTRY)
    {
        for (String s : this.getVariantNames(item))
        {
            ResourceLocation resourcelocation = this.getItemLocation(s);
            ResourceLocation resourcelocation1 = (ResourceLocation)Item.REGISTRY.getNameForObject(item);
            this.loadItemModel(s, resourcelocation, resourcelocation1);

            if (item.hasCustomProperties())
            {
                ModelBlock modelblock = (ModelBlock)this.models.get(resourcelocation);

                if (modelblock != null)
                {
                    for (ResourceLocation resourcelocation2 : modelblock.getOverrideLocations())
                    {
                        this.loadItemModel(resourcelocation2.toString(), resourcelocation2, resourcelocation1);
                    }
                }
            }
        }
    }
}
 
Example 24
Project: CustomWorldGen   File: GameRegistry.java   Source Code and License 5 votes vote down vote up
/**
 * Use {@link #register(IForgeRegistryEntry)} instead
 */
@Deprecated
public static void registerItem(Item item, String name)
{
    if (item.getRegistryName() == null && Strings.isNullOrEmpty(name))
        throw new IllegalArgumentException("Attempted to register a item with no name: " + item);
    if (item.getRegistryName() != null && !item.getRegistryName().toString().equals(name))
        throw new IllegalArgumentException("Attempted to register a item with conflicting names. Old: " + item.getRegistryName() + " New: " + name);
    register(item.getRegistryName() == null ? item.setRegistryName(name) : item);
}
 
Example 25
Project: CustomWorldGen   File: BlockSand.java   Source Code and License 5 votes vote down vote up
/**
 * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
 */
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
    for (BlockSand.EnumType blocksand$enumtype : BlockSand.EnumType.values())
    {
        list.add(new ItemStack(itemIn, 1, blocksand$enumtype.getMetadata()));
    }
}
 
Example 26
Project: pnc-repressurized   File: Itemss.java   Source Code and License 5 votes vote down vote up
private static void registerUpgrades(IForgeRegistry<Item> registry) {
    for (EnumUpgrade upgrade : EnumUpgrade.values()) {
        if (upgrade != EnumUpgrade.THAUMCRAFT || Loader.isModLoaded(ModIds.THAUMCRAFT)) {
            String upgradeName = upgrade.toString().toLowerCase() + "_upgrade";
            Item upgradeItem = new ItemMachineUpgrade(upgradeName, upgrade.ordinal());
            registerItem(registry, upgradeItem);
            upgrades.put(upgrade, upgradeItem);
        }
    }
}
 
Example 27
Project: minecraft-quiverbow   File: LapisMagazine.java   Source Code and License 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) 
   {  
	if (world.isRemote) { return stack; }				// Not doing this on client side
	if (stack.getItemDamage() == 0) { return stack; }	// Already fully loaded
	if (stack.getItemDamage() < 25) { return stack; }	// No room for another lapis block
	
	boolean doSFX = false;
	
	//if (player.inventory.hasItemStack(this.lapisStack))
	if (player.inventory.hasItem(Item.getItemFromBlock(Blocks.lapis_block)))
	{
		//this.consumeItemStack(player.inventory, this.lapisStack);	// We're just grabbing what we need from the inventory
		
		int dmg = stack.getItemDamage() - 25;
		stack.setItemDamage(dmg);
		
		player.inventory.consumeInventoryItem(Item.getItemFromBlock(Blocks.lapis_block));	// We're just grabbing what we need from the inventory
		
		// SFX
		doSFX = true;
	}
	// else, doesn't have what it takes
	
	if (doSFX) { world.playSoundAtEntity(player, "random.wood_click", 1.0F, 0.2F); }
	
	return stack;
   }
 
Example 28
Project: Backmemed   File: Barrier.java   Source Code and License 5 votes vote down vote up
protected Barrier(World worldIn, double p_i46286_2_, double p_i46286_4_, double p_i46286_6_, Item p_i46286_8_)
{
    super(worldIn, p_i46286_2_, p_i46286_4_, p_i46286_6_, 0.0D, 0.0D, 0.0D);
    this.setParticleTexture(Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getParticleIcon(p_i46286_8_));
    this.particleRed = 1.0F;
    this.particleGreen = 1.0F;
    this.particleBlue = 1.0F;
    this.motionX = 0.0D;
    this.motionY = 0.0D;
    this.motionZ = 0.0D;
    this.particleGravity = 0.0F;
    this.particleMaxAge = 80;
}
 
Example 29
Project: pnc-repressurized   File: ModuleRegistrator.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public static void init(RegistryEvent.Register<Item> event) {
    IForgeRegistry<Item> registry = event.getRegistry();
    registerModule(registry, ModuleSafetyValve.class);
    registerModule(registry, ModulePressureGauge.class);
    registerModule(registry, ModuleFlowDetector.class);
    registerModule(registry, ModuleAirGrate.class);
    registerModule(registry, ModuleRegulatorTube.class);
    registerModule(registry, ModuleCharging.class);
    registerModule(registry, ModuleLogistics.class);
}
 
Example 30
Project: BaseClient   File: BlockNewLeaf.java   Source Code and License 4 votes vote down vote up
protected ItemStack createStackedBlock(IBlockState state)
{
    return new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4);
}
 
Example 31
Project: ToughExpansion   File: ModCreativeTab.java   Source Code and License 4 votes vote down vote up
@Override
public Item getTabIconItem() {
	return new ItemStack(ModBlocks.TEMP_REGULATOR).getItem();
}
 
Example 32
Project: CustomWorldGen   File: BlockOldLeaf.java   Source Code and License 4 votes vote down vote up
protected ItemStack createStackedBlock(IBlockState state)
{
    return new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata());
}
 
Example 33
Project: CustomWorldGen   File: BlockMobSpawner.java   Source Code and License 4 votes vote down vote up
/**
 * Get the Item that this Block should drop when harvested.
 */
@Nullable
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return null;
}
 
Example 34
Project: Thermionics   File: ThermionicsItems.java   Source Code and License 4 votes vote down vote up
public static <T extends Item> T item(IForgeRegistry<Item> registry, T t) {
	registry.register(t);
	Thermionics.instance().needModelRegistration.add(t);
	return t;
}
 
Example 35
Project: CustomWorldGen   File: MerchantRecipe.java   Source Code and License 4 votes vote down vote up
public MerchantRecipe(ItemStack buy1, Item sellItem)
{
    this(buy1, new ItemStack(sellItem));
}
 
Example 36
Project: BetterBeginningsReborn   File: KilnRecipeHandler.java   Source Code and License 4 votes vote down vote up
public void addLists(Item input, ItemStack itemStack, float experience)
{
	putLists(new StackRecipeElement(input, 1, OreDictionary.WILDCARD_VALUE), itemStack, experience);
}
 
Example 37
Project: BaseClient   File: BlockCauldron.java   Source Code and License 4 votes vote down vote up
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Items.cauldron;
}
 
Example 38
Project: BetterBeginningsReborn   File: RegisterMetaItemRenders.java   Source Code and License 4 votes vote down vote up
public static void registerItemIconWithMeta(Item item, int meta, String filename)
{
	ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(new ResourceLocation(ModMain.MODID, filename), "inventory"));
}
 
Example 39
Project: Firma   File: ClayBlock.java   Source Code and License 4 votes vote down vote up
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
	for (final RockEnum enumType : RockEnum.values()) {
		list.add(new ItemStack(this, 1, enumType.getMeta()));
	}
}
 
Example 40
Project: BaseClient   File: BlockVine.java   Source Code and License 4 votes vote down vote up
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
	return null;
}
 
Example 41
Project: Simple-Chunks   File: CommonProxy.java   Source Code and License 4 votes vote down vote up
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
	event.getRegistry().register(new ItemBlock(ModBlocks.chunkLoader).setRegistryName(ModBlocks.chunkLoader.getRegistryName()));
}
 
Example 42
Project: Backmemed   File: BlockMobSpawner.java   Source Code and License 4 votes vote down vote up
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Items.field_190931_a;
}
 
Example 43
Project: BaseClient   File: RecipeRepairItem.java   Source Code and License 4 votes vote down vote up
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    List<ItemStack> list = Lists.<ItemStack>newArrayList();

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null)
        {
            list.add(itemstack);

            if (list.size() > 1)
            {
                ItemStack itemstack1 = (ItemStack)list.get(0);

                if (itemstack.getItem() != itemstack1.getItem() || itemstack1.stackSize != 1 || itemstack.stackSize != 1 || !itemstack1.getItem().isDamageable())
                {
                    return null;
                }
            }
        }
    }

    if (list.size() == 2)
    {
        ItemStack itemstack2 = (ItemStack)list.get(0);
        ItemStack itemstack3 = (ItemStack)list.get(1);

        if (itemstack2.getItem() == itemstack3.getItem() && itemstack2.stackSize == 1 && itemstack3.stackSize == 1 && itemstack2.getItem().isDamageable())
        {
            Item item = itemstack2.getItem();
            int j = item.getMaxDamage() - itemstack2.getItemDamage();
            int k = item.getMaxDamage() - itemstack3.getItemDamage();
            int l = j + k + item.getMaxDamage() * 5 / 100;
            int i1 = item.getMaxDamage() - l;

            if (i1 < 0)
            {
                i1 = 0;
            }

            return new ItemStack(itemstack2.getItem(), 1, i1);
        }
    }

    return null;
}
 
Example 44
Project: MagicWinds   File: ToolTestSword.java   Source Code and License 4 votes vote down vote up
public ToolTestSword(String name, Item.ToolMaterial material, CreativeTabs tab) {
    super(name, material, tab);
}
 
Example 45
Project: Backmemed   File: BlockGrassPath.java   Source Code and License 4 votes vote down vote up
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Blocks.DIRT.getItemDropped(Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
}
 
Example 46
Project: EasyCraft   File: BlockLoader.java   Source Code and License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
private static void registerRender(Block block) {
	ModelResourceLocation model = new ModelResourceLocation(block.getRegistryName(), "inventory");
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, model);
}
 
Example 47
Project: connor41-etfuturum2   File: BlockWoodDoor.java   Source Code and License 4 votes vote down vote up
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
	return (meta & 8) != 0 ? null : Item.getItemFromBlock(this);
}
 
Example 48
Project: CustomWorldGen   File: CreativeTabs.java   Source Code and License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public Item getTabIconItem()
{
    return Items.APPLE;
}
 
Example 49
Project: PurificatiMagicae   File: ClientUtils.java   Source Code and License 4 votes vote down vote up
public static void setModelLocationDirBased(Item itm, int meta, String file)
{
    ModelLoader.setCustomModelResourceLocation(itm, meta, new ModelResourceLocation(itm.getRegistryName() + "/" + file, "normal"));
}
 
Example 50
Project: Technical   File: GrinderMedium.java   Source Code and License 4 votes vote down vote up
public Item getItem(World world, int par2, int par3, int par4) {
	return Item.getItemFromBlock(TechnicalBlock.GrinderMediumIdle);
}
 
Example 51
Project: Zombe-Modpack   File: ZWrapper.java   Source Code and License 4 votes vote down vote up
@Deprecated
public static int getId(Item item) {
    return Item.getIdFromItem(item);
}
 
Example 52
Project: pnc-repressurized   File: TileEntityAirCannon.java   Source Code and License 4 votes vote down vote up
private void updateDestination() {
    doneTurning = false;
    // take dispenser upgrade in account
    double payloadFrictionY = 0.98D; // this value will differ when a dispenser upgrade is inserted.
    double payloadFrictionX = 0.98D;
    double payloadGravity = 0.04D;
    if (getUpgrades(EnumUpgrade.ENTITY_TRACKER) > 0) {
        payloadFrictionY = 0.98D;
        payloadFrictionX = 0.91D;
        payloadGravity = 0.08D;
    } else if (getUpgrades(EnumUpgrade.DISPENSER) > 0 && !inventory.getStackInSlot(CANNON_SLOT).isEmpty()) {
        Item item = inventory.getStackInSlot(CANNON_SLOT).getItem();
        if (item == Items.POTIONITEM || item == Items.EXPERIENCE_BOTTLE || item == Items.EGG || item == Items.SNOWBALL) {// EntityThrowable
            payloadFrictionY = 0.99D;
            payloadGravity = 0.03D;
        } else if (item == Items.ARROW) {
            payloadFrictionY = 0.99D;
            payloadGravity = 0.05D;
        } else if (item == Items.MINECART || item == Items.CHEST_MINECART || item == Items.HOPPER_MINECART || item == Items.TNT_MINECART || item == Items.FURNACE_MINECART) {
            payloadFrictionY = 0.95D;
        }
        // else if(itemID == Item.fireballCharge.itemID){
        // payloadGravity = 0.0D;
        // }

        // family items (throwable) which only differ in gravity.
        if (item == Items.POTIONITEM) {
            payloadGravity = 0.05D;
        } else if (item == Items.EXPERIENCE_BOTTLE) {
            payloadGravity = 0.07D;
        }

        payloadFrictionX = payloadFrictionY;

        // items which have different frictions for each axis.
        if (item == Items.BOAT) {
            payloadFrictionX = 0.99D;
            payloadFrictionY = 0.95D;
        }
        if (item == Items.SPAWN_EGG) {
            payloadFrictionY = 0.98D;
            payloadFrictionX = 0.91D;
            payloadGravity = 0.08D;
        }
    }

    // calculate the heading.
    double deltaX = gpsX - getPos().getX();
    double deltaZ = gpsZ - getPos().getZ();
    float calculatedRotationAngle;
    if (deltaX >= 0 && deltaZ < 0) {
        calculatedRotationAngle = (float) (Math.atan(Math.abs(deltaX / deltaZ)) / Math.PI * 180D);
    } else if (deltaX >= 0 && deltaZ >= 0) {
        calculatedRotationAngle = (float) (Math.atan(Math.abs(deltaZ / deltaX)) / Math.PI * 180D) + 90;
    } else if (deltaX < 0 && deltaZ >= 0) {
        calculatedRotationAngle = (float) (Math.atan(Math.abs(deltaX / deltaZ)) / Math.PI * 180D) + 180;
    } else {
        calculatedRotationAngle = (float) (Math.atan(Math.abs(deltaZ / deltaX)) / Math.PI * 180D) + 270;
    }

    // calculate the height angle.
    double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
    double deltaY = gpsY - getPos().getY();
    float calculatedHeightAngle = calculateBestHeightAngle(distance, deltaY, getForce(), payloadGravity, payloadFrictionX, payloadFrictionY);

    setTargetAngles(calculatedRotationAngle, calculatedHeightAngle);
}
 
Example 53
Project: pnc-repressurized   File: HackUpgradeRenderHandler.java   Source Code and License 4 votes vote down vote up
@Override
public Item[] getRequiredUpgrades() {
    return new Item[]{Itemss.upgrades.get(EnumUpgrade.SECURITY)};
}
 
Example 54
Project: BaseClient   File: EntityVillager.java   Source Code and License 4 votes vote down vote up
public ListItemForEmeralds(Item par1Item, EntityVillager.PriceInfo priceInfo)
{
    this.field_179403_a = new ItemStack(par1Item);
    this.field_179402_b = priceInfo;
}
 
Example 55
Project: ExPetrum   File: BlockFruit.java   Source Code and License 4 votes vote down vote up
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return ExPItems.food;
}
 
Example 56
Project: Got-Wood   File: BlockWoodSlab.java   Source Code and License 4 votes vote down vote up
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
	return this.getSlabItem();
}
 
Example 57
Project: BaseClient   File: BlockSnow.java   Source Code and License 4 votes vote down vote up
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Items.snowball;
}
 
Example 58
Project: pnc-repressurized   File: SensorHandler.java   Source Code and License 4 votes vote down vote up
@Override
public Set<Item> getRequiredUpgrades() {
    Set<Item> upgrades = new HashSet<Item>(coordinateSensor.getRequiredUpgrades());
    upgrades.add(Itemss.GPS_TOOL);
    return upgrades;
}
 
Example 59
Project: ExPetrum   File: ClientRegistry.java   Source Code and License 4 votes vote down vote up
public static void registerModels()
{
    // Model loaders
    OBJLoader.INSTANCE.addDomain("exp");
    ModelLoaderRegistry.registerLoader(new ModelLoaderExP());

    // Statically mapped block models
    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ExPBlocks.coralRock), 0, new ModelResourceLocation(ExPBlocks.coralRock.getRegistryName(), "rtindex=0"));
    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ExPBlocks.coralPlant), 0, new ModelResourceLocation(ExPBlocks.coralPlant.getRegistryName(), "ptindex=0,rtindex=0"));
    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ExPBlocks.snow), 0, new ModelResourceLocation(ExPBlocks.snow.getRegistryName(), "layers=1"));
    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ExPBlocks.crop), 0, new ModelResourceLocation("exp:crops/dead", "normal"));

    // Iteration-dependent models
    mkCustomModelResourceLocations(ExPItems.stick, EnumTreeType.values().length + EnumShrubType.values().length + EnumBerry.values().length, i -> "type=" + ExPOreDict.stickNames[i]);
    mkCustomModelResourceLocations(ExPItems.toolHead, EnumToolhead.values().length, i -> "type=" + EnumToolhead.values()[i].getName());
    mkCustomModelResourceLocations(ExPItems.seeds, EnumCrop.values().length - 1, i -> "crop=" + EnumCrop.values()[i + 1].getName());
    mkCustomModelResourceLocations(ExPItems.food, FoodEntry.allEntries.size(), i -> "type=" + FoodEntry.allEntries.get(i).getUnlocalizedName());
    mkCustomModelResourceLocations(ExPItems.ingot, EnumMetal.values().length, null);
    mkCustomModelResourceLocations(ExPBlocks.pebble, 16, i -> "amdl=0,class=" + EnumRockClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.boulder, 16, i -> "amdl=0,class=" + EnumRockClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.workedBoulder, 16, i -> "class=" + EnumRockClass.values()[i].getName() + ",workindex=0");
    mkCustomModelResourceLocations(ExPItems.rock, 16, i -> "class=" + EnumRockClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPItems.rock, 16, i -> "class=" + EnumRockClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.ice, 2, i -> "salt=" + (i == 1));
    mkCustomModelResourceLocations(ExPBlocks.vegetation, 4, i -> "inventory-" + i);
    mkCustomModelResourceLocations(ExPBlocks.waterLily, 10, i -> "blooming=" + (i >= 5) + ",type=" + EnumWaterLilyType.values()[i % 5].getName());
    mkCustomModelResourceLocations(ExPBlocks.fruit, 15, i -> "type=" + EnumFruit.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.rock, 16, i -> "class=" + EnumRockClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.soil, 16, i -> "class=" + EnumDirtClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.grass, 16, i -> "class=" + EnumDirtClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.grass_dry, 16, i -> "class=" + EnumDirtClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.grass_dead, 16, i -> "class=" + EnumDirtClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.cattail, 16, i -> "class=" + EnumDirtClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.sand, 16, i -> "class=" + EnumRockClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.seaweed, 16, i -> "class=" + EnumRockClass.values()[i].getName());
    mkCustomModelResourceLocations(ExPBlocks.farmland, 16, i -> "class=" + EnumDirtClass.values()[i].getName());

    // Statically mapped item models
    registerStaticModel(ExPItems.basket, new ModelResourceLocation(ExPItems.basket.getRegistryName(), "inventory"));

    // Other models
    registerToolModels();
    registerFluidModels();
    registerTreeModels();
    registerOreModels();
    registerBerryBushModels();
    registerShrubModels();
    registerShrubberyModels();

    // State mappers
    registerCustomStateMappers();
}
 
Example 60
Project: Bewitchment   File: BlockCrop.java   Source Code and License 4 votes vote down vote up
@Override
public void setSeed(Item seed) {
	this.seed = seed;
}