Search in sources :

Example 1 with RandomTextureUtil

use of com.fastasyncworldedit.core.util.RandomTextureUtil in project FastAsyncWorldEdit by IntellectualSites.

the class Fawe method getCachedTextureUtil.

public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
    // TODO NOT IMPLEMENTED - optimize this by caching the default true/0/100 texture util
    TextureUtil tu = getTextureUtil();
    try {
        tu = min == 0 && max == 100 ? tu : new CleanTextureUtil(tu, min, max);
        tu = randomize ? new RandomTextureUtil(tu) : new CachedTextureUtil(tu);
    } catch (FileNotFoundException neverHappens) {
        neverHappens.printStackTrace();
    }
    return tu;
}
Also used : CleanTextureUtil(com.fastasyncworldedit.core.util.CleanTextureUtil) TextureUtil(com.fastasyncworldedit.core.util.TextureUtil) RandomTextureUtil(com.fastasyncworldedit.core.util.RandomTextureUtil) CachedTextureUtil(com.fastasyncworldedit.core.util.CachedTextureUtil) CachedTextureUtil(com.fastasyncworldedit.core.util.CachedTextureUtil) CleanTextureUtil(com.fastasyncworldedit.core.util.CleanTextureUtil) FileNotFoundException(java.io.FileNotFoundException) RandomTextureUtil(com.fastasyncworldedit.core.util.RandomTextureUtil)

Example 2 with RandomTextureUtil

use of com.fastasyncworldedit.core.util.RandomTextureUtil in project FastAsyncWorldEdit by IntellectualSites.

the class GeneralCommands method gtexture.

// FAWE start
@Command(name = "/gtexture", aliases = { "gtexture" }, descFooter = "The global destination mask applies to all edits you do and masks based on the destination blocks (i.e., the blocks in the world).", desc = "Set the global mask")
@CommandPermissions("worldedit.global-texture")
public void gtexture(Actor actor, World worldArg, LocalSession session, EditSession editSession, @Arg(name = "context", desc = "InjectedValueAccess", def = "") List<String> arguments) throws WorldEditException, FileNotFoundException {
    // TODO NOT IMPLEMENTED convert this to an ArgumentConverter
    if (arguments.isEmpty()) {
        session.setTextureUtil(null);
        actor.print(Caption.of("fawe.worldedit.general.texture.disabled"));
    } else {
        String arg = arguments.get(0);
        String argLower = arg.toLowerCase(Locale.ROOT);
        TextureUtil util = Fawe.instance().getTextureUtil();
        int randomIndex = 1;
        boolean checkRandomization = true;
        if (arguments.size() >= 2 && MathMan.isInteger(arguments.get(0)) && MathMan.isInteger(arguments.get(1))) {
            // complexity
            int min = Integer.parseInt(arguments.get(0));
            int max = Integer.parseInt(arguments.get(1));
            if (min < 0 || max > 100) {
                throw new InputParseException(Caption.of("fawe.error.too-simple"));
            }
            if (min != 0 || max != 100) {
                util = new CleanTextureUtil(util, min, max);
            }
            randomIndex = 2;
        } else if (arguments.size() == 1 && argLower.equals("true") || argLower.equals("false")) {
            if (argLower.equals("true")) {
                util = new RandomTextureUtil(util);
            }
            checkRandomization = false;
        } else {
            if (argLower.equals("#copy") || argLower.equals("#clipboard")) {
                Clipboard clipboard = session.getClipboard().getClipboard();
                util = TextureUtil.fromClipboard(clipboard);
            } else if (argLower.equals("*") || argLower.equals("true")) {
                util = Fawe.instance().getTextureUtil();
            } else {
                ParserContext parserContext = new ParserContext();
                parserContext.setActor(actor);
                parserContext.setWorld(worldArg);
                parserContext.setSession(session);
                parserContext.setExtent(editSession);
                Mask mask = worldEdit.getMaskFactory().parseFromInput(arg, parserContext);
                util = TextureUtil.fromMask(mask);
            }
        }
        if (checkRandomization) {
            if (arguments.size() > randomIndex) {
                boolean random = Boolean.parseBoolean(arguments.get(randomIndex));
                if (random) {
                    util = new RandomTextureUtil(util);
                }
            }
        }
        if (!(util instanceof CachedTextureUtil)) {
            util = new CachedTextureUtil(util);
        }
        session.setTextureUtil(util);
        actor.print(Caption.of("fawe.worldedit.general.texture.set", StringMan.join(arguments, " ")));
    }
}
Also used : InputParseException(com.sk89q.worldedit.extension.input.InputParseException) RandomTextureUtil(com.fastasyncworldedit.core.util.RandomTextureUtil) CachedTextureUtil(com.fastasyncworldedit.core.util.CachedTextureUtil) CleanTextureUtil(com.fastasyncworldedit.core.util.CleanTextureUtil) TextureUtil(com.fastasyncworldedit.core.util.TextureUtil) CachedTextureUtil(com.fastasyncworldedit.core.util.CachedTextureUtil) CleanTextureUtil(com.fastasyncworldedit.core.util.CleanTextureUtil) Mask(com.sk89q.worldedit.function.mask.Mask) Clipboard(com.sk89q.worldedit.extent.clipboard.Clipboard) ParserContext(com.sk89q.worldedit.extension.input.ParserContext) RandomTextureUtil(com.fastasyncworldedit.core.util.RandomTextureUtil) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

CachedTextureUtil (com.fastasyncworldedit.core.util.CachedTextureUtil)2 CleanTextureUtil (com.fastasyncworldedit.core.util.CleanTextureUtil)2 RandomTextureUtil (com.fastasyncworldedit.core.util.RandomTextureUtil)2 TextureUtil (com.fastasyncworldedit.core.util.TextureUtil)2 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 InputParseException (com.sk89q.worldedit.extension.input.InputParseException)1 ParserContext (com.sk89q.worldedit.extension.input.ParserContext)1 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)1 Mask (com.sk89q.worldedit.function.mask.Mask)1 FileNotFoundException (java.io.FileNotFoundException)1 Command (org.enginehub.piston.annotation.Command)1