Java Code Examples for net.minecraft.init.Blocks.air()

The following are Jave code examples for showing how to use air() of the net.minecraft.init.Blocks class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: Chunk.java   View Source Code Vote up 6 votes
/**
 * Returns the block corresponding to the given coordinates inside a chunk.
 */
private Block getBlock0(int x, int y, int z)
{
    Block block = Blocks.air;

    if (y >= 0 && y >> 4 < this.storageArrays.length)
    {
        ExtendedBlockStorage extendedblockstorage = this.storageArrays[y >> 4];

        if (extendedblockstorage != null)
        {
            try
            {
                block = extendedblockstorage.getBlockByExtId(x, y & 15, z);
            }
            catch (Throwable throwable)
            {
                CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Getting block");
                throw new ReportedException(crashreport);
            }
        }
    }

    return block;
}
 
Example 2
Project: DecompiledMinecraft   File: ExtendedBlockStorage.java   View Source Code Vote up 6 votes
public void removeInvalidBlocks()
{
    this.blockRefCount = 0;
    this.tickRefCount = 0;

    for (int i = 0; i < 16; ++i)
    {
        for (int j = 0; j < 16; ++j)
        {
            for (int k = 0; k < 16; ++k)
            {
                Block block = this.getBlockByExtId(i, j, k);

                if (block != Blocks.air)
                {
                    ++this.blockRefCount;

                    if (block.getTickRandomly())
                    {
                        ++this.tickRefCount;
                    }
                }
            }
        }
    }
}
 
Example 3
Project: BaseClient   File: EntityAIHarvestFarmland.java   View Source Code Vote up 6 votes
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.farmland)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7 && this.field_179503_e && (this.field_179501_f == 0 || this.field_179501_f < 0))
        {
            this.field_179501_f = 0;
            return true;
        }

        if (block == Blocks.air && this.hasFarmItem && (this.field_179501_f == 1 || this.field_179501_f < 0))
        {
            this.field_179501_f = 1;
            return true;
        }
    }

    return false;
}
 
Example 4
Project: BaseClient   File: EntityAIHarvestFarmland.java   View Source Code Vote up 6 votes
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.farmland)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7 && this.field_179503_e && (this.field_179501_f == 0 || this.field_179501_f < 0))
        {
            this.field_179501_f = 0;
            return true;
        }

        if (block == Blocks.air && this.hasFarmItem && (this.field_179501_f == 1 || this.field_179501_f < 0))
        {
            this.field_179501_f = 1;
            return true;
        }
    }

    return false;
}
 
Example 5
Project: BaseClient   File: BlockDynamicLiquid.java   View Source Code Vote up 6 votes
private void tryFlowInto(World worldIn, BlockPos pos, IBlockState state, int level)
{
    if (this.canFlowInto(worldIn, pos, state))
    {
        if (state.getBlock() != Blocks.air)
        {
            if (this.blockMaterial == Material.lava)
            {
                this.triggerMixEffects(worldIn, pos);
            }
            else
            {
                state.getBlock().dropBlockAsItem(worldIn, pos, state, 0);
            }
        }

        worldIn.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(level)), 3);
    }
}
 
Example 6
Project: DecompiledMinecraft   File: ExtendedBlockStorage.java   View Source Code Vote up 6 votes
public void removeInvalidBlocks()
{
    this.blockRefCount = 0;
    this.tickRefCount = 0;

    for (int i = 0; i < 16; ++i)
    {
        for (int j = 0; j < 16; ++j)
        {
            for (int k = 0; k < 16; ++k)
            {
                Block block = this.getBlockByExtId(i, j, k);

                if (block != Blocks.air)
                {
                    ++this.blockRefCount;

                    if (block.getTickRandomly())
                    {
                        ++this.tickRefCount;
                    }
                }
            }
        }
    }
}
 
Example 7
Project: DecompiledMinecraft   File: TileEntity.java   View Source Code Vote up 5 votes
/**
 * For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it
 * hasn't changed and skip it.
 */
public void markDirty()
{
    if (this.worldObj != null)
    {
        IBlockState iblockstate = this.worldObj.getBlockState(this.pos);
        this.blockMetadata = iblockstate.getBlock().getMetaFromState(iblockstate);
        this.worldObj.markChunkDirty(this.pos, this);

        if (this.getBlockType() != Blocks.air)
        {
            this.worldObj.updateComparatorOutputLevel(this.pos, this.getBlockType());
        }
    }
}
 
Example 8
Project: Uranium   File: CraftBlock.java   View Source Code Vote up 5 votes
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.block.Block block = this.getNMSBlock();
    if (block != Blocks.air) {
        byte data = getData();
        // based on nms.Block.dropNaturally
        int count = block.quantityDroppedWithBonus(0, chunk.getHandle().worldObj.rand);
        for (int i = 0; i < count; ++i) {
            Item item = block.getItemDropped(data, chunk.getHandle().worldObj.rand, 0);
            if (item != null) {
                // Skulls are special, their data is based on the tile entity
                if (Blocks.skull == block) {
                    net.minecraft.item.ItemStack nmsStack = new net.minecraft.item.ItemStack(item, 1, block.getDamageValue(chunk.getHandle().worldObj, x, y, z));
                    TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().worldObj.getTileEntity(x, y, z);

                    if (tileentityskull.func_145904_a() == 3 && tileentityskull.func_152108_a() != null) {
                        nmsStack.setTagCompound(new NBTTagCompound());
                        NBTTagCompound nbttagcompound = new NBTTagCompound();

                        NBTUtil.func_152460_a(nbttagcompound, tileentityskull.func_152108_a());
                        nmsStack.getTagCompound().setTag("SkullOwner", nbttagcompound);
                    }

                    drops.add(CraftItemStack.asBukkitCopy(nmsStack));
                    // We don't want to drop cocoa blocks, we want to drop cocoa beans.
                } else if (Blocks.cocoa == block) {
                    int dropAmount = (BlockCocoa.func_149987_c(data) >= 2 ? 3 : 1);
                    for (int j = 0; j < dropAmount; ++j) {
                        drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
                    }
                } else {
                    drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.damageDropped(data)));
                }
            }
        }
    }
    return drops;
}
 
Example 9
Project: FundamentalChemistry   File: TileVersatileGenerator.java   View Source Code Vote up 5 votes
public boolean hasAir()
{
	if(this.worldObj.getBlockState(this.pos.add(1,0,0)).getBlock() == Blocks.air)
		return true;
	if(this.worldObj.getBlockState(this.pos.add(-1,0,0)).getBlock() == Blocks.air)
		return true;
	if(this.worldObj.getBlockState(this.pos.add(0,0,1)).getBlock() == Blocks.air)
		return true;
	if(this.worldObj.getBlockState(this.pos.add(0,0,-1)).getBlock() == Blocks.air)
		return true;
	
	return false;
}
 
Example 10
Project: BaseClient   File: TileEntityFurnace.java   View Source Code Vote up 5 votes
/**
 * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
 * fuel
 */
public static int getItemBurnTime(ItemStack p_145952_0_)
{
    if (p_145952_0_ == null)
    {
        return 0;
    }
    else
    {
        Item item = p_145952_0_.getItem();

        if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air)
        {
            Block block = Block.getBlockFromItem(item);

            if (block == Blocks.wooden_slab)
            {
                return 150;
            }

            if (block.getMaterial() == Material.wood)
            {
                return 300;
            }

            if (block == Blocks.coal_block)
            {
                return 16000;
            }
        }

        return item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD") ? 200 : (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD") ? 200 : (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD") ? 200 : (item == Items.stick ? 100 : (item == Items.coal ? 1600 : (item == Items.lava_bucket ? 20000 : (item == Item.getItemFromBlock(Blocks.sapling) ? 100 : (item == Items.blaze_rod ? 2400 : 0)))))));
    }
}
 
Example 11
Project: BaseClient   File: TileEntityFurnace.java   View Source Code Vote up 5 votes
/**
 * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
 * fuel
 */
public static int getItemBurnTime(ItemStack p_145952_0_)
{
    if (p_145952_0_ == null)
    {
        return 0;
    }
    else
    {
        Item item = p_145952_0_.getItem();

        if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air)
        {
            Block block = Block.getBlockFromItem(item);

            if (block == Blocks.wooden_slab)
            {
                return 150;
            }

            if (block.getMaterial() == Material.wood)
            {
                return 300;
            }

            if (block == Blocks.coal_block)
            {
                return 16000;
            }
        }

        return item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD") ? 200 : (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD") ? 200 : (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD") ? 200 : (item == Items.stick ? 100 : (item == Items.coal ? 1600 : (item == Items.lava_bucket ? 20000 : (item == Item.getItemFromBlock(Blocks.sapling) ? 100 : (item == Items.blaze_rod ? 2400 : 0)))))));
    }
}
 
Example 12
Project: BaseClient   File: BlockDynamicLiquid.java   View Source Code Vote up 5 votes
private void tryFlowInto(World worldIn, BlockPos pos, IBlockState state, int level) {
	if (this.canFlowInto(worldIn, pos, state)) {
		if (state.getBlock() != Blocks.air) {
			if (this.blockMaterial == Material.lava) {
				this.triggerMixEffects(worldIn, pos);
			} else {
				state.getBlock().dropBlockAsItem(worldIn, pos, state, 0);
			}
		}

		worldIn.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(level)), 3);
	}
}
 
Example 13
Project: BaseClient   File: TileEntity.java   View Source Code Vote up 5 votes
/**
 * For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it
 * hasn't changed and skip it.
 */
public void markDirty()
{
    if (this.worldObj != null)
    {
        IBlockState iblockstate = this.worldObj.getBlockState(this.pos);
        this.blockMetadata = iblockstate.getBlock().getMetaFromState(iblockstate);
        this.worldObj.markChunkDirty(this.pos, this);

        if (this.getBlockType() != Blocks.air)
        {
            this.worldObj.updateComparatorOutputLevel(this.pos, this.getBlockType());
        }
    }
}
 
Example 14
Project: DecompiledMinecraft   File: ExtendedBlockStorage.java   View Source Code Vote up 5 votes
public void set(int x, int y, int z, IBlockState state)
{
    IBlockState iblockstate = this.get(x, y, z);
    Block block = iblockstate.getBlock();
    Block block1 = state.getBlock();

    if (block != Blocks.air)
    {
        --this.blockRefCount;

        if (block.getTickRandomly())
        {
            --this.tickRefCount;
        }
    }

    if (block1 != Blocks.air)
    {
        ++this.blockRefCount;

        if (block1.getTickRandomly())
        {
            ++this.tickRefCount;
        }
    }

    this.data[y << 8 | z << 4 | x] = (char)Block.BLOCK_STATE_IDS.get(state);
}
 
Example 15
Project: DecompiledMinecraft   File: EmptyChunk.java   View Source Code Vote up 4 votes
public Block getBlock(BlockPos pos)
{
    return Blocks.air;
}
 
Example 16
Project: DecompiledMinecraft   File: EntityAIHarvestFarmland.java   View Source Code Vote up 4 votes
/**
 * Updates the task
 */
public void updateTask()
{
    super.updateTask();
    this.theVillager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.theVillager.getVerticalFaceSpeed());

    if (this.getIsAboveDestination())
    {
        World world = this.theVillager.worldObj;
        BlockPos blockpos = this.destinationBlock.up();
        IBlockState iblockstate = world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (this.field_179501_f == 0 && block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7)
        {
            world.destroyBlock(blockpos, true);
        }
        else if (this.field_179501_f == 1 && block == Blocks.air)
        {
            InventoryBasic inventorybasic = this.theVillager.getVillagerInventory();

            for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
            {
                ItemStack itemstack = inventorybasic.getStackInSlot(i);
                boolean flag = false;

                if (itemstack != null)
                {
                    if (itemstack.getItem() == Items.wheat_seeds)
                    {
                        world.setBlockState(blockpos, Blocks.wheat.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.potato)
                    {
                        world.setBlockState(blockpos, Blocks.potatoes.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.carrot)
                    {
                        world.setBlockState(blockpos, Blocks.carrots.getDefaultState(), 3);
                        flag = true;
                    }
                }

                if (flag)
                {
                    --itemstack.stackSize;

                    if (itemstack.stackSize <= 0)
                    {
                        inventorybasic.setInventorySlotContents(i, (ItemStack)null);
                    }

                    break;
                }
            }
        }

        this.field_179501_f = -1;
        this.runDelay = 10;
    }
}
 
Example 17
Project: DecompiledMinecraft   File: ItemBucket.java   View Source Code Vote up 4 votes
public boolean tryPlaceContainedLiquid(World worldIn, BlockPos pos)
{
    if (this.isFull == Blocks.air)
    {
        return false;
    }
    else
    {
        Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
        boolean flag = !material.isSolid();

        if (!worldIn.isAirBlock(pos) && !flag)
        {
            return false;
        }
        else
        {
            if (worldIn.provider.doesWaterVaporize() && this.isFull == Blocks.flowing_water)
            {
                int i = pos.getX();
                int j = pos.getY();
                int k = pos.getZ();
                worldIn.playSoundEffect((double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F), "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

                for (int l = 0; l < 8; ++l)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)i + Math.random(), (double)j + Math.random(), (double)k + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
                }
            }
            else
            {
                if (!worldIn.isRemote && flag && !material.isLiquid())
                {
                    worldIn.destroyBlock(pos, true);
                }

                worldIn.setBlockState(pos, this.isFull.getDefaultState(), 3);
            }

            return true;
        }
    }
}
 
Example 18
Project: BaseClient   File: EntityAIHarvestFarmland.java   View Source Code Vote up 4 votes
/**
 * Updates the task
 */
public void updateTask()
{
    super.updateTask();
    this.theVillager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.theVillager.getVerticalFaceSpeed());

    if (this.getIsAboveDestination())
    {
        World world = this.theVillager.worldObj;
        BlockPos blockpos = this.destinationBlock.up();
        IBlockState iblockstate = world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (this.field_179501_f == 0 && block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7)
        {
            world.destroyBlock(blockpos, true);
        }
        else if (this.field_179501_f == 1 && block == Blocks.air)
        {
            InventoryBasic inventorybasic = this.theVillager.getVillagerInventory();

            for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
            {
                ItemStack itemstack = inventorybasic.getStackInSlot(i);
                boolean flag = false;

                if (itemstack != null)
                {
                    if (itemstack.getItem() == Items.wheat_seeds)
                    {
                        world.setBlockState(blockpos, Blocks.wheat.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.potato)
                    {
                        world.setBlockState(blockpos, Blocks.potatoes.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.carrot)
                    {
                        world.setBlockState(blockpos, Blocks.carrots.getDefaultState(), 3);
                        flag = true;
                    }
                }

                if (flag)
                {
                    --itemstack.stackSize;

                    if (itemstack.stackSize <= 0)
                    {
                        inventorybasic.setInventorySlotContents(i, (ItemStack)null);
                    }

                    break;
                }
            }
        }

        this.field_179501_f = -1;
        this.runDelay = 10;
    }
}
 
Example 19
Project: BaseClient   File: EntityAIFollowOwner.java   View Source Code Vote up 4 votes
private boolean func_181065_a(BlockPos p_181065_1_)
{
    IBlockState iblockstate = this.theWorld.getBlockState(p_181065_1_);
    Block block = iblockstate.getBlock();
    return block == Blocks.air ? true : !block.isFullCube();
}
 
Example 20
Project: BaseClient   File: EmptyChunk.java   View Source Code Vote up 4 votes
public Block getBlock(BlockPos pos)
{
    return Blocks.air;
}