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"));
}
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"));
}
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"));
}
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;
}
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;
}
Aggregations