Java Code Examples for net.minecraft.block.Block#NULL_AABB

The following examples show how to use net.minecraft.block.Block#NULL_AABB . 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: RecipeLogicSteam.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void tryDoVenting() {
    BlockPos machinePos = metaTileEntity.getPos();
    EnumFacing ventingSide = getVentingSide();
    BlockPos ventingBlockPos = machinePos.offset(ventingSide);
    IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos);
    if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) {
        metaTileEntity.getWorld()
            .getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET)
            .forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f));
        WorldServer world = (WorldServer) metaTileEntity.getWorld();
        double posX = machinePos.getX() + 0.5 + ventingSide.getFrontOffsetX() * 0.6;
        double posY = machinePos.getY() + 0.5 + ventingSide.getFrontOffsetY() * 0.6;
        double posZ = machinePos.getZ() + 0.5 + ventingSide.getFrontOffsetZ() * 0.6;

        world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ,
            7 + world.rand.nextInt(3),
            ventingSide.getFrontOffsetX() / 2.0,
            ventingSide.getFrontOffsetY() / 2.0,
            ventingSide.getFrontOffsetZ() / 2.0, 0.1);
        world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
        setNeedsVenting(false);
    } else if (!ventingStuck) {
        setVentingStuck(true);
    }
}
 
Example 2
Source File: ItemSlab.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, int subtype)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this.singleSlab)
    {
        int subtype1 = singleSlabCS.getSubtype(iblockstate);

        if (subtype1 == subtype)
        {
            IBlockState stateDouble = this.makeState(subtype1);
            AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos);

            if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11))
            {
                SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player);
                worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                stack.shrink(1);
            }

            return true;
        }
    }

    return false;
}
 
Example 3
Source File: WorldHelper.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns true if block is replaceable and has no collider
 */
public static boolean isAirLikeBlock(World world, BlockPos pos)
{
	IBlockState state = world.getBlockState(pos);
	Block block = state.getBlock();
	boolean replaceable = block.isReplaceable(world, pos);
	boolean noCollider = (state.getCollisionBoundingBox(world, pos) == Block.NULL_AABB);
	return (replaceable || noCollider);
}
 
Example 4
Source File: ItemSlab.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (!itemstack.isEmpty() && player.canPlayerEdit(pos.offset(facing), facing, itemstack))
    {
        int subtype = getMetadata(itemstack);
        IBlockState currentState = worldIn.getBlockState(pos);

        if (currentState.getBlock() == singleSlab)
        {
            int subtype1 = this.singleSlabCS.getSubtype(currentState);
            net.minecraft.block.BlockSlab.EnumBlockHalf half = currentState.getValue(net.minecraft.block.BlockSlab.HALF);

            if ((facing == EnumFacing.UP && half == net.minecraft.block.BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && half == net.minecraft.block.BlockSlab.EnumBlockHalf.TOP)
                && subtype1 == subtype)
            {
                IBlockState stateDouble = this.makeState(subtype1);
                AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos);

                if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11))
                {
                    SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player);
                    worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                    itemstack.shrink(1);
                }

                return EnumActionResult.SUCCESS;
            }
        }

        return this.tryPlace(player, itemstack, worldIn, pos.offset(facing), subtype) ? EnumActionResult.SUCCESS : super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    } else
    {
        return EnumActionResult.FAIL;
    }
}
 
Example 5
Source File: BlockCrop.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
@Nullable
@Deprecated
@SuppressWarnings("deprecation")
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
    return Block.NULL_AABB;
}
 
Example 6
Source File: BlockWindBell.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
	return Block.NULL_AABB;
}
 
Example 7
Source File: BlockKitunebi.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
	return Block.NULL_AABB;
}
 
Example 8
Source File: ItemSnow.java    From customstuff4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack))
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        BlockPos blockpos = pos;

        if ((facing != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
        {
            blockpos = pos.offset(facing);
            iblockstate = worldIn.getBlockState(blockpos);
            block = iblockstate.getBlock();
        }

        if (block == this.block)
        {
            int i = iblockstate.getValue(BlockSnow.LAYERS);

            if (i < 8)
            {
                IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, i + 1);
                AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, blockpos);

                if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(blockpos)) && worldIn.setBlockState(blockpos, iblockstate1, 10))
                {
                    SoundType soundtype = this.block.getSoundType(iblockstate1, worldIn, pos, player);
                    worldIn.playSound(player, blockpos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);

                    if (player instanceof EntityPlayerMP)
                    {
                        CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos, itemstack);
                    }

                    itemstack.shrink(1);
                    return EnumActionResult.SUCCESS;
                }
            }
        }

        return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
 
Example 9
Source File: EntityEnderPearlReusable.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void onImpact(RayTraceResult rayTraceResult)
{
    Entity thrower = this.getThrower();

    // Thrower not found, drop the item if applicable and bail out
    if (thrower == null)
    {
        if (this.getEntityWorld().isRemote == false && this.canPickUp)
        {
            this.dropAsItem();
        }

        this.setDead();
        return;
    }

    // Don't collide with the thrower or the entities in the 'stack' with the thrower
    if (this.getEntityWorld().isRemote == false && rayTraceResult.typeOfHit == RayTraceResult.Type.ENTITY)
    {
        if (EntityUtils.doesEntityStackContainEntity(rayTraceResult.entityHit, thrower))
        {
            return;
        }

        if (rayTraceResult.entityHit instanceof EntityPlayerMP && ((EntityPlayerMP)rayTraceResult.entityHit).isSpectator())
        {
            return;
        }

        if (rayTraceResult.entityHit instanceof EntityLivingBase)
        {
            rayTraceResult.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, thrower), 0.0f);
        }
    }
    // Don't collide with blocks without a collision box
    else if (rayTraceResult.typeOfHit == RayTraceResult.Type.BLOCK && rayTraceResult.getBlockPos() != null)
    {
        IBlockState state = this.getEntityWorld().getBlockState(rayTraceResult.getBlockPos());
        AxisAlignedBB aabb = state.getCollisionBoundingBox(this.getEntityWorld(), rayTraceResult.getBlockPos());
        if (aabb == Block.NULL_AABB)
        {
            return;
        }
    }

    // A regular pearl lands, teleport the thrower
    if (this.isElite == false)
    {
        // If the thrower is currently riding an elite pearl, unmount the pearl
        Entity bottom = thrower.getLowestRidingEntity();
        if (bottom instanceof EntityEnderPearlReusable && bottom.isBeingRidden())
        {
            bottom.removePassengers();
        }

        if (this.getEntityWorld().isRemote == false)
        {
            TeleportEntity.teleportEntityWithProjectile(thrower, this, rayTraceResult, this.teleportDamage, true, true);
        }
    }
    // An Elite pearl lands, which is still being ridden by something (see above)
    else if (this.isBeingRidden())
    {
        Entity entity = this.getPassengers().get(0);
        this.removePassengers();

        if (this.getEntityWorld().isRemote == false)
        {
            TeleportEntity.teleportEntityWithProjectile(entity, this, rayTraceResult, this.teleportDamage, true, true);
        }
    }

    // Try to add the pearl straight back to the player's inventory
    if (this.getEntityWorld().isRemote == false && this.returnToPlayersInventory() == false)
    {
        this.dropAsItem();
    }

    this.setDead();
}