Search in sources :

Example 6 with TileEntityOwnable

use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.

the class BlockReinforcedFenceGate method onEntityCollidedWithBlock.

public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    if (world.getBlockMetadata(x, y, z) > 3)
        return;
    //so dropped items don't get destroyed
    if (entity instanceof EntityItem)
        return;
    else //owner check
    if (entity instanceof EntityPlayer) {
        if (((TileEntityOwnable) world.getTileEntity(x, y, z)).getOwner().isOwner((EntityPlayer) entity))
            return;
    } else if (entity instanceof EntityCreeper) {
        EntityCreeper creeper = (EntityCreeper) entity;
        EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);
        creeper.onStruckByLightning(lightning);
        creeper.extinguish();
        return;
    }
    //3 hearts per attack
    entity.attackEntityFrom(CustomDamageSources.electricity, 6.0F);
}
Also used : EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) EntityItem(net.minecraft.entity.item.EntityItem) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable)

Example 7 with TileEntityOwnable

use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.

the class ItemScannerDoor 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
	 */
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
    if (world.isRemote)
        return true;
    else {
        if (side != EnumFacing.UP)
            return false;
        else {
            IBlockState iblockstate = world.getBlockState(pos);
            Block block = iblockstate.getBlock();
            if (!block.isReplaceable(world, pos))
                pos = pos.offset(side);
            if (!player.canPlayerEdit(pos, side, stack))
                return false;
            else if (!mod_SecurityCraft.scannerDoor.canPlaceBlockAt(world, pos))
                return false;
            else {
                //TERD.getOwner().set(player.getGameProfile().getId().toString(), player.getName());
                placeDoor(world, pos, EnumFacing.fromAngle(player.rotationYaw), mod_SecurityCraft.scannerDoor);
                ((TileEntityOwnable) world.getTileEntity(pos)).getOwner().set(player.getGameProfile().getId().toString(), player.getName());
                ((TileEntityOwnable) world.getTileEntity(pos.up())).getOwner().set(player.getGameProfile().getId().toString(), player.getName());
                stack.stackSize--;
                return true;
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable)

Example 8 with TileEntityOwnable

use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.

the class BlockReinforcedFenceGate method onEntityIntersected.

@Override
public void onEntityIntersected(World world, BlockPos pos, Entity entity) {
    if (BlockUtils.getBlockPropertyAsBoolean(world, pos, OPEN)) {
        return;
    }
    if (entity instanceof EntityItem)
        return;
    else if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        if (((TileEntityOwnable) world.getTileEntity(pos)).getOwner().isOwner(player))
            return;
    } else if (entity instanceof EntityCreeper) {
        EntityCreeper creeper = (EntityCreeper) entity;
        EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), true);
        creeper.onStruckByLightning(lightning);
        return;
    }
    entity.attackEntityFrom(CustomDamageSources.electricity, 6.0F);
}
Also used : EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) EntityItem(net.minecraft.entity.item.EntityItem) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable)

Example 9 with TileEntityOwnable

use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.

the class ItemScannerDoor 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 (worldIn.isRemote)
        return EnumActionResult.SUCCESS;
    else {
        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))
                return EnumActionResult.FAIL;
            else if (!mod_SecurityCraft.scannerDoor.canPlaceBlockAt(worldIn, pos))
                return EnumActionResult.FAIL;
            else {
                //TERD.getOwner().set(player.getGameProfile().getId().toString(), player.getName());
                placeDoor(worldIn, pos, EnumFacing.fromAngle(playerIn.rotationYaw), mod_SecurityCraft.scannerDoor);
                ((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;
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable)

Aggregations

TileEntityOwnable (net.geforcemods.securitycraft.tileentity.TileEntityOwnable)9 Block (net.minecraft.block.Block)4 IBlockState (net.minecraft.block.state.IBlockState)4 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)4 EntityItem (net.minecraft.entity.item.EntityItem)4 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)1 Owner (net.geforcemods.securitycraft.api.Owner)1 TileEntityKeypad (net.geforcemods.securitycraft.tileentity.TileEntityKeypad)1 TileEntityKeypadChest (net.geforcemods.securitycraft.tileentity.TileEntityKeypadChest)1 TileEntityKeypadFurnace (net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace)1 TileEntityPortableRadar (net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1