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

The following examples show how to use net.minecraft.item.Item#getItemFromBlock() .
Example 1
Project: archimedes-ships   File: RecipeBalloon.java    License: 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
Project: Gadomancy   File: ModSubstitutions.java    License: 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
Project: EnderZoo   File: EntityEnderminy.java    License: 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
Project: ForbiddenMagic   File: BlockRoseBush.java    License: 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
Project: NOVA-Core   File: ClientProxy.java    License: 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 6
Project: enderutilities   File: ShapedMetadataOreRecipe.java    License: 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
Project: Signals   File: ClientProxy.java    License: 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 8
Project: TFC2   File: BlockWoodSupport.java    License: 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 9
Project: Et-Futurum   File: OldGravel.java    License: The Unlicense 4 votes vote down vote up
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
	return Item.getItemFromBlock(this);
}
 
Example 10
Project: Sakura_mod   File: BlockSakuraLeave.java    License: 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 11
Project: BigReactors   File: CreativeTabBR.java    License: MIT License 4 votes vote down vote up
public Item getTabIconItem()
{
	return Item.getItemFromBlock(BigReactors.blockYelloriteOre);
}
 
Example 12
Project: GardenCollection   File: VanillaLanternSource.java    License: MIT License 4 votes vote down vote up
public RedstoneTorchSource () {
    super(new LanternSourceInfo("redstoneTorch", Item.getItemFromBlock(Blocks.redstone_torch), Blocks.redstone_torch.getLightValue()));
}
 
Example 13
Project: ExNihiloAdscensio   File: ExNihiloAdscensio.java    License: MIT License 4 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
	return Item.getItemFromBlock(ENBlocks.sieve);
}
 
Example 14
Project: Sakura_mod   File: TileEntityRegistry.java    License: MIT License 4 votes vote down vote up
private static Item getItem(final Block block) {
    return Item.getItemFromBlock(block);
}
 
Example 15
Project: Et-Futurum   File: NewAnvil.java    License: The Unlicense 4 votes vote down vote up
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
	return Item.getItemFromBlock(Blocks.anvil);
}
 
Example 16
Project: Sakura_mod   File: BlockPepperCrop.java    License: 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 17
Project: Sakura_mod   File: BlockVanillaCrop.java    License: 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 18
Project: TFC2   File: BlockLogNatural.java    License: 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 19
Project: GregTech   File: BlockGregLog.java    License: 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 20
Project: Et-Futurum   File: EntityArmourStand.java    License: 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;
}