Java Code Examples for net.minecraft.item.Item#getItemFromBlock()

The following examples show how to use net.minecraft.item.Item#getItemFromBlock() . 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 File: RecipeBalloon.java    From archimedes-ships with MIT License 6 votes vote down vote up
@Override
public boolean matches(InventoryCrafting inventorycrafting, World world)
{
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			ItemStack itemstack = inventorycrafting.getStackInRowAndColumn(i, j);
			if (itemstack == null) continue;
			if (itemstack.getItem() == Item.getItemFromBlock(Blocks.wool))
			{
				ItemStack itemstack1 = inventorycrafting.getStackInRowAndColumn(i, j + 1);
				if (itemstack1 != null && itemstack1.getItem() == Items.string)
				{
					return true;
				}
				return false;
			}
			return false;
		}
	}
	return false;
}
 
Example 2
Source File: ModSubstitutions.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void preInit() {
        if(ModConfig.enableAdditionalNodeTypes) {
            try {
                ItemBlock item = (ItemBlock) Item.getItemFromBlock(ConfigBlocks.blockAiry);

                item.field_150939_a = RegisteredBlocks.blockNode;

                //Hacky way
                FMLControlledNamespacedRegistry<Block> registry = GameData.getBlockRegistry();
                registry.underlyingIntegerMap.field_148749_a.put(RegisteredBlocks.blockNode, Block.getIdFromBlock(ConfigBlocks.blockAiry));
                registry.underlyingIntegerMap.field_148748_b.set(Block.getIdFromBlock(ConfigBlocks.blockAiry), RegisteredBlocks.blockNode);
                ((BiMap)registry.field_148758_b).forcePut(RegisteredBlocks.blockNode, registry.field_148758_b.get(ConfigBlocks.blockAiry));

                registry.underlyingIntegerMap.field_148749_a.remove(ConfigBlocks.blockAiry);

                ConfigBlocks.blockAiry = RegisteredBlocks.blockNode;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
}
 
Example 3
Source File: EntityEnderminy.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
/**
   * Checks to see if this enderman should be attacking this player
   */
  private boolean shouldAttackPlayer(EntityPlayer player) {
    ItemStack itemstack = player.inventory.armorInventory.get(3);
//    3: Helmet, 2: Chestpiece, 1: Legs, 0: Boots
    if(itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN)) {
      return false;
    } else {

      Vec3d relativePlayerEyePos = new Vec3d(
          posX - player.posX,
          getEntityBoundingBox().minY + height / 2.0F - (player.posY + player.getEyeHeight()),
          posZ - player.posZ);

      double distance = relativePlayerEyePos.lengthVector();
      relativePlayerEyePos = relativePlayerEyePos.normalize();

      //NB: inverse of normal enderman, attack when this guy looks at the player instead of the other
      //way around
      Vec3d lookVec = getLook(1.0F).normalize();
      double dotTangent = -lookVec.dotProduct(relativePlayerEyePos);

      return dotTangent > 1.0D - 0.025D / distance;
    }
  }
 
Example 4
Source File: BlockRoseBush.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public Item getItemDropped(int metadata, Random rand, int fortune)
{
    if (metadata != 1)
    {
        return null;
    }
    else
    {
        return Item.getItemFromBlock(this);
    }
}
 
Example 5
Source File: ClientProxy.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(){
    for(Block block : new Block[]{ModBlocks.BLOCK_SIGNAL, ModBlocks.CHAIN_SIGNAL, ModBlocks.STATION_MARKER, ModBlocks.LIMITER_RAIL, ModBlocks.TRANSPORT_RAIL, ModBlocks.TELEPORT_RAIL, ModBlocks.CART_HOPPER, ModBlocks.RAIL_LINK}) {
        Item item = Item.getItemFromBlock(block);
        registerItemModels(item);
    }
    registerItemModels(ModItems.RAIL_NETWORK_CONTROLLER);
    registerItemModels(ModItems.CART_ENGINE);
    if(!SignalsConfig.disableChunkLoaderUpgrades) registerItemModels(ModItems.CHUNKLOADER_UPGRADE);
    registerItemModels(ModItems.RAIL_CONFIGURATOR);
}
 
Example 6
Source File: ShapedMetadataOreRecipe.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Registers a recipe where the metadata value of the first occurence of <b>sourceItem</b> in the recipe
 * bitwise OR'ed into <b>mask</b> determines the final metadata of the result ItemStack.
 * @param result
 * @param sourceItem
 * @param mask
 * @param recipe
 */
public ShapedMetadataOreRecipe(ResourceLocation name, ItemStack result, Block sourceBlock, int mask, Object... recipe)
{
    super(name, result, recipe);

    this.setRegistryName(name);
    this.sourceItem = Item.getItemFromBlock(sourceBlock);
    this.mask = mask;
}
 
Example 7
Source File: ClientProxy.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void postRegisterBlock(FWBlock block) {
	super.postRegisterBlock(block);

	//Hack to inject custom itemblock definition
	Item itemFromBlock = Item.getItemFromBlock(block);

	ModelLoader.setCustomMeshDefinition(itemFromBlock, stack -> new ModelResourceLocation(Item.REGISTRY.getNameForObject(itemFromBlock), "inventory"));
}
 
Example 8
Source File: EntityArmourStand.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
public boolean interact(EntityPlayer player, Vec3 hitPos) {
	if (!worldObj.isRemote) {
		byte b0 = 0;
		ItemStack itemstack = player.getCurrentEquippedItem();
		boolean flag = itemstack != null;

		if (flag && itemstack.getItem() instanceof ItemArmor) {
			ItemArmor itemarmor = (ItemArmor) itemstack.getItem();

			if (itemarmor.armorType == 3)
				b0 = 1;
			else if (itemarmor.armorType == 2)
				b0 = 2;
			else if (itemarmor.armorType == 1)
				b0 = 3;
			else if (itemarmor.armorType == 0)
				b0 = 4;
		}

		if (flag && (itemstack.getItem() == Items.skull || itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin)))
			b0 = 4;

		byte b1 = 0;
		boolean isSmall = isSmall();
		double d3 = isSmall ? hitPos.yCoord * 2.0D : hitPos.yCoord;

		if (d3 >= 0.1D && d3 < 0.1D + (isSmall ? 0.8D : 0.45D) && getEquipmentInSlot(1) != null)
			b1 = 1;
		else if (d3 >= 0.9D + (isSmall ? 0.3D : 0.0D) && d3 < 0.9D + (isSmall ? 1.0D : 0.7D) && getEquipmentInSlot(3) != null)
			b1 = 3;
		else if (d3 >= 0.4D && d3 < 0.4D + (isSmall ? 1.0D : 0.8D) && getEquipmentInSlot(2) != null)
			b1 = 2;
		else if (d3 >= 1.6D && getEquipmentInSlot(4) != null)
			b1 = 4;

		boolean flag2 = getEquipmentInSlot(b1) != null;

		if (flag && b0 == 0 && !getShowArms())
			return true;
		else {
			if (flag)
				func_175422_a(player, b0);
			else if (flag2)
				func_175422_a(player, b1);

			return true;
		}
	} else
		return true;
}
 
Example 9
Source File: BlockWoodSupport.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
	return Item.getItemFromBlock(this);
}
 
Example 10
Source File: BlockGregLog.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected ItemStack getSilkTouchDrop(IBlockState state) {
    return new ItemStack(Item.getItemFromBlock(this), 1,
        state.getValue(VARIANT).ordinal());
}
 
Example 11
Source File: BlockLogNatural.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
	return Item.getItemFromBlock(TFCBlocks.LogVertical);
}
 
Example 12
Source File: BlockVanillaCrop.java    From Sakura_mod with MIT 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 Item.getItemFromBlock(BlockLoader.VANILLA_SPLINT);
}
 
Example 13
Source File: BlockPepperCrop.java    From Sakura_mod with MIT 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 Item.getItemFromBlock(BlockLoader.PEPPER_SPLINT);
}
 
Example 14
Source File: NewAnvil.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
	return Item.getItemFromBlock(Blocks.anvil);
}
 
Example 15
Source File: TileEntityRegistry.java    From Sakura_mod with MIT License 4 votes vote down vote up
private static Item getItem(final Block block) {
    return Item.getItemFromBlock(block);
}
 
Example 16
Source File: ExNihiloAdscensio.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
	return Item.getItemFromBlock(ENBlocks.sieve);
}
 
Example 17
Source File: VanillaLanternSource.java    From GardenCollection with MIT License 4 votes vote down vote up
public RedstoneTorchSource () {
    super(new LanternSourceInfo("redstoneTorch", Item.getItemFromBlock(Blocks.redstone_torch), Blocks.redstone_torch.getLightValue()));
}
 
Example 18
Source File: CreativeTabBR.java    From BigReactors with MIT License 4 votes vote down vote up
public Item getTabIconItem()
{
	return Item.getItemFromBlock(BigReactors.blockYelloriteOre);
}
 
Example 19
Source File: BlockSakuraLeave.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public Item getItemDropped(IBlockState state, Random random, int fortune) {
    return Item.getItemFromBlock(BlockLoader.SAKURA_SAPLING);
}
 
Example 20
Source File: OldGravel.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
	return Item.getItemFromBlock(this);
}