Search in sources :

Example 6 with CustomizableSCTE

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

the class GuiSCManual method updateRecipeAndIcons.

private void updateRecipeAndIcons() {
    if (this.currentPage < 0) {
        recipe = null;
        this.hoverCheckers.clear();
        return;
    }
    this.hoverCheckers.clear();
    if (mod_SecurityCraft.instance.manualPages.get(currentPage).hasCustomRecipe()) {
        this.recipe = mod_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() == mod_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() == mod_SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
                    this.recipe = this.toItemStackArray(recipe.recipeItems);
                    break;
                }
            }
            this.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 {
        String name = mod_SecurityCraft.instance.manualPages.get(currentPage).getItemName();
        //make first character lower case and remove spaces
        name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length()).replace(" ", "");
        hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, I18n.translateToLocal("gui.scManual.recipe." + name)));
    }
    Item item = mod_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) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 29, (k + 29) + 16, 20, I18n.translateToLocal("gui.scManual.ownableBlock")));
        }
        if (te instanceof IPasswordProtected) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 55, (k + 55) + 16, 20, I18n.translateToLocal("gui.scManual.passwordProtectedBlock")));
        }
        if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView()) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 81, (k + 81) + 16, 20, I18n.translateToLocal("gui.scManual.viewActivatedBlock")));
        }
        if (itemBlock instanceof IExplosive) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 107, (k + 107) + 16, 20, I18n.translateToLocal("gui.scManual.explosiveBlock")));
        }
        if (te instanceof CustomizableSCTE) {
            this.hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 213, (k + 213) + 16, 20, I18n.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 7 with CustomizableSCTE

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

the class ForgeEventHandler method onBlockBroken.

@SubscribeEvent
public void onBlockBroken(BreakEvent event) {
    if (!event.getWorld().isRemote) {
        if (event.getWorld().getTileEntity(event.getPos()) != null && event.getWorld().getTileEntity(event.getPos()) instanceof CustomizableSCTE) {
            CustomizableSCTE te = (CustomizableSCTE) event.getWorld().getTileEntity(event.getPos());
            for (int i = 0; i < te.getNumberOfCustomizableOptions(); i++) {
                if (te.itemStacks[i] != null) {
                    ItemStack stack = te.itemStacks[i];
                    EntityItem item = new EntityItem(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), stack);
                    event.getWorld().spawnEntityInWorld(item);
                    te.onModuleRemoved(stack, ((ItemModule) stack.getItem()).getModule());
                    te.createLinkedBlockAction(EnumLinkedAction.MODULE_REMOVED, new Object[] { stack, ((ItemModule) stack.getItem()).getModule() }, te);
                }
            }
        }
    }
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with CustomizableSCTE

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

the class BlockUtils method setBlockProperty.

public static void setBlockProperty(World par1World, int par2, int par3, int par4, PropertyBool property, boolean value) {
    ItemStack[] modules = null;
    if (par1World.getTileEntity(new BlockPos(par2, par3, par4)) instanceof CustomizableSCTE) {
        modules = ((CustomizableSCTE) par1World.getTileEntity(toPos(par2, par3, par4))).itemStacks;
    }
    TileEntity tileEntity = par1World.getTileEntity(toPos(par2, par3, par4));
    par1World.setBlockState(new BlockPos(par2, par3, par4), par1World.getBlockState(new BlockPos(par2, par3, par4)).withProperty(property, value));
    par1World.setTileEntity(new BlockPos(par2, par3, par4), tileEntity);
    if (modules != null) {
        ((CustomizableSCTE) par1World.getTileEntity(toPos(par2, par3, par4))).itemStacks = modules;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 9 with CustomizableSCTE

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

the class BlockUtils method setBlockProperty.

public static void setBlockProperty(World par1World, BlockPos pos, PropertyBool property, boolean value, boolean retainOldTileEntity) {
    if (retainOldTileEntity) {
        ItemStack[] modules = null;
        ItemStack[] inventory = null;
        int[] times = new int[4];
        String password = "";
        Owner owner = null;
        int cooldown = -1;
        if (par1World.getTileEntity(pos) instanceof CustomizableSCTE) {
            modules = ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks;
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
            inventory = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks;
            times[0] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime;
            times[1] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime;
            times[2] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime;
            times[3] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime;
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityOwnable && ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner() != null) {
            owner = ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypad && ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword() != null) {
            password = ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace && ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword() != null) {
            password = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityKeypadChest && ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword() != null) {
            password = ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword();
        }
        if (par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown() != 0) {
            cooldown = ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown();
        }
        TileEntity tileEntity = par1World.getTileEntity(pos);
        par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
        par1World.setTileEntity(pos, tileEntity);
        if (modules != null) {
            ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks = modules;
        }
        if (inventory != null && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks = inventory;
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime = times[0];
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime = times[1];
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime = times[2];
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime = times[3];
        }
        if (owner != null) {
            ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner().set(owner);
        }
        if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypad) {
            ((TileEntityKeypad) par1World.getTileEntity(pos)).setPassword(password);
        }
        if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
            ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).setPassword(password);
        }
        if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadChest) {
            ((TileEntityKeypadChest) par1World.getTileEntity(pos)).setPassword(password);
        }
        if (cooldown != -1 && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar) {
            ((TileEntityPortableRadar) par1World.getTileEntity(pos)).setAttackCooldown(cooldown);
        }
    } else {
        par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
    }
}
Also used : Owner(net.geforcemods.securitycraft.api.Owner) TileEntityKeypadFurnace(net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace) TileEntity(net.minecraft.tileentity.TileEntity) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) TileEntityKeypadChest(net.geforcemods.securitycraft.tileentity.TileEntityKeypadChest) TileEntityPortableRadar(net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar) ItemStack(net.minecraft.item.ItemStack) TileEntityOwnable(net.geforcemods.securitycraft.tileentity.TileEntityOwnable) TileEntityKeypad(net.geforcemods.securitycraft.tileentity.TileEntityKeypad)

Example 10 with CustomizableSCTE

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

the class ModuleUtils method getPlayersFromModule.

public static List<String> getPlayersFromModule(World par1World, BlockPos pos, EnumCustomModules module) {
    List<String> list = new ArrayList<String>();
    CustomizableSCTE te = (CustomizableSCTE) par1World.getTileEntity(pos);
    if (te.hasModule(module)) {
        ItemStack item = te.getModule(module);
        for (int i = 1; i <= 10; i++) {
            if (item.getTagCompound() != null && item.getTagCompound().getString("Player" + i) != null && !item.getTagCompound().getString("Player" + i).isEmpty()) {
                list.add(item.getTagCompound().getString("Player" + i).toLowerCase());
            }
        }
    }
    return list;
}
Also used : CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

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