Search in sources :

Example 1 with TileEntityOwnable

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

the class BlockIronFence method onEntityCollidedWithBlock.

public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    //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 2 with TileEntityOwnable

use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable 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
     */
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.reinforcedDoor.canPlaceBlockAt(world, pos)) {
                return false;
            } else {
                //TERD.getOwner().set(player.getGameProfile().getId().toString(), player.getName());
                placeDoor(world, pos, EnumFacing.fromAngle(player.rotationYaw), mod_SecurityCraft.reinforcedDoor);
                ((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 3 with TileEntityOwnable

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

the class BlockIronFence method onEntityIntersected.

@Override
public void onEntityIntersected(World world, BlockPos pos, Entity entity) {
    //so dropped items don't get destroyed
    if (entity instanceof EntityItem)
        return;
    else //owner check
    if (entity instanceof EntityPlayer) {
        if (((TileEntityOwnable) world.getTileEntity(pos)).getOwner().isOwner((EntityPlayer) entity))
            ;
        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);
        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 4 with TileEntityOwnable

use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable 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 (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.reinforcedDoor.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.reinforcedDoor);
                ((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)

Example 5 with TileEntityOwnable

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

the class BlockUtils method setBlockProperty.

public static void setBlockProperty(World par1World, BlockPos pos, PropertyBool property, boolean value, boolean retainOldTileEntity) {
    if (retainOldTileEntity) {
        ItemStack[] modules = null;
        ItemStack[] inventory = null;
        int[] times = new int[4];
        String password = "";
        Owner owner = null;
        int cooldown = -1;
        if (par1World.getTileEntity(pos) instanceof CustomizableSCTE) {
            modules = ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks;
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
            inventory = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks;
            times[0] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime;
            times[1] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime;
            times[2] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime;
            times[3] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime;
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityOwnable && ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner() != null) {
            owner = ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypad && ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword() != null) {
            password = ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace && ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword() != null) {
            password = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypadChest && ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword() != null) {
            password = ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown() != 0) {
            cooldown = ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown();
        }
        TileEntity tileEntity = par1World.getTileEntity(pos);
        par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
        par1World.setTileEntity(pos, tileEntity);
        if (modules != null) {
            ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks = modules;
        }
        if (inventory != null && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks = inventory;
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime = times[0];
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime = times[1];
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime = times[2];
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime = times[3];
        }
        if (owner != null) {
            ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner().set(owner);
        }
        if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypad) {
            ((TileEntityKeypad) par1World.getTileEntity(pos)).setPassword(password);
        }
        if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).setPassword(password);
        }
        if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadChest) {
            ((TileEntityKeypadChest) par1World.getTileEntity(pos)).setPassword(password);
        }
        if (cooldown != -1 && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar) {
            ((TileEntityPortableRadar) par1World.getTileEntity(pos)).setAttackCooldown(cooldown);
        }
    } else {
        par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
    }
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) TileEntityKeypadFurnace(net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace) TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) TileEntityKeypadChest(net.geforcemods.securitycraft.tileentity.TileEntityKeypadChest) TileEntityPortableRadar(net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar) ItemStack(net.minecraft.item.ItemStack) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable) TileEntityKeypad(net.geforcemods.securitycraft.tileentity.TileEntityKeypad)

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