Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-07 12:00:07 +01:00
Renaming and cleanup and a new method.
Dieser Commit ist enthalten in:
Ursprung
0feebac44b
Commit
4a40c7d99c
@ -47,10 +47,12 @@ import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.DoubleChestInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
@ -154,6 +156,11 @@ public class BukkitWorld extends AbstractWorld {
|
||||
return getWorld().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getStoragePath() {
|
||||
return getWorld().getWorldFolder().toPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightLevel(BlockVector3 pt) {
|
||||
return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel();
|
||||
@ -239,11 +246,11 @@ public class BukkitWorld extends AbstractWorld {
|
||||
return false;
|
||||
}
|
||||
BlockState state = block.getState();
|
||||
if (!(state instanceof org.bukkit.inventory.InventoryHolder)) {
|
||||
if (!(state instanceof InventoryHolder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state;
|
||||
InventoryHolder chest = (InventoryHolder) state;
|
||||
Inventory inven = chest.getInventory();
|
||||
if (chest instanceof Chest) {
|
||||
inven = getBlockInventory((Chest) chest);
|
||||
|
@ -17,6 +17,7 @@ import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -36,24 +37,18 @@ import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The FaweAPI class offers a few useful functions.<br>
|
||||
|
@ -1,12 +1,17 @@
|
||||
package com.boydti.fawe;
|
||||
|
||||
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FaweCache {
|
||||
public static final IterableThreadLocal<int[]> BLOCK_TO_PALETTE = new IterableThreadLocal<int[]>() {
|
||||
@ -115,7 +120,7 @@ public class FaweCache {
|
||||
} else if (value instanceof String) {
|
||||
return asTag((String) value);
|
||||
} else if (value instanceof Map) {
|
||||
return asTag((Map) value);
|
||||
return asTag((Map<String, Object>) value);
|
||||
} else if (value instanceof Collection) {
|
||||
return asTag((Collection) value);
|
||||
} else if (value instanceof Object[]) {
|
||||
@ -153,7 +158,7 @@ public class FaweCache {
|
||||
}
|
||||
|
||||
public static ListTag asTag(Object... values) {
|
||||
Class clazz = null;
|
||||
Class<? extends Tag> clazz = null;
|
||||
List<Tag> list = new ArrayList<>(values.length);
|
||||
for (Object value : values) {
|
||||
Tag tag = asTag(value);
|
||||
@ -167,7 +172,7 @@ public class FaweCache {
|
||||
}
|
||||
|
||||
public static ListTag asTag(Collection values) {
|
||||
Class clazz = null;
|
||||
Class<? extends Tag> clazz = null;
|
||||
List<Tag> list = new ArrayList<>(values.size());
|
||||
for (Object value : values) {
|
||||
Tag tag = asTag(value);
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.boydti.fawe.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.jnbt.anvil.*;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAClipboard;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFile;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFilter;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAQueue;
|
||||
import com.boydti.fawe.jnbt.anvil.filters.*;
|
||||
import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory;
|
||||
import com.boydti.fawe.jnbt.anvil.history.NullAnvilHistory;
|
||||
@ -14,17 +16,18 @@ import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal4;
|
||||
import com.boydti.fawe.object.changeset.AnvilHistory;
|
||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
||||
import com.boydti.fawe.object.mask.FaweBlockMatcher;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
@ -36,17 +39,12 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Command(aliases = {"/anvil"}, desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)")
|
||||
@Command(aliases = {"/anvil"},
|
||||
desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)")
|
||||
public class AnvilCommands {
|
||||
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
@ -54,7 +52,6 @@ public class AnvilCommands {
|
||||
*/
|
||||
public AnvilCommands(WorldEdit worldEdit) {
|
||||
checkNotNull(worldEdit);
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,19 +167,20 @@ public class AnvilCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.remapall")
|
||||
public void remapall(Player player, String folder) throws WorldEditException {
|
||||
ClipboardRemapper mapper;
|
||||
ClipboardRemapper.RemapPlatform from;
|
||||
ClipboardRemapper.RemapPlatform to;
|
||||
from = ClipboardRemapper.RemapPlatform.PE;
|
||||
to = ClipboardRemapper.RemapPlatform.PC;
|
||||
RemapFilter filter = new RemapFilter(from, to);
|
||||
RemapFilter result = runWithWorld(player, folder, filter, true);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = {"deleteallunvisited", "delunvisited" },
|
||||
aliases = {"deleteallunvisited", "delunvisited"},
|
||||
usage = "<folder> <age-ticks> [file-age=60000]",
|
||||
desc = "Delete all chunks which haven't been occupied",
|
||||
help = "Delete all chunks which haven't been occupied for `age-ticks` (20t = 1s) and \n" +
|
||||
@ -196,11 +194,13 @@ public class AnvilCommands {
|
||||
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Optional("60000") int fileDurationMillis) throws WorldEditException {
|
||||
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||
DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"deleteallunclaimed", "delallunclaimed" },
|
||||
aliases = {"deleteallunclaimed", "delallunclaimed"},
|
||||
usage = "<age-ticks> [file-age=60000]",
|
||||
desc = "(Supports: WG, P2, GP) Delete all chunks which haven't been occupied AND claimed",
|
||||
help = "(Supports: WG, P2, GP) Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n" +
|
||||
@ -211,12 +211,17 @@ public class AnvilCommands {
|
||||
max = 3
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.deleteallunclaimed")
|
||||
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException {
|
||||
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch(
|
||||
'd') boolean debug) throws WorldEditException {
|
||||
String folder = player.getWorld().getName();
|
||||
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||
if (debug) filter.enableDebug();
|
||||
if (debug) {
|
||||
filter.enableDebug();
|
||||
}
|
||||
DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -231,15 +236,20 @@ public class AnvilCommands {
|
||||
max = 3
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.deleteunclaimed")
|
||||
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException {
|
||||
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Optional(
|
||||
"60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException {
|
||||
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||
if (debug) filter.enableDebug();
|
||||
if (debug) {
|
||||
filter.enableDebug();
|
||||
}
|
||||
DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"deletealloldregions", "deloldreg" },
|
||||
aliases = {"deletealloldregions", "deloldreg"},
|
||||
usage = "<folder> <time>",
|
||||
desc = "Delete regions which haven't been accessed in a certain amount of time",
|
||||
help = "Delete regions which haven't been accessed in a certain amount of time\n" +
|
||||
@ -254,11 +264,13 @@ public class AnvilCommands {
|
||||
long duration = MainUtil.timeToSec(time) * 1000L;
|
||||
DeleteOldFilter filter = new DeleteOldFilter(duration);
|
||||
DeleteOldFilter result = runWithWorld(player, folder, filter, true);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"trimallplots", },
|
||||
aliases = {"trimallplots",},
|
||||
desc = "Trim chunks in a Plot World",
|
||||
help = "Trim chunks in a Plot World\n" +
|
||||
"Unclaimed chunks will be deleted\n" +
|
||||
@ -274,40 +286,48 @@ public class AnvilCommands {
|
||||
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
|
||||
MCAQueue queue = new MCAQueue(defaultQueue);
|
||||
PlotTrimFilter result = queue.filterWorld(filter);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"deletebiomechunks", },
|
||||
aliases = {"deletebiomechunks",},
|
||||
desc = "Delete chunks matching a specific biome"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.trimallair")
|
||||
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch('u') boolean unsafe) {
|
||||
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
|
||||
DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"trimallair", },
|
||||
aliases = {"trimallair",},
|
||||
desc = "Trim all air in the world"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.trimallair")
|
||||
public void trimAllAir(Player player, String folder, @Switch('u') boolean unsafe) throws WorldEditException {
|
||||
TrimAirFilter filter = new TrimAirFilter();
|
||||
TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"debugfixroads", },
|
||||
aliases = {"debugfixroads",},
|
||||
desc = "debug - do not use"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.debugfixroads")
|
||||
public void debugfixroads(Player player, String folder) throws WorldEditException {
|
||||
DebugFixP2Roads filter = new DebugFixP2Roads();
|
||||
DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -319,7 +339,8 @@ public class AnvilCommands {
|
||||
max = 4
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.replaceall")
|
||||
public void replaceAllPattern(Player player, String folder, @Optional String from, final Pattern to, @Switch('d') boolean useData, @Switch('m') boolean useMap) throws WorldEditException {
|
||||
public void replaceAllPattern(Player player, String folder, @Optional String from, final Pattern to, @Switch('d') boolean useData, @Switch(
|
||||
'm') boolean useMap) throws WorldEditException {
|
||||
// MCAFilterCounter filter;
|
||||
// if (useMap) {
|
||||
// if (to instanceof RandomPattern) {
|
||||
@ -341,7 +362,8 @@ public class AnvilCommands {
|
||||
// MCAFilterCounter result = runWithWorld(player, folder, filter, true);
|
||||
// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
//
|
||||
|
||||
//
|
||||
@Command(
|
||||
aliases = {"countall"},
|
||||
usage = "<folder> [hasSky] <id>",
|
||||
@ -414,7 +436,9 @@ public class AnvilCommands {
|
||||
}
|
||||
};
|
||||
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
if (result != null) {
|
||||
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -441,7 +465,8 @@ public class AnvilCommands {
|
||||
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||
// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal()));
|
||||
}
|
||||
//
|
||||
|
||||
//
|
||||
@Command(
|
||||
aliases = {"distr"},
|
||||
desc = "Replace all blocks in the selection with another"
|
||||
@ -518,14 +543,16 @@ public class AnvilCommands {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
//
|
||||
|
||||
//
|
||||
@Command(
|
||||
aliases = {"replace", "r"},
|
||||
usage = "[from-block] <to-block>",
|
||||
desc = "Replace all blocks in the selection with another"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.replace")
|
||||
public void replace(Player player, EditSession editSession, @Selection Region selection, @Optional String from, String to, @Switch('d') boolean useData) throws WorldEditException {
|
||||
public void replace(Player player, EditSession editSession, @Selection Region selection, @Optional String from, String to, @Switch(
|
||||
'd') boolean useData) throws WorldEditException {
|
||||
// final FaweBlockMatcher matchFrom;
|
||||
// if (from == null) {
|
||||
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
||||
@ -539,7 +566,8 @@ public class AnvilCommands {
|
||||
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
// }
|
||||
}
|
||||
//
|
||||
|
||||
//
|
||||
@Command(
|
||||
aliases = {"replacepattern", "preplace", "rp"},
|
||||
usage = "[from-mask] <to-pattern>",
|
||||
@ -547,7 +575,8 @@ public class AnvilCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.replace")
|
||||
// Player player, String folder, @Optional String from, final Pattern to, @Switch('d') boolean useData, @Switch('m') boolean useMap
|
||||
public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Optional String from, final Pattern to, @Switch('d') boolean useData, @Switch('m') boolean useMap) throws WorldEditException {
|
||||
public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Optional String from, final Pattern to, @Switch(
|
||||
'd') boolean useData, @Switch('m') boolean useMap) throws WorldEditException {
|
||||
// MCAFilterCounter filter;
|
||||
// if (useMap) {
|
||||
// if (to instanceof RandomPattern) {
|
||||
@ -638,7 +667,7 @@ public class AnvilCommands {
|
||||
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.pastechunks")
|
||||
public void paste(Player player, LocalSession session, EditSession editSession, @Switch('c') boolean alignChunk) throws WorldEditException, IOException {
|
||||
public void paste(Player player, LocalSession session, EditSession editSession, @Switch('c') boolean alignChunk) throws WorldEditException {
|
||||
// FawePlayer fp = FawePlayer.wrap(player);
|
||||
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
|
||||
// if (clipboard == null) {
|
||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.config.Commands;
|
||||
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
@ -13,6 +14,7 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.MethodCommands;
|
||||
import com.sk89q.worldedit.util.command.SimpleDispatcher;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class CFICommand extends MethodCommands {
|
||||
@ -29,9 +31,6 @@ public class CFICommand extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"cfi", "createfromimage"},
|
||||
usage = "",
|
||||
min = 0,
|
||||
max = -1,
|
||||
anyFlags = true,
|
||||
desc = "Start CreateFromImage"
|
||||
)
|
||||
@ -51,49 +50,41 @@ public class CFICommand extends MethodCommands {
|
||||
|
||||
private void dispatch(FawePlayer fp, CFICommands.CFISettings settings, CommandContext context) throws CommandException {
|
||||
if (!settings.hasGenerator()) {
|
||||
switch (context.argsLength()) {
|
||||
case 0: {
|
||||
String hmCmd = child.alias() + " ";
|
||||
if (settings.image == null) {
|
||||
hmCmd += "image";
|
||||
} else {
|
||||
hmCmd = Commands.getAlias(CFICommands.class, "heightmap") + " " + settings.imageArg;
|
||||
}
|
||||
child.msg("What do you want to use as the base?").newline()
|
||||
.text("&7[&aHeightMap&7]").cmdTip(hmCmd).text(" - A heightmap like ").text("&7[&athis&7]").linkTip("http://i.imgur.com/qCd30MR.jpg")
|
||||
.newline()
|
||||
.text("&7[&aEmpty&7]").cmdTip(child.alias() + " empty").text("- An empty map of a specific size")
|
||||
.send(fp);
|
||||
break;
|
||||
if (context.argsLength() == 0) {
|
||||
String hmCmd = child.alias() + " ";
|
||||
if (settings.image == null) {
|
||||
hmCmd += "image";
|
||||
} else {
|
||||
hmCmd = Commands.getAlias(CFICommands.class, "heightmap") + " " + settings.imageArg;
|
||||
}
|
||||
default: {
|
||||
String remaining = context.getJoinedStrings(0);
|
||||
if (!dispatcher.contains(context.getString(0))) {
|
||||
switch (context.argsLength()) {
|
||||
case 1: {
|
||||
String cmd = Commands.getAlias(CFICommands.class, "heightmap") + " " + context.getJoinedStrings(0);
|
||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||
return;
|
||||
}
|
||||
case 2: {
|
||||
String cmd = Commands.getAlias(CFICommands.class, "empty") + " " + context.getJoinedStrings(0);
|
||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||
return;
|
||||
}
|
||||
child.msg("What do you want to use as the base?").newline()
|
||||
.text("&7[&aHeightMap&7]").cmdTip(hmCmd).text(" - A heightmap like ").text("&7[&athis&7]").linkTip("http://i.imgur.com/qCd30MR.jpg")
|
||||
.newline()
|
||||
.text("&7[&aEmpty&7]").cmdTip(child.alias() + " empty").text("- An empty map of a specific size")
|
||||
.send(fp);
|
||||
} else {
|
||||
String remaining = context.getJoinedStrings(0);
|
||||
if (!dispatcher.contains(context.getString(0))) {
|
||||
switch (context.argsLength()) {
|
||||
case 1: {
|
||||
String cmd = Commands.getAlias(CFICommands.class, "heightmap") + " " + context.getJoinedStrings(0);
|
||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||
return;
|
||||
}
|
||||
case 2:
|
||||
String cmd = Commands.getAlias(CFICommands.class, "empty") + " " + context.getJoinedStrings(0);
|
||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||
return;
|
||||
}
|
||||
dispatcher.call(remaining, context.getLocals(), new String[0]);
|
||||
}
|
||||
dispatcher.call(remaining, context.getLocals(), new String[0]);
|
||||
}
|
||||
} else {
|
||||
switch (context.argsLength()) {
|
||||
case 0:
|
||||
settings.setCategory("");
|
||||
child.mainMenu(fp);
|
||||
break;
|
||||
default:
|
||||
dispatcher.call(context.getJoinedStrings(0), context.getLocals(), new String[0]);
|
||||
break;
|
||||
if (context.argsLength() == 0) {
|
||||
settings.setCategory("");
|
||||
child.mainMenu(fp);
|
||||
} else {
|
||||
dispatcher.call(context.getJoinedStrings(0), context.getLocals(), new String[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
|
||||
import static com.boydti.fawe.util.image.ImageUtil.load;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
@ -70,10 +72,8 @@ import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.boydti.fawe.util.image.ImageUtil.load;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Command(aliases = {"/cfi"}, desc = "Create a world from images: [More Info](https://git.io/v5iDy)")
|
||||
public class CFICommands extends MethodCommands {
|
||||
@ -87,7 +87,7 @@ public class CFICommands extends MethodCommands {
|
||||
*/
|
||||
public CFICommands(WorldEdit worldEdit, Dispatcher dispatcher) {
|
||||
super(worldEdit);
|
||||
this.dispathcer= dispatcher;
|
||||
this.dispathcer = dispatcher;
|
||||
}
|
||||
|
||||
public static File getFolder(String worldName) {
|
||||
@ -106,10 +106,7 @@ public class CFICommands extends MethodCommands {
|
||||
public void heightmap(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional("1") double yscale) throws ParameterException {
|
||||
if (yscale != 0) {
|
||||
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
|
||||
int[] table = new int[256];
|
||||
for (int i = 0; i < table.length; i++) {
|
||||
table[i] = Math.min(255, (int) (i * yscale));
|
||||
}
|
||||
int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale))).toArray();
|
||||
for (int i = 0; i < raw.length; i++) {
|
||||
int color = raw[i];
|
||||
int red = table[(color >> 16) & 0xFF];
|
||||
@ -154,15 +151,15 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Info about using brushes with CFI"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void brush(FawePlayer fp) throws ParameterException{
|
||||
public void brush(FawePlayer fp) throws ParameterException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
settings.popMessages(fp);
|
||||
Message msg;
|
||||
if (settings.getGenerator().getImageViewer() != null) {
|
||||
msg = msg("CFI supports using brushes during creation").newline()
|
||||
.text(" - Place the map on a wall of item frames").newline()
|
||||
.text(" - Use any WorldEdit brush on the item frames").newline()
|
||||
.text(" - Example: ").text("Video").linkTip("https://goo.gl/PK4DMG").newline();
|
||||
.text(" - Place the map on a wall of item frames").newline()
|
||||
.text(" - Use any WorldEdit brush on the item frames").newline()
|
||||
.text(" - Example: ").text("Video").linkTip("https://goo.gl/PK4DMG").newline();
|
||||
} else {
|
||||
msg = msg("This is not supported with your platform/version").newline();
|
||||
}
|
||||
@ -175,14 +172,13 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Cancel creation"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void cancel(FawePlayer fp) throws ParameterException, IOException {
|
||||
public void cancel(FawePlayer fp) {
|
||||
getSettings(fp).remove();
|
||||
fp.sendMessage("Cancelled!");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"done", "create"},
|
||||
usage = "",
|
||||
desc = "Create the world"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
@ -190,27 +186,24 @@ public class CFICommands extends MethodCommands {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
HeightMapMCAGenerator generator = settings.getGenerator();
|
||||
|
||||
Function<File, Boolean> function = new Function<File, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(File folder) {
|
||||
if (folder != null) {
|
||||
try {
|
||||
generator.setFolder(folder);
|
||||
fp.sendMessage("Generating " + folder);
|
||||
generator.generate();
|
||||
generator.setPacketViewer(null);
|
||||
generator.setImageViewer(null);
|
||||
settings.remove();
|
||||
fp.sendMessage("Done!");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
fp.sendMessage("Unable to generate world... (see console)?");
|
||||
Function<File, Boolean> function = folder -> {
|
||||
if (folder != null) {
|
||||
try {
|
||||
generator.setFolder(folder);
|
||||
fp.sendMessage("Generating " + folder);
|
||||
generator.generate();
|
||||
generator.setPacketViewer(null);
|
||||
generator.setImageViewer(null);
|
||||
settings.remove();
|
||||
fp.sendMessage("Done!");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
fp.sendMessage("Unable to generate world... (see console)?");
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
try {
|
||||
@ -245,11 +238,16 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Set the floor and main block"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void column(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
public void column(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException {
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
if (image != null) gen.setColumn(load(image), pattern, !disableWhiteOnly);
|
||||
else if (mask != null) gen.setColumn(mask, pattern);
|
||||
else gen.setColumn(pattern);
|
||||
if (image != null) {
|
||||
gen.setColumn(load(image), pattern, !disableWhiteOnly);
|
||||
} else if (mask != null) {
|
||||
gen.setColumn(mask, pattern);
|
||||
} else {
|
||||
gen.setColumn(pattern);
|
||||
}
|
||||
fp.sendMessage("Set column!");
|
||||
assertSettings(fp).resetComponent();
|
||||
component(fp);
|
||||
@ -261,18 +259,24 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Set the floor (default: grass)"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void floorCmd(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
public void floorCmd(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException {
|
||||
floor(fp, pattern, image, mask, disableWhiteOnly);
|
||||
fp.sendMessage("Set floor!");
|
||||
assertSettings(fp).resetComponent();
|
||||
component(fp);
|
||||
}
|
||||
|
||||
private void floor(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException {
|
||||
private void floor(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException {
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
if (image != null) gen.setFloor(load(image), pattern, !disableWhiteOnly);
|
||||
else if (mask != null) gen.setFloor(mask, pattern);
|
||||
else gen.setFloor(pattern);
|
||||
if (image != null) {
|
||||
gen.setFloor(load(image), pattern, !disableWhiteOnly);
|
||||
} else if (mask != null) {
|
||||
gen.setFloor(mask, pattern);
|
||||
} else {
|
||||
gen.setFloor(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -281,18 +285,24 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Set the main block (default: stone)"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void mainCmd(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
public void mainCmd(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException {
|
||||
main(fp, pattern, image, mask, disableWhiteOnly);
|
||||
fp.sendMessage("Set main!");
|
||||
assertSettings(fp).resetComponent();
|
||||
component(fp);
|
||||
}
|
||||
|
||||
public void main(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
public void main(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException {
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
if (image != null) gen.setMain(load(image), pattern, !disableWhiteOnly);
|
||||
else if (mask != null) gen.setMain(mask, pattern);
|
||||
else gen.setMain(pattern);
|
||||
if (image != null) {
|
||||
gen.setMain(load(image), pattern, !disableWhiteOnly);
|
||||
} else if (mask != null) {
|
||||
gen.setMain(mask, pattern);
|
||||
} else {
|
||||
gen.setMain(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -303,11 +313,16 @@ public class CFICommands extends MethodCommands {
|
||||
"e.g. Tallgrass"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void overlay(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
public void overlay(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException {
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
if (image != null) gen.setOverlay(load(image), pattern, !disableWhiteOnly);
|
||||
else if (mask != null) gen.setOverlay(mask, pattern);
|
||||
else gen.setOverlay(pattern);
|
||||
if (image != null) {
|
||||
gen.setOverlay(load(image), pattern, !disableWhiteOnly);
|
||||
} else if (mask != null) {
|
||||
gen.setOverlay(mask, pattern);
|
||||
} else {
|
||||
gen.setOverlay(pattern);
|
||||
}
|
||||
fp.sendMessage("Set overlay!");
|
||||
component(fp);
|
||||
}
|
||||
@ -322,16 +337,21 @@ public class CFICommands extends MethodCommands {
|
||||
" - A good value for radius and iterations would be 1 8."
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void smoothCmd(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
public void smoothCmd(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException {
|
||||
smooth(fp, radius, iterations, image, mask, disableWhiteOnly);
|
||||
assertSettings(fp).resetComponent();
|
||||
component(fp);
|
||||
}
|
||||
|
||||
private void smooth(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
private void smooth(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException {
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
if (image != null) gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
|
||||
else gen.smooth(mask, radius, iterations);
|
||||
if (image != null) {
|
||||
gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
|
||||
} else {
|
||||
gen.smooth(mask, radius, iterations);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -340,7 +360,7 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Create some snow"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void snow(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
public void snow(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException {
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, mask, disableWhiteOnly);
|
||||
main(fp, BlockTypes.SNOW_BLOCK, image, mask, disableWhiteOnly);
|
||||
@ -360,7 +380,7 @@ public class CFICommands extends MethodCommands {
|
||||
"Below 50 will prefer to color with blocks"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void biomepriority(FawePlayer fp, int value) throws ParameterException{
|
||||
public void biomepriority(FawePlayer fp, int value) throws ParameterException {
|
||||
assertSettings(fp).getGenerator().setBiomePriority(value);
|
||||
coloring(fp);
|
||||
}
|
||||
@ -377,16 +397,16 @@ public class CFICommands extends MethodCommands {
|
||||
public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Optional String arg) throws ParameterException, EmptyClipboardException, InputParseException, FileNotFoundException {
|
||||
if (arg == null) {
|
||||
msg("What blocks do you want to color with?").newline()
|
||||
.text("&7[&aAll&7]").cmdTip(alias() + " PaletteBlocks *").text(" - All available blocks")
|
||||
.newline()
|
||||
.text("&7[&aClipboard&7]").cmdTip(alias() + " PaletteBlocks #clipboard").text(" - The blocks in your clipboard")
|
||||
.newline()
|
||||
.text("&7[&aList&7]").suggestTip(alias() + " PaletteBlocks stone,gravel").text(" - A comma separated list of blocks")
|
||||
.newline()
|
||||
.text("&7[&aComplexity&7]").cmdTip(alias() + " Complexity").text(" - Block textures within a complexity range")
|
||||
.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "coloring"))
|
||||
.send(fp);
|
||||
.text("&7[&aAll&7]").cmdTip(alias() + " PaletteBlocks *").text(" - All available blocks")
|
||||
.newline()
|
||||
.text("&7[&aClipboard&7]").cmdTip(alias() + " PaletteBlocks #clipboard").text(" - The blocks in your clipboard")
|
||||
.newline()
|
||||
.text("&7[&aList&7]").suggestTip(alias() + " PaletteBlocks stone,gravel").text(" - A comma separated list of blocks")
|
||||
.newline()
|
||||
.text("&7[&aComplexity&7]").cmdTip(alias() + " Complexity").text(" - Block textures within a complexity range")
|
||||
.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "coloring"))
|
||||
.send(fp);
|
||||
return;
|
||||
}
|
||||
HeightMapMCAGenerator generator = assertSettings(fp).getGenerator();
|
||||
@ -413,7 +433,9 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
blocks = new HashSet<>();
|
||||
for (int combined = 0; combined < ids.length; combined++) {
|
||||
if (ids[combined]) blocks.add(BlockTypes.get(combined));
|
||||
if (ids[combined]) {
|
||||
blocks.add(BlockTypes.get(combined));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -434,7 +456,9 @@ public class CFICommands extends MethodCommands {
|
||||
BlockType type = BlockTypes.get(typeId);
|
||||
BlockStateHolder block = type.getDefaultState();
|
||||
pattern.setBlock(block);
|
||||
if (mask.test(BlockVector3.ZERO)) blocks.add(type);
|
||||
if (mask.test(BlockVector3.ZERO)) {
|
||||
blocks.add(type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -469,8 +493,11 @@ public class CFICommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void complexity(FawePlayer fp, int min, int max) throws ParameterException, FileNotFoundException {
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
if (min == 0 && max == 100) gen.setTextureUtil(Fawe.get().getTextureUtil());
|
||||
else gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max));
|
||||
if (min == 0 && max == 100) {
|
||||
gen.setTextureUtil(Fawe.get().getTextureUtil());
|
||||
} else {
|
||||
gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max));
|
||||
}
|
||||
coloring(fp);
|
||||
}
|
||||
|
||||
@ -511,11 +538,16 @@ public class CFICommands extends MethodCommands {
|
||||
" - If a mask is used, the biome will be set anywhere the mask applies"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException {
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
if (image != null) gen.setBiome(load(image), biome, !disableWhiteOnly);
|
||||
else if (mask != null) gen.setBiome(mask, biome);
|
||||
else gen.setBiome(biome);
|
||||
if (image != null) {
|
||||
gen.setBiome(load(image), biome, !disableWhiteOnly);
|
||||
} else if (mask != null) {
|
||||
gen.setBiome(mask, biome);
|
||||
} else {
|
||||
gen.setBiome(biome);
|
||||
}
|
||||
msg("Set biome!").send(fp);
|
||||
assertSettings(fp).resetComponent();
|
||||
component(fp);
|
||||
@ -678,7 +710,8 @@ public class CFICommands extends MethodCommands {
|
||||
)
|
||||
// ![79,174,212,5:3,5:4,18,161,20]
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void glass(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
||||
public void glass(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
settings.getGenerator().setColorWithGlass(load(image));
|
||||
msg("Set color with glass!").send(fp);
|
||||
@ -695,12 +728,17 @@ public class CFICommands extends MethodCommands {
|
||||
"The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void color(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
||||
public void color(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
HeightMapMCAGenerator gen = settings.getGenerator();
|
||||
if (imageMask != null) gen.setColor(load(image), load(imageMask), !disableWhiteOnly);
|
||||
else if (mask != null) gen.setColor(load(image), mask);
|
||||
else gen.setColor(load(image));
|
||||
if (imageMask != null) {
|
||||
gen.setColor(load(image), load(imageMask), !disableWhiteOnly);
|
||||
} else if (mask != null) {
|
||||
gen.setColor(load(image), mask);
|
||||
} else {
|
||||
gen.setColor(load(image));
|
||||
}
|
||||
settings.resetColoring();
|
||||
msg("Set color with blocks!").send(fp);
|
||||
mainMenu(fp);
|
||||
@ -712,10 +750,11 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Set the color with blocks and biomes",
|
||||
help = "Color the terrain using blocks and biomes.\n" +
|
||||
"Provide an image, or worldedit mask to restrict what areas are colored\n" +
|
||||
"The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
|
||||
"The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void blockbiome(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
||||
public void blockbiome(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
settings.getGenerator().setBlockAndBiomeColor(load(image), mask, load(imageMask), !disableWhiteOnly);
|
||||
msg("Set color with blocks and biomes!").send(fp);
|
||||
@ -731,7 +770,8 @@ public class CFICommands extends MethodCommands {
|
||||
" - If you changed the block to something other than grass you will not see anything."
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void biomecolor(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
||||
public void biomecolor(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch(
|
||||
'w') boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
settings.getGenerator().setBiomeColor(load(image));
|
||||
msg("Set color with biomes!").send(fp);
|
||||
@ -746,7 +786,7 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Color the world using an image"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void coloring(FawePlayer fp) throws ParameterException{
|
||||
public void coloring(FawePlayer fp) throws ParameterException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
settings.popMessages(fp);
|
||||
settings.setCategory("coloring");
|
||||
@ -778,7 +818,9 @@ public class CFICommands extends MethodCommands {
|
||||
for (int typeId : blockArray) {
|
||||
BlockType type = BlockTypes.get(typeId);
|
||||
String name = type.getName();
|
||||
if (name.contains(":")) name = name.split(":")[1];
|
||||
if (name.contains(":")) {
|
||||
name = name.split(":")[1];
|
||||
}
|
||||
materials.add(name);
|
||||
}
|
||||
String blockList = materials.size() > 100 ? materials.size() + " blocks" : StringMan.join(materials, ',');
|
||||
@ -786,33 +828,39 @@ public class CFICommands extends MethodCommands {
|
||||
int biomePriority = gen.getBiomePriority();
|
||||
|
||||
Message msg = msg("&8>>&7 Current Settings &8<<&7").newline()
|
||||
.text("&7Randomization ").text("&7[&a" + (Boolean.toString(rand).toUpperCase()) + "&7]").cmdTip(alias() + " randomization " + (!rand))
|
||||
.newline()
|
||||
.text("&7Mask ").text("&7[&a" + mask + "&7]").cmdTip(alias() + " mask")
|
||||
.newline()
|
||||
.text("&7Blocks ").text("&7[&a" + blocks + "&7]").tooltip(blockList).command(alias() + " paletteBlocks")
|
||||
.newline()
|
||||
.text("&7BiomePriority ").text("&7[&a" + biomePriority + "&7]").cmdTip(alias() + " biomepriority")
|
||||
.newline();
|
||||
.text("&7Randomization ").text("&7[&a" + (Boolean.toString(rand).toUpperCase()) + "&7]").cmdTip(alias() + " randomization " + (!rand))
|
||||
.newline()
|
||||
.text("&7Mask ").text("&7[&a" + mask + "&7]").cmdTip(alias() + " mask")
|
||||
.newline()
|
||||
.text("&7Blocks ").text("&7[&a" + blocks + "&7]").tooltip(blockList).command(alias() + " paletteBlocks")
|
||||
.newline()
|
||||
.text("&7BiomePriority ").text("&7[&a" + biomePriority + "&7]").cmdTip(alias() + " biomepriority")
|
||||
.newline();
|
||||
|
||||
if (settings.image != null) {
|
||||
StringBuilder colorArgs = new StringBuilder();
|
||||
colorArgs.append(" " + settings.imageArg);
|
||||
if (settings.imageMask != null) colorArgs.append(" " + settings.imageMaskArg);
|
||||
if (settings.mask != null) colorArgs.append(" " + settings.maskArg);
|
||||
if (!settings.whiteOnly) colorArgs.append(" -w");
|
||||
if (settings.imageMask != null) {
|
||||
colorArgs.append(" " + settings.imageMaskArg);
|
||||
}
|
||||
if (settings.mask != null) {
|
||||
colorArgs.append(" " + settings.maskArg);
|
||||
}
|
||||
if (!settings.whiteOnly) {
|
||||
colorArgs.append(" -w");
|
||||
}
|
||||
|
||||
msg.text("&7Image: ")
|
||||
.text("&7[&a" + settings.imageArg + "&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
|
||||
.newline().newline()
|
||||
.text("&cLet's Color&7: ")
|
||||
.cmdOptions(alias() + " ", colorArgs.toString(), "Biomes", "Blocks", "BlockAndBiome", "Glass")
|
||||
.newline();
|
||||
.text("&7[&a" + settings.imageArg + "&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
|
||||
.newline().newline()
|
||||
.text("&cLet's Color&7: ")
|
||||
.cmdOptions(alias() + " ", colorArgs.toString(), "Biomes", "Blocks", "BlockAndBiome", "Glass")
|
||||
.newline();
|
||||
} else {
|
||||
msg.newline().text("You can color a world using an image like ")
|
||||
.text("&7[&aThis&7]").linkTip("http://i.imgur.com/vJYinIU.jpg").newline()
|
||||
.text("&cYou MUST provide an image: ")
|
||||
.text("&7[&aNone&7]").cmdTip(alias() + " " + Commands.getAlias(Command.class, "image")).newline();
|
||||
.text("&7[&aThis&7]").linkTip("http://i.imgur.com/vJYinIU.jpg").newline()
|
||||
.text("&cYou MUST provide an image: ")
|
||||
.text("&7[&aNone&7]").cmdTip(alias() + " " + Commands.getAlias(Command.class, "image")).newline();
|
||||
}
|
||||
msg.text("&8< &7[&aBack&7]").cmdTip(alias()).send(fp);
|
||||
}
|
||||
@ -823,7 +871,7 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Select a mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void mask(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly, CommandContext context) throws ParameterException{
|
||||
public void mask(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri imageMask, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly, CommandContext context) throws ParameterException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
String[] split = getArguments(context).split(" ");
|
||||
int index = 2;
|
||||
@ -836,11 +884,11 @@ public class CFICommands extends MethodCommands {
|
||||
StringBuilder cmd = new StringBuilder(alias() + " mask ");
|
||||
|
||||
msg("&8>>&7 Current Settings &8<<&7").newline()
|
||||
.text("&7Image Mask ").text("&7[&a" + settings.imageMaskArg + "&7]").suggestTip(cmd + "http://")
|
||||
.newline()
|
||||
.text("&7WorldEdit Mask ").text("&7[&a" + settings.maskArg + "&7]").suggestTip(cmd + "<mask>")
|
||||
.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias() + " " + settings.getCategory()).send(fp);
|
||||
.text("&7Image Mask ").text("&7[&a" + settings.imageMaskArg + "&7]").suggestTip(cmd + "http://")
|
||||
.newline()
|
||||
.text("&7WorldEdit Mask ").text("&7[&a" + settings.maskArg + "&7]").suggestTip(cmd + "<mask>")
|
||||
.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias() + " " + settings.getCategory()).send(fp);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -862,9 +910,9 @@ public class CFICommands extends MethodCommands {
|
||||
dispathcer.call(settings.getCategory(), context.getLocals(), new String[0]);
|
||||
} else {
|
||||
msg("&8>>&7 Current Settings &8<<&7").newline()
|
||||
.text("&7Pattern ").text("&7[&aClick Here&7]").suggestTip(cmd + " stone")
|
||||
.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias() + " " + settings.getCategory()).send(fp);
|
||||
.text("&7Pattern ").text("&7[&aClick Here&7]").suggestTip(cmd + " stone")
|
||||
.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias() + " " + settings.getCategory()).send(fp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -877,7 +925,7 @@ public class CFICommands extends MethodCommands {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
BufferedImage image = settings.getGenerator().draw();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageIO.write(image, "jpg", baos );
|
||||
ImageIO.write(image, "jpg", baos);
|
||||
byte[] data = baos.toByteArray();
|
||||
fp.sendMessage("Please wait...");
|
||||
URL url = ImgurUtility.uploadImage(data);
|
||||
@ -902,10 +950,10 @@ public class CFICommands extends MethodCommands {
|
||||
StringBuilder cmd = new StringBuilder(alias() + " image ");
|
||||
if (image == null) {
|
||||
msg("Please provide an image:").newline()
|
||||
.text("From a URL: ").text("&7[&aClick Here&7]").suggestTip(cmd + "http://")
|
||||
.newline()
|
||||
.text("From a file: ").text("&7[&aClick Here&7]").suggestTip(cmd + "file://")
|
||||
.send(fp);
|
||||
.text("From a URL: ").text("&7[&aClick Here&7]").suggestTip(cmd + "http://")
|
||||
.newline()
|
||||
.text("From a file: ").text("&7[&aClick Here&7]").suggestTip(cmd + "file://")
|
||||
.send(fp);
|
||||
} else {
|
||||
if (settings.hasGenerator()) {
|
||||
coloring(fp);
|
||||
@ -924,15 +972,15 @@ public class CFICommands extends MethodCommands {
|
||||
desc = ""
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void populate(FawePlayer fp) throws ParameterException{
|
||||
public void populate(FawePlayer fp) throws ParameterException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
settings.popMessages(fp);
|
||||
settings.setCategory("populate");
|
||||
msg("What would you like to populate?").newline()
|
||||
.text("(You will need to type these commands)").newline()
|
||||
.cmdOptions(alias() + " ", "", "Ores", "Ore", "Caves", "Schematics", "Smooth")
|
||||
.newline().text("&8< &7[&aBack&7]").cmdTip(alias())
|
||||
.send(fp);
|
||||
.text("(You will need to type these commands)").newline()
|
||||
.cmdOptions(alias() + " ", "", "Ores", "Ore", "Caves", "Schematics", "Smooth")
|
||||
.newline().text("&8< &7[&aBack&7]").cmdTip(alias())
|
||||
.send(fp);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -941,7 +989,7 @@ public class CFICommands extends MethodCommands {
|
||||
desc = "Components menu"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void component(FawePlayer fp) throws ParameterException{
|
||||
public void component(FawePlayer fp) throws ParameterException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
settings.popMessages(fp);
|
||||
settings.setCategory("component");
|
||||
@ -958,65 +1006,72 @@ public class CFICommands extends MethodCommands {
|
||||
String pattern = settings.pattern == null ? "NONE" : settings.patternArg;
|
||||
|
||||
StringBuilder maskArgs = new StringBuilder();
|
||||
if (settings.imageMask != null) maskArgs.append(" " + settings.imageMaskArg);
|
||||
if (settings.mask != null) maskArgs.append(" " + settings.maskArg);
|
||||
if (!settings.whiteOnly) maskArgs.append(" -w");
|
||||
if (settings.imageMask != null) {
|
||||
maskArgs.append(" " + settings.imageMaskArg);
|
||||
}
|
||||
if (settings.mask != null) {
|
||||
maskArgs.append(" " + settings.maskArg);
|
||||
}
|
||||
if (!settings.whiteOnly) {
|
||||
maskArgs.append(" -w");
|
||||
}
|
||||
|
||||
String height = Commands.getAlias(CFICommands.class, "height");
|
||||
String waterHeight = Commands.getAlias(CFICommands.class, "waterheight");
|
||||
String snow = Commands.getAlias(CFICommands.class, "snow");
|
||||
|
||||
Message msg = msg("&8>>&7 Current Settings &8<<&7").newline()
|
||||
.text("&7Mask ").text("&7[&a" + mask + "&7]").cmdTip(alias() + " mask")
|
||||
.newline()
|
||||
.text("&7Pattern ").text("&7[&a" + pattern + "&7]").cmdTip(alias() + " pattern")
|
||||
.newline()
|
||||
.newline()
|
||||
.text("&8>>&7 Components &8<<&7")
|
||||
.newline()
|
||||
.text("&7[&aHeight&7]").suggestTip(alias() + " " + alias("height") + " 120").text(" - Terrain height for whole map")
|
||||
.newline()
|
||||
.text("&7[&aWaterHeight&7]").suggestTip(alias() + " " + alias("waterheight") + " 60").text(" - Sea level for whole map")
|
||||
.newline()
|
||||
.text("&7[&aFloorThickness&7]").suggestTip(alias() + " " + alias("floorthickness") + " 60").text(" - Floor thickness of entire map")
|
||||
.newline()
|
||||
.text("&7[&aWorldThickness&7]").suggestTip(alias() + " " + alias("worldthickness") + " 60").text(" - World thickness of entire map")
|
||||
.newline()
|
||||
.text("&7[&aSnow&7]").suggestTip(alias() + " " + alias("snow") + maskArgs).text(" - Set snow in the masked areas")
|
||||
.newline();
|
||||
.text("&7Mask ").text("&7[&a" + mask + "&7]").cmdTip(alias() + " mask")
|
||||
.newline()
|
||||
.text("&7Pattern ").text("&7[&a" + pattern + "&7]").cmdTip(alias() + " pattern")
|
||||
.newline()
|
||||
.newline()
|
||||
.text("&8>>&7 Components &8<<&7")
|
||||
.newline()
|
||||
.text("&7[&aHeight&7]").suggestTip(alias() + " " + alias("height") + " 120").text(" - Terrain height for whole map")
|
||||
.newline()
|
||||
.text("&7[&aWaterHeight&7]").suggestTip(alias() + " " + alias("waterheight") + " 60").text(" - Sea level for whole map")
|
||||
.newline()
|
||||
.text("&7[&aFloorThickness&7]").suggestTip(alias() + " " + alias("floorthickness") + " 60").text(" - Floor thickness of entire map")
|
||||
.newline()
|
||||
.text("&7[&aWorldThickness&7]").suggestTip(alias() + " " + alias("worldthickness") + " 60").text(" - World thickness of entire map")
|
||||
.newline()
|
||||
.text("&7[&aSnow&7]").suggestTip(alias() + " " + alias("snow") + maskArgs).text(" - Set snow in the masked areas")
|
||||
.newline();
|
||||
|
||||
if (pattern != null) {
|
||||
String disabled = "You must specify a pattern";
|
||||
msg
|
||||
.text("&7[&cWaterId&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cBedrockId&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cFloor&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cMain&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cColumn&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cOverlay&7]").tooltip(disabled).newline();
|
||||
.text("&7[&cWaterId&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cBedrockId&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cFloor&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cMain&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cColumn&7]").tooltip(disabled).newline()
|
||||
.text("&7[&cOverlay&7]").tooltip(disabled).newline();
|
||||
} else {
|
||||
StringBuilder compArgs = new StringBuilder();
|
||||
compArgs.append(" " + settings.patternArg + maskArgs);
|
||||
|
||||
msg
|
||||
.text("&7[&aWaterId&7]").cmdTip(alias() + " waterId " + pattern).text(" - Water id for whole map").newline()
|
||||
.text("&7[&aBedrockId&7]").cmdTip(alias() + " baseId " + pattern).text(" - Bedrock id for whole map").newline()
|
||||
.text("&7[&aFloor&7]").cmdTip(alias() + " floor" + compArgs).text(" - Set the floor in the masked areas").newline()
|
||||
.text("&7[&aMain&7]").cmdTip(alias() + " main" + compArgs).text(" - Set the main block in the masked areas").newline()
|
||||
.text("&7[&aColumn&7]").cmdTip(alias() + " column" + compArgs).text(" - Set the columns in the masked areas").newline()
|
||||
.text("&7[&aOverlay&7]").cmdTip(alias() + " overlay" + compArgs).text(" - Set the overlay in the masked areas").newline();
|
||||
.text("&7[&aWaterId&7]").cmdTip(alias() + " waterId " + pattern).text(" - Water id for whole map").newline()
|
||||
.text("&7[&aBedrockId&7]").cmdTip(alias() + " baseId " + pattern).text(" - Bedrock id for whole map").newline()
|
||||
.text("&7[&aFloor&7]").cmdTip(alias() + " floor" + compArgs).text(" - Set the floor in the masked areas").newline()
|
||||
.text("&7[&aMain&7]").cmdTip(alias() + " main" + compArgs).text(" - Set the main block in the masked areas").newline()
|
||||
.text("&7[&aColumn&7]").cmdTip(alias() + " column" + compArgs).text(" - Set the columns in the masked areas").newline()
|
||||
.text("&7[&aOverlay&7]").cmdTip(alias() + " overlay" + compArgs).text(" - Set the overlay in the masked areas").newline();
|
||||
}
|
||||
|
||||
msg.newline()
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias())
|
||||
.send(fp);
|
||||
.text("&8< &7[&aBack&7]").cmdTip(alias())
|
||||
.send(fp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private CFISettings assertSettings(FawePlayer fp) throws ParameterException {
|
||||
CFISettings settings = getSettings(fp);
|
||||
if (!settings.hasGenerator()) throw new ParameterException("Please use /" + alias());
|
||||
if (!settings.hasGenerator()) {
|
||||
throw new ParameterException("Please use /" + alias());
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
@ -1103,12 +1158,16 @@ public class CFICommands extends MethodCommands {
|
||||
|
||||
public CFISettings setGenerator(HeightMapMCAGenerator generator) {
|
||||
this.generator = generator;
|
||||
if (bound) fp.getSession().setVirtualWorld(generator);
|
||||
if (bound) {
|
||||
fp.getSession().setVirtualWorld(generator);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public CFISettings bind() {
|
||||
if (generator != null) fp.getSession().setVirtualWorld(generator);
|
||||
if (generator != null) {
|
||||
fp.getSession().setVirtualWorld(generator);
|
||||
}
|
||||
bound = true;
|
||||
fp.setMeta("CFISettings", this);
|
||||
return this;
|
||||
@ -1152,17 +1211,17 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
|
||||
protected Message msg(String text) {
|
||||
return new Message().newline()
|
||||
.text(BBC.getPrefix())
|
||||
.text(text);
|
||||
return new Message().newline()
|
||||
.text(BBC.getPrefix())
|
||||
.text(text);
|
||||
}
|
||||
|
||||
protected void mainMenu(FawePlayer fp) {
|
||||
msg("What do you want to do now?").newline()
|
||||
.cmdOptions(alias() + " ", "", "Coloring", "Component", "Populate", "Brush")
|
||||
.newline().text("&3<> &7[&aView&7]").command(alias() + " " + Commands.getAlias(CFICommands.class, "download")).tooltip("View full resolution image")
|
||||
.newline().text("&4>< &7[&aCancel&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "cancel"))
|
||||
.newline().text("&2>> &7[&aDone&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "done"))
|
||||
.send(fp);
|
||||
.cmdOptions(alias() + " ", "", "Coloring", "Component", "Populate", "Brush")
|
||||
.newline().text("&3<> &7[&aView&7]").command(alias() + " " + Commands.getAlias(CFICommands.class, "download")).tooltip("View full resolution image")
|
||||
.newline().text("&4>< &7[&aCancel&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "cancel"))
|
||||
.newline().text("&2>> &7[&aDone&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "done"))
|
||||
.send(fp);
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.extent.NullExtent;
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -30,23 +30,20 @@ import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.binding.Validate;
|
||||
import com.sk89q.worldedit.util.command.parametric.ArgumentStack;
|
||||
import com.sk89q.worldedit.util.command.parametric.BindingBehavior;
|
||||
import com.sk89q.worldedit.util.command.parametric.BindingHelper;
|
||||
import com.sk89q.worldedit.util.command.parametric.BindingMatch;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FawePrimitiveBinding {
|
||||
@BindingMatch(type = {Long.class, long.class},
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public Long getLong(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
try {
|
||||
Long v = Long.parseLong(context.next());
|
||||
@ -80,11 +77,15 @@ public class FawePrimitiveBinding {
|
||||
public class ImageUri {
|
||||
public final URI uri;
|
||||
private BufferedImage image;
|
||||
public ImageUri(URI uri) {
|
||||
|
||||
ImageUri(URI uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public BufferedImage load() throws ParameterException {
|
||||
if (image != null) return image;
|
||||
if (image != null) {
|
||||
return image;
|
||||
}
|
||||
return image = ImageUtil.load(uri);
|
||||
}
|
||||
}
|
||||
@ -105,7 +106,9 @@ public class FawePrimitiveBinding {
|
||||
)
|
||||
public TextureUtil getTexture(ArgumentStack context) {
|
||||
Actor actor = context.getContext().getLocals().get(Actor.class);
|
||||
if (actor == null) return Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
if (actor == null) {
|
||||
return Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
}
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
|
||||
return session.getTextureUtil();
|
||||
}
|
||||
@ -117,12 +120,20 @@ public class FawePrimitiveBinding {
|
||||
)
|
||||
public Extent getExtent(ArgumentStack context) throws ParameterException {
|
||||
Extent extent = context.getContext().getLocals().get(EditSession.class);
|
||||
if (extent != null) return extent;
|
||||
if (extent != null) {
|
||||
return extent;
|
||||
}
|
||||
extent = Request.request().getExtent();
|
||||
if (extent != null) return extent;
|
||||
if (extent != null) {
|
||||
return extent;
|
||||
}
|
||||
Actor actor = context.getContext().getLocals().get(Actor.class);
|
||||
if (actor == null) throw new ParameterException("No player to get a session for");
|
||||
if (!(actor instanceof Player)) throw new ParameterException("Caller is not a player");
|
||||
if (actor == null) {
|
||||
throw new ParameterException("No player to get a session for");
|
||||
}
|
||||
if (!(actor instanceof Player)) {
|
||||
throw new ParameterException("Caller is not a player");
|
||||
}
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
|
||||
EditSession editSession = session.createEditSession((Player) actor);
|
||||
editSession.enableQueue();
|
||||
@ -139,7 +150,7 @@ public class FawePrimitiveBinding {
|
||||
* @throws ParameterException on other error
|
||||
*/
|
||||
@BindingMatch(type = FawePlayer.class,
|
||||
behavior = BindingBehavior.PROVIDES)
|
||||
behavior = BindingBehavior.PROVIDES)
|
||||
public FawePlayer getFawePlayer(ArgumentStack context) throws ParameterException, InputParseException {
|
||||
Actor sender = context.getContext().getLocals().get(Actor.class);
|
||||
if (sender == null) {
|
||||
@ -157,10 +168,12 @@ public class FawePrimitiveBinding {
|
||||
* @throws ParameterException on other error
|
||||
*/
|
||||
@BindingMatch(type = ResettableExtent.class,
|
||||
behavior = BindingBehavior.PROVIDES)
|
||||
behavior = BindingBehavior.PROVIDES)
|
||||
public ResettableExtent getResettableExtent(ArgumentStack context) throws ParameterException, InputParseException {
|
||||
String input = context.next();
|
||||
if (input.equalsIgnoreCase("#null")) return new NullExtent();
|
||||
if (input.equalsIgnoreCase("#null")) {
|
||||
return new NullExtent();
|
||||
}
|
||||
DefaultTransformParser parser = Fawe.get().getTransformParser();
|
||||
Actor actor = context.getContext().getLocals().get(Actor.class);
|
||||
ParserContext parserContext = new ParserContext();
|
||||
@ -178,17 +191,17 @@ public class FawePrimitiveBinding {
|
||||
/**
|
||||
* Gets a type from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @param text the text annotation
|
||||
* @param context the context
|
||||
* @param text the text annotation
|
||||
* @param modifiers a list of modifiers
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(classifier = Text.class,
|
||||
type = String.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = -1,
|
||||
provideModifiers = true)
|
||||
type = String.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = -1,
|
||||
provideModifiers = true)
|
||||
public String getText(ArgumentStack context, Text text, Annotation[] modifiers)
|
||||
throws ParameterException {
|
||||
String v = context.remaining();
|
||||
@ -196,9 +209,9 @@ public class FawePrimitiveBinding {
|
||||
return v;
|
||||
}
|
||||
|
||||
@BindingMatch(type = { Expression.class },
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
@BindingMatch(type = {Expression.class},
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
public Expression getExpression(ArgumentStack context) throws ParameterException, ExpressionException {
|
||||
String input = context.next();
|
||||
try {
|
||||
@ -222,15 +235,15 @@ public class FawePrimitiveBinding {
|
||||
/**
|
||||
* Gets a type from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @param context the context
|
||||
* @param modifiers a list of modifiers
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = String.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public String getString(ArgumentStack context, Annotation[] modifiers)
|
||||
throws ParameterException {
|
||||
String v = context.next();
|
||||
@ -246,8 +259,8 @@ public class FawePrimitiveBinding {
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = {Boolean.class, boolean.class},
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1)
|
||||
public Boolean getBoolean(ArgumentStack context) throws ParameterException {
|
||||
return context.nextBoolean();
|
||||
}
|
||||
@ -260,9 +273,9 @@ public class FawePrimitiveBinding {
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = Vector3.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public Vector3 getVector3(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
String radiusString = context.next();
|
||||
String[] radii = radiusString.split(",");
|
||||
@ -293,9 +306,9 @@ public class FawePrimitiveBinding {
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = Vector2.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public Vector2 getVector2(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
String radiusString = context.next();
|
||||
String[] radii = radiusString.split(",");
|
||||
@ -314,69 +327,71 @@ public class FawePrimitiveBinding {
|
||||
throw new ParameterException("You must either specify 1 or 2 radius values.");
|
||||
}
|
||||
return Vector2.at(radiusX, radiusZ);
|
||||
} /**
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a type from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = BlockVector3.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public BlockVector3 getBlockVector3(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
String radiusString = context.next();
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
||||
break;
|
||||
*
|
||||
* @param context the context
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = BlockVector3.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public BlockVector3 getBlockVector3(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
String radiusString = context.next();
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusY = radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
radiusX = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
||||
radiusY = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[1]));
|
||||
radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[2]));
|
||||
break;
|
||||
case 3:
|
||||
radiusX = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
||||
radiusY = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[1]));
|
||||
radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[2]));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ParameterException("You must either specify 1 or 3 radius values.");
|
||||
}
|
||||
return BlockVector3.at(radiusX, radiusY, radiusZ);
|
||||
}
|
||||
default:
|
||||
throw new ParameterException("You must either specify 1 or 3 radius values.");
|
||||
}
|
||||
return BlockVector3.at(radiusX, radiusY, radiusZ);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a type from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = BlockVector2.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public BlockVector2 getBlockVector2(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
String radiusString = context.next();
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
||||
break;
|
||||
/**
|
||||
* Gets a type from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = BlockVector2.class,
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public BlockVector2 getBlockVector2(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
String radiusString = context.next();
|
||||
String[] radii = radiusString.split(",");
|
||||
final double radiusX, radiusZ;
|
||||
switch (radii.length) {
|
||||
case 1:
|
||||
radiusX = radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
radiusX = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
||||
radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[1]));
|
||||
break;
|
||||
case 2:
|
||||
radiusX = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0]));
|
||||
radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[1]));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ParameterException("You must either specify 1 or 2 radius values.");
|
||||
}
|
||||
return BlockVector2.at(radiusX, radiusZ);
|
||||
}
|
||||
default:
|
||||
throw new ParameterException("You must either specify 1 or 2 radius values.");
|
||||
}
|
||||
return BlockVector2.at(radiusX, radiusZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to parse numeric input as either a number or a mathematical expression.
|
||||
@ -410,15 +425,15 @@ public class FawePrimitiveBinding {
|
||||
/**
|
||||
* Gets a type from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @param context the context
|
||||
* @param modifiers a list of modifiers
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = {Integer.class, int.class},
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public Integer getInteger(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
Double v = parseNumericInput(context.next());
|
||||
if (v != null) {
|
||||
@ -433,15 +448,15 @@ public class FawePrimitiveBinding {
|
||||
/**
|
||||
* Gets a type from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @param context the context
|
||||
* @param modifiers a list of modifiers
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = {Short.class, short.class},
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public Short getShort(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
Integer v = getInteger(context, modifiers);
|
||||
if (v != null) {
|
||||
@ -453,15 +468,15 @@ public class FawePrimitiveBinding {
|
||||
/**
|
||||
* Gets a type from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @param context the context
|
||||
* @param modifiers a list of modifiers
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = {Double.class, double.class},
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public Double getDouble(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
Double v = parseNumericInput(context.next());
|
||||
if (v != null) {
|
||||
@ -475,15 +490,15 @@ public class FawePrimitiveBinding {
|
||||
/**
|
||||
* Gets a type from a {@link ArgumentStack}.
|
||||
*
|
||||
* @param context the context
|
||||
* @param context the context
|
||||
* @param modifiers a list of modifiers
|
||||
* @return the requested type
|
||||
* @throws ParameterException on error
|
||||
*/
|
||||
@BindingMatch(type = {Float.class, float.class},
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
behavior = BindingBehavior.CONSUMES,
|
||||
consumedCount = 1,
|
||||
provideModifiers = true)
|
||||
public Float getFloat(ArgumentStack context, Annotation[] modifiers) throws ParameterException {
|
||||
Double v = getDouble(context, modifiers);
|
||||
if (v != null) {
|
||||
@ -495,7 +510,7 @@ public class FawePrimitiveBinding {
|
||||
/**
|
||||
* Validate a number value using relevant modifiers.
|
||||
*
|
||||
* @param number the number
|
||||
* @param number the number
|
||||
* @param modifiers the list of modifiers to scan
|
||||
* @throws ParameterException on a validation error
|
||||
*/
|
||||
@ -506,14 +521,10 @@ public class FawePrimitiveBinding {
|
||||
Range range = (Range) modifier;
|
||||
if (number < range.min()) {
|
||||
throw new ParameterException(
|
||||
String.format(
|
||||
"A valid value is greater than or equal to %s " +
|
||||
"(you entered %s)", range.min(), number));
|
||||
String.format("A valid value is greater than or equal to %s (you entered %s)", range.min(), number));
|
||||
} else if (number > range.max()) {
|
||||
throw new ParameterException(
|
||||
String.format(
|
||||
"A valid value is less than or equal to %s " +
|
||||
"(you entered %s)", range.max(), number));
|
||||
String.format("A valid value is less than or equal to %s (you entered %s)", range.max(), number));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -522,7 +533,7 @@ public class FawePrimitiveBinding {
|
||||
/**
|
||||
* Validate a number value using relevant modifiers.
|
||||
*
|
||||
* @param number the number
|
||||
* @param number the number
|
||||
* @param modifiers the list of modifiers to scan
|
||||
* @throws ParameterException on a validation error
|
||||
*/
|
||||
@ -534,13 +545,11 @@ public class FawePrimitiveBinding {
|
||||
if (number < range.min()) {
|
||||
throw new ParameterException(
|
||||
String.format(
|
||||
"A valid value is greater than or equal to %s " +
|
||||
"(you entered %s)", range.min(), number));
|
||||
"A valid value is greater than or equal to %s (you entered %s)", range.min(), number));
|
||||
} else if (number > range.max()) {
|
||||
throw new ParameterException(
|
||||
String.format(
|
||||
"A valid value is less than or equal to %s " +
|
||||
"(you entered %s)", range.max(), number));
|
||||
"A valid value is less than or equal to %s (you entered %s)", range.max(), number));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -549,7 +558,7 @@ public class FawePrimitiveBinding {
|
||||
/**
|
||||
* Validate a string value using relevant modifiers.
|
||||
*
|
||||
* @param string the string
|
||||
* @param string the string
|
||||
* @param modifiers the list of modifiers to scan
|
||||
* @throws ParameterException on a validation error
|
||||
*/
|
||||
@ -567,8 +576,7 @@ public class FawePrimitiveBinding {
|
||||
if (!string.matches(validate.regex())) {
|
||||
throw new ParameterException(
|
||||
String.format(
|
||||
"The given text doesn't match the right " +
|
||||
"format (technically speaking, the 'format' is %s)",
|
||||
"The given text doesn't match the right format (technically speaking, the 'format' is %s)",
|
||||
validate.regex()));
|
||||
}
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ public enum BBC {
|
||||
allNames.add(c.name());
|
||||
allCats.add(c.category.toLowerCase());
|
||||
}
|
||||
final HashSet<BBC> captions = new HashSet<>();
|
||||
final EnumSet<BBC> captions = EnumSet.noneOf(BBC.class);
|
||||
boolean changed = false;
|
||||
for (final String key : keys) {
|
||||
final Object value = yml.get(key);
|
||||
|
@ -391,7 +391,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
private void fixSkyLighting(List<RelightSkyEntry> sorted) {
|
||||
RelightSkyEntry[] chunks = sorted.toArray(new RelightSkyEntry[sorted.size()]);
|
||||
RelightSkyEntry[] chunks = sorted.toArray(new RelightSkyEntry[0]);
|
||||
boolean remove = this.removeFirst;
|
||||
BlockVectorSet chunkSet = null;
|
||||
if (remove) {
|
||||
|
@ -1,16 +1,14 @@
|
||||
package com.boydti.fawe.jnbt;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.RunnableVal2;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class NBTStreamer {
|
||||
private final NBTInputStream is;
|
||||
@ -27,7 +25,7 @@ public class NBTStreamer {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void readFully() throws IOException {
|
||||
is.readNamedTagLazy(node -> readers.get(node));
|
||||
is.readNamedTagLazy(readers::get);
|
||||
is.close();
|
||||
}
|
||||
|
||||
@ -57,12 +55,6 @@ public class NBTStreamer {
|
||||
readers.put(node, run);
|
||||
}
|
||||
|
||||
public <T, V> void addReader(BiConsumer<T, V> run, String... nodes) {
|
||||
for (String node : nodes) {
|
||||
addReader(node, run);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class NBTStreamReader<T, V> implements BiConsumer<T, V> {
|
||||
private String node;
|
||||
|
||||
@ -84,7 +76,7 @@ public class NBTStreamer {
|
||||
public abstract void run(int index, int byteValue);
|
||||
}
|
||||
|
||||
public static abstract class LazyReader implements BiConsumer<Integer, DataInputStream> {}
|
||||
public interface LazyReader extends BiConsumer<Integer, DataInputStream> {}
|
||||
|
||||
public static abstract class LongReader implements BiConsumer<Integer, Long> {
|
||||
@Override
|
||||
|
@ -57,21 +57,21 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
}
|
||||
|
||||
public void addBlockReaders() throws IOException {
|
||||
NBTStreamReader idInit = new NBTStreamReader<Integer, Integer>() {
|
||||
NBTStreamReader<? extends Integer, ? extends Integer> idInit = new NBTStreamReader<Integer, Integer>() {
|
||||
@Override
|
||||
public void accept(Integer length, Integer type) {
|
||||
setupClipboard(length);
|
||||
ids = new FaweOutputStream(new LZ4BlockOutputStream(idOut));
|
||||
}
|
||||
};
|
||||
NBTStreamReader dataInit = new NBTStreamReader<Integer, Integer>() {
|
||||
NBTStreamReader<? extends Integer, ? extends Integer> dataInit = new NBTStreamReader<Integer, Integer>() {
|
||||
@Override
|
||||
public void accept(Integer length, Integer type) {
|
||||
setupClipboard(length);
|
||||
datas = new FaweOutputStream(new LZ4BlockOutputStream(dataOut));
|
||||
}
|
||||
};
|
||||
NBTStreamReader addInit = new NBTStreamReader<Integer, Integer>() {
|
||||
NBTStreamReader<? extends Integer, ? extends Integer> addInit = new NBTStreamReader<Integer, Integer>() {
|
||||
@Override
|
||||
public void accept(Integer length, Integer type) {
|
||||
setupClipboard(length*2);
|
||||
@ -225,19 +225,19 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
Direction left = facing.getLeft();
|
||||
Direction right = facing.getRight();
|
||||
|
||||
BlockStateHolder forwardBlock = fc.getBlock(x + forward.getBlockX(), y + forward.getBlockY(), z + forward.getBlockZ());
|
||||
BlockStateHolder<com.sk89q.worldedit.world.block.BaseBlock> forwardBlock = fc.getBlock(x + forward.getBlockX(), y + forward.getBlockY(), z + forward.getBlockZ());
|
||||
BlockType forwardType = forwardBlock.getBlockType();
|
||||
if (forwardType.hasProperty(PropertyKey.SHAPE) && forwardType.hasProperty(PropertyKey.FACING)) {
|
||||
Direction forwardFacing = (Direction) forwardBlock.getState(PropertyKey.FACING);
|
||||
if (forwardFacing == left) {
|
||||
BlockStateHolder rightBlock = fc.getBlock(x + right.toBlockVector().getBlockX(), y + right.toBlockVector().getBlockY(), z + right.toBlockVector().getBlockZ());
|
||||
BlockStateHolder<com.sk89q.worldedit.world.block.BaseBlock> rightBlock = fc.getBlock(x + right.toBlockVector().getBlockX(), y + right.toBlockVector().getBlockY(), z + right.toBlockVector().getBlockZ());
|
||||
BlockType rightType = rightBlock.getBlockType();
|
||||
if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) {
|
||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "inner_left"));
|
||||
}
|
||||
return;
|
||||
} else if (forwardFacing == right) {
|
||||
BlockStateHolder leftBlock = fc.getBlock(x + left.toBlockVector().getBlockX(), y + left.toBlockVector().getBlockY(), z + left.toBlockVector().getBlockZ());
|
||||
BlockStateHolder<com.sk89q.worldedit.world.block.BaseBlock> leftBlock = fc.getBlock(x + left.toBlockVector().getBlockX(), y + left.toBlockVector().getBlockY(), z + left.toBlockVector().getBlockZ());
|
||||
BlockType leftType = leftBlock.getBlockType();
|
||||
if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) {
|
||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "inner_right"));
|
||||
@ -246,19 +246,19 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
}
|
||||
}
|
||||
|
||||
BlockStateHolder backwardsBlock = fc.getBlock(x - forward.getBlockX(), y - forward.getBlockY(), z - forward.getBlockZ());
|
||||
BlockStateHolder<com.sk89q.worldedit.world.block.BaseBlock> backwardsBlock = fc.getBlock(x - forward.getBlockX(), y - forward.getBlockY(), z - forward.getBlockZ());
|
||||
BlockType backwardsType = backwardsBlock.getBlockType();
|
||||
if (backwardsType.hasProperty(PropertyKey.SHAPE) && backwardsType.hasProperty(PropertyKey.FACING)) {
|
||||
Direction backwardsFacing = (Direction) backwardsBlock.getState(PropertyKey.FACING);
|
||||
if (backwardsFacing == left) {
|
||||
BlockStateHolder rightBlock = fc.getBlock(x + right.toBlockVector().getBlockX(), y + right.toBlockVector().getBlockY(), z + right.toBlockVector().getBlockZ());
|
||||
BlockStateHolder<com.sk89q.worldedit.world.block.BaseBlock> rightBlock = fc.getBlock(x + right.toBlockVector().getBlockX(), y + right.toBlockVector().getBlockY(), z + right.toBlockVector().getBlockZ());
|
||||
BlockType rightType = rightBlock.getBlockType();
|
||||
if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) {
|
||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_left"));
|
||||
}
|
||||
return;
|
||||
} else if (backwardsFacing == right) {
|
||||
BlockStateHolder leftBlock = fc.getBlock(x + left.toBlockVector().getBlockX(), y + left.toBlockVector().getBlockY(), z + left.toBlockVector().getBlockZ());
|
||||
BlockStateHolder<com.sk89q.worldedit.world.block.BaseBlock> leftBlock = fc.getBlock(x + left.toBlockVector().getBlockX(), y + left.toBlockVector().getBlockY(), z + left.toBlockVector().getBlockZ());
|
||||
BlockType leftType = leftBlock.getBlockType();
|
||||
if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) {
|
||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_right"));
|
||||
@ -298,7 +298,7 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
}, true).build();
|
||||
|
||||
private boolean merge(int group, int x, int y, int z) {
|
||||
BlockStateHolder block = fc.getBlock(x, y, z);
|
||||
BlockStateHolder<com.sk89q.worldedit.world.block.BaseBlock> block = fc.getBlock(x, y, z);
|
||||
BlockType type = block.getBlockType();
|
||||
return group(type) == group || fullCube.apply(type);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class OreGen extends Resource {
|
||||
public class OreGen implements Resource {
|
||||
private final int maxSize;
|
||||
private final double maxSizeO8;
|
||||
private final double maxSizeO16;
|
||||
@ -21,9 +21,9 @@ public class OreGen extends Resource {
|
||||
private final Mask mask;
|
||||
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
private double ONE_2 = 1 / 2F;
|
||||
private double ONE_8 = 1 / 8F;
|
||||
private double ONE_16 = 1 / 16F;
|
||||
private final double ONE_2 = 1 / 2F;
|
||||
private final double ONE_8 = 1 / 8F;
|
||||
private final double ONE_16 = 1 / 16F;
|
||||
|
||||
public int laced = 0;
|
||||
|
||||
@ -47,16 +47,13 @@ public class OreGen extends Resource {
|
||||
}
|
||||
double f = rand.nextDouble() * Math.PI;
|
||||
|
||||
int x8 = x;
|
||||
int z8 = z;
|
||||
double so8 = maxSizeO8;
|
||||
double so16 = maxSizeO16;
|
||||
double sf = MathMan.sinInexact(f) * so8;
|
||||
double cf = MathMan.cosInexact(f) * so8;
|
||||
double d1 = x8 + sf;
|
||||
double d2 = x8 - sf;
|
||||
double d3 = z8 + cf;
|
||||
double d4 = z8 - cf;
|
||||
double d1 = x + sf;
|
||||
double d2 = x - sf;
|
||||
double d3 = z + cf;
|
||||
double d4 = z - cf;
|
||||
|
||||
double d5 = y + rand.nextInt(3) - 2;
|
||||
double d6 = y + rand.nextInt(3) - 2;
|
||||
@ -71,7 +68,7 @@ public class OreGen extends Resource {
|
||||
double d8 = d5 + yd * iFactor;
|
||||
double d9 = d3 + zd * iFactor;
|
||||
|
||||
double d10 = rand.nextDouble() * so16;
|
||||
double d10 = rand.nextDouble() * maxSizeO16;
|
||||
double sif = MathMan.sinInexact(Math.PI * iFactor);
|
||||
double d11 = (sif + 1.0) * d10 + 1.0;
|
||||
double d12 = (sif + 1.0) * d10 + 1.0;
|
||||
@ -116,4 +113,4 @@ public class OreGen extends Resource {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class Resource {
|
||||
public Resource() {}
|
||||
public interface Resource {
|
||||
|
||||
public abstract boolean spawn(Random random, int x, int z) throws WorldEditException;
|
||||
boolean spawn(Random random, int x, int z) throws WorldEditException;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class SchemGen extends Resource {
|
||||
public class SchemGen implements Resource {
|
||||
|
||||
private final Extent extent;
|
||||
private final List<ClipboardHolder> clipboards;
|
||||
|
@ -27,8 +27,6 @@ public class ShatterBrush extends ScatterBrush {
|
||||
@Override
|
||||
public void finish(EditSession editSession, LocalBlockVectorSet placed, final BlockVector3 position, Pattern pattern, double size) {
|
||||
int radius2 = (int) (size * size);
|
||||
// Keep track of where we've visited
|
||||
LocalBlockVectorSet tmp = new LocalBlockVectorSet();
|
||||
// Individual frontier for each point
|
||||
LocalBlockVectorSet[] frontiers = new LocalBlockVectorSet[placed.size()];
|
||||
// Keep track of where each frontier has visited
|
||||
@ -51,6 +49,8 @@ public class ShatterBrush extends ScatterBrush {
|
||||
final SurfaceMask surfaceTest = new SurfaceMask(editSession);
|
||||
// Expand
|
||||
boolean notEmpty = true;
|
||||
// Keep track of where we've visited
|
||||
LocalBlockVectorSet tmp = new LocalBlockVectorSet();
|
||||
while (notEmpty) {
|
||||
notEmpty = false;
|
||||
for (i = 0; i < frontiers.length; i++) {
|
||||
@ -59,37 +59,33 @@ public class ShatterBrush extends ScatterBrush {
|
||||
final LocalBlockVectorSet frontierVisited = frontiersVisited[i];
|
||||
// This is a temporary set with the next blocks the frontier will visit
|
||||
final LocalBlockVectorSet finalTmp = tmp;
|
||||
frontier.forEach(new LocalBlockVectorSet.BlockVectorSetVisitor() {
|
||||
@Override
|
||||
public void run(int x, int y, int z, int index) {
|
||||
if (ThreadLocalRandom.current().nextInt(2) == 0) {
|
||||
finalTmp.add(x, y, z);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < BreadthFirstSearch.DIAGONAL_DIRECTIONS.length; i++) {
|
||||
BlockVector3 direction = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i];
|
||||
int x2 = x + direction.getBlockX();
|
||||
int y2 = y + direction.getBlockY();
|
||||
int z2 = z + direction.getBlockZ();
|
||||
// Check boundary
|
||||
int dx = position.getBlockX() - x2;
|
||||
int dy = position.getBlockY() - y2;
|
||||
int dz = position.getBlockZ() - z2;
|
||||
int dSqr = (dx * dx) + (dy * dy) + (dz * dz);
|
||||
if (dSqr <= radius2) {
|
||||
MutableBlockVector3 v = mutable.setComponents(x2, y2, z2);
|
||||
BlockVector3 bv = v;
|
||||
if (surfaceTest.test(bv) && finalMask.test(bv)) {
|
||||
// (collision) If it's visited and part of another frontier, set the block
|
||||
if (!placed.add(x2, y2, z2)) {
|
||||
if (!frontierVisited.contains(x2, y2, z2)) {
|
||||
editSession.setBlock(x2, y2, z2, pattern);
|
||||
}
|
||||
} else {
|
||||
// Hasn't visited and not a collision = add it
|
||||
finalTmp.add(x2, y2, z2);
|
||||
frontierVisited.add(x2, y2, z2);
|
||||
frontier.forEach((x, y, z, index) -> {
|
||||
if (ThreadLocalRandom.current().nextInt(2) == 0) {
|
||||
finalTmp.add(x, y, z);
|
||||
return;
|
||||
}
|
||||
for (int i1 = 0; i1 < BreadthFirstSearch.DIAGONAL_DIRECTIONS.length; i1++) {
|
||||
BlockVector3 direction = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i1];
|
||||
int x2 = x + direction.getBlockX();
|
||||
int y2 = y + direction.getBlockY();
|
||||
int z2 = z + direction.getBlockZ();
|
||||
// Check boundary
|
||||
int dx = position.getBlockX() - x2;
|
||||
int dy = position.getBlockY() - y2;
|
||||
int dz = position.getBlockZ() - z2;
|
||||
int dSqr = (dx * dx) + (dy * dy) + (dz * dz);
|
||||
if (dSqr <= radius2) {
|
||||
BlockVector3 bv = mutable.setComponents(x2, y2, z2);
|
||||
if (surfaceTest.test(bv) && finalMask.test(bv)) {
|
||||
// (collision) If it's visited and part of another frontier, set the block
|
||||
if (!placed.add(x2, y2, z2)) {
|
||||
if (!frontierVisited.contains(x2, y2, z2)) {
|
||||
editSession.setBlock(x2, y2, z2, pattern);
|
||||
}
|
||||
} else {
|
||||
// Hasn't visited and not a collision = add it
|
||||
finalTmp.add(x2, y2, z2);
|
||||
frontierVisited.add(x2, y2, z2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package com.boydti.fawe.object.brush.visualization;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.IntFaweChunk;
|
||||
import com.boydti.fawe.example.NullQueueIntFaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.visitor.FaweChunkVisitor;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
@ -17,7 +15,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectIterator;
|
||||
|
||||
public class VisualExtent extends AbstractDelegateExtent {
|
||||
|
||||
@ -67,9 +64,7 @@ public class VisualExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
public void clear(VisualExtent other, FawePlayer... players) {
|
||||
ObjectIterator<Long2ObjectMap.Entry<VisualChunk>> iter = chunks.long2ObjectEntrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Long2ObjectMap.Entry<VisualChunk> entry = iter.next();
|
||||
for (Long2ObjectMap.Entry<VisualChunk> entry : chunks.long2ObjectEntrySet()) {
|
||||
long pair = entry.getLongKey();
|
||||
int cx = MathMan.unpairIntX(pair);
|
||||
int cz = MathMan.unpairIntY(pair);
|
||||
@ -79,21 +74,15 @@ public class VisualExtent extends AbstractDelegateExtent {
|
||||
final int bx = cx << 4;
|
||||
final int bz = cz << 4;
|
||||
if (otherChunk == null) {
|
||||
chunk.forEachQueuedBlock(new FaweChunkVisitor() {
|
||||
@Override
|
||||
public void run(int localX, int y, int localZ, int combined) {
|
||||
combined = queue.getCombinedId4Data(bx + localX, y, bz + localZ, 0);
|
||||
newChunk.setBlock(localX, y, localZ, combined);
|
||||
}
|
||||
chunk.forEachQueuedBlock((localX, y, localZ, combined) -> {
|
||||
combined = queue.getCombinedId4Data(bx + localX, y, bz + localZ, 0);
|
||||
newChunk.setBlock(localX, y, localZ, combined);
|
||||
});
|
||||
} else {
|
||||
chunk.forEachQueuedBlock(new FaweChunkVisitor() {
|
||||
@Override
|
||||
public void run(int localX, int y, int localZ, int combined) {
|
||||
if (combined != otherChunk.getBlockCombinedId(localX, y, localZ)) {
|
||||
combined = queue.getCombinedId4Data(bx + localX, y, bz + localZ, 0);
|
||||
newChunk.setBlock(localX, y, localZ, combined);
|
||||
}
|
||||
chunk.forEachQueuedBlock((localX, y, localZ, combined) -> {
|
||||
if (combined != otherChunk.getBlockCombinedId(localX, y, localZ)) {
|
||||
combined = queue.getCombinedId4Data(bx + localX, y, bz + localZ, 0);
|
||||
newChunk.setBlock(localX, y, localZ, combined);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.boydti.fawe.object.clipboard;
|
||||
|
||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,21 +1,18 @@
|
||||
package com.boydti.fawe.object.clipboard;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||
import com.boydti.fawe.object.IntegerTrio;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -239,9 +236,9 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
||||
states[index] = block.getInternalId();
|
||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
if (hasNbt) {
|
||||
setTile(index, ((BaseBlock)block).getNbtData());
|
||||
setTile(index, block.getNbtData());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -46,9 +46,7 @@ import java.util.UUID;
|
||||
*/
|
||||
public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
|
||||
public static int COMPRESSION = 0;
|
||||
public static int MODE = 0;
|
||||
public static int HEADER_SIZE = 14;
|
||||
private static int HEADER_SIZE = 14;
|
||||
|
||||
protected int length;
|
||||
protected int height;
|
||||
@ -61,9 +59,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
private final File file;
|
||||
|
||||
private RandomAccessFile braf;
|
||||
private MappedByteBuffer mbb;
|
||||
private MappedByteBuffer byteBuffer;
|
||||
|
||||
private FileChannel fc;
|
||||
private FileChannel fileChannel;
|
||||
private boolean hasBiomes;
|
||||
|
||||
public DiskOptimizedClipboard(int width, int height, int length, UUID uuid) {
|
||||
@ -78,9 +76,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
this.braf = new RandomAccessFile(file, "rw");
|
||||
braf.setLength(file.length());
|
||||
init();
|
||||
width = mbb.getChar(2);
|
||||
height = mbb.getChar(4);
|
||||
length = mbb.getChar(6);
|
||||
width = byteBuffer.getChar(2);
|
||||
height = byteBuffer.getChar(4);
|
||||
length = byteBuffer.getChar(6);
|
||||
area = width * length;
|
||||
this.volume = length * width * height;
|
||||
|
||||
@ -98,9 +96,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
}
|
||||
|
||||
private void init() throws IOException {
|
||||
if (this.fc == null) {
|
||||
this.fc = braf.getChannel();
|
||||
this.mbb = fc.map(FileChannel.MapMode.READ_WRITE, 0, file.length());
|
||||
if (this.fileChannel == null) {
|
||||
this.fileChannel = braf.getChannel();
|
||||
this.byteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, file.length());
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +132,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
@Override
|
||||
public void setBiome(int index, BiomeType biome) {
|
||||
if (initBiome()) {
|
||||
mbb.put(HEADER_SIZE + (volume << 2) + index, (byte) biome.getInternalId());
|
||||
byteBuffer.put(HEADER_SIZE + (volume << 2) + index, (byte) biome.getInternalId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +141,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
if (!hasBiomes()) {
|
||||
return null;
|
||||
}
|
||||
int biomeId = mbb.get(HEADER_SIZE + (volume << 2) + index) & 0xFF;
|
||||
int biomeId = byteBuffer.get(HEADER_SIZE + (volume << 2) + index) & 0xFF;
|
||||
return BiomeTypes.get(biomeId);
|
||||
}
|
||||
|
||||
@ -154,7 +152,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
int mbbIndex = HEADER_SIZE + (volume << 2);
|
||||
for (int z = 0; z < length; z++) {
|
||||
for (int x = 0; x < width; x++, index++, mbbIndex++) {
|
||||
int biome = mbb.get(mbbIndex) & 0xFF;
|
||||
int biome = byteBuffer.get(mbbIndex) & 0xFF;
|
||||
task.run(index, biome);
|
||||
}
|
||||
}
|
||||
@ -173,9 +171,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
public BlockArrayClipboard toClipboard() {
|
||||
try {
|
||||
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(width - 1, height - 1, length - 1));
|
||||
int ox = mbb.getShort(8);
|
||||
int oy = mbb.getShort(10);
|
||||
int oz = mbb.getShort(12);
|
||||
int ox = byteBuffer.getShort(8);
|
||||
int oy = byteBuffer.getShort(10);
|
||||
int oz = byteBuffer.getShort(12);
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, this);
|
||||
clipboard.setOrigin(BlockVector3.at(ox, oy, oz));
|
||||
return clipboard;
|
||||
@ -213,9 +211,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
if (width * height * length != 0) {
|
||||
init();
|
||||
// write length etc
|
||||
mbb.putChar(2, (char) width);
|
||||
mbb.putChar(4, (char) height);
|
||||
mbb.putChar(6, (char) length);
|
||||
byteBuffer.putChar(2, (char) width);
|
||||
byteBuffer.putChar(4, (char) height);
|
||||
byteBuffer.putChar(6, (char) length);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -225,9 +223,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
@Override
|
||||
public void setOrigin(BlockVector3 offset) {
|
||||
try {
|
||||
mbb.putShort(8, (short) offset.getBlockX());
|
||||
mbb.putShort(10, (short) offset.getBlockY());
|
||||
mbb.putShort(12, (short) offset.getBlockZ());
|
||||
byteBuffer.putShort(8, (short) offset.getBlockX());
|
||||
byteBuffer.putShort(10, (short) offset.getBlockY());
|
||||
byteBuffer.putShort(12, (short) offset.getBlockZ());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -248,9 +246,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
braf.setLength(size);
|
||||
init();
|
||||
}
|
||||
mbb.putChar(2, (char) width);
|
||||
mbb.putChar(4, (char) height);
|
||||
mbb.putChar(6, (char) length);
|
||||
byteBuffer.putChar(2, (char) width);
|
||||
byteBuffer.putChar(4, (char) height);
|
||||
byteBuffer.putChar(6, (char) length);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -258,7 +256,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
mbb.force();
|
||||
byteBuffer.force();
|
||||
}
|
||||
|
||||
public DiskOptimizedClipboard(int width, int height, int length) {
|
||||
@ -267,7 +265,6 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
|
||||
private void closeDirectBuffer(ByteBuffer cb) {
|
||||
if (cb == null || !cb.isDirect()) return;
|
||||
|
||||
// we could use this type cast and call functions without reflection code,
|
||||
// but static import from sun.* package is risky for non-SUN virtual machine.
|
||||
//try { ((sun.nio.ch.DirectBuffer)cb).cleaner().clean(); } catch (Exception ex) { }
|
||||
@ -299,14 +296,15 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
if (mbb != null) {
|
||||
mbb.force();
|
||||
fc.close();
|
||||
if (byteBuffer != null) {
|
||||
byteBuffer.force();
|
||||
fileChannel.close();
|
||||
braf.close();
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
file.setWritable(true);
|
||||
closeDirectBuffer(mbb);
|
||||
mbb = null;
|
||||
fc = null;
|
||||
closeDirectBuffer(byteBuffer);
|
||||
byteBuffer = null;
|
||||
fileChannel = null;
|
||||
braf = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -337,13 +335,13 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
@Override
|
||||
public void streamCombinedIds(NBTStreamer.ByteReader task) {
|
||||
try {
|
||||
mbb.force();
|
||||
byteBuffer.force();
|
||||
int pos = HEADER_SIZE;
|
||||
int index = 0;
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
for (int x = 0; x < width; x++, pos += 4) {
|
||||
int combinedId = mbb.getInt(pos);
|
||||
int combinedId = byteBuffer.getInt(pos);
|
||||
task.run(index++, combinedId);
|
||||
}
|
||||
}
|
||||
@ -360,7 +358,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
|
||||
@Override
|
||||
public void forEach(final BlockReader task, boolean air) {
|
||||
mbb.force();
|
||||
byteBuffer.force();
|
||||
int pos = HEADER_SIZE;
|
||||
IntegerTrio trio = new IntegerTrio();
|
||||
final boolean hasTile = !nbtMap.isEmpty();
|
||||
@ -369,7 +367,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
for (int x = 0; x < width; x++, pos += 4) {
|
||||
int combinedId = mbb.getInt(pos);
|
||||
int combinedId = byteBuffer.getInt(pos);
|
||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||
BlockState state = type.withStateId(combinedId);
|
||||
if (type.getMaterial().hasContainer()) {
|
||||
@ -388,7 +386,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
for (int x = 0; x < width; x++, pos += 4) {
|
||||
int combinedId = mbb.getInt(pos);
|
||||
int combinedId = byteBuffer.getInt(pos);
|
||||
BlockState state = BlockState.getFromInternalId(combinedId);
|
||||
task.run(x, y, z, state);
|
||||
}
|
||||
@ -399,7 +397,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
for (int x = 0; x < width; x++, pos += 4) {
|
||||
int combinedId = mbb.getInt(pos);
|
||||
int combinedId = byteBuffer.getInt(pos);
|
||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||
if (!type.getMaterial().isAir()) {
|
||||
BlockState state = type.withStateId(combinedId);
|
||||
@ -427,7 +425,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
public BaseBlock getBlock(int x, int y, int z) {
|
||||
try {
|
||||
int index = HEADER_SIZE + (getIndex(x, y, z) << 2);
|
||||
int combinedId = mbb.getInt(index);
|
||||
int combinedId = byteBuffer.getInt(index);
|
||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
||||
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
||||
@ -440,7 +438,6 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
} catch (IndexOutOfBoundsException ignore) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
}
|
||||
@ -449,7 +446,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
public BaseBlock getBlock(int i) {
|
||||
try {
|
||||
int diskIndex = (HEADER_SIZE) + (i << 2);
|
||||
int combinedId = mbb.getInt(diskIndex);
|
||||
int combinedId = byteBuffer.getInt(diskIndex);
|
||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
||||
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
||||
@ -499,7 +496,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
try {
|
||||
int index = (HEADER_SIZE) + ((getIndex(x, y, z) << 2));
|
||||
int combined = block.getInternalId();
|
||||
mbb.putInt(index, combined);
|
||||
byteBuffer.putInt(index, combined);
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
if (hasNbt) {
|
||||
setTile(x, y, z, block.getNbtData());
|
||||
@ -516,7 +513,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
try {
|
||||
int combined = block.getInternalId();
|
||||
int index = (HEADER_SIZE) + (i << 2);
|
||||
mbb.putInt(index, combined);
|
||||
byteBuffer.putInt(index, combined);
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
if (hasNbt) {
|
||||
int y = i / area;
|
||||
|
@ -2,27 +2,24 @@ package com.boydti.fawe.object.clipboard;
|
||||
|
||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public abstract class FaweClipboard {
|
||||
public abstract BaseBlock getBlock(int x, int y, int z);
|
||||
@ -66,8 +63,8 @@ public abstract class FaweClipboard {
|
||||
*/
|
||||
public abstract void forEach(BlockReader task, boolean air);
|
||||
|
||||
public static abstract class BlockReader {
|
||||
public abstract <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block);
|
||||
public interface BlockReader {
|
||||
<B extends BlockStateHolder<B>> void run(int x, int y, int z, B block);
|
||||
}
|
||||
|
||||
public abstract void streamBiomes(final NBTStreamer.ByteReader task);
|
||||
@ -86,7 +83,6 @@ public abstract class FaweClipboard {
|
||||
public List<CompoundTag> getTileEntities() {
|
||||
final List<CompoundTag> tiles = new ArrayList<>();
|
||||
forEach(new BlockReader() {
|
||||
private int index = 0;
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
|
||||
|
@ -1,23 +1,21 @@
|
||||
package com.boydti.fawe.object.clipboard;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||
import com.boydti.fawe.object.IntegerTrio;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -31,9 +29,9 @@ import java.util.Map;
|
||||
|
||||
public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
|
||||
public static final int BLOCK_SIZE = 1048576 * 4;
|
||||
public static final int BLOCK_MASK = 1048575;
|
||||
public static final int BLOCK_SHIFT = 20;
|
||||
private static final int BLOCK_SIZE = 1048576 * 4;
|
||||
private static final int BLOCK_MASK = 1048575;
|
||||
private static final int BLOCK_SHIFT = 20;
|
||||
|
||||
private int length;
|
||||
private int height;
|
||||
@ -341,9 +339,9 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
||||
int combinedId = block.getInternalId();
|
||||
setCombinedId(index, combinedId);
|
||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
if (hasNbt) {
|
||||
setTile(index, ((BaseBlock)block).getNbtData());
|
||||
setTile(index, block.getNbtData());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.boydti.fawe.object.clipboard;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class OffsetFaweClipboard extends AbstractDelegateFaweClipboard {
|
||||
|
@ -1,17 +1,15 @@
|
||||
package com.boydti.fawe.object.clipboard;
|
||||
|
||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -79,22 +79,19 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
||||
if (region instanceof CuboidRegion) {
|
||||
if (air) {
|
||||
((CuboidRegion) region).setUseOldIterator(true);
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 pos) throws WorldEditException {
|
||||
BaseBlock block = getBlockAbs(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
int x = pos.getBlockX() - mx;
|
||||
int y = pos.getBlockY() - my;
|
||||
int z = pos.getBlockZ() - mz;
|
||||
if (block.hasNbtData()) {
|
||||
Map<String, Tag> values = ReflectionUtils.getMap(block.getNbtData().getValue());
|
||||
values.put("x", new IntTag(x));
|
||||
values.put("y", new IntTag(y));
|
||||
values.put("z", new IntTag(z));
|
||||
}
|
||||
task.run(x, y, z, block);
|
||||
return true;
|
||||
RegionVisitor visitor = new RegionVisitor(region, pos1 -> {
|
||||
BaseBlock block = getBlockAbs(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ());
|
||||
int x = pos1.getBlockX() - mx;
|
||||
int y = pos1.getBlockY() - my;
|
||||
int z = pos1.getBlockZ() - mz;
|
||||
if (block.hasNbtData()) {
|
||||
Map<String, Tag> values = ReflectionUtils.getMap(block.getNbtData().getValue());
|
||||
values.put("x", new IntTag(x));
|
||||
values.put("y", new IntTag(y));
|
||||
values.put("z", new IntTag(z));
|
||||
}
|
||||
task.run(x, y, z, block);
|
||||
return true;
|
||||
}, extent instanceof EditSession ? (EditSession) extent : null);
|
||||
Operations.completeBlindly(visitor);
|
||||
} else {
|
||||
@ -107,7 +104,6 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
||||
int y = pos.getBlockY() - my;
|
||||
int z = pos.getBlockZ() - mz;
|
||||
if (region.contains(pos)) {
|
||||
// BlockState block = getBlockAbs(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
BaseBlock block = extent.getFullBlock(pos);
|
||||
if (block.hasNbtData()) {
|
||||
Map<String, Tag> values = ReflectionUtils.getMap(block.getNbtData().getValue());
|
||||
@ -118,9 +114,8 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
||||
if (!block.getBlockType().getMaterial().isAir()) {
|
||||
task.run(x, y, z, block);
|
||||
}
|
||||
} else {
|
||||
// task.run(x, y, z, EditSession.nullBlock);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}, extent instanceof EditSession ? (EditSession) extent : null);
|
||||
|
@ -25,6 +25,7 @@ public class WorldCutClipboard extends WorldCopyClipboard {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlockAbs(int x, int y, int z) {
|
||||
BaseBlock block = extent.getFullBlock(BlockVector3.at(x, y, z));
|
||||
extent.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
|
||||
|
@ -1,72 +0,0 @@
|
||||
package com.boydti.fawe.object.clipboard.remap;
|
||||
|
||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||
import com.boydti.fawe.object.clipboard.AbstractDelegateFaweClipboard;
|
||||
import com.boydti.fawe.object.clipboard.FaweClipboard;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
// TODO FIXME
|
||||
public class RemappedClipboard extends AbstractDelegateFaweClipboard {
|
||||
private final ClipboardRemapper remapper;
|
||||
|
||||
public RemappedClipboard(FaweClipboard parent, ClipboardRemapper remapper) {
|
||||
super(parent);
|
||||
this.remapper = remapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlock(int x, int y, int z) {
|
||||
return remapper.remap(super.getBlock(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlock(int index) {
|
||||
return remapper.remap(super.getBlock(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(BlockReader task, boolean air) {
|
||||
super.forEach(new BlockReader() {
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
|
||||
task.run(x, y, z, remapper.remap(block));
|
||||
}
|
||||
}, air);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void streamCombinedIds(NBTStreamer.ByteReader task) {
|
||||
super.streamCombinedIds(task);
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void streamIds(NBTStreamer.ByteReader task) {
|
||||
// super.streamIds(new NBTStreamer.ByteReader() {
|
||||
// @Override
|
||||
// public void run(int index, int byteValue) {
|
||||
// if (remapper.hasRemapId(byteValue)) {
|
||||
// int result = remapper.remapId(byteValue);
|
||||
// if (result != byteValue) {
|
||||
// task.run(index, result);
|
||||
// } else {
|
||||
// task.run(index, getBlock(index).getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void streamDatas(NBTStreamer.ByteReader task) {
|
||||
// super.streamDatas(new NBTStreamer.ByteReader() {
|
||||
// @Override
|
||||
// public void run(int index, int byteValue) {
|
||||
// if (remapper.hasRemapData(byteValue)) {
|
||||
// task.run(index, getBlock(index).getData());
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
@ -2,14 +2,18 @@ package com.boydti.fawe.object.clipboard.remap;
|
||||
|
||||
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -23,7 +27,7 @@ public class WikiScraper {
|
||||
Wiki(String url) {this.url = url;}
|
||||
}
|
||||
|
||||
private Map<Wiki, Map<String, Integer>> cache = new HashMap<>();
|
||||
private EnumMap<Wiki, Map<String, Integer>> cache = new EnumMap<>(WikiScraper.Wiki.class);
|
||||
|
||||
public Map<String, Integer> expand(Map<String, Integer> map) {
|
||||
HashMap<String, Integer> newMap = new HashMap<>(map);
|
||||
@ -50,8 +54,8 @@ public class WikiScraper {
|
||||
String str = Resources.toString(file.toURL(), Charset.defaultCharset());
|
||||
return gson.fromJson(str, new TypeToken<Map<String, Integer>>() {
|
||||
}.getType());
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
} catch (JsonSyntaxException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
map = scrape(wiki);
|
||||
@ -94,15 +98,15 @@ public class WikiScraper {
|
||||
return map;
|
||||
} else {
|
||||
String header = wiki == Wiki.ITEM_MAPPINGS_PE ? "=== Item IDs ===" : "{{";
|
||||
String footer = "{{-}}";
|
||||
String prefix = "{{id table|";
|
||||
|
||||
int headerIndex = text.indexOf(header);
|
||||
if (headerIndex == -1) return map;
|
||||
String footer = "{{-}}";
|
||||
int endIndex = text.indexOf(footer, headerIndex);
|
||||
String part = text.substring(headerIndex, endIndex == -1 ? text.length() : endIndex);
|
||||
|
||||
int id = 255;
|
||||
String prefix = "{{id table|";
|
||||
for (String line : part.split("\n")) {
|
||||
String lower = line.toLowerCase();
|
||||
if (lower.startsWith(prefix)) {
|
||||
|
@ -12,7 +12,7 @@ public class FastRandomCollection<T> extends RandomCollection<T> {
|
||||
super(weights, random);
|
||||
int max = 0;
|
||||
int[] counts = new int[weights.size()];
|
||||
Double[] weightDoubles = weights.values().toArray(new Double[weights.size()]);
|
||||
Double[] weightDoubles = weights.values().toArray(new Double[0]);
|
||||
for (int i = 0; i < weightDoubles.length; i++) {
|
||||
int weight = (int) (weightDoubles[i] * 100);
|
||||
counts[i] = weight;
|
||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.object.collection;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@ -209,25 +210,16 @@ public class LocalBlockVector2DSet implements Set<BlockVector2> {
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
for (Object o : c) {
|
||||
if (!contains(o)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return c.stream().allMatch(this::contains);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends BlockVector2> c) {
|
||||
boolean result = false;
|
||||
for (BlockVector2 v : c) {
|
||||
result |= add(v);
|
||||
}
|
||||
return result;
|
||||
return c.stream().map(this::add).reduce(false, (a, b) -> a || b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
public boolean retainAll(@NotNull Collection<?> c) {
|
||||
boolean result = false;
|
||||
int size = size();
|
||||
int index = -1;
|
||||
@ -246,27 +238,7 @@ public class LocalBlockVector2DSet implements Set<BlockVector2> {
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
boolean result = false;
|
||||
for (Object o : c) {
|
||||
result |= remove(o);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void forEach(BlockVector2DSetVisitor visitor) {
|
||||
int size = size();
|
||||
int index = -1;
|
||||
for (int i = 0; i < size; i++) {
|
||||
index = set.nextSetBit(index + 1);
|
||||
int x = MathMan.unpairSearchCoordsX(index);
|
||||
int y = MathMan.unpairSearchCoordsY(index);
|
||||
mutable.setComponents(x, y);
|
||||
visitor.run(x, y, index);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class BlockVector2DSetVisitor {
|
||||
public abstract void run(int x, int y, int index);
|
||||
return c.stream().map(this::remove).reduce(false, (a, b) -> a || b);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -322,8 +322,8 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class BlockVectorSetVisitor {
|
||||
public abstract void run(int x, int y, int z, int index);
|
||||
public interface BlockVectorSetVisitor {
|
||||
void run(int x, int y, int z, int index);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,7 +28,7 @@ public class MultiTransform extends RandomTransform {
|
||||
@Override
|
||||
public void add(ResettableExtent extent, double chance) {
|
||||
super.add(extent, chance);
|
||||
this.extents = getExtents().toArray(new ResettableExtent[getExtents().size()]);
|
||||
this.extents = getExtents().toArray(new ResettableExtent[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,9 +3,8 @@ package com.boydti.fawe.object.extent;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -15,6 +14,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -41,7 +41,7 @@ public class NullExtent extends FaweRegionExtent {
|
||||
super(new com.sk89q.worldedit.extent.NullExtent(), FaweLimit.MAX);
|
||||
this.reason = BBC.WORLDEDIT_CANCEL_REASON_MANUAL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResettableExtent setExtent(Extent extent) {
|
||||
return this;
|
||||
@ -49,74 +49,66 @@ public class NullExtent extends FaweRegionExtent {
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(final BlockVector2 arg0) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return null;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(final BlockVector3 arg0) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return null;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(final BlockVector3 arg0) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return null;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final BlockVector2 arg0, final BiomeType arg1) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return false;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(final BlockVector3 arg0, final BlockStateHolder arg1) throws WorldEditException {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return false;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return false;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return null;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return null;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,30 +123,28 @@ public class NullExtent extends FaweRegionExtent {
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return BlockVector3.at(0, 0, 0);
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return BlockVector3.at(0, 0, 0);
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int x, int z) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return false;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int x, int y, int z) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return false;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,11 +152,6 @@ public class NullExtent extends FaweRegionExtent {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Operation commitBefore() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Operation commit() {
|
||||
@ -175,29 +160,26 @@ public class NullExtent extends FaweRegionExtent {
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return -1;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return -1;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
return -1;
|
||||
if (reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,23 +3,21 @@ package com.boydti.fawe.object.extent;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
private final FaweLimit limit;
|
||||
private final AbstractDelegateExtent extent;
|
||||
@ -46,21 +44,6 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
return super.createEntity(location, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(final BlockVector2 position) {
|
||||
return super.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
return super.getEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(final Region region) {
|
||||
return super.getEntities(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
if (!limit.MAX_CHECKS()) {
|
||||
|
@ -30,7 +30,7 @@ public class StripNBTExtent extends AbstractDelegateExtent {
|
||||
*/
|
||||
public StripNBTExtent(Extent extent, Set<String> strip) {
|
||||
super(extent);
|
||||
this.strip = strip.toArray(new String[strip.size()]);
|
||||
this.strip = strip.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,7 +60,7 @@ public class StripNBTExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
return (B) localBlock;
|
||||
}
|
||||
|
||||
|
||||
public <T extends NbtValued> T stripEntityNBT(T entity) {
|
||||
if (!entity.hasNbtData()) return entity;
|
||||
CompoundTag nbt = entity.getNbtData();
|
||||
|
@ -1,13 +1,11 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
|
||||
import java.util.Arrays;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AngleMask extends SolidBlockMask implements ResettableMask {
|
||||
public static double ADJACENT_MOD = 0.5;
|
||||
@ -160,9 +158,4 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
|
||||
return testSlope(x, y, z);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,4 @@ public class BlockLightMask extends AbstractExtentMask {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.boydti.fawe.object.extent.LightingExtent;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BrightnessMask extends AbstractExtentMask {
|
||||
|
||||
private final int min, max;
|
||||
@ -28,9 +26,4 @@ public class BrightnessMask extends AbstractExtentMask {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,8 @@ package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DataMask extends AbstractExtentMask implements ResettableMask {
|
||||
|
||||
public DataMask(Extent extent) {
|
||||
@ -31,9 +28,4 @@ public class DataMask extends AbstractExtentMask implements ResettableMask {
|
||||
this.data = -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,9 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class IdDataMask extends AbstractExtentMask implements ResettableMask {
|
||||
private transient int combined = -1;
|
||||
|
||||
@ -31,9 +27,4 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask {
|
||||
this.combined = -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,4 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
|
||||
this.id = -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,4 @@ public class LightMask extends AbstractExtentMask {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,4 @@ public class OpacityMask extends AbstractExtentMask {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -61,9 +61,4 @@ public class PlaneMask extends AbstractMask implements ResettableMask {
|
||||
mode = -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -44,9 +44,4 @@ public class RadiusMask extends AbstractMask implements ResettableMask {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,4 @@ public class SkyLightMask extends AbstractExtentMask {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,9 +88,4 @@ public class SolidPlaneMask extends SolidBlockMask implements ResettableMask {
|
||||
mutable = new MutableBlockVector3();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,4 @@ public class XAxisMask extends AbstractMask implements ResettableMask {
|
||||
this.layer = -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Restricts the
|
||||
*/
|
||||
@ -26,9 +23,4 @@ public class YAxisMask extends AbstractMask implements ResettableMask {
|
||||
this.layer = -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,4 @@ public class ZAxisMask extends AbstractMask implements ResettableMask {
|
||||
this.layer = -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
package com.boydti.fawe.object.pattern;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class PatternExtent extends AbstractPattern implements Extent {
|
||||
private final Pattern pattern;
|
||||
@ -55,12 +51,6 @@ public class PatternExtent extends AbstractPattern implements Extent {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
BlockStateHolder tmp = pattern.apply(position);
|
||||
@ -116,12 +106,6 @@ public class PatternExtent extends AbstractPattern implements Extent {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Operation commit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
return pattern.apply(position);
|
||||
|
@ -9,18 +9,8 @@ public class ChatProgressTracker extends DefaultProgressTracker {
|
||||
setInterval(getDelay() / 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTask() {
|
||||
super.sendTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneTask() {
|
||||
super.doneTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTile(String title, String sub) {
|
||||
getPlayer().sendMessage(BBC.getPrefix() + title + sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class PolyhedralRegion extends AbstractRegion {
|
||||
|
||||
case 3:
|
||||
// Generate minimal mesh to start from
|
||||
final BlockVector3[] v = vertices.toArray(new BlockVector3[vertices.size()]);
|
||||
final BlockVector3[] v = vertices.toArray(new BlockVector3[0]);
|
||||
|
||||
triangles.add((new Triangle(v[0], v[size - 2], v[size - 1])));
|
||||
triangles.add((new Triangle(v[0], v[size - 1], v[size - 2])));
|
||||
|
@ -3,18 +3,8 @@ package com.boydti.fawe.object.schematic;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.DoubleTag;
|
||||
import com.sk89q.jnbt.FloatTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.NamedTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
@ -28,14 +18,15 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import com.sk89q.worldedit.world.storage.NBTConversions;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -45,17 +36,17 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
||||
public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
||||
private static final int WARN_SIZE = 32;
|
||||
|
||||
private NBTInputStream in;
|
||||
private NBTInputStream inputStream;
|
||||
private NBTOutputStream out;
|
||||
|
||||
public StructureFormat(NBTInputStream in) {
|
||||
this.in = in;
|
||||
public MinecraftStructure(@NotNull NBTInputStream inputStream) {
|
||||
this.inputStream = inputStream;
|
||||
}
|
||||
|
||||
public StructureFormat(NBTOutputStream out) {
|
||||
public MinecraftStructure(NBTOutputStream out) {
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
@ -65,10 +56,13 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
||||
}
|
||||
|
||||
public Clipboard read(UUID clipboardId) throws IOException {
|
||||
NamedTag rootTag = in.readNamedTag();
|
||||
if (!rootTag.getName().equals("")) {
|
||||
throw new IOException("Root tag does not exist or is not first");
|
||||
NamedTag rootTag = inputStream.readNamedTag();
|
||||
|
||||
// MC structures are all unnamed, but this doesn't seem to be necessary? might remove this later
|
||||
if (!rootTag.getName().isEmpty()) {
|
||||
throw new IOException("Root tag has name - are you sure this is a structure?");
|
||||
}
|
||||
|
||||
Map<String, Tag> tags = ((CompoundTag) rootTag.getTag()).getValue();
|
||||
|
||||
ListTag size = (ListTag) tags.get("size");
|
||||
@ -258,8 +252,8 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
if (out != null) {
|
||||
out.close();
|
@ -1,13 +1,13 @@
|
||||
package com.boydti.fawe.object.visitor;
|
||||
|
||||
public abstract class FaweChunkVisitor {
|
||||
public interface FaweChunkVisitor {
|
||||
/**
|
||||
* The will run for each set block in the chunk
|
||||
*
|
||||
* @param localX The x position in the chunk (0-15)
|
||||
* @param y The y position (0 - 255)
|
||||
* @param localZ The z position in the chunk (0-15)
|
||||
* @param localX The x position in the chunk (0-15)
|
||||
* @param y The y position (0 - 255)
|
||||
* @param localZ The z position in the chunk (0-15)
|
||||
* @param combined The combined id
|
||||
*/
|
||||
public abstract void run(int localX, int y, int localZ, int combined);
|
||||
void run(int localX, int y, int localZ, int combined);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
@ -15,6 +16,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.io.File;
|
||||
@ -26,25 +28,20 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class PlotTrim {
|
||||
private final MCAQueue queue;
|
||||
private final PlotArea area;
|
||||
private final PlotPlayer player;
|
||||
private final MCAQueue originalQueue;
|
||||
private final File root;
|
||||
private final File originalRoot;
|
||||
private int[][] ids;
|
||||
private boolean deleteUnowned = true;
|
||||
private boolean deleteUnowned;
|
||||
|
||||
public PlotTrim(PlotPlayer player, PlotArea area, String worldName, boolean deleteUnowned) {
|
||||
FaweQueue tmpQueue = SetQueue.IMP.getNewQueue(worldName, true, false);
|
||||
File saveFolder = tmpQueue.getSaveFolder();
|
||||
this.root = new File(saveFolder.getParentFile().getParentFile(), worldName + "-Copy" + File.separator + "region");
|
||||
this.originalRoot = saveFolder;
|
||||
this.originalQueue = new MCAQueue(worldName, originalRoot, true);
|
||||
this.originalQueue = new MCAQueue(worldName, saveFolder, true);
|
||||
this.queue = new MCAQueue(worldName + "-Copy", root, true);
|
||||
this.area = area;
|
||||
this.player = player;
|
||||
@ -124,10 +121,7 @@ public class PlotTrim {
|
||||
@Override
|
||||
public boolean appliesFile(int mcaX, int mcaZ) {
|
||||
ChunkLoc loc = new ChunkLoc(mcaX, mcaZ);
|
||||
if (mcas.contains(loc)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !mcas.contains(loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -155,11 +149,6 @@ public class PlotTrim {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesChunk(int cx, int cz) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAChunk applyChunk(MCAChunk chunk, Object ignore) {
|
||||
long pair = MathMan.pairInt(chunk.getX(), chunk.getZ());
|
||||
@ -181,8 +170,6 @@ public class PlotTrim {
|
||||
player.sendMessage("Done!");
|
||||
}
|
||||
|
||||
private int count = 0;
|
||||
|
||||
private boolean isEqual(int[] a, int[] b) {
|
||||
if (a == b) {
|
||||
return true;
|
||||
|
@ -2,7 +2,10 @@ package com.boydti.fawe.wrappers;
|
||||
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.*;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -28,7 +31,6 @@ import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class WorldWrapper extends AbstractWorld {
|
||||
|
||||
@ -99,7 +101,7 @@ public class WorldWrapper extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
||||
return TaskManager.IMP.sync((Supplier<Boolean>) () -> {
|
||||
return TaskManager.IMP.sync(() -> {
|
||||
try {
|
||||
return parent.generateTree(type, editSession, position);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
|
@ -50,9 +50,8 @@ public final class NBTInputStream implements Closeable {
|
||||
* from the specified input stream.
|
||||
*
|
||||
* @param is the input stream
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
public NBTInputStream(InputStream is) throws IOException {
|
||||
public NBTInputStream(InputStream is) {
|
||||
this.is = new DataInputStream(is);
|
||||
}
|
||||
|
||||
@ -152,39 +151,21 @@ public final class NBTInputStream implements Closeable {
|
||||
if (reader instanceof NBTStreamer.ByteReader) {
|
||||
NBTStreamer.ByteReader byteReader = (NBTStreamer.ByteReader) reader;
|
||||
int i = 0;
|
||||
if (is instanceof InputStream) {
|
||||
DataInputStream dis = is;
|
||||
if (length > 1024) {
|
||||
if (buf == null) {
|
||||
buf = new byte[1024];
|
||||
}
|
||||
int left = length;
|
||||
for (; left > 1024; left -= 1024) {
|
||||
dis.readFully(buf);
|
||||
for (byte b : buf) {
|
||||
byteReader.run(i++, b & 0xFF);
|
||||
}
|
||||
DataInputStream dis = is;
|
||||
if (length > 1024) {
|
||||
if (buf == null) {
|
||||
buf = new byte[1024];
|
||||
}
|
||||
int left = length;
|
||||
for (; left > 1024; left -= 1024) {
|
||||
dis.readFully(buf);
|
||||
for (byte b : buf) {
|
||||
byteReader.run(i++, b & 0xFF);
|
||||
}
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
byteReader.run(i, dis.read());
|
||||
}
|
||||
} else {
|
||||
if (length > 1024) {
|
||||
if (buf == null) {
|
||||
buf = new byte[1024];
|
||||
}
|
||||
int left = length;
|
||||
for (; left > 1024; left -= 1024) {
|
||||
is.readFully(buf);
|
||||
for (byte b : buf) {
|
||||
byteReader.run(i++, b & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
byteReader.run(i, is.readByte() & 0xFF);
|
||||
}
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
byteReader.run(i, dis.read());
|
||||
}
|
||||
} else if (reader instanceof NBTStreamer.LazyReader) {
|
||||
reader.accept(length, is);
|
||||
@ -382,7 +363,7 @@ public final class NBTInputStream implements Closeable {
|
||||
int toRead = Math.min(length << 2, buf.length);
|
||||
is.readFully(buf, 0, toRead);
|
||||
for (int i = 0; i < toRead; i += 4, index++) {
|
||||
data[index] = ((buf[i + 0] & 0xFF) << 24) + ((buf[i + 1] & 0xFF) << 16) + ((buf[i + 2] & 0xFF) << 8) + (buf[i + 3] & 0xFF);
|
||||
data[index] = ((buf[i] & 0xFF) << 24) + ((buf[i + 1] & 0xFF) << 16) + ((buf[i + 2] & 0xFF) << 8) + (buf[i + 3] & 0xFF);
|
||||
}
|
||||
length -= toRead;
|
||||
}
|
||||
@ -583,7 +564,7 @@ public final class NBTInputStream implements Closeable {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (is instanceof AutoCloseable) {
|
||||
if (is != null) {
|
||||
try {
|
||||
((AutoCloseable) is).close();
|
||||
} catch (Exception e) {
|
||||
|
@ -131,6 +131,7 @@ import com.sk89q.worldedit.regions.shape.RegionShape;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.world.SimpleWorld;
|
||||
@ -149,6 +150,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -377,7 +379,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
} else {
|
||||
this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
||||
if (allowedRegions.length == 1) {
|
||||
Region region = allowedRegions[0];
|
||||
this.extent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
|
||||
} else {
|
||||
this.extent = new MultiRegionExtent(this.extent, this.limit, allowedRegions);
|
||||
@ -417,7 +418,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
|
||||
public void resetLimit() {
|
||||
this.limit.set(this.originalLimit);
|
||||
ExtentTraverser<ProcessedWEExtent> find = new ExtentTraverser(extent).find(ProcessedWEExtent.class);
|
||||
ExtentTraverser<ProcessedWEExtent> find = new ExtentTraverser<>(extent).find(ProcessedWEExtent.class);
|
||||
if (find != null && find.get() != null) {
|
||||
find.get().setLimit(this.limit);
|
||||
}
|
||||
@ -456,7 +457,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return FaweRegionExtent (may be null)
|
||||
*/
|
||||
public FaweRegionExtent getRegionExtent() {
|
||||
ExtentTraverser<FaweRegionExtent> traverser = new ExtentTraverser(this.extent).find(FaweRegionExtent.class);
|
||||
ExtentTraverser<FaweRegionExtent> traverser = new ExtentTraverser<>(this.extent).find(FaweRegionExtent.class);
|
||||
return traverser == null ? null : traverser.get();
|
||||
}
|
||||
|
||||
@ -740,7 +741,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return mask, may be null
|
||||
*/
|
||||
public Mask getMask() {
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser<>(this.extent).find(MaskingExtent.class);
|
||||
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||
}
|
||||
|
||||
@ -750,30 +751,29 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return mask, may be null
|
||||
*/
|
||||
public Mask getSourceMask() {
|
||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser(this.extent).find(SourceMaskExtent.class);
|
||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser<>(this.extent).find(SourceMaskExtent.class);
|
||||
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||
}
|
||||
|
||||
public void addTransform(ResettableExtent transform) {
|
||||
wrapped = true;
|
||||
if (transform == null) {
|
||||
ExtentTraverser<AbstractDelegateExtent> traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
|
||||
ExtentTraverser<ResettableExtent> traverser = new ExtentTraverser<>(this.extent).find(ResettableExtent.class);
|
||||
AbstractDelegateExtent next = extent;
|
||||
while (traverser != null && traverser.get() instanceof ResettableExtent) {
|
||||
while (traverser != null && traverser.get() != null) {
|
||||
traverser = traverser.next();
|
||||
next = traverser.get();
|
||||
}
|
||||
this.extent = next;
|
||||
return;
|
||||
} else {
|
||||
this.extent = transform.setExtent(extent);
|
||||
}
|
||||
}
|
||||
|
||||
public @Nullable ResettableExtent getTransform() {
|
||||
ExtentTraverser<AbstractDelegateExtent> traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
|
||||
ExtentTraverser<ResettableExtent> traverser = new ExtentTraverser<>(this.extent).find(ResettableExtent.class);
|
||||
if (traverser != null) {
|
||||
return (ResettableExtent) traverser.get();
|
||||
return traverser.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -789,7 +789,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
} else {
|
||||
new MaskTraverser(mask).reset(this);
|
||||
}
|
||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser(this.extent).find(SourceMaskExtent.class);
|
||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser<>(this.extent).find(SourceMaskExtent.class);
|
||||
if (maskingExtent != null && maskingExtent.get() != null) {
|
||||
Mask oldMask = maskingExtent.get().getMask();
|
||||
if (oldMask instanceof ResettableMask) {
|
||||
@ -828,7 +828,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
} else {
|
||||
new MaskTraverser(mask).reset(this);
|
||||
}
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser<>(this.extent).find(MaskingExtent.class);
|
||||
if (maskingExtent != null && maskingExtent.get() != null) {
|
||||
Mask oldMask = maskingExtent.get().getMask();
|
||||
if (oldMask instanceof ResettableMask) {
|
||||
@ -846,13 +846,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return the survival simulation extent
|
||||
*/
|
||||
public SurvivalModeExtent getSurvivalExtent() {
|
||||
ExtentTraverser<SurvivalModeExtent> survivalExtent = new ExtentTraverser(this.extent).find(SurvivalModeExtent.class);
|
||||
ExtentTraverser<SurvivalModeExtent> survivalExtent = new ExtentTraverser<>(this.extent).find(SurvivalModeExtent.class);
|
||||
if (survivalExtent != null) {
|
||||
return survivalExtent.get();
|
||||
} else {
|
||||
AbstractDelegateExtent extent = this.extent;
|
||||
SurvivalModeExtent survival = new SurvivalModeExtent(extent.getExtent(), getWorld());
|
||||
new ExtentTraverser(extent).setNext(survival);
|
||||
new ExtentTraverser<>(extent).setNext(survival);
|
||||
return survival;
|
||||
}
|
||||
}
|
||||
@ -879,21 +879,21 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
if (history == null) {
|
||||
return;
|
||||
}
|
||||
ExtentTraverser traverseHistory = new ExtentTraverser(this.extent).find(HistoryExtent.class);
|
||||
ExtentTraverser<HistoryExtent> traverseHistory = new ExtentTraverser<>(this.extent).find(HistoryExtent.class);
|
||||
if (disableHistory) {
|
||||
if (traverseHistory != null && traverseHistory.exists()) {
|
||||
ExtentTraverser beforeHistory = traverseHistory.previous();
|
||||
ExtentTraverser afterHistory = traverseHistory.next();
|
||||
ExtentTraverser<HistoryExtent> beforeHistory = traverseHistory.previous();
|
||||
ExtentTraverser<HistoryExtent> afterHistory = traverseHistory.next();
|
||||
if (beforeHistory != null && beforeHistory.exists()) {
|
||||
beforeHistory.setNext(afterHistory.get());
|
||||
} else {
|
||||
extent = (AbstractDelegateExtent) afterHistory.get();
|
||||
extent = afterHistory.get();
|
||||
}
|
||||
}
|
||||
} else if (traverseHistory == null || !traverseHistory.exists()) {
|
||||
ExtentTraverser traverseBypass = new ExtentTraverser(this.extent).find(bypassHistory);
|
||||
ExtentTraverser<AbstractDelegateExtent> traverseBypass = new ExtentTraverser<>(this.extent).find(bypassHistory);
|
||||
if (traverseBypass != null) {
|
||||
ExtentTraverser beforeHistory = traverseBypass.previous();
|
||||
ExtentTraverser<AbstractDelegateExtent> beforeHistory = traverseBypass.previous();
|
||||
beforeHistory.setNext(history);
|
||||
}
|
||||
}
|
||||
@ -940,19 +940,19 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
*
|
||||
* @return a map of missing blocks
|
||||
*/
|
||||
public Map<com.sk89q.worldedit.world.block.BlockType, Integer> popMissingBlocks() {
|
||||
public Map<BlockType, Integer> popMissingBlocks() {
|
||||
BlockBag bag = getBlockBag();
|
||||
if (bag != null) {
|
||||
bag.flushChanges();
|
||||
|
||||
Map<com.sk89q.worldedit.world.block.BlockType, Integer> missingBlocks;
|
||||
Map<BlockType, Integer> missingBlocks;
|
||||
ChangeSet changeSet = getChangeSet();
|
||||
|
||||
|
||||
if (changeSet instanceof BlockBagChangeSet) {
|
||||
missingBlocks = ((BlockBagChangeSet) changeSet).popMissing();
|
||||
} else {
|
||||
ExtentTraverser<BlockBagExtent> find = new ExtentTraverser(extent).find(BlockBagExtent.class);
|
||||
ExtentTraverser<BlockBagExtent> find = new ExtentTraverser<>(extent).find(BlockBagExtent.class);
|
||||
if (find != null && find.get() != null) {
|
||||
missingBlocks = find.get().popMissing();
|
||||
} else {
|
||||
@ -1228,7 +1228,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean setBlock(final BlockVector3 position, final Pattern pattern) {
|
||||
this.changes++;
|
||||
try {
|
||||
@ -1238,7 +1237,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int setBlocks(final Set<BlockVector3> vset, final Pattern pattern) {
|
||||
RegionVisitor visitor = new RegionVisitor(vset, new BlockReplace(extent, pattern), this);
|
||||
Operations.completeBlindly(visitor);
|
||||
@ -1276,7 +1274,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity createEntity(com.sk89q.worldedit.util.Location location, final BaseEntity entity) {
|
||||
public Entity createEntity(Location location, final BaseEntity entity) {
|
||||
return this.extent.createEntity(location, entity);
|
||||
}
|
||||
|
||||
@ -1407,7 +1405,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
if (used.MAX_FAILS > 0) {
|
||||
if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) {
|
||||
BBC.WORLDEDIT_SOME_FAILS.send(player, used.MAX_FAILS);
|
||||
} else if (new ExtentTraverser(this).findAndGet(FaweRegionExtent.class) != null){
|
||||
} else if (new ExtentTraverser<>(this).findAndGet(FaweRegionExtent.class) != null){
|
||||
BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION.send(player);
|
||||
} else {
|
||||
BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_LEVEL.send(player);
|
||||
@ -1447,12 +1445,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
if (searchIDs.size() == 1) {
|
||||
final BlockType id = searchIDs.iterator().next();
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return getBlockType(position) == id;
|
||||
}
|
||||
}, this);
|
||||
RegionVisitor visitor = new RegionVisitor(region, position -> getBlockType(position) == id, this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
@ -1464,23 +1457,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
|
||||
public int countBlock(final Region region, final boolean[] ids) {
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return ids[getBlockType(position).getInternalId()];
|
||||
}
|
||||
}, this);
|
||||
RegionVisitor visitor = new RegionVisitor(region, position -> ids[getBlockType(position).getInternalId()], this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
|
||||
public int countBlock(final Region region, final Mask mask) {
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return mask.test(position);
|
||||
}
|
||||
}, this);
|
||||
RegionVisitor visitor = new RegionVisitor(region, mask::test, this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
@ -1494,12 +1477,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
*/
|
||||
public int countBlocks(Region region, Set<BlockStateHolder> searchBlocks) {
|
||||
Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(extent);
|
||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
return mask.test(position);
|
||||
}
|
||||
}, this);
|
||||
RegionVisitor visitor = new RegionVisitor(region, mask::test, this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return visitor.getAffected();
|
||||
}
|
||||
@ -1509,30 +1487,27 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
final int startPerformY = region.getMinimumPoint().getBlockY();
|
||||
final int startCheckY = fullHeight ? 0 : startPerformY;
|
||||
final int endY = region.getMaximumPoint().getBlockY();
|
||||
RegionVisitor visitor = new RegionVisitor(flat, new RegionFunction() {
|
||||
@Override
|
||||
public boolean apply(BlockVector3 pos) throws WorldEditException {
|
||||
int x = pos.getBlockX();
|
||||
int z = pos.getBlockZ();
|
||||
int freeSpot = startCheckY;
|
||||
for (int y = startCheckY; y <= endY; y++) {
|
||||
if (y < startPerformY) {
|
||||
if (!getBlockType(x, y, z).getMaterial().isAir()) {
|
||||
freeSpot = y + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
BlockType block = getBlockType(x, y, z);
|
||||
if (!block.getMaterial().isAir()) {
|
||||
if (freeSpot != y) {
|
||||
setBlock(x, freeSpot, z, block);
|
||||
setBlock(x, y, z, replace);
|
||||
}
|
||||
freeSpot++;
|
||||
RegionVisitor visitor = new RegionVisitor(flat, pos -> {
|
||||
int x = pos.getBlockX();
|
||||
int z = pos.getBlockZ();
|
||||
int freeSpot = startCheckY;
|
||||
for (int y = startCheckY; y <= endY; y++) {
|
||||
if (y < startPerformY) {
|
||||
if (!getBlockType(x, y, z).getMaterial().isAir()) {
|
||||
freeSpot = y + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
BlockType block = getBlockType(x, y, z);
|
||||
if (!block.getMaterial().isAir()) {
|
||||
if (freeSpot != y) {
|
||||
setBlock(x, freeSpot, z, block);
|
||||
setBlock(x, y, z, replace);
|
||||
}
|
||||
freeSpot++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}, this);
|
||||
Operations.completeBlindly(visitor);
|
||||
return this.changes;
|
||||
@ -1813,7 +1788,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* returned by a given pattern.
|
||||
*
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param filter a list of block types to match, or null to use {@link ExistingBlockMask}
|
||||
* @param replacement the replacement block
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
@ -1827,7 +1802,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* returned by a given pattern.
|
||||
*
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param filter a list of block types to match, or null to use {@link ExistingBlockMask}
|
||||
* @param pattern the pattern that provides the new blocks
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
|
@ -1068,7 +1068,7 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (previous != null && player != null && previous instanceof BrushTool) {
|
||||
if (player != null && previous instanceof BrushTool) {
|
||||
BrushTool brushTool = (BrushTool) previous;
|
||||
brushTool.clear(player);
|
||||
}
|
||||
|
@ -36,11 +36,14 @@ import com.boydti.fawe.util.ImgurUtility;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MaskTraverser;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -86,10 +89,6 @@ import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
|
||||
/**
|
||||
* Clipboard commands.
|
||||
@ -132,9 +131,6 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
session.setClipboard(null);
|
||||
final BlockVector3 origin = region.getMinimumPoint();
|
||||
final int mx = origin.getBlockX();
|
||||
final int my = origin.getBlockY();
|
||||
final int mz = origin.getBlockZ();
|
||||
ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(editSession, region, !skipEntities, copyBiomes);
|
||||
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
||||
@ -152,7 +148,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
desc = "Copy the selection to the clipboard",
|
||||
help = "Copy the selection to the clipboard\n" +
|
||||
"Flags:\n" +
|
||||
" -e skips copying entities\n" +
|
||||
" -e will also copy entities\n" +
|
||||
" -m sets a source mask so that excluded blocks become air\n" +
|
||||
" -b copies biomes\n" +
|
||||
"WARNING: Pasting entities cannot yet be undone!",
|
||||
@ -161,7 +157,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.copy")
|
||||
public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region, @Switch('e') boolean skipEntities,
|
||||
@Selection Region region, @Switch('e') boolean copyEntities,
|
||||
@Switch('m') Mask mask, CommandContext context, @Switch('b') boolean copyBiomes) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
@ -173,12 +169,14 @@ public class ClipboardCommands extends MethodCommands {
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
session.setClipboard(null);
|
||||
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||
|
||||
session.setClipboard(new ClipboardHolder(clipboard));
|
||||
|
||||
clipboard.setOrigin(pos);
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||
copy.setCopyingEntities(!skipEntities);
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setCopyBiomes(copyBiomes);
|
||||
Mask sourceMask = editSession.getSourceMask();
|
||||
if (sourceMask != null) {
|
||||
@ -225,9 +223,6 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
session.setClipboard(null);
|
||||
final BlockVector3 origin = region.getMinimumPoint();
|
||||
final int mx = origin.getBlockX();
|
||||
final int my = origin.getBlockY();
|
||||
final int mz = origin.getBlockZ();
|
||||
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||
@ -242,8 +237,8 @@ public class ClipboardCommands extends MethodCommands {
|
||||
desc = "Cut the selection to the clipboard",
|
||||
help = "Copy the selection to the clipboard\n" +
|
||||
"Flags:\n" +
|
||||
" -e skips entity copy\n" +
|
||||
" -m sets a source mask so that excluded blocks become air\n" +
|
||||
" -e will also cut entities\n" +
|
||||
" -m <mask> sets a source mask so that excluded blocks become air\n" +
|
||||
" -b copies biomes\n" +
|
||||
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
||||
max = 1
|
||||
@ -251,7 +246,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.clipboard.cut")
|
||||
@Logging(REGION)
|
||||
public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean skipEntities,
|
||||
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean copyEntities,
|
||||
@Switch('m') Mask mask, @Switch('b') boolean copyBiomes, CommandContext context) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
@ -266,11 +261,13 @@ public class ClipboardCommands extends MethodCommands {
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
fp.checkConfirmationRegion(() -> {
|
||||
session.setClipboard(null);
|
||||
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||
|
||||
clipboard.setOrigin(pos);
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
||||
copy.setCopyingEntities(!skipEntities);
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setRemovingEntities(true);
|
||||
copy.setCopyBiomes(copyBiomes);
|
||||
Mask sourceMask = editSession.getSourceMask();
|
||||
@ -401,7 +398,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions({"worldedit.clipboard.asset"})
|
||||
public void asset(final Player player, final LocalSession session, String category) throws CommandException, WorldEditException {
|
||||
public void asset(final Player player, final LocalSession session, String category) throws WorldEditException {
|
||||
final ClipboardFormat format = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
@ -438,7 +435,6 @@ public class ClipboardCommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "/paste" },
|
||||
usage = "",
|
||||
flags = "saobe",
|
||||
desc = "Paste the clipboard's contents",
|
||||
help =
|
||||
@ -502,7 +498,6 @@ public class ClipboardCommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"/place"},
|
||||
usage = "",
|
||||
flags = "sao",
|
||||
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)",
|
||||
help =
|
||||
@ -578,7 +573,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.flip")
|
||||
public void flip(Player player, LocalSession session,
|
||||
public void flip(Player player, LocalSession session, EditSession editSession,
|
||||
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
AffineTransform transform = new AffineTransform();
|
||||
@ -595,7 +590,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.clear")
|
||||
public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
|
||||
public void clearClipboard(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
|
||||
session.setClipboard(null);
|
||||
BBC.CLIPBOARD_CLEARED.send(player);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import com.boydti.fawe.object.RunnableVal3;
|
||||
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
||||
import com.boydti.fawe.object.schematic.StructureFormat;
|
||||
import com.boydti.fawe.object.schematic.MinecraftStructure;
|
||||
//import com.boydti.fawe.object.schematic.visualizer.SchemVis;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
@ -44,7 +44,6 @@ import com.sk89q.worldedit.event.extent.PlayerSaveClipboardEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
@ -65,7 +64,6 @@ import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||
@ -353,8 +351,8 @@ public class SchematicCommands extends MethodCommands {
|
||||
if (holder instanceof URIClipboardHolder) uri = ((URIClipboardHolder) holder).getURI(clipboard);
|
||||
if (new PlayerSaveClipboardEvent(player, clipboard, uri, f.toURI()).call()) {
|
||||
try (ClipboardWriter writer = format.getWriter(fos)) {
|
||||
if (writer instanceof StructureFormat) {
|
||||
((StructureFormat) writer).write(target, player.getName());
|
||||
if (writer instanceof MinecraftStructure) {
|
||||
((MinecraftStructure) writer).write(target, player.getName());
|
||||
} else {
|
||||
writer.write(target);
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.MaxBrushRadiusException;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
@ -519,7 +521,9 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
||||
double size = current.getSize();
|
||||
WorldEdit.getInstance().checkMaxBrushRadius(size);
|
||||
brush.build(editSession, target, current.getMaterial(), size);
|
||||
} catch (WorldEditException e) {
|
||||
} catch (MaxBrushRadiusException e) {
|
||||
player.printError("Max blocks change limit reached."); // Never happens
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached."); // Never happens
|
||||
} finally {
|
||||
if (bag != null) {
|
||||
|
@ -37,7 +37,6 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -118,7 +117,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
protected void finalize() {
|
||||
close();
|
||||
}
|
||||
|
||||
@ -267,8 +266,6 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getLight(int x, int y, int z) {
|
||||
return getBlockLight(x, y, z);
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
@ -60,7 +61,7 @@ public interface Clipboard extends Extent {
|
||||
|
||||
/**
|
||||
* Returns true if the clipboard has biome data. This can be checked since {@link Extent#getBiome(BlockVector2)}
|
||||
* strongly suggests returning {@link com.sk89q.worldedit.world.biome.BiomeTypes.OCEAN} instead of {@code null}
|
||||
* strongly suggests returning {@link com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null}
|
||||
* if biomes aren't present. However, it might not be desired to set areas to ocean if the clipboard is defaulting
|
||||
* to ocean, instead of having biomes explicitly set.
|
||||
*
|
||||
|
@ -22,7 +22,8 @@ package com.sk89q.worldedit.extent.clipboard.io;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.boydti.fawe.object.io.ResettableFileInputStream;
|
||||
import com.boydti.fawe.object.schematic.PNGWriter;
|
||||
import com.boydti.fawe.object.schematic.StructureFormat;
|
||||
import com.boydti.fawe.object.schematic.MinecraftStructure;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
@ -122,35 +123,41 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||
* The structure block format:
|
||||
* http://minecraft.gamepedia.com/Structure_block_file_format
|
||||
*/
|
||||
STRUCTURE("structure", "nbt") {
|
||||
MINECRAFT_STRUCTURE("structure") {
|
||||
@Override
|
||||
public String getPrimaryFileExtension() {
|
||||
return "nbt";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClipboardReader getReader(InputStream inputStream) throws IOException {
|
||||
inputStream = new BufferedInputStream(inputStream);
|
||||
NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(inputStream)));
|
||||
return new StructureFormat(nbtStream);
|
||||
return new MinecraftStructure(nbtStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClipboardWriter getWriter(OutputStream outputStream) throws IOException {
|
||||
outputStream = new BufferedOutputStream(outputStream);
|
||||
OutputStream gzip;
|
||||
if (outputStream instanceof PGZIPOutputStream || outputStream instanceof GZIPOutputStream) {
|
||||
gzip = outputStream;
|
||||
} else {
|
||||
gzip = new PGZIPOutputStream(outputStream);
|
||||
}
|
||||
OutputStream gzip = new PGZIPOutputStream(outputStream);
|
||||
NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip));
|
||||
return new StructureFormat(nbtStream);
|
||||
return new MinecraftStructure(nbtStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFormat(File file) {
|
||||
return file.getName().toLowerCase().endsWith(".nbt");
|
||||
}
|
||||
try (NBTInputStream str = new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))) {
|
||||
NamedTag rootTag = str.readNamedTag();
|
||||
CompoundTag structureTag = (CompoundTag) rootTag.getTag();
|
||||
Map<String, Tag> structure = structureTag.getValue();
|
||||
if (!structure.containsKey("DataVersion")) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryFileExtension() {
|
||||
return "nbt";
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -29,7 +29,6 @@ import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
@ -40,7 +39,6 @@ import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import static com.sk89q.worldedit.util.Direction.*;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@ -93,19 +91,11 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
private static long[] adapt(Direction... dirs) {
|
||||
long[] arr = new long[dirs.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
arr[i] = 1L << dirs[i].ordinal();
|
||||
}
|
||||
return arr;
|
||||
return Arrays.stream(dirs).mapToLong(dir -> 1L << dir.ordinal()).toArray();
|
||||
}
|
||||
|
||||
private static long[] adapt(Long... dirs) {
|
||||
long[] arr = new long[dirs.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
arr[i] = dirs[i];
|
||||
}
|
||||
return arr;
|
||||
return Arrays.stream(dirs).mapToLong(dir -> dir).toArray();
|
||||
}
|
||||
|
||||
private static long[] getDirections(AbstractProperty property) {
|
||||
@ -219,9 +209,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
private static long notIndex(long mask, int... indexes) {
|
||||
for (int index : indexes) {
|
||||
mask = mask | (1L << (index + values().length));
|
||||
}
|
||||
mask |= Arrays.stream(indexes).mapToLong(index -> (1L << (index + values().length))).reduce(0, (a, b) -> a | b);
|
||||
return mask;
|
||||
}
|
||||
|
||||
@ -388,11 +376,6 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResettableExtent setExtent(Extent extent) {
|
||||
return super.setExtent(extent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transform.
|
||||
*
|
||||
@ -469,7 +452,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
return BlockState.getFromInternalId(newMaskedId);
|
||||
}
|
||||
|
||||
public final BaseBlock transform(BlockStateHolder block) {
|
||||
public final BaseBlock transform(BlockStateHolder<BaseBlock> block) {
|
||||
BlockState transformed = transform(block.toImmutableState());
|
||||
if (block.hasNbtData()) {
|
||||
return transformBaseBlockNBT(transformed, block.getNbtData(), transform);
|
||||
@ -503,11 +486,6 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
return transform(super.getLazyBlock(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return super.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||
return super.setBlock(x, y, z, transformInverse(block));
|
||||
|
@ -20,13 +20,10 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A mask that tests whether a block matches a given {@link BlockCategory}, or tag.
|
||||
*/
|
||||
@ -45,9 +42,4 @@ public class BlockCategoryMask extends AbstractExtentMask {
|
||||
return category.contains(getExtent().getBlock(vector));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -269,10 +268,4 @@ public class BlockMask extends AbstractExtentMask {
|
||||
return FastBitSet.get(bitSet, block.getInternalPropertiesId());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockStateMask extends AbstractExtentMask {
|
||||
@ -62,9 +61,4 @@ public class BlockStateMask extends AbstractExtentMask {
|
||||
.allMatch(entry -> block.getState(entry.getKey()) == entry.getValue());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,11 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -117,9 +114,4 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
// return blocks.contains(getExtent().getBlock(vector).getBlockType());
|
||||
// }
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,8 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Has the criteria where the Y value of passed positions must be within
|
||||
* a certain range of Y values (inclusive).
|
||||
@ -51,10 +48,4 @@ public class BoundedHeightMask extends AbstractMask {
|
||||
return vector.getY() >= minY && vector.getY() <= maxY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ package com.sk89q.worldedit.function.mask;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A mask that returns true whenever the block at the location is not
|
||||
* an air block (it contains some other block).
|
||||
@ -44,10 +42,4 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,12 +20,9 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A mask that tests whether given positions are contained within a region.
|
||||
*/
|
||||
@ -66,10 +63,4 @@ public class RegionMask extends AbstractMask {
|
||||
return region.contains(vector);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,8 +25,6 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SolidBlockMask extends BlockTypeMask {
|
||||
|
||||
public static boolean[] getTypes() {
|
||||
@ -48,10 +46,4 @@ public class SolidBlockMask extends BlockTypeMask {
|
||||
return block.getBlockType().getMaterial().isMovementBlocker();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,7 +74,4 @@ public class MutableVector3 extends Vector3 {
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
@ -309,8 +309,4 @@ public class Location extends Vector3 {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.file.Path;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
/**
|
||||
@ -56,6 +57,10 @@ public abstract class AbstractWorld implements World {
|
||||
return setBlock(pt, block, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getStoragePath() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return getMaximumPoint().getBlockY();
|
||||
|
@ -20,29 +20,29 @@
|
||||
package com.sk89q.worldedit.world;
|
||||
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.sk89q.worldedit.*;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.block.*;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* An abstract implementation of {@link World}.
|
||||
@ -67,6 +67,10 @@ public interface SimpleWorld extends World {
|
||||
@Override
|
||||
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pt, B block) throws WorldEditException;
|
||||
|
||||
@Nullable @Override default Path getStoragePath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
default int getMaxY() {
|
||||
return getMaximumPoint().getBlockY();
|
||||
@ -117,11 +121,6 @@ public interface SimpleWorld extends World {
|
||||
return BlockVector3.at(30000000, 255, 30000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
default @Nullable Operation commit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
default boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
||||
|
@ -38,6 +38,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Represents a world (dimension).
|
||||
*/
|
||||
@ -50,11 +53,21 @@ public interface World extends Extent {
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Get the folder in which this world is stored. May return null if unknown
|
||||
* or if this world is not serialized to disk.
|
||||
*
|
||||
* @return world storage path
|
||||
*/
|
||||
@Nullable
|
||||
Path getStoragePath();
|
||||
|
||||
/**
|
||||
* Get the maximum Y.
|
||||
*
|
||||
* @return the maximum Y
|
||||
*/
|
||||
@Override
|
||||
int getMaxY();
|
||||
|
||||
/**
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren