Search in sources :

Example 16 with CustomizableSCTE

use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.

the class ForgeEventHandler method onRightClickBlock.

@SubscribeEvent
public void onRightClickBlock(RightClickBlock event) {
    if (!event.getEntityPlayer().worldObj.isRemote) {
        World world = event.getEntityPlayer().worldObj;
        TileEntity tileEntity = event.getEntityPlayer().worldObj.getTileEntity(event.getPos());
        Block block = event.getEntityPlayer().worldObj.getBlockState(event.getPos()).getBlock();
        if (PlayerUtils.isHoldingItem(event.getEntityPlayer(), mod_SecurityCraft.codebreaker) && handleCodebreaking(event)) {
            event.setCanceled(true);
            return;
        }
        if (tileEntity != null && tileEntity instanceof CustomizableSCTE && PlayerUtils.isHoldingItem(event.getEntityPlayer(), mod_SecurityCraft.universalBlockModifier)) {
            event.setCanceled(true);
            if (!((IOwnable) tileEntity).getOwner().isOwner(event.getEntityPlayer())) {
                PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), I18n.translateToLocal("item.universalBlockModifier.name"), I18n.translateToLocal("messages.notOwned").replace("#", ((TileEntityOwnable) tileEntity).getOwner().getName()), TextFormatting.RED);
                return;
            }
            event.getEntityPlayer().openGui(mod_SecurityCraft.instance, GuiHandler.CUSTOMIZE_BLOCK, world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
            return;
        }
        if (tileEntity instanceof INameable && ((INameable) tileEntity).canBeNamed() && PlayerUtils.isHoldingItem(event.getEntityPlayer(), Items.NAME_TAG) && event.getEntityPlayer().inventory.getCurrentItem().hasDisplayName()) {
            event.setCanceled(true);
            for (String character : new String[] { "(", ")" }) {
                if (event.getEntityPlayer().inventory.getCurrentItem().getDisplayName().contains(character)) {
                    PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), "Naming", I18n.translateToLocal("messages.naming.error").replace("#n", event.getEntityPlayer().inventory.getCurrentItem().getDisplayName()).replace("#c", character), TextFormatting.RED);
                    return;
                }
            }
            if (((INameable) tileEntity).getCustomName().matches(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName())) {
                PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), "Naming", I18n.translateToLocal("messages.naming.alreadyMatches").replace("#n", ((INameable) tileEntity).getCustomName()), TextFormatting.RED);
                return;
            }
            event.getEntityPlayer().inventory.getCurrentItem().stackSize--;
            ((INameable) tileEntity).setCustomName(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName());
            return;
        }
        if (tileEntity != null && isOwnableBlock(block, tileEntity) && PlayerUtils.isHoldingItem(event.getEntityPlayer(), mod_SecurityCraft.universalBlockRemover)) {
            event.setCanceled(true);
            if (!((IOwnable) tileEntity).getOwner().isOwner(event.getEntityPlayer())) {
                PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), I18n.translateToLocal("item.universalBlockRemover.name"), I18n.translateToLocal("messages.notOwned").replace("#", ((TileEntityOwnable) tileEntity).getOwner().getName()), TextFormatting.RED);
                return;
            }
            if (block == mod_SecurityCraft.laserBlock) {
                world.destroyBlock(event.getPos(), true);
                BlockLaserBlock.destroyAdjacentLasers(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
                event.getEntityPlayer().inventory.getCurrentItem().damageItem(1, event.getEntityPlayer());
            } else {
                world.destroyBlock(event.getPos(), true);
                world.removeTileEntity(event.getPos());
                event.getEntityPlayer().inventory.getCurrentItem().damageItem(1, event.getEntityPlayer());
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) INameable(net.geforcemods.securitycraft.api.INameable) RightClickBlock(net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock) Block(net.minecraft.block.Block) BlockLaserBlock(net.geforcemods.securitycraft.blocks.BlockLaserBlock) IOwnable(net.geforcemods.securitycraft.api.IOwnable) TextComponentString(net.minecraft.util.text.TextComponentString) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 17 with CustomizableSCTE

use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.

the class BlockKeypad method shouldSideBeRendered.

@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) {
    BlockPos keypadPos = pos.offset(side.getOpposite());
    if (worldIn.getTileEntity(keypadPos) == null)
        return true;
    CustomizableSCTE tileEntity = (CustomizableSCTE) worldIn.getTileEntity(keypadPos);
    if (tileEntity.hasModule(EnumCustomModules.DISGUISE)) {
        ItemStack disguiseModule = tileEntity.getModule(EnumCustomModules.DISGUISE);
        List<Block> blocks = ((ItemModule) disguiseModule.getItem()).getBlockAddons(disguiseModule.getTagCompound());
        if (blocks.size() != 0) {
            Block blockToDisguiseAs = blocks.get(0);
            // If the keypad has a disguise module added with a transparent block inserted.
            if (!blockToDisguiseAs.isOpaqueCube() || !blockToDisguiseAs.isFullCube())
                return checkForSideTransparency(worldIn, keypadPos, worldIn.getBlockState(keypadPos.offset(side)).getBlock(), side);
        }
    }
    return true;
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.BlockPos) ItemStack(net.minecraft.item.ItemStack) ItemModule(net.geforcemods.securitycraft.items.ItemModule) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 18 with CustomizableSCTE

use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.

the class BlockLaserField method onEntityIntersected.

@Override
public void onEntityIntersected(World world, BlockPos pos, Entity entity) {
    if (!world.isRemote && entity instanceof EntityLivingBase && !EntityUtils.doesMobHavePotionEffect((EntityLivingBase) entity, Potion.invisibility)) {
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = BlockUtils.getBlock(world, pos.east(i));
            if (id == SCContent.laserBlock && !BlockUtils.getBlockPropertyAsBoolean(world, pos.east(i), BlockLaserBlock.POWERED)) {
                if (world.getTileEntity(pos.east(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.east(i))).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(world, pos.east(i), EnumCustomModules.WHITELIST).contains(((EntityLivingBase) entity).getCommandSenderName().toLowerCase()))
                    return;
                BlockUtils.setBlockProperty(world, pos.east(i), BlockLaserBlock.POWERED, true, true);
                world.notifyNeighborsOfStateChange(pos.east(i), SCContent.laserBlock);
                world.scheduleUpdate(pos.east(i), SCContent.laserBlock, 50);
                if (world.getTileEntity(pos.east(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.east(i))).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) entity).attackEntityFrom(CustomDamageSources.laser, 10F);
                break;
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = BlockUtils.getBlock(world, pos.west(i));
            if (id == SCContent.laserBlock && !BlockUtils.getBlockPropertyAsBoolean(world, pos.west(i), BlockLaserBlock.POWERED)) {
                if (world.getTileEntity(pos.west(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.west(i))).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(world, pos.west(i), EnumCustomModules.WHITELIST).contains(((EntityLivingBase) entity).getCommandSenderName().toLowerCase()))
                    return;
                BlockUtils.setBlockProperty(world, pos.west(i), BlockLaserBlock.POWERED, true, true);
                world.notifyNeighborsOfStateChange(pos.west(i), SCContent.laserBlock);
                world.scheduleUpdate(pos.west(i), SCContent.laserBlock, 50);
                if (world.getTileEntity(pos.west(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.west(i))).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) entity).attackEntityFrom(CustomDamageSources.laser, 10F);
                break;
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = BlockUtils.getBlock(world, pos.south(i));
            if (id == SCContent.laserBlock && !BlockUtils.getBlockPropertyAsBoolean(world, pos.south(i), BlockLaserBlock.POWERED)) {
                if (world.getTileEntity(pos.south(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.south(i))).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(world, pos.south(i), EnumCustomModules.WHITELIST).contains(((EntityLivingBase) entity).getCommandSenderName().toLowerCase()))
                    return;
                BlockUtils.setBlockProperty(world, pos.south(i), BlockLaserBlock.POWERED, true, true);
                world.notifyNeighborsOfStateChange(pos.south(i), SCContent.laserBlock);
                world.scheduleUpdate(pos.south(i), SCContent.laserBlock, 50);
                if (world.getTileEntity(pos.south(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.south(i))).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) entity).attackEntityFrom(CustomDamageSources.laser, 10F);
                break;
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = BlockUtils.getBlock(world, pos.north(i));
            if (id == SCContent.laserBlock && !BlockUtils.getBlockPropertyAsBoolean(world, pos.north(i), BlockLaserBlock.POWERED)) {
                if (world.getTileEntity(pos.north(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.north(i))).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(world, pos.north(i), EnumCustomModules.WHITELIST).contains(((EntityLivingBase) entity).getCommandSenderName().toLowerCase()))
                    return;
                BlockUtils.setBlockProperty(world, pos.north(i), BlockLaserBlock.POWERED, true, true);
                world.notifyNeighborsOfStateChange(pos.north(i), SCContent.laserBlock);
                world.scheduleUpdate(pos.north(i), SCContent.laserBlock, 50);
                if (world.getTileEntity(pos.north(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.north(i))).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) entity).attackEntityFrom(CustomDamageSources.laser, 10F);
                break;
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = BlockUtils.getBlock(world, pos.up(i));
            if (id == SCContent.laserBlock && !BlockUtils.getBlockPropertyAsBoolean(world, pos.up(i), BlockLaserBlock.POWERED)) {
                if (world.getTileEntity(pos.up(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.up(i))).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(world, pos.up(i), EnumCustomModules.WHITELIST).contains(((EntityLivingBase) entity).getCommandSenderName().toLowerCase()))
                    return;
                BlockUtils.setBlockProperty(world, pos.up(i), BlockLaserBlock.POWERED, true, true);
                world.notifyNeighborsOfStateChange(pos.up(i), SCContent.laserBlock);
                world.scheduleUpdate(pos.up(i), SCContent.laserBlock, 50);
                if (world.getTileEntity(pos.up(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.up(i))).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) entity).attackEntityFrom(CustomDamageSources.laser, 10F);
                break;
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = BlockUtils.getBlock(world, pos.down(i));
            if (id == SCContent.laserBlock && !BlockUtils.getBlockPropertyAsBoolean(world, pos.down(i), BlockLaserBlock.POWERED)) {
                if (world.getTileEntity(pos.down(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.down(i))).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(world, pos.down(i), EnumCustomModules.WHITELIST).contains(((EntityLivingBase) entity).getCommandSenderName().toLowerCase()))
                    return;
                BlockUtils.setBlockProperty(world, pos.down(i), BlockLaserBlock.POWERED, true, true);
                world.notifyNeighborsOfStateChange(pos.down(i), SCContent.laserBlock);
                world.scheduleUpdate(pos.down(i), SCContent.laserBlock, 50);
                if (world.getTileEntity(pos.down(i)) instanceof CustomizableSCTE && ((CustomizableSCTE) world.getTileEntity(pos.down(i))).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) entity).attackEntityFrom(CustomDamageSources.laser, 10F);
                break;
            }
        }
    }
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Block(net.minecraft.block.Block)

Example 19 with CustomizableSCTE

use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.

the class BlockLaserField method onEntityCollidedWithBlock.

/**
 * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
 */
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
    if (!par1World.isRemote && par5Entity instanceof EntityLivingBase && !EntityUtils.doesMobHavePotionEffect((EntityLivingBase) par5Entity, Potion.invisibility)) {
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2 + i, par3, par4);
            if (id == SCContent.laserBlock) {
                if (par1World.getTileEntity(par2 + i, par3, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2 + i, par3, par4)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2 + i, par3, par4, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName().toLowerCase()))
                    return;
                par1World.setBlockMetadataWithNotify(par2 + i, par3, par4, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2 + i, par3, par4, SCContent.laserBlock);
                par1World.scheduleBlockUpdate(par2 + i, par3, par4, SCContent.laserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2 + i, par3, par4, SCContent.laserBlock);
                if (par1World.getTileEntity(par2 + i, par3, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2 + i, par3, par4)).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) par5Entity).attackEntityFrom(CustomDamageSources.laser, 10F);
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2 - i, par3, par4);
            if (id == SCContent.laserBlock) {
                if (par1World.getTileEntity(par2 - i, par3, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2 - i, par3, par4)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2 - i, par3, par4, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName().toLowerCase()))
                    return;
                par1World.setBlockMetadataWithNotify(par2 - i, par3, par4, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2 - i, par3, par4, SCContent.laserBlock);
                par1World.scheduleBlockUpdate(par2 - i, par3, par4, SCContent.laserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2 - i, par3, par4, SCContent.laserBlock);
                if (par1World.getTileEntity(par2 - i, par3, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2 - i, par3, par4)).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) par5Entity).attackEntityFrom(CustomDamageSources.laser, 10F);
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2, par3, par4 + i);
            if (id == SCContent.laserBlock) {
                if (par1World.getTileEntity(par2, par3, par4 + i) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4 + i)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2, par3, par4 + i, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName().toLowerCase()))
                    return;
                par1World.setBlockMetadataWithNotify(par2, par3, par4 + i, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + i, SCContent.laserBlock);
                par1World.scheduleBlockUpdate(par2, par3, par4 + i, SCContent.laserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + i, SCContent.laserBlock);
                if (par1World.getTileEntity(par2, par3, par4 + i) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4 + i)).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) par5Entity).attackEntityFrom(CustomDamageSources.laser, 10F);
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2, par3, par4 - i);
            if (id == SCContent.laserBlock) {
                if (par1World.getTileEntity(par2, par3, par4 - i) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4 - i)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2, par3, par4 - i, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName().toLowerCase()))
                    return;
                par1World.setBlockMetadataWithNotify(par2, par3, par4 - i, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - i, SCContent.laserBlock);
                par1World.scheduleBlockUpdate(par2, par3, par4 - i, SCContent.laserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - i, SCContent.laserBlock);
                if (par1World.getTileEntity(par2, par3, par4 - i) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4 - i)).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) par5Entity).attackEntityFrom(CustomDamageSources.laser, 10F);
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2, par3 + i, par4);
            if (id == SCContent.laserBlock) {
                if (par1World.getTileEntity(par2, par3 + i, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3 + i, par4)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2, par3 + i, par4, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName().toLowerCase()))
                    return;
                par1World.setBlockMetadataWithNotify(par2, par3 + i, par4, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2, par3 + i, par4, SCContent.laserBlock);
                par1World.scheduleBlockUpdate(par2, par3 + i, par4, SCContent.laserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2, par3 + i, par4, SCContent.laserBlock);
                if (par1World.getTileEntity(par2, par3 + i, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3 + i, par4)).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) par5Entity).attackEntityFrom(CustomDamageSources.laser, 10F);
            }
        }
        for (int i = 0; i < SecurityCraft.config.laserBlockRange; i++) {
            Block id = par1World.getBlock(par2, par3 - i, par4);
            if (id == SCContent.laserBlock) {
                if (par1World.getTileEntity(par2, par3 - i, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3 - i, par4)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2, par3 - i, par4, EnumCustomModules.WHITELIST).contains(((EntityLivingBase) par5Entity).getCommandSenderName().toLowerCase()))
                    return;
                par1World.setBlockMetadataWithNotify(par2, par3 - i, par4, 2, 3);
                par1World.notifyBlocksOfNeighborChange(par2, par3 - i, par4, SCContent.laserBlock);
                par1World.scheduleBlockUpdate(par2, par3 - i, par4, SCContent.laserBlock, 50);
                par1World.notifyBlocksOfNeighborChange(par2, par3 - i, par4, SCContent.laserBlock);
                if (par1World.getTileEntity(par2, par3 - i, par4) instanceof CustomizableSCTE && ((CustomizableSCTE) par1World.getTileEntity(par2, par3 - i, par4)).hasModule(EnumCustomModules.HARMING))
                    ((EntityLivingBase) par5Entity).attackEntityFrom(CustomDamageSources.laser, 10F);
            }
        }
    }
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Block(net.minecraft.block.Block)

Example 20 with CustomizableSCTE

use of net.geforcemods.securitycraft.api.CustomizableSCTE in project SecurityCraft by Geforce132.

the class ItemAdminTool method onItemUse.

@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
    if (!par3World.isRemote) {
        if (par3World.getTileEntity(par4, par5, par6) != null) {
            TileEntity te = par3World.getTileEntity(par4, par5, par6);
            boolean hasInfo = false;
            if (te instanceof IOwnable) {
                PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.owner.name").replace("#", (((IOwnable) te).getOwner().getName() == null ? "????" : ((IOwnable) te).getOwner().getName())), EnumChatFormatting.DARK_PURPLE);
                PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.owner.uuid").replace("#", (((IOwnable) te).getOwner().getUUID() == null ? "????" : ((IOwnable) te).getOwner().getUUID())), EnumChatFormatting.DARK_PURPLE);
                hasInfo = true;
            }
            if (te instanceof IPasswordProtected) {
                PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.password").replace("#", (((IPasswordProtected) te).getPassword() == null ? "????" : ((IPasswordProtected) te).getPassword())), EnumChatFormatting.DARK_PURPLE);
                hasInfo = true;
            }
            if (te instanceof CustomizableSCTE) {
                List<EnumCustomModules> modules = ((CustomizableSCTE) te).getModules();
                if (!modules.isEmpty()) {
                    PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.equippedModules"), EnumChatFormatting.DARK_PURPLE);
                    for (EnumCustomModules module : modules) PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), "-" + module.getName(), EnumChatFormatting.DARK_PURPLE);
                    hasInfo = true;
                }
            }
            if (!hasInfo)
                PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.noInfo"), EnumChatFormatting.DARK_PURPLE);
            return false;
        }
        PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.adminTool.name"), StatCollector.translateToLocal("messages.adminTool.noInfo"), EnumChatFormatting.DARK_PURPLE);
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) IOwnable(net.geforcemods.securitycraft.api.IOwnable) EnumCustomModules(net.geforcemods.securitycraft.misc.EnumCustomModules)

Aggregations

CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)24 TileEntity (net.minecraft.tileentity.TileEntity)12 IOwnable (net.geforcemods.securitycraft.api.IOwnable)10 Block (net.minecraft.block.Block)10 ItemStack (net.minecraft.item.ItemStack)9 IPasswordProtected (net.geforcemods.securitycraft.api.IPasswordProtected)7 INameable (net.geforcemods.securitycraft.api.INameable)6 EnumCustomModules (net.geforcemods.securitycraft.misc.EnumCustomModules)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 BlockLaserBlock (net.geforcemods.securitycraft.blocks.BlockLaserBlock)3 TileEntityPortableRadar (net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar)3 World (net.minecraft.world.World)3 ArrayList (java.util.ArrayList)2 IExplosive (net.geforcemods.securitycraft.api.IExplosive)2 TileEntitySCTE (net.geforcemods.securitycraft.api.TileEntitySCTE)2 CustomHoverChecker (net.geforcemods.securitycraft.gui.components.CustomHoverChecker)2 ItemModule (net.geforcemods.securitycraft.items.ItemModule)2 TileEntityKeypad (net.geforcemods.securitycraft.tileentity.TileEntityKeypad)2 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2