use of com.fastasyncworldedit.core.util.CleanTextureUtil 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;
}
use of com.fastasyncworldedit.core.util.CleanTextureUtil 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, " ")));
}
}
Aggregations