Search in sources :

Example 1 with IPasswordProtected

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

the class ItemAdminTool method onItemUse.

@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) {
        if (worldIn.getTileEntity(pos) != null) {
            TileEntity te = worldIn.getTileEntity(pos);
            boolean hasInfo = false;
            if (te instanceof IOwnable) {
                PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.owner.name").replace("#", (((IOwnable) te).getOwner().getName() == null ? "????" : ((IOwnable) te).getOwner().getName())), TextFormatting.DARK_PURPLE);
                PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.owner.uuid").replace("#", (((IOwnable) te).getOwner().getUUID() == null ? "????" : ((IOwnable) te).getOwner().getUUID())), TextFormatting.DARK_PURPLE);
                hasInfo = true;
            }
            if (te instanceof IPasswordProtected) {
                PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.password").replace("#", (((IPasswordProtected) te).getPassword() == null ? "????" : ((IPasswordProtected) te).getPassword())), TextFormatting.DARK_PURPLE);
                hasInfo = true;
            }
            if (te instanceof CustomizableSCTE) {
                List<EnumCustomModules> modules = ((CustomizableSCTE) te).getModules();
                if (!modules.isEmpty()) {
                    PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.equippedModules"), TextFormatting.DARK_PURPLE);
                    for (EnumCustomModules module : modules) PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), "-" + module.getName(), TextFormatting.DARK_PURPLE);
                    hasInfo = true;
                }
            }
            if (!hasInfo)
                PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
            return EnumActionResult.FAIL;
        }
        PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
    }
    return EnumActionResult.FAIL;
}
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)

Example 2 with IPasswordProtected

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

the class ItemAdminTool method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        if (worldIn.getTileEntity(pos) != null) {
            TileEntity te = worldIn.getTileEntity(pos);
            boolean hasInfo = false;
            if (te instanceof IOwnable) {
                PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.owner.name").replace("#", (((IOwnable) te).getOwner().getName() == null ? "????" : ((IOwnable) te).getOwner().getName())), TextFormatting.DARK_PURPLE);
                PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.owner.uuid").replace("#", (((IOwnable) te).getOwner().getUUID() == null ? "????" : ((IOwnable) te).getOwner().getUUID())), TextFormatting.DARK_PURPLE);
                hasInfo = true;
            }
            if (te instanceof IPasswordProtected) {
                PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.password").replace("#", (((IPasswordProtected) te).getPassword() == null ? "????" : ((IPasswordProtected) te).getPassword())), TextFormatting.DARK_PURPLE);
                hasInfo = true;
            }
            if (te instanceof CustomizableSCTE) {
                List<EnumCustomModules> modules = ((CustomizableSCTE) te).getModules();
                if (!modules.isEmpty()) {
                    PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.equippedModules"), TextFormatting.DARK_PURPLE);
                    for (EnumCustomModules module : modules) PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), "-" + module.getName(), TextFormatting.DARK_PURPLE);
                    hasInfo = true;
                }
            }
            if (!hasInfo)
                PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
            return EnumActionResult.FAIL;
        }
        PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
    }
    return EnumActionResult.FAIL;
}
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)

Example 3 with IPasswordProtected

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

the class GuiSCManual method updateRecipeAndIcons.

private void updateRecipeAndIcons() {
    if (currentPage < 0) {
        recipe = null;
        hoverCheckers.clear();
        return;
    }
    hoverCheckers.clear();
    if (SecurityCraft.instance.manualPages.get(currentPage).hasCustomRecipe())
        recipe = SecurityCraft.instance.manualPages.get(currentPage).getRecipe();
    else
        for (Object object : CraftingManager.getInstance().getRecipeList()) {
            if (object instanceof ShapedRecipes) {
                ShapedRecipes recipe = (ShapedRecipes) object;
                if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
                    this.recipe = recipe.recipeItems;
                    break;
                }
            } else if (object instanceof ShapelessRecipes) {
                ShapelessRecipes recipe = (ShapelessRecipes) object;
                if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
                    this.recipe = toItemStackArray(recipe.recipeItems);
                    break;
                }
            }
            recipe = null;
        }
    if (recipe != null) {
        outer: for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if ((i * 3) + j == recipe.length)
                    break outer;
                if (recipe[(i * 3) + j] != null)
                    hoverCheckers.add(new CustomHoverChecker(144 + (i * 20), 144 + (i * 20) + 16, (k + 100) + (j * 20), (k + 100) + (j * 20) + 16, 20, recipe[(i * 3) + j].getDisplayName()));
            }
        }
    } else if (SecurityCraft.instance.manualPages.get(currentPage).isRecipeDisabled())
        hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.disabled")));
    else if (SecurityCraft.instance.manualPages.get(currentPage).getHelpInfo().equals("help.reinforced.info"))
        hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.recipe.reinforced")));
    else {
        String name = SecurityCraft.instance.manualPages.get(currentPage).getItem().getUnlocalizedName().substring(5);
        hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.recipe." + name)));
    }
    Item item = SecurityCraft.instance.manualPages.get(currentPage).getItem();
    TileEntity te = ((item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof ITileEntityProvider) ? ((ITileEntityProvider) ((ItemBlock) item).getBlock()).createNewTileEntity(Minecraft.getMinecraft().theWorld, 0) : null);
    Block itemBlock = ((item instanceof ItemBlock) ? ((ItemBlock) item).getBlock() : null);
    if (te != null) {
        if (te instanceof IOwnable)
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 29, (k + 29) + 16, 20, StatCollector.translateToLocal("gui.scManual.ownableBlock")));
        if (te instanceof IPasswordProtected)
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 55, (k + 55) + 16, 20, StatCollector.translateToLocal("gui.scManual.passwordProtectedBlock")));
        if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView())
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 81, (k + 81) + 16, 20, StatCollector.translateToLocal("gui.scManual.viewActivatedBlock")));
        if (itemBlock instanceof IExplosive)
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 107, (k + 107) + 16, 20, StatCollector.translateToLocal("gui.scManual.explosiveBlock")));
        if (te instanceof CustomizableSCTE)
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 213, (k + 213) + 16, 20, StatCollector.translateToLocal("gui.scManual.customizableBlock")));
    }
}
Also used : ShapedRecipes(net.minecraft.item.crafting.ShapedRecipes) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) CustomHoverChecker(net.geforcemods.securitycraft.gui.components.CustomHoverChecker) TileEntitySCTE(net.geforcemods.securitycraft.api.TileEntitySCTE) ItemBlock(net.minecraft.item.ItemBlock) TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) ITileEntityProvider(net.minecraft.block.ITileEntityProvider) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IOwnable(net.geforcemods.securitycraft.api.IOwnable) IExplosive(net.geforcemods.securitycraft.api.IExplosive) ShapelessRecipes(net.minecraft.item.crafting.ShapelessRecipes)

Example 4 with IPasswordProtected

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

the class GuiSetPassword method actionPerformed.

@Override
protected void actionPerformed(GuiButton guibutton) {
    switch(guibutton.id) {
        case 0:
            if (keycodeTextbox.getText().isEmpty()) {
                flag = true;
                updateButtonText();
                return;
            }
            ((IPasswordProtected) tileEntity).setPassword(keycodeTextbox.getText());
            SecurityCraft.network.sendToServer(new PacketSSetPassword(tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ(), keycodeTextbox.getText()));
            ClientUtils.closePlayerScreen();
            Minecraft.getMinecraft().thePlayer.openGui(SecurityCraft.instance, GuiHandler.INSERT_PASSWORD_ID, tileEntity.getWorld(), tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ());
    }
}
Also used : PacketSSetPassword(net.geforcemods.securitycraft.network.packets.PacketSSetPassword) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected)

Example 5 with IPasswordProtected

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

the class SCEventHandler method handleCodebreaking.

private boolean handleCodebreaking(PlayerInteractEvent event) {
    World world = event.entityPlayer.worldObj;
    TileEntity tileEntity = event.entityPlayer.worldObj.getTileEntity(event.pos);
    if (// safety so when codebreakers are disabled they can't take damage
    SecurityCraft.config.allowCodebreakerItem)
        event.entityPlayer.getCurrentEquippedItem().damageItem(1, event.entityPlayer);
    if (tileEntity != null && tileEntity instanceof IPasswordProtected && new Random().nextInt(3) == 1)
        return ((IPasswordProtected) tileEntity).onCodebreakerUsed(world.getBlockState(event.pos), event.entityPlayer, !SecurityCraft.config.allowCodebreakerItem);
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) Random(java.util.Random) World(net.minecraft.world.World)

Aggregations

IPasswordProtected (net.geforcemods.securitycraft.api.IPasswordProtected)11 TileEntity (net.minecraft.tileentity.TileEntity)8 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)7 IOwnable (net.geforcemods.securitycraft.api.IOwnable)7 EnumCustomModules (net.geforcemods.securitycraft.misc.EnumCustomModules)5 IExplosive (net.geforcemods.securitycraft.api.IExplosive)2 TileEntitySCTE (net.geforcemods.securitycraft.api.TileEntitySCTE)2 CustomHoverChecker (net.geforcemods.securitycraft.gui.components.CustomHoverChecker)2 PacketSSetPassword (net.geforcemods.securitycraft.network.packets.PacketSSetPassword)2 Block (net.minecraft.block.Block)2 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)2 Item (net.minecraft.item.Item)2 ItemBlock (net.minecraft.item.ItemBlock)2 World (net.minecraft.world.World)2 Random (java.util.Random)1 INameable (net.geforcemods.securitycraft.api.INameable)1 ShapedRecipes (net.minecraft.item.crafting.ShapedRecipes)1 ShapelessRecipes (net.minecraft.item.crafting.ShapelessRecipes)1