Search in sources :

Example 16 with IBlockState

use of net.minecraft.block.state.IBlockState in project MinecraftForge by MinecraftForge.

the class BlockFluidBase method getFlowDirection.

public static double getFlowDirection(IBlockAccess world, BlockPos pos) {
    IBlockState state = world.getBlockState(pos);
    if (!state.getMaterial().isLiquid()) {
        return -1000.0;
    }
    Vec3d vec = ((BlockFluidBase) state.getBlock()).getFlowVector(world, pos);
    return vec.xCoord == 0.0D && vec.zCoord == 0.0D ? -1000.0D : Math.atan2(vec.zCoord, vec.xCoord) - Math.PI / 2D;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Vec3d(net.minecraft.util.math.Vec3d)

Example 17 with IBlockState

use of net.minecraft.block.state.IBlockState in project MinecraftForge by MinecraftForge.

the class BlockFluidBase method getFluidHeightForRender.

public float getFluidHeightForRender(IBlockAccess world, BlockPos pos) {
    IBlockState here = world.getBlockState(pos);
    IBlockState up = world.getBlockState(pos.down(densityDir));
    if (here.getBlock() == this) {
        if (up.getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock) {
            return 1;
        }
        if (getMetaFromState(here) == getMaxRenderHeightMeta()) {
            return 0.875F;
        }
    }
    if (here.getBlock() instanceof BlockLiquid) {
        return Math.min(1 - BlockLiquid.getLiquidHeightPercent(here.getValue(BlockLiquid.LEVEL)), 14f / 16);
    }
    return !here.getMaterial().isSolid() && up.getBlock() == this ? 1 : this.getQuantaPercentage(world, pos) * 0.875F;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid)

Example 18 with IBlockState

use of net.minecraft.block.state.IBlockState in project MinecraftForge by MinecraftForge.

the class BlockFluidClassic method getQuantaValue.

@Override
public int getQuantaValue(IBlockAccess world, BlockPos pos) {
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() == Blocks.AIR) {
        return 0;
    }
    if (state.getBlock() != this) {
        return -1;
    }
    int quantaRemaining = quantaPerBlock - state.getValue(LEVEL);
    return quantaRemaining;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState)

Example 19 with IBlockState

use of net.minecraft.block.state.IBlockState in project MinecraftForge by MinecraftForge.

the class BlockFluidClassic method canFlowInto.

protected boolean canFlowInto(IBlockAccess world, BlockPos pos) {
    if (world.isAirBlock(pos))
        return true;
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() == this) {
        return true;
    }
    if (displacements.containsKey(state.getBlock())) {
        return displacements.get(state.getBlock());
    }
    Material material = state.getMaterial();
    if (material.blocksMovement() || material == Material.WATER || material == Material.LAVA || material == Material.PORTAL) {
        return false;
    }
    int density = getDensity(world, pos);
    if (density == Integer.MAX_VALUE) {
        return true;
    }
    if (this.density > density) {
        return true;
    } else {
        return false;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Material(net.minecraft.block.material.Material)

Example 20 with IBlockState

use of net.minecraft.block.state.IBlockState in project MinecraftForge by MinecraftForge.

the class BlockLiquidWrapper method getTankProperties.

@Override
public IFluidTankProperties[] getTankProperties() {
    FluidStack containedStack = null;
    IBlockState blockState = world.getBlockState(blockPos);
    if (blockState.getBlock() == blockLiquid) {
        containedStack = getStack(blockState);
    }
    return new FluidTankProperties[] { new FluidTankProperties(containedStack, Fluid.BUCKET_VOLUME, false, true) };
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) FluidTankProperties(net.minecraftforge.fluids.capability.FluidTankProperties) IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) FluidStack(net.minecraftforge.fluids.FluidStack)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)798 BlockPos (net.minecraft.util.math.BlockPos)325 Block (net.minecraft.block.Block)246 ItemStack (net.minecraft.item.ItemStack)118 TileEntity (net.minecraft.tileentity.TileEntity)84 EnumFacing (net.minecraft.util.EnumFacing)81 World (net.minecraft.world.World)66 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)42 EntityPlayer (net.minecraft.entity.player.EntityPlayer)34 Entity (net.minecraft.entity.Entity)30 Random (java.util.Random)28 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)28 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)28 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)23 ArrayList (java.util.ArrayList)22 Vec3d (net.minecraft.util.math.Vec3d)22 SoundType (net.minecraft.block.SoundType)21 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)21 ResourceLocation (net.minecraft.util.ResourceLocation)21 RayTraceResult (net.minecraft.util.math.RayTraceResult)21