geforkt von Mirrors/FastAsyncWorldEdit
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.entity.Entity;
|
||||||
import org.bukkit.inventory.DoubleChestInventory;
|
import org.bukkit.inventory.DoubleChestInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -154,6 +156,11 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
return getWorld().getName();
|
return getWorld().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path getStoragePath() {
|
||||||
|
return getWorld().getWorldFolder().toPath();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockLightLevel(BlockVector3 pt) {
|
public int getBlockLightLevel(BlockVector3 pt) {
|
||||||
return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel();
|
return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel();
|
||||||
@ -239,11 +246,11 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BlockState state = block.getState();
|
BlockState state = block.getState();
|
||||||
if (!(state instanceof org.bukkit.inventory.InventoryHolder)) {
|
if (!(state instanceof InventoryHolder)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state;
|
InventoryHolder chest = (InventoryHolder) state;
|
||||||
Inventory inven = chest.getInventory();
|
Inventory inven = chest.getInventory();
|
||||||
if (chest instanceof Chest) {
|
if (chest instanceof Chest) {
|
||||||
inven = getBlockInventory((Chest) 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.TaskManager;
|
||||||
import com.boydti.fawe.util.WEManager;
|
import com.boydti.fawe.util.WEManager;
|
||||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
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.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.AbstractWorld;
|
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The FaweAPI class offers a few useful functions.<br>
|
* The FaweAPI class offers a few useful functions.<br>
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package com.boydti.fawe;
|
package com.boydti.fawe;
|
||||||
|
|
||||||
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
||||||
|
|
||||||
import com.sk89q.jnbt.*;
|
import com.sk89q.jnbt.*;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
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 class FaweCache {
|
||||||
public static final IterableThreadLocal<int[]> BLOCK_TO_PALETTE = new IterableThreadLocal<int[]>() {
|
public static final IterableThreadLocal<int[]> BLOCK_TO_PALETTE = new IterableThreadLocal<int[]>() {
|
||||||
@ -115,7 +120,7 @@ public class FaweCache {
|
|||||||
} else if (value instanceof String) {
|
} else if (value instanceof String) {
|
||||||
return asTag((String) value);
|
return asTag((String) value);
|
||||||
} else if (value instanceof Map) {
|
} else if (value instanceof Map) {
|
||||||
return asTag((Map) value);
|
return asTag((Map<String, Object>) value);
|
||||||
} else if (value instanceof Collection) {
|
} else if (value instanceof Collection) {
|
||||||
return asTag((Collection) value);
|
return asTag((Collection) value);
|
||||||
} else if (value instanceof Object[]) {
|
} else if (value instanceof Object[]) {
|
||||||
@ -153,7 +158,7 @@ public class FaweCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ListTag asTag(Object... values) {
|
public static ListTag asTag(Object... values) {
|
||||||
Class clazz = null;
|
Class<? extends Tag> clazz = null;
|
||||||
List<Tag> list = new ArrayList<>(values.length);
|
List<Tag> list = new ArrayList<>(values.length);
|
||||||
for (Object value : values) {
|
for (Object value : values) {
|
||||||
Tag tag = asTag(value);
|
Tag tag = asTag(value);
|
||||||
@ -167,7 +172,7 @@ public class FaweCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ListTag asTag(Collection values) {
|
public static ListTag asTag(Collection values) {
|
||||||
Class clazz = null;
|
Class<? extends Tag> clazz = null;
|
||||||
List<Tag> list = new ArrayList<>(values.size());
|
List<Tag> list = new ArrayList<>(values.size());
|
||||||
for (Object value : values) {
|
for (Object value : values) {
|
||||||
Tag tag = asTag(value);
|
Tag tag = asTag(value);
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.boydti.fawe.command;
|
package com.boydti.fawe.command;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
import com.boydti.fawe.config.BBC;
|
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.filters.*;
|
||||||
import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory;
|
import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory;
|
||||||
import com.boydti.fawe.jnbt.anvil.history.NullAnvilHistory;
|
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.RunnableVal4;
|
||||||
import com.boydti.fawe.object.changeset.AnvilHistory;
|
import com.boydti.fawe.object.changeset.AnvilHistory;
|
||||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
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.MainUtil;
|
||||||
import com.boydti.fawe.util.SetQueue;
|
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.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
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.entity.Player;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
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.internal.annotation.Selection;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
@ -36,17 +39,12 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@Command(aliases = {"/anvil"},
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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 {
|
public class AnvilCommands {
|
||||||
|
|
||||||
private final WorldEdit worldEdit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
@ -54,7 +52,6 @@ public class AnvilCommands {
|
|||||||
*/
|
*/
|
||||||
public AnvilCommands(WorldEdit worldEdit) {
|
public AnvilCommands(WorldEdit worldEdit) {
|
||||||
checkNotNull(worldEdit);
|
checkNotNull(worldEdit);
|
||||||
this.worldEdit = worldEdit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,14 +167,15 @@ public class AnvilCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.remapall")
|
@CommandPermissions("worldedit.anvil.remapall")
|
||||||
public void remapall(Player player, String folder) throws WorldEditException {
|
public void remapall(Player player, String folder) throws WorldEditException {
|
||||||
ClipboardRemapper mapper;
|
|
||||||
ClipboardRemapper.RemapPlatform from;
|
ClipboardRemapper.RemapPlatform from;
|
||||||
ClipboardRemapper.RemapPlatform to;
|
ClipboardRemapper.RemapPlatform to;
|
||||||
from = ClipboardRemapper.RemapPlatform.PE;
|
from = ClipboardRemapper.RemapPlatform.PE;
|
||||||
to = ClipboardRemapper.RemapPlatform.PC;
|
to = ClipboardRemapper.RemapPlatform.PC;
|
||||||
RemapFilter filter = new RemapFilter(from, to);
|
RemapFilter filter = new RemapFilter(from, to);
|
||||||
RemapFilter result = runWithWorld(player, folder, filter, true);
|
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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -196,7 +194,9 @@ public class AnvilCommands {
|
|||||||
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Optional("60000") int fileDurationMillis) throws WorldEditException {
|
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Optional("60000") int fileDurationMillis) throws WorldEditException {
|
||||||
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||||
DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
|
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(
|
@Command(
|
||||||
@ -211,12 +211,17 @@ public class AnvilCommands {
|
|||||||
max = 3
|
max = 3
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.deleteallunclaimed")
|
@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();
|
String folder = player.getWorld().getName();
|
||||||
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||||
if (debug) filter.enableDebug();
|
if (debug) {
|
||||||
|
filter.enableDebug();
|
||||||
|
}
|
||||||
DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
|
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(
|
@Command(
|
||||||
@ -231,11 +236,16 @@ public class AnvilCommands {
|
|||||||
max = 3
|
max = 3
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.deleteunclaimed")
|
@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);
|
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||||
if (debug) filter.enableDebug();
|
if (debug) {
|
||||||
|
filter.enableDebug();
|
||||||
|
}
|
||||||
DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
|
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(
|
@Command(
|
||||||
@ -254,7 +264,9 @@ public class AnvilCommands {
|
|||||||
long duration = MainUtil.timeToSec(time) * 1000L;
|
long duration = MainUtil.timeToSec(time) * 1000L;
|
||||||
DeleteOldFilter filter = new DeleteOldFilter(duration);
|
DeleteOldFilter filter = new DeleteOldFilter(duration);
|
||||||
DeleteOldFilter result = runWithWorld(player, folder, filter, true);
|
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(
|
@Command(
|
||||||
@ -274,7 +286,9 @@ public class AnvilCommands {
|
|||||||
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
|
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
|
||||||
MCAQueue queue = new MCAQueue(defaultQueue);
|
MCAQueue queue = new MCAQueue(defaultQueue);
|
||||||
PlotTrimFilter result = queue.filterWorld(filter);
|
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(
|
@Command(
|
||||||
@ -285,7 +299,9 @@ public class AnvilCommands {
|
|||||||
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch('u') boolean unsafe) {
|
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch('u') boolean unsafe) {
|
||||||
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
|
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
|
||||||
DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
|
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(
|
@Command(
|
||||||
@ -296,7 +312,9 @@ public class AnvilCommands {
|
|||||||
public void trimAllAir(Player player, String folder, @Switch('u') boolean unsafe) throws WorldEditException {
|
public void trimAllAir(Player player, String folder, @Switch('u') boolean unsafe) throws WorldEditException {
|
||||||
TrimAirFilter filter = new TrimAirFilter();
|
TrimAirFilter filter = new TrimAirFilter();
|
||||||
TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
|
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(
|
@Command(
|
||||||
@ -307,7 +325,9 @@ public class AnvilCommands {
|
|||||||
public void debugfixroads(Player player, String folder) throws WorldEditException {
|
public void debugfixroads(Player player, String folder) throws WorldEditException {
|
||||||
DebugFixP2Roads filter = new DebugFixP2Roads();
|
DebugFixP2Roads filter = new DebugFixP2Roads();
|
||||||
DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
|
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(
|
@Command(
|
||||||
@ -319,7 +339,8 @@ public class AnvilCommands {
|
|||||||
max = 4
|
max = 4
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.replaceall")
|
@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;
|
// MCAFilterCounter filter;
|
||||||
// if (useMap) {
|
// if (useMap) {
|
||||||
// if (to instanceof RandomPattern) {
|
// if (to instanceof RandomPattern) {
|
||||||
@ -341,6 +362,7 @@ public class AnvilCommands {
|
|||||||
// MCAFilterCounter result = runWithWorld(player, folder, filter, true);
|
// MCAFilterCounter 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(
|
@Command(
|
||||||
aliases = {"countall"},
|
aliases = {"countall"},
|
||||||
@ -414,7 +436,9 @@ public class AnvilCommands {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
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(
|
@Command(
|
||||||
@ -441,6 +465,7 @@ public class AnvilCommands {
|
|||||||
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||||
// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal()));
|
// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"distr"},
|
aliases = {"distr"},
|
||||||
@ -518,6 +543,7 @@ public class AnvilCommands {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"replace", "r"},
|
aliases = {"replace", "r"},
|
||||||
@ -525,7 +551,8 @@ public class AnvilCommands {
|
|||||||
desc = "Replace all blocks in the selection with another"
|
desc = "Replace all blocks in the selection with another"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.replace")
|
@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;
|
// final FaweBlockMatcher matchFrom;
|
||||||
// if (from == null) {
|
// if (from == null) {
|
||||||
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
||||||
@ -539,6 +566,7 @@ public class AnvilCommands {
|
|||||||
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"replacepattern", "preplace", "rp"},
|
aliases = {"replacepattern", "preplace", "rp"},
|
||||||
@ -547,7 +575,8 @@ public class AnvilCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.replace")
|
@CommandPermissions("worldedit.anvil.replace")
|
||||||
// Player player, String folder, @Optional String from, final Pattern to, @Switch('d') boolean useData, @Switch('m') boolean useMap
|
// 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;
|
// MCAFilterCounter filter;
|
||||||
// if (useMap) {
|
// if (useMap) {
|
||||||
// if (to instanceof RandomPattern) {
|
// if (to instanceof RandomPattern) {
|
||||||
@ -638,7 +667,7 @@ public class AnvilCommands {
|
|||||||
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.pastechunks")
|
@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);
|
// FawePlayer fp = FawePlayer.wrap(player);
|
||||||
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
|
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
|
||||||
// if (clipboard == null) {
|
// if (clipboard == null) {
|
||||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.config.Commands;
|
|||||||
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
|
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
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.command.MethodCommands;
|
||||||
import com.sk89q.worldedit.util.command.SimpleDispatcher;
|
import com.sk89q.worldedit.util.command.SimpleDispatcher;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
|
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CFICommand extends MethodCommands {
|
public class CFICommand extends MethodCommands {
|
||||||
@ -29,9 +31,6 @@ public class CFICommand extends MethodCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"cfi", "createfromimage"},
|
aliases = {"cfi", "createfromimage"},
|
||||||
usage = "",
|
|
||||||
min = 0,
|
|
||||||
max = -1,
|
|
||||||
anyFlags = true,
|
anyFlags = true,
|
||||||
desc = "Start CreateFromImage"
|
desc = "Start CreateFromImage"
|
||||||
)
|
)
|
||||||
@ -51,8 +50,7 @@ public class CFICommand extends MethodCommands {
|
|||||||
|
|
||||||
private void dispatch(FawePlayer fp, CFICommands.CFISettings settings, CommandContext context) throws CommandException {
|
private void dispatch(FawePlayer fp, CFICommands.CFISettings settings, CommandContext context) throws CommandException {
|
||||||
if (!settings.hasGenerator()) {
|
if (!settings.hasGenerator()) {
|
||||||
switch (context.argsLength()) {
|
if (context.argsLength() == 0) {
|
||||||
case 0: {
|
|
||||||
String hmCmd = child.alias() + " ";
|
String hmCmd = child.alias() + " ";
|
||||||
if (settings.image == null) {
|
if (settings.image == null) {
|
||||||
hmCmd += "image";
|
hmCmd += "image";
|
||||||
@ -64,9 +62,7 @@ public class CFICommand extends MethodCommands {
|
|||||||
.newline()
|
.newline()
|
||||||
.text("&7[&aEmpty&7]").cmdTip(child.alias() + " empty").text("- An empty map of a specific size")
|
.text("&7[&aEmpty&7]").cmdTip(child.alias() + " empty").text("- An empty map of a specific size")
|
||||||
.send(fp);
|
.send(fp);
|
||||||
break;
|
} else {
|
||||||
}
|
|
||||||
default: {
|
|
||||||
String remaining = context.getJoinedStrings(0);
|
String remaining = context.getJoinedStrings(0);
|
||||||
if (!dispatcher.contains(context.getString(0))) {
|
if (!dispatcher.contains(context.getString(0))) {
|
||||||
switch (context.argsLength()) {
|
switch (context.argsLength()) {
|
||||||
@ -75,25 +71,20 @@ public class CFICommand extends MethodCommands {
|
|||||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2:
|
||||||
String cmd = Commands.getAlias(CFICommands.class, "empty") + " " + context.getJoinedStrings(0);
|
String cmd = Commands.getAlias(CFICommands.class, "empty") + " " + context.getJoinedStrings(0);
|
||||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
dispatcher.call(remaining, context.getLocals(), new String[0]);
|
dispatcher.call(remaining, context.getLocals(), new String[0]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
switch (context.argsLength()) {
|
if (context.argsLength() == 0) {
|
||||||
case 0:
|
|
||||||
settings.setCategory("");
|
settings.setCategory("");
|
||||||
child.mainMenu(fp);
|
child.mainMenu(fp);
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
dispatcher.call(context.getJoinedStrings(0), context.getLocals(), new String[0]);
|
dispatcher.call(context.getJoinedStrings(0), context.getLocals(), new String[0]);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ import com.boydti.fawe.util.TaskManager;
|
|||||||
import com.boydti.fawe.util.TextureUtil;
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
import com.boydti.fawe.util.chat.Message;
|
import com.boydti.fawe.util.chat.Message;
|
||||||
import com.boydti.fawe.util.image.ImageUtil;
|
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.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
@ -70,10 +72,8 @@ import java.util.Date;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
import static com.boydti.fawe.util.image.ImageUtil.load;
|
|
||||||
|
|
||||||
@Command(aliases = {"/cfi"}, desc = "Create a world from images: [More Info](https://git.io/v5iDy)")
|
@Command(aliases = {"/cfi"}, desc = "Create a world from images: [More Info](https://git.io/v5iDy)")
|
||||||
public class CFICommands extends MethodCommands {
|
public class CFICommands extends MethodCommands {
|
||||||
@ -106,10 +106,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
public void heightmap(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional("1") double yscale) throws ParameterException {
|
public void heightmap(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional("1") double yscale) throws ParameterException {
|
||||||
if (yscale != 0) {
|
if (yscale != 0) {
|
||||||
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
|
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
|
||||||
int[] table = new int[256];
|
int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale))).toArray();
|
||||||
for (int i = 0; i < table.length; i++) {
|
|
||||||
table[i] = Math.min(255, (int) (i * yscale));
|
|
||||||
}
|
|
||||||
for (int i = 0; i < raw.length; i++) {
|
for (int i = 0; i < raw.length; i++) {
|
||||||
int color = raw[i];
|
int color = raw[i];
|
||||||
int red = table[(color >> 16) & 0xFF];
|
int red = table[(color >> 16) & 0xFF];
|
||||||
@ -175,14 +172,13 @@ public class CFICommands extends MethodCommands {
|
|||||||
desc = "Cancel creation"
|
desc = "Cancel creation"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void cancel(FawePlayer fp) throws ParameterException, IOException {
|
public void cancel(FawePlayer fp) {
|
||||||
getSettings(fp).remove();
|
getSettings(fp).remove();
|
||||||
fp.sendMessage("Cancelled!");
|
fp.sendMessage("Cancelled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"done", "create"},
|
aliases = {"done", "create"},
|
||||||
usage = "",
|
|
||||||
desc = "Create the world"
|
desc = "Create the world"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
@ -190,9 +186,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
CFISettings settings = assertSettings(fp);
|
CFISettings settings = assertSettings(fp);
|
||||||
HeightMapMCAGenerator generator = settings.getGenerator();
|
HeightMapMCAGenerator generator = settings.getGenerator();
|
||||||
|
|
||||||
Function<File, Boolean> function = new Function<File, Boolean>() {
|
Function<File, Boolean> function = folder -> {
|
||||||
@Override
|
|
||||||
public Boolean apply(File folder) {
|
|
||||||
if (folder != null) {
|
if (folder != null) {
|
||||||
try {
|
try {
|
||||||
generator.setFolder(folder);
|
generator.setFolder(folder);
|
||||||
@ -210,7 +204,6 @@ public class CFICommands extends MethodCommands {
|
|||||||
fp.sendMessage("Unable to generate world... (see console)?");
|
fp.sendMessage("Unable to generate world... (see console)?");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -245,11 +238,16 @@ public class CFICommands extends MethodCommands {
|
|||||||
desc = "Set the floor and main block"
|
desc = "Set the floor and main block"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@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();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setColumn(load(image), pattern, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setColumn(mask, pattern);
|
gen.setColumn(load(image), pattern, !disableWhiteOnly);
|
||||||
else gen.setColumn(pattern);
|
} else if (mask != null) {
|
||||||
|
gen.setColumn(mask, pattern);
|
||||||
|
} else {
|
||||||
|
gen.setColumn(pattern);
|
||||||
|
}
|
||||||
fp.sendMessage("Set column!");
|
fp.sendMessage("Set column!");
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(fp).resetComponent();
|
||||||
component(fp);
|
component(fp);
|
||||||
@ -261,18 +259,24 @@ public class CFICommands extends MethodCommands {
|
|||||||
desc = "Set the floor (default: grass)"
|
desc = "Set the floor (default: grass)"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@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);
|
floor(fp, pattern, image, mask, disableWhiteOnly);
|
||||||
fp.sendMessage("Set floor!");
|
fp.sendMessage("Set floor!");
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(fp).resetComponent();
|
||||||
component(fp);
|
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();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setFloor(load(image), pattern, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setFloor(mask, pattern);
|
gen.setFloor(load(image), pattern, !disableWhiteOnly);
|
||||||
else gen.setFloor(pattern);
|
} else if (mask != null) {
|
||||||
|
gen.setFloor(mask, pattern);
|
||||||
|
} else {
|
||||||
|
gen.setFloor(pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -281,18 +285,24 @@ public class CFICommands extends MethodCommands {
|
|||||||
desc = "Set the main block (default: stone)"
|
desc = "Set the main block (default: stone)"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@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);
|
main(fp, pattern, image, mask, disableWhiteOnly);
|
||||||
fp.sendMessage("Set main!");
|
fp.sendMessage("Set main!");
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(fp).resetComponent();
|
||||||
component(fp);
|
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();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setMain(load(image), pattern, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setMain(mask, pattern);
|
gen.setMain(load(image), pattern, !disableWhiteOnly);
|
||||||
else gen.setMain(pattern);
|
} else if (mask != null) {
|
||||||
|
gen.setMain(mask, pattern);
|
||||||
|
} else {
|
||||||
|
gen.setMain(pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -303,11 +313,16 @@ public class CFICommands extends MethodCommands {
|
|||||||
"e.g. Tallgrass"
|
"e.g. Tallgrass"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@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();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setOverlay(load(image), pattern, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setOverlay(mask, pattern);
|
gen.setOverlay(load(image), pattern, !disableWhiteOnly);
|
||||||
else gen.setOverlay(pattern);
|
} else if (mask != null) {
|
||||||
|
gen.setOverlay(mask, pattern);
|
||||||
|
} else {
|
||||||
|
gen.setOverlay(pattern);
|
||||||
|
}
|
||||||
fp.sendMessage("Set overlay!");
|
fp.sendMessage("Set overlay!");
|
||||||
component(fp);
|
component(fp);
|
||||||
}
|
}
|
||||||
@ -322,16 +337,21 @@ public class CFICommands extends MethodCommands {
|
|||||||
" - A good value for radius and iterations would be 1 8."
|
" - A good value for radius and iterations would be 1 8."
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@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);
|
smooth(fp, radius, iterations, image, mask, disableWhiteOnly);
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(fp).resetComponent();
|
||||||
component(fp);
|
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();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
|
if (image != null) {
|
||||||
else gen.smooth(mask, radius, iterations);
|
gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
|
||||||
|
} else {
|
||||||
|
gen.smooth(mask, radius, iterations);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -413,7 +433,9 @@ public class CFICommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
blocks = new HashSet<>();
|
blocks = new HashSet<>();
|
||||||
for (int combined = 0; combined < ids.length; combined++) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
@ -434,7 +456,9 @@ public class CFICommands extends MethodCommands {
|
|||||||
BlockType type = BlockTypes.get(typeId);
|
BlockType type = BlockTypes.get(typeId);
|
||||||
BlockStateHolder block = type.getDefaultState();
|
BlockStateHolder block = type.getDefaultState();
|
||||||
pattern.setBlock(block);
|
pattern.setBlock(block);
|
||||||
if (mask.test(BlockVector3.ZERO)) blocks.add(type);
|
if (mask.test(BlockVector3.ZERO)) {
|
||||||
|
blocks.add(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -469,8 +493,11 @@ public class CFICommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void complexity(FawePlayer fp, int min, int max) throws ParameterException, FileNotFoundException {
|
public void complexity(FawePlayer fp, int min, int max) throws ParameterException, FileNotFoundException {
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (min == 0 && max == 100) gen.setTextureUtil(Fawe.get().getTextureUtil());
|
if (min == 0 && max == 100) {
|
||||||
else gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max));
|
gen.setTextureUtil(Fawe.get().getTextureUtil());
|
||||||
|
} else {
|
||||||
|
gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max));
|
||||||
|
}
|
||||||
coloring(fp);
|
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"
|
" - If a mask is used, the biome will be set anywhere the mask applies"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@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();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setBiome(load(image), biome, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setBiome(mask, biome);
|
gen.setBiome(load(image), biome, !disableWhiteOnly);
|
||||||
else gen.setBiome(biome);
|
} else if (mask != null) {
|
||||||
|
gen.setBiome(mask, biome);
|
||||||
|
} else {
|
||||||
|
gen.setBiome(biome);
|
||||||
|
}
|
||||||
msg("Set biome!").send(fp);
|
msg("Set biome!").send(fp);
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(fp).resetComponent();
|
||||||
component(fp);
|
component(fp);
|
||||||
@ -678,7 +710,8 @@ public class CFICommands extends MethodCommands {
|
|||||||
)
|
)
|
||||||
// ![79,174,212,5:3,5:4,18,161,20]
|
// ![79,174,212,5:3,5:4,18,161,20]
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@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);
|
CFISettings settings = assertSettings(fp);
|
||||||
settings.getGenerator().setColorWithGlass(load(image));
|
settings.getGenerator().setColorWithGlass(load(image));
|
||||||
msg("Set color with glass!").send(fp);
|
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"
|
"The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@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);
|
CFISettings settings = assertSettings(fp);
|
||||||
HeightMapMCAGenerator gen = settings.getGenerator();
|
HeightMapMCAGenerator gen = settings.getGenerator();
|
||||||
if (imageMask != null) gen.setColor(load(image), load(imageMask), !disableWhiteOnly);
|
if (imageMask != null) {
|
||||||
else if (mask != null) gen.setColor(load(image), mask);
|
gen.setColor(load(image), load(imageMask), !disableWhiteOnly);
|
||||||
else gen.setColor(load(image));
|
} else if (mask != null) {
|
||||||
|
gen.setColor(load(image), mask);
|
||||||
|
} else {
|
||||||
|
gen.setColor(load(image));
|
||||||
|
}
|
||||||
settings.resetColoring();
|
settings.resetColoring();
|
||||||
msg("Set color with blocks!").send(fp);
|
msg("Set color with blocks!").send(fp);
|
||||||
mainMenu(fp);
|
mainMenu(fp);
|
||||||
@ -715,7 +753,8 @@ public class CFICommands extends MethodCommands {
|
|||||||
"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")
|
@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);
|
CFISettings settings = assertSettings(fp);
|
||||||
settings.getGenerator().setBlockAndBiomeColor(load(image), mask, load(imageMask), !disableWhiteOnly);
|
settings.getGenerator().setBlockAndBiomeColor(load(image), mask, load(imageMask), !disableWhiteOnly);
|
||||||
msg("Set color with blocks and biomes!").send(fp);
|
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."
|
" - If you changed the block to something other than grass you will not see anything."
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@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);
|
CFISettings settings = assertSettings(fp);
|
||||||
settings.getGenerator().setBiomeColor(load(image));
|
settings.getGenerator().setBiomeColor(load(image));
|
||||||
msg("Set color with biomes!").send(fp);
|
msg("Set color with biomes!").send(fp);
|
||||||
@ -778,7 +818,9 @@ public class CFICommands extends MethodCommands {
|
|||||||
for (int typeId : blockArray) {
|
for (int typeId : blockArray) {
|
||||||
BlockType type = BlockTypes.get(typeId);
|
BlockType type = BlockTypes.get(typeId);
|
||||||
String name = type.getName();
|
String name = type.getName();
|
||||||
if (name.contains(":")) name = name.split(":")[1];
|
if (name.contains(":")) {
|
||||||
|
name = name.split(":")[1];
|
||||||
|
}
|
||||||
materials.add(name);
|
materials.add(name);
|
||||||
}
|
}
|
||||||
String blockList = materials.size() > 100 ? materials.size() + " blocks" : StringMan.join(materials, ',');
|
String blockList = materials.size() > 100 ? materials.size() + " blocks" : StringMan.join(materials, ',');
|
||||||
@ -798,9 +840,15 @@ public class CFICommands extends MethodCommands {
|
|||||||
if (settings.image != null) {
|
if (settings.image != null) {
|
||||||
StringBuilder colorArgs = new StringBuilder();
|
StringBuilder colorArgs = new StringBuilder();
|
||||||
colorArgs.append(" " + settings.imageArg);
|
colorArgs.append(" " + settings.imageArg);
|
||||||
if (settings.imageMask != null) colorArgs.append(" " + settings.imageMaskArg);
|
if (settings.imageMask != null) {
|
||||||
if (settings.mask != null) colorArgs.append(" " + settings.maskArg);
|
colorArgs.append(" " + settings.imageMaskArg);
|
||||||
if (!settings.whiteOnly) colorArgs.append(" -w");
|
}
|
||||||
|
if (settings.mask != null) {
|
||||||
|
colorArgs.append(" " + settings.maskArg);
|
||||||
|
}
|
||||||
|
if (!settings.whiteOnly) {
|
||||||
|
colorArgs.append(" -w");
|
||||||
|
}
|
||||||
|
|
||||||
msg.text("&7Image: ")
|
msg.text("&7Image: ")
|
||||||
.text("&7[&a" + settings.imageArg + "&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
|
.text("&7[&a" + settings.imageArg + "&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
|
||||||
@ -958,9 +1006,15 @@ public class CFICommands extends MethodCommands {
|
|||||||
String pattern = settings.pattern == null ? "NONE" : settings.patternArg;
|
String pattern = settings.pattern == null ? "NONE" : settings.patternArg;
|
||||||
|
|
||||||
StringBuilder maskArgs = new StringBuilder();
|
StringBuilder maskArgs = new StringBuilder();
|
||||||
if (settings.imageMask != null) maskArgs.append(" " + settings.imageMaskArg);
|
if (settings.imageMask != null) {
|
||||||
if (settings.mask != null) maskArgs.append(" " + settings.maskArg);
|
maskArgs.append(" " + settings.imageMaskArg);
|
||||||
if (!settings.whiteOnly) maskArgs.append(" -w");
|
}
|
||||||
|
if (settings.mask != null) {
|
||||||
|
maskArgs.append(" " + settings.maskArg);
|
||||||
|
}
|
||||||
|
if (!settings.whiteOnly) {
|
||||||
|
maskArgs.append(" -w");
|
||||||
|
}
|
||||||
|
|
||||||
String height = Commands.getAlias(CFICommands.class, "height");
|
String height = Commands.getAlias(CFICommands.class, "height");
|
||||||
String waterHeight = Commands.getAlias(CFICommands.class, "waterheight");
|
String waterHeight = Commands.getAlias(CFICommands.class, "waterheight");
|
||||||
@ -1013,10 +1067,11 @@ public class CFICommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private CFISettings assertSettings(FawePlayer fp) throws ParameterException {
|
private CFISettings assertSettings(FawePlayer fp) throws ParameterException {
|
||||||
CFISettings settings = getSettings(fp);
|
CFISettings settings = getSettings(fp);
|
||||||
if (!settings.hasGenerator()) throw new ParameterException("Please use /" + alias());
|
if (!settings.hasGenerator()) {
|
||||||
|
throw new ParameterException("Please use /" + alias());
|
||||||
|
}
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1103,12 +1158,16 @@ public class CFICommands extends MethodCommands {
|
|||||||
|
|
||||||
public CFISettings setGenerator(HeightMapMCAGenerator generator) {
|
public CFISettings setGenerator(HeightMapMCAGenerator generator) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
if (bound) fp.getSession().setVirtualWorld(generator);
|
if (bound) {
|
||||||
|
fp.getSession().setVirtualWorld(generator);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CFISettings bind() {
|
public CFISettings bind() {
|
||||||
if (generator != null) fp.getSession().setVirtualWorld(generator);
|
if (generator != null) {
|
||||||
|
fp.getSession().setVirtualWorld(generator);
|
||||||
|
}
|
||||||
bound = true;
|
bound = true;
|
||||||
fp.setMeta("CFISettings", this);
|
fp.setMeta("CFISettings", this);
|
||||||
return this;
|
return this;
|
||||||
|
@ -4,9 +4,9 @@ import com.boydti.fawe.Fawe;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.extent.NullExtent;
|
import com.boydti.fawe.object.extent.NullExtent;
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
import com.boydti.fawe.util.image.ImageUtil;
|
import com.boydti.fawe.util.image.ImageUtil;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -30,17 +30,14 @@ import com.sk89q.worldedit.util.command.binding.Text;
|
|||||||
import com.sk89q.worldedit.util.command.binding.Validate;
|
import com.sk89q.worldedit.util.command.binding.Validate;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ArgumentStack;
|
import com.sk89q.worldedit.util.command.parametric.ArgumentStack;
|
||||||
import com.sk89q.worldedit.util.command.parametric.BindingBehavior;
|
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.BindingMatch;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class FawePrimitiveBinding {
|
public class FawePrimitiveBinding {
|
||||||
@BindingMatch(type = {Long.class, long.class},
|
@BindingMatch(type = {Long.class, long.class},
|
||||||
@ -80,11 +77,15 @@ public class FawePrimitiveBinding {
|
|||||||
public class ImageUri {
|
public class ImageUri {
|
||||||
public final URI uri;
|
public final URI uri;
|
||||||
private BufferedImage image;
|
private BufferedImage image;
|
||||||
public ImageUri(URI uri) {
|
|
||||||
|
ImageUri(URI uri) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage load() throws ParameterException {
|
public BufferedImage load() throws ParameterException {
|
||||||
if (image != null) return image;
|
if (image != null) {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
return image = ImageUtil.load(uri);
|
return image = ImageUtil.load(uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,7 +106,9 @@ public class FawePrimitiveBinding {
|
|||||||
)
|
)
|
||||||
public TextureUtil getTexture(ArgumentStack context) {
|
public TextureUtil getTexture(ArgumentStack context) {
|
||||||
Actor actor = context.getContext().getLocals().get(Actor.class);
|
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);
|
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
|
||||||
return session.getTextureUtil();
|
return session.getTextureUtil();
|
||||||
}
|
}
|
||||||
@ -117,12 +120,20 @@ public class FawePrimitiveBinding {
|
|||||||
)
|
)
|
||||||
public Extent getExtent(ArgumentStack context) throws ParameterException {
|
public Extent getExtent(ArgumentStack context) throws ParameterException {
|
||||||
Extent extent = context.getContext().getLocals().get(EditSession.class);
|
Extent extent = context.getContext().getLocals().get(EditSession.class);
|
||||||
if (extent != null) return extent;
|
if (extent != null) {
|
||||||
|
return extent;
|
||||||
|
}
|
||||||
extent = Request.request().getExtent();
|
extent = Request.request().getExtent();
|
||||||
if (extent != null) return extent;
|
if (extent != null) {
|
||||||
|
return extent;
|
||||||
|
}
|
||||||
Actor actor = context.getContext().getLocals().get(Actor.class);
|
Actor actor = context.getContext().getLocals().get(Actor.class);
|
||||||
if (actor == null) throw new ParameterException("No player to get a session for");
|
if (actor == null) {
|
||||||
if (!(actor instanceof Player)) throw new ParameterException("Caller is not a player");
|
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);
|
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
|
||||||
EditSession editSession = session.createEditSession((Player) actor);
|
EditSession editSession = session.createEditSession((Player) actor);
|
||||||
editSession.enableQueue();
|
editSession.enableQueue();
|
||||||
@ -160,7 +171,9 @@ public class FawePrimitiveBinding {
|
|||||||
behavior = BindingBehavior.PROVIDES)
|
behavior = BindingBehavior.PROVIDES)
|
||||||
public ResettableExtent getResettableExtent(ArgumentStack context) throws ParameterException, InputParseException {
|
public ResettableExtent getResettableExtent(ArgumentStack context) throws ParameterException, InputParseException {
|
||||||
String input = context.next();
|
String input = context.next();
|
||||||
if (input.equalsIgnoreCase("#null")) return new NullExtent();
|
if (input.equalsIgnoreCase("#null")) {
|
||||||
|
return new NullExtent();
|
||||||
|
}
|
||||||
DefaultTransformParser parser = Fawe.get().getTransformParser();
|
DefaultTransformParser parser = Fawe.get().getTransformParser();
|
||||||
Actor actor = context.getContext().getLocals().get(Actor.class);
|
Actor actor = context.getContext().getLocals().get(Actor.class);
|
||||||
ParserContext parserContext = new ParserContext();
|
ParserContext parserContext = new ParserContext();
|
||||||
@ -314,7 +327,9 @@ public class FawePrimitiveBinding {
|
|||||||
throw new ParameterException("You must either specify 1 or 2 radius values.");
|
throw new ParameterException("You must either specify 1 or 2 radius values.");
|
||||||
}
|
}
|
||||||
return Vector2.at(radiusX, radiusZ);
|
return Vector2.at(radiusX, radiusZ);
|
||||||
} /**
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Gets a type from a {@link ArgumentStack}.
|
* Gets a type from a {@link ArgumentStack}.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
@ -506,14 +521,10 @@ public class FawePrimitiveBinding {
|
|||||||
Range range = (Range) modifier;
|
Range range = (Range) modifier;
|
||||||
if (number < range.min()) {
|
if (number < range.min()) {
|
||||||
throw new ParameterException(
|
throw new ParameterException(
|
||||||
String.format(
|
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()) {
|
} else if (number > range.max()) {
|
||||||
throw new ParameterException(
|
throw new ParameterException(
|
||||||
String.format(
|
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,13 +545,11 @@ public class FawePrimitiveBinding {
|
|||||||
if (number < range.min()) {
|
if (number < range.min()) {
|
||||||
throw new ParameterException(
|
throw new ParameterException(
|
||||||
String.format(
|
String.format(
|
||||||
"A valid value is greater than or equal to %s " +
|
"A valid value is greater than or equal to %s (you entered %s)", range.min(), number));
|
||||||
"(you entered %s)", range.min(), number));
|
|
||||||
} else if (number > range.max()) {
|
} else if (number > range.max()) {
|
||||||
throw new ParameterException(
|
throw new ParameterException(
|
||||||
String.format(
|
String.format(
|
||||||
"A valid value is less than or equal to %s " +
|
"A valid value is less than or equal to %s (you entered %s)", range.max(), number));
|
||||||
"(you entered %s)", range.max(), number));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -567,8 +576,7 @@ public class FawePrimitiveBinding {
|
|||||||
if (!string.matches(validate.regex())) {
|
if (!string.matches(validate.regex())) {
|
||||||
throw new ParameterException(
|
throw new ParameterException(
|
||||||
String.format(
|
String.format(
|
||||||
"The given text doesn't match the right " +
|
"The given text doesn't match the right format (technically speaking, the 'format' is %s)",
|
||||||
"format (technically speaking, the 'format' is %s)",
|
|
||||||
validate.regex()));
|
validate.regex()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,7 +434,7 @@ public enum BBC {
|
|||||||
allNames.add(c.name());
|
allNames.add(c.name());
|
||||||
allCats.add(c.category.toLowerCase());
|
allCats.add(c.category.toLowerCase());
|
||||||
}
|
}
|
||||||
final HashSet<BBC> captions = new HashSet<>();
|
final EnumSet<BBC> captions = EnumSet.noneOf(BBC.class);
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (final String key : keys) {
|
for (final String key : keys) {
|
||||||
final Object value = yml.get(key);
|
final Object value = yml.get(key);
|
||||||
|
@ -391,7 +391,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fixSkyLighting(List<RelightSkyEntry> sorted) {
|
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;
|
boolean remove = this.removeFirst;
|
||||||
BlockVectorSet chunkSet = null;
|
BlockVectorSet chunkSet = null;
|
||||||
if (remove) {
|
if (remove) {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.boydti.fawe.jnbt;
|
package com.boydti.fawe.jnbt;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.object.RunnableVal2;
|
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
|
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class NBTStreamer {
|
public class NBTStreamer {
|
||||||
private final NBTInputStream is;
|
private final NBTInputStream is;
|
||||||
@ -27,7 +25,7 @@ public class NBTStreamer {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void readFully() throws IOException {
|
public void readFully() throws IOException {
|
||||||
is.readNamedTagLazy(node -> readers.get(node));
|
is.readNamedTagLazy(readers::get);
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,12 +55,6 @@ public class NBTStreamer {
|
|||||||
readers.put(node, run);
|
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> {
|
public static abstract class NBTStreamReader<T, V> implements BiConsumer<T, V> {
|
||||||
private String node;
|
private String node;
|
||||||
|
|
||||||
@ -84,7 +76,7 @@ public class NBTStreamer {
|
|||||||
public abstract void run(int index, int byteValue);
|
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> {
|
public static abstract class LongReader implements BiConsumer<Integer, Long> {
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,21 +57,21 @@ public class SchematicStreamer extends NBTStreamer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addBlockReaders() throws IOException {
|
public void addBlockReaders() throws IOException {
|
||||||
NBTStreamReader idInit = new NBTStreamReader<Integer, Integer>() {
|
NBTStreamReader<? extends Integer, ? extends Integer> idInit = new NBTStreamReader<Integer, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public void accept(Integer length, Integer type) {
|
public void accept(Integer length, Integer type) {
|
||||||
setupClipboard(length);
|
setupClipboard(length);
|
||||||
ids = new FaweOutputStream(new LZ4BlockOutputStream(idOut));
|
ids = new FaweOutputStream(new LZ4BlockOutputStream(idOut));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
NBTStreamReader dataInit = new NBTStreamReader<Integer, Integer>() {
|
NBTStreamReader<? extends Integer, ? extends Integer> dataInit = new NBTStreamReader<Integer, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public void accept(Integer length, Integer type) {
|
public void accept(Integer length, Integer type) {
|
||||||
setupClipboard(length);
|
setupClipboard(length);
|
||||||
datas = new FaweOutputStream(new LZ4BlockOutputStream(dataOut));
|
datas = new FaweOutputStream(new LZ4BlockOutputStream(dataOut));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
NBTStreamReader addInit = new NBTStreamReader<Integer, Integer>() {
|
NBTStreamReader<? extends Integer, ? extends Integer> addInit = new NBTStreamReader<Integer, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public void accept(Integer length, Integer type) {
|
public void accept(Integer length, Integer type) {
|
||||||
setupClipboard(length*2);
|
setupClipboard(length*2);
|
||||||
@ -225,19 +225,19 @@ public class SchematicStreamer extends NBTStreamer {
|
|||||||
Direction left = facing.getLeft();
|
Direction left = facing.getLeft();
|
||||||
Direction right = facing.getRight();
|
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();
|
BlockType forwardType = forwardBlock.getBlockType();
|
||||||
if (forwardType.hasProperty(PropertyKey.SHAPE) && forwardType.hasProperty(PropertyKey.FACING)) {
|
if (forwardType.hasProperty(PropertyKey.SHAPE) && forwardType.hasProperty(PropertyKey.FACING)) {
|
||||||
Direction forwardFacing = (Direction) forwardBlock.getState(PropertyKey.FACING);
|
Direction forwardFacing = (Direction) forwardBlock.getState(PropertyKey.FACING);
|
||||||
if (forwardFacing == left) {
|
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();
|
BlockType rightType = rightBlock.getBlockType();
|
||||||
if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) {
|
if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) {
|
||||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "inner_left"));
|
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "inner_left"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (forwardFacing == right) {
|
} 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();
|
BlockType leftType = leftBlock.getBlockType();
|
||||||
if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) {
|
if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) {
|
||||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "inner_right"));
|
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();
|
BlockType backwardsType = backwardsBlock.getBlockType();
|
||||||
if (backwardsType.hasProperty(PropertyKey.SHAPE) && backwardsType.hasProperty(PropertyKey.FACING)) {
|
if (backwardsType.hasProperty(PropertyKey.SHAPE) && backwardsType.hasProperty(PropertyKey.FACING)) {
|
||||||
Direction backwardsFacing = (Direction) backwardsBlock.getState(PropertyKey.FACING);
|
Direction backwardsFacing = (Direction) backwardsBlock.getState(PropertyKey.FACING);
|
||||||
if (backwardsFacing == left) {
|
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();
|
BlockType rightType = rightBlock.getBlockType();
|
||||||
if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) {
|
if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) {
|
||||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_left"));
|
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_left"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (backwardsFacing == right) {
|
} 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();
|
BlockType leftType = leftBlock.getBlockType();
|
||||||
if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) {
|
if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) {
|
||||||
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_right"));
|
fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_right"));
|
||||||
@ -298,7 +298,7 @@ public class SchematicStreamer extends NBTStreamer {
|
|||||||
}, true).build();
|
}, true).build();
|
||||||
|
|
||||||
private boolean merge(int group, int x, int y, int z) {
|
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();
|
BlockType type = block.getBlockType();
|
||||||
return group(type) == group || fullCube.apply(type);
|
return group(type) == group || fullCube.apply(type);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import com.sk89q.worldedit.math.MutableBlockVector3;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class OreGen extends Resource {
|
public class OreGen implements Resource {
|
||||||
private final int maxSize;
|
private final int maxSize;
|
||||||
private final double maxSizeO8;
|
private final double maxSizeO8;
|
||||||
private final double maxSizeO16;
|
private final double maxSizeO16;
|
||||||
@ -21,9 +21,9 @@ public class OreGen extends Resource {
|
|||||||
private final Mask mask;
|
private final Mask mask;
|
||||||
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
private double ONE_2 = 1 / 2F;
|
private final double ONE_2 = 1 / 2F;
|
||||||
private double ONE_8 = 1 / 8F;
|
private final double ONE_8 = 1 / 8F;
|
||||||
private double ONE_16 = 1 / 16F;
|
private final double ONE_16 = 1 / 16F;
|
||||||
|
|
||||||
public int laced = 0;
|
public int laced = 0;
|
||||||
|
|
||||||
@ -47,16 +47,13 @@ public class OreGen extends Resource {
|
|||||||
}
|
}
|
||||||
double f = rand.nextDouble() * Math.PI;
|
double f = rand.nextDouble() * Math.PI;
|
||||||
|
|
||||||
int x8 = x;
|
|
||||||
int z8 = z;
|
|
||||||
double so8 = maxSizeO8;
|
double so8 = maxSizeO8;
|
||||||
double so16 = maxSizeO16;
|
|
||||||
double sf = MathMan.sinInexact(f) * so8;
|
double sf = MathMan.sinInexact(f) * so8;
|
||||||
double cf = MathMan.cosInexact(f) * so8;
|
double cf = MathMan.cosInexact(f) * so8;
|
||||||
double d1 = x8 + sf;
|
double d1 = x + sf;
|
||||||
double d2 = x8 - sf;
|
double d2 = x - sf;
|
||||||
double d3 = z8 + cf;
|
double d3 = z + cf;
|
||||||
double d4 = z8 - cf;
|
double d4 = z - cf;
|
||||||
|
|
||||||
double d5 = y + rand.nextInt(3) - 2;
|
double d5 = y + rand.nextInt(3) - 2;
|
||||||
double d6 = 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 d8 = d5 + yd * iFactor;
|
||||||
double d9 = d3 + zd * iFactor;
|
double d9 = d3 + zd * iFactor;
|
||||||
|
|
||||||
double d10 = rand.nextDouble() * so16;
|
double d10 = rand.nextDouble() * maxSizeO16;
|
||||||
double sif = MathMan.sinInexact(Math.PI * iFactor);
|
double sif = MathMan.sinInexact(Math.PI * iFactor);
|
||||||
double d11 = (sif + 1.0) * d10 + 1.0;
|
double d11 = (sif + 1.0) * d10 + 1.0;
|
||||||
double d12 = (sif + 1.0) * d10 + 1.0;
|
double d12 = (sif + 1.0) * d10 + 1.0;
|
||||||
|
@ -4,8 +4,7 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public abstract class Resource {
|
public interface Resource {
|
||||||
public 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.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class SchemGen extends Resource {
|
public class SchemGen implements Resource {
|
||||||
|
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
private final List<ClipboardHolder> clipboards;
|
private final List<ClipboardHolder> clipboards;
|
||||||
|
@ -27,8 +27,6 @@ public class ShatterBrush extends ScatterBrush {
|
|||||||
@Override
|
@Override
|
||||||
public void finish(EditSession editSession, LocalBlockVectorSet placed, final BlockVector3 position, Pattern pattern, double size) {
|
public void finish(EditSession editSession, LocalBlockVectorSet placed, final BlockVector3 position, Pattern pattern, double size) {
|
||||||
int radius2 = (int) (size * size);
|
int radius2 = (int) (size * size);
|
||||||
// Keep track of where we've visited
|
|
||||||
LocalBlockVectorSet tmp = new LocalBlockVectorSet();
|
|
||||||
// Individual frontier for each point
|
// Individual frontier for each point
|
||||||
LocalBlockVectorSet[] frontiers = new LocalBlockVectorSet[placed.size()];
|
LocalBlockVectorSet[] frontiers = new LocalBlockVectorSet[placed.size()];
|
||||||
// Keep track of where each frontier has visited
|
// Keep track of where each frontier has visited
|
||||||
@ -51,6 +49,8 @@ public class ShatterBrush extends ScatterBrush {
|
|||||||
final SurfaceMask surfaceTest = new SurfaceMask(editSession);
|
final SurfaceMask surfaceTest = new SurfaceMask(editSession);
|
||||||
// Expand
|
// Expand
|
||||||
boolean notEmpty = true;
|
boolean notEmpty = true;
|
||||||
|
// Keep track of where we've visited
|
||||||
|
LocalBlockVectorSet tmp = new LocalBlockVectorSet();
|
||||||
while (notEmpty) {
|
while (notEmpty) {
|
||||||
notEmpty = false;
|
notEmpty = false;
|
||||||
for (i = 0; i < frontiers.length; i++) {
|
for (i = 0; i < frontiers.length; i++) {
|
||||||
@ -59,15 +59,13 @@ public class ShatterBrush extends ScatterBrush {
|
|||||||
final LocalBlockVectorSet frontierVisited = frontiersVisited[i];
|
final LocalBlockVectorSet frontierVisited = frontiersVisited[i];
|
||||||
// This is a temporary set with the next blocks the frontier will visit
|
// This is a temporary set with the next blocks the frontier will visit
|
||||||
final LocalBlockVectorSet finalTmp = tmp;
|
final LocalBlockVectorSet finalTmp = tmp;
|
||||||
frontier.forEach(new LocalBlockVectorSet.BlockVectorSetVisitor() {
|
frontier.forEach((x, y, z, index) -> {
|
||||||
@Override
|
|
||||||
public void run(int x, int y, int z, int index) {
|
|
||||||
if (ThreadLocalRandom.current().nextInt(2) == 0) {
|
if (ThreadLocalRandom.current().nextInt(2) == 0) {
|
||||||
finalTmp.add(x, y, z);
|
finalTmp.add(x, y, z);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < BreadthFirstSearch.DIAGONAL_DIRECTIONS.length; i++) {
|
for (int i1 = 0; i1 < BreadthFirstSearch.DIAGONAL_DIRECTIONS.length; i1++) {
|
||||||
BlockVector3 direction = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i];
|
BlockVector3 direction = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i1];
|
||||||
int x2 = x + direction.getBlockX();
|
int x2 = x + direction.getBlockX();
|
||||||
int y2 = y + direction.getBlockY();
|
int y2 = y + direction.getBlockY();
|
||||||
int z2 = z + direction.getBlockZ();
|
int z2 = z + direction.getBlockZ();
|
||||||
@ -77,8 +75,7 @@ public class ShatterBrush extends ScatterBrush {
|
|||||||
int dz = position.getBlockZ() - z2;
|
int dz = position.getBlockZ() - z2;
|
||||||
int dSqr = (dx * dx) + (dy * dy) + (dz * dz);
|
int dSqr = (dx * dx) + (dy * dy) + (dz * dz);
|
||||||
if (dSqr <= radius2) {
|
if (dSqr <= radius2) {
|
||||||
MutableBlockVector3 v = mutable.setComponents(x2, y2, z2);
|
BlockVector3 bv = mutable.setComponents(x2, y2, z2);
|
||||||
BlockVector3 bv = v;
|
|
||||||
if (surfaceTest.test(bv) && finalMask.test(bv)) {
|
if (surfaceTest.test(bv) && finalMask.test(bv)) {
|
||||||
// (collision) If it's visited and part of another frontier, set the block
|
// (collision) If it's visited and part of another frontier, set the block
|
||||||
if (!placed.add(x2, y2, z2)) {
|
if (!placed.add(x2, y2, z2)) {
|
||||||
@ -93,7 +90,6 @@ public class ShatterBrush extends ScatterBrush {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
// Swap the frontier with the temporary set
|
// Swap the frontier with the temporary set
|
||||||
frontiers[i] = tmp;
|
frontiers[i] = tmp;
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package com.boydti.fawe.object.brush.visualization;
|
package com.boydti.fawe.object.brush.visualization;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
import com.boydti.fawe.example.IntFaweChunk;
|
import com.boydti.fawe.example.IntFaweChunk;
|
||||||
import com.boydti.fawe.example.NullQueueIntFaweChunk;
|
import com.boydti.fawe.example.NullQueueIntFaweChunk;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.visitor.FaweChunkVisitor;
|
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
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 com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectIterator;
|
|
||||||
|
|
||||||
public class VisualExtent extends AbstractDelegateExtent {
|
public class VisualExtent extends AbstractDelegateExtent {
|
||||||
|
|
||||||
@ -67,9 +64,7 @@ public class VisualExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clear(VisualExtent other, FawePlayer... players) {
|
public void clear(VisualExtent other, FawePlayer... players) {
|
||||||
ObjectIterator<Long2ObjectMap.Entry<VisualChunk>> iter = chunks.long2ObjectEntrySet().iterator();
|
for (Long2ObjectMap.Entry<VisualChunk> entry : chunks.long2ObjectEntrySet()) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
Long2ObjectMap.Entry<VisualChunk> entry = iter.next();
|
|
||||||
long pair = entry.getLongKey();
|
long pair = entry.getLongKey();
|
||||||
int cx = MathMan.unpairIntX(pair);
|
int cx = MathMan.unpairIntX(pair);
|
||||||
int cz = MathMan.unpairIntY(pair);
|
int cz = MathMan.unpairIntY(pair);
|
||||||
@ -79,22 +74,16 @@ public class VisualExtent extends AbstractDelegateExtent {
|
|||||||
final int bx = cx << 4;
|
final int bx = cx << 4;
|
||||||
final int bz = cz << 4;
|
final int bz = cz << 4;
|
||||||
if (otherChunk == null) {
|
if (otherChunk == null) {
|
||||||
chunk.forEachQueuedBlock(new FaweChunkVisitor() {
|
chunk.forEachQueuedBlock((localX, y, localZ, combined) -> {
|
||||||
@Override
|
|
||||||
public void run(int localX, int y, int localZ, int combined) {
|
|
||||||
combined = queue.getCombinedId4Data(bx + localX, y, bz + localZ, 0);
|
combined = queue.getCombinedId4Data(bx + localX, y, bz + localZ, 0);
|
||||||
newChunk.setBlock(localX, y, localZ, combined);
|
newChunk.setBlock(localX, y, localZ, combined);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
chunk.forEachQueuedBlock(new FaweChunkVisitor() {
|
chunk.forEachQueuedBlock((localX, y, localZ, combined) -> {
|
||||||
@Override
|
|
||||||
public void run(int localX, int y, int localZ, int combined) {
|
|
||||||
if (combined != otherChunk.getBlockCombinedId(localX, y, localZ)) {
|
if (combined != otherChunk.getBlockCombinedId(localX, y, localZ)) {
|
||||||
combined = queue.getCombinedId4Data(bx + localX, y, bz + localZ, 0);
|
combined = queue.getCombinedId4Data(bx + localX, y, bz + localZ, 0);
|
||||||
newChunk.setBlock(localX, y, localZ, combined);
|
newChunk.setBlock(localX, y, localZ, combined);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (newChunk.getTotalCount() != 0) {
|
if (newChunk.getTotalCount() != 0) {
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package com.boydti.fawe.object.clipboard;
|
package com.boydti.fawe.object.clipboard;
|
||||||
|
|
||||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
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.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
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.BlockStateHolder;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -1,21 +1,18 @@
|
|||||||
package com.boydti.fawe.object.clipboard;
|
package com.boydti.fawe.object.clipboard;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||||
import com.boydti.fawe.object.IntegerTrio;
|
import com.boydti.fawe.object.IntegerTrio;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.IntTag;
|
import com.sk89q.jnbt.IntTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
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.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
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.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -239,9 +236,9 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
|||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
||||||
states[index] = block.getInternalId();
|
states[index] = block.getInternalId();
|
||||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
setTile(index, ((BaseBlock)block).getNbtData());
|
setTile(index, block.getNbtData());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,7 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||||
|
|
||||||
public static int COMPRESSION = 0;
|
private static int HEADER_SIZE = 14;
|
||||||
public static int MODE = 0;
|
|
||||||
public static int HEADER_SIZE = 14;
|
|
||||||
|
|
||||||
protected int length;
|
protected int length;
|
||||||
protected int height;
|
protected int height;
|
||||||
@ -61,9 +59,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
private final File file;
|
private final File file;
|
||||||
|
|
||||||
private RandomAccessFile braf;
|
private RandomAccessFile braf;
|
||||||
private MappedByteBuffer mbb;
|
private MappedByteBuffer byteBuffer;
|
||||||
|
|
||||||
private FileChannel fc;
|
private FileChannel fileChannel;
|
||||||
private boolean hasBiomes;
|
private boolean hasBiomes;
|
||||||
|
|
||||||
public DiskOptimizedClipboard(int width, int height, int length, UUID uuid) {
|
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");
|
this.braf = new RandomAccessFile(file, "rw");
|
||||||
braf.setLength(file.length());
|
braf.setLength(file.length());
|
||||||
init();
|
init();
|
||||||
width = mbb.getChar(2);
|
width = byteBuffer.getChar(2);
|
||||||
height = mbb.getChar(4);
|
height = byteBuffer.getChar(4);
|
||||||
length = mbb.getChar(6);
|
length = byteBuffer.getChar(6);
|
||||||
area = width * length;
|
area = width * length;
|
||||||
this.volume = length * width * height;
|
this.volume = length * width * height;
|
||||||
|
|
||||||
@ -98,9 +96,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init() throws IOException {
|
private void init() throws IOException {
|
||||||
if (this.fc == null) {
|
if (this.fileChannel == null) {
|
||||||
this.fc = braf.getChannel();
|
this.fileChannel = braf.getChannel();
|
||||||
this.mbb = fc.map(FileChannel.MapMode.READ_WRITE, 0, file.length());
|
this.byteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, file.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +132,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void setBiome(int index, BiomeType biome) {
|
public void setBiome(int index, BiomeType biome) {
|
||||||
if (initBiome()) {
|
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()) {
|
if (!hasBiomes()) {
|
||||||
return null;
|
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);
|
return BiomeTypes.get(biomeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +152,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
int mbbIndex = HEADER_SIZE + (volume << 2);
|
int mbbIndex = HEADER_SIZE + (volume << 2);
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, index++, mbbIndex++) {
|
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);
|
task.run(index, biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,9 +171,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
public BlockArrayClipboard toClipboard() {
|
public BlockArrayClipboard toClipboard() {
|
||||||
try {
|
try {
|
||||||
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(width - 1, height - 1, length - 1));
|
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(width - 1, height - 1, length - 1));
|
||||||
int ox = mbb.getShort(8);
|
int ox = byteBuffer.getShort(8);
|
||||||
int oy = mbb.getShort(10);
|
int oy = byteBuffer.getShort(10);
|
||||||
int oz = mbb.getShort(12);
|
int oz = byteBuffer.getShort(12);
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, this);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, this);
|
||||||
clipboard.setOrigin(BlockVector3.at(ox, oy, oz));
|
clipboard.setOrigin(BlockVector3.at(ox, oy, oz));
|
||||||
return clipboard;
|
return clipboard;
|
||||||
@ -213,9 +211,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
if (width * height * length != 0) {
|
if (width * height * length != 0) {
|
||||||
init();
|
init();
|
||||||
// write length etc
|
// write length etc
|
||||||
mbb.putChar(2, (char) width);
|
byteBuffer.putChar(2, (char) width);
|
||||||
mbb.putChar(4, (char) height);
|
byteBuffer.putChar(4, (char) height);
|
||||||
mbb.putChar(6, (char) length);
|
byteBuffer.putChar(6, (char) length);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -225,9 +223,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void setOrigin(BlockVector3 offset) {
|
public void setOrigin(BlockVector3 offset) {
|
||||||
try {
|
try {
|
||||||
mbb.putShort(8, (short) offset.getBlockX());
|
byteBuffer.putShort(8, (short) offset.getBlockX());
|
||||||
mbb.putShort(10, (short) offset.getBlockY());
|
byteBuffer.putShort(10, (short) offset.getBlockY());
|
||||||
mbb.putShort(12, (short) offset.getBlockZ());
|
byteBuffer.putShort(12, (short) offset.getBlockZ());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -248,9 +246,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
braf.setLength(size);
|
braf.setLength(size);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
mbb.putChar(2, (char) width);
|
byteBuffer.putChar(2, (char) width);
|
||||||
mbb.putChar(4, (char) height);
|
byteBuffer.putChar(4, (char) height);
|
||||||
mbb.putChar(6, (char) length);
|
byteBuffer.putChar(6, (char) length);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -258,7 +256,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
mbb.force();
|
byteBuffer.force();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiskOptimizedClipboard(int width, int height, int length) {
|
public DiskOptimizedClipboard(int width, int height, int length) {
|
||||||
@ -267,7 +265,6 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
|
|
||||||
private void closeDirectBuffer(ByteBuffer cb) {
|
private void closeDirectBuffer(ByteBuffer cb) {
|
||||||
if (cb == null || !cb.isDirect()) return;
|
if (cb == null || !cb.isDirect()) return;
|
||||||
|
|
||||||
// we could use this type cast and call functions without reflection code,
|
// 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.
|
// but static import from sun.* package is risky for non-SUN virtual machine.
|
||||||
//try { ((sun.nio.ch.DirectBuffer)cb).cleaner().clean(); } catch (Exception ex) { }
|
//try { ((sun.nio.ch.DirectBuffer)cb).cleaner().clean(); } catch (Exception ex) { }
|
||||||
@ -299,14 +296,15 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
try {
|
try {
|
||||||
if (mbb != null) {
|
if (byteBuffer != null) {
|
||||||
mbb.force();
|
byteBuffer.force();
|
||||||
fc.close();
|
fileChannel.close();
|
||||||
braf.close();
|
braf.close();
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
file.setWritable(true);
|
file.setWritable(true);
|
||||||
closeDirectBuffer(mbb);
|
closeDirectBuffer(byteBuffer);
|
||||||
mbb = null;
|
byteBuffer = null;
|
||||||
fc = null;
|
fileChannel = null;
|
||||||
braf = null;
|
braf = null;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -337,13 +335,13 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void streamCombinedIds(NBTStreamer.ByteReader task) {
|
public void streamCombinedIds(NBTStreamer.ByteReader task) {
|
||||||
try {
|
try {
|
||||||
mbb.force();
|
byteBuffer.force();
|
||||||
int pos = HEADER_SIZE;
|
int pos = HEADER_SIZE;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, pos += 4) {
|
for (int x = 0; x < width; x++, pos += 4) {
|
||||||
int combinedId = mbb.getInt(pos);
|
int combinedId = byteBuffer.getInt(pos);
|
||||||
task.run(index++, combinedId);
|
task.run(index++, combinedId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,7 +358,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(final BlockReader task, boolean air) {
|
public void forEach(final BlockReader task, boolean air) {
|
||||||
mbb.force();
|
byteBuffer.force();
|
||||||
int pos = HEADER_SIZE;
|
int pos = HEADER_SIZE;
|
||||||
IntegerTrio trio = new IntegerTrio();
|
IntegerTrio trio = new IntegerTrio();
|
||||||
final boolean hasTile = !nbtMap.isEmpty();
|
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 y = 0; y < height; y++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, pos += 4) {
|
for (int x = 0; x < width; x++, pos += 4) {
|
||||||
int combinedId = mbb.getInt(pos);
|
int combinedId = byteBuffer.getInt(pos);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||||
BlockState state = type.withStateId(combinedId);
|
BlockState state = type.withStateId(combinedId);
|
||||||
if (type.getMaterial().hasContainer()) {
|
if (type.getMaterial().hasContainer()) {
|
||||||
@ -388,7 +386,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, pos += 4) {
|
for (int x = 0; x < width; x++, pos += 4) {
|
||||||
int combinedId = mbb.getInt(pos);
|
int combinedId = byteBuffer.getInt(pos);
|
||||||
BlockState state = BlockState.getFromInternalId(combinedId);
|
BlockState state = BlockState.getFromInternalId(combinedId);
|
||||||
task.run(x, y, z, state);
|
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 y = 0; y < height; y++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, pos += 4) {
|
for (int x = 0; x < width; x++, pos += 4) {
|
||||||
int combinedId = mbb.getInt(pos);
|
int combinedId = byteBuffer.getInt(pos);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||||
if (!type.getMaterial().isAir()) {
|
if (!type.getMaterial().isAir()) {
|
||||||
BlockState state = type.withStateId(combinedId);
|
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) {
|
public BaseBlock getBlock(int x, int y, int z) {
|
||||||
try {
|
try {
|
||||||
int index = HEADER_SIZE + (getIndex(x, y, z) << 2);
|
int index = HEADER_SIZE + (getIndex(x, y, z) << 2);
|
||||||
int combinedId = mbb.getInt(index);
|
int combinedId = byteBuffer.getInt(index);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||||
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
||||||
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
||||||
@ -440,7 +438,6 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
} catch (IndexOutOfBoundsException ignore) {
|
} catch (IndexOutOfBoundsException ignore) {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
@ -449,7 +446,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
public BaseBlock getBlock(int i) {
|
public BaseBlock getBlock(int i) {
|
||||||
try {
|
try {
|
||||||
int diskIndex = (HEADER_SIZE) + (i << 2);
|
int diskIndex = (HEADER_SIZE) + (i << 2);
|
||||||
int combinedId = mbb.getInt(diskIndex);
|
int combinedId = byteBuffer.getInt(diskIndex);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||||
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
||||||
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
||||||
@ -499,7 +496,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
try {
|
try {
|
||||||
int index = (HEADER_SIZE) + ((getIndex(x, y, z) << 2));
|
int index = (HEADER_SIZE) + ((getIndex(x, y, z) << 2));
|
||||||
int combined = block.getInternalId();
|
int combined = block.getInternalId();
|
||||||
mbb.putInt(index, combined);
|
byteBuffer.putInt(index, combined);
|
||||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
setTile(x, y, z, block.getNbtData());
|
setTile(x, y, z, block.getNbtData());
|
||||||
@ -516,7 +513,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
try {
|
try {
|
||||||
int combined = block.getInternalId();
|
int combined = block.getInternalId();
|
||||||
int index = (HEADER_SIZE) + (i << 2);
|
int index = (HEADER_SIZE) + (i << 2);
|
||||||
mbb.putInt(index, combined);
|
byteBuffer.putInt(index, combined);
|
||||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
int y = i / area;
|
int y = i / area;
|
||||||
|
@ -2,27 +2,24 @@ package com.boydti.fawe.object.clipboard;
|
|||||||
|
|
||||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.IntTag;
|
import com.sk89q.jnbt.IntTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
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.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
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.BlockStateHolder;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
public abstract class FaweClipboard {
|
public abstract class FaweClipboard {
|
||||||
public abstract BaseBlock getBlock(int x, int y, int z);
|
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 abstract void forEach(BlockReader task, boolean air);
|
||||||
|
|
||||||
public static abstract class BlockReader {
|
public interface BlockReader {
|
||||||
public abstract <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block);
|
<B extends BlockStateHolder<B>> void run(int x, int y, int z, B block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void streamBiomes(final NBTStreamer.ByteReader task);
|
public abstract void streamBiomes(final NBTStreamer.ByteReader task);
|
||||||
@ -86,7 +83,6 @@ public abstract class FaweClipboard {
|
|||||||
public List<CompoundTag> getTileEntities() {
|
public List<CompoundTag> getTileEntities() {
|
||||||
final List<CompoundTag> tiles = new ArrayList<>();
|
final List<CompoundTag> tiles = new ArrayList<>();
|
||||||
forEach(new BlockReader() {
|
forEach(new BlockReader() {
|
||||||
private int index = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
|
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;
|
package com.boydti.fawe.object.clipboard;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||||
import com.boydti.fawe.object.IntegerTrio;
|
import com.boydti.fawe.object.IntegerTrio;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.IntTag;
|
import com.sk89q.jnbt.IntTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
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.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
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.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -31,9 +29,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class MemoryOptimizedClipboard extends FaweClipboard {
|
public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||||
|
|
||||||
public static final int BLOCK_SIZE = 1048576 * 4;
|
private static final int BLOCK_SIZE = 1048576 * 4;
|
||||||
public static final int BLOCK_MASK = 1048575;
|
private static final int BLOCK_MASK = 1048575;
|
||||||
public static final int BLOCK_SHIFT = 20;
|
private static final int BLOCK_SHIFT = 20;
|
||||||
|
|
||||||
private int length;
|
private int length;
|
||||||
private int height;
|
private int height;
|
||||||
@ -341,9 +339,9 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
|||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
||||||
int combinedId = block.getInternalId();
|
int combinedId = block.getInternalId();
|
||||||
setCombinedId(index, combinedId);
|
setCombinedId(index, combinedId);
|
||||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
setTile(index, ((BaseBlock)block).getNbtData());
|
setTile(index, block.getNbtData());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.boydti.fawe.object.clipboard;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
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.BlockStateHolder;
|
||||||
|
|
||||||
public class OffsetFaweClipboard extends AbstractDelegateFaweClipboard {
|
public class OffsetFaweClipboard extends AbstractDelegateFaweClipboard {
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
package com.boydti.fawe.object.clipboard;
|
package com.boydti.fawe.object.clipboard;
|
||||||
|
|
||||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
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.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
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.BlockStateHolder;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -79,13 +79,11 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
|||||||
if (region instanceof CuboidRegion) {
|
if (region instanceof CuboidRegion) {
|
||||||
if (air) {
|
if (air) {
|
||||||
((CuboidRegion) region).setUseOldIterator(true);
|
((CuboidRegion) region).setUseOldIterator(true);
|
||||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
RegionVisitor visitor = new RegionVisitor(region, pos1 -> {
|
||||||
@Override
|
BaseBlock block = getBlockAbs(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ());
|
||||||
public boolean apply(BlockVector3 pos) throws WorldEditException {
|
int x = pos1.getBlockX() - mx;
|
||||||
BaseBlock block = getBlockAbs(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
int y = pos1.getBlockY() - my;
|
||||||
int x = pos.getBlockX() - mx;
|
int z = pos1.getBlockZ() - mz;
|
||||||
int y = pos.getBlockY() - my;
|
|
||||||
int z = pos.getBlockZ() - mz;
|
|
||||||
if (block.hasNbtData()) {
|
if (block.hasNbtData()) {
|
||||||
Map<String, Tag> values = ReflectionUtils.getMap(block.getNbtData().getValue());
|
Map<String, Tag> values = ReflectionUtils.getMap(block.getNbtData().getValue());
|
||||||
values.put("x", new IntTag(x));
|
values.put("x", new IntTag(x));
|
||||||
@ -94,7 +92,6 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
|||||||
}
|
}
|
||||||
task.run(x, y, z, block);
|
task.run(x, y, z, block);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}, extent instanceof EditSession ? (EditSession) extent : null);
|
}, extent instanceof EditSession ? (EditSession) extent : null);
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
} else {
|
} else {
|
||||||
@ -107,7 +104,6 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
|||||||
int y = pos.getBlockY() - my;
|
int y = pos.getBlockY() - my;
|
||||||
int z = pos.getBlockZ() - mz;
|
int z = pos.getBlockZ() - mz;
|
||||||
if (region.contains(pos)) {
|
if (region.contains(pos)) {
|
||||||
// BlockState block = getBlockAbs(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
|
||||||
BaseBlock block = extent.getFullBlock(pos);
|
BaseBlock block = extent.getFullBlock(pos);
|
||||||
if (block.hasNbtData()) {
|
if (block.hasNbtData()) {
|
||||||
Map<String, Tag> values = ReflectionUtils.getMap(block.getNbtData().getValue());
|
Map<String, Tag> values = ReflectionUtils.getMap(block.getNbtData().getValue());
|
||||||
@ -118,9 +114,8 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
|||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
task.run(x, y, z, block);
|
task.run(x, y, z, block);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// task.run(x, y, z, EditSession.nullBlock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}, extent instanceof EditSession ? (EditSession) extent : null);
|
}, extent instanceof EditSession ? (EditSession) extent : null);
|
||||||
|
@ -25,6 +25,7 @@ public class WorldCutClipboard extends WorldCopyClipboard {
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BaseBlock getBlockAbs(int x, int y, int z) {
|
public BaseBlock getBlockAbs(int x, int y, int z) {
|
||||||
BaseBlock block = extent.getFullBlock(BlockVector3.at(x, y, z));
|
BaseBlock block = extent.getFullBlock(BlockVector3.at(x, y, z));
|
||||||
extent.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
|
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.boydti.fawe.util.MainUtil;
|
||||||
|
|
||||||
import com.google.common.io.Resources;
|
import com.google.common.io.Resources;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -23,7 +27,7 @@ public class WikiScraper {
|
|||||||
Wiki(String url) {this.url = url;}
|
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) {
|
public Map<String, Integer> expand(Map<String, Integer> map) {
|
||||||
HashMap<String, Integer> newMap = new HashMap<>(map);
|
HashMap<String, Integer> newMap = new HashMap<>(map);
|
||||||
@ -50,8 +54,8 @@ public class WikiScraper {
|
|||||||
String str = Resources.toString(file.toURL(), Charset.defaultCharset());
|
String str = Resources.toString(file.toURL(), Charset.defaultCharset());
|
||||||
return gson.fromJson(str, new TypeToken<Map<String, Integer>>() {
|
return gson.fromJson(str, new TypeToken<Map<String, Integer>>() {
|
||||||
}.getType());
|
}.getType());
|
||||||
} catch (Throwable ignore) {
|
} catch (JsonSyntaxException | IOException e) {
|
||||||
ignore.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map = scrape(wiki);
|
map = scrape(wiki);
|
||||||
@ -94,15 +98,15 @@ public class WikiScraper {
|
|||||||
return map;
|
return map;
|
||||||
} else {
|
} else {
|
||||||
String header = wiki == Wiki.ITEM_MAPPINGS_PE ? "=== Item IDs ===" : "{{";
|
String header = wiki == Wiki.ITEM_MAPPINGS_PE ? "=== Item IDs ===" : "{{";
|
||||||
String footer = "{{-}}";
|
|
||||||
String prefix = "{{id table|";
|
|
||||||
|
|
||||||
int headerIndex = text.indexOf(header);
|
int headerIndex = text.indexOf(header);
|
||||||
if (headerIndex == -1) return map;
|
if (headerIndex == -1) return map;
|
||||||
|
String footer = "{{-}}";
|
||||||
int endIndex = text.indexOf(footer, headerIndex);
|
int endIndex = text.indexOf(footer, headerIndex);
|
||||||
String part = text.substring(headerIndex, endIndex == -1 ? text.length() : endIndex);
|
String part = text.substring(headerIndex, endIndex == -1 ? text.length() : endIndex);
|
||||||
|
|
||||||
int id = 255;
|
int id = 255;
|
||||||
|
String prefix = "{{id table|";
|
||||||
for (String line : part.split("\n")) {
|
for (String line : part.split("\n")) {
|
||||||
String lower = line.toLowerCase();
|
String lower = line.toLowerCase();
|
||||||
if (lower.startsWith(prefix)) {
|
if (lower.startsWith(prefix)) {
|
||||||
|
@ -12,7 +12,7 @@ public class FastRandomCollection<T> extends RandomCollection<T> {
|
|||||||
super(weights, random);
|
super(weights, random);
|
||||||
int max = 0;
|
int max = 0;
|
||||||
int[] counts = new int[weights.size()];
|
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++) {
|
for (int i = 0; i < weightDoubles.length; i++) {
|
||||||
int weight = (int) (weightDoubles[i] * 100);
|
int weight = (int) (weightDoubles[i] * 100);
|
||||||
counts[i] = weight;
|
counts[i] = weight;
|
||||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.object.collection;
|
|||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -209,25 +210,16 @@ public class LocalBlockVector2DSet implements Set<BlockVector2> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAll(Collection<?> c) {
|
public boolean containsAll(Collection<?> c) {
|
||||||
for (Object o : c) {
|
return c.stream().allMatch(this::contains);
|
||||||
if (!contains(o)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(Collection<? extends BlockVector2> c) {
|
public boolean addAll(Collection<? extends BlockVector2> c) {
|
||||||
boolean result = false;
|
return c.stream().map(this::add).reduce(false, (a, b) -> a || b);
|
||||||
for (BlockVector2 v : c) {
|
|
||||||
result |= add(v);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(Collection<?> c) {
|
public boolean retainAll(@NotNull Collection<?> c) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
int size = size();
|
int size = size();
|
||||||
int index = -1;
|
int index = -1;
|
||||||
@ -246,27 +238,7 @@ public class LocalBlockVector2DSet implements Set<BlockVector2> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
boolean result = false;
|
return c.stream().map(this::remove).reduce(false, (a, b) -> a || b);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -322,8 +322,8 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class BlockVectorSetVisitor {
|
public interface BlockVectorSetVisitor {
|
||||||
public abstract void run(int x, int y, int z, int index);
|
void run(int x, int y, int z, int index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,7 +28,7 @@ public class MultiTransform extends RandomTransform {
|
|||||||
@Override
|
@Override
|
||||||
public void add(ResettableExtent extent, double chance) {
|
public void add(ResettableExtent extent, double chance) {
|
||||||
super.add(extent, chance);
|
super.add(extent, chance);
|
||||||
this.extents = getExtents().toArray(new ResettableExtent[getExtents().size()]);
|
this.extents = getExtents().toArray(new ResettableExtent[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,9 +3,8 @@ package com.boydti.fawe.object.extent;
|
|||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.FaweLimit;
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
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.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
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.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -51,72 +51,64 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
public BiomeType getBiome(final BlockVector2 arg0) {
|
public BiomeType getBiome(final BlockVector2 arg0) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(final BlockVector3 arg0) {
|
public BlockState getBlock(final BlockVector3 arg0) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(final BlockVector3 arg0) {
|
public BlockState getLazyBlock(final BlockVector3 arg0) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final BlockVector2 arg0, final BiomeType arg1) {
|
public boolean setBiome(final BlockVector2 arg0, final BiomeType arg1) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(final BlockVector3 arg0, final BlockStateHolder arg1) throws WorldEditException {
|
public boolean setBlock(final BlockVector3 arg0, final BlockStateHolder arg1) throws WorldEditException {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getLazyBlock(int x, int y, int z) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -131,30 +123,28 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
return BlockVector3.at(0, 0, 0);
|
return BlockVector3.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
return BlockVector3.at(0, 0, 0);
|
return BlockVector3.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int z) {
|
public boolean contains(int x, int z) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int y, int z) {
|
public boolean contains(int x, int y, int z) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -162,11 +152,6 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Operation commitBefore() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Operation commit() {
|
public Operation commit() {
|
||||||
@ -177,27 +162,24 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,23 +3,21 @@ package com.boydti.fawe.object.extent;
|
|||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.FaweLimit;
|
||||||
import com.boydti.fawe.util.WEManager;
|
import com.boydti.fawe.util.WEManager;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
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.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
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.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||||
private final FaweLimit limit;
|
private final FaweLimit limit;
|
||||||
private final AbstractDelegateExtent extent;
|
private final AbstractDelegateExtent extent;
|
||||||
@ -46,21 +44,6 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
return super.createEntity(location, entity);
|
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
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getLazyBlock(int x, int y, int z) {
|
||||||
if (!limit.MAX_CHECKS()) {
|
if (!limit.MAX_CHECKS()) {
|
||||||
|
@ -30,7 +30,7 @@ public class StripNBTExtent extends AbstractDelegateExtent {
|
|||||||
*/
|
*/
|
||||||
public StripNBTExtent(Extent extent, Set<String> strip) {
|
public StripNBTExtent(Extent extent, Set<String> strip) {
|
||||||
super(extent);
|
super(extent);
|
||||||
this.strip = strip.toArray(new String[strip.size()]);
|
this.strip = strip.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
package com.boydti.fawe.object.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class AngleMask extends SolidBlockMask implements ResettableMask {
|
public class AngleMask extends SolidBlockMask implements ResettableMask {
|
||||||
public static double ADJACENT_MOD = 0.5;
|
public static double ADJACENT_MOD = 0.5;
|
||||||
@ -160,9 +158,4 @@ public class AngleMask extends SolidBlockMask implements ResettableMask {
|
|||||||
return testSlope(x, y, z);
|
return testSlope(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,4 @@ public class BlockLightMask extends AbstractExtentMask {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
package com.boydti.fawe.object.mask;
|
||||||
|
|
||||||
import com.boydti.fawe.object.extent.LightingExtent;
|
import com.boydti.fawe.object.extent.LightingExtent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class BrightnessMask extends AbstractExtentMask {
|
public class BrightnessMask extends AbstractExtentMask {
|
||||||
|
|
||||||
private final int min, max;
|
private final int min, max;
|
||||||
@ -28,9 +26,4 @@ public class BrightnessMask extends AbstractExtentMask {
|
|||||||
return false;
|
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.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class DataMask extends AbstractExtentMask implements ResettableMask {
|
public class DataMask extends AbstractExtentMask implements ResettableMask {
|
||||||
|
|
||||||
public DataMask(Extent extent) {
|
public DataMask(Extent extent) {
|
||||||
@ -31,9 +28,4 @@ public class DataMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
this.data = -1;
|
this.data = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
package com.boydti.fawe.object.mask;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class IdDataMask extends AbstractExtentMask implements ResettableMask {
|
public class IdDataMask extends AbstractExtentMask implements ResettableMask {
|
||||||
private transient int combined = -1;
|
private transient int combined = -1;
|
||||||
|
|
||||||
@ -31,9 +27,4 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
this.combined = -1;
|
this.combined = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,4 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
this.id = -1;
|
this.id = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,4 @@ public class LightMask extends AbstractExtentMask {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -27,9 +27,4 @@ public class OpacityMask extends AbstractExtentMask {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,4 @@ public class PlaneMask extends AbstractMask implements ResettableMask {
|
|||||||
mode = -1;
|
mode = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,4 @@ public class RadiusMask extends AbstractMask implements ResettableMask {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,4 @@ public class SkyLightMask extends AbstractExtentMask {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -88,9 +88,4 @@ public class SolidPlaneMask extends SolidBlockMask implements ResettableMask {
|
|||||||
mutable = new MutableBlockVector3();
|
mutable = new MutableBlockVector3();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,4 @@ public class XAxisMask extends AbstractMask implements ResettableMask {
|
|||||||
this.layer = -1;
|
this.layer = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
package com.boydti.fawe.object.mask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restricts the
|
* Restricts the
|
||||||
*/
|
*/
|
||||||
@ -26,9 +23,4 @@ public class YAxisMask extends AbstractMask implements ResettableMask {
|
|||||||
this.layer = -1;
|
this.layer = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,4 @@ public class ZAxisMask extends AbstractMask implements ResettableMask {
|
|||||||
this.layer = -1;
|
this.layer = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,21 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
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.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
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.AbstractPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
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.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.BlockStateHolder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class PatternExtent extends AbstractPattern implements Extent {
|
public class PatternExtent extends AbstractPattern implements Extent {
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
@ -55,12 +51,6 @@ public class PatternExtent extends AbstractPattern implements Extent {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Entity createEntity(Location location, BaseEntity entity) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
BlockStateHolder tmp = pattern.apply(position);
|
BlockStateHolder tmp = pattern.apply(position);
|
||||||
@ -116,12 +106,6 @@ public class PatternExtent extends AbstractPattern implements Extent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Operation commit() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
return pattern.apply(position);
|
return pattern.apply(position);
|
||||||
|
@ -9,16 +9,6 @@ public class ChatProgressTracker extends DefaultProgressTracker {
|
|||||||
setInterval(getDelay() / 50);
|
setInterval(getDelay() / 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendTask() {
|
|
||||||
super.sendTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doneTask() {
|
|
||||||
super.doneTask();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendTile(String title, String sub) {
|
public void sendTile(String title, String sub) {
|
||||||
getPlayer().sendMessage(BBC.getPrefix() + title + sub);
|
getPlayer().sendMessage(BBC.getPrefix() + title + sub);
|
||||||
|
@ -159,7 +159,7 @@ public class PolyhedralRegion extends AbstractRegion {
|
|||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// Generate minimal mesh to start from
|
// 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 - 2], v[size - 1])));
|
||||||
triangles.add((new Triangle(v[0], v[size - 1], v[size - 2])));
|
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.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.DoubleTag;
|
import com.sk89q.jnbt.*;
|
||||||
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.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
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.AbstractProperty;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Location;
|
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.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
|
||||||
import com.sk89q.worldedit.world.storage.NBTConversions;
|
import com.sk89q.worldedit.world.storage.NBTConversions;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -45,17 +36,17 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
||||||
private static final int WARN_SIZE = 32;
|
private static final int WARN_SIZE = 32;
|
||||||
|
|
||||||
private NBTInputStream in;
|
private NBTInputStream inputStream;
|
||||||
private NBTOutputStream out;
|
private NBTOutputStream out;
|
||||||
|
|
||||||
public StructureFormat(NBTInputStream in) {
|
public MinecraftStructure(@NotNull NBTInputStream inputStream) {
|
||||||
this.in = in;
|
this.inputStream = inputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StructureFormat(NBTOutputStream out) {
|
public MinecraftStructure(NBTOutputStream out) {
|
||||||
this.out = out;
|
this.out = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +56,13 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Clipboard read(UUID clipboardId) throws IOException {
|
public Clipboard read(UUID clipboardId) throws IOException {
|
||||||
NamedTag rootTag = in.readNamedTag();
|
NamedTag rootTag = inputStream.readNamedTag();
|
||||||
if (!rootTag.getName().equals("")) {
|
|
||||||
throw new IOException("Root tag does not exist or is not first");
|
// 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();
|
Map<String, Tag> tags = ((CompoundTag) rootTag.getTag()).getValue();
|
||||||
|
|
||||||
ListTag size = (ListTag) tags.get("size");
|
ListTag size = (ListTag) tags.get("size");
|
||||||
@ -258,8 +252,8 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
if (in != null) {
|
if (inputStream != null) {
|
||||||
in.close();
|
inputStream.close();
|
||||||
}
|
}
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
out.close();
|
out.close();
|
@ -1,6 +1,6 @@
|
|||||||
package com.boydti.fawe.object.visitor;
|
package com.boydti.fawe.object.visitor;
|
||||||
|
|
||||||
public abstract class FaweChunkVisitor {
|
public interface FaweChunkVisitor {
|
||||||
/**
|
/**
|
||||||
* The will run for each set block in the chunk
|
* The will run for each set block in the chunk
|
||||||
*
|
*
|
||||||
@ -9,5 +9,5 @@ public abstract class FaweChunkVisitor {
|
|||||||
* @param localZ The z position in the chunk (0-15)
|
* @param localZ The z position in the chunk (0-15)
|
||||||
* @param combined The combined id
|
* @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.MainUtil;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.SetQueue;
|
import com.boydti.fawe.util.SetQueue;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
|
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
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.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
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 com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -26,25 +28,20 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
public class PlotTrim {
|
public class PlotTrim {
|
||||||
private final MCAQueue queue;
|
private final MCAQueue queue;
|
||||||
private final PlotArea area;
|
private final PlotArea area;
|
||||||
private final PlotPlayer player;
|
private final PlotPlayer player;
|
||||||
private final MCAQueue originalQueue;
|
private final MCAQueue originalQueue;
|
||||||
private final File root;
|
private final File root;
|
||||||
private final File originalRoot;
|
|
||||||
private int[][] ids;
|
private int[][] ids;
|
||||||
private boolean deleteUnowned = true;
|
private boolean deleteUnowned;
|
||||||
|
|
||||||
public PlotTrim(PlotPlayer player, PlotArea area, String worldName, boolean deleteUnowned) {
|
public PlotTrim(PlotPlayer player, PlotArea area, String worldName, boolean deleteUnowned) {
|
||||||
FaweQueue tmpQueue = SetQueue.IMP.getNewQueue(worldName, true, false);
|
FaweQueue tmpQueue = SetQueue.IMP.getNewQueue(worldName, true, false);
|
||||||
File saveFolder = tmpQueue.getSaveFolder();
|
File saveFolder = tmpQueue.getSaveFolder();
|
||||||
this.root = new File(saveFolder.getParentFile().getParentFile(), worldName + "-Copy" + File.separator + "region");
|
this.root = new File(saveFolder.getParentFile().getParentFile(), worldName + "-Copy" + File.separator + "region");
|
||||||
this.originalRoot = saveFolder;
|
this.originalQueue = new MCAQueue(worldName, saveFolder, true);
|
||||||
this.originalQueue = new MCAQueue(worldName, originalRoot, true);
|
|
||||||
this.queue = new MCAQueue(worldName + "-Copy", root, true);
|
this.queue = new MCAQueue(worldName + "-Copy", root, true);
|
||||||
this.area = area;
|
this.area = area;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@ -124,10 +121,7 @@ public class PlotTrim {
|
|||||||
@Override
|
@Override
|
||||||
public boolean appliesFile(int mcaX, int mcaZ) {
|
public boolean appliesFile(int mcaX, int mcaZ) {
|
||||||
ChunkLoc loc = new ChunkLoc(mcaX, mcaZ);
|
ChunkLoc loc = new ChunkLoc(mcaX, mcaZ);
|
||||||
if (mcas.contains(loc)) {
|
return !mcas.contains(loc);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -155,11 +149,6 @@ public class PlotTrim {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean appliesChunk(int cx, int cz) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MCAChunk applyChunk(MCAChunk chunk, Object ignore) {
|
public MCAChunk applyChunk(MCAChunk chunk, Object ignore) {
|
||||||
long pair = MathMan.pairInt(chunk.getX(), chunk.getZ());
|
long pair = MathMan.pairInt(chunk.getX(), chunk.getZ());
|
||||||
@ -181,8 +170,6 @@ public class PlotTrim {
|
|||||||
player.sendMessage("Done!");
|
player.sendMessage("Done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private int count = 0;
|
|
||||||
|
|
||||||
private boolean isEqual(int[] a, int[] b) {
|
private boolean isEqual(int[] a, int[] b) {
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -2,7 +2,10 @@ package com.boydti.fawe.wrappers;
|
|||||||
|
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
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.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
@ -28,7 +31,6 @@ import com.sk89q.worldedit.world.weather.WeatherType;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class WorldWrapper extends AbstractWorld {
|
public class WorldWrapper extends AbstractWorld {
|
||||||
|
|
||||||
@ -99,7 +101,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
||||||
return TaskManager.IMP.sync((Supplier<Boolean>) () -> {
|
return TaskManager.IMP.sync(() -> {
|
||||||
try {
|
try {
|
||||||
return parent.generateTree(type, editSession, position);
|
return parent.generateTree(type, editSession, position);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
|
@ -50,9 +50,8 @@ public final class NBTInputStream implements Closeable {
|
|||||||
* from the specified input stream.
|
* from the specified input stream.
|
||||||
*
|
*
|
||||||
* @param is the 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);
|
this.is = new DataInputStream(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +151,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
if (reader instanceof NBTStreamer.ByteReader) {
|
if (reader instanceof NBTStreamer.ByteReader) {
|
||||||
NBTStreamer.ByteReader byteReader = (NBTStreamer.ByteReader) reader;
|
NBTStreamer.ByteReader byteReader = (NBTStreamer.ByteReader) reader;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (is instanceof InputStream) {
|
|
||||||
DataInputStream dis = is;
|
DataInputStream dis = is;
|
||||||
if (length > 1024) {
|
if (length > 1024) {
|
||||||
if (buf == null) {
|
if (buf == null) {
|
||||||
@ -169,23 +167,6 @@ public final class NBTInputStream implements Closeable {
|
|||||||
for (; i < length; i++) {
|
for (; i < length; i++) {
|
||||||
byteReader.run(i, dis.read());
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (reader instanceof NBTStreamer.LazyReader) {
|
} else if (reader instanceof NBTStreamer.LazyReader) {
|
||||||
reader.accept(length, is);
|
reader.accept(length, is);
|
||||||
} else {
|
} else {
|
||||||
@ -382,7 +363,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
int toRead = Math.min(length << 2, buf.length);
|
int toRead = Math.min(length << 2, buf.length);
|
||||||
is.readFully(buf, 0, toRead);
|
is.readFully(buf, 0, toRead);
|
||||||
for (int i = 0; i < toRead; i += 4, index++) {
|
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;
|
length -= toRead;
|
||||||
}
|
}
|
||||||
@ -583,7 +564,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
if (is instanceof AutoCloseable) {
|
if (is != null) {
|
||||||
try {
|
try {
|
||||||
((AutoCloseable) is).close();
|
((AutoCloseable) is).close();
|
||||||
} catch (Exception e) {
|
} 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.regions.shape.WorldEditExpressionEnvironment;
|
||||||
import com.sk89q.worldedit.util.Countable;
|
import com.sk89q.worldedit.util.Countable;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||||
import com.sk89q.worldedit.world.SimpleWorld;
|
import com.sk89q.worldedit.world.SimpleWorld;
|
||||||
@ -149,6 +150,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -377,7 +379,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
} else {
|
} else {
|
||||||
this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
||||||
if (allowedRegions.length == 1) {
|
if (allowedRegions.length == 1) {
|
||||||
Region region = allowedRegions[0];
|
|
||||||
this.extent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
|
this.extent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
|
||||||
} else {
|
} else {
|
||||||
this.extent = new MultiRegionExtent(this.extent, this.limit, allowedRegions);
|
this.extent = new MultiRegionExtent(this.extent, this.limit, allowedRegions);
|
||||||
@ -417,7 +418,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
|
|
||||||
public void resetLimit() {
|
public void resetLimit() {
|
||||||
this.limit.set(this.originalLimit);
|
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) {
|
if (find != null && find.get() != null) {
|
||||||
find.get().setLimit(this.limit);
|
find.get().setLimit(this.limit);
|
||||||
}
|
}
|
||||||
@ -456,7 +457,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* @return FaweRegionExtent (may be null)
|
* @return FaweRegionExtent (may be null)
|
||||||
*/
|
*/
|
||||||
public FaweRegionExtent getRegionExtent() {
|
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();
|
return traverser == null ? null : traverser.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,7 +741,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* @return mask, may be null
|
* @return mask, may be null
|
||||||
*/
|
*/
|
||||||
public Mask getMask() {
|
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;
|
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,30 +751,29 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* @return mask, may be null
|
* @return mask, may be null
|
||||||
*/
|
*/
|
||||||
public Mask getSourceMask() {
|
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;
|
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTransform(ResettableExtent transform) {
|
public void addTransform(ResettableExtent transform) {
|
||||||
wrapped = true;
|
wrapped = true;
|
||||||
if (transform == null) {
|
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;
|
AbstractDelegateExtent next = extent;
|
||||||
while (traverser != null && traverser.get() instanceof ResettableExtent) {
|
while (traverser != null && traverser.get() != null) {
|
||||||
traverser = traverser.next();
|
traverser = traverser.next();
|
||||||
next = traverser.get();
|
next = traverser.get();
|
||||||
}
|
}
|
||||||
this.extent = next;
|
this.extent = next;
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
this.extent = transform.setExtent(extent);
|
this.extent = transform.setExtent(extent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ResettableExtent getTransform() {
|
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) {
|
if (traverser != null) {
|
||||||
return (ResettableExtent) traverser.get();
|
return traverser.get();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -789,7 +789,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
} else {
|
} else {
|
||||||
new MaskTraverser(mask).reset(this);
|
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) {
|
if (maskingExtent != null && maskingExtent.get() != null) {
|
||||||
Mask oldMask = maskingExtent.get().getMask();
|
Mask oldMask = maskingExtent.get().getMask();
|
||||||
if (oldMask instanceof ResettableMask) {
|
if (oldMask instanceof ResettableMask) {
|
||||||
@ -828,7 +828,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
} else {
|
} else {
|
||||||
new MaskTraverser(mask).reset(this);
|
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) {
|
if (maskingExtent != null && maskingExtent.get() != null) {
|
||||||
Mask oldMask = maskingExtent.get().getMask();
|
Mask oldMask = maskingExtent.get().getMask();
|
||||||
if (oldMask instanceof ResettableMask) {
|
if (oldMask instanceof ResettableMask) {
|
||||||
@ -846,13 +846,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* @return the survival simulation extent
|
* @return the survival simulation extent
|
||||||
*/
|
*/
|
||||||
public SurvivalModeExtent getSurvivalExtent() {
|
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) {
|
if (survivalExtent != null) {
|
||||||
return survivalExtent.get();
|
return survivalExtent.get();
|
||||||
} else {
|
} else {
|
||||||
AbstractDelegateExtent extent = this.extent;
|
AbstractDelegateExtent extent = this.extent;
|
||||||
SurvivalModeExtent survival = new SurvivalModeExtent(extent.getExtent(), getWorld());
|
SurvivalModeExtent survival = new SurvivalModeExtent(extent.getExtent(), getWorld());
|
||||||
new ExtentTraverser(extent).setNext(survival);
|
new ExtentTraverser<>(extent).setNext(survival);
|
||||||
return survival;
|
return survival;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -879,21 +879,21 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
if (history == null) {
|
if (history == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ExtentTraverser traverseHistory = new ExtentTraverser(this.extent).find(HistoryExtent.class);
|
ExtentTraverser<HistoryExtent> traverseHistory = new ExtentTraverser<>(this.extent).find(HistoryExtent.class);
|
||||||
if (disableHistory) {
|
if (disableHistory) {
|
||||||
if (traverseHistory != null && traverseHistory.exists()) {
|
if (traverseHistory != null && traverseHistory.exists()) {
|
||||||
ExtentTraverser beforeHistory = traverseHistory.previous();
|
ExtentTraverser<HistoryExtent> beforeHistory = traverseHistory.previous();
|
||||||
ExtentTraverser afterHistory = traverseHistory.next();
|
ExtentTraverser<HistoryExtent> afterHistory = traverseHistory.next();
|
||||||
if (beforeHistory != null && beforeHistory.exists()) {
|
if (beforeHistory != null && beforeHistory.exists()) {
|
||||||
beforeHistory.setNext(afterHistory.get());
|
beforeHistory.setNext(afterHistory.get());
|
||||||
} else {
|
} else {
|
||||||
extent = (AbstractDelegateExtent) afterHistory.get();
|
extent = afterHistory.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (traverseHistory == null || !traverseHistory.exists()) {
|
} 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) {
|
if (traverseBypass != null) {
|
||||||
ExtentTraverser beforeHistory = traverseBypass.previous();
|
ExtentTraverser<AbstractDelegateExtent> beforeHistory = traverseBypass.previous();
|
||||||
beforeHistory.setNext(history);
|
beforeHistory.setNext(history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -940,19 +940,19 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
*
|
*
|
||||||
* @return a map of missing blocks
|
* @return a map of missing blocks
|
||||||
*/
|
*/
|
||||||
public Map<com.sk89q.worldedit.world.block.BlockType, Integer> popMissingBlocks() {
|
public Map<BlockType, Integer> popMissingBlocks() {
|
||||||
BlockBag bag = getBlockBag();
|
BlockBag bag = getBlockBag();
|
||||||
if (bag != null) {
|
if (bag != null) {
|
||||||
bag.flushChanges();
|
bag.flushChanges();
|
||||||
|
|
||||||
Map<com.sk89q.worldedit.world.block.BlockType, Integer> missingBlocks;
|
Map<BlockType, Integer> missingBlocks;
|
||||||
ChangeSet changeSet = getChangeSet();
|
ChangeSet changeSet = getChangeSet();
|
||||||
|
|
||||||
|
|
||||||
if (changeSet instanceof BlockBagChangeSet) {
|
if (changeSet instanceof BlockBagChangeSet) {
|
||||||
missingBlocks = ((BlockBagChangeSet) changeSet).popMissing();
|
missingBlocks = ((BlockBagChangeSet) changeSet).popMissing();
|
||||||
} else {
|
} 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) {
|
if (find != null && find.get() != null) {
|
||||||
missingBlocks = find.get().popMissing();
|
missingBlocks = find.get().popMissing();
|
||||||
} else {
|
} else {
|
||||||
@ -1228,7 +1228,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public boolean setBlock(final BlockVector3 position, final Pattern pattern) {
|
public boolean setBlock(final BlockVector3 position, final Pattern pattern) {
|
||||||
this.changes++;
|
this.changes++;
|
||||||
try {
|
try {
|
||||||
@ -1238,7 +1237,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public int setBlocks(final Set<BlockVector3> vset, final Pattern pattern) {
|
public int setBlocks(final Set<BlockVector3> vset, final Pattern pattern) {
|
||||||
RegionVisitor visitor = new RegionVisitor(vset, new BlockReplace(extent, pattern), this);
|
RegionVisitor visitor = new RegionVisitor(vset, new BlockReplace(extent, pattern), this);
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
@ -1276,7 +1274,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@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);
|
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_FAILS > 0) {
|
||||||
if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) {
|
if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) {
|
||||||
BBC.WORLDEDIT_SOME_FAILS.send(player, used.MAX_FAILS);
|
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);
|
BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION.send(player);
|
||||||
} else {
|
} else {
|
||||||
BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_LEVEL.send(player);
|
BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_LEVEL.send(player);
|
||||||
@ -1447,12 +1445,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
if (searchIDs.size() == 1) {
|
if (searchIDs.size() == 1) {
|
||||||
final BlockType id = searchIDs.iterator().next();
|
final BlockType id = searchIDs.iterator().next();
|
||||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
RegionVisitor visitor = new RegionVisitor(region, position -> getBlockType(position) == id, this);
|
||||||
@Override
|
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
|
||||||
return getBlockType(position) == id;
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
return visitor.getAffected();
|
return visitor.getAffected();
|
||||||
}
|
}
|
||||||
@ -1464,23 +1457,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int countBlock(final Region region, final boolean[] ids) {
|
public int countBlock(final Region region, final boolean[] ids) {
|
||||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
RegionVisitor visitor = new RegionVisitor(region, position -> ids[getBlockType(position).getInternalId()], this);
|
||||||
@Override
|
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
|
||||||
return ids[getBlockType(position).getInternalId()];
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
return visitor.getAffected();
|
return visitor.getAffected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int countBlock(final Region region, final Mask mask) {
|
public int countBlock(final Region region, final Mask mask) {
|
||||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
RegionVisitor visitor = new RegionVisitor(region, mask::test, this);
|
||||||
@Override
|
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
|
||||||
return mask.test(position);
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
return visitor.getAffected();
|
return visitor.getAffected();
|
||||||
}
|
}
|
||||||
@ -1494,12 +1477,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
*/
|
*/
|
||||||
public int countBlocks(Region region, Set<BlockStateHolder> searchBlocks) {
|
public int countBlocks(Region region, Set<BlockStateHolder> searchBlocks) {
|
||||||
Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(extent);
|
Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(extent);
|
||||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
RegionVisitor visitor = new RegionVisitor(region, mask::test, this);
|
||||||
@Override
|
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
|
||||||
return mask.test(position);
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
return visitor.getAffected();
|
return visitor.getAffected();
|
||||||
}
|
}
|
||||||
@ -1509,9 +1487,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
final int startPerformY = region.getMinimumPoint().getBlockY();
|
final int startPerformY = region.getMinimumPoint().getBlockY();
|
||||||
final int startCheckY = fullHeight ? 0 : startPerformY;
|
final int startCheckY = fullHeight ? 0 : startPerformY;
|
||||||
final int endY = region.getMaximumPoint().getBlockY();
|
final int endY = region.getMaximumPoint().getBlockY();
|
||||||
RegionVisitor visitor = new RegionVisitor(flat, new RegionFunction() {
|
RegionVisitor visitor = new RegionVisitor(flat, pos -> {
|
||||||
@Override
|
|
||||||
public boolean apply(BlockVector3 pos) throws WorldEditException {
|
|
||||||
int x = pos.getBlockX();
|
int x = pos.getBlockX();
|
||||||
int z = pos.getBlockZ();
|
int z = pos.getBlockZ();
|
||||||
int freeSpot = startCheckY;
|
int freeSpot = startCheckY;
|
||||||
@ -1532,7 +1508,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}, this);
|
}, this);
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
return this.changes;
|
return this.changes;
|
||||||
@ -1813,7 +1788,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* returned by a given pattern.
|
* returned by a given pattern.
|
||||||
*
|
*
|
||||||
* @param region the region to replace the blocks within
|
* @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
|
* @param replacement the replacement block
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @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.
|
* returned by a given pattern.
|
||||||
*
|
*
|
||||||
* @param region the region to replace the blocks within
|
* @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
|
* @param pattern the pattern that provides the new blocks
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @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 brushTool = (BrushTool) previous;
|
||||||
brushTool.clear(player);
|
brushTool.clear(player);
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,14 @@ import com.boydti.fawe.util.ImgurUtility;
|
|||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MaskTraverser;
|
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.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
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.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -86,10 +89,6 @@ import java.util.Set;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
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.
|
* Clipboard commands.
|
||||||
@ -132,9 +131,6 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
final BlockVector3 origin = region.getMinimumPoint();
|
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);
|
ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(editSession, region, !skipEntities, copyBiomes);
|
||||||
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
||||||
@ -152,7 +148,7 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
desc = "Copy the selection to the clipboard",
|
desc = "Copy the selection to the clipboard",
|
||||||
help = "Copy the selection to the clipboard\n" +
|
help = "Copy the selection to the clipboard\n" +
|
||||||
"Flags:\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" +
|
" -m sets a source mask so that excluded blocks become air\n" +
|
||||||
" -b copies biomes\n" +
|
" -b copies biomes\n" +
|
||||||
"WARNING: Pasting entities cannot yet be undone!",
|
"WARNING: Pasting entities cannot yet be undone!",
|
||||||
@ -161,7 +157,7 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.copy")
|
@CommandPermissions("worldedit.clipboard.copy")
|
||||||
public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
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 {
|
@Switch('m') Mask mask, CommandContext context, @Switch('b') boolean copyBiomes) throws WorldEditException {
|
||||||
BlockVector3 min = region.getMinimumPoint();
|
BlockVector3 min = region.getMinimumPoint();
|
||||||
BlockVector3 max = region.getMaximumPoint();
|
BlockVector3 max = region.getMaximumPoint();
|
||||||
@ -173,12 +169,14 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
BlockVector3 pos = session.getPlacementPosition(player);
|
BlockVector3 pos = session.getPlacementPosition(player);
|
||||||
fp.checkConfirmationRegion(() -> {
|
fp.checkConfirmationRegion(() -> {
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||||
|
|
||||||
session.setClipboard(new ClipboardHolder(clipboard));
|
session.setClipboard(new ClipboardHolder(clipboard));
|
||||||
|
|
||||||
clipboard.setOrigin(pos);
|
clipboard.setOrigin(pos);
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||||
copy.setCopyingEntities(!skipEntities);
|
copy.setCopyingEntities(copyEntities);
|
||||||
copy.setCopyBiomes(copyBiomes);
|
copy.setCopyBiomes(copyBiomes);
|
||||||
Mask sourceMask = editSession.getSourceMask();
|
Mask sourceMask = editSession.getSourceMask();
|
||||||
if (sourceMask != null) {
|
if (sourceMask != null) {
|
||||||
@ -225,9 +223,6 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
final BlockVector3 origin = region.getMinimumPoint();
|
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);
|
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||||
@ -242,8 +237,8 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
desc = "Cut the selection to the clipboard",
|
desc = "Cut the selection to the clipboard",
|
||||||
help = "Copy the selection to the clipboard\n" +
|
help = "Copy the selection to the clipboard\n" +
|
||||||
"Flags:\n" +
|
"Flags:\n" +
|
||||||
" -e skips entity copy\n" +
|
" -e will also cut entities\n" +
|
||||||
" -m sets a source mask so that excluded blocks become air\n" +
|
" -m <mask> sets a source mask so that excluded blocks become air\n" +
|
||||||
" -b copies biomes\n" +
|
" -b copies biomes\n" +
|
||||||
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
||||||
max = 1
|
max = 1
|
||||||
@ -251,7 +246,7 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.clipboard.cut")
|
@CommandPermissions("worldedit.clipboard.cut")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
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 {
|
@Switch('m') Mask mask, @Switch('b') boolean copyBiomes, CommandContext context) throws WorldEditException {
|
||||||
BlockVector3 min = region.getMinimumPoint();
|
BlockVector3 min = region.getMinimumPoint();
|
||||||
BlockVector3 max = region.getMaximumPoint();
|
BlockVector3 max = region.getMaximumPoint();
|
||||||
@ -266,11 +261,13 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
BlockVector3 pos = session.getPlacementPosition(player);
|
BlockVector3 pos = session.getPlacementPosition(player);
|
||||||
fp.checkConfirmationRegion(() -> {
|
fp.checkConfirmationRegion(() -> {
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||||
|
|
||||||
clipboard.setOrigin(pos);
|
clipboard.setOrigin(pos);
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||||
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
||||||
copy.setCopyingEntities(!skipEntities);
|
copy.setCopyingEntities(copyEntities);
|
||||||
copy.setRemovingEntities(true);
|
copy.setRemovingEntities(true);
|
||||||
copy.setCopyBiomes(copyBiomes);
|
copy.setCopyBiomes(copyBiomes);
|
||||||
Mask sourceMask = editSession.getSourceMask();
|
Mask sourceMask = editSession.getSourceMask();
|
||||||
@ -401,7 +398,7 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.clipboard.asset"})
|
@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;
|
final ClipboardFormat format = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
@ -438,7 +435,6 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/paste" },
|
aliases = { "/paste" },
|
||||||
usage = "",
|
|
||||||
flags = "saobe",
|
flags = "saobe",
|
||||||
desc = "Paste the clipboard's contents",
|
desc = "Paste the clipboard's contents",
|
||||||
help =
|
help =
|
||||||
@ -502,7 +498,6 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"/place"},
|
aliases = {"/place"},
|
||||||
usage = "",
|
|
||||||
flags = "sao",
|
flags = "sao",
|
||||||
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)",
|
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)",
|
||||||
help =
|
help =
|
||||||
@ -578,7 +573,7 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.flip")
|
@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 {
|
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
@ -595,7 +590,7 @@ public class ClipboardCommands extends MethodCommands {
|
|||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.clear")
|
@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);
|
session.setClipboard(null);
|
||||||
BBC.CLIPBOARD_CLEARED.send(player);
|
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.MultiClipboardHolder;
|
||||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
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.object.schematic.visualizer.SchemVis;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.chat.Message;
|
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.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
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.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
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.channels.ReadableByteChannel;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.LongAdder;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
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 (holder instanceof URIClipboardHolder) uri = ((URIClipboardHolder) holder).getURI(clipboard);
|
||||||
if (new PlayerSaveClipboardEvent(player, clipboard, uri, f.toURI()).call()) {
|
if (new PlayerSaveClipboardEvent(player, clipboard, uri, f.toURI()).call()) {
|
||||||
try (ClipboardWriter writer = format.getWriter(fos)) {
|
try (ClipboardWriter writer = format.getWriter(fos)) {
|
||||||
if (writer instanceof StructureFormat) {
|
if (writer instanceof MinecraftStructure) {
|
||||||
((StructureFormat) writer).write(target, player.getName());
|
((MinecraftStructure) writer).write(target, player.getName());
|
||||||
} else {
|
} else {
|
||||||
writer.write(target);
|
writer.write(target);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@ import com.sk89q.minecraft.util.commands.CommandException;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.MaxBrushRadiusException;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
@ -519,7 +521,9 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
double size = current.getSize();
|
double size = current.getSize();
|
||||||
WorldEdit.getInstance().checkMaxBrushRadius(size);
|
WorldEdit.getInstance().checkMaxBrushRadius(size);
|
||||||
brush.build(editSession, target, current.getMaterial(), 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
|
player.printError("Max blocks change limit reached."); // Never happens
|
||||||
} finally {
|
} finally {
|
||||||
if (bag != null) {
|
if (bag != null) {
|
||||||
|
@ -37,7 +37,6 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
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.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
@ -118,7 +117,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +266,6 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLight(int x, int y, int z) {
|
public int getLight(int x, int y, int z) {
|
||||||
return getBlockLight(x, y, z);
|
return getBlockLight(x, y, z);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package com.sk89q.worldedit.extent.clipboard;
|
package com.sk89q.worldedit.extent.clipboard;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
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)}
|
* 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
|
* 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.
|
* 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.PGZIPOutputStream;
|
||||||
import com.boydti.fawe.object.io.ResettableFileInputStream;
|
import com.boydti.fawe.object.io.ResettableFileInputStream;
|
||||||
import com.boydti.fawe.object.schematic.PNGWriter;
|
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.google.common.collect.ImmutableSet;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
@ -122,35 +123,41 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
|||||||
* The structure block format:
|
* The structure block format:
|
||||||
* http://minecraft.gamepedia.com/Structure_block_file_format
|
* http://minecraft.gamepedia.com/Structure_block_file_format
|
||||||
*/
|
*/
|
||||||
STRUCTURE("structure", "nbt") {
|
MINECRAFT_STRUCTURE("structure") {
|
||||||
|
@Override
|
||||||
|
public String getPrimaryFileExtension() {
|
||||||
|
return "nbt";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClipboardReader getReader(InputStream inputStream) throws IOException {
|
public ClipboardReader getReader(InputStream inputStream) throws IOException {
|
||||||
inputStream = new BufferedInputStream(inputStream);
|
inputStream = new BufferedInputStream(inputStream);
|
||||||
NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(inputStream)));
|
NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(inputStream)));
|
||||||
return new StructureFormat(nbtStream);
|
return new MinecraftStructure(nbtStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClipboardWriter getWriter(OutputStream outputStream) throws IOException {
|
public ClipboardWriter getWriter(OutputStream outputStream) throws IOException {
|
||||||
outputStream = new BufferedOutputStream(outputStream);
|
outputStream = new BufferedOutputStream(outputStream);
|
||||||
OutputStream gzip;
|
OutputStream gzip = new PGZIPOutputStream(outputStream);
|
||||||
if (outputStream instanceof PGZIPOutputStream || outputStream instanceof GZIPOutputStream) {
|
|
||||||
gzip = outputStream;
|
|
||||||
} else {
|
|
||||||
gzip = new PGZIPOutputStream(outputStream);
|
|
||||||
}
|
|
||||||
NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip));
|
NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip));
|
||||||
return new StructureFormat(nbtStream);
|
return new MinecraftStructure(nbtStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFormat(File file) {
|
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
|
return true;
|
||||||
public String getPrimaryFileExtension() {
|
|
||||||
return "nbt";
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ import com.sk89q.jnbt.Tag;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
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.registry.state.PropertyKey;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import static 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.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
@ -93,19 +91,11 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long[] adapt(Direction... dirs) {
|
private static long[] adapt(Direction... dirs) {
|
||||||
long[] arr = new long[dirs.length];
|
return Arrays.stream(dirs).mapToLong(dir -> 1L << dir.ordinal()).toArray();
|
||||||
for (int i = 0; i < arr.length; i++) {
|
|
||||||
arr[i] = 1L << dirs[i].ordinal();
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] adapt(Long... dirs) {
|
private static long[] adapt(Long... dirs) {
|
||||||
long[] arr = new long[dirs.length];
|
return Arrays.stream(dirs).mapToLong(dir -> dir).toArray();
|
||||||
for (int i = 0; i < arr.length; i++) {
|
|
||||||
arr[i] = dirs[i];
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] getDirections(AbstractProperty property) {
|
private static long[] getDirections(AbstractProperty property) {
|
||||||
@ -219,9 +209,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long notIndex(long mask, int... indexes) {
|
private static long notIndex(long mask, int... indexes) {
|
||||||
for (int index : indexes) {
|
mask |= Arrays.stream(indexes).mapToLong(index -> (1L << (index + values().length))).reduce(0, (a, b) -> a | b);
|
||||||
mask = mask | (1L << (index + values().length));
|
|
||||||
}
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,11 +376,6 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResettableExtent setExtent(Extent extent) {
|
|
||||||
return super.setExtent(extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the transform.
|
* Get the transform.
|
||||||
*
|
*
|
||||||
@ -469,7 +452,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return BlockState.getFromInternalId(newMaskedId);
|
return BlockState.getFromInternalId(newMaskedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BaseBlock transform(BlockStateHolder block) {
|
public final BaseBlock transform(BlockStateHolder<BaseBlock> block) {
|
||||||
BlockState transformed = transform(block.toImmutableState());
|
BlockState transformed = transform(block.toImmutableState());
|
||||||
if (block.hasNbtData()) {
|
if (block.hasNbtData()) {
|
||||||
return transformBaseBlockNBT(transformed, block.getNbtData(), transform);
|
return transformBaseBlockNBT(transformed, block.getNbtData(), transform);
|
||||||
@ -503,11 +486,6 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return transform(super.getLazyBlock(position));
|
return transform(super.getLazyBlock(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiomeType getBiome(BlockVector2 position) {
|
|
||||||
return super.getBiome(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||||
return super.setBlock(x, y, z, transformInverse(block));
|
return super.setBlock(x, y, z, transformInverse(block));
|
||||||
|
@ -20,13 +20,10 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
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.
|
* 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));
|
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.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -269,10 +268,4 @@ public class BlockMask extends AbstractExtentMask {
|
|||||||
return FastBitSet.get(bitSet, block.getInternalPropertiesId());
|
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.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BlockStateMask extends AbstractExtentMask {
|
public class BlockStateMask extends AbstractExtentMask {
|
||||||
@ -62,9 +61,4 @@ public class BlockStateMask extends AbstractExtentMask {
|
|||||||
.allMatch(entry -> block.getState(entry.getKey()) == entry.getValue());
|
.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;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -117,9 +114,4 @@ public class BlockTypeMask extends AbstractExtentMask {
|
|||||||
// return blocks.contains(getExtent().getBlock(vector).getBlockType());
|
// return blocks.contains(getExtent().getBlock(vector).getBlockType());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,8 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has the criteria where the Y value of passed positions must be within
|
* Has the criteria where the Y value of passed positions must be within
|
||||||
* a certain range of Y values (inclusive).
|
* a certain range of Y values (inclusive).
|
||||||
@ -51,10 +48,4 @@ public class BoundedHeightMask extends AbstractMask {
|
|||||||
return vector.getY() >= minY && vector.getY() <= maxY;
|
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.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mask that returns true whenever the block at the location is not
|
* A mask that returns true whenever the block at the location is not
|
||||||
* an air block (it contains some other block).
|
* an air block (it contains some other block).
|
||||||
@ -44,10 +42,4 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
|||||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,9 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mask that tests whether given positions are contained within a region.
|
* 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);
|
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.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class SolidBlockMask extends BlockTypeMask {
|
public class SolidBlockMask extends BlockTypeMask {
|
||||||
|
|
||||||
public static boolean[] getTypes() {
|
public static boolean[] getTypes() {
|
||||||
@ -48,10 +46,4 @@ public class SolidBlockMask extends BlockTypeMask {
|
|||||||
return block.getBlockType().getMaterial().isMovementBlocker();
|
return block.getBlockType().getMaterial().isMovementBlocker();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,4 @@ public class MutableVector3 extends Vector3 {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -309,8 +309,4 @@ public class Location extends Vector3 {
|
|||||||
return true;
|
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 com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.PriorityQueue;
|
import java.util.PriorityQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,6 +57,10 @@ public abstract class AbstractWorld implements World {
|
|||||||
return setBlock(pt, block, true);
|
return setBlock(pt, block, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path getStoragePath() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getMaxY() {
|
public int getMaxY() {
|
||||||
return getMaximumPoint().getBlockY();
|
return getMaximumPoint().getBlockY();
|
||||||
|
@ -20,29 +20,29 @@
|
|||||||
package com.sk89q.worldedit.world;
|
package com.sk89q.worldedit.world;
|
||||||
|
|
||||||
import com.boydti.fawe.util.SetQueue;
|
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.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
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.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.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
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.WeatherType;
|
||||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.PriorityQueue;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract implementation of {@link World}.
|
* An abstract implementation of {@link World}.
|
||||||
@ -67,6 +67,10 @@ public interface SimpleWorld extends World {
|
|||||||
@Override
|
@Override
|
||||||
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pt, B block) throws WorldEditException;
|
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pt, B block) throws WorldEditException;
|
||||||
|
|
||||||
|
@Nullable @Override default Path getStoragePath() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default int getMaxY() {
|
default int getMaxY() {
|
||||||
return getMaximumPoint().getBlockY();
|
return getMaximumPoint().getBlockY();
|
||||||
@ -117,11 +121,6 @@ public interface SimpleWorld extends World {
|
|||||||
return BlockVector3.at(30000000, 255, 30000000);
|
return BlockVector3.at(30000000, 255, 30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
default @Nullable Operation commit() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
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.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a world (dimension).
|
* Represents a world (dimension).
|
||||||
*/
|
*/
|
||||||
@ -50,11 +53,21 @@ public interface World extends Extent {
|
|||||||
*/
|
*/
|
||||||
String getName();
|
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.
|
* Get the maximum Y.
|
||||||
*
|
*
|
||||||
* @return the maximum Y
|
* @return the maximum Y
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
int getMaxY();
|
int getMaxY();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren