Search in sources :

Example 1 with ItemModule

use of net.geforcemods.securitycraft.items.ItemModule in project SecurityCraft by Geforce132.

the class CommandModule method execute.

public void execute(ICommandSender par1ICommandSender, String[] par2String) throws CommandException {
    if (par2String.length == 1) {
        if (par2String[0].matches("copy")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(par1ICommandSender.getName());
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                mod_SecurityCraft.instance.setSavedModule(player.getCurrentEquippedItem().getTagCompound());
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.saved"), EnumChatFormatting.GREEN);
            } else {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.notHoldingForData"), EnumChatFormatting.RED);
            }
            return;
        } else if (par2String[0].matches("paste")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(par1ICommandSender.getName());
            if (mod_SecurityCraft.instance.getSavedModule() == null) {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.nothingSaved"), EnumChatFormatting.RED);
                return;
            }
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                player.getCurrentEquippedItem().setTagCompound(mod_SecurityCraft.instance.getSavedModule());
                mod_SecurityCraft.instance.setSavedModule(null);
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.saved"), EnumChatFormatting.GREEN);
            }
            return;
        }
    } else if (par2String.length == 2) {
        if (par2String[0].matches("add")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(par1ICommandSender.getName());
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                if (player.getCurrentEquippedItem().getTagCompound() == null) {
                    player.getCurrentEquippedItem().setTagCompound(new NBTTagCompound());
                }
                for (int i = 1; i <= 10; i++) {
                    if (player.getCurrentEquippedItem().getTagCompound().hasKey("Player" + i) && player.getCurrentEquippedItem().getTagCompound().getString("Player" + i).matches(par2String[1])) {
                        PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.alreadyContained").replace("#", par2String[1]), EnumChatFormatting.RED);
                        return;
                    }
                }
                player.getCurrentEquippedItem().getTagCompound().setString("Player" + getNextSlot(player.getCurrentEquippedItem().getTagCompound()), par2String[1]);
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.added").replace("#", par2String[1]), EnumChatFormatting.GREEN);
                return;
            } else {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.notHoldingForModify"), EnumChatFormatting.RED);
                return;
            }
        } else if (par2String[0].matches("remove")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(par1ICommandSender.getName());
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                if (player.getCurrentEquippedItem().getTagCompound() == null) {
                    player.getCurrentEquippedItem().setTagCompound(new NBTTagCompound());
                }
                for (int i = 1; i <= 10; i++) {
                    if (player.getCurrentEquippedItem().getTagCompound().hasKey("Player" + i) && player.getCurrentEquippedItem().getTagCompound().getString("Player" + i).matches(par2String[1])) {
                        player.getCurrentEquippedItem().getTagCompound().removeTag("Player" + i);
                    }
                }
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.removed").replace("#", par2String[1]), EnumChatFormatting.GREEN);
                return;
            } else {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.notHoldingForModify"), EnumChatFormatting.RED);
                return;
            }
        }
    }
    throw new WrongUsageException(StatCollector.translateToLocal("messages.command.module.usage"));
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemModule(net.geforcemods.securitycraft.items.ItemModule)

Example 2 with ItemModule

use of net.geforcemods.securitycraft.items.ItemModule in project SecurityCraft by Geforce132.

the class CommandModule method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 1) {
        if (args[0].matches("copy")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getName());
            if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemModule && ((ItemModule) player.inventory.getCurrentItem().getItem()).canNBTBeModified()) {
                mod_SecurityCraft.instance.setSavedModule(player.inventory.getCurrentItem().getTagCompound());
                PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("messages.module.manager"), I18n.translateToLocal("messages.module.saved"), TextFormatting.GREEN);
            } else {
                PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("messages.module.manager"), I18n.translateToLocal("messages.module.notHoldingForData"), TextFormatting.RED);
            }
            return;
        } else if (args[0].matches("paste")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getName());
            if (mod_SecurityCraft.instance.getSavedModule() == null) {
                PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("messages.module.manager"), I18n.translateToLocal("messages.module.nothingSaved"), TextFormatting.RED);
                return;
            }
            if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemModule && ((ItemModule) player.inventory.getCurrentItem().getItem()).canNBTBeModified()) {
                player.inventory.getCurrentItem().setTagCompound(mod_SecurityCraft.instance.getSavedModule());
                mod_SecurityCraft.instance.setSavedModule(null);
                PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("messages.module.manager"), I18n.translateToLocal("messages.module.saved"), TextFormatting.GREEN);
            }
            return;
        }
    } else if (args.length == 2) {
        if (args[0].matches("add")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getName());
            if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemModule && ((ItemModule) player.inventory.getCurrentItem().getItem()).canNBTBeModified()) {
                if (player.inventory.getCurrentItem().getTagCompound() == null) {
                    player.inventory.getCurrentItem().setTagCompound(new NBTTagCompound());
                }
                for (int i = 1; i <= 10; i++) {
                    if (player.inventory.getCurrentItem().getTagCompound().hasKey("Player" + i) && player.inventory.getCurrentItem().getTagCompound().getString("Player" + i).matches(args[1])) {
                        PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("messages.module.manager"), I18n.translateToLocal("messages.module.alreadyContained").replace("#", args[1]), TextFormatting.RED);
                        return;
                    }
                }
                player.inventory.getCurrentItem().getTagCompound().setString("Player" + getNextSlot(player.inventory.getCurrentItem().getTagCompound()), args[1]);
                PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("messages.module.manager"), I18n.translateToLocal("messages.module.added").replace("#", args[1]), TextFormatting.GREEN);
                return;
            } else {
                PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("messages.module.manager"), I18n.translateToLocal("messages.module.notHoldingForModify"), TextFormatting.RED);
                return;
            }
        } else if (args[0].matches("remove")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getName());
            if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemModule && ((ItemModule) player.inventory.getCurrentItem().getItem()).canNBTBeModified()) {
                if (player.inventory.getCurrentItem().getTagCompound() == null) {
                    player.inventory.getCurrentItem().setTagCompound(new NBTTagCompound());
                }
                for (int i = 1; i <= 10; i++) {
                    if (player.inventory.getCurrentItem().getTagCompound().hasKey("Player" + i) && player.inventory.getCurrentItem().getTagCompound().getString("Player" + i).matches(args[1])) {
                        player.inventory.getCurrentItem().getTagCompound().removeTag("Player" + i);
                    }
                }
                PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("messages.module.manager"), I18n.translateToLocal("messages.module.removed").replace("#", args[1]), TextFormatting.GREEN);
                return;
            } else {
                PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("messages.module.manager"), I18n.translateToLocal("messages.module.notHoldingForModify"), TextFormatting.RED);
                return;
            }
        }
    }
    throw new WrongUsageException(I18n.translateToLocal("messages.command.module.usage"));
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemModule(net.geforcemods.securitycraft.items.ItemModule)

Example 3 with ItemModule

use of net.geforcemods.securitycraft.items.ItemModule in project SecurityCraft by Geforce132.

the class CommandModule method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 1) {
        if (args[0].matches("copy")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getCommandSenderName());
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                mod_SecurityCraft.instance.setSavedModule(player.getCurrentEquippedItem().getTagCompound());
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.saved"), EnumChatFormatting.GREEN);
            } else {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.notHoldingForData"), EnumChatFormatting.RED);
            }
            return;
        } else if (args[0].matches("paste")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getCommandSenderName());
            if (mod_SecurityCraft.instance.getSavedModule() == null) {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.nothingSaved"), EnumChatFormatting.RED);
                return;
            }
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                player.getCurrentEquippedItem().setTagCompound(mod_SecurityCraft.instance.getSavedModule());
                mod_SecurityCraft.instance.setSavedModule(null);
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.saved"), EnumChatFormatting.GREEN);
            }
            return;
        }
    } else if (args.length == 2) {
        if (args[0].matches("add")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getCommandSenderName());
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                if (player.getCurrentEquippedItem().getTagCompound() == null) {
                    player.getCurrentEquippedItem().setTagCompound(new NBTTagCompound());
                }
                for (int i = 1; i <= 10; i++) {
                    if (player.getCurrentEquippedItem().getTagCompound().hasKey("Player" + i) && player.getCurrentEquippedItem().getTagCompound().getString("Player" + i).matches(args[1])) {
                        PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.alreadyContained").replace("#", args[1]), EnumChatFormatting.RED);
                        return;
                    }
                }
                player.getCurrentEquippedItem().getTagCompound().setString("Player" + getNextSlot(player.getCurrentEquippedItem().getTagCompound()), args[1]);
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.added").replace("#", args[1]), EnumChatFormatting.GREEN);
                return;
            } else {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.notHoldingForModify"), EnumChatFormatting.RED);
                return;
            }
        } else if (args[0].matches("remove")) {
            EntityPlayer player = PlayerUtils.getPlayerFromName(sender.getCommandSenderName());
            if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemModule && ((ItemModule) player.getCurrentEquippedItem().getItem()).canNBTBeModified()) {
                if (player.getCurrentEquippedItem().getTagCompound() == null) {
                    player.getCurrentEquippedItem().setTagCompound(new NBTTagCompound());
                }
                for (int i = 1; i <= 10; i++) {
                    if (player.getCurrentEquippedItem().getTagCompound().hasKey("Player" + i) && player.getCurrentEquippedItem().getTagCompound().getString("Player" + i).matches(args[1])) {
                        player.getCurrentEquippedItem().getTagCompound().removeTag("Player" + i);
                    }
                }
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.removed").replace("#", args[1]), EnumChatFormatting.GREEN);
                return;
            } else {
                PlayerUtils.sendMessageToPlayer(player, StatCollector.translateToLocal("messages.module.manager"), StatCollector.translateToLocal("messages.module.notHoldingForModify"), EnumChatFormatting.RED);
                return;
            }
        }
    }
    throw new WrongUsageException(StatCollector.translateToLocal("messages.command.module.usage"));
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemModule(net.geforcemods.securitycraft.items.ItemModule)

Example 4 with ItemModule

use of net.geforcemods.securitycraft.items.ItemModule in project SecurityCraft by Geforce132.

the class BlockKeypad method shouldSideBeRendered.

@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 5 with ItemModule

use of net.geforcemods.securitycraft.items.ItemModule in project SecurityCraft by Geforce132.

the class BlockKeypad method shouldSideBeRendered.

@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered(IBlockState state, 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(state) || !blockToDisguiseAs.isFullCube(state)) {
                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.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) ItemModule(net.geforcemods.securitycraft.items.ItemModule) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ItemModule (net.geforcemods.securitycraft.items.ItemModule)7 WrongUsageException (net.minecraft.command.WrongUsageException)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ItemStack (net.minecraft.item.ItemStack)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)2 Block (net.minecraft.block.Block)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 ItemAdminTool (net.geforcemods.securitycraft.items.ItemAdminTool)1 ItemBriefcase (net.geforcemods.securitycraft.items.ItemBriefcase)1 ItemCameraMonitor (net.geforcemods.securitycraft.items.ItemCameraMonitor)1 ItemCodebreaker (net.geforcemods.securitycraft.items.ItemCodebreaker)1 ItemKeyPanel (net.geforcemods.securitycraft.items.ItemKeyPanel)1 ItemKeycardBase (net.geforcemods.securitycraft.items.ItemKeycardBase)1 ItemMineRemoteAccessTool (net.geforcemods.securitycraft.items.ItemMineRemoteAccessTool)1 ItemModifiedBucket (net.geforcemods.securitycraft.items.ItemModifiedBucket)1 ItemReinforcedDoor (net.geforcemods.securitycraft.items.ItemReinforcedDoor)1 ItemSCManual (net.geforcemods.securitycraft.items.ItemSCManual)1 ItemScannerDoor (net.geforcemods.securitycraft.items.ItemScannerDoor)1 ItemTaser (net.geforcemods.securitycraft.items.ItemTaser)1