Search in sources :

Example 46 with EnumFacing

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

the class BlockSecurityCamera method getStateForPlacement.

@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
    IBlockState iblockstate = getDefaultState().withProperty(POWERED, Boolean.valueOf(false));
    if (world.isSideSolid(pos.offset(facing.getOpposite()), facing))
        return iblockstate.withProperty(FACING, facing).withProperty(POWERED, false);
    else {
        Iterator<?> iterator = EnumFacing.Plane.HORIZONTAL.iterator();
        EnumFacing enumfacing1;
        do {
            if (!iterator.hasNext())
                return iblockstate;
            enumfacing1 = (EnumFacing) iterator.next();
        } while (!world.isSideSolid(pos.offset(enumfacing1.getOpposite()), enumfacing1));
        return iblockstate.withProperty(FACING, facing).withProperty(POWERED, false);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing)

Example 47 with EnumFacing

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

the class ItemReinforcedDoor method onItemUse.

/**
 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
 */
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (facing != EnumFacing.UP)
        return EnumActionResult.FAIL;
    else {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        if (!block.isReplaceable(worldIn, pos))
            pos = pos.offset(facing);
        if (playerIn.canPlayerEdit(pos, facing, stack) && SCContent.reinforcedDoor.canPlaceBlockAt(worldIn, pos)) {
            EnumFacing enumfacing = EnumFacing.fromAngle(playerIn.rotationYaw);
            int i = enumfacing.getFrontOffsetX();
            int j = enumfacing.getFrontOffsetZ();
            boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
            placeDoor(worldIn, pos, enumfacing, SCContent.reinforcedDoor, flag);
            SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, playerIn);
            worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            ((TileEntityOwnable) worldIn.getTileEntity(pos)).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
            ((TileEntityOwnable) worldIn.getTileEntity(pos.up())).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
            --stack.stackSize;
            return EnumActionResult.SUCCESS;
        } else
            return EnumActionResult.FAIL;
    }
}
Also used : SoundType(net.minecraft.block.SoundType) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block)

Example 48 with EnumFacing

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

the class TileEntitySecurityCameraRenderer method render.

@Override
public void render(TileEntitySecurityCamera par1TileEntity, double x, double y, double z, float par5, int par6, float alpha) {
    float rotation = 0F;
    if (par1TileEntity.hasWorld()) {
        Tessellator tessellator = Tessellator.getInstance();
        float f = par1TileEntity.getWorld().getLightBrightness(par1TileEntity.getPos());
        int l = par1TileEntity.getWorld().getCombinedLight(par1TileEntity.getPos(), 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        // TODO: does this work?
        tessellator.getBuffer().putColorRGBA(0, (int) (f * 255.0F), (int) (f * 255.0F), (int) (f * 255.0F), 255);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
    }
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
    Minecraft.getMinecraft().renderEngine.bindTexture(cameraTexture);
    GL11.glPushMatrix();
    if (par1TileEntity.hasWorld() && BlockUtils.getBlock(par1TileEntity.getWorld(), par1TileEntity.getPos()) == SCContent.securityCamera) {
        EnumFacing side = BlockUtils.getBlockPropertyAsEnum(getWorld(), par1TileEntity.getPos(), BlockSecurityCamera.FACING);
        if (side == EnumFacing.EAST)
            rotation = -1F;
        else if (side == EnumFacing.SOUTH)
            rotation = -10000F;
        else if (side == EnumFacing.WEST)
            rotation = 1F;
        else if (side == EnumFacing.NORTH)
            rotation = 0F;
    } else
        rotation = -10000F;
    GL11.glRotatef(180F, rotation, 0.0F, 1.0F);
    modelSecurityCamera.cameraRotationPoint.rotateAngleY = par1TileEntity.cameraRotation;
    modelSecurityCamera.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) EnumFacing(net.minecraft.util.EnumFacing)

Example 49 with EnumFacing

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

the class EntitySecurityCamera method moveViewRight.

public void moveViewRight() {
    if (BlockUtils.hasBlockProperty(worldObj, BlockUtils.toPos((int) Math.floor(posX), (int) (posY - 1D), (int) Math.floor(posZ)), BlockSecurityCamera.FACING)) {
        EnumFacing facing = BlockUtils.getBlockPropertyAsEnum(worldObj, BlockUtils.toPos((int) Math.floor(posX), (int) (posY - 1D), (int) Math.floor(posZ)), BlockSecurityCamera.FACING);
        if (facing == EnumFacing.EAST) {
            if ((rotationYaw + CAMERA_SPEED) < 0F)
                setRotation(rotationYaw += CAMERA_SPEED, rotationPitch);
        } else if (facing == EnumFacing.WEST) {
            if ((rotationYaw + CAMERA_SPEED) < 180F)
                setRotation(rotationYaw += CAMERA_SPEED, rotationPitch);
        } else if (facing == EnumFacing.NORTH) {
            if ((((rotationYaw + CAMERA_SPEED) > 85F) && ((rotationYaw + CAMERA_SPEED) < 185F)) || ((rotationYaw + CAMERA_SPEED) < -95F) && ((rotationYaw + CAMERA_SPEED) > -180F))
                setRotation(rotationYaw += CAMERA_SPEED, rotationPitch);
        } else if (facing == EnumFacing.SOUTH)
            if ((rotationYaw + CAMERA_SPEED) < 90F)
                setRotation(rotationYaw += CAMERA_SPEED, rotationPitch);
        updateServerRotation();
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing)

Example 50 with EnumFacing

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

the class BlockAlarm method onNeighborBlockChange.

/**
 * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
 * their own) Args: x, y, z, neighbor Block
 */
@Override
public void onNeighborBlockChange(World par1World, BlockPos pos, IBlockState state, Block par5Block) {
    if (par1World.isRemote)
        return;
    else
        playSoundAndUpdate(par1World, pos);
    EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
    if (!par1World.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true)) {
        dropBlockAsItem(par1World, pos, state, 0);
        par1World.setBlockToAir(pos);
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing)

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