Search in sources :

Example 6 with ModuleModifier

use of com.teamwizardry.wizardry.api.spell.module.ModuleModifier in project Wizardry by TeamWizardry.

the class SpellRing method serializeNBT.

@Override
public NBTTagCompound serializeNBT() {
    NBTTagCompound compound = new NBTTagCompound();
    if (!modifiers.isEmpty()) {
        NBTTagList attribs = new NBTTagList();
        for (Map.Entry<ModuleModifier, Integer> modifier : modifiers.entrySet()) {
            NBTTagCompound modifierCompound = new NBTTagCompound();
            modifierCompound.setTag("modifier", modifier.getKey().serialize());
            modifierCompound.setInteger("count", modifier.getValue());
            attribs.appendTag(modifierCompound);
        }
        compound.setTag("modifiers", attribs);
    }
    compound.setTag("extra", informationTag);
    compound.setString("primary_color", String.valueOf(primaryColor.getRGB()));
    compound.setString("secondary_color", String.valueOf(secondaryColor.getRGB()));
    if (childRing != null)
        compound.setTag("child_ring", this.childRing.serializeNBT());
    if (module != null)
        compound.setString("module", module.getID());
    return compound;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ModuleModifier(com.teamwizardry.wizardry.api.spell.module.ModuleModifier) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 7 with ModuleModifier

use of com.teamwizardry.wizardry.api.spell.module.ModuleModifier in project Wizardry by TeamWizardry.

the class CommandWizardry method execute.

@Override
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException {
    if (args.length < 1)
        throw new WrongUsageException(getUsage(sender));
    if (args[0].equalsIgnoreCase("reload")) {
        ModuleRegistry.INSTANCE.loadUnprocessedModules();
        ModuleRegistry.INSTANCE.copyMissingModulesFromResources(CommonProxy.directory);
        ModuleRegistry.INSTANCE.processModules();
        if (server.isDedicatedServer()) {
            PacketHandler.NETWORK.sendToAll(new PacketSyncModules(ModuleRegistry.INSTANCE.modules));
        }
        notifyCommandListener(sender, this, "wizardry.command.success");
    } else if (args[0].equalsIgnoreCase("reset")) {
        notifyCommandListener(sender, this, "wizardry.command.reset");
        File moduleDirectory = new File(CommonProxy.directory, "modules");
        if (moduleDirectory.exists()) {
            File[] files = moduleDirectory.listFiles();
            if (files != null)
                for (File file : files) {
                    String name = file.getName();
                    if (!file.delete()) {
                        throw new CommandException("wizardry.command.fail", name);
                    } else {
                        notifyCommandListener(sender, this, "wizardry.command.success_delete", name);
                    }
                }
            if (!moduleDirectory.delete()) {
                throw new CommandException("wizardry.command.fail_dir_delete");
            }
        }
        if (!moduleDirectory.exists())
            if (!moduleDirectory.mkdirs()) {
                throw new CommandException("wizardry.command.fail_dir_create");
            }
        ModuleRegistry.INSTANCE.setDirectory(moduleDirectory);
        ModuleRegistry.INSTANCE.loadUnprocessedModules();
        ModuleRegistry.INSTANCE.copyMissingModulesFromResources(CommonProxy.directory);
        ModuleRegistry.INSTANCE.processModules();
        if (server.isDedicatedServer()) {
            PacketHandler.NETWORK.sendToAll(new PacketSyncModules(ModuleRegistry.INSTANCE.modules));
        }
        notifyCommandListener(sender, this, "wizardry.command.success");
    } else if (args[0].equalsIgnoreCase("listModules")) {
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " ________________________________________________\\\\");
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " | " + TextFormatting.GRAY + "Module List");
        for (Module module : ModuleRegistry.INSTANCE.modules) {
            notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + module.getID() + TextFormatting.RESET + ": " + TextFormatting.GRAY + module.getReadableName());
        }
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |________________________________________________//");
    } else if (args[0].equalsIgnoreCase("debug")) {
        if (args.length < 2)
            throw new WrongUsageException(getUsage(sender));
        Module module = ModuleRegistry.INSTANCE.getModule(args[1]);
        if (module == null) {
            notifyCommandListener(sender, this, "Module not found.");
            return;
        }
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " ________________________________________________\\\\");
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " | " + TextFormatting.GRAY + "Module " + module.getReadableName() + ":");
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Description           " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getDescription());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Item Stack            " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getItemStack().getDisplayName());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Burnout Fill          " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getBurnoutFill());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |  |_ " + TextFormatting.DARK_GREEN + "Burnout Multiplier" + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getBurnoutMultiplier());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Mana Drain           " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getManaDrain());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |  |_" + TextFormatting.DARK_GREEN + "Mana Multiplier     " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getManaMultiplier());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Power Multiplier     " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getPowerMultiplier());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Charge Up Time      " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getChargeupTime());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Cooldown Time        " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getCooldownTime());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Primary Color        " + TextFormatting.GRAY + " | " + TextFormatting.RED + module.getPrimaryColor().getRed() + TextFormatting.GRAY + ", " + TextFormatting.GREEN + module.getPrimaryColor().getGreen() + TextFormatting.GRAY + ", " + TextFormatting.BLUE + module.getPrimaryColor().getBlue());
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Secondary Color    " + TextFormatting.GRAY + " | " + TextFormatting.RED + module.getSecondaryColor().getRed() + TextFormatting.GRAY + ", " + TextFormatting.GREEN + module.getSecondaryColor().getGreen() + TextFormatting.GRAY + ", " + TextFormatting.BLUE + module.getSecondaryColor().getBlue());
        if (!module.getAttributes().isEmpty())
            notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Default AttributeRegistry");
        for (AttributeModifier attributeModifier : module.getAttributes()) notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |  |_ " + TextFormatting.GRAY + attributeModifier.toString());
        ModuleModifier[] modifierList = module.applicableModifiers();
        if (modifierList != null) {
            notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Applicable Modifiers ");
            for (ModuleModifier modifier : modifierList) notifyCommandListener(sender, this, TextFormatting.YELLOW + " |     |_ " + TextFormatting.DARK_GREEN + modifier.getID());
        }
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |________________________________________________//");
    } else {
        throw new WrongUsageException(getUsage(sender));
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) PacketSyncModules(com.teamwizardry.wizardry.common.network.PacketSyncModules) ModuleModifier(com.teamwizardry.wizardry.api.spell.module.ModuleModifier) CommandException(net.minecraft.command.CommandException) Module(com.teamwizardry.wizardry.api.spell.module.Module) AttributeModifier(com.teamwizardry.wizardry.api.spell.attribute.AttributeModifier) File(java.io.File)

Aggregations

ModuleModifier (com.teamwizardry.wizardry.api.spell.module.ModuleModifier)7 Module (com.teamwizardry.wizardry.api.spell.module.Module)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 GuiComponent (com.teamwizardry.librarianlib.features.gui.component.GuiComponent)2 AttributeModifier (com.teamwizardry.wizardry.api.spell.attribute.AttributeModifier)2 LibrarianLib (com.teamwizardry.librarianlib.core.LibrarianLib)1 Easing (com.teamwizardry.librarianlib.features.animator.Easing)1 Keyframe (com.teamwizardry.librarianlib.features.animator.animations.Keyframe)1 KeyframeAnimation (com.teamwizardry.librarianlib.features.animator.animations.KeyframeAnimation)1 ScheduledEventAnimation (com.teamwizardry.librarianlib.features.animator.animations.ScheduledEventAnimation)1 EnumMouseButton (com.teamwizardry.librarianlib.features.gui.EnumMouseButton)1 GuiComponentEvents (com.teamwizardry.librarianlib.features.gui.component.GuiComponentEvents)1 ComponentList (com.teamwizardry.librarianlib.features.gui.components.ComponentList)1 ComponentRect (com.teamwizardry.librarianlib.features.gui.components.ComponentRect)1 ComponentSprite (com.teamwizardry.librarianlib.features.gui.components.ComponentSprite)1 ComponentText (com.teamwizardry.librarianlib.features.gui.components.ComponentText)1 Vec2d (com.teamwizardry.librarianlib.features.math.Vec2d)1 Sprite (com.teamwizardry.librarianlib.features.sprite.Sprite)1 Wizardry (com.teamwizardry.wizardry.Wizardry)1 Operation (com.teamwizardry.wizardry.api.spell.attribute.Operation)1