Search in sources :

Example 51 with EnumFacing

use of net.minecraft.util.EnumFacing in project SecurityCraft by Geforce132.

the class BlockAlarm method setBlockBoundsBasedOnState.

@Override
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) {
    float f = 0.1875F;
    // bottom of the alarm when placed on a block side
    float ySideMin = 0.5F - f;
    // top of the alarm when placed on a block side
    float ySideMax = 0.5F + f;
    // the left start for s/w and right start for n/e
    float hSideMin = 0.5F - f;
    // the left start for n/e and right start for s/w
    float hSideMax = 0.5F + f;
    // one sixteenth of a block
    float px = 1.0F / 16.0F;
    EnumFacing enumfacing = (EnumFacing) worldIn.getBlockState(pos).getValue(FACING);
    switch(BlockAlarm.SwitchEnumFacing.FACING_LOOKUP[enumfacing.ordinal()]) {
        case // east
        1:
            setBlockBounds(0.0F, ySideMin - px, hSideMin - px, 0.5F, ySideMax + px, hSideMax + px);
            break;
        case // west
        2:
            setBlockBounds(0.5F, ySideMin - px, hSideMin - px, 1.0F, ySideMax + px, hSideMax + px);
            break;
        case // north
        3:
            setBlockBounds(hSideMin - px, ySideMin - px, 0.0F, hSideMax + px, ySideMax + px, 0.5F);
            break;
        case // south
        4:
            setBlockBounds(hSideMin - px, ySideMin - px, 0.5F, hSideMax + px, ySideMax + px, 1.0F);
            break;
        case // up
        5:
            setBlockBounds(0.5F - f - px, 0F, 0.5F - f - px, 0.5F + f + px, 0.5F, 0.5F + f + px);
            break;
        case // down
        6:
            setBlockBounds(0.5F - f - px, 0.5F, 0.5F - f - px, 0.5F + f + px, 1.0F, 0.5F + f + px);
            break;
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing)

Example 52 with EnumFacing

use of net.minecraft.util.EnumFacing in project SecurityCraft by Geforce132.

the class BlockAlarm method playSoundAndUpdate.

private void playSoundAndUpdate(World par1World, BlockPos pos) {
    if (!(par1World.getTileEntity(pos) instanceof TileEntityAlarm))
        return;
    if (par1World.isBlockIndirectlyGettingPowered(pos) > 0) {
        boolean isPowered = ((TileEntityAlarm) par1World.getTileEntity(pos)).isPowered();
        if (!isPowered) {
            Owner owner = ((TileEntityAlarm) par1World.getTileEntity(pos)).getOwner();
            EnumFacing dir = BlockUtils.getBlockPropertyAsEnum(par1World, pos, FACING);
            BlockUtils.setBlock(par1World, pos, SCContent.alarmLit);
            BlockUtils.setBlockProperty(par1World, pos, FACING, dir);
            ((TileEntityAlarm) par1World.getTileEntity(pos)).getOwner().set(owner);
            ((TileEntityAlarm) par1World.getTileEntity(pos)).setPowered(true);
        }
    } else {
        boolean isPowered = ((TileEntityAlarm) par1World.getTileEntity(pos)).isPowered();
        if (isPowered) {
            Owner owner = ((TileEntityAlarm) par1World.getTileEntity(pos)).getOwner();
            EnumFacing dir = BlockUtils.getBlockPropertyAsEnum(par1World, pos, FACING);
            BlockUtils.setBlock(par1World, pos, SCContent.alarm);
            BlockUtils.setBlockProperty(par1World, pos, FACING, dir);
            ((TileEntityAlarm) par1World.getTileEntity(pos)).getOwner().set(owner);
            ((TileEntityAlarm) par1World.getTileEntity(pos)).setPowered(false);
        }
    }
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) TileEntityAlarm(net.geforcemods.securitycraft.tileentity.TileEntityAlarm) EnumFacing(net.minecraft.util.EnumFacing)

Example 53 with EnumFacing

use of net.minecraft.util.EnumFacing in project SecurityCraft by Geforce132.

the class BlockFakeLava method updateTick.

@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    int i = ((Integer) state.getValue(LEVEL)).intValue();
    byte b0 = 1;
    if (blockMaterial == Material.lava && !worldIn.provider.doesWaterVaporize())
        b0 = 2;
    int j = tickRate(worldIn);
    int i1;
    if (i > 0) {
        int k = -100;
        adjacentSourceBlocks = 0;
        EnumFacing enumfacing;
        for (Iterator<?> iterator = EnumFacing.Plane.HORIZONTAL.iterator(); iterator.hasNext(); k = checkAdjacentBlock(worldIn, pos.offset(enumfacing), k)) enumfacing = (EnumFacing) iterator.next();
        int l = k + b0;
        if (l >= 8 || k < 0)
            l = -1;
        if (getLevel(worldIn, pos.up()) >= 0) {
            i1 = getLevel(worldIn, pos.up());
            if (i1 >= 8)
                l = i1;
            else
                l = i1 + 8;
        }
        if (adjacentSourceBlocks >= 2 && blockMaterial == Material.water) {
            IBlockState iblockstate2 = worldIn.getBlockState(pos.down());
            if (iblockstate2.getBlock().getMaterial().isSolid())
                l = 0;
            else if (iblockstate2.getBlock().getMaterial() == blockMaterial && ((Integer) iblockstate2.getValue(LEVEL)).intValue() == 0)
                l = 0;
        }
        if (blockMaterial == Material.lava && i < 8 && l < 8 && l > i && rand.nextInt(4) != 0)
            j *= 4;
        if (l == i)
            placeStaticBlock(worldIn, pos, state);
        else {
            i = l;
            if (l < 0)
                worldIn.setBlockToAir(pos);
            else {
                state = state.withProperty(LEVEL, Integer.valueOf(l));
                worldIn.setBlockState(pos, state, 2);
                worldIn.scheduleUpdate(pos, this, j);
                worldIn.notifyNeighborsOfStateChange(pos, this);
            }
        }
    } else
        placeStaticBlock(worldIn, pos, state);
    IBlockState iblockstate1 = worldIn.getBlockState(pos.down());
    if (canFlowInto(worldIn, pos.down(), iblockstate1)) {
        if (blockMaterial == Material.lava && worldIn.getBlockState(pos.down()).getBlock().getMaterial() == Material.water) {
            worldIn.setBlockState(pos.down(), Blocks.stone.getDefaultState());
            triggerMixEffects(worldIn, pos.down());
            return;
        }
        if (i >= 8)
            tryFlowInto(worldIn, pos.down(), iblockstate1, i);
        else
            tryFlowInto(worldIn, pos.down(), iblockstate1, i + 8);
    } else if (i >= 0 && (i == 0 || isBlocked(worldIn, pos.down(), iblockstate1))) {
        Set<?> set = getPossibleFlowDirections(worldIn, pos);
        i1 = i + b0;
        if (i >= 8)
            i1 = 1;
        if (i1 >= 8)
            return;
        Iterator<?> iterator1 = set.iterator();
        while (iterator1.hasNext()) {
            EnumFacing enumfacing1 = (EnumFacing) iterator1.next();
            tryFlowInto(worldIn, pos.offset(enumfacing1), worldIn.getBlockState(pos.offset(enumfacing1)), i1);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Set(java.util.Set) EnumSet(java.util.EnumSet) EnumFacing(net.minecraft.util.EnumFacing) Iterator(java.util.Iterator)

Example 54 with EnumFacing

use of net.minecraft.util.EnumFacing in project SecurityCraft by Geforce132.

the class BlockFakeLava method func_176374_a.

private int func_176374_a(World worldIn, BlockPos pos, int distance, EnumFacing calculateFlowCost) {
    int j = 1000;
    Iterator<?> iterator = EnumFacing.Plane.HORIZONTAL.iterator();
    while (iterator.hasNext()) {
        EnumFacing enumfacing1 = (EnumFacing) iterator.next();
        if (enumfacing1 != calculateFlowCost) {
            BlockPos blockpos1 = pos.offset(enumfacing1);
            IBlockState iblockstate = worldIn.getBlockState(blockpos1);
            if (!isBlocked(worldIn, blockpos1, iblockstate) && (iblockstate.getBlock().getMaterial() != blockMaterial || ((Integer) iblockstate.getValue(LEVEL)).intValue() > 0)) {
                if (!isBlocked(worldIn, blockpos1.down(), iblockstate))
                    return distance;
                if (distance < 4) {
                    int k = func_176374_a(worldIn, blockpos1, distance + 1, enumfacing1.getOpposite());
                    if (k < j)
                        j = k;
                }
            }
        }
    }
    return j;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.BlockPos)

Example 55 with EnumFacing

use of net.minecraft.util.EnumFacing in project SecurityCraft by Geforce132.

the class BlockInventoryScanner method checkAndPlaceAppropriately.

private void checkAndPlaceAppropriately(World par1World, BlockPos pos) {
    TileEntityInventoryScanner connectedScanner = getConnectedInventoryScanner(par1World, pos);
    if (connectedScanner == null)
        return;
    if ((EnumFacing) par1World.getBlockState(pos).getValue(FACING) == EnumFacing.WEST) {
        for (int i = 1; i < Math.abs(pos.getX() - connectedScanner.getPos().getX()); i++) {
            par1World.setBlockState(pos.west(i), SCContent.inventoryScannerField.getDefaultState().withProperty(FACING, EnumFacing.WEST));
        }
    } else if ((EnumFacing) par1World.getBlockState(pos).getValue(FACING) == EnumFacing.EAST) {
        for (int i = 1; i < Math.abs(pos.getX() - connectedScanner.getPos().getX()); i++) {
            par1World.setBlockState(pos.east(i), SCContent.inventoryScannerField.getDefaultState().withProperty(FACING, EnumFacing.EAST));
        }
    } else if ((EnumFacing) par1World.getBlockState(pos).getValue(FACING) == EnumFacing.NORTH) {
        for (int i = 1; i < Math.abs(pos.getZ() - connectedScanner.getPos().getZ()); i++) {
            par1World.setBlockState(pos.north(i), SCContent.inventoryScannerField.getDefaultState().withProperty(FACING, EnumFacing.NORTH));
        }
    } else if ((EnumFacing) par1World.getBlockState(pos).getValue(FACING) == EnumFacing.SOUTH) {
        for (int i = 1; i < Math.abs(pos.getZ() - connectedScanner.getPos().getZ()); i++) {
            par1World.setBlockState(pos.south(i), SCContent.inventoryScannerField.getDefaultState().withProperty(FACING, EnumFacing.SOUTH));
        }
    }
    CustomizableSCTE.link((CustomizableSCTE) par1World.getTileEntity(pos), connectedScanner);
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) TileEntityInventoryScanner(net.geforcemods.securitycraft.tileentity.TileEntityInventoryScanner)

Aggregations

EnumFacing (net.minecraft.util.EnumFacing)1673 BlockPos (net.minecraft.util.math.BlockPos)491 IBlockState (net.minecraft.block.state.IBlockState)403 TileEntity (net.minecraft.tileentity.TileEntity)392 ItemStack (net.minecraft.item.ItemStack)192 Block (net.minecraft.block.Block)158 ArrayList (java.util.ArrayList)121 World (net.minecraft.world.World)114 Vec3d (net.minecraft.util.math.Vec3d)104 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)98 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)88 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)73 EntityPlayer (net.minecraft.entity.player.EntityPlayer)65 FluidStack (net.minecraftforge.fluids.FluidStack)65 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)63 Nullable (javax.annotation.Nullable)51 List (java.util.List)48 Nonnull (javax.annotation.Nonnull)47 HashSet (java.util.HashSet)43 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)43