3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-07 20:10:06 +01:00

wip on FaweQueue

Dieser Commit ist enthalten in:
Jesse Boyd 2019-07-19 06:49:29 +10:00
Ursprung 1dcb18ae20
Commit e86e4c9c53
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
91 geänderte Dateien mit 540 neuen und 5951 gelöschten Zeilen

Datei anzeigen

@ -2,7 +2,7 @@ package com.boydti.fawe.bukkit.listener;
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.BrushSettings;
import com.boydti.fawe.object.extent.FastWorldEditExtent;

Datei anzeigen

@ -173,7 +173,7 @@ public class FaweAPI {
* @param world The name of the world
* @param autoqueue If it should start dispatching before you enqueue it.
* @return
* @see FaweQueue#enqueue()
* @see IQueueExtent#enqueue()
*/
public static IQueueExtent createQueue(World world, boolean autoqueue) {
IQueueExtent queue = Fawe.get().getQueueHandler().getQueue(world);

Datei anzeigen

@ -2,22 +2,37 @@ package com.boydti.fawe;
import com.boydti.fawe.beta.Trimable;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.jnbt.anvil.BitArray4096;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.IterableThreadLocal;
import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.*;
import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.DoubleTag;
import com.sk89q.jnbt.EndTag;
import com.sk89q.jnbt.FloatTag;
import com.sk89q.jnbt.IntArrayTag;
import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.LongArrayTag;
import com.sk89q.jnbt.LongTag;
import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.MutableVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.lang.reflect.Field;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

Datei anzeigen

@ -3,7 +3,6 @@ package com.boydti.fawe;
import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.image.ImageViewer;
@ -26,10 +25,6 @@ public interface IFawe {
TaskManager getTaskManager();
FaweQueue getNewQueue(World world, boolean fast);
FaweQueue getNewQueue(String world, boolean fast);
String getWorldName(World world);
Collection<FaweMaskManager> getMaskManagers();

Datei anzeigen

@ -1,54 +1,35 @@
package com.boydti.fawe.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC;
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.DebugFixP2Roads;
import com.boydti.fawe.jnbt.anvil.filters.DeleteBiomeFilterSimple;
import com.boydti.fawe.jnbt.anvil.filters.DeleteOldFilter;
import com.boydti.fawe.jnbt.anvil.filters.DeleteUnclaimedFilter;
import com.boydti.fawe.jnbt.anvil.filters.DeleteUninhabitedFilter;
import com.boydti.fawe.jnbt.anvil.filters.PlotTrimFilter;
import com.boydti.fawe.jnbt.anvil.filters.RemapFilter;
import com.boydti.fawe.jnbt.anvil.filters.RemoveLayerFilter;
import com.boydti.fawe.jnbt.anvil.filters.SetPatternFilter;
import com.boydti.fawe.jnbt.anvil.filters.TrimAirFilter;
import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory;
import com.boydti.fawe.jnbt.anvil.history.NullAnvilHistory;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal4;
import com.boydti.fawe.object.changeset.AnvilHistory;
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
import com.boydti.fawe.object.mask.FaweBlockMatcher;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.SetQueue;
import org.enginehub.piston.annotation.Command;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.Switch;
import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.Switch;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.function.Consumer;
import static com.google.common.base.Preconditions.checkNotNull;
@Command(aliases = {"/anvil"}, desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)")
public class AnvilCommands {
@ -62,81 +43,81 @@ public class AnvilCommands {
checkNotNull(worldEdit);
}
/**
* Run safely on an unloaded world (no selection)
*
* @param player
* @param folder
* @param filter
* @param <G>
* @param <T>
* @return
*/
@Deprecated
public static <G, T extends MCAFilter<G>> T runWithWorld(Player player, String folder, T filter, boolean force) {
return runWithWorld(player, folder, filter, force, false);
}
@Deprecated
public static <G, T extends MCAFilter<G>> T runWithWorld(Player player, String folder, T filter, boolean force, boolean unsafe) {
boolean copy = false;
if (FaweAPI.getWorld(folder) != null) {
if (!force) {
BBC.WORLD_IS_LOADED.send(player);
return null;
}
copy = true;
}
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
MCAQueue queue = new MCAQueue(defaultQueue);
if (copy && !unsafe) {
return queue.filterCopy(filter, RegionWrapper.GLOBAL());
} else {
return queue.filterWorld(filter);
}
}
/**
* Run safely on an existing world within a selection
*
* @param player
* @param editSession
* @param selection
* @param filter
* @param <G>
* @param <T>
* @return
*/
@Deprecated
public static <G, T extends MCAFilter<G>> T runWithSelection(Player player, EditSession editSession, Region selection, T filter) {
if (!(selection instanceof CuboidRegion)) {
BBC.NO_REGION.send(player);
return null;
}
CuboidRegion cuboid = (CuboidRegion) selection;
RegionWrapper wrappedRegion = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
String worldName = editSession.getWorld().getName();
FaweQueue tmp = SetQueue.IMP.getNewQueue(worldName, true, false);
MCAQueue queue = new MCAQueue(tmp);
FawePlayer<Object> fp = FawePlayer.wrap(player);
fp.checkAllowedRegion(selection);
recordHistory(fp, editSession.getWorld(), iAnvilHistory -> {
queue.filterCopy(filter, wrappedRegion, iAnvilHistory);
});
return filter;
}
public static void recordHistory(FawePlayer fp, World world, Consumer<IAnvilHistory> run) {
LocalSession session = fp.getSession();
if (session == null || session.hasFastMode()) {
run.accept(new NullAnvilHistory());
} else {
AnvilHistory history = new AnvilHistory(world.getName(), fp.getUUID());
run.accept(history);
session.remember(fp.getPlayer(), world, history, fp.getLimit());
}
}
// /**
// * Run safely on an unloaded world (no selection)
// *
// * @param player
// * @param folder
// * @param filter
// * @param <G>
// * @param <T>
// * @return
// */
// @Deprecated
// public static <G, T extends MCAFilter<G>> T runWithWorld(Player player, String folder, T filter, boolean force) {
// return runWithWorld(player, folder, filter, force, false);
// }
//
//
// @Deprecated
// public static <G, T extends MCAFilter<G>> T runWithWorld(Player player, String folder, T filter, boolean force, boolean unsafe) {
// boolean copy = false;
// if (FaweAPI.getWorld(folder) != null) {
// if (!force) {
// BBC.WORLD_IS_LOADED.send(player);
// return null;
// }
// copy = true;
// }
// IQueueExtent defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
// MCAQueue queue = new MCAQueue(defaultQueue);
// if (copy && !unsafe) {
// return queue.filterCopy(filter, RegionWrapper.GLOBAL());
// } else {
// return queue.filterWorld(filter);
// }
// }
//
// /**
// * Run safely on an existing world within a selection
// *
// * @param player
// * @param editSession
// * @param selection
// * @param filter
// * @param <G>
// * @param <T>
// * @return
// */
// @Deprecated
// public static <G, T extends MCAFilter<G>> T runWithSelection(Player player, EditSession editSession, Region selection, T filter) {
// if (!(selection instanceof CuboidRegion)) {
// BBC.NO_REGION.send(player);
// return null;
// }
// CuboidRegion cuboid = (CuboidRegion) selection;
// RegionWrapper wrappedRegion = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
// String worldName = editSession.getWorld().getName();
// IQueueExtent tmp = SetQueue.IMP.getNewQueue(worldName, true, false);
// MCAQueue queue = new MCAQueue(tmp);
// FawePlayer<Object> fp = FawePlayer.wrap(player);
// fp.checkAllowedRegion(selection);
// recordHistory(fp, editSession.getWorld(), iAnvilHistory -> {
// queue.filterCopy(filter, wrappedRegion, iAnvilHistory);
// });
// return filter;
// }
//
// public static void recordHistory(FawePlayer fp, World world, Consumer<IAnvilHistory> run) {
// LocalSession session = fp.getSession();
// if (session == null || session.hasFastMode()) {
// run.accept(new NullAnvilHistory());
// } else {
// AnvilHistory history = new AnvilHistory(world.getName(), fp.getUUID());
// run.accept(history);
// session.remember(fp.getPlayer(), world, history, fp.getLimit());
// }
// }
@Command(
name = "replaceall",
@ -146,7 +127,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.replaceall")
public void replaceAll(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, String to, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException {
// final FaweBlockMatcher matchFrom;
// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
// if (from == null) {
// matchFrom = FaweBlockMatcher.NOT_AIR;
// } else {
@ -168,15 +149,15 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.remapall")
public void remapall(Player player, String folder) throws WorldEditException {
ClipboardRemapper.RemapPlatform from;
ClipboardRemapper.RemapPlatform to;
from = ClipboardRemapper.RemapPlatform.PE;
to = ClipboardRemapper.RemapPlatform.PC;
RemapFilter filter = new RemapFilter(from, to);
RemapFilter result = runWithWorld(player, folder, filter, true);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// ClipboardRemapper.RemapPlatform from; TODO NOT IMPLEMENTED
// ClipboardRemapper.RemapPlatform to;
// from = ClipboardRemapper.RemapPlatform.PE;
// to = ClipboardRemapper.RemapPlatform.PC;
// RemapFilter filter = new RemapFilter(from, to);
// RemapFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@ -191,11 +172,11 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.deleteallunvisited")
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis) throws WorldEditException {
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis);
DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED
// DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -210,15 +191,15 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.deleteallunclaimed")
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis, @Switch(name='d', desc = "TODO") boolean debug) throws WorldEditException {
String folder = player.getWorld().getName();
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
if (debug) {
filter.enableDebug();
}
DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED
// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
// if (debug) {
// filter.enableDebug();
// }
// DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -233,14 +214,14 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.deleteunclaimed")
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis, @Switch(name='d', desc = "TODO") boolean debug) throws WorldEditException {
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
if (debug) {
filter.enableDebug();
}
DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED
// if (debug) {
// filter.enableDebug();
// }
// DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -253,12 +234,12 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.deletealloldregions")
public void deleteAllOldRegions(Player player, String folder, String time) throws WorldEditException {
long duration = MainUtil.timeToSec(time) * 1000L;
DeleteOldFilter filter = new DeleteOldFilter(duration);
DeleteOldFilter result = runWithWorld(player, folder, filter, true);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// long duration = MainUtil.timeToSec(time) * 1000L; TODO NOT IMPLEMENTED
// DeleteOldFilter filter = new DeleteOldFilter(duration);
// DeleteOldFilter result = runWithWorld(player, folder, filter, true);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -271,16 +252,16 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.trimallplots")
public void trimAllPlots(Player player, @Switch(name='v', desc = "TODO") boolean deleteUnvisited) throws WorldEditException {
String folder = player.getWorld().getName();
int visitTime = deleteUnvisited ? 1 : -1;
PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000);
// PlotTrimFilter result = runWithWorld(player, folder, filter, true);
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
MCAQueue queue = new MCAQueue(defaultQueue);
PlotTrimFilter result = queue.filterWorld(filter);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED
// int visitTime = deleteUnvisited ? 1 : -1;
// PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000);
//// PlotTrimFilter result = runWithWorld(player, folder, filter, true);
// IQueueExtent defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
// MCAQueue queue = new MCAQueue(defaultQueue);
// PlotTrimFilter result = queue.filterWorld(filter);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -290,11 +271,11 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.trimallair")
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch(name='u', desc = "TODO") boolean unsafe) {
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); TODO NOT IMPLEMENTED
// DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -304,11 +285,11 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.trimallair")
public void trimAllAir(Player player, String folder, @Switch(name='u', desc = "TODO") boolean unsafe) throws WorldEditException {
TrimAirFilter filter = new TrimAirFilter();
TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// TrimAirFilter filter = new TrimAirFilter(); TODO NOT IMPLEMENTED
// TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -318,11 +299,11 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.debugfixroads")
public void debugfixroads(Player player, String folder) throws WorldEditException {
DebugFixP2Roads filter = new DebugFixP2Roads();
DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// DebugFixP2Roads filter = new DebugFixP2Roads(); TODO NOT IMPLEMENTED
// DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -332,8 +313,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.replaceall")
public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException {
// MCAFilterCounter filter;
// MCAFilterCounter filter; TODO NOT IMPLEMENTED
// if (useMap) {
// if (to instanceof RandomPattern) {
// List<String> split = StringMan.split(from, ',');
@ -384,50 +364,50 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.clear")
public void unset(Player player, EditSession editSession, @Selection Region selection) throws WorldEditException {
BlockVector3 bot = selection.getMinimumPoint();
BlockVector3 top = selection.getMaximumPoint();
RegionWrapper region = new RegionWrapper(bot, top);
MCAFilterCounter filter = new MCAFilterCounter() {
@Override
public MCAFile applyFile(MCAFile file) {
int X = file.getX();
int Z = file.getZ();
int bcx = X << 5;
int bcz = Z << 5;
int bx = X << 9;
int bz = Z << 9;
if (region.isIn(bx, bz) && region.isIn(bx + 511, bz + 511)) {
file.setDeleted(true);
get().add(512 * 512 * 256);
} else if (region.isInMCA(X, Z)) {
file.init();
final byte[] empty = new byte[4];
RandomAccessFile raf = file.getRandomAccessFile();
file.forEachChunk(new RunnableVal4<Integer, Integer, Integer, Integer>() {
@Override
public void run(Integer cx, Integer cz, Integer offset, Integer size) {
if (region.isInChunk(bcx + cx, bcz + cz)) {
int index = ((cx & 31) << 2) + ((cz & 31) << 7);
try {
raf.seek(index);
raf.write(empty);
get().add(16 * 16 * 256);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
file.clear();
}
return null;
}
};
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// BlockVector3 bot = selection.getMinimumPoint(); TODO NOT IMPLEMENTED
// BlockVector3 top = selection.getMaximumPoint();
// RegionWrapper region = new RegionWrapper(bot, top);
//
// MCAFilterCounter filter = new MCAFilterCounter() {
// @Override
// public MCAFile applyFile(MCAFile file) {
// int X = file.getX();
// int Z = file.getZ();
// int bcx = X << 5;
// int bcz = Z << 5;
// int bx = X << 9;
// int bz = Z << 9;
// if (region.isIn(bx, bz) && region.isIn(bx + 511, bz + 511)) {
// file.setDeleted(true);
// get().add(512 * 512 * 256);
// } else if (region.isInMCA(X, Z)) {
// file.init();
// final byte[] empty = new byte[4];
// RandomAccessFile raf = file.getRandomAccessFile();
// file.forEachChunk(new RunnableVal4<Integer, Integer, Integer, Integer>() {
// @Override
// public void run(Integer cx, Integer cz, Integer offset, Integer size) {
// if (region.isInChunk(bcx + cx, bcz + cz)) {
// int index = ((cx & 31) << 2) + ((cz & 31) << 7);
// try {
// raf.seek(index);
// raf.write(empty);
// get().add(16 * 16 * 256);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// });
// file.clear();
// }
// return null;
// }
// };
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -436,7 +416,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.count")
public void count(Player player, EditSession editSession, @Selection Region selection, String arg, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException {
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true);
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED
// MCAFilterCounter filter;
// if (useData || arg.contains(":")) { // Optimize for both cases
// CountFilter counter = new CountFilter();
@ -458,7 +438,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.distr")
public void distr(Player player, EditSession editSession, @Selection Region selection, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException {
// long total = 0;
// long total = 0; TODO NOT IMPLEMENTED
// long[] count;
// MCAFilter<long[]> counts;
// if (useData) {
@ -537,8 +517,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.replace")
public void replace(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, String to, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException {
// final FaweBlockMatcher matchFrom;
// final FaweBlockMatcher matchFrom; TODO NOT IMPLEMENTED
// if (from == null) {
// matchFrom = FaweBlockMatcher.NOT_AIR;
// } else {
@ -561,8 +540,7 @@ public class AnvilCommands {
@CommandPermissions("worldedit.anvil.replace")
// Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap
public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException {
// MCAFilterCounter filter;
// MCAFilterCounter filter; TODO NOT IMPLEMENTED
// if (useMap) {
// if (to instanceof RandomPattern) {
// List<String> split = StringMan.split(from, ',');
@ -593,11 +571,11 @@ public class AnvilCommands {
@CommandPermissions("worldedit.anvil.set")
// Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap
public void set(Player player, EditSession editSession, @Selection Region selection, final Pattern to) throws WorldEditException {
MCAFilterCounter filter = new SetPatternFilter(to);
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@Command(
@ -607,15 +585,15 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.removelayer")
public void removeLayers(Player player, EditSession editSession, @Selection Region selection, int id) throws WorldEditException {
BlockVector3 min = selection.getMinimumPoint();
BlockVector3 max = selection.getMaximumPoint();
int minY = min.getBlockY();
int maxY = max.getBlockY();
RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id);
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
if (result != null) {
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
}
// BlockVector3 min = selection.getMinimumPoint(); TODO NOT IMPLEMENTED
// BlockVector3 max = selection.getMaximumPoint();
// int minY = min.getBlockY();
// int maxY = max.getBlockY();
// RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id);
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
// if (result != null) {
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
// }
}
@ -625,19 +603,19 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.copychunks")
public void copy(Player player, LocalSession session, EditSession editSession, @Selection Region selection) throws WorldEditException {
if (!(selection instanceof CuboidRegion)) {
BBC.NO_REGION.send(player);
return;
}
CuboidRegion cuboid = (CuboidRegion) selection;
String worldName = editSession.getWorld().getName();
FaweQueue tmp = SetQueue.IMP.getNewQueue(worldName, true, false);
MCAQueue queue = new MCAQueue(tmp);
BlockVector3 origin = session.getPlacementPosition(player);
MCAClipboard clipboard = new MCAClipboard(queue, cuboid, origin);
FawePlayer fp = FawePlayer.wrap(player);
fp.setMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD, clipboard);
BBC.COMMAND_COPY.send(player, selection.getArea());
// if (!(selection instanceof CuboidRegion)) { TODO NOT IMPLEMENTED
// BBC.NO_REGION.send(player);
// return;
// }
// CuboidRegion cuboid = (CuboidRegion) selection;
// String worldName = editSession.getWorld().getName();
// IQueueExtent tmp = SetQueue.IMP.getNewQueue(worldName, true, false);
// MCAQueue queue = new MCAQueue(tmp);
// BlockVector3 origin = session.getPlacementPosition(player);
// MCAClipboard clipboard = new MCAClipboard(queue, cuboid, origin);
// FawePlayer fp = FawePlayer.wrap(player);
// fp.setMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD, clipboard);
// BBC.COMMAND_COPY.send(player, selection.getArea());
}
@Command(
@ -649,8 +627,7 @@ public class AnvilCommands {
)
@CommandPermissions("worldedit.anvil.pastechunks")
public void paste(Player player, LocalSession session, EditSession editSession, @Switch(name='c', desc = "TODO") boolean alignChunk) throws WorldEditException, IOException {
// FawePlayer fp = FawePlayer.wrap(player);
// FawePlayer fp = FawePlayer.wrap(player); TODO NOT IMPLEMENTED
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
// if (clipboard == null) {
// fp.sendMessage("You must first use `//anvil copy`");
@ -666,7 +643,7 @@ public class AnvilCommands {
// int oZ = offset.getBlockZ();
// RegionWrapper pasteRegion = new RegionWrapper(copyRegion.minX + oX, copyRegion.maxX + oX, copyRegion.minZ + oZ, copyRegion.maxZ + oZ);
// String pasteWorldName = Fawe.imp().getWorldName(editSession.getWorld());
// FaweQueue tmpTo = SetQueue.IMP.getNewQueue(pasteWorldName, true, false);
// IQueueExtent tmpTo = SetQueue.IMP.getNewQueue(pasteWorldName, true, false);
// MCAQueue copyQueue = clipboard.getQueue();
// MCAQueue pasteQueue = new MCAQueue(tmpTo);
//

Datei anzeigen

@ -1,7 +1,7 @@
package com.boydti.fawe.command;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.changeset.CFIChangeSet;
import org.enginehub.piston.annotation.Command;

Datei anzeigen

@ -5,16 +5,14 @@ import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.SingleFilterBlock;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.util.CleanTextureUtil;
import com.boydti.fawe.util.FilteredTextureUtil;
import com.boydti.fawe.util.ImgurUtility;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.TextureUtil;
@ -46,10 +44,7 @@ import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.Dispatcher;
import org.enginehub.piston.annotation.param.Switch;
import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.util.command.parametric.ParameterException;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -95,7 +90,7 @@ public class CFICommands extends MethodCommands {
public static File getFolder(String worldName) {
Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
List<? extends World> worlds = platform.getWorlds();
FaweQueue queue = SetQueue.IMP.getNewQueue(worlds.get(0), true, false);
IQueueExtent queue = SetQueue.IMP.getNewQueue(worlds.get(0), true, false);
return new File(queue.getSaveFolder().getParentFile().getParentFile(), worldName + File.separator + "region");
}
@ -182,7 +177,7 @@ public class CFICommands extends MethodCommands {
desc = "Create the world"
)
@CommandPermissions("worldedit.anvil.cfi")
public void done(FawePlayer fp) throws ParameterException, IOException {
public void done(FawePlayer fp) {
CFISettings settings = assertSettings(fp);
HeightMapMCAGenerator generator = settings.getGenerator();

Datei anzeigen

@ -1,7 +1,5 @@
package com.boydti.fawe.command;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.util.TaskManager;
@ -17,12 +15,9 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import com.sk89q.worldedit.function.pattern.FawePattern;
import com.sk89q.worldedit.util.Location;
import java.io.File;
import java.io.IOException;
import java.util.function.Consumer;
import java.util.function.Function;
public class PlotLoader {

Datei anzeigen

@ -1,19 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
public class ChunkSimplifier {
private final HeightMapMCAGenerator gen;
public ChunkSimplifier(HeightMapMCAGenerator gen) {
this.gen = gen;
}
public void simplify(MCAChunk chunk) {
// Copy biome
// Calculate water level
// Determine floor block
// Determine overlay block
// determine main block
// Copy bedrock
// copy anomalies to blocks
}
}

Datei anzeigen

@ -1,145 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
public final class HeightMapMCADrawer {
private final HeightMapMCAGenerator gen;
private final TextureUtil tu;
private final ForkJoinPool pool;
public HeightMapMCADrawer(HeightMapMCAGenerator generator, TextureUtil textureUtil) {
this.gen = generator;
this.tu = textureUtil;
this.pool = new ForkJoinPool();
}
public HeightMapMCADrawer(HeightMapMCAGenerator generator) {
this(generator, Fawe.get().getCachedTextureUtil(false, 0, 100));
}
public BufferedImage draw() {
BufferedImage img = new BufferedImage(gen.getWidth(), gen.getLength(), BufferedImage.TYPE_INT_RGB);
final int[] overlay = gen.overlay == null ? gen.floor.get() : gen.overlay.get();
final int[] floor = gen.floor.get();
final int[] main = gen.main.get();
final byte[] heights = gen.heights.get();
final byte[] biomes = gen.biomes.get();
final int waterHeight = gen.primtives.waterHeight;
final int width = gen.getWidth();
final int length = gen.getLength();
int[] raw = ((DataBufferInt) img.getRaster().getDataBuffer()).getData();
int parallelism = pool.getParallelism();
int size = (heights.length + parallelism - 1) / parallelism;
for (int i = 0; i < parallelism; i++) {
int start = i * size;
int end = Math.min(heights.length, start + size);
pool.submit((Runnable) () -> {
for (int index = start; index < end; index ++) {
int height = (heights[index] & 0xFF);
int combined;
if ((combined = overlay[index]) == 0) {
height--;
combined = floor[index];
if (BlockTypes.getFromStateId(combined).getMaterial().isAir()) {
height--;
combined = main[index];
}
}
// draw combined
int color;
switch (combined >> 4) {
case 2:
color = getAverageBiomeColor(biomes, width, index);
break;
case 78:
color = (0xDD << 16) + (0xDD << 8) + (0xDD << 0);
break;
default:
color = tu.getColor(BlockTypes.getFromStateId(combined));
break;
}
int slope = getSlope(heights, width, index, height);
if (slope != 0) {
slope = (slope << 3) + (slope << 2);
int r = MathMan.clamp(((color >> 16) & 0xFF) + slope, 0, 255);
int g = MathMan.clamp(((color >> 8) & 0xFF) + slope, 0, 255);
int b = MathMan.clamp(((color >> 0) & 0xFF) + slope, 0, 255);
color = (r << 16) + (g << 8) + (b << 0);
}
if (height + 1 < waterHeight) {
int waterId = gen.primtives.waterId;
int waterColor = 0;
BlockType waterType = BlockTypes.get(waterId);
switch (waterType.getInternalId()) {
case BlockID.WATER:
color = tu.averageColor((0x11 << 16) + (0x66 << 8) + (0xCC), color);
break;
case BlockID.LAVA:
color = (0xCC << 16) + (0x33 << 8) + (0);
break;
default:
color = tu.getColor(waterType);
break;
}
}
raw[index] = color;
}
});
}
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
pool.shutdownNow();
return img;
}
private final int getAverageBiomeColor(byte[] biomes, int width, int index) {
int c0 = tu.getBiome(biomes[index] & 0xFF).grassCombined;
int c2 = getBiome(biomes, index + 1 + width, index);
int c1 = getBiome(biomes, index - 1 - width, index);
// int c3 = getBiome(biomes, index + width, index);
// int c4 = getBiome(biomes, index - width, index);
int r = ((c0 >> 16) & 0xFF) + ((c1 >> 16) & 0xFF) + ((c2 >> 16) & 0xFF);// + ((c3 >> 16) & 0xFF) + ((c4 >> 16) & 0xFF);
int g = ((c0 >> 8) & 0xFF) + ((c1 >> 8) & 0xFF) + ((c2 >> 8) & 0xFF);// + ((c3 >> 8) & 0xFF) + ((c4 >> 8) & 0xFF);
int b = ((c0) & 0xFF) + ((c1) & 0xFF) + ((c2) & 0xFF);// + ((c3) & 0xFF) + ((c4) & 0xFF);
r = r * 85 >> 8;
g = g * 85 >> 8;
b = b * 85 >> 8;
return (r << 16) + (g << 8) + (b);
}
private final int getBiome(byte[] biomes, int newIndex, int index) {
if (newIndex < 0 || newIndex >= biomes.length) newIndex = index;
int biome = biomes[newIndex] & 0xFF;
return tu.getBiome(biome).grassCombined;
}
private int getSlope(byte[] heights, int width, int index, int height) {
return (
+ getHeight(heights, index + 1, height)
// + getHeight(heights, index + width, height)
+ getHeight(heights, index + width + 1, height)
- getHeight(heights, index - 1, height)
// - getHeight(heights, index - width, height)
- getHeight(heights, index - width - 1, height)
);
}
private int getHeight(byte[] heights, int index, int height) {
if (index < 0 || index >= heights.length) return height;
return heights[index] & 0xFF;
}
}

Datei anzeigen

@ -1,796 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.jnbt.NBTStreamer;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
import com.boydti.fawe.object.number.MutableLong;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.*;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.function.BiConsumer;
public class MCAChunk extends FaweChunk<Void> {
public int[][] ids;
public byte[][] skyLight;
public byte[][] blockLight;
public byte[] biomes;
public Map<Short, CompoundTag> tiles = new HashMap<>();
public Map<UUID, CompoundTag> entities = new HashMap<>();
private long inhabitedTime;
private long lastUpdate;
private int[] heightMap;
private int modified;
private boolean deleted;
public MCAChunk(FaweQueue queue, int x, int z) {
super(queue, x, z);
this.ids = new int[16][];
this.skyLight = new byte[16][];
this.blockLight = new byte[16][];
this.biomes = new byte[256];
this.tiles = new HashMap<>();
this.entities = new HashMap<>();
this.lastUpdate = System.currentTimeMillis();
this.heightMap = new int[256];
this.setModified();
}
public MCAChunk(MCAChunk parent, boolean shallow) {
super(parent.getParent(), parent.getX(), parent.getZ());
if (shallow) {
this.ids = parent.ids;
this.skyLight = parent.skyLight;
this.blockLight = parent.blockLight;
this.biomes = parent.biomes;
this.tiles = parent.tiles;
this.entities = parent.entities;
this.inhabitedTime = parent.inhabitedTime;
this.lastUpdate = parent.lastUpdate;
this.heightMap = parent.heightMap;
this.modified = parent.modified;
this.deleted = parent.deleted;
} else {
this.ids = (int[][]) MainUtil.copyNd(parent.ids);
this.skyLight = (byte[][]) MainUtil.copyNd(parent.skyLight);
this.blockLight = (byte[][]) MainUtil.copyNd(parent.blockLight);
this.biomes = parent.biomes.clone();
this.tiles = new HashMap<>(parent.tiles);
this.entities = new HashMap<>(parent.entities);
this.inhabitedTime = parent.inhabitedTime;
this.lastUpdate = parent.lastUpdate;
this.heightMap = parent.heightMap.clone();
this.modified = parent.modified;
this.deleted = parent.deleted;
}
}
public void write(NBTOutputStream nbtOut) throws IOException {
nbtOut.writeNamedTagName("", NBTConstants.TYPE_COMPOUND);
nbtOut.writeLazyCompoundTag("Level", out -> {
out.writeNamedTag("V", (byte) 1);
out.writeNamedTag("xPos", getX());
out.writeNamedTag("zPos", getZ());
out.writeNamedTag("LightPopulated", (byte) 0);
out.writeNamedTag("TerrainPopulated", (byte) 1);
if (entities.isEmpty()) {
out.writeNamedEmptyList("Entities");
} else {
out.writeNamedTag("Entities", new ListTag(CompoundTag.class, new ArrayList<>(entities.values())));
}
if (tiles.isEmpty()) {
out.writeNamedEmptyList("TileEntities");
} else {
out.writeNamedTag("TileEntities", new ListTag(CompoundTag.class,
new ArrayList<>(tiles.values())));
}
out.writeNamedTag("InhabitedTime", inhabitedTime);
out.writeNamedTag("LastUpdate", lastUpdate);
if (biomes != null) {
out.writeNamedTag("Biomes", biomes);
}
out.writeNamedTag("HeightMap", heightMap);
out.writeNamedTagName("Sections", NBTConstants.TYPE_LIST);
nbtOut.getOutputStream().writeByte(NBTConstants.TYPE_COMPOUND);
int len = 0;
for (int[] id : ids) {
if (id != null) len++;
}
nbtOut.getOutputStream().writeInt(len);
for (int layer = 0; layer < ids.length; layer++) {
int[] idLayer = ids[layer];
if (idLayer == null) {
continue;
}
out.writeNamedTag("Y", (byte) layer);
out.writeNamedTag("BlockLight", blockLight[layer]);
out.writeNamedTag("SkyLight", skyLight[layer]);
out.writeNamedTag("Blocks", idLayer);
out.writeEndTag();
}
});
nbtOut.writeEndTag();
}
public byte[] toBytes(byte[] buffer) throws IOException {
if (buffer == null) {
buffer = new byte[8192];
}
FastByteArrayOutputStream buffered = new FastByteArrayOutputStream(buffer);
try (NBTOutputStream nbtOut = new NBTOutputStream(buffered)) {
write(nbtOut);
}
return buffered.toByteArray();
}
public long getInhabitedTime() {
return inhabitedTime;
}
public long getLastUpdate() {
return lastUpdate;
}
public void setInhabitedTime(long inhabitedTime) {
this.inhabitedTime = inhabitedTime;
}
public void setLastUpdate(long lastUpdate) {
this.lastUpdate = lastUpdate;
}
public void copyFrom(MCAChunk other, int minX, int maxX, int minY, int maxY, int minZ, int maxZ, int offsetX, int offsetY, int offsetZ) {
minY = Math.max(-offsetY - minY, minY);
maxY = Math.min(255 - offsetY, maxY);
minZ = Math.max(-offsetZ - minZ, minZ);
maxZ = Math.min(15 - offsetZ, maxZ);
minX = Math.max(-offsetX - minX, minX);
maxX = Math.min(15 - offsetX, maxX);
if (minX > maxX || minZ > maxZ || minY > maxY) return;
int startLayer = minY >> 4;
int endLayer = maxY >> 4;
for (int otherY = minY, thisY = minY + offsetY; otherY <= maxY; otherY++, thisY++) {
int thisLayer = thisY >> 4;
int otherLayer = otherY >> 4;
int[] thisIds = ids[thisLayer];
int[] otherIds = other.ids[otherLayer];
if (otherIds == null) {
if (thisIds != null) {
int indexY = (thisY & 15) << 8;
byte[] thisSkyLight = skyLight[thisLayer];
byte[] thisBlockLight = blockLight[thisLayer];
for (int otherZ = minZ, thisZ = minZ + offsetZ; otherZ <= maxZ; otherZ++, thisZ++) {
int startIndex = indexY + (thisZ << 4) + minX + offsetX;
int endIndex = startIndex + maxX - minX;
Arrays.fill(thisIds, startIndex, endIndex + 1, 0);
int startIndexShift = startIndex >> 1;
int endIndexShift = endIndex >> 1;
if ((startIndex & 1) != 0) {
startIndexShift++;
setNibble(startIndex, thisSkyLight, (byte) 0);
setNibble(startIndex, thisBlockLight, (byte) 0);
}
if ((endIndex & 1) != 1) {
endIndexShift--;
setNibble(endIndex, thisSkyLight, (byte) 0);
setNibble(endIndex, thisBlockLight, (byte) 0);
}
Arrays.fill(thisSkyLight, startIndexShift, endIndexShift + 1, (byte) 0);
Arrays.fill(thisBlockLight, startIndexShift, endIndexShift + 1, (byte) 0);
}
}
continue;
} else if (thisIds == null) {
ids[thisLayer] = thisIds = new int[4096];
skyLight[thisLayer] = new byte[2048];
blockLight[thisLayer] = new byte[2048];
}
int indexY = (thisY & 15) << 8;
int otherIndexY = (otherY & 15) << 8;
byte[] thisSkyLight = skyLight[thisLayer];
byte[] thisBlockLight = blockLight[thisLayer];
byte[] otherSkyLight = other.skyLight[otherLayer];
byte[] otherBlockLight = other.blockLight[otherLayer];
for (int otherZ = minZ, thisZ = minZ + offsetZ; otherZ <= maxZ; otherZ++, thisZ++) {
int startIndex = indexY + (thisZ << 4) + minX + offsetX;
int endIndex = startIndex + maxX - minX;
int otherStartIndex = otherIndexY + (otherZ << 4) + minX;
int otherEndIndex = otherStartIndex + maxX - minX;
System.arraycopy(otherIds, otherStartIndex, thisIds, startIndex, endIndex - startIndex + 1);
if ((startIndex & 1) == (otherStartIndex & 1)) {
int startIndexShift = startIndex >> 1;
int endIndexShift = endIndex >> 1;
int otherStartIndexShift = otherStartIndex >> 1;
if ((startIndex & 1) != 0) {
startIndexShift++;
otherStartIndexShift++;
setNibble(startIndex, thisSkyLight, getNibble(otherStartIndex, otherSkyLight));
setNibble(startIndex, thisBlockLight, getNibble(otherStartIndex, otherBlockLight));
}
if ((endIndex & 1) != 1) {
endIndexShift--;
setNibble(endIndex, thisSkyLight, getNibble(otherEndIndex, otherSkyLight));
setNibble(endIndex, thisBlockLight, getNibble(otherEndIndex, otherBlockLight));
}
System.arraycopy(otherSkyLight, otherStartIndexShift, thisSkyLight, startIndexShift, endIndexShift - startIndexShift + 1);
System.arraycopy(otherBlockLight, otherStartIndexShift, thisBlockLight, startIndexShift, endIndexShift - startIndexShift + 1);
} else {
for (int thisIndex = startIndex, otherIndex = otherStartIndex; thisIndex <= endIndex; thisIndex++, otherIndex++) {
setNibble(thisIndex, thisSkyLight, getNibble(otherIndex, otherSkyLight));
setNibble(thisIndex, thisBlockLight, getNibble(otherIndex, otherBlockLight));
}
}
}
}
if (!other.tiles.isEmpty()) {
for (Map.Entry<Short, CompoundTag> entry : other.tiles.entrySet()) {
int key = entry.getKey();
int x = MathMan.untripleBlockCoordX(key);
int y = MathMan.untripleBlockCoordY(key);
int z = MathMan.untripleBlockCoordZ(key);
if (x < minX || x > maxX) continue;
if (z < minZ || z > maxZ) continue;
if (y < minY || y > maxY) continue;
x += offsetX;
y += offsetY;
z += offsetZ;
short pair = MathMan.tripleBlockCoord(x, y, z);
CompoundTag tag = entry.getValue();
Map<String, Tag> map = ReflectionUtils.getMap(tag.getValue());
map.put("x", new IntTag((x & 15) + (getX() << 4)));
map.put("y", new IntTag(y));
map.put("z", new IntTag((z & 15) + (getZ() << 4)));
tiles.put(pair, tag);
}
}
}
public void copyFrom(MCAChunk other, int minY, int maxY, int offsetY) {
minY = Math.max(-offsetY - minY, minY);
maxY = Math.min(255 - offsetY, maxY);
if (minY > maxY) return;
if ((offsetY & 15) == 0) {
int offsetLayer = offsetY >> 4;
int startLayer = minY >> 4;
int endLayer = maxY >> 4;
for (int thisLayer = startLayer + offsetLayer, otherLayer = startLayer; thisLayer <= endLayer; thisLayer++, otherLayer++) {
int[] otherIds = other.ids[otherLayer];
int[] currentIds = ids[thisLayer];
int by = otherLayer << 4;
int ty = by + 15;
if (by >= minY && ty <= maxY) {
if (otherIds != null) {
ids[thisLayer] = otherIds;
skyLight[thisLayer] = other.skyLight[otherLayer];
blockLight[thisLayer] = other.blockLight[otherLayer];
} else {
ids[thisLayer] = null;
}
} else {
by = Math.max(by, minY) & 15;
ty = Math.min(ty, maxY) & 15;
int indexStart = by << 8;
int indexEnd = 256 + (ty << 8);
int indexStartShift = indexStart >> 1;
int indexEndShift = indexEnd >> 1;
if (otherIds == null) {
if (currentIds != null) {
Arrays.fill(currentIds, indexStart, indexEnd, 0);
Arrays.fill(skyLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
Arrays.fill(blockLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
}
} else {
if (currentIds == null) {
currentIds = this.ids[thisLayer] = new int[4096];
this.skyLight[thisLayer] = new byte[2048];
this.blockLight[thisLayer] = new byte[2048];
}
System.arraycopy(other.ids[otherLayer], indexStart, currentIds, indexStart, indexEnd - indexStart);
System.arraycopy(other.skyLight[otherLayer], indexStartShift, skyLight[thisLayer], indexStartShift, indexEndShift - indexStartShift);
System.arraycopy(other.blockLight[otherLayer], indexStartShift, blockLight[thisLayer], indexStartShift, indexEndShift - indexStartShift);
}
}
}
} else {
for (int otherY = minY, thisY = minY + offsetY; otherY <= maxY; otherY++, thisY++) {
int otherLayer = otherY >> 4;
int thisLayer = thisY >> 4;
int[] thisIds = this.ids[thisLayer];
int[] otherIds = other.ids[otherLayer];
int thisStartIndex = (thisY & 15) << 8;
int thisStartIndexShift = thisStartIndex >> 1;
if (otherIds == null) {
if (thisIds == null) {
continue;
}
Arrays.fill(thisIds, thisStartIndex, thisStartIndex + 256, 0);
Arrays.fill(this.skyLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
Arrays.fill(this.blockLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
continue;
} else if (thisIds == null) {
ids[thisLayer] = thisIds = new int[4096];
skyLight[thisLayer] = new byte[2048];
blockLight[thisLayer] = new byte[2048];
}
int otherStartIndex = (otherY & 15) << 8;
int otherStartIndexShift = otherStartIndex >> 1;
System.arraycopy(other.ids[otherLayer], otherStartIndex, thisIds, thisStartIndex, 256);
System.arraycopy(other.skyLight[otherLayer], otherStartIndexShift, skyLight[thisLayer], thisStartIndexShift, 128);
System.arraycopy(other.blockLight[otherLayer], otherStartIndexShift, blockLight[thisLayer], thisStartIndexShift, 128);
}
}
// Copy nbt
int thisMinY = minY + offsetY;
int thisMaxY = maxY + offsetY;
if (!tiles.isEmpty()) {
Iterator<Map.Entry<Short, CompoundTag>> iter = tiles.entrySet().iterator();
while (iter.hasNext()) {
int y = MathMan.untripleBlockCoordY(iter.next().getKey());
if (y >= thisMinY && y <= thisMaxY) iter.remove();
}
}
if (!other.tiles.isEmpty()) {
for (Map.Entry<Short, CompoundTag> entry : other.tiles.entrySet()) {
int key = entry.getKey();
int y = MathMan.untripleBlockCoordY(key);
if (y >= minY && y <= maxY) {
tiles.put((short) (key + offsetY), entry.getValue());
}
}
}
if (!other.entities.isEmpty()) {
for (Map.Entry<UUID, CompoundTag> entry : other.entities.entrySet()) {
// TODO FIXME
}
}
}
public int getMinLayer() {
for (int layer = 0; layer < ids.length; layer++) {
if (ids[layer] != null) {
return layer;
}
}
return Integer.MAX_VALUE;
}
public int getMaxLayer() {
for (int layer = ids.length - 1; layer >= 0; layer--) {
if (ids[layer] != null) {
return layer;
}
}
return Integer.MIN_VALUE;
}
/**
* Deprecated, use the toBytes method
*
* @return
*/
@Deprecated
public CompoundTag toTag() {
if (deleted) {
return null;
}
// e.g. by precalculating the length
HashMap<String, Object> level = new HashMap<>();
level.put("Entities", new ListTag(CompoundTag.class, new ArrayList<>(entities.values())));
level.put("TileEntities", new ListTag(CompoundTag.class, new ArrayList<>(tiles.values())));
level.put("InhabitedTime", inhabitedTime);
level.put("LastUpdate", lastUpdate);
level.put("LightPopulated", (byte) 0);
level.put("TerrainPopulated", (byte) 1);
level.put("V", (byte) 1);
level.put("xPos", getX());
level.put("zPos", getZ());
if (biomes != null) {
level.put("Biomes", biomes);
}
level.put("HeightMap", heightMap);
ArrayList<HashMap<String, Object>> sections = new ArrayList<>();
for (int layer = 0; layer < ids.length; layer++) {
int[] idLayer = ids[layer];
if (idLayer == null) {
continue;
}
HashMap<String, Object> map = new HashMap<>();
map.put("Y", (byte) layer);
map.put("BlockLight", blockLight[layer]);
map.put("SkyLight", skyLight[layer]);
map.put("Blocks", idLayer);
sections.add(map);
}
level.put("Sections", sections);
HashMap<String, Object> root = new HashMap<>();
root.put("Level", level);
return FaweCache.asTag(root);
}
public MCAChunk(NBTInputStream nis, FaweQueue parent, int x, int z, boolean readPos) throws IOException {
super(parent, x, z);
ids = new int[16][];
skyLight = new byte[16][];
blockLight = new byte[16][];
NBTStreamer streamer = new NBTStreamer(nis);
streamer.addReader(".Level.InhabitedTime",
(BiConsumer<Integer, Long>) (index, value) -> inhabitedTime = value);
streamer.addReader(".Level.LastUpdate",
(BiConsumer<Integer, Long>) (index, value) -> lastUpdate = value);
streamer.addReader(".Level.Sections.#", (BiConsumer<Integer, CompoundTag>) (index, tag) -> {
int layer = tag.getByte("Y");
ids[layer] = tag.getIntArray("Blocks");
skyLight[layer] = tag.getByteArray("SkyLight");
blockLight[layer] = tag.getByteArray("BlockLight");
});
streamer.addReader(".Level.TileEntities.#",
(BiConsumer<Integer, CompoundTag>) (index, tile) -> {
int x1 = tile.getInt("x") & 15;
int y = tile.getInt("y");
int z1 = tile.getInt("z") & 15;
short pair = MathMan.tripleBlockCoord(x1, y, z1);
tiles.put(pair, tile);
});
streamer.addReader(".Level.Entities.#",
(BiConsumer<Integer, CompoundTag>) (index, entityTag) -> {
if (entities == null) {
entities = new HashMap<>();
}
long least = entityTag.getLong("UUIDLeast");
long most = entityTag.getLong("UUIDMost");
entities.put(new UUID(most, least), entityTag);
});
streamer.addReader(".Level.Biomes",
(BiConsumer<Integer, byte[]>) (index, value) -> biomes = value);
streamer.addReader(".Level.HeightMap",
(BiConsumer<Integer, int[]>) (index, value) -> heightMap = value);
if (readPos) {
streamer.addReader(".Level.xPos",
(BiConsumer<Integer, Integer>) (index, value) -> MCAChunk.this.setLoc(getParent(), value, getZ()));
streamer.addReader(".Level.zPos",
(BiConsumer<Integer, Integer>) (index, value) -> MCAChunk.this.setLoc(getParent(), getX(), value));
}
streamer.readFully();
}
public long filterBlocks(MutableMCABackedBaseBlock mutableBlock, MCAFilter filter) {
MutableLong result = new MutableLong();
mutableBlock.setChunk(this);
int bx = getX() << 4;
int bz = getZ() << 4;
int tx = bx + 15;
int tz = bz + 15;
for (int layer = 0; layer < ids.length; layer++) {
if (doesSectionExist(layer)) {
mutableBlock.setArrays(layer);
int yStart = layer << 4;
int yEnd = yStart + 15;
for (int y = yStart, y0 = (yStart & 15); y <= yEnd; y++, y0++) {
int yIndex = ((y0) << 8);
mutableBlock.setY(y);
for (int z = bz, z0 = bz & 15; z <= tz; z++, z0++) {
int zIndex = yIndex + ((z0) << 4);
mutableBlock.setZ(z);
for (int x = bx, x0 = bx & 15; x <= tx; x++, x0++) {
int xIndex = zIndex + x0;
mutableBlock.setX(x);
mutableBlock.setIndex(xIndex);
filter.applyBlock(x, y, z, mutableBlock, result);
}
}
}
}
}
return result.get();
}
public int[] getHeightMapArray() {
return heightMap;
}
public void setDeleted(boolean deleted) {
setModified();
this.deleted = deleted;
}
public boolean isDeleted() {
return deleted;
}
public boolean isModified() {
return modified != 0;
}
public int getModified() {
return modified;
}
@Deprecated
public final void setModified() {
this.modified++;
}
@Override
public int getBitMask() {
int bitMask = 0;
for (int section = 0; section < ids.length; section++) {
if (ids[section] != null) {
bitMask += 1 << section;
}
}
return bitMask;
}
@Override
public void setTile(int x, int y, int z, CompoundTag tile) {
setModified();
short pair = MathMan.tripleBlockCoord(x, y, z);
if (tile != null) {
tiles.put(pair, tile);
} else {
tiles.remove(pair);
}
}
@Override
public void setEntity(CompoundTag entityTag) {
setModified();
long least = entityTag.getLong("UUIDLeast");
long most = entityTag.getLong("UUIDMost");
entities.put(new UUID(most, least), entityTag);
}
@Override
public void setBiome(int x, int z, BiomeType biome) {
setModified();
biomes[x + (z << 4)] = (byte) biome.getInternalId();
}
@Override
public Set<CompoundTag> getEntities() {
return new HashSet<>(entities.values());
}
@Override
public Map<Short, CompoundTag> getTiles() {
return tiles == null ? new HashMap<>() : tiles;
}
@Override
public CompoundTag getTile(int x, int y, int z) {
if (tiles == null || tiles.isEmpty()) {
return null;
}
short pair = MathMan.tripleBlockCoord(x, y, z);
return tiles.get(pair);
}
public boolean doesSectionExist(int cy) {
return ids[cy] != null;
}
@Override
public FaweChunk<Void> copy(boolean shallow) {
return new MCAChunk(this, shallow);
}
@Override
public int getBlockCombinedId(int x, int y, int z) {
int layer = y >> 4;
int[] idLayer = ids[layer];
if (idLayer == null) {
return 0;
}
return idLayer[(((y & 15) << 8) | ((z & 15) << 4) | (x & 15))];
}
@Override
public BiomeType[] getBiomeArray() {
BiomeType[] arr = new BiomeType[256];
for (int i = 0; i < arr.length; i++) {
arr[i] = BiomeTypes.get(biomes[i]);
}
return arr;
}
@Override
public BiomeType getBiomeType(int x, int z) {
return BiomeTypes.get(biomes[(x & 15) + ((z & 15) << 4)]);
}
@Override
public Set<UUID> getEntityRemoves() {
return new HashSet<>();
}
public void setSkyLight(int x, int y, int z, int value) {
setModified();
int layer = y >> 4;
byte[] skyLayer = skyLight[layer];
if (skyLayer == null) {
return;
}
setNibble((((y & 15) << 8) | ((z & 15) << 4) | (x & 15)), skyLayer, value);
}
public void setBlockLight(int x, int y, int z, int value) {
setModified();
int layer = y >> 4;
byte[] blockLayer = blockLight[layer];
if (blockLayer == null) {
return;
}
setNibble((((y & 15) << 8) | ((z & 15) << 4) | (x & 15)), blockLayer, value);
}
public int getSkyLight(int x, int y, int z) {
int layer = y >> 4;
byte[] skyLayer = skyLight[layer];
if (skyLayer == null) {
return 0;
}
return getNibble((((y & 15) << 8) | ((z & 15) << 4) | (x & 15)), skyLayer);
}
public int getBlockLight(int x, int y, int z) {
int layer = y >> 4;
byte[] blockLayer = blockLight[layer];
if (blockLayer == null) {
return 0;
}
return getNibble((((y & 15) << 8) | ((z & 15) << 4) | (x & 15)), blockLayer);
}
public void setFullbright() {
setModified();
for (byte[] array : skyLight) {
if (array != null) {
Arrays.fill(array, (byte) 255);
}
}
}
public void removeLight() {
for (int i = 0; i < skyLight.length; i++) {
removeLight(i);
}
}
public void removeLight(int i) {
byte[] array1 = skyLight[i];
if (array1 == null) {
return;
}
byte[] array2 = blockLight[i];
Arrays.fill(array1, (byte) 0);
Arrays.fill(array2, (byte) 0);
}
public int getNibble(int index, byte[] array) {
int indexShift = index >> 1;
if ((index & 1) == 0) {
return array[indexShift] & 15;
} else {
return array[indexShift] >> 4 & 15;
}
}
public void setNibble(int index, byte[] array, int value) {
int indexShift = index >> 1;
byte existing = array[indexShift];
int valueShift = value << 4;
if (existing == value + valueShift) {
return;
}
if ((index & 1) == 0) {
array[indexShift] = (byte) (existing & 240 | value);
} else {
array[indexShift] = (byte) (existing & 15 | valueShift);
}
}
public void setIdUnsafe(byte[] idsLayer, int index, byte id) {
idsLayer[index] = id;
}
public void setBlockUnsafe(byte[] idsLayer, byte[] dataLayer, int index, byte id, int data) {
idsLayer[index] = id;
setNibble(index, dataLayer, data);
}
@Override
public void setBlock(int x, int y, int z, int combinedId) {
setModified();
int layer = y >> 4;
int[] idsLayer = ids[layer];
if (idsLayer == null) {
idsLayer = this.ids[layer] = new int[4096];
this.skyLight[layer] = new byte[2048];
this.blockLight[layer] = new byte[2048];
}
idsLayer[(((y & 15) << 8) | ((z & 15) << 4) | (x & 15))] = combinedId;
}
@Override
public void setBiome(BiomeType biome) {
Arrays.fill(biomes, (byte) biome.getInternalId());
}
@Override
public void removeEntity(UUID uuid) {
setModified();
entities.remove(uuid);
}
private final boolean idsEqual(int[] a, int[] b) {
// Assumes both are null, or none are (idsEqual - 2d array)
// Assumes length is 4096
if (a == b) return true;
for (char i = 0; i < 4096; i++) {
if (a[i] != b[i]) return false;
}
return true;
}
private final boolean idsEqual(int[][] a, int[][] b, boolean matchNullToAir) {
// Assumes length is 16
for (byte i = 0; i < 16; i++) {
if ((a[i] == null) != (b[i] == null)) {
if (matchNullToAir) {
if (b[i] != null) {
for (int c : b[i]) {
if (c != 0) return false;
}
} else if (a[i] != null) {
for (int c : a[i]) {
if (c != 0) return false;
}
}
}
return false;
}
}
// Check the chunks close to the ground first
for (byte i = 4; i < 8; i++) {
if (!idsEqual(a[i], b[i])) return false;
}
for (byte i = 3; i >= 0; i--) {
if (!idsEqual(a[i], b[i])) return false;
}
for (byte i = 8; i < 16; i++) {
if (!idsEqual(a[i], b[i])) return false;
}
return true;
}
/**
* Check if the ids match the ids in the other chunk
* @param other
* @param matchNullToAir
* @return
*/
public boolean idsEqual(MCAChunk other, boolean matchNullToAir) {
return idsEqual(other.ids, this.ids, matchNullToAir);
}
@Override
public Void getChunk() {
throw new UnsupportedOperationException("Not applicable for this");
}
@Override
public FaweChunk call() {
throw new UnsupportedOperationException("Not supported");
}
}

Datei anzeigen

@ -1,28 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
public class MCAClipboard {
private final MCAQueue queue;
private final CuboidRegion region;
private final BlockVector3 origin;
public MCAClipboard(MCAQueue queue, CuboidRegion region, BlockVector3 origin) {
this.queue = queue;
this.region = region;
this.origin = origin;
}
public MCAQueue getQueue() {
return queue;
}
public CuboidRegion getRegion() {
return region;
}
public BlockVector3 getOrigin() {
return origin;
}
}

Datei anzeigen

@ -1,678 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.jnbt.NBTStreamer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.RunnableVal4;
import com.boydti.fawe.object.collection.IterableThreadLocal;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.io.BufferedRandomAccessFile;
import com.boydti.fawe.object.io.FastByteArrayInputStream;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.NBTInputStream;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
/**
* Chunk format: http://minecraft.gamepedia.com/Chunk_format#Entity_format
* e.g.: `.Level.Entities.#` (Starts with a . as the root tag is unnamed)
*/
public class MCAFile {
private static Field fieldBuf2;
private static Field fieldBuf3;
static {
try {
fieldBuf2 = InflaterInputStream.class.getDeclaredField("buf");
fieldBuf2.setAccessible(true);
fieldBuf3 = NBTInputStream.class.getDeclaredField("buf");
fieldBuf3.setAccessible(true);
} catch (Throwable e) {
e.printStackTrace();
}
}
private final FaweQueue queue;
private final File file;
private RandomAccessFile raf;
private byte[] locations;
private boolean deleted;
private final int X, Z;
private final Int2ObjectOpenHashMap<MCAChunk> chunks = new Int2ObjectOpenHashMap<>();
final ThreadLocal<byte[]> byteStore1 = new ThreadLocal<byte[]>() {
@Override
protected byte[] initialValue() {
return new byte[4096];
}
};
final ThreadLocal<byte[]> byteStore2 = new ThreadLocal<byte[]>() {
@Override
protected byte[] initialValue() {
return new byte[4096];
}
};
final ThreadLocal<byte[]> byteStore3 = new ThreadLocal<byte[]>() {
@Override
protected byte[] initialValue() {
return new byte[1024];
}
};
public MCAFile(FaweQueue parent, File file) {
this.queue = parent;
this.file = file;
if (!file.exists()) {
throw FaweException.CHUNK;
}
String[] split = file.getName().split("\\.");
X = Integer.parseInt(split[1]);
Z = Integer.parseInt(split[2]);
}
public MCAFile(FaweQueue parent, int mcrX, int mcrZ) throws Exception {
this(parent, mcrX, mcrZ, new File(parent.getSaveFolder(), "r." + mcrX + "." + mcrZ + ".mca"));
}
public MCAFile(FaweQueue parent, int mcrX, int mcrZ, File file) {
this.queue = parent;
this.file = file;
X = mcrX;
Z = mcrZ;
}
public void clear() {
if (raf != null) {
try {
raf.close();
} catch (IOException e) {
e.printStackTrace();
}
}
synchronized (chunks) {
chunks.clear();
}
locations = null;
IterableThreadLocal.clean(byteStore1);
IterableThreadLocal.clean(byteStore2);
IterableThreadLocal.clean(byteStore3);
}
@Override
protected void finalize() throws Throwable {
IterableThreadLocal.clean(byteStore1);
IterableThreadLocal.clean(byteStore2);
IterableThreadLocal.clean(byteStore3);
super.finalize();
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
public boolean isDeleted() {
return deleted;
}
public FaweQueue getParent() {
return queue;
}
/**
* Loads the location header from disk
*/
public void init() {
try {
if (raf == null) {
this.locations = new byte[4096];
if (file != null) {
this.raf = new RandomAccessFile(file, "rw");
if (raf.length() < 8192) {
raf.setLength(8192);
} else {
raf.seek(0);
raf.readFully(locations);
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
public int getX() {
return X;
}
public int getZ() {
return Z;
}
public RandomAccessFile getRandomAccessFile() {
return raf;
}
public File getFile() {
return file;
}
public MCAChunk getCachedChunk(int cx, int cz) {
int pair = MathMan.pair((short) (cx & 31), (short) (cz & 31));
synchronized (chunks) {
return chunks.get(pair);
}
}
public void setChunk(MCAChunk chunk) {
int cx = chunk.getX();
int cz = chunk.getZ();
int pair = MathMan.pair((short) (cx & 31), (short) (cz & 31));
synchronized (chunks) {
chunks.put(pair, chunk);
}
}
public MCAChunk getChunk(int cx, int cz) throws IOException {
MCAChunk cached = getCachedChunk(cx, cz);
if (cached != null) {
return cached;
} else {
return readChunk(cx, cz);
}
}
public MCAChunk readChunk(int cx, int cz) throws IOException {
int i = ((cx & 31) << 2) + ((cz & 31) << 7);
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF))) << 12;
int size = (locations[i + 3] & 0xFF) << 12;
if (offset == 0) {
return null;
}
NBTInputStream nis = getChunkIS(offset);
MCAChunk chunk = new MCAChunk(nis, queue, cx, cz, false);
nis.close();
int pair = MathMan.pair((short) (cx & 31), (short) (cz & 31));
synchronized (chunks) {
chunks.put(pair, chunk);
}
return chunk;
}
/**
* CX, CZ, OFFSET, SIZE
*
* @param onEach
* @throws IOException
*/
public void forEachSortedChunk(RunnableVal4<Integer, Integer, Integer, Integer> onEach) throws IOException {
char[] offsets = new char[(int) (raf.length() / 4096) - 2];
Arrays.fill(offsets, Character.MAX_VALUE);
char i = 0;
for (int z = 0; z < 32; z++) {
for (int x = 0; x < 32; x++, i += 4) {
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF))) - 2;
int size = locations[i + 3] & 0xFF;
if (size != 0) {
if (offset < offsets.length) {
offsets[offset] = i;
} else {
Fawe.debug("Ignoring invalid offset " + offset);
}
}
}
}
for (i = 0; i < offsets.length; i++) {
int index = offsets[i];
if (index != Character.MAX_VALUE) {
int offset = i + 2;
int size = locations[index + 3] & 0xFF;
int index2 = index >> 2;
int x = (index2) & 31;
int z = (index2) >> 5;
onEach.run(x, z, offset << 12, size << 12);
}
}
}
/**
* @param onEach cx, cz, offset, size
*/
public void forEachChunk(RunnableVal4<Integer, Integer, Integer, Integer> onEach) {
int i = 0;
for (int z = 0; z < 32; z++) {
for (int x = 0; x < 32; x++, i += 4) {
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF)));
int size = locations[i + 3] & 0xFF;
if (size != 0) {
onEach.run(x, z, offset << 12, size << 12);
}
}
}
}
public void forEachChunk(RunnableVal<MCAChunk> onEach) {
int i = 0;
for (int z = 0; z < 32; z++) {
for (int x = 0; x < 32; x++, i += 4) {
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF)));
int size = locations[i + 3] & 0xFF;
if (size != 0) {
try {
onEach.run(getChunk(x, z));
} catch (Throwable ignore) {
}
}
}
}
}
public int getOffset(int cx, int cz) {
int i = ((cx & 31) << 2) + ((cz & 31) << 7);
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF)));
return offset << 12;
}
public int getSize(int cx, int cz) {
int i = ((cx & 31) << 2) + ((cz & 31) << 7);
return (locations[i + 3] & 0xFF) << 12;
}
public List<Integer> getChunks() {
final List<Integer> values;
synchronized (chunks) {
values = new ArrayList<>(chunks.size());
}
for (int i = 0; i < locations.length; i += 4) {
int offset = (((locations[i] & 0xFF) << 16) + ((locations[i + 1] & 0xFF) << 8) + ((locations[i + 2] & 0xFF)));
values.add(offset);
}
return values;
}
public byte[] getChunkCompressedBytes(int offset) throws IOException {
if (offset == 0) {
return null;
}
synchronized (raf) {
raf.seek(offset);
int size = raf.readInt();
int compression = raf.read();
byte[] data = new byte[size];
raf.readFully(data);
return data;
}
}
private NBTInputStream getChunkIS(int offset) throws IOException {
try {
byte[] data = getChunkCompressedBytes(offset);
FastByteArrayInputStream bais = new FastByteArrayInputStream(data);
InflaterInputStream iis = new InflaterInputStream(bais, new Inflater(), 1);
fieldBuf2.set(iis, byteStore2.get());
BufferedInputStream bis = new BufferedInputStream(iis);
NBTInputStream nis = new NBTInputStream(bis);
fieldBuf3.set(nis, byteStore3.get());
return nis;
} catch (IllegalAccessException unlikely) {
unlikely.printStackTrace();
return null;
}
}
public void streamChunk(int cx, int cz, RunnableVal<NBTStreamer> addReaders) throws IOException {
streamChunk(getOffset(cx, cz), addReaders);
}
public void streamChunk(int offset, RunnableVal<NBTStreamer> withStream) throws IOException {
byte[] data = getChunkCompressedBytes(offset);
streamChunk(data, withStream);
}
public void streamChunk(byte[] data, RunnableVal<NBTStreamer> withStream) throws IOException {
if (data != null) {
try {
FastByteArrayInputStream nbtIn = new FastByteArrayInputStream(data);
FastByteArrayInputStream bais = new FastByteArrayInputStream(data);
InflaterInputStream iis = new InflaterInputStream(bais, new Inflater(), 1);
fieldBuf2.set(iis, byteStore2.get());
BufferedInputStream bis = new BufferedInputStream(iis);
NBTInputStream nis = new NBTInputStream(bis);
fieldBuf3.set(nis, byteStore3.get());
NBTStreamer streamer = new NBTStreamer(nis);
withStream.run(streamer);
streamer.readQuick();
} catch (IllegalAccessException unlikely) {
unlikely.printStackTrace();
}
}
}
/**
* @param onEach chunk
*/
public void forEachCachedChunk(RunnableVal<MCAChunk> onEach) {
synchronized (chunks) {
for (Map.Entry<Integer, MCAChunk> entry : chunks.entrySet()) {
onEach.run(entry.getValue());
}
}
}
public List<MCAChunk> getCachedChunks() {
synchronized (chunks) {
return new ArrayList<>(chunks.values());
}
}
public void uncache(int cx, int cz) {
int pair = MathMan.pair((short) (cx & 31), (short) (cz & 31));
synchronized (chunks) {
chunks.remove(pair);
}
}
private byte[] toBytes(MCAChunk chunk) throws Exception {
if (chunk.isDeleted()) {
return null;
}
byte[] uncompressed = chunk.toBytes(byteStore3.get());
byte[] compressed = MainUtil.compress(uncompressed, byteStore2.get(), null);
return compressed;
}
private byte[] getChunkBytes(int cx, int cz) throws Exception {
MCAChunk mca = getCachedChunk(cx, cz);
if (mca == null) {
int offset = getOffset(cx, cz);
if (offset == 0) {
return null;
}
return getChunkCompressedBytes(offset);
}
return toBytes(mca);
}
private void writeSafe(RandomAccessFile raf, int offset, byte[] data) throws IOException {
int len = data.length + 5;
raf.seek(offset);
if (raf.length() - offset < len) {
raf.setLength(((offset + len + 4095) / 4096) * 4096);
}
// Length of remaining data
raf.writeInt(data.length + 1);
// Compression type
raf.write(2);
raf.write(data);
}
private void writeHeader(RandomAccessFile raf, int cx, int cz, int offsetMedium, int sizeByte, boolean writeTime) throws IOException {
int i = ((cx & 31) << 2) + ((cz & 31) << 7);
locations[i] = (byte) (offsetMedium >> 16);
locations[i + 1] = (byte) (offsetMedium >> 8);
locations[i + 2] = (byte) (offsetMedium);
locations[i + 3] = (byte) sizeByte;
raf.seek(i);
raf.write((offsetMedium >> 16));
raf.write((offsetMedium >> 8));
raf.write((offsetMedium >> 0));
raf.write(sizeByte);
raf.seek(i + 4096);
if (offsetMedium == 0 && sizeByte == 0) {
raf.writeInt(0);
} else {
raf.writeInt((int) (System.currentTimeMillis() / 1000L));
}
}
public void close(ForkJoinPool pool) {
if (raf == null) return;
synchronized (raf) {
if (raf != null) {
flush(pool);
try {
raf.close();
} catch (IOException e) {
e.printStackTrace();
}
raf = null;
locations = null;
}
}
}
public boolean isModified() {
if (isDeleted()) {
return true;
}
synchronized (chunks) {
for (Int2ObjectMap.Entry<MCAChunk> entry : chunks.int2ObjectEntrySet()) {
MCAChunk chunk = entry.getValue();
if (chunk.isModified() || chunk.isDeleted()) {
return true;
}
}
}
return false;
}
/**
* Write the chunk to the file
* @param pool
*/
public void flush(ForkJoinPool pool) {
synchronized (raf) {
// If the file is marked as deleted, nothing is written
if (isDeleted()) {
clear();
file.delete();
return;
}
boolean wait; // If the flush method needs to wait for the pool
if (pool == null) {
wait = true;
pool = new ForkJoinPool();
} else wait = false;
// Chunks that need to be relocated
Int2ObjectOpenHashMap<byte[]> relocate = new Int2ObjectOpenHashMap<>();
// The position of each chunk
final Int2ObjectOpenHashMap<Integer> offsetMap = new Int2ObjectOpenHashMap<>(); // Offset -> <byte cx, byte cz, short size>
// The data of each modified chunk
final Int2ObjectOpenHashMap<byte[]> compressedMap = new Int2ObjectOpenHashMap<>();
// The data of each chunk that needs to be moved
final Int2ObjectOpenHashMap<byte[]> append = new Int2ObjectOpenHashMap<>();
boolean modified = false;
// Get the current time for the chunk timestamp
long now = System.currentTimeMillis();
// Load the chunks into the append or compressed map
for (MCAChunk chunk : getCachedChunks()) {
if (chunk.isModified() || chunk.isDeleted()) {
modified = true;
chunk.setLastUpdate(now);
if (!chunk.isDeleted()) {
pool.submit(new Runnable() {
@Override
public void run() {
try {
byte[] compressed = toBytes(chunk);
int pair = MathMan.pair((short) (chunk.getX() & 31), (short) (chunk.getZ() & 31));
Int2ObjectOpenHashMap map;
if (getOffset(chunk.getX(), chunk.getZ()) == 0) {
map = append;
} else {
map = compressedMap;
}
synchronized (map) {
map.put(pair, compressed);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
});
}
}
}
// If any changes were detected
if (modified) {
file.setLastModified(now);
// Load the offset data into the offset map
forEachChunk(new RunnableVal4<Integer, Integer, Integer, Integer>() {
@Override
public void run(Integer cx, Integer cz, Integer offset, Integer size) {
short pair1 = MathMan.pairByte((byte) (cx & 31), (byte) (cz & 31));
short pair2 = (short) (size >> 12);
offsetMap.put((int) offset, (Integer) MathMan.pair(pair1, pair2));
}
});
// Wait for previous tasks
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
int start = 8192;
int written = start;
int end = 8192;
int nextOffset = 8192;
try {
for (int count = 0; count < offsetMap.size(); count++) {
// Get the previous position of the next chunk
Integer loc = offsetMap.get(nextOffset);
while (loc == null) {
nextOffset += 4096;
loc = offsetMap.get(nextOffset);
}
int offset = nextOffset;
// Get the x/z from the paired location
short cxz = MathMan.unpairX(loc);
int cx = MathMan.unpairShortX(cxz);
int cz = MathMan.unpairShortY(cxz);
// Get the size from the pair
int size = MathMan.unpairY(loc) << 12;
nextOffset += size;
end = Math.min(start + size, end);
int pair = MathMan.pair((short) (cx & 31), (short) (cz & 31));
byte[] newBytes = relocate.get(pair);
// newBytes is null if the chunk isn't modified or marked for moving
if (newBytes == null) {
MCAChunk cached = getCachedChunk(cx, cz);
// If the previous offset marks the current write position (start) then we only write the header
if (offset == start) {
if (cached == null || !cached.isModified()) {
writeHeader(raf, cx, cz, start >> 12, size >> 12, true);
start += size;
written = start + size;
continue;
} else {
newBytes = compressedMap.get(pair);
}
} else {
// The chunk needs to be moved, fetch the data if necessary
newBytes = compressedMap.get(pair);
if (newBytes == null) {
if (cached == null || !cached.isDeleted()) {
newBytes = getChunkCompressedBytes(getOffset(cx, cz));
}
}
}
}
if (newBytes == null) {
writeHeader(raf, cx, cz, 0, 0, false);
continue;
}
// The length to be written (compressed data + 5 byte chunk header)
int len = newBytes.length + 5;
int oldSize = (size + 4095) >> 12;
int newSize = (len + 4095) >> 12;
int nextOffset2 = end;
// If the current write position (start) + length of data to write (len) are longer than the position of the next chunk, we need to move the next chunks
while (start + len > end) {
Integer nextLoc = offsetMap.get(nextOffset2);
if (nextLoc != null) {
short nextCXZ = MathMan.unpairX(nextLoc);
int nextCX = MathMan.unpairShortX(nextCXZ);
int nextCZ = MathMan.unpairShortY(nextCXZ);
MCAChunk cached = getCachedChunk(nextCX, nextCZ);
if (cached == null || !cached.isModified()) {
byte[] nextBytes = getChunkCompressedBytes(nextOffset2);
relocate.put(MathMan.pair((short) (nextCX & 31), (short) (nextCZ & 31)), nextBytes);
}
int nextSize = MathMan.unpairY(nextLoc) << 12;
end += nextSize;
nextOffset2 += nextSize;
} else {
end += 4096;
nextOffset2 += 4096;
}
}
// Write the chunk + chunk header
writeSafe(raf, start, newBytes);
// Write the location data (beginning of file)
writeHeader(raf, cx, cz, start >> 12, newSize, true);
written = start + newBytes.length + 5;
start += newSize << 12;
}
// Write all the chunks which need to be appended
if (!append.isEmpty()) {
for (Int2ObjectMap.Entry<byte[]> entry : append.int2ObjectEntrySet()) {
int pair = entry.getIntKey();
short cx = MathMan.unpairX(pair);
short cz = MathMan.unpairY(pair);
byte[] bytes = entry.getValue();
int len = bytes.length + 5;
int newSize = (len + 4095) >> 12;
writeSafe(raf, start, bytes);
writeHeader(raf, cx, cz, start >> 12, newSize, true);
written = start + bytes.length + 5;
start += newSize << 12;
}
}
// Round the file length, since the vanilla server doesn't like it for some reason
raf.setLength(4096 * ((written + 4095) / 4096));
if (raf instanceof BufferedRandomAccessFile) {
((BufferedRandomAccessFile) raf).flush();
}
raf.close();
} catch (Throwable e) {
e.printStackTrace();
}
if (wait) {
pool.shutdown();
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
}
}
IterableThreadLocal.clean(byteStore1);
IterableThreadLocal.clean(byteStore2);
IterableThreadLocal.clean(byteStore3);
}
}

Datei anzeigen

@ -1,107 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.object.collection.IterableThreadLocal;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.concurrent.ForkJoinPool;
/**
* MCAQueue.filterWorld(MCAFilter)<br>
* - Read and modify the world
*/
public class MCAFilter<T> extends IterableThreadLocal<T> {
public void withPool(ForkJoinPool pool, MCAQueue queue) {
}
/**
* Check whether this .mca file should be read
* @param path
* @param attr
* @return
*/
public boolean appliesFile(Path path, BasicFileAttributes attr) {
return true;
}
/**
* Check whether a .mca file should be read
*
* @param mcaX
* @param mcaZ
* @return
*/
public boolean appliesFile(int mcaX, int mcaZ) {
return true;
}
/**
* Do something with the MCAFile<br>
* - Return null if you don't want to filter chunks<br>
* - Return the same file if you do want to filter chunks<br>
*
* @param file
* @return file or null
*/
public MCAFile applyFile(MCAFile file) {
return file;
}
/**
* Check whether a chunk should be read
*
* @param cx
* @param cz
* @return
*/
public boolean appliesChunk(int cx, int cz) {
return true;
}
/**
* Do something with the MCAChunk<br>
* - Return null if you don't want to filter blocks<br>
* - Return the chunk if you do want to filter blocks<br>
*
* @param chunk
* @return
*/
public MCAChunk applyChunk(MCAChunk chunk, T cache) {
return chunk;
}
/**
* Make changes to the block here<br>
* - e.g. block.setId(...)<br>
* - Note: Performance is critical here<br>
*
* @param x
* @param y
* @param z
* @param block
*/
public void applyBlock(int x, int y, int z, BaseBlock block, T cache) {
}
/**
* Do something with the MCAChunk after block filtering<br>
*
* @param chunk
* @param cache
* @return
*/
public void finishChunk(MCAChunk chunk, T cache) {
}
/**
* Do something with the MCAFile after block filtering<br>
*
* @param file
* @param cache
* @return
*/
public void finishFile(MCAFile file, T cache) {
}
}

Datei anzeigen

@ -1,23 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.object.number.MutableLong;
public class MCAFilterCounter extends MCAFilter<MutableLong> {
@Override
public void finishChunk(MCAChunk chunk, MutableLong cache) {
cache.add(chunk.getModified());
}
@Override
public MutableLong init() {
return new MutableLong();
}
public long getTotal() {
long total = 0;
for (MutableLong value : getAll()) {
total += value.get();
}
return total;
}
}

Datei anzeigen

@ -1,826 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.example.IntFaweChunk;
import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.example.NullFaweChunk;
import com.boydti.fawe.jnbt.anvil.filters.DelegateMCAFilter;
import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory;
import com.boydti.fawe.jnbt.anvil.history.NullAnvilHistory;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.RunnableVal4;
import com.boydti.fawe.object.collection.IterableThreadLocal;
import com.boydti.fawe.util.MainUtil;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk, FaweChunk> {
private FaweQueue parent;
private NMSMappedFaweQueue parentNMS;
private final boolean hasSky;
private final File saveFolder;
private final ThreadLocal<MutableMCABackedBaseBlock> blockStore = new ThreadLocal<MutableMCABackedBaseBlock>() {
@Override
protected MutableMCABackedBaseBlock initialValue() {
return new MutableMCABackedBaseBlock();
}
};
@Override
protected void finalize() throws Throwable {
IterableThreadLocal.clean(blockStore);
super.finalize();
}
public MCAQueue(FaweQueue parent) {
super(parent.getWorldName(), new MCAQueueMap());
this.parent = parent;
if (parent instanceof NMSMappedFaweQueue) {
parentNMS = (NMSMappedFaweQueue) parent;
}
((MCAQueueMap) getFaweQueueMap()).setParentQueue(parent);
hasSky = parent.hasSky();
saveFolder = parent.getSaveFolder();
}
public MCAQueue(String world, File saveFolder, boolean hasSky) {
super(world, new MCAQueueMap());
((MCAQueueMap) getFaweQueueMap()).setParentQueue(this);
this.saveFolder = saveFolder;
this.hasSky = hasSky;
}
@Override
public FaweChunk loadChunk(FaweQueue faweQueue, int x, int z, boolean generate) {
return getFaweChunk(x, z);
}
@Override
public FaweChunk getSections(FaweChunk faweChunk) {
return faweChunk;
}
@Override
public FaweChunk getCachedChunk(FaweQueue faweQueue, int cx, int cz) {
return getFaweChunk(cx, cz);
}
@Override
public BiomeType getBiome(FaweChunk faweChunk, int x, int z) {
if (faweChunk instanceof MCAChunk) {
return ((MCAChunk) faweChunk).getBiomeType(x, z);
} else if (parent != null) {
return parent.getBiomeType(x, z);
} else {
return null;
}
}
/**
*
* @param newChunk
* @param bx
* @param tx
* @param bz
* @param tz
* @param oX
* @param oZ
* @return true if the newChunk has been changed
*/
public boolean copyTo(MCAChunk newChunk, int bx, int tx, int bz, int tz, int oX, int oZ) {
int obx = bx - oX;
int obz = bz - oZ;
int otx = tx - oX;
int otz = tz - oZ;
int otherBCX = (obx) >> 4;
int otherBCZ = (obz) >> 4;
int otherTCX = (otx) >> 4;
int otherTCZ = (otz) >> 4;
int cx = newChunk.getX();
int cz = newChunk.getZ();
int cbx = (cx << 4) - oX;
int cbz = (cz << 4) - oZ;
boolean changed = false;
for (int otherCZ = otherBCZ; otherCZ <= otherTCZ; otherCZ++) {
for (int otherCX = otherBCX; otherCX <= otherTCX; otherCX++) {
FaweChunk chunk;
synchronized (this) {
chunk = this.getFaweChunk(otherCX, otherCZ);
}
if (!(chunk instanceof NullFaweChunk)) {
changed = true;
MCAChunk other = (MCAChunk) chunk;
int ocbx = otherCX << 4;
int ocbz = otherCZ << 4;
int octx = ocbx + 15;
int octz = ocbz + 15;
int offsetY = 0;
int minX = obx > ocbx ? (obx - ocbx) & 15 : 0;
int maxX = otx < octx ? (otx - ocbx) : 15;
int minZ = obz > ocbz ? (obz - ocbz) & 15 : 0;
int maxZ = otz < octz ? (otz - ocbz) : 15;
int offsetX = ocbx - cbx;
int offsetZ = ocbz - cbz;
newChunk.copyFrom(other, minX, maxX, 0, 255, minZ, maxZ, offsetX, offsetY, offsetZ);
}
}
}
return changed;
}
@Override
public boolean setMCA(int mcaX, int mcaZ, RegionWrapper region, Runnable whileLocked, boolean save, boolean unload) {
if (parent != null) return parent.setMCA(mcaX, mcaZ, region, whileLocked, save, unload);
return super.setMCA(mcaX, mcaZ, region, whileLocked, save, unload);
}
public void pasteRegion(MCAQueue from, final RegionWrapper regionFrom, BlockVector3 offset) throws IOException {
pasteRegion(from, regionFrom, offset, new NullAnvilHistory());
}
public void pasteRegion(MCAQueue from, final RegionWrapper regionFrom, BlockVector3 offset, IAnvilHistory history) throws IOException {
int oX = offset.getBlockX();
int oZ = offset.getBlockZ();
int oY = offset.getBlockY();
int oCX = oX >> 4;
int oCZ = oZ >> 4;
RegionWrapper regionTo = new RegionWrapper(regionFrom.minX + oX, regionFrom.maxX + oX, regionFrom.minZ + oZ, regionFrom.maxZ + oZ);
File folder = getSaveFolder();
int bMcaX = (regionTo.minX >> 9);
int bMcaZ = (regionTo.minZ >> 9);
int tMcaX = (regionTo.maxX >> 9);
int tMcaZ = (regionTo.maxZ >> 9);
filterCopy(new MCAFilter() {
@Override
public MCAFile applyFile(MCAFile mcaFile) {
try {
int mcaX = mcaFile.getX();
int mcaZ = mcaFile.getZ();
int bcx = Math.max(mcaX << 5, regionTo.minX >> 4);
int bcz = Math.max(mcaZ << 5, regionTo.minZ >> 4);
int tcx = Math.min((mcaX << 5) + 31, regionTo.maxX >> 4);
int tcz = Math.min((mcaZ << 5) + 31, regionTo.maxZ >> 4);
mcaFile.init();
final long heapSize = Runtime.getRuntime().totalMemory();
final long heapMaxSize = Runtime.getRuntime().maxMemory();
int free = (int) (((heapMaxSize - heapSize) + Runtime.getRuntime().freeMemory()) / (1024 * 1024));
// int obcx = bcx - oCX;
// int obcz = bcz - oCX;
// int otcx = tcx - oCX;
// int otcz = tcz - oCX;
for (int cz = bcz; cz <= tcz; cz++) {
for (int cx = bcx; cx <= tcx; cx++) {
int bx = cx << 4;
int bz = cz << 4;
int tx = bx + 15;
int tz = bz + 15;
if (oX == 0 && oZ == 0) {
if (bx >= regionTo.minX && tx <= regionTo.maxX && bz >= regionTo.minZ && tz <= regionTo.maxZ) {
FaweChunk chunk = from.getFaweChunk(cx - oCX, cz - oCZ);
if (!(chunk instanceof NullFaweChunk)) {
// if (regionTo.minY == 0 && regionTo.maxY == 255) {
// System.out.println("Vertical");
// MCAChunk mcaChunk = (MCAChunk) chunk;
// mcaChunk.setLoc(null, cx, cz);
// mcaChunk.setModified();
// mcaFile.setChunk(mcaChunk);
// } else
{
MCAChunk newChunk = mcaFile.getChunk(cx, cz);
if (newChunk == null) {
newChunk = new MCAChunk(MCAQueue.this, cx, cz);
mcaFile.setChunk(newChunk);
} else {
newChunk.setModified();
}
newChunk.copyFrom((MCAChunk) chunk, regionFrom.minY, regionFrom.maxY, oY);
}
}
continue;
}
}
bx = Math.max(regionTo.minX, bx);
bz = Math.max(regionTo.minZ, bz);
tx = Math.min(regionTo.maxX, tx);
tz = Math.min(regionTo.maxZ, tz);
int obx = bx - oX;
int obz = bz - oZ;
int otx = tx - oX;
int otz = tz - oZ;
int otherBCX = (obx) >> 4;
int otherBCZ = (obz) >> 4;
int otherTCX = (otx) >> 4;
int otherTCZ = (otz) >> 4;
MCAChunk newChunk = mcaFile.getChunk(cx, cz);
boolean created;
if (newChunk == null) {
newChunk = new MCAChunk(MCAQueue.this, cx, cz);
created = true;
} else {
created = false;
newChunk.setModified();
}
boolean modified = false;
int cbx = (cx << 4) - oX;
int cbz = (cz << 4) - oZ;
for (int otherCZ = otherBCZ; otherCZ <= otherTCZ; otherCZ++) {
for (int otherCX = otherBCX; otherCX <= otherTCX; otherCX++) {
FaweChunk chunk = from.getFaweChunk(otherCX, otherCZ);
if (!(chunk instanceof NullFaweChunk)) {
MCAChunk other = (MCAChunk) chunk;
int ocbx = otherCX << 4;
int ocbz = otherCZ << 4;
int octx = ocbx + 15;
int octz = ocbz + 15;
int minY = regionFrom.minY;
int maxY = regionFrom.maxY;
int offsetY = oY;
int minX = obx > ocbx ? (obx - ocbx) & 15 : 0;
int maxX = otx < octx ? (otx - ocbx) : 15;
int minZ = obz > ocbz ? (obz - ocbz) & 15 : 0;
int maxZ = otz < octz ? (otz - ocbz) : 15;
int offsetX = ocbx - cbx;
int offsetZ = ocbz - cbz;
newChunk.copyFrom(other, minX, maxX, minY, maxY, minZ, maxZ, offsetX, offsetY, offsetZ);
newChunk.setModified();
modified = true;
}
}
}
if (created && modified) {
mcaFile.setChunk(newChunk);
}
}
}
from.clear();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}, regionTo, history);
from.clear();
}
private void performCopy(MCAFile original, MCAFile copy, RegionWrapper region, IAnvilHistory task, ForkJoinPool pool) {
original.clear();
File originalFile = original.getFile();
File copyFile = copy.getFile();
if (copy.isModified()) {
if (copy.isDeleted()) {
if (task.addFileChange(originalFile)) return;
setMCA(original.getX(), original.getZ(), region, () -> task.addFileChange(originalFile), true, true);
return;
} else if (copyFile.exists()) {
// If the task is the normal delete task, we can do a normal file move
copy.close(pool);
if (task.getClass() == NullAnvilHistory.class) {
try {
Files.move(copyFile.toPath(), originalFile.toPath(), StandardCopyOption.ATOMIC_MOVE);
return;
} catch (IOException ignore) {}
}
setMCA(original.getX(), original.getZ(), region, () -> {
task.addFileChange(originalFile);
if (!copyFile.renameTo(originalFile)) {
Fawe.debug("Failed to copy (2)");
}
}, true, true);
}
}
copy.clear();
copyFile.delete();
}
public <G, T extends MCAFilter<G>> T filterCopy(final T filter, RegionWrapper region) {
return filterCopy(filter, region, new NullAnvilHistory());
}
public <G, T extends MCAFilter<G>> T filterCopy(final T filter, RegionWrapper region, IAnvilHistory task) {
DelegateMCAFilter<G> delegate = new DelegateMCAFilter<G>(filter) {
MCAFile original;
MCAFile copy;
ForkJoinPool pool;
@Override
public void withPool(ForkJoinPool pool, MCAQueue queue) {
this.pool = pool;
}
@Override
public MCAFile applyFile(MCAFile original) {
this.original = original;
this.original.clear();
File file = original.getFile();
file.setWritable(true);
File copyDest = new File(file.getParentFile(), file.getName() + "-copy");
setMCA(original.getX(), original.getZ(), region, () -> {
try {
Files.copy(file.toPath(), copyDest.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
}, true, false);
this.copy = new MCAFile(original.getParent(), copyDest);
MCAFile result = filter.applyFile(copy);
if (result == null) {
performCopy(original, copy, region, task, pool);
}
if (result == null || !copy.getFile().equals(result.getFile())) {
copy.clear();
if (copyDest.exists() && !copyDest.delete()) copyDest.deleteOnExit();
}
return result;
}
@Override
public void finishFile(MCAFile newRegion, G cache) {
performCopy(original, newRegion, region, task, pool);
}
};
if (region == RegionWrapper.GLOBAL()) {
this.filterWorld(delegate);
} else {
this.filterRegion(delegate, region);
}
return filter;
}
public <G, T extends MCAFilter<G>> T filterRegion(final T filter, final RegionWrapper region) {
DelegateMCAFilter<G> delegate = new DelegateMCAFilter<G>(filter) {
@Override
public boolean appliesFile(Path path, BasicFileAttributes attr) {
String name = path.toString();
int[] coords = MainUtil.regionNameToCoords(name);
final int mcaX = coords[0];
final int mcaZ = coords[1];
return region.isInMCA(mcaX, mcaZ) && filter.appliesFile(path, attr);
}
@Override
public boolean appliesFile(int mcaX, int mcaZ) {
return region.isInMCA(mcaX, mcaZ) && filter.appliesFile(mcaX, mcaZ);
}
@Override
public boolean appliesChunk(int cx, int cz) {
return region.isInChunk(cx, cz) && filter.appliesChunk(cx, cz);
}
@Override
public G get() {
return filter.get();
}
@Override
public MCAChunk applyChunk(MCAChunk chunk, G value) {
chunk = filter.applyChunk(chunk, value);
if (chunk != null) {
final MutableMCABackedBaseBlock mutableBlock = blockStore.get();
mutableBlock.setChunk(chunk);
int bx = chunk.getX() << 4;
int bz = chunk.getZ() << 4;
int tx = bx + 15;
int tz = bz + 15;
bx = Math.max(bx, region.minX);
bz = Math.max(bz, region.minZ);
tx = Math.min(tx, region.maxX);
tz = Math.min(tz, region.maxZ);
int minLayer = region.minY >> 4;
int maxLayer = region.maxY >> 4;
for (int layer = minLayer; layer <= maxLayer; layer++) {
if (chunk.doesSectionExist(layer)) {
mutableBlock.setArrays(layer);
int yStart = layer << 4;
int yEnd = yStart + 15;
yStart = Math.max(yStart, region.minY);
yEnd = Math.min(yEnd, region.maxY);
for (int y = yStart, y0 = (yStart & 15); y <= yEnd; y++, y0++) {
int yIndex = ((y0) << 8);
mutableBlock.setY(y);
for (int z = bz, z0 = bz & 15; z <= tz; z++, z0++) {
int zIndex = yIndex + ((z0) << 4);
mutableBlock.setZ(z);
for (int x = bx, x0 = bx & 15; x <= tx; x++, x0++) {
int xIndex = zIndex + x0;
mutableBlock.setX(x);
mutableBlock.setIndex(xIndex);
filter.applyBlock(x, y, z, mutableBlock, value);
}
}
}
}
}
}
return null;
}
};
final int minMCAX = region.minX >> 9;
final int minMCAZ = region.minZ >> 9;
final int maxMCAX = region.maxX >> 9;
final int maxMCAZ = region.maxZ >> 9;
long mcaArea = (maxMCAX - minMCAX + 1l) * (maxMCAZ - minMCAZ + 1l);
if (mcaArea < 128) {
this.filterWorld(delegate, new RunnableVal2<Path, RunnableVal2<Path, BasicFileAttributes>>() {
@Override
public void run(Path root, RunnableVal2<Path, BasicFileAttributes> funx) {
for (int x = minMCAX; x <= maxMCAX; x++) {
for (int z = minMCAZ; z <= maxMCAZ; z++) {
Path newPath = root.resolve(Paths.get("r." + x + "." + z + ".mca"));
if (Files.exists(newPath)) {
try {
BasicFileAttributes attrs = Files.readAttributes(newPath, BasicFileAttributes.class);
funx.run(newPath, attrs);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
});
} else {
this.filterWorld(delegate);
}
return filter;
}
public <G, T extends MCAFilter<G>> T createRegion(final T filter, final RegionWrapper region) {
int botMcaX = region.minX >> 9;
int botMcaZ = region.minZ >> 9;
int topMcaX = region.maxX >> 9;
int topMcaZ = region.maxZ >> 9;
for (int mcaX = botMcaX >> 9; mcaX <= topMcaX; mcaX++) {
for (int mcaZ = botMcaZ >> 9; mcaZ <= topMcaZ; mcaZ++) {
}
}
return filter;
}
private <G, T extends MCAFilter<G>> RunnableVal2<Path, BasicFileAttributes> filterFunction(final T filter, ForkJoinPool pool) {
return new RunnableVal2<Path, BasicFileAttributes>() {
@Override
public void run(Path path, BasicFileAttributes attr) {
try {
String name = path.getFileName().toString();
if (!name.endsWith(".mca") && !name.endsWith(".mcapm")) {
return;
}
if (!filter.appliesFile(path, attr)) {
return;
}
String[] split = name.split("\\.");
final int mcaX = Integer.parseInt(split[1]);
final int mcaZ = Integer.parseInt(split[2]);
if (filter.appliesFile(mcaX, mcaZ)) {
File file = path.toFile();
final MCAFile original = new MCAFile(MCAQueue.this, file);
final MCAFile finalFile = filter.applyFile(original);
if (finalFile != null && !finalFile.isDeleted()) {
finalFile.init();
// May not do anything, but seems to lead to smaller lag spikes
final int cbx = mcaX << 5;
final int cbz = mcaZ << 5;
finalFile.forEachSortedChunk(new RunnableVal4<Integer, Integer, Integer, Integer>() {
@Override
public void run(final Integer rcx, final Integer rcz, Integer offset, Integer size) {
pool.submit(new Runnable() {
@Override
public void run() {
try {
int cx = cbx + rcx;
int cz = cbz + rcz;
if (filter.appliesChunk(cx, cz)) {
MCAChunk chunk = finalFile.getChunk(cx, cz);
try {
final G value = filter.get();
chunk = filter.applyChunk(chunk, value);
if (chunk != null) {
final MutableMCABackedBaseBlock mutableBlock = blockStore.get();
mutableBlock.setChunk(chunk);
int bx = cx << 4;
int bz = cz << 4;
for (int layer = 0; layer < 16; layer++) {
if (chunk.doesSectionExist(layer)) {
mutableBlock.setArrays(layer);
int yStart = layer << 4;
int index = 0;
for (int y = yStart; y < yStart + 16; y++) {
mutableBlock.setY(y);
for (int z = bz; z < bz + 16; z++) {
mutableBlock.setZ(z);
for (int x = bx; x < bx + 16; x++, index++) {
mutableBlock.setX(x);
mutableBlock.setIndex(index);
filter.applyBlock(x, y, z, mutableBlock, value);
}
}
}
}
}
filter.finishChunk(chunk, value);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
});
}
});
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
filter.finishFile(finalFile, filter.get());
} else {
if (original.isDeleted()) {
try {
original.close(pool);
file.delete();
} catch (Throwable ignore) {
ignore.printStackTrace();
}
}
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
original.close(pool);
if (original.isDeleted()) {
file.delete();
}
}
} catch (Throwable ignore) {
ignore.printStackTrace();
}
}
};
}
private <G, T extends MCAFilter<G>> T filterWorld(final T filter, RunnableVal2<Path, RunnableVal2<Path, BasicFileAttributes>> traverser) {
File folder = getSaveFolder();
final ForkJoinPool pool = new ForkJoinPool();
filter.withPool(pool, this);
RunnableVal2<Path, BasicFileAttributes> task = filterFunction(filter, pool);
traverser.run(folder.toPath(), task);
pool.shutdown();
try {
pool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
} catch (Throwable e) {
e.printStackTrace();
}
return filter;
}
public <G, T extends MCAFilter<G>> T filterWorld(final T filter) {
return filterWorld(filter, new RunnableVal2<Path, RunnableVal2<Path, BasicFileAttributes>>() {
@Override
public void run(Path value1, RunnableVal2<Path, BasicFileAttributes> value2) {
MainUtil.traverse(value1, value2);
}
});
}
public <G, T extends MCAFilter<G>> T filterWorld(final T filter, Comparator<File> comparator) {
return filterWorld(filter, new RunnableVal2<Path, RunnableVal2<Path, BasicFileAttributes>>() {
@Override
public void run(Path value1, RunnableVal2<Path, BasicFileAttributes> value2) {
MainUtil.forEachFile(value1, value2, comparator);
}
});
}
@Override
public boolean supports(Capability capability) {
if (capability == Capability.CHANGE_TASKS) {
return false;
}
return super.supports(capability);
}
@Override
public void relight(int x, int y, int z) {
throw new UnsupportedOperationException("Not supported");
}
@Override
public void relightBlock(int x, int y, int z) {
throw new UnsupportedOperationException("Not supported");
}
@Override
public void relightSky(int x, int y, int z) {
throw new UnsupportedOperationException("Not supported");
}
@Override
public boolean regenerateChunk(FaweQueue faweQueue, int x, int z, BiomeType biome, Long seed) {
throw new UnsupportedOperationException("Not supported");
}
@Override
public FaweQueue getImpWorld() {
return parent;
}
@Override
public void setFullbright(FaweChunk sections) {
if (sections.getClass() == MCAChunk.class) {
((MCAChunk) sections).setFullbright();
} else if (parentNMS != null) {
int cx = sections.getX();
int cz = sections.getZ();
parentNMS.ensureChunkLoaded(cx, cz);
Object parentSections = parentNMS.getCachedSections(parentNMS.getWorld(), cx, cz);
if (parentSections != null) {
parentNMS.setFullbright(sections);
}
}
}
@Override
public boolean removeSectionLighting(FaweChunk sections, int layer, boolean hasSky) {
if (sections.getClass() == MCAChunk.class) {
((MCAChunk) sections).removeLight(layer);
} else if (parentNMS != null) {
int cx = sections.getX();
int cz = sections.getZ();
parentNMS.ensureChunkLoaded(cx, cz);
Object parentSections = parentNMS.getCachedSections(parentNMS.getWorld(), cx, cz);
if (parentSections != null) {
parentNMS.removeSectionLighting(sections, layer, hasSky);
}
}
return true;
}
@Override
public boolean removeLighting(FaweChunk sections, RelightMode mode, boolean hasSky) {
if (mode != RelightMode.NONE) {
if (sections.getClass() == MCAChunk.class) {
((MCAChunk) sections).removeLight();
} else if (parentNMS != null) {
int cx = sections.getX();
int cz = sections.getZ();
parentNMS.ensureChunkLoaded(cx, cz);
Object parentSections = parentNMS.getCachedSections(parentNMS.getWorld(), cx, cz);
if (parentSections != null) {
parentNMS.removeLighting(sections, mode, hasSky);
}
}
return true;
}
return false;
}
@Override
public void setSkyLight(FaweChunk sections, int x, int y, int z, int value) {
if (sections.getClass() == MCAChunk.class) {
((MCAChunk) sections).setSkyLight(x, y, z, value);
} else if (parentNMS != null) {
parentNMS.setSkyLight(x, y, z, value);
}
}
@Override
public void setBlockLight(FaweChunk sections, int x, int y, int z, int value) {
if (sections.getClass() == MCAChunk.class) {
((MCAChunk) sections).setBlockLight(x, y, z, value);
} else if (parentNMS != null) {
parentNMS.setBlockLight(x, y, z, value);
}
}
@Override
public void refreshChunk(FaweChunk fs) {
if (fs.getClass() != MCAChunk.class) {
parentNMS.sendChunk(fs);
}
}
@Override
public void sendChunk(int x, int z, int bitMask) {
if (parentNMS != null) {
parentNMS.sendChunk(x, z, bitMask);
}
}
@Override
public CompoundTag getTileEntity(FaweChunk sections, int x, int y, int z) {
if (sections.getClass() == MCAChunk.class) {
return sections.getTile(x, y, z);
} else {
return parentNMS.getTileEntity(x, y, z);
}
}
@Override
public FaweChunk getFaweChunk(int cx, int cz) {
return getFaweQueueMap().getFaweChunk(cx, cz);
}
@Override
public File getSaveFolder() {
return saveFolder;
}
@Override
public boolean hasSky() {
return hasSky;
}
@Override
public MCAChunk getCachedSections(FaweQueue faweQueue, int cx, int cz) {
return (MCAChunk) getFaweQueueMap().getFaweChunk(cx, cz);
}
@Override
public FaweChunk getCachedSection(FaweChunk sections, int cy) {
if (sections.getClass() == MCAChunk.class) {
if (((MCAChunk) sections).doesSectionExist(cy)) {
return sections;
}
return null;
} else if (parentNMS != null) {
return sections;
}
return null;
}
@Override
public int getCombinedId4Data(FaweChunk sections, int x, int y, int z) {
if (sections.getClass() == MCAChunk.class) {
return sections.getBlockCombinedId(x, y, z);
} else {
return parentNMS.getCombinedId4Data(x, y, z);
}
}
@Override
public int getSkyLight(FaweChunk sections, int x, int y, int z) {
if (sections.getClass() == MCAChunk.class) {
return ((MCAChunk) sections).getSkyLight(x, y, z);
} else {
return parentNMS.getSkyLight(x, y, z);
}
}
@Override
public int getEmmittedLight(FaweChunk sections, int x, int y, int z) {
if (sections.getClass() == MCAChunk.class) {
return ((MCAChunk) sections).getBlockLight(x, y, z);
} else {
return parentNMS.getEmmittedLight(x, y, z);
}
}
@Override
public void startSet(boolean parallel) {
if (parent != null) {
parent.startSet(parallel);
}
}
@Override
public void endSet(boolean parallel) {
if (parent != null) {
parent.endSet(parallel);
}
}
@Override
public void sendBlockUpdate(FaweChunk chunk, FawePlayer... players) {
if (parent != null) {
parentNMS.sendBlockUpdate(chunk, players);
}
}
}

Datei anzeigen

@ -1,222 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.example.IFaweQueueMap;
import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.example.NullFaweChunk;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.SetQueue;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class MCAQueueMap implements IFaweQueueMap {
private FaweQueue queue;
private Map<Long, MCAFile> mcaFileMap = new ConcurrentHashMap<>(8, 0.9f, 1);
private NullFaweChunk nullChunk;
private boolean isHybridQueue;
public void setParentQueue(FaweQueue queue) {
this.queue = queue;
this.nullChunk = new NullFaweChunk(queue, 0, 0);
this.isHybridQueue = queue != null && !(queue instanceof MCAQueue) && (!(queue instanceof MappedFaweQueue) || ((MappedFaweQueue) queue).getFaweQueueMap() != this);
}
private MCAFile lastFile;
private int lastFileX = Integer.MIN_VALUE;
private int lastFileZ = Integer.MIN_VALUE;
private FaweChunk lastChunk;
private int lastX = Integer.MIN_VALUE;
private int lastZ = Integer.MIN_VALUE;
public synchronized MCAFile getMCAFile(int cx, int cz, boolean create) {
int mcaX = cx >> 5;
int mcaZ = cz >> 5;
if (mcaX == lastFileX && mcaZ == lastFileZ) {
return lastFile;
}
long pair = MathMan.pairInt(lastFileX = mcaX, lastFileZ = mcaZ);
MCAFile tmp;
lastFile = tmp = mcaFileMap.get(pair);
if (lastFile == null) {
try {
queue.setMCA(lastFileX, lastFileZ, RegionWrapper.GLOBAL(), null, true, false);
File save = queue.getSaveFolder();
File file;
if (save != null) {
file = new File(queue.getSaveFolder(), "r." + lastFileX + "." + lastFileZ + ".mca");
if (create) {
File parent = file.getParentFile();
if (!parent.exists()) parent.mkdirs();
if (!file.exists()) file.createNewFile();
}
} else {
file = null;
}
lastFile = tmp = new MCAFile(queue, mcaX, mcaZ, file);
} catch (FaweException.FaweChunkLoadException ignore) {
lastFile = null;
return null;
} catch (Exception e) {
e.printStackTrace();
lastFile = null;
return null;
}
mcaFileMap.put(pair, tmp);
}
return tmp;
}
@Override
public Collection<FaweChunk> getFaweChunks() {
final List<FaweChunk> chunks = new ArrayList<>();
for (Map.Entry<Long, MCAFile> entry : mcaFileMap.entrySet()) {
MCAFile file = entry.getValue();
if (file != null) {
chunks.addAll(file.getCachedChunks());
}
}
return chunks;
}
@Override
public void forEachChunk(RunnableVal<FaweChunk> onEach) {
for (FaweChunk chunk : getFaweChunks()) {
onEach.run(chunk);
}
}
public FaweChunk getFaweChunk(int cx, int cz, boolean create) {
if (cx == lastX && cz == lastZ) {
if (nullChunk == lastChunk) {
nullChunk.setLoc(queue, lastX, lastZ);
}
return lastChunk;
}
lastX = cx;
lastZ = cz;
if (isHybridQueue) {
MappedFaweQueue mfq = ((MappedFaweQueue) queue);
lastChunk = mfq.getFaweQueueMap().getCachedFaweChunk(cx, cz);
if (lastChunk != null) {
return lastChunk;
}
}
try {
MCAFile mcaFile = getMCAFile(cx, cz, create);
if (mcaFile != null) {
mcaFile.init();
lastChunk = mcaFile.getChunk(cx, cz);
if (lastChunk != null) {
return lastChunk;
} else if (create) {
MCAChunk chunk = new MCAChunk(queue, cx, cz);
mcaFile.setChunk(chunk);
lastChunk = chunk;
return chunk;
}
}
} catch (Throwable ignore) {
ignore.printStackTrace();
}
if (isHybridQueue) { // Use parent queue for in use chunks
lastChunk = ((MappedFaweQueue) queue).getFaweQueueMap().getFaweChunk(cx, cz);
return lastChunk;
}
nullChunk.setLoc(queue, lastX, lastZ);
return lastChunk = nullChunk;
}
@Override
public FaweChunk getFaweChunk(int cx, int cz) {
return getFaweChunk(cx, cz, !isHybridQueue);
}
@Override
public FaweChunk getCachedFaweChunk(int cx, int cz) {
int mcaX = cx >> 5;
int mcaZ = cz >> 5;
long pair = MathMan.pairInt(mcaX, mcaZ);
MCAFile file = mcaFileMap.get(pair);
if (file != null) {
return file.getCachedChunk(cx, cz);
}
return null;
}
@Override
public void add(FaweChunk chunk) {
throw new UnsupportedOperationException("Not supported");
}
@Override
public void clear() {
for (Map.Entry<Long, MCAFile> entry : mcaFileMap.entrySet()) {
entry.getValue().clear();
}
mcaFileMap.clear();
lastChunk = null;
lastFile = null;
lastFileX = Integer.MIN_VALUE;
lastFileZ = Integer.MIN_VALUE;
lastX = Integer.MIN_VALUE;
lastZ = Integer.MIN_VALUE;
if (isHybridQueue) {
queue.clear();
}
}
@Override
public int size() {
int size = mcaFileMap.size();
if (isHybridQueue) {
size += queue.size();
}
return size;
}
@Override
public boolean next(int size, long time) {
lastX = Integer.MIN_VALUE;
lastZ = Integer.MIN_VALUE;
lastFileX = Integer.MIN_VALUE;
lastFileZ = Integer.MIN_VALUE;
if (!mcaFileMap.isEmpty()) {
Iterator<Map.Entry<Long, MCAFile>> iter = mcaFileMap.entrySet().iterator();
boolean result;
long start = System.currentTimeMillis();
do {
if (result = iter.hasNext()) {
MCAFile file = iter.next().getValue();
iter.remove();
queue.setMCA(file.getX(), file.getZ(), RegionWrapper.GLOBAL(), new Runnable() {
@Override
public void run() {
file.close(SetQueue.IMP.getForkJoinPool());
}
}, true, true);
} else {
break;
}
} while (System.currentTimeMillis() - start < time);
return result;
}
if (isHybridQueue) {
boolean value = queue.next();
return value;
}
return false;
}
}

Datei anzeigen

@ -1,136 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.object.extent.FastWorldEditExtent;
import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector2;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.SimpleWorld;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
public class MCAWorld implements SimpleWorld {
private final String name;
private final MCAQueue queue;
private final FastWorldEditExtent extent;
public MCAWorld(String name, File saveFolder, boolean hasSky) {
this.name = name;
this.queue = new MCAQueue(name, saveFolder, hasSky);
this.extent = new FastWorldEditExtent(this, queue);
}
public MCAQueue getQueue() {
return queue;
}
@Override
public String getName() {
return name;
}
@Override
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
return extent.setBlock(position, block);
}
@Override
public int getBlockLightLevel(BlockVector3 position) {
return queue.getEmmittedLight(position.getBlockX(), position.getBlockY(), position.getBlockZ());
}
@Override
public boolean clearContainerBlockContents(BlockVector3 position) {
BaseBlock block = extent.getFullBlock(position);
if (block.hasNbtData()) {
Map<String, Tag> nbt = ReflectionUtils.getMap(block.getNbtData().getValue());
if (nbt.containsKey("Items")) {
nbt.put("Items", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>()));
try {
extent.setBlock(position, block);
} catch (WorldEditException e) {
e.printStackTrace();
}
}
}
return true;
}
@Override
public void dropItem(Vector3 position, BaseItemStack item) {
}
@Override
public boolean regenerate(Region region, EditSession editSession) {
return false;
}
@Override
public List<? extends Entity> getEntities(Region region) {
return new ArrayList<>();
}
@Override
public List<? extends Entity> getEntities() {
return new ArrayList<>();
}
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
return extent.createEntity(location, entity);
}
@Override
public BlockState getBlock(BlockVector3 position) {
return extent.getBlock(position);
}
@Override
public BiomeType getBiome(BlockVector2 position) {
return extent.getBiome(position);
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return extent.setBiome(position, biome);
}
@Override
public boolean playEffect(Vector3 position, int type, int data) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
// TODO Auto-generated method stub
return false;
}
@Override
public BlockVector3 getSpawnPosition() {
return queue.getWEWorld().getSpawnPosition();
}
}

Datei anzeigen

@ -1,98 +0,0 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.FaweCache;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import javax.annotation.Nullable;
/**
* I'm aware this isn't OOP, but object creation is expensive
*/
public class MutableMCABackedBaseBlock extends BaseBlock {
private MCAChunk chunk;
private int[] ids;
private int index;
private int x;
private int y;
private int z;
public MutableMCABackedBaseBlock() {
super(0, null);
}
public void setChunk(MCAChunk chunk) {
this.chunk = chunk;
}
public void setArrays(int layer) {
ids = chunk.ids[layer];
}
public MCAChunk getChunk() {
return chunk;
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public void setZ(int z) {
this.z = z;
}
public void setIndex(int index) {
this.index = index;
}
// TODO FIXME update to latest
// @Override
// public int getId() {
// return Byte.toUnsignedInt(ids[index]);
// }
//
// @Override
// public int getData() {
// if (!FaweCache.hasData(ids[index] & 0xFF)) {
// return 0;
// } else {
// int indexShift = index >> 1;
// if ((index & 1) == 0) {
// return data[indexShift] & 15;
// } else {
// return (data[indexShift] >> 4) & 15;
// }
// }
// }
@Nullable
@Override
public CompoundTag getNbtData() {
return chunk.getTile(x, y, z);
}
//
// @Override
// public void setData(int value) {
// int indexShift = index >> 1;
// if ((index & 1) == 0) {
// data[indexShift] = (byte) (data[indexShift] & 240 | value & 15);
// } else {
// data[indexShift] = (byte) (data[indexShift] & 15 | (value & 15) << 4);
// }
// chunk.setModified();
// }
@Override
public void setNbtData(@Nullable CompoundTag nbtData) {
chunk.setTile(x, y, z, nbtData);
chunk.setModified();
}
}

Datei anzeigen

@ -1,53 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.number.MutableLong;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
// TODO FIXME
public class CountFilter extends MCAFilterCounter {
// private final boolean[] allowedId = new boolean[FaweCache.getId(Character.MAX_VALUE)];
// private final boolean[] allowed = new boolean[Character.MAX_VALUE];
public CountFilter() {
}
public CountFilter addBlock(BaseBlock block) {
// addBlock(block.getId(), block.getData());
return this;
}
public CountFilter addBlock(int id, int data) {
// allowedId[id] = true;
// allowed[FaweCache.getCombined(id, data)] = true;
return this;
}
@Override
public MCAChunk applyChunk(MCAChunk chunk, MutableLong count) {
// for (int layer = 0; layer < chunk.ids.length; layer++) {
// byte[] ids = chunk.ids[layer];
// if (ids == null) {
// continue;
// }
// byte[] datas = chunk.data[layer];
// for (int i = 0; i < ids.length; i++) {
// int id = ids[i] & 0xFF;
// if (!allowedId[id]) {
// continue;
// }
// int combined = (id) << 4;
// if (FaweCache.hasData(id)) {
// combined += chunk.getNibble(i, datas);
// }
// if (allowed[combined]) {
// count.increment();
// }
// }
// }
return null;
}
}

Datei anzeigen

@ -1,43 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.number.MutableLong;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
public class CountIdFilter extends MCAFilterCounter {
private final boolean[] allowedId = new boolean[BlockTypes.size()];
public CountIdFilter() {
}
public CountIdFilter addBlock(BlockType type) {
allowedId[type.getInternalId()] = true;
return this;
}
public CountIdFilter addBlock(BlockStateHolder block) {
allowedId[block.getInternalBlockTypeId()] = true;
return this;
}
@Override
public MCAChunk applyChunk(MCAChunk chunk, MutableLong count) {
// TODO FIXME
for (int layer = 0; layer < chunk.ids.length; layer++) {
int[] ids = chunk.ids[layer];
if (ids != null) {
for (int i : ids) {
if (allowedId[BlockTypes.getFromStateId(i).getInternalId()]) {
count.increment();
}
}
}
}
return null;
}
}

Datei anzeigen

@ -1,11 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.jnbt.anvil.MCAFile;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
public class DebugFixP2Roads extends MCAFilterCounter {
@Override
public MCAFile applyFile(MCAFile file) {
return super.applyFile(file);
}
}

Datei anzeigen

@ -1,105 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFile;
import com.boydti.fawe.jnbt.anvil.MCAFilter;
import com.boydti.fawe.jnbt.anvil.MCAQueue;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Spliterator;
import java.util.concurrent.ForkJoinPool;
import java.util.function.Consumer;
public class DelegateMCAFilter<T> extends MCAFilter<T> {
private final MCAFilter<T> filter;
@Override
public void withPool(ForkJoinPool pool, MCAQueue queue) {
filter.withPool(pool, queue);
}
@Override
public boolean appliesFile(Path path, BasicFileAttributes attr) {
return filter.appliesFile(path, attr);
}
@Override
public boolean appliesFile(int mcaX, int mcaZ) {
return filter.appliesFile(mcaX, mcaZ);
}
@Override
public MCAFile applyFile(MCAFile file) {
return filter.applyFile(file);
}
@Override
public boolean appliesChunk(int cx, int cz) {
return filter.appliesChunk(cx, cz);
}
@Override
public MCAChunk applyChunk(MCAChunk chunk, T cache) {
return filter.applyChunk(chunk, cache);
}
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, T cache) {
filter.applyBlock(x, y, z, block, cache);
}
@Override
public void finishChunk(MCAChunk chunk, T cache) {
filter.finishChunk(chunk, cache);
}
@Override
public void finishFile(MCAFile file, T cache) {
filter.finishFile(file, cache);
}
@Override
public T init() {
return filter.init();
}
@Override
public void clean() {
filter.clean();
}
@Override
public T get() {
return filter.get();
}
@Override
public void forEach(Consumer<? super T> action) {
filter.forEach(action);
}
@Override
public Spliterator<T> spliterator() {
return filter.spliterator();
}
@Override
public void remove() {
filter.remove();
}
@Override
public void set(T value) {
filter.set(value);
}
public DelegateMCAFilter(MCAFilter<T> filter) {
this.filter = filter;
}
public MCAFilter<T> getFilter() {
return filter;
}
}

Datei anzeigen

@ -1,23 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.number.MutableLong;
import com.sk89q.worldedit.world.biome.BiomeType;
public class DeleteBiomeFilterSimple extends MCAFilterCounter {
private final int id;
public DeleteBiomeFilterSimple(BiomeType biome) {
this.id = biome.getInternalId();
}
@Override
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
if ((chunk.biomes[0] & 0xFF) == id) {
chunk.setDeleted(true);
cache.add(Character.MAX_VALUE);
}
return null;
}
}

Datei anzeigen

@ -1,28 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
public class DeleteOldFilter extends MCAFilterCounter {
private final long time;
public DeleteOldFilter(long time) {
this.time = time;
if (time < 1) {
throw new IllegalArgumentException("Time must be positive");
}
}
@Override
public boolean appliesFile(Path path, BasicFileAttributes attr) {
long modified = attr.lastModifiedTime().toMillis();
// long access = attr.lastAccessTime().toMillis();
long last = modified;//Math.max(modified, access);
if (last != 0 && System.currentTimeMillis() - last > this.time) {
path.toFile().delete();
get().add(512 * 512 * 256);
}
return false;
}
}

Datei anzeigen

@ -1,47 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.jnbt.anvil.MCAFile;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.regions.general.RegionFilter;
import com.sk89q.worldedit.world.World;
import java.io.File;
import java.io.IOException;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
public class DeleteUnclaimedFilter extends DeleteUninhabitedFilter {
private ArrayList<RegionFilter> filters = new ArrayList<>();
public DeleteUnclaimedFilter(World world, long fileDuration, long inhabitedTicks, long chunkInactivity) {
super(fileDuration, inhabitedTicks, chunkInactivity);
for (FaweMaskManager m : FaweAPI.getMaskManagers()) {
RegionFilter filter = m.getFilter(world.getName());
if (filter != null) {
filters.add(filter);
}
}
}
@Override
public boolean shouldDelete(File file, BasicFileAttributes attr, int mcaX, int mcaZ) throws IOException {
boolean contains = false;
for (RegionFilter filter : filters) {
if (contains = filter.containsRegion(mcaX, mcaZ)) {
break;
}
}
return !contains && super.shouldDelete(file, attr, mcaX, mcaZ);
}
@Override
public boolean shouldDeleteChunk(MCAFile mca, int cx, int cz) {
boolean contains = false;
for (RegionFilter filter : filters) {
if (contains = filter.containsChunk(cx, cz)) {
break;
}
}
return !contains && super.shouldDeleteChunk(mca, cx, cz);
}
}

Datei anzeigen

@ -1,162 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.jnbt.NBTStreamer;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFile;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.RunnableVal4;
import com.boydti.fawe.object.exception.FaweException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Date;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
/**
* Deletes unvisited MCA files and Chunks<br>
* - This a global filter and cannot be used a selection<br>
*/
public class DeleteUninhabitedFilter extends MCAFilterCounter {
private final long inhabitedTicks;
private final long fileDurationMillis;
private final long cutoffChunkAgeEpoch;
private boolean debug = false;
public DeleteUninhabitedFilter(long fileDurationMillis, long inhabitedTicks, long chunkInactivityMillis) {
this.fileDurationMillis = fileDurationMillis;
this.inhabitedTicks = inhabitedTicks;
this.cutoffChunkAgeEpoch = System.currentTimeMillis() - chunkInactivityMillis;
}
public void enableDebug() {
this.debug = true;
}
public long getInhabitedTicks() {
return inhabitedTicks;
}
public long getFileDurationMillis() {
return fileDurationMillis;
}
public long getCutoffChunkAgeEpoch() {
return cutoffChunkAgeEpoch;
}
@Override
public boolean appliesFile(Path path, BasicFileAttributes attr) {
String name = path.getFileName().toString();
String[] split = name.split("\\.");
final int mcaX = Integer.parseInt(split[1]);
final int mcaZ = Integer.parseInt(split[2]);
File file = path.toFile();
long lastModified = attr.lastModifiedTime().toMillis();
if (lastModified > cutoffChunkAgeEpoch) {
return false;
}
try {
if (shouldDelete(file, attr, mcaX, mcaZ)) {
if (debug) {
Fawe.debug("Deleting " + file + " as it was modified at " + new Date(lastModified) + " and you provided a threshold of " + new Date(cutoffChunkAgeEpoch));
}
file.delete();
get().add(512 * 512 * 256);
return false;
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
@Override
public MCAFile applyFile(MCAFile mca) {
try {
ForkJoinPool pool = new ForkJoinPool();
mca.init();
filter(mca, pool);
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
mca.close(pool);
pool.shutdown();
pool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
public boolean shouldDelete(File file, BasicFileAttributes attr, int mcaX, int mcaZ) throws IOException {
long creation = attr.creationTime().toMillis();
long modified = attr.lastModifiedTime().toMillis();
if ((modified - creation < fileDurationMillis && modified > creation) || file.length() < 12288) {
return true;
}
return false;
}
public boolean shouldDeleteChunk(MCAFile mca, int cx, int cz) {
return true;
}
public void filter(MCAFile mca, ForkJoinPool pool) throws IOException {
mca.forEachSortedChunk(new RunnableVal4<Integer, Integer, Integer, Integer>() {
@Override
public void run(Integer x, Integer z, Integer offset, Integer size) {
int bx = mca.getX() << 5;
int bz = mca.getZ() << 5;
int cx = bx + x;
int cz = bz + z;
if (shouldDeleteChunk(mca, cx, cz)) {
Runnable task = new Runnable() {
@Override
public void run() {
try {
mca.streamChunk(offset, new RunnableVal<NBTStreamer>() {
@Override
public void run(NBTStreamer value) {
addReaders(mca, x, z, value);
}
});
} catch (FaweException ignore) {
} catch (IOException e) {
e.printStackTrace();
}
}
};
pool.submit(task);
}
}
});
}
public void addReaders(MCAFile mca, int x, int z, NBTStreamer streamer) {
streamer.addReader(".Level.InhabitedTime", new BiConsumer<Integer, Long>() {
@Override
public void accept(Integer index, Long value) {
if (value <= inhabitedTicks) {
MCAChunk chunk = new MCAChunk(null, x, z);
if (debug) {
int cx = (mca.getX() << 5) + (x & 31);
int cz = (mca.getZ() << 5) + (z & 31);
Fawe.debug("Deleting chunk " + cx + "," + cz + " as it was only inhabited for " + value + " and passed all other checks");
}
chunk.setDeleted(true);
synchronized (mca) {
mca.setChunk(chunk);
}
get().add(16 * 16 * 256);
}
}
});
}
}

Datei anzeigen

@ -1,73 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.number.MutableLong;
import com.boydti.fawe.util.StringMan;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import java.util.ArrayList;
import java.util.List;
// TODO FIXME
public class MappedReplacePatternFilter extends MCAFilterCounter {
private Pattern[] map = new Pattern[Character.MAX_VALUE + 1];
public MappedReplacePatternFilter() {
}
public MappedReplacePatternFilter(String from, RandomPattern to, boolean useData) throws InputParseException {
// List<String> split = StringMan.split(from, ',');
// Pattern[] patterns = ((RandomPattern) to).getPatterns().toArray(new Pattern[0]);
// if (patterns.length == split.size()) {
// for (int i = 0; i < split.size(); i++) {
// Pattern pattern = patterns[i];
// String arg = split.get(i);
// ArrayList<BaseBlock> blocks = new ArrayList<BaseBlock>();
// for (String arg2 : arg.split(",")) {
// BaseBlock block = FaweCache.getBlock(arg, true, !useData);
// blocks.add(block);
// }
// for (BaseBlock block : blocks) {
// if (block.getData() != -1) {
// int combined = FaweCache.getCombined(block);
// map[combined] = pattern;
// } else {
// for (int data = 0; data < 16; data++) {
// int combined = FaweCache.getCombined(block.getId(), data);
// map[combined] = pattern;
// }
// }
// }
// }
// } else {
// throw new InputParseException("Mask:Pattern must be a 1:1 match");
// }
}
public void addReplace(BaseBlock block, Pattern pattern) {
// map[block.getCombined()] = pattern;
}
// private final MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong ignore) {
// int id = block.getId();
// int data = FaweCache.hasData(id) ? block.getData() : 0;
// int combined = FaweCache.getCombined(id, data);
// Pattern p = map[combined];
// if (p != null) {
// BaseBlock newBlock = p.apply(x, y, z);
// int currentId = block.getId();
// if (FaweCache.hasNBT(currentId)) {
// block.setNbtData(null);
// }
// block.setId(newBlock.getId());
// block.setData(newBlock.getData());
// }
}
}

Datei anzeigen

@ -1,192 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFile;
import com.boydti.fawe.object.RunnableVal4;
import com.boydti.fawe.object.collection.LongHashSet;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.HybridGen;
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.concurrent.ForkJoinPool;
public class PlotTrimFilter extends DeleteUninhabitedFilter {
private final HybridPlotWorld hpw;
private final HybridGen hg;
private final MCAChunk reference;
private final LongHashSet occupiedRegions;
private final LongHashSet unoccupiedChunks;
private boolean referenceIsVoid;
public static boolean shouldSuggest(PlotArea area) {
IndependentPlotGenerator gen = area.getGenerator();
if (area instanceof HybridPlotWorld && gen instanceof HybridGen) {
HybridPlotWorld hpw = (HybridPlotWorld) area;
return hpw.PLOT_BEDROCK && !hpw.PLOT_SCHEMATIC && hpw.MAIN_BLOCK.getBlocks().size() == 1 && hpw.TOP_BLOCK.getBlocks().size() == 1;
}
return false;
}
public PlotTrimFilter(World world, long fileDuration, long inhabitedTicks, long chunkInactivity) {
super(fileDuration, inhabitedTicks, chunkInactivity);
Fawe.debug("Initializing Plot trim...");
String worldName = world.getName();
PlotArea area = PlotSquared.get().getPlotAreaByString(worldName);
IndependentPlotGenerator gen = area.getGenerator();
if (!(area instanceof HybridPlotWorld) || !(gen instanceof HybridGen)) {
throw new UnsupportedOperationException("Trim does not support non hybrid plot worlds");
}
this.hg = (HybridGen) gen;
this.hpw = (HybridPlotWorld) area;
if (hpw.PLOT_SCHEMATIC || hpw.MAIN_BLOCK.getBlocks().size() != 1 || hpw.TOP_BLOCK.getBlocks().size() != 1) {
throw new UnsupportedOperationException("WIP - will implement later");
}
this.occupiedRegions = new LongHashSet();
this.unoccupiedChunks = new LongHashSet();
this.reference = calculateReference();
Fawe.debug(" - calculating claims");
this.calculateClaimedArea();
}
private MCAChunk calculateReference() {
MCAChunk reference = new MCAChunk(null, 0, 0);
if (hpw.PLOT_BEDROCK) {
reference.fillCuboid(0, 15, 0, 0, 0, 15, BlockTypes.BEDROCK.getInternalId());
} else if (hpw.MAIN_BLOCK.hasSingleItem() && hpw.MAIN_BLOCK.getBlock().isAir() && hpw.TOP_BLOCK.hasSingleItem() && hpw.TOP_BLOCK.getBlock().isAir()) {
referenceIsVoid = true;
}
reference.fillCuboid(0, 15, 1, hpw.PLOT_HEIGHT - 1, 0, 15, LegacyMapper.getInstance().getBaseBlockFromPlotBlock(hpw.MAIN_BLOCK.getBlock()).getInternalBlockTypeId());
reference.fillCuboid(0, 15, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, 0, 15, LegacyMapper.getInstance().getBaseBlockFromPlotBlock(hpw.TOP_BLOCK.getBlock()).getInternalBlockTypeId());
return reference;
}
private void calculateClaimedArea() {
ArrayList<Plot> plots = new ArrayList<>(hpw.getPlots());
if (ExpireManager.IMP != null) {
plots.removeAll(ExpireManager.IMP.getPendingExpired());
}
for (Plot plot : plots) {
Location pos1 = plot.getBottom();
Location pos2 = plot.getTop();
int ccx1 = pos1.getX() >> 9;
int ccz1 = pos1.getZ() >> 9;
int ccx2 = pos2.getX() >> 9;
int ccz2 = pos2.getZ() >> 9;
for (int x = ccx1; x <= ccx2; x++) {
for (int z = ccz1; z <= ccz2; z++) {
if (!occupiedRegions.containsKey(x, z)) {
occupiedRegions.add(x, z);
int bcx = x << 5;
int bcz = z << 5;
int tcx = bcx + 32;
int tcz = bcz + 32;
for (int cz = bcz; cz < tcz; cz++) {
for (int cx = bcx; cx < tcx; cx++) {
unoccupiedChunks.add(cx, cz);
}
}
}
}
}
int cx1 = pos1.getX() >> 4;
int cz1 = pos1.getZ() >> 4;
int cx2 = pos2.getX() >> 4;
int cz2 = pos2.getZ() >> 4;
for (int cz = cz1; cz <= cz2; cz++) {
for (int cx = cx1; cx <= cx2; cx++) {
unoccupiedChunks.remove(cx, cz);
}
}
}
}
@Override
public boolean shouldDelete(File file, BasicFileAttributes attr, int mcaX, int mcaZ) throws IOException {
Fawe.debug("Apply file: " + file);
return !occupiedRegions.containsKey(mcaX, mcaZ) || super.shouldDelete(file, attr, mcaX, mcaZ);
}
@Override
public boolean shouldDeleteChunk(MCAFile mca, int cx, int cz) {
return unoccupiedChunks.containsKey(cx, cz);
}
@Override
public void filter(MCAFile mca, ForkJoinPool pool) throws IOException {
if (reference == null) {
super.filter(mca, pool);
return;
}
Path file = mca.getFile().toPath();
BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class);
long creationDate = attr.creationTime().toMillis();
mca.forEachSortedChunk(new RunnableVal4<Integer, Integer, Integer, Integer>() {
@Override
public void run(Integer x, Integer z, Integer offset, Integer size) {
int bx = mca.getX() << 5;
int bz = mca.getZ() << 5;
int cx = bx + x;
int cz = bz + z;
if (shouldDeleteChunk(mca, cx, cz)) {
MCAChunk chunk = new MCAChunk(null, x, z);
chunk.setDeleted(true);
synchronized (mca) {
mca.setChunk(chunk);
}
get().add(16 * 16 * 256);
return;
}
Runnable task = new Runnable() {
@Override
public void run() {
try {
MCAChunk chunk = mca.getChunk(x, z);
if (chunk.getInhabitedTime() <= getInhabitedTicks()) {
chunk.setDeleted(true);
get().add(16 * 16 * 256);
return;
}
if (referenceIsVoid) {
for (int i = 0; i < chunk.ids.length; i++) {
int[] arr = chunk.ids[i];
if (arr != null) {
for (int b : arr) {
if (!BlockTypes.getFromStateId(b).getMaterial().isAir()) return;
}
}
}
}
else if (!reference.idsEqual(chunk, false)) {
return;
}
chunk.setDeleted(true);
get().add(16 * 16 * 256);
} catch (IOException e) {
e.printStackTrace();
}
}
};
pool.submit(task);
}
});
}
}

Datei anzeigen

@ -1,4 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
public class RegionFilter {
}

Datei anzeigen

@ -1,172 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFile;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.jnbt.anvil.MutableMCABackedBaseBlock;
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
import com.boydti.fawe.object.collection.BlockVectorSet;
import com.boydti.fawe.object.number.MutableLong;
import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
// TODO FIXME
public class RemapFilter extends MCAFilterCounter {
private final ClipboardRemapper remapper;
private final ClipboardRemapper.RemapPlatform from;
private boolean skipRemap;
private List<CompoundTag> portals = Collections.synchronizedList(new ArrayList<>());
private BlockVectorSet pLocs = new BlockVectorSet();
private int dimension;
public RemapFilter(ClipboardRemapper remapper) {
this.remapper = remapper;
this.from = null;
}
public RemapFilter(ClipboardRemapper.RemapPlatform from, ClipboardRemapper.RemapPlatform to) {
this.remapper = new ClipboardRemapper(from, to);
this.from = from;
}
@Override
public MCAFile applyFile(MCAFile mca) {
File file = mca.getFile();
this.skipRemap = file.getName().endsWith(".mcapm");
return super.applyFile(mca);
}
@Override
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
if (skipRemap) return null;
return super.applyChunk(chunk, cache);
}
public List<CompoundTag> getPortals() {
return portals;
}
public void setDimension(int dimension) {
this.dimension = dimension;
}
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong cache) {
// int id = block.getId();
// if (remapper.hasRemap(id)) {
// BaseBlock result = remapper.remap(block);
// if (result != block) {
// cache.add(1);
// block.setId(id = result.getId());
// if (id == 218) {
// CompoundTag nbt = block.getNbtData();
// if (nbt != null) {
// Map<String, Tag> map = ReflectionUtils.getMap(nbt.getValue());
// map.putIfAbsent("facing", new ByteTag((byte) block.getData()));
// }
// }
// block.setData(result.getData());
// }
// }
// if (from != null) {
// outer:
// switch (from) {
// case PC: {
// int newLight = 0;
// switch (id) {
// case 90: {
// pLocs.add(x, y, z);
// if (pLocs.contains(x, y - 1, z) || pLocs.contains(x - 1, y, z) || pLocs.contains(x, y, z - 1))
// break;
// Map<String, Tag> tag = new HashMap<>();
// tag.put("Span", new ByteTag((byte) 1));
// tag.put("TpX", new IntTag(x));
// tag.put("TpY", new IntTag(y));
// tag.put("TpZ", new IntTag(z));
// tag.put("DimId", new IntTag(dimension));
// int data = block.getData();
// tag.put("Xa", new ByteTag((byte) ((data == 2) ? 0 : 1)));
// tag.put("Za", new ByteTag((byte) ((data == 2) ? 1 : 0)));
// portals.add(new CompoundTag(tag));
// break;
// }
// case 29:
// case 33: {
// int data = block.getData();
// Map<String, Object> map = new HashMap<>();
// map.put("Progress", 1f);
// map.put("State", (byte) 2);
// map.put("LastProgress", 1f);
// map.put("NewState", (byte) 2);
// map.put("isMoveable", (byte) 0);
// map.put("id", "PistonArm");
// map.put("AttachedBlocks", new ArrayList<>());
// map.put("Sticky", (byte) (id == 29 ? 1 : 0));
// map.put("x", x);
// map.put("y", y);
// map.put("z", z);
// block.setNbtData(FaweCache.asTag(map));
// break;
// }
// case 44:
// case 182:
// case 158:
// case 53:
// case 67:
// case 108:
// case 109:
// case 114:
// case 128:
// case 134:
// case 135:
// case 136:
// case 156:
// case 163:
// case 164:
// case 180:
// case 203:
// case 198:
// MutableMCABackedBaseBlock mcaBlock = (MutableMCABackedBaseBlock) block;
// MCAChunk chunk = mcaBlock.getChunk();
// int currentLight = chunk.getSkyLight(x, y, z);
// if (currentLight >= 14) {
// break;
// }
// newLight = chunk.getSkyLight(x, (y + 1) & 0xFF, z);
// if (newLight > currentLight) break;
// if (x > 0) {
// if ((newLight = chunk.getSkyLight(x - 1, y, z)) > currentLight) break;
// }
// if (x < 16) {
// if ((newLight = chunk.getSkyLight(x + 1, y, z)) > currentLight) break;
// }
// if (z > 0) {
// if ((newLight = chunk.getSkyLight(x, y, z - 1)) > currentLight) break;
// }
// if (z < 16) {
// if ((newLight = chunk.getSkyLight(x, y, z + 1)) > currentLight) break;
// }
// default:
// break outer;
// }
// if (newLight != 0) {
// ((MutableMCABackedBaseBlock) block).getChunk().setSkyLight(x, y, z, newLight);
// }
// break;
// }
// }
// }
}
}

Datei anzeigen

@ -1,52 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.number.MutableLong;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Arrays;
public class RemoveLayerFilter extends MCAFilterCounter {
private final int startLayer;
private final int endLayer;
private final int minY, maxY;
private final int id;
public RemoveLayerFilter(int minY, int maxY, int id) {
this.minY = minY;
this.maxY = maxY;
this.startLayer = minY >> 4;
this.endLayer = maxY >> 4;
this.id = id;
}
@Override
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
for (int layer = startLayer; layer <= endLayer; layer++) {
int[] ids = chunk.ids[layer];
if (ids == null) {
return null;
}
int startY = Math.max(minY, layer << 4) & 15;
int endY = Math.min(maxY, 15 + (layer << 4)) & 15;
for (int y = startY; y <= endY; y++) {
int indexStart = y << 8;
int indexEnd = indexStart + 255;
for (int index = indexStart; index <= indexEnd; index++) {
if (ids[index] != id) {
return null;
}
}
}
for (int y = startY; y <= endY; y++) {
int indexStart = y << 8;
int indexEnd = indexStart + 255;
Arrays.fill(ids, indexStart, indexEnd + 1, BlockTypes.AIR.getInternalId());
}
chunk.setModified();
}
return null;
}
}

Datei anzeigen

@ -1,33 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.mask.FaweBlockMatcher;
import com.boydti.fawe.object.number.MutableLong;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.function.pattern.Pattern;
// TODO FIXME
public class ReplacePatternFilter extends MCAFilterCounter {
private final FaweBlockMatcher matchFrom;
private final Pattern to;
public ReplacePatternFilter(FaweBlockMatcher from, Pattern to) {
this.matchFrom = from;
this.to = to;
}
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong ignore) {
// if (matchFrom.apply(block)) {
// BaseBlock newBlock = to.apply(x, y, z);
// int currentId = block.getId();
// if (FaweCache.hasNBT(currentId)) {
// block.setNbtData(null);
// }
// block.setId(newBlock.getId());
// block.setData(newBlock.getData());
// }
}
}

Datei anzeigen

@ -1,25 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.mask.FaweBlockMatcher;
import com.boydti.fawe.object.number.MutableLong;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
public class ReplaceSimpleFilter extends MCAFilterCounter {
private final FaweBlockMatcher to;
private final FaweBlockMatcher from;
public ReplaceSimpleFilter(FaweBlockMatcher from, FaweBlockMatcher to) {
this.from = from;
this.to = to;
}
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong count) {
if (from.apply(block)) {
to.apply(block);
count.increment();
}
}
}

Datei anzeigen

@ -1,29 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.number.MutableLong;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.function.pattern.Pattern;
// TODO FIXME
public class SetPatternFilter extends MCAFilterCounter {
private final Pattern to;
public SetPatternFilter(Pattern to) {
this.to = to;
}
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong count) {
// BaseBlock newBlock = to.apply(x, y, z);
// int currentId = block.getId();
// if (FaweCache.hasNBT(currentId)) {
// block.setNbtData(null);
// }
// block.setId(newBlock.getId());
// block.setData(newBlock.getData());
// count.increment();
}
}

Datei anzeigen

@ -1,46 +0,0 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFile;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.number.MutableLong;
import com.sk89q.worldedit.world.block.BlockTypes;
public class TrimAirFilter extends MCAFilterCounter {
@Override
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
for (int layer = 0; layer < chunk.ids.length; layer++) {
int[] idLayer = chunk.ids[layer];
if (idLayer == null) continue;
for (int i = 0; i < 4096; i++) {
if (!BlockTypes.getFromStateId(idLayer[i]).getMaterial().isAir()) {
return null;
}
}
{ // Possibly dead code depending on the generator
chunk.ids[layer] = null;
chunk.setModified();
}
}
cache.add(Character.MAX_VALUE);
chunk.setDeleted(true);
return null;
}
@Override
public void finishFile(MCAFile file, MutableLong cache) {
boolean[] deleteFile = { true };
file.forEachCachedChunk(new RunnableVal<MCAChunk>() {
@Override
public void run(MCAChunk value) {
if (!value.isDeleted()) {
deleteFile[0] = false;
}
}
});
if (deleteFile[0]) {
file.setDeleted(true);
}
}
}

Datei anzeigen

@ -1,9 +0,0 @@
package com.boydti.fawe.jnbt.anvil.history;
import java.io.File;
public interface IAnvilHistory {
default boolean addFileChange(File originalMCAFile) {
return originalMCAFile.delete();
}
}

Datei anzeigen

@ -1,4 +0,0 @@
package com.boydti.fawe.jnbt.anvil.history;
public class NullAnvilHistory implements IAnvilHistory {
}

Datei anzeigen

@ -2,7 +2,7 @@ package com.boydti.fawe.object;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.object.queue.DelegateFaweQueue;
import com.boydti.fawe.object.queue.DelegateIQueueExtent;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector3;
@ -12,10 +12,10 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
public class ChangeSetFaweQueue extends DelegateFaweQueue {
public class ChangeSetIQueueExtent extends DelegateIQueueExtent {
private FaweChangeSet set;
public ChangeSetFaweQueue(FaweChangeSet set, FaweQueue parent) {
public ChangeSetIQueueExtent(FaweChangeSet set, IQueueExtent parent) {
super(parent);
this.set = set;
}

Datei anzeigen

@ -119,10 +119,10 @@ public abstract class FawePlayer<T> extends Metadatable {
}
public int cancel(boolean close) {
// Collection<FaweQueue> queues = SetQueue.IMP.getAllQueues(); TODO NOT IMPLEMENTED
// Collection<IQueueExtent> queues = SetQueue.IMP.getAllQueues(); TODO NOT IMPLEMENTED
int cancelled = 0;
// clearActions();
// for (FaweQueue queue : queues) {
// for (IQueueExtent queue : queues) {
// Collection<EditSession> sessions = queue.getEditSessions();
// for (EditSession session : sessions) {
// FawePlayer currentPlayer = session.getPlayer();

Datei anzeigen

@ -4,7 +4,7 @@ import com.boydti.fawe.object.extent.FaweRegionExtent;
import com.boydti.fawe.object.extent.HeightBoundExtent;
import com.boydti.fawe.object.extent.MultiRegionExtent;
import com.boydti.fawe.object.extent.SingleRegionExtent;
import com.boydti.fawe.object.queue.DelegateFaweQueue;
import com.boydti.fawe.object.queue.DelegateIQueueExtent;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector2;
@ -14,10 +14,10 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class MaskedFaweQueue extends DelegateFaweQueue {
public class MaskedIQueueExtent extends DelegateIQueueExtent {
private FaweRegionExtent region;
public MaskedFaweQueue(FaweQueue parent, Region[] mask) {
public MaskedIQueueExtent(IQueueExtent parent, Region[] mask) {
super(parent);
setMask(mask);
}

Datei anzeigen

@ -1,8 +1,8 @@
package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.brush.heightmap.HeightMap;
import com.boydti.fawe.object.brush.heightmap.RotatableHeightMap;
import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap;
@ -75,7 +75,7 @@ public class HeightBrush implements Brush {
HeightMap map = getHeightMap();
map.setSize(size);
FaweQueue queue = editSession.getQueue();
IQueueExtent queue = editSession.getQueue();
// Optimized application of height map
if (queue instanceof HeightMapMCAGenerator) {
HeightMapMCAGenerator hmmg = (HeightMapMCAGenerator) queue;

Datei anzeigen

@ -1,7 +1,7 @@
package com.boydti.fawe.object.brush;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.collection.BlockVectorSet;
import com.boydti.fawe.object.mask.AdjacentAnyMask;
import com.boydti.fawe.object.mask.RadiusMask;
@ -35,7 +35,7 @@ public class LayerBrush implements Brush {
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws MaxChangedBlocksException {
final FaweQueue queue = editSession.getQueue();
final IQueueExtent queue = editSession.getQueue();
final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR));
final SolidBlockMask solid = new SolidBlockMask(editSession);
final RadiusMask radius = new RadiusMask(0, (int) size);

Datei anzeigen

@ -1,9 +1,7 @@
package com.boydti.fawe.object.brush.visualization;
import com.boydti.fawe.example.IntFaweChunk;
import com.boydti.fawe.example.NullQueueIntFaweChunk;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.WorldEditException;
@ -18,10 +16,10 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
public class VisualExtent extends AbstractDelegateExtent {
private final FaweQueue queue;
private final IQueueExtent queue;
private Long2ObjectMap<VisualChunk> chunks = new Long2ObjectOpenHashMap<>();
public VisualExtent(Extent parent, FaweQueue queue) {
public VisualExtent(Extent parent, IQueueExtent queue) {
super(parent);
this.queue = queue;
}

Datei anzeigen

@ -1,6 +1,7 @@
package com.boydti.fawe.jnbt.anvil;
package com.boydti.fawe.object.brush.visualization.cfi;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.FawePlayer;
@ -15,7 +16,6 @@ import com.boydti.fawe.object.collection.IterableThreadLocal;
import com.boydti.fawe.object.collection.LocalBlockVector2DSet;
import com.boydti.fawe.object.collection.SummedAreaTable;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.queue.LazyFaweChunk;
import com.boydti.fawe.object.schematic.Schematic;
import com.boydti.fawe.util.CachedTextureUtil;
import com.boydti.fawe.util.RandomTextureUtil;
@ -202,7 +202,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
blocks.clearChanges(); // blocks.redoChanges(in); Unsupported
}
@Override
// @Override TODO NOT IMPLEMENTED
public void addEditSession(EditSession session) {
session.setFastMode(true);
this.editSession = session;
@ -212,7 +212,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
private ImageViewer viewer;
// Used for visualizing the world by sending chunk packets
// These three variables should be set together
// private FaweQueue packetQueue;
// private IQueueExtent packetQueue;
private FawePlayer player;
private BlockVector2 chunkOffset = BlockVector2.ZERO;
private EditSession editSession;
@ -283,44 +283,44 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (viewer != null) {
viewer.view(this);
}
if (chunkOffset != null && player != null) {
FaweQueue packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false);
if (!packetQueue.supports(Capability.CHUNK_PACKETS)) {
return;
}
int lenCX = (getWidth() + 15) >> 4;
int lenCZ = (getLength() + 15) >> 4;
int OX = chunkOffset.getBlockX();
int OZ = chunkOffset.getBlockZ();
Location position = player.getLocation();
int pcx = (position.getBlockX() >> 4) - OX;
int pcz = (position.getBlockZ() >> 4) - OZ;
int scx = Math.max(0, pcx - 15);
int scz = Math.max(0, pcz - 15);
int ecx = Math.min(lenCX - 1, pcx + 15);
int ecz = Math.min(lenCZ - 1, pcz + 15);
for (int cz = scz; cz <= ecz; cz++) {
for (int cx = scx; cx <= ecx; cx++) {
final int finalCX = cx;
final int finalCZ = cz;
TaskManager.IMP.getPublicForkJoinPool().submit(() -> {
try {
FaweChunk toSend = getSnapshot(finalCX, finalCZ);
toSend.setLoc(HeightMapMCAGenerator.this, finalCX + OX, finalCZ + OZ);
packetQueue.sendChunkUpdate(toSend, player);
} catch (Throwable e) {
e.printStackTrace();
}
});
}
}
}
// if (chunkOffset != null && player != null) { TODO NOT IMPLEMENTED
// IQueueExtent packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false);
//
// if (!packetQueue.supports(Capability.CHUNK_PACKETS)) {
// return;
// }
//
// int lenCX = (getWidth() + 15) >> 4;
// int lenCZ = (getLength() + 15) >> 4;
//
// int OX = chunkOffset.getBlockX();
// int OZ = chunkOffset.getBlockZ();
//
// Location position = player.getLocation();
// int pcx = (position.getBlockX() >> 4) - OX;
// int pcz = (position.getBlockZ() >> 4) - OZ;
//
// int scx = Math.max(0, pcx - 15);
// int scz = Math.max(0, pcz - 15);
// int ecx = Math.min(lenCX - 1, pcx + 15);
// int ecz = Math.min(lenCZ - 1, pcz + 15);
//
// for (int cz = scz; cz <= ecz; cz++) {
// for (int cx = scx; cx <= ecx; cx++) {
// final int finalCX = cx;
// final int finalCZ = cz;
// TaskManager.IMP.getPublicForkJoinPool().submit(() -> {
// try {
// FaweChunk toSend = getSnapshot(finalCX, finalCZ);
// toSend.setLoc(HeightMapMCAGenerator.this, finalCX + OX, finalCZ + OZ);
// packetQueue.sendChunkUpdate(toSend, player);
// } catch (Throwable e) {
// e.printStackTrace();
// }
// });
// }
// }
// }
}
public TextureUtil getRawTextureUtil() {
@ -705,13 +705,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return setBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ(), block);
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return this.setBiome(position.getBlockX(), position.getBlockZ(), biome);
}
@Override
public boolean setBlock(int x, int y, int z, int combined) {
private boolean setBlock(int x, int y, int z, int combined) {
int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) return false;
int height = heights.getByte(index) & 0xFF;
@ -732,8 +726,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
combined = floorId;
default:
try {
short chunkX = (short) (x >> 4);
short chunkZ = (short) (z >> 4);
blocks.set(x, y, z, combined);
return true;
} catch (IndexOutOfBoundsException ignore) {
@ -750,79 +742,79 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return true;
}
@Override
public FaweChunk getFaweChunk(int chunkX, int chunkZ) {
return new SimpleIntFaweChunk(this, chunkX, chunkZ);
}
@Override
public FaweChunk getSnapshot(int chunkX, int chunkZ) {
return getSnapshot(null, chunkX, chunkZ);
}
private FaweChunk getSnapshot(final WritableMCAChunk chunk, int chunkX, int chunkZ) {
return new LazyFaweChunk<WritableMCAChunk>(this, chunkX, chunkZ) {
@Override
public WritableMCAChunk getChunk() {
WritableMCAChunk tmp = chunk;
if (tmp == null) {
tmp = new WritableMCAChunk();
}
tmp.setLoc(HeightMapMCAGenerator.this, chunkX, chunkZ);
int cbx = chunkX << 4;
int cbz = chunkZ << 4;
int csx = Math.max(0, cbx);
int csz = Math.max(0, cbz);
int cex = Math.min(getWidth(), cbx + 15);
int cez = Math.min(getLength(), cbz + 15);
write(tmp, csx, cex, csz, cez);
tmp.setLoc(HeightMapMCAGenerator.this, getX(), getZ());
return tmp;
}
@Override
public void addToQueue() {
WritableMCAChunk cached = getCachedChunk();
if (cached != null) setChunk(cached);
}
};
}
@Override
public Collection<FaweChunk> getFaweChunks() {
return Collections.emptyList();
}
@Override
public void setChunk(FaweChunk chunk) {
int[][] src = chunk.getCombinedIdArrays();
for (int i = 0; i < src.length; i++) {
if (src[i] != null) {
int bx = chunk.getX() << 4;
int bz = chunk.getZ() << 4;
int by = i << 4;
for (int layer = i; layer < src.length; layer++) {
int[] srcLayer = src[layer];
if (srcLayer != null) {
int index = 0;
for (int y = 0; y < 16; y++) {
int yy = by + y;
for (int z = 0; z < 16; z++) {
int zz = bz + z;
for (int x = 0; x < 16; x++, index++) {
int combined = srcLayer[index];
if (combined != 0) {
setBlock(bx + x, yy, zz, combined);
}
}
}
}
}
}
break;
}
}
}
// @Override TODO NOT IMPLEMENTED
// public FaweChunk getFaweChunk(int chunkX, int chunkZ) {
// return new SimpleIntFaweChunk(this, chunkX, chunkZ);
// }
//
// @Override
// public FaweChunk getSnapshot(int chunkX, int chunkZ) {
// return getSnapshot(null, chunkX, chunkZ);
// }
//
// private FaweChunk getSnapshot(final WritableMCAChunk chunk, int chunkX, int chunkZ) {
// return new LazyFaweChunk<WritableMCAChunk>(this, chunkX, chunkZ) {
// @Override
// public WritableMCAChunk getChunk() {
// WritableMCAChunk tmp = chunk;
// if (tmp == null) {
// tmp = new WritableMCAChunk();
// }
// tmp.setLoc(HeightMapMCAGenerator.this, chunkX, chunkZ);
// int cbx = chunkX << 4;
// int cbz = chunkZ << 4;
// int csx = Math.max(0, cbx);
// int csz = Math.max(0, cbz);
// int cex = Math.min(getWidth(), cbx + 15);
// int cez = Math.min(getLength(), cbz + 15);
// write(tmp, csx, cex, csz, cez);
// tmp.setLoc(HeightMapMCAGenerator.this, getX(), getZ());
// return tmp;
// }
//
// @Override
// public void addToQueue() {
// WritableMCAChunk cached = getCachedChunk();
// if (cached != null) setChunk(cached);
// }
// };
// }
//
// @Override
// public Collection<FaweChunk> getFaweChunks() {
// return Collections.emptyList();
// }
//
// @Override
// public void setChunk(FaweChunk chunk) {
// int[][] src = chunk.getCombinedIdArrays();
// for (int i = 0; i < src.length; i++) {
// if (src[i] != null) {
// int bx = chunk.getX() << 4;
// int bz = chunk.getZ() << 4;
// int by = i << 4;
// for (int layer = i; layer < src.length; layer++) {
// int[] srcLayer = src[layer];
// if (srcLayer != null) {
// int index = 0;
// for (int y = 0; y < 16; y++) {
// int yy = by + y;
// for (int z = 0; z < 16; z++) {
// int zz = bz + z;
// for (int x = 0; x < 16; x++, index++) {
// int combined = srcLayer[index];
// if (combined != 0) {
// setBlock(bx + x, yy, zz, combined);
// }
// }
// }
// }
// }
// }
// break;
// }
// }
// }
@Override
public File getSaveFolder() {
@ -835,18 +827,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return false;
}
@Nullable
@Override
public void sendBlockUpdate(FaweChunk chunk, FawePlayer... players) {
}
@Override
public void flush(int time) {
next(0, time);
}
@Override
public boolean next(int amount, long time) {
public Operation commit() {
EditSession curES = editSession;
if (curES != null && isModified()) {
try {
@ -863,15 +846,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
}
clear();
return false;
}
@Override
public void sendChunk(FaweChunk chunk) {
}
@Override
public void sendChunk(int x, int z, int bitMask) {
return null;
}
@Override
@ -883,7 +858,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
public void close(boolean update) {
clear();
if (chunkOffset != null && player != null && update) {
FaweQueue packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false);
IQueueExtent packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false);
int lenCX = (getWidth() + 15) >> 4;
int lenCZ = (getLength() + 15) >> 4;
@ -965,41 +940,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
}
@Override
public int getCombinedId4Data(int x, int y, int z, int def) {
return getCombinedId4Data(x, y, z);
}
@Override
public int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getCombinedId4Data(x, y, z);
}
@Override
public boolean hasSky() {
return true;
}
@Override
public int getSkyLight(int x, int y, int z) {
return getNearestSurfaceTerrainBlock(x, z, y, 0, 255) < y ? 15 : 0;
}
@Override
public int getEmmittedLight(int x, int y, int z) {
return 0;
}
@Override
public CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return null;
}
@Override
public int size() {
return 0;
}
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
return this.setBlock(x, y, z, block.getInternalId());
@ -1980,87 +1920,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return 255;
}
@Override
public void setWorld(String world) {
}
@Override
public World getWEWorld() {
return this;
}
@Override
public String getWorldName() {
return getName();
}
@Override
public long getModified() {
return 0;
}
@Override
public void setModified(long modified) {
// Unsupported
}
@Override
public RunnableVal2<ProgressType, Integer> getProgressTask() {
return null;
}
@Override
public void setProgressTask(RunnableVal2<ProgressType, Integer> progressTask) {
}
@Override
public void setChangeTask(RunnableVal2<FaweChunk, FaweChunk> changeTask) {
}
@Override
public RunnableVal2<FaweChunk, FaweChunk> getChangeTask() {
return null;
}
@Override
public SetQueue.QueueStage getStage() {
return SetQueue.QueueStage.NONE;
}
@Override
public void setStage(SetQueue.QueueStage stage) {
// Not supported
}
@Override
public void addNotifyTask(Runnable runnable) {
runnable.run();
}
@Override
public void runTasks() {
}
@Override
public void addTask(Runnable whenFree) {
whenFree.run();
}
@Override
public boolean isEmpty() {
return !isModified();
}
@Nullable
@Override
public Operation commit() {
return null;
}
@Override
public String getName() {
File folder = getFolder();
@ -2121,4 +1980,4 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
// TODO Auto-generated method stub
return null;
}
}
}

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.jnbt.anvil;
package com.boydti.fawe.object.brush.visualization.cfi;
import com.boydti.fawe.object.collection.IterableThreadLocal;
import com.boydti.fawe.object.io.BufferedRandomAccessFile;

Datei anzeigen

@ -1,7 +1,7 @@
package com.boydti.fawe.jnbt.anvil;
package com.boydti.fawe.object.brush.visualization.cfi;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.CompoundTag;
@ -23,7 +23,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
public class WritableMCAChunk extends FaweChunk<Void> {
public class WritableMCAChunk {
public final boolean[] hasSections = new boolean[16];
public final byte[] skyLight = new byte[65536];
public final byte[] blockLight = new byte[65536];
@ -44,7 +44,6 @@ public class WritableMCAChunk extends FaweChunk<Void> {
public int chunkX, chunkZ;
protected WritableMCAChunk() {
super(null, 0, 0);
}
public int getX() {
@ -100,7 +99,7 @@ public class WritableMCAChunk extends FaweChunk<Void> {
out.writeNamedEmptyList("TileEntities");
} else {
out.writeNamedTag("TileEntities", new ListTag(CompoundTag.class,
new ArrayList<>(tiles.values())));
new ArrayList<>(tiles.values())));
}
out.writeNamedTag("InhabitedTime", inhabitedTime);
out.writeNamedTag("LastUpdate", lastUpdate);
@ -405,20 +404,7 @@ public class WritableMCAChunk extends FaweChunk<Void> {
Arrays.fill(biomes, (byte) biome.getInternalId());
}
@Override
public FaweChunk<Void> copy(boolean shallow) {
throw new UnsupportedOperationException("Unsupported");
}
public void removeEntity(UUID uuid) {
entities.remove(uuid);
}
public Void getChunk() {
throw new UnsupportedOperationException("Not applicable for this");
}
public FaweChunk call() {
throw new UnsupportedOperationException("Not supported");
}
}

Datei anzeigen

@ -1,9 +1,9 @@
package com.boydti.fawe.object.change;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.history.UndoContext;
@ -23,9 +23,9 @@ public class CFIChange implements Change {
}
private HeightMapMCAGenerator getQueue(UndoContext context) {
ExtentTraverser found = new ExtentTraverser(context.getExtent()).find(HasFaweQueue.class);
ExtentTraverser found = new ExtentTraverser(context.getExtent()).find(HasIQueueExtent.class);
if (found != null) {
FaweQueue queue = ((HasFaweQueue) found.get()).getQueue();
IQueueExtent queue = ((HasIQueueExtent) found.get()).getQueue();
if (queue instanceof HeightMapMCAGenerator) return (HeightMapMCAGenerator) queue;
}
Fawe.debug("FAWE does not support: " + context.getExtent() + " for " + getClass() + " (bug Empire92)");

Datei anzeigen

@ -1,8 +1,8 @@
package com.boydti.fawe.object.change;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
@ -34,7 +34,7 @@ public class MutableBlockChange implements Change {
create(context);
}
private FaweQueue queue;
private IQueueExtent queue;
private boolean checkedQueue;
public void create(UndoContext context) {
@ -44,9 +44,9 @@ public class MutableBlockChange implements Change {
if (!checkedQueue) {
checkedQueue = true;
Extent extent = context.getExtent();
ExtentTraverser found = new ExtentTraverser(extent).find(HasFaweQueue.class);
ExtentTraverser found = new ExtentTraverser(extent).find(HasIQueueExtent.class);
if (found != null) {
(queue = ((HasFaweQueue) found.get()).getQueue()).setBlock(x, y, z, combinedId);
(queue = ((HasIQueueExtent) found.get()).getQueue()).setBlock(x, y, z, combinedId);
} else {
Fawe.debug("FAWE does not support: " + extent + " for " + getClass() + " (bug Empire92)");
}

Datei anzeigen

@ -2,8 +2,8 @@ package com.boydti.fawe.object.change;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
@ -33,7 +33,7 @@ public class MutableChunkChange implements Change {
create(context, false);
}
private FaweQueue queue;
private IQueueExtent queue;
private boolean checkedQueue;
public void create(UndoContext context, boolean undo) {
@ -43,16 +43,16 @@ public class MutableChunkChange implements Change {
if (!checkedQueue) {
checkedQueue = true;
Extent extent = context.getExtent();
ExtentTraverser found = new ExtentTraverser(extent).find(HasFaweQueue.class);
ExtentTraverser found = new ExtentTraverser(extent).find(HasIQueueExtent.class);
if (found != null) {
perform(queue = ((HasFaweQueue) found.get()).getQueue(), undo);
perform(queue = ((HasIQueueExtent) found.get()).getQueue(), undo);
} else {
Fawe.debug("FAWE does not support: " + extent + " for " + getClass() + " (bug Empire92)");
}
}
}
public void perform(FaweQueue queue, boolean undo) {
public void perform(IQueueExtent queue, boolean undo) {
if (undo) {
if (checkEmpty) {
int[][] previousIds = from.getCombinedIdArrays();

Datei anzeigen

@ -1,8 +1,8 @@
package com.boydti.fawe.object.change;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.object.extent.FastWorldEditExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.boydti.fawe.util.MathMan;
@ -75,7 +75,7 @@ public class MutableEntityChange implements Change {
}
}
private FaweQueue queue;
private IQueueExtent queue;
private boolean checkedQueue;
public void create(UndoContext context) {
@ -85,16 +85,16 @@ public class MutableEntityChange implements Change {
if (!checkedQueue) {
checkedQueue = true;
Extent extent = context.getExtent();
ExtentTraverser found = new ExtentTraverser(extent).find(HasFaweQueue.class);
ExtentTraverser found = new ExtentTraverser(extent).find(HasIQueueExtent.class);
if (found != null) {
perform(queue = ((HasFaweQueue) found.get()).getQueue());
perform(queue = ((HasIQueueExtent) found.get()).getQueue());
} else {
Fawe.debug("FAWE does not support: " + extent + " for " + getClass() + " (bug Empire92)");
}
}
}
public void perform(FaweQueue queue) {
public void perform(IQueueExtent queue) {
Map<String, Tag> map = tag.getValue();
Tag posTag = map.get("Pos");
if (posTag == null) {

Datei anzeigen

@ -1,8 +1,8 @@
package com.boydti.fawe.object.change;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
@ -41,7 +41,7 @@ public class MutableFullBlockChange implements Change {
create(context);
}
private FaweQueue queue;
private IQueueExtent queue;
private boolean checkedQueue;
public void create(UndoContext context) {
@ -51,16 +51,16 @@ public class MutableFullBlockChange implements Change {
if (!checkedQueue) {
checkedQueue = true;
Extent extent = context.getExtent();
ExtentTraverser found = new ExtentTraverser(extent).find(HasFaweQueue.class);
ExtentTraverser found = new ExtentTraverser(extent).find(HasIQueueExtent.class);
if (found != null) {
perform(queue = ((HasFaweQueue) found.get()).getQueue());
perform(queue = ((HasIQueueExtent) found.get()).getQueue());
} else {
Fawe.debug("FAWE does not support: " + extent + " for " + getClass() + " (bug Empire92)");
}
}
}
public void perform(FaweQueue queue) {
public void perform(IQueueExtent queue) {
BlockType idFrom = BlockTypes.getFromStateId(from);
if (blockBag != null) {
BlockType idTo = BlockTypes.getFromStateId(to);

Datei anzeigen

@ -1,8 +1,8 @@
package com.boydti.fawe.object.change;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag;
@ -37,7 +37,7 @@ public class MutableTileChange implements Change {
}
}
private FaweQueue queue;
private IQueueExtent queue;
private boolean checkedQueue;
public void create(UndoContext context) {
@ -47,16 +47,16 @@ public class MutableTileChange implements Change {
if (!checkedQueue) {
checkedQueue = true;
Extent extent = context.getExtent();
ExtentTraverser found = new ExtentTraverser(extent).find(HasFaweQueue.class);
ExtentTraverser found = new ExtentTraverser(extent).find(HasIQueueExtent.class);
if (found != null) {
perform(queue = ((HasFaweQueue) found.get()).getQueue());
perform(queue = ((HasIQueueExtent) found.get()).getQueue());
} else {
Fawe.debug("FAWE does not support: " + extent + " for " + getClass() + " (bug Empire92)");
}
}
}
public void perform(FaweQueue queue) {
public void perform(IQueueExtent queue) {
Map<String, Tag> map = tag.getValue();
int x = ((IntTag) map.get("x")).getValue();
int y = ((IntTag) map.get("y")).getValue();

Datei anzeigen

@ -1,7 +1,7 @@
package com.boydti.fawe.object.changeset;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.world.block.BaseBlock;
@ -29,7 +29,7 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
}
@Override
public void addChangeTask(FaweQueue queue) {
public void addChangeTask(IQueueExtent queue) {
super.addChangeTask(queue);
}

Datei anzeigen

@ -2,7 +2,7 @@ package com.boydti.fawe.object.changeset;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.change.CFIChange;
import com.boydti.fawe.util.MainUtil;
import com.sk89q.jnbt.CompoundTag;

Datei anzeigen

@ -1,7 +1,7 @@
package com.boydti.fawe.object.changeset;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.change.MutableChunkChange;
import com.sk89q.jnbt.CompoundTag;
@ -20,7 +20,7 @@ public class CPUOptimizedChangeSet extends FaweChangeSet {
private ArrayList<Change> changes = new ArrayList<>();
public void addChangeTask(FaweQueue queue) {
public void addChangeTask(IQueueExtent queue) {
queue.setChangeTask(new RunnableVal2<FaweChunk, FaweChunk>() {
@Override
public void run(final FaweChunk previous, final FaweChunk next) {

Datei anzeigen

@ -1,8 +1,8 @@
package com.boydti.fawe.object.changeset;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.util.ExtentTraverser;
import com.boydti.fawe.util.MainUtil;
@ -23,7 +23,7 @@ public class MutableAnvilChange implements Change {
this.source = source;
}
private FaweQueue queue;
private IQueueExtent queue;
private boolean checkedQueue;
@Override
@ -34,9 +34,9 @@ public class MutableAnvilChange implements Change {
if (!checkedQueue) {
checkedQueue = true;
Extent extent = context.getExtent();
ExtentTraverser found = new ExtentTraverser(extent).find(HasFaweQueue.class);
ExtentTraverser found = new ExtentTraverser(extent).find(HasIQueueExtent.class);
if (found != null) {
queue = ((HasFaweQueue) found.get()).getQueue();
queue = ((HasIQueueExtent) found.get()).getQueue();
destDir = queue.getSaveFolder().toPath();
perform(queue);
} else {
@ -45,7 +45,7 @@ public class MutableAnvilChange implements Change {
}
}
public void perform(FaweQueue queue) {
public void perform(IQueueExtent queue) {
Path dest = destDir.resolve(source.getFileName());
try {
Files.move(source, dest, StandardCopyOption.ATOMIC_MOVE);

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.jnbt.anvil;
package com.boydti.fawe.object.collection;
public final class BitArray4096 {

Datei anzeigen

@ -1,7 +1,7 @@
package com.boydti.fawe.object.extent;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.DoubleTag;
@ -30,19 +30,19 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFaweQueue {
public class FastWorldEditExtent extends AbstractDelegateExtent implements HasIQueueExtent {
private final World world;
private FaweQueue queue;
private IQueueExtent queue;
public FastWorldEditExtent(final World world, FaweQueue queue) {
public FastWorldEditExtent(final World world, IQueueExtent queue) {
super(queue);
this.world = world;
this.queue = queue;
}
@Override
public FaweQueue getQueue() {
public IQueueExtent getQueue() {
return queue;
}

Datei anzeigen

@ -3,7 +3,7 @@ package com.boydti.fawe.object.progress;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager;
@ -11,7 +11,7 @@ import com.boydti.fawe.util.TaskManager;
/**
* The default progress tracker uses titles
*/
public class DefaultProgressTracker extends RunnableVal2<FaweQueue.ProgressType, Integer> {
public class DefaultProgressTracker extends RunnableVal2<IQueueExtent.ProgressType, Integer> {
private final FawePlayer player;
private final long start;
@ -55,7 +55,7 @@ public class DefaultProgressTracker extends RunnableVal2<FaweQueue.ProgressType,
private boolean done = false;
@Override
public void run(FaweQueue.ProgressType type, Integer amount) {
public void run(IQueueExtent.ProgressType type, Integer amount) {
switch (type) {
case DISPATCH:
amountDispatch++;

Datei anzeigen

@ -1,25 +0,0 @@
package com.boydti.fawe.object.queue;
import com.boydti.fawe.object.FaweQueue;
public class DelegateFaweQueue implements IDelegateFaweQueue {
private FaweQueue parent;
public DelegateFaweQueue(FaweQueue parent) {
this.parent = parent;
}
public FaweQueue getParent() {
return parent;
}
public void setParent(FaweQueue parent) {
this.parent = parent;
setWorld(getQueue().getWorldName());
}
@Override
public FaweQueue getQueue() {
return parent;
}
}

Datei anzeigen

@ -1,89 +0,0 @@
package com.boydti.fawe.object.queue;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector2;
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 static com.google.common.base.Preconditions.checkNotNull;
public class FaweQueueDelegateExtent extends DelegateFaweQueue {
private final FaweQueue parentQueue;
private final Extent parentExtent;
// private final MutableBlockVector2 mutable2d = new MutableBlockVector2();
public FaweQueueDelegateExtent(FaweQueue parentQueue, Extent parentExtent) {
super(parentQueue);
checkNotNull(parentExtent);
checkNotNull(parentQueue);
this.parentQueue = parentQueue;
this.parentExtent = parentExtent;
}
@Override
public boolean setBlock(int x, int y, int z, int combinedId) {
return setBlock(x, y, z, BlockState.getFromInternalId(combinedId));
}
@Override
public boolean setBlock(int x, int y, int z, int combinedId, CompoundTag nbt) {
if (nbt != null) {
return setBlock(x, y, z, BaseBlock.getFromInternalId(combinedId, nbt));
}
return setBlock(x, y, z, BlockState.getFromInternalId(combinedId));
}
@Override
public int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getCombinedId4Data(x, y, z);
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getBlock(x, y, z).getInternalId();
}
@Override
public CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getFullBlock(BlockVector3.at(x, y, z)).getNbtData();
}
@Override
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
return parentExtent.getBiome(BlockVector2.at(x, z));
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return parentExtent.setBiome(position, biome);
}
@Override
public BlockState getBlock(BlockVector3 position) {
return parentExtent.getBlock(position);
}
@Override
public BiomeType getBiome(BlockVector2 position) {
return parentExtent.getBiome(position);
}
@Override
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
return parentExtent.setBlock(position, block);
}
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
return parentExtent.setBlock(x, y, z, block);
}
}

Datei anzeigen

@ -1,507 +0,0 @@
package com.boydti.fawe.object.queue;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.Relighter;
import com.boydti.fawe.jnbt.anvil.generator.GenBase;
import com.boydti.fawe.jnbt.anvil.generator.Resource;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.SetQueue;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
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.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
public interface IDelegateFaweQueue extends FaweQueue {
@Override
FaweQueue getQueue();
@Override
default void dequeue() {
getQueue().dequeue();
}
@Override
default Relighter getRelighter() {
return getQueue().getRelighter();
}
@Override
default BlockVector3 getMinimumPoint() {
return getQueue().getMinimumPoint();
}
@Override
default BlockVector3 getMaximumPoint() {
return getQueue().getMaximumPoint();
}
@Override
default BlockState getBlock(int x, int y, int z) {
return getQueue().getBlock(x, y, z);
}
@Override
default <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
return getQueue().setBlock(x, y, z, block);
}
@Override
default BlockState getBlock(BlockVector3 position) {
return getQueue().getBlock(position);
}
@Override
default BiomeType getBiome(BlockVector2 position) {
return getQueue().getBiome(position);
}
@Override
default <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block) throws WorldEditException {
return getQueue().setBlock(position, block);
}
@Override
default boolean setBiome(BlockVector2 position, BiomeType biome) {
return getQueue().setBiome(position, biome);
}
@Override
default void addEditSession(EditSession session) {
getQueue().addEditSession(session);
}
@Override
default void setProgressTracker(RunnableVal2<ProgressType, Integer> progressTask) {
getQueue().setProgressTracker(progressTask);
}
@Override
default Collection<EditSession> getEditSessions() {
return getQueue().getEditSessions();
}
@Override
default boolean supports(Capability capability) {
return getQueue().supports(capability);
}
@Override
default void optimize() {
getQueue().optimize();
}
@Override
default int setBlocks(CuboidRegion cuboid, int combinedId) {
return getQueue().setBlocks(cuboid, combinedId);
}
@Override
default boolean setBlock(int x, int y, int z, int combinedId) {
return getQueue().setBlock(x, y, z, combinedId);
}
@Override
default boolean setBlock(int x, int y, int z, int combinedId, CompoundTag nbt) {
return getQueue().setBlock(x, y, z, combinedId, nbt);
}
@Override
default void setTile(int x, int y, int z, CompoundTag tag) {
getQueue().setTile(x, y, z, tag);
}
@Override
default void setEntity(int x, int y, int z, CompoundTag tag) {
getQueue().setEntity(x, y, z, tag);
}
@Override
default void removeEntity(int x, int y, int z, UUID uuid) {
getQueue().removeEntity(x, y, z, uuid);
}
@Override
default boolean setBiome(int x, int z, BiomeType biome) {
return getQueue().setBiome(x, z, biome);
}
@Override
default FaweChunk getFaweChunk(int x, int z) {
return getQueue().getFaweChunk(x, z);
}
@Override
default Collection<FaweChunk> getFaweChunks() {
return getQueue().getFaweChunks();
}
@Override
default boolean setMCA(int mcaX, int mcaZ, RegionWrapper region, Runnable whileLocked, boolean save, boolean load) {
return getQueue().setMCA(mcaX, mcaZ, region, whileLocked, save, load);
}
@Override
default void setChunk(FaweChunk chunk) {
getQueue().setChunk(chunk);
}
@Override
default File getSaveFolder() {
return getQueue().getSaveFolder();
}
@Override
default int getMaxY() {
return getQueue().getMaxY();
}
@Override
default Settings getSettings() {
return getQueue().getSettings();
}
@Override
default void setSettings(Settings settings) {
getQueue().setSettings(settings);
}
@Override
default void setWorld(String world) {
getQueue().setWorld(world);
}
@Override
default World getWEWorld() {
return getQueue().getWEWorld();
}
@Override
default String getWorldName() {
return getQueue().getWorldName();
}
@Override
default long getModified() {
return getQueue().getModified();
}
@Override
default void setModified(long modified) {
getQueue().setModified(modified);
}
@Override
default RunnableVal2<ProgressType, Integer> getProgressTask() {
return getQueue().getProgressTask();
}
@Override
default void setProgressTask(RunnableVal2<ProgressType, Integer> progressTask) {
getQueue().setProgressTask(progressTask);
}
@Override
default void setChangeTask(RunnableVal2<FaweChunk, FaweChunk> changeTask) {
getQueue().setChangeTask(changeTask);
}
@Override
default RunnableVal2<FaweChunk, FaweChunk> getChangeTask() {
return getQueue().getChangeTask();
}
@Override
default SetQueue.QueueStage getStage() {
return getQueue().getStage();
}
@Override
default void setStage(SetQueue.QueueStage stage) {
getQueue().setStage(stage);
}
@Override
default void addNotifyTask(Runnable runnable) {
getQueue().addNotifyTask(runnable);
}
@Override
default void runTasks() {
getQueue().runTasks();
}
@Override
default void addTask(Runnable whenFree) {
getQueue().addTask(whenFree);
}
@Override
default void forEachBlockInChunk(int cx, int cz, RunnableVal2<BlockVector3, BaseBlock> onEach) {
getQueue().forEachBlockInChunk(cx, cz, onEach);
}
@Override
default void forEachTileInChunk(int cx, int cz, RunnableVal2<BlockVector3, BaseBlock> onEach) {
getQueue().forEachTileInChunk(cx, cz, onEach);
}
@Override
@Deprecated
default boolean regenerateChunk(int x, int z) {
return getQueue().regenerateChunk(x, z);
}
@Override
default boolean regenerateChunk(int x, int z, @Nullable BiomeType biome, @Nullable Long seed) {
return getQueue().regenerateChunk(x, z, biome, seed);
}
@Override
default void startSet(boolean parallel) {
getQueue().startSet(parallel);
}
@Override
default void endSet(boolean parallel) {
getQueue().endSet(parallel);
}
@Override
default int cancel() {
return getQueue().cancel();
}
@Override
default void sendBlockUpdate(FaweChunk chunk, FawePlayer... players) {
getQueue().sendBlockUpdate(chunk, players);
}
@Override
@Deprecated
default boolean next() {
return getQueue().next();
}
@Override
default boolean next(int amount, long time) {
return getQueue().next(amount, time);
}
@Override
default void saveMemory() {
getQueue().saveMemory();
}
@Override
default void sendChunk(FaweChunk chunk) {
getQueue().sendChunk(chunk);
}
@Override
default void sendChunk(int x, int z, int bitMask) {
getQueue().sendChunk(x, z, bitMask);
}
@Override
default void clear() {
getQueue().clear();
}
@Override
default boolean hasBlock(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getQueue().hasBlock(x, y, z);
}
@Override
default BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
return getQueue().getBiomeType(x, z);
}
@Override
default int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getQueue().getCombinedId4Data(x, y, z);
}
@Override
default int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getQueue().getCachedCombinedId4Data(x, y, z);
}
@Override
default int getAdjacentLight(int x, int y, int z) {
return getQueue().getAdjacentLight(x, y, z);
}
@Override
default boolean hasSky() {
return getQueue().hasSky();
}
@Override
default int getSkyLight(int x, int y, int z) {
return getQueue().getSkyLight(x, y, z);
}
@Override
default int getLight(int x, int y, int z) {
return getQueue().getLight(x, y, z);
}
@Override
default int getEmmittedLight(int x, int y, int z) {
return getQueue().getEmmittedLight(x, y, z);
}
@Override
default CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getQueue().getTileEntity(x, y, z);
}
@Override
default int getCombinedId4Data(int x, int y, int z, int def) {
return getQueue().getCombinedId4Data(x, y, z, def);
}
@Override
default int getCachedCombinedId4Data(int x, int y, int z, int def) {
return getQueue().getCachedCombinedId4Data(x, y, z, def);
}
@Override
default int getCombinedId4DataDebug(int x, int y, int z, int def, EditSession session) {
return getQueue().getCombinedId4DataDebug(x, y, z, def, session);
}
@Override
default int getBrightness(int x, int y, int z) {
return getQueue().getBrightness(x, y, z);
}
@Override
default int getOpacityBrightnessPair(int x, int y, int z) {
return getQueue().getOpacityBrightnessPair(x, y, z);
}
@Override
default int getOpacity(int x, int y, int z) {
return getQueue().getOpacity(x, y, z);
}
@Override
default int size() {
return getQueue().size();
}
@Override
default boolean isEmpty() {
return getQueue().isEmpty();
}
@Override
default void flush() {
getQueue().flush();
}
@Override
default void flush(int time) {
getQueue().flush(time);
}
@Override
default boolean enqueue() {
return getQueue().enqueue();
}
@Override
default List<? extends Entity> getEntities(Region region) {
return getQueue().getEntities(region);
}
@Override
default List<? extends Entity> getEntities() {
return getQueue().getEntities();
}
@Override
@Nullable
default Entity createEntity(Location location, BaseEntity entity) {
return getQueue().createEntity(location, entity);
}
@Nullable
@Override
default Operation commit() {
return getQueue().commit();
}
@Override
default int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
return getQueue().getNearestSurfaceLayer(x, z, y, minY, maxY);
}
@Override
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
return getQueue().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
}
@Override
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
return getQueue().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
}
@Override
default void addCaves(Region region) throws WorldEditException {
getQueue().addCaves(region);
}
@Override
default void generate(Region region, GenBase gen) throws WorldEditException {
getQueue().generate(region, gen);
}
@Override
default void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
getQueue().addSchems(region, mask, clipboards, rarity, rotate);
}
@Override
default void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
getQueue().spawnResource(region, gen, rarity, frequency);
}
@Override
default void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
getQueue().addOre(region, mask, material, size, frequency, rarity, minY, maxY);
}
@Override
default void addOres(Region region, Mask mask) throws WorldEditException {
getQueue().addOres(region, mask);
}
}

Datei anzeigen

@ -1,197 +0,0 @@
package com.boydti.fawe.object.queue;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.visitor.FaweChunkVisitor;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nullable;
public abstract class LazyFaweChunk<T extends FaweChunk> extends FaweChunk {
private T parent;
public LazyFaweChunk(FaweQueue queue, int chunkX, int chunkZ) {
super(queue, chunkX, chunkZ);
}
private T internalGetOrCacheChunk() {
T tmp = parent;
if (tmp == null) parent = tmp = getChunk();
return tmp;
}
protected T getCachedChunk() {
return parent;
}
public abstract T getChunk();
@Override
public FaweQueue getParent() {
return internalGetOrCacheChunk().getParent();
}
@Override
public long longHash() {
return internalGetOrCacheChunk().longHash();
}
@Override
public int hashCode() {
return internalGetOrCacheChunk().hashCode();
}
@Override
public void addToQueue() {
internalGetOrCacheChunk().addToQueue();
}
@Override
public int getBitMask() {
return internalGetOrCacheChunk().getBitMask();
}
@Override
public int getBlockCombinedId(int x, int y, int z) {
return internalGetOrCacheChunk().getBlockCombinedId(x, y, z);
}
@Override
public void setBlock(int x, int y, int z, BlockStateHolder block) {
internalGetOrCacheChunk().setBlock(x, y, z, block);
}
@Override
public BlockState getBlock(int x, int y, int z) {
return internalGetOrCacheChunk().getBlock(x, y, z);
}
@Override
@Nullable
public int[] getIdArray(int layer) {
return internalGetOrCacheChunk().getIdArray(layer);
}
@Override
public byte[][] getBlockLightArray() {
return internalGetOrCacheChunk().getBlockLightArray();
}
@Override
public byte[][] getSkyLightArray() {
return internalGetOrCacheChunk().getSkyLightArray();
}
@Override
public BiomeType[] getBiomeArray() {
return internalGetOrCacheChunk().getBiomeArray();
}
@Override
public void forEachQueuedBlock(FaweChunkVisitor onEach) {
internalGetOrCacheChunk().forEachQueuedBlock(onEach);
}
@Override
public int[][] getCombinedIdArrays() {
return internalGetOrCacheChunk().getCombinedIdArrays();
}
@Override
public void fill(int combinedId) {
internalGetOrCacheChunk().fill(combinedId);
}
@Override
public void fillCuboid(int x1, int x2, int y1, int y2, int z1, int z2, int combinedId) {
internalGetOrCacheChunk().fillCuboid(x1, x2, y1, y2, z1, z2, combinedId);
}
@Override
public void setTile(int x, int y, int z, CompoundTag tile) {
internalGetOrCacheChunk().setTile(x, y, z, tile);
}
@Override
public void setEntity(CompoundTag entity) {
internalGetOrCacheChunk().setEntity(entity);
}
@Override
public void removeEntity(UUID uuid) {
internalGetOrCacheChunk().removeEntity(uuid);
}
@Override
public void setBlock(int x, int y, int z, int combinedId) {
internalGetOrCacheChunk().setBlock(x, y, z, combinedId);
}
@Override
public Set<CompoundTag> getEntities() {
return internalGetOrCacheChunk().getEntities();
}
@Override
public Set<UUID> getEntityRemoves() {
return internalGetOrCacheChunk().getEntityRemoves();
}
@Override
public Map<Short, CompoundTag> getTiles() {
return internalGetOrCacheChunk().getTiles();
}
@Override
public CompoundTag getTile(int x, int y, int z) {
return internalGetOrCacheChunk().getTile(x, y, z);
}
@Override
public void setBiome(int x, int z, BiomeType biome) {
internalGetOrCacheChunk().setBiome(x, z, biome);
}
@Override
public void setBiome(BiomeType biome) {
internalGetOrCacheChunk().setBiome(biome);
}
@Override
public void optimize() {
internalGetOrCacheChunk().optimize();
}
@Override
public boolean equals(Object obj) {
return internalGetOrCacheChunk().equals(obj);
}
@Override
public FaweChunk copy(boolean shallow) {
return internalGetOrCacheChunk().copy(shallow);
}
@Override
public void start() {
internalGetOrCacheChunk().start();
}
@Override
public void end() {
internalGetOrCacheChunk().end();
}
@Override
public FaweChunk call() {
return internalGetOrCacheChunk().call();
}
}

Datei anzeigen

@ -1,224 +0,0 @@
package com.boydti.fawe.object.queue;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.SetQueue;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.UUID;
import javax.annotation.Nullable;
public class NullFaweQueue implements FaweQueue {
private final String worldName;
private final BlockState state;
public NullFaweQueue(String worldName) {
this(worldName, BlockTypes.AIR.getDefaultState());
}
public NullFaweQueue(String worldName, BlockState state) {
this.worldName = worldName;
this.state = state;
}
@Override
public boolean setBlock(int x, int y, int z, int combinedId) {
return false;
}
@Override
public void setTile(int x, int y, int z, CompoundTag tag) {
}
@Override
public void setEntity(int x, int y, int z, CompoundTag tag) {
}
@Override
public void removeEntity(int x, int y, int z, UUID uuid) {
}
@Override
public boolean setBiome(int x, int z, BiomeType biome) {
return false;
}
@Override
public FaweChunk getFaweChunk(int x, int z) {
return null;
}
@Override
public Collection<FaweChunk> getFaweChunks() {
return Collections.emptyList();
}
@Override
public void setChunk(FaweChunk chunk) {
}
@Override
public File getSaveFolder() {
return null;
}
@Override
public void setWorld(String world) {
}
@Override
public World getWEWorld() {
return null;
}
@Override
public String getWorldName() {
return worldName;
}
@Override
public long getModified() {
return 0;
}
@Override
public void setModified(long modified) {
}
@Override
public RunnableVal2<ProgressType, Integer> getProgressTask() {
return null;
}
@Override
public void setProgressTask(RunnableVal2<ProgressType, Integer> progressTask) {
}
@Override
public void setChangeTask(RunnableVal2<FaweChunk, FaweChunk> changeTask) {
}
@Override
public RunnableVal2<FaweChunk, FaweChunk> getChangeTask() {
return null;
}
@Override
public SetQueue.QueueStage getStage() {
return SetQueue.QueueStage.NONE;
}
@Override
public void setStage(SetQueue.QueueStage stage) {
}
@Override
public void addNotifyTask(Runnable runnable) {
runnable.run();
}
@Override
public void runTasks() {
}
@Override
public void addTask(Runnable whenFree) {
whenFree.run();
}
@Override
public boolean regenerateChunk(int x, int z, @Nullable BiomeType biome, @Nullable Long seed) {
return false;
}
@Override
public void sendBlockUpdate(FaweChunk chunk, FawePlayer... players) {
}
@Override
public boolean next(int amount, long time) {
return false;
}
@Override
public void sendChunk(FaweChunk chunk) {
}
@Override
public void sendChunk(int x, int z, int bitMask) {
}
@Override
public void clear() {
}
@Override
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
return null;
}
@Override
public BlockState getBlock(BlockVector3 position) {
return state;
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return state.getInternalId();
}
@Override
public int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return state.getInternalId();
}
@Override
public boolean hasSky() {
return true;
}
@Override
public int getSkyLight(int x, int y, int z) {
return 0;
}
@Override
public int getEmmittedLight(int x, int y, int z) {
return 0;
}
@Override
public CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return null;
}
@Override
public int size() {
return 0;
}
}

Datei anzeigen

@ -1,6 +1,6 @@
package com.boydti.fawe.object.schematic;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.object.clipboard.FaweClipboard;
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
import com.boydti.fawe.util.EditSessionBuilder;
@ -266,7 +266,7 @@ public class Schematic {
extent.setBlock(xx, mutable.getBlockY() + rely, zz, block);
return false;
}
}, (HasFaweQueue) (null));
}, (HasIQueueExtent) (null));
Operations.completeBlindly(visitor);
}
// Entity offset is the paste location subtract the clipboard origin (entity's location is already relative to the world origin)

Datei anzeigen

@ -168,7 +168,7 @@
// }
// }
// // Resend relevant chunks
// FaweQueue packetQueue = SetQueue.IMP.getNewQueue(this.player.getWorld(), true, false);
// IQueueExtent packetQueue = SetQueue.IMP.getNewQueue(this.player.getWorld(), true, false);
// if (packetQueue.supports(Capability.CHUNK_PACKETS)) {
// ArrayDeque<Long> toSend = new ArrayDeque<>();
// ObjectIterator<Long2ObjectMap.Entry<MCAChunk>> iter = chunks.long2ObjectEntrySet().fastIterator();
@ -232,7 +232,7 @@
// * @param chunkX
// * @param chunkZ
// */
// private void send(FaweQueue packetQueue, int chunkX, int chunkZ) {
// private void send(IQueueExtent packetQueue, int chunkX, int chunkZ) {
// TaskManager.IMP.getPublicForkJoinPool().submit(() -> {
// try {
// int OX = chunkOffset.getBlockX();
@ -519,7 +519,7 @@
// */
// @Override
// public void update() {
// FaweQueue packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false);
// IQueueExtent packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false);
//
// if (!packetQueue.supports(Capability.CHUNK_PACKETS)) {
// return;
@ -574,7 +574,7 @@
// files.clear();
// player.getPlayer().setPosition(origin, origin.getPitch(), origin.getYaw());
// if (update) {
// FaweQueue packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false);
// IQueueExtent packetQueue = SetQueue.IMP.getNewQueue(player.getWorld(), true, false);
//
// int OX = chunkOffset.getBlockX();
// int OZ = chunkOffset.getBlockZ();

Datei anzeigen

@ -1,6 +1,6 @@
package com.boydti.fawe.object.visitor;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.object.HasIQueueExtent;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
@ -34,8 +34,8 @@ public class AboveVisitor extends RecursiveVisitor {
this(mask, function, baseY, Integer.MAX_VALUE, null);
}
public AboveVisitor(Mask mask, RegionFunction function, int baseY, int depth, HasFaweQueue hasFaweQueue) {
super(mask, function, depth, hasFaweQueue);
public AboveVisitor(Mask mask, RegionFunction function, int baseY, int depth, HasIQueueExtent hasIQueueExtent) {
super(mask, function, depth, hasIQueueExtent);
checkNotNull(mask);
this.baseY = baseY;

Datei anzeigen

@ -1,9 +1,9 @@
package com.boydti.fawe.object.visitor;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.example.MappedIQueueExtent;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.Extent;
@ -16,23 +16,23 @@ import javax.annotation.Nullable;
public class Fast2DIterator implements Iterable<BlockVector2> {
private final Iterable<? extends BlockVector2> iterable;
private final MappedFaweQueue queue;
private final MappedIQueueExtent queue;
public Fast2DIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable EditSession extent) {
this(iter, (HasFaweQueue) extent);
this(iter, (HasIQueueExtent) extent);
}
public Fast2DIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable Extent extent) {
this(iter, (HasFaweQueue) (extent != null ? (extent instanceof HasFaweQueue ? extent : new ExtentTraverser(extent).findAndGet(HasFaweQueue.class)) : null));
this(iter, (HasIQueueExtent) (extent != null ? (extent instanceof HasIQueueExtent ? extent : new ExtentTraverser(extent).findAndGet(HasIQueueExtent.class)) : null));
}
public Fast2DIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable HasFaweQueue editSession) {
public Fast2DIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable HasIQueueExtent editSession) {
this(iter, editSession != null ? editSession.getQueue() : null);
}
public Fast2DIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable FaweQueue faweQueue) {
public Fast2DIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable IQueueExtent IQueueExtent) {
this.iterable = iter;
this.queue = faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null;
this.queue = IQueueExtent instanceof MappedIQueueExtent ? (MappedIQueueExtent) IQueueExtent : null;
}
public Iterable<? extends BlockVector2> getIterable() {

Datei anzeigen

@ -1,9 +1,9 @@
package com.boydti.fawe.object.visitor;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.example.MappedIQueueExtent;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.Extent;
@ -17,23 +17,23 @@ import javax.annotation.Nullable;
public class FastChunkIterator implements Iterable<BlockVector2> {
private final Iterable<? extends BlockVector2> iterable;
private final MappedFaweQueue queue;
private final MappedIQueueExtent queue;
public FastChunkIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable EditSession extent) {
this(iter, (HasFaweQueue) extent);
this(iter, (HasIQueueExtent) extent);
}
public FastChunkIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable Extent extent) {
this(iter, (HasFaweQueue) (extent != null ? (extent instanceof HasFaweQueue ? extent : new ExtentTraverser(extent).findAndGet(HasFaweQueue.class)) : null));
this(iter, (HasIQueueExtent) (extent != null ? (extent instanceof HasIQueueExtent ? extent : new ExtentTraverser(extent).findAndGet(HasIQueueExtent.class)) : null));
}
public FastChunkIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable HasFaweQueue editSession) {
public FastChunkIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable HasIQueueExtent editSession) {
this(iter, editSession != null ? editSession.getQueue() : null);
}
public FastChunkIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable FaweQueue faweQueue) {
public FastChunkIterator(@Nonnull Iterable<? extends BlockVector2> iter, @Nullable IQueueExtent IQueueExtent) {
this.iterable = iter;
this.queue = faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null;
this.queue = IQueueExtent instanceof MappedIQueueExtent ? (MappedIQueueExtent) IQueueExtent : null;
}
public Iterable<? extends BlockVector2> getIterable() {

Datei anzeigen

@ -1,9 +1,9 @@
package com.boydti.fawe.object.visitor;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.example.MappedIQueueExtent;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.Extent;
@ -16,23 +16,23 @@ import javax.annotation.Nullable;
public class FastIterator implements Iterable<BlockVector3> {
private final Iterable<? extends BlockVector3> iterable;
private final MappedFaweQueue queue;
private final MappedIQueueExtent queue;
public FastIterator(@Nonnull Iterable<? extends BlockVector3> iter, @Nullable EditSession extent) {
this(iter, (HasFaweQueue) extent);
this(iter, (HasIQueueExtent) extent);
}
public FastIterator(@Nonnull Iterable<? extends BlockVector3> iter, @Nullable Extent extent) {
this(iter, (HasFaweQueue) (extent != null ? (extent instanceof HasFaweQueue ? extent : new ExtentTraverser(extent).findAndGet(HasFaweQueue.class)) : null));
this(iter, (HasIQueueExtent) (extent != null ? (extent instanceof HasIQueueExtent ? extent : new ExtentTraverser(extent).findAndGet(HasIQueueExtent.class)) : null));
}
public FastIterator(@Nonnull Iterable<? extends BlockVector3> iter, @Nullable HasFaweQueue editSession) {
this(iter, (FaweQueue) (editSession != null ? editSession.getQueue() : null));
public FastIterator(@Nonnull Iterable<? extends BlockVector3> iter, @Nullable HasIQueueExtent editSession) {
this(iter, (IQueueExtent) (editSession != null ? editSession.getQueue() : null));
}
public FastIterator(@Nonnull Iterable<? extends BlockVector3> iter, @Nullable FaweQueue faweQueue) {
public FastIterator(@Nonnull Iterable<? extends BlockVector3> iter, @Nullable IQueueExtent IQueueExtent) {
this.iterable = iter;
this.queue = faweQueue != null && faweQueue instanceof MappedFaweQueue ? (MappedFaweQueue) faweQueue : null;
this.queue = IQueueExtent != null && IQueueExtent instanceof MappedIQueueExtent ? (MappedIQueueExtent) IQueueExtent : null;
}
public Iterable<? extends BlockVector3> getIterable() {

Datei anzeigen

@ -2,7 +2,7 @@ package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.util.SetQueue;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
@ -25,7 +25,7 @@ import java.util.List;
// TODO FIXME
public class FaweLocalBlockQueue extends LocalBlockQueue {
public final FaweQueue IMP;
public final IQueueExtent IMP;
private final LegacyMapper legacyMapper;
public FaweLocalBlockQueue(String world) {

Datei anzeigen

@ -1,7 +1,7 @@
package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
import com.boydti.fawe.object.io.PGZIPOutputStream;
import com.boydti.fawe.util.EditSessionBuilder;
@ -47,9 +47,9 @@ public class FaweSchematicHandler extends SchematicHandler {
queue.setTile(x, y, z, compoundTag);
return true;
}
FaweQueue faweQueue = SetQueue.IMP.getNewQueue(((FaweLocalBlockQueue) queue).IMP.getWEWorld(), true, false);
faweQueue.setTile(x, y, z, (CompoundTag) FaweCache.asTag(compoundTag));
faweQueue.flush();
IQueueExtent IQueueExtent = SetQueue.IMP.getNewQueue(((FaweLocalBlockQueue) queue).IMP.getWEWorld(), true, false);
IQueueExtent.setTile(x, y, z, (CompoundTag) FaweCache.asTag(compoundTag));
IQueueExtent.flush();
return false;
}

Datei anzeigen

@ -6,7 +6,7 @@ import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAQueue;
import com.boydti.fawe.jnbt.anvil.MCAWriter;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.util.SetQueue;
import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
@ -162,7 +162,7 @@ public class MoveTo512 /*extends Command*/ {
//
// WorldUtil.IMP.saveWorld(area.worldname);
//
// FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(area.worldname, true, false);
// IQueueExtent defaultQueue = SetQueue.IMP.getNewQueue(area.worldname, true, false);
// MCAQueue queueFrom = new MCAQueue(area.worldname, defaultQueue.getSaveFolder(), defaultQueue.hasSky());
//
// String world = args[0];

Datei anzeigen

@ -4,7 +4,7 @@ import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFile;
import com.boydti.fawe.jnbt.anvil.MCAFilter;
import com.boydti.fawe.jnbt.anvil.MCAQueue;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.SetQueue;
@ -38,7 +38,7 @@ public class PlotTrim {
private boolean deleteUnowned;
public PlotTrim(PlotPlayer player, PlotArea area, String worldName, boolean deleteUnowned) {
FaweQueue tmpQueue = SetQueue.IMP.getNewQueue(worldName, true, false);
IQueueExtent tmpQueue = SetQueue.IMP.getNewQueue(worldName, true, false);
File saveFolder = tmpQueue.getSaveFolder();
this.root = new File(saveFolder.getParentFile().getParentFile(), worldName + "-Copy" + File.separator + "region");
this.originalQueue = new MCAQueue(worldName, saveFolder, true);

Datei anzeigen

@ -307,12 +307,12 @@ public class EditSessionBuilder {
// if (queue == null) {
// boolean placeChunks = this.fastmode || this.limit.FAST_PLACEMENT;
// World unwrapped = WorldWrapper.unwrap(world);
// if (unwrapped instanceof FaweQueue) {
// queue = (FaweQueue) unwrapped;
// if (unwrapped instanceof IQueueExtent) {
// queue = (IQueueExtent) unwrapped;
// } else if (unwrapped instanceof MCAWorld) {
// queue = ((MCAWorld) unwrapped).getQueue();
// } else if (player != null && world.equals(player.getWorld())) {
// queue = player.getFaweQueue(placeChunks, autoQueue);
// queue = player.getIQueueExtent(placeChunks, autoQueue);
// } else {
// queue = SetQueue.IMP.getNewQueue(world, placeChunks, autoQueue);
// }
@ -324,7 +324,7 @@ public class EditSessionBuilder {
// // If fast placement is disabled, it's slower to perform a copy on each chunk
// && this.limit.FAST_PLACEMENT
// // If the specific queue doesn't support it
// && queue.supports(FaweQueue.Capability.CHANGE_TASKS)
// && queue.supports(IQueueExtent.Capability.CHANGE_TASKS)
// // If the edit uses items from the inventory we can't use a delayed task
// && this.blockBag == null;
// }

Datei anzeigen

@ -2,7 +2,7 @@ package com.boydti.fawe.util;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.RunnableVal;
import org.jetbrains.annotations.NotNull;
@ -138,7 +138,7 @@ public abstract class TaskManager {
* @param queue
* @param run
*/
public void runUnsafe(FaweQueue queue, Runnable run) {
public void runUnsafe(IQueueExtent queue, Runnable run) {
queue.startSet(true);
try {
run.run();

Datei anzeigen

@ -1,7 +1,7 @@
package com.boydti.fawe.util.task;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.Metadatable;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.util.SetQueue;
@ -322,7 +322,7 @@ public class TaskBuilder extends Metadatable {
}
}
private FaweQueue queue;
private IQueueExtent queue;
private long last;
private long start;
private Object asyncWaitLock = new Object();
@ -430,7 +430,7 @@ public class TaskBuilder extends Metadatable {
public static abstract class SplitTask extends RunnableTask {
private final long allocation;
private final FaweQueue queue;
private final IQueueExtent queue;
private long last;
private long start;
private Object asyncWaitLock = new Object();

Datei anzeigen

@ -183,7 +183,7 @@ public class HistoryCommands extends MethodCommands {
// TODO mask the regions bot / top to the bottom and top coord in the allowedRegions
// TODO: then mask the edit to the bot / top
// if (allowedRegions.length != 1 || !allowedRegions[0].isGlobal()) {
// finalQueue = new MaskedFaweQueue(SetQueue.IMP.getNewQueue(fp.getWorld(), true, false), allowedRegions);
// finalQueue = new MaskedIQueueExtent(SetQueue.IMP.getNewQueue(fp.getWorld(), true, false), allowedRegions);
// } else {
// finalQueue = SetQueue.IMP.getNewQueue(fp.getWorld(), true, false);
// }

Datei anzeigen

@ -35,10 +35,10 @@ import com.boydti.fawe.beta.filters.SetFilter;
import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.beta.filters.DistrFilter;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.example.NMSMappedIQueueExtent;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.visitor.Fast2DIterator;
import com.boydti.fawe.util.MathMan;
@ -166,7 +166,7 @@ public class RegionCommands {
final int cz = loc.getBlockZ() >> 4;
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
}
int count = FaweAPI.fixLighting(player.getWorld(), selection,null, FaweQueue.RelightMode.ALL);
int count = FaweAPI.fixLighting(player.getWorld(), selection,null, IQueueExtent.RelightMode.ALL);
BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count);
}
@ -178,7 +178,7 @@ public class RegionCommands {
public void getlighting(Player player) throws WorldEditException {
FawePlayer fp = FawePlayer.wrap(player);
final Location loc = player.getLocation();
FaweQueue queue = fp.getFaweQueue(false);
IQueueExtent queue = fp.getIQueueExtent(false);
fp.sendMessage("Light: " + queue.getEmmittedLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()) + " | " + queue.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
@ -195,7 +195,7 @@ public class RegionCommands {
final int cz = player.getLocation().getBlockZ() >> 4;
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
}
int count = FaweAPI.fixLighting(player.getWorld(), selection, null, FaweQueue.RelightMode.NONE);
int count = FaweAPI.fixLighting(player.getWorld(), selection, null, IQueueExtent.RelightMode.NONE);
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
}
@ -225,7 +225,7 @@ public class RegionCommands {
@CommandPermissions("worldedit.light.set")
public void setlighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
FawePlayer fp = FawePlayer.wrap(player);
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false);
final NMSMappedIQueueExtent queue = (NMSMappedIQueueExtent) fp.getIQueueExtent(false);
for (BlockVector3 pt : region) {
queue.setBlockLight(pt.getX(), pt.getY(), pt.getZ(), value);
}
@ -244,7 +244,7 @@ public class RegionCommands {
@CommandPermissions("worldedit.light.set")
public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
FawePlayer fp = FawePlayer.wrap(player);
final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false);
final NMSMappedIQueueExtent queue = (NMSMappedIQueueExtent) fp.getIQueueExtent(false);
for (BlockVector3 pt : region) {
queue.setSkyLight(pt.getX(), pt.getY(), pt.getZ(), value);
}

Datei anzeigen

@ -21,7 +21,7 @@ package com.sk89q.worldedit.command.composition;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.extent.FaweRegionExtent;
@ -111,7 +111,7 @@ public class SelectionCommand extends SimpleCommand<Operation> {
Pattern pattern = (Pattern) field.get(replace);
if (pattern instanceof BlockStateHolder) {
BlockStateHolder block = ((BlockStateHolder) pattern);
final FaweQueue queue = editSession.getQueue();
final IQueueExtent queue = editSession.getQueue();
final int minY = cuboid.getMinimumY();
final int maxY = cuboid.getMaximumY();

Datei anzeigen

@ -19,11 +19,6 @@
package com.sk89q.worldedit.extent;
import com.boydti.fawe.jnbt.anvil.generator.CavesGen;
import com.boydti.fawe.jnbt.anvil.generator.GenBase;
import com.boydti.fawe.jnbt.anvil.generator.OreGen;
import com.boydti.fawe.jnbt.anvil.generator.Resource;
import com.boydti.fawe.jnbt.anvil.generator.SchemGen;
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.worldedit.MaxChangedBlocksException;
@ -33,6 +28,11 @@ import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.generator.CavesGen;
import com.sk89q.worldedit.function.generator.GenBase;
import com.sk89q.worldedit.function.generator.OreGen;
import com.sk89q.worldedit.function.generator.Resource;
import com.sk89q.worldedit.function.generator.SchemGen;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
@ -535,7 +535,7 @@ public interface Extent extends InputExtent, OutputExtent {
return setBlocks(region, (BlockStateHolder) pattern);
}
BlockReplace replace = new BlockReplace(this, pattern);
RegionVisitor visitor = new RegionVisitor(region, replace, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null);
RegionVisitor visitor = new RegionVisitor(region, replace, queue instanceof MappedIQueueExtent ? (MappedIQueueExtent) queue : null);
Operations.completeBlindly(visitor);
return this.changes = visitor.getAffected();
}

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.jnbt.anvil.generator;
package com.sk89q.worldedit.function.generator;
import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.WorldEditException;

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.jnbt.anvil.generator;
package com.sk89q.worldedit.function.generator;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.jnbt.anvil.generator;
package com.sk89q.worldedit.function.generator;
import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.WorldEditException;

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.jnbt.anvil.generator;
package com.sk89q.worldedit.function.generator;
import com.sk89q.worldedit.WorldEditException;

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.jnbt.anvil.generator;
package com.sk89q.worldedit.function.generator;
import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.math.MutableBlockVector3;

Datei anzeigen

@ -22,8 +22,8 @@ package com.sk89q.worldedit.function.operation;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.example.MappedIQueueExtent;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.extent.BlockTranslateExtent;
import com.boydti.fawe.object.extent.PositionTransformExtent;
import com.boydti.fawe.object.function.block.BiomeCopy;
@ -277,7 +277,7 @@ public class ForwardExtentCopy implements Operation {
if (currentTransform == null) {
currentTransform = transform;
}
FaweQueue queue;
IQueueExtent queue;
if (source instanceof EditSession) {
queue = ((EditSession) source).getQueue();
} else if (destination instanceof EditSession) {
@ -368,7 +368,7 @@ public class ForwardExtentCopy implements Operation {
if (copyingBiomes && (!(source instanceof BlockArrayClipboard) || ((BlockArrayClipboard) source).IMP.hasBiomes())) {
copy = CombinedRegionFunction.combine(copy, new BiomeCopy(source, finalDest));
}
blockCopy = new RegionVisitor(region, copy, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null);
blockCopy = new RegionVisitor(region, copy, queue instanceof MappedIQueueExtent ? (MappedIQueueExtent) queue : null);
}
List<? extends Entity> entities;

Datei anzeigen

@ -22,7 +22,7 @@ package com.sk89q.worldedit.function.visitor;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.example.MappedIQueueExtent;
import com.boydti.fawe.object.collection.BlockVectorSet;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction;

Datei anzeigen

@ -20,9 +20,9 @@
package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.example.MappedIQueueExtent;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.HasIQueueExtent;
import com.boydti.fawe.object.visitor.Fast2DIterator;
import static com.google.common.base.Preconditions.checkNotNull;
@ -41,7 +41,7 @@ import java.util.List;
public class FlatRegionVisitor implements Operation {
private final FlatRegionFunction function;
private MappedFaweQueue queue;
private MappedIQueueExtent queue;
private int affected = 0;
private final Iterable<BlockVector2> iterator;
@ -59,13 +59,13 @@ public class FlatRegionVisitor implements Operation {
this.iterator = flatRegion.asFlatRegion();
}
public FlatRegionVisitor(final FlatRegion flatRegion, final FlatRegionFunction function, HasFaweQueue hasFaweQueue) {
public FlatRegionVisitor(final FlatRegion flatRegion, final FlatRegionFunction function, HasIQueueExtent hasIQueueExtent) {
checkNotNull(flatRegion);
checkNotNull(function);
this.function = function;
this.iterator = flatRegion.asFlatRegion();
FaweQueue queue = hasFaweQueue.getQueue();
this.queue = (MappedFaweQueue) (queue instanceof MappedFaweQueue ? queue : null);
IQueueExtent queue = hasIQueueExtent.getQueue();
this.queue = (MappedIQueueExtent) (queue instanceof MappedIQueueExtent ? queue : null);
}
/**

Datei anzeigen

@ -19,7 +19,7 @@
package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.object.HasIQueueExtent;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask;
@ -42,8 +42,8 @@ public class NonRisingVisitor extends RecursiveVisitor {
this(mask, function, Integer.MAX_VALUE, null);
}
public NonRisingVisitor(Mask mask, RegionFunction function, int depth, HasFaweQueue hasFaweQueue) {
super(mask, function, depth, hasFaweQueue);
public NonRisingVisitor(Mask mask, RegionFunction function, int depth, HasIQueueExtent hasIQueueExtent) {
super(mask, function, depth, hasIQueueExtent);
setDirections(
BlockVector3.UNIT_X,
BlockVector3.UNIT_MINUS_X,