Search in sources :

Example 6 with IPasswordProtected

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

the class ForgeEventHandler method handleCodebreaking.

private boolean handleCodebreaking(PlayerInteractEvent event) {
    World world = event.getEntityPlayer().worldObj;
    TileEntity tileEntity = event.getEntityPlayer().worldObj.getTileEntity(event.getPos());
    if (tileEntity != null && tileEntity instanceof IPasswordProtected) {
        return ((IPasswordProtected) tileEntity).onCodebreakerUsed(world.getBlockState(event.getPos()), event.getEntityPlayer(), !mod_SecurityCraft.configHandler.allowCodebreakerItem);
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) World(net.minecraft.world.World)

Example 7 with IPasswordProtected

use of net.geforcemods.securitycraft.api.IPasswordProtected 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)

Example 8 with IPasswordProtected

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

the class GuiKeyChanger method actionPerformed.

@Override
protected void actionPerformed(GuiButton guibutton) {
    switch(guibutton.id) {
        case 0:
            ((IPasswordProtected) tileEntity).setPassword(textboxNewPasscode.getText());
            SecurityCraft.network.sendToServer(new PacketSSetPassword(tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ(), textboxNewPasscode.getText()));
            ClientUtils.closePlayerScreen();
            PlayerUtils.sendMessageToPlayer(Minecraft.getMinecraft().thePlayer, StatCollector.translateToLocal("item.universalKeyChanger.name"), StatCollector.translateToLocal("messages.universalKeyChanger.passcodeChanged"), EnumChatFormatting.GREEN);
    }
}
Also used : PacketSSetPassword(net.geforcemods.securitycraft.network.packets.PacketSSetPassword) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected)

Example 9 with IPasswordProtected

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

the class GuiSCManual method drawScreen.

@Override
public void drawScreen(int par1, int par2, float par3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    if (update) {
        updateRecipeAndIcons();
        update = false;
    }
    if (currentPage == -1)
        mc.getTextureManager().bindTexture(infoBookTitlePage);
    else if (recipe != null || SecurityCraft.instance.manualPages.get(currentPage).isRecipeDisabled())
        mc.getTextureManager().bindTexture(infoBookTexture);
    else
        mc.getTextureManager().bindTexture(infoBookTextureSpecial);
    this.drawTexturedModalRect(k, 5, 0, 0, 256, 250);
    if (currentPage > -1) {
        if (SecurityCraft.instance.manualPages.get(currentPage).getHelpInfo().equals("help.reinforced.info"))
            fontRendererObj.drawString(StatCollector.translateToLocal("gui.scManual.reinforced"), k + 39, 27, 0, false);
        else
            fontRendererObj.drawString(StatCollector.translateToLocal(SecurityCraft.instance.manualPages.get(currentPage).getItem().getUnlocalizedName() + ".name"), k + 39, 27, 0, false);
        fontRendererObj.drawSplitString(StatCollector.translateToLocal(SecurityCraft.instance.manualPages.get(currentPage).getHelpInfo()), k + 18, 45, 225, 0);
    } else {
        fontRendererObj.drawString(StatCollector.translateToLocal("gui.scManual.intro.1"), k + 39, 27, 0, false);
        fontRendererObj.drawString(StatCollector.translateToLocal("gui.scManual.intro.2"), k + 60, 159, 0, false);
        if (StatCollector.canTranslate("gui.scManual.author"))
            fontRendererObj.drawString(StatCollector.translateToLocal("gui.scManual.author"), k + 65, 170, 0, false);
    }
    for (int i = 0; i < buttonList.size(); i++) ((GuiButton) buttonList.get(i)).drawButton(mc, par1, par2);
    if (currentPage > -1) {
        Item item = SecurityCraft.instance.manualPages.get(currentPage).getItem();
        GuiUtils.drawItemStackToGui(mc, item, k + 19, 22, !(SecurityCraft.instance.manualPages.get(currentPage).getItem() instanceof ItemBlock));
        mc.getTextureManager().bindTexture(infoBookIcons);
        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 (itemBlock != null) {
            if (itemBlock instanceof IExplosive)
                this.drawTexturedModalRect(k + 107, 117, 54, 1, 18, 18);
            if (te != null) {
                if (te instanceof IOwnable)
                    this.drawTexturedModalRect(k + 29, 118, 1, 1, 16, 16);
                if (te instanceof IPasswordProtected)
                    this.drawTexturedModalRect(k + 55, 118, 18, 1, 17, 16);
                if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView())
                    this.drawTexturedModalRect(k + 81, 118, 36, 1, 17, 16);
                if (te instanceof CustomizableSCTE)
                    this.drawTexturedModalRect(k + 213, 118, 72, 1, 16, 16);
            }
        }
        if (recipe != null) {
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    if (((i * 3) + j) >= recipe.length)
                        break;
                    if (recipe[(i * 3) + j] == null)
                        continue;
                    if (recipe[(i * 3) + j].getItem() instanceof ItemBlock)
                        GuiUtils.drawItemStackToGui(mc, Block.getBlockFromItem(recipe[(i * 3) + j].getItem()), (k + 100) + (j * 20), 144 + (i * 20), !(recipe[(i * 3) + j].getItem() instanceof ItemBlock));
                    else
                        GuiUtils.drawItemStackToGui(mc, recipe[(i * 3) + j].getItem(), recipe[(i * 3) + j].getItemDamage(), (k + 100) + (j * 20), 144 + (i * 20), !(recipe[(i * 3) + j].getItem() instanceof ItemBlock));
                }
            }
        }
        for (CustomHoverChecker chc : hoverCheckers) {
            if (chc != null && chc.checkHover(par1, par2)) {
                if (chc.getName() != null)
                    drawHoveringText(mc.fontRendererObj.listFormattedStringToWidth(chc.getName(), 250), par1, par2, mc.fontRendererObj);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) ITileEntityProvider(net.minecraft.block.ITileEntityProvider) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) CustomHoverChecker(net.geforcemods.securitycraft.gui.components.CustomHoverChecker) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IOwnable(net.geforcemods.securitycraft.api.IOwnable) TileEntitySCTE(net.geforcemods.securitycraft.api.TileEntitySCTE) IExplosive(net.geforcemods.securitycraft.api.IExplosive) ItemBlock(net.minecraft.item.ItemBlock)

Example 10 with IPasswordProtected

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

the class WailaDataProvider method getWailaBody.

@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> tipList, IWailaDataAccessor iDataAccessor, IWailaConfigHandler iConfigHandler) {
    if (iDataAccessor.getBlock() instanceof ICustomWailaDisplay && !((ICustomWailaDisplay) iDataAccessor.getBlock()).shouldShowSCInfo(iDataAccessor.getWorld(), iDataAccessor.getBlockState(), iDataAccessor.getPosition()))
        return tipList;
    if (iConfigHandler.getConfig("securitycraft.showowner") && iDataAccessor.getTileEntity() instanceof IOwnable)
        tipList.add(StatCollector.translateToLocal("waila.owner") + " " + ((IOwnable) iDataAccessor.getTileEntity()).getOwner().getName());
    if (iConfigHandler.getConfig("securitycraft.showmodules") && iDataAccessor.getTileEntity() instanceof CustomizableSCTE && ((CustomizableSCTE) iDataAccessor.getTileEntity()).getOwner().isOwner(iDataAccessor.getPlayer())) {
        if (!((CustomizableSCTE) iDataAccessor.getTileEntity()).getModules().isEmpty())
            tipList.add(StatCollector.translateToLocal("waila.equipped"));
        for (EnumCustomModules module : ((CustomizableSCTE) iDataAccessor.getTileEntity()).getModules()) tipList.add("- " + module.getName());
    }
    if (iConfigHandler.getConfig("securitycraft.showpasswords") && iDataAccessor.getTileEntity() instanceof IPasswordProtected && ((IOwnable) iDataAccessor.getTileEntity()).getOwner().isOwner(iDataAccessor.getPlayer())) {
        String password = ((IPasswordProtected) iDataAccessor.getTileEntity()).getPassword();
        tipList.add(StatCollector.translateToLocal("waila.password") + " " + (password != null && !password.isEmpty() ? password : StatCollector.translateToLocal("waila.password.notSet")));
    }
    if (iConfigHandler.getConfig("securitycraft.showcustomname") && iDataAccessor.getTileEntity() instanceof INameable && ((INameable) iDataAccessor.getTileEntity()).canBeNamed()) {
        String name = ((INameable) iDataAccessor.getTileEntity()).getCustomName();
        tipList.add(StatCollector.translateToLocal("waila.customName") + " " + (((INameable) iDataAccessor.getTileEntity()).hasCustomName() ? name : StatCollector.translateToLocal("waila.customName.notSet")));
    }
    return tipList;
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) INameable(net.geforcemods.securitycraft.api.INameable) IOwnable(net.geforcemods.securitycraft.api.IOwnable) EnumCustomModules(net.geforcemods.securitycraft.misc.EnumCustomModules)

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