mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Merge branch 'breaking'
This commit is contained in:
@ -44,8 +44,10 @@ processResources {
|
||||
from('src/main/resources') {
|
||||
include 'fawe.properties'
|
||||
expand(
|
||||
internalVersion: "${project.parent.version}",
|
||||
version: "${project.parent.version}",
|
||||
name: project.parent.name,
|
||||
commit: "${git.head().abbreviatedId}",
|
||||
date: "${git.head().getDate().format("yy.MM.dd")}",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,7 @@ import com.sk89q.worldedit.session.request.Request;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.management.InstanceAlreadyExistsException;
|
||||
import javax.management.NotificationEmitter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.*;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryMXBean;
|
||||
import java.lang.management.MemoryPoolMXBean;
|
||||
@ -81,7 +78,6 @@ public class Fawe {
|
||||
private final FaweTimer timer;
|
||||
private FaweVersion version;
|
||||
private VisualQueue visualQueue;
|
||||
private Updater updater;
|
||||
private TextureUtil textures;
|
||||
private DefaultTransformParser transformParser;
|
||||
private ChatManager chatManager = new PlainChatManager();
|
||||
@ -198,26 +194,11 @@ public class Fawe {
|
||||
}, 0);
|
||||
|
||||
TaskManager.IMP.repeat(timer, 1);
|
||||
|
||||
if (!Settings.IMP.UPDATE.equalsIgnoreCase("false")) {
|
||||
// Delayed updating
|
||||
updater = new Updater();
|
||||
TaskManager.IMP.async(this::update);
|
||||
TaskManager.IMP.repeatAsync(this::update, 36000);
|
||||
}
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
private boolean update() {
|
||||
if (updater != null) {
|
||||
updater.getUpdate(IMP.getPlatform(), getVersion());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CUI getCUI(Actor actor) {
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(actor);
|
||||
CUI cui = fp.getMeta("CUI");
|
||||
@ -255,16 +236,6 @@ public class Fawe {
|
||||
return transformParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* The FAWE updater class
|
||||
* - Use to get basic update information (changelog/version etc)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Updater getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
|
||||
TextureUtil tu = getTextureUtil();
|
||||
try {
|
||||
@ -342,15 +313,17 @@ public class Fawe {
|
||||
// Setting up config.yml
|
||||
File file = new File(this.IMP.getDirectory(), "config.yml");
|
||||
Settings.IMP.PLATFORM = IMP.getPlatform().replace("\"", "");
|
||||
try {
|
||||
InputStream stream = getClass().getResourceAsStream("/fawe.properties");
|
||||
java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
||||
String versionString = scanner.next().trim();
|
||||
scanner.close();
|
||||
this.version = new FaweVersion(versionString);
|
||||
try (InputStream stream = getClass().getResourceAsStream("/fawe.properties");
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(stream))) {
|
||||
// java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
||||
String versionString = br.readLine();
|
||||
String commitString = br.readLine();
|
||||
String dateString = br.readLine();
|
||||
// scanner.close();
|
||||
this.version = FaweVersion.tryParse(versionString, commitString, dateString);
|
||||
Settings.IMP.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||
Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build;
|
||||
Settings.IMP.COMMIT = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash);
|
||||
Settings.IMP.BUILD = "https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/" + version.build;
|
||||
Settings.IMP.COMMIT = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/commit/" + Integer.toHexString(version.hash);
|
||||
} catch (Throwable ignore) {}
|
||||
try {
|
||||
Settings.IMP.reload(file);
|
||||
|
@ -1,79 +1,43 @@
|
||||
package com.boydti.fawe;
|
||||
|
||||
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
public class FaweCache {
|
||||
/**
|
||||
* [ y | z | x ] => index
|
||||
*/
|
||||
public final static short[][][] CACHE_I = new short[256][16][16];
|
||||
/**
|
||||
* [ y | z | x ] => index
|
||||
*/
|
||||
public final static short[][][] CACHE_J = new short[256][16][16];
|
||||
|
||||
/**
|
||||
* [ i | j ] => x
|
||||
*/
|
||||
public final static byte[][] CACHE_X = new byte[16][];
|
||||
/**
|
||||
* [ i | j ] => y
|
||||
*/
|
||||
public final static short[][] CACHE_Y = new short[16][4096];
|
||||
/**
|
||||
* [ i | j ] => z
|
||||
*/
|
||||
public final static byte[][] CACHE_Z = new byte[16][];
|
||||
|
||||
/**
|
||||
* Immutable biome cache
|
||||
*/
|
||||
public final static BaseBiome[] CACHE_BIOME = new BaseBiome[256];
|
||||
|
||||
public static final BaseBiome getBiome(int id) {
|
||||
return CACHE_BIOME[id];
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
CACHE_BIOME[i] = new BaseBiome(i) {
|
||||
@Override
|
||||
public void setId(int id) {
|
||||
throw new IllegalStateException("Cannot set id");
|
||||
}
|
||||
};
|
||||
public static final IterableThreadLocal<int[]> BLOCK_TO_PALETTE = new IterableThreadLocal<int[]>() {
|
||||
@Override
|
||||
public int[] init() {
|
||||
int[] result = new int[BlockTypes.states.length];
|
||||
Arrays.fill(result, Integer.MAX_VALUE);
|
||||
return result;
|
||||
}
|
||||
CACHE_X[0] = new byte[4096];
|
||||
CACHE_Z[0] = new byte[4096];
|
||||
for (int y = 0; y < 16; y++) {
|
||||
CACHE_X[y] = CACHE_X[0];
|
||||
CACHE_Z[y] = CACHE_Z[0];
|
||||
};
|
||||
|
||||
public static final IterableThreadLocal<int[]> PALETTE_TO_BLOCK = new IterableThreadLocal<int[]>() {
|
||||
@Override
|
||||
public int[] init() {
|
||||
return new int[Character.MAX_VALUE];
|
||||
}
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
final short j = (short) (((y & 0xF) << 8) | (z << 4) | x);
|
||||
CACHE_X[0][j] = (byte) x;
|
||||
CACHE_Z[0][j] = (byte) z;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final IterableThreadLocal<long[]> BLOCK_STATES = new IterableThreadLocal<long[]>() {
|
||||
@Override
|
||||
public long[] init() {
|
||||
return new long[2048];
|
||||
}
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < 256; y++) {
|
||||
final short i = (short) (y >> 4);
|
||||
final short j = (short) (((y & 0xF) << 8) | (z << 4) | x);
|
||||
CACHE_I[y][z][x] = i;
|
||||
CACHE_J[y][z][x] = j;
|
||||
CACHE_Y[i][j] = (short) y;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final IterableThreadLocal<int[]> SECTION_BLOCKS = new IterableThreadLocal<int[]>() {
|
||||
@Override
|
||||
public int[] init() {
|
||||
return new int[4096];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static Map<String, Object> asMap(Object... pairs) {
|
||||
HashMap<String, Object> map = new HashMap<>(pairs.length >> 1);
|
||||
|
@ -1,24 +1,33 @@
|
||||
package com.boydti.fawe;
|
||||
|
||||
public class FaweVersion {
|
||||
public final int year, month, day, hash, build, major, minor, patch;
|
||||
public final int year, month, day, hash, build;
|
||||
|
||||
public FaweVersion(String version) {
|
||||
String[] split = version.substring(version.indexOf('=') + 1).split("-");
|
||||
if (split[0].equals("unknown")) {
|
||||
this.year = month = day = hash = build = major = minor = patch = 0;
|
||||
return;
|
||||
}
|
||||
String[] date = split[0].split("\\.");
|
||||
this.year = Integer.parseInt(date[0]);
|
||||
this.month = Integer.parseInt(date[1]);
|
||||
this.day = Integer.parseInt(date[2]);
|
||||
this.hash = Integer.parseInt(split[1], 16);
|
||||
public FaweVersion(int year, int month, int day, int hash, int build) {
|
||||
this.year = year;
|
||||
this.month = month;
|
||||
this.day = day;
|
||||
this.hash = hash;
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
public FaweVersion(String version, String commit, String date) {
|
||||
String[] split = version.substring(version.indexOf('=') + 1).split("\\.");
|
||||
this.build = Integer.parseInt(split[2]);
|
||||
String[] semver = split[3].split("\\.");
|
||||
this.major = Integer.parseInt(semver[0]);
|
||||
this.minor = Integer.parseInt(semver[1]);
|
||||
this.patch = Integer.parseInt(semver[2]);
|
||||
this.hash = Integer.parseInt(commit.substring(commit.indexOf('=') + 1), 16);
|
||||
String[] split1 = date.substring(date.indexOf('=') + 1).split("\\.");
|
||||
this.year = Integer.parseInt(split1[0]);
|
||||
this.month = Integer.parseInt(split1[1]);
|
||||
this.day = Integer.parseInt(split1[2]);
|
||||
}
|
||||
|
||||
public static FaweVersion tryParse(String version, String commit, String date) {
|
||||
try {
|
||||
return new FaweVersion(version, commit, date);
|
||||
} catch (Exception ignore) {
|
||||
ignore.printStackTrace();
|
||||
return new FaweVersion(0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,6 +36,6 @@ public class FaweVersion {
|
||||
}
|
||||
|
||||
public boolean isNewer(FaweVersion other) {
|
||||
return other.build < this.build && (this.major > other.major || (this.major == other.major && this.minor > other.minor) || (this.major == other.major && this.minor == other.minor && this.patch > other.patch));
|
||||
return other.build < this.build;
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
@ -291,7 +291,7 @@ public class AnvilCommands {
|
||||
desc = "Delete chunks matching a specific biome"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.trimallair")
|
||||
public void deleteBiome(Player player, String folder, BaseBiome biome, @Switch('u') boolean unsafe) {
|
||||
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch('u') boolean unsafe) {
|
||||
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
|
||||
DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
|
||||
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
@ -308,18 +308,6 @@ public class AnvilCommands {
|
||||
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = {"debugfixair", },
|
||||
desc = "debug - do not use"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.debugfixair")
|
||||
public void debugfixair(Player player, String folder) throws WorldEditException {
|
||||
DebugFixAir filter = new DebugFixAir();
|
||||
DebugFixAir result = runWithWorld(player, folder, filter, true, true);
|
||||
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"debugfixroads", },
|
||||
desc = "debug - do not use"
|
||||
|
@ -1,43 +1,40 @@
|
||||
package com.boydti.fawe.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Commands;
|
||||
import com.boydti.fawe.jnbt.anvil.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.object.pattern.PatternExtent;
|
||||
import com.boydti.fawe.util.*;
|
||||
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;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.Auto;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
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.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.EmptyClipboardException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.MethodCommands;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
@ -47,15 +44,18 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
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 com.sk89q.worldedit.util.command.binding.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.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -68,8 +68,11 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.boydti.fawe.util.image.ImageUtil.load;
|
||||
|
||||
@Command(aliases = {"/cfi"}, desc = "Create a world from images: [More Info](https://git.io/v5iDy)")
|
||||
@ -87,8 +90,11 @@ public class CFICommands extends MethodCommands {
|
||||
this.dispathcer= dispatcher;
|
||||
}
|
||||
|
||||
private File getFolder(String worldName) {
|
||||
return new File(PlotSquared.imp().getWorldContainer(), worldName + File.separator + "region");
|
||||
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);
|
||||
return new File(queue.getSaveFolder().getParentFile().getParentFile(), worldName + File.separator + "region");
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -174,23 +180,6 @@ public class CFICommands extends MethodCommands {
|
||||
fp.sendMessage(BBC.getPrefix() + "Cancelled!");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start, com.github.intellectualsites.plotsquared.plot.object.RunnableVal<Plot> whenDone) {
|
||||
final Plot plot = area.getNextFreePlot(player, start);
|
||||
if (plot == null) {
|
||||
whenDone.run(null);
|
||||
return;
|
||||
}
|
||||
whenDone.value = plot;
|
||||
plot.owner = player.getUUID();
|
||||
DBFunc.createPlotSafe(plot, whenDone, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
autoClaimFromDatabase(player, area, plot.getId(), whenDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"done", "create"},
|
||||
usage = "",
|
||||
@ -199,59 +188,54 @@ public class CFICommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void done(FawePlayer fp) throws ParameterException, IOException {
|
||||
CFISettings settings = assertSettings(fp);
|
||||
HeightMapMCAGenerator generator = settings.getGenerator();
|
||||
|
||||
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager;
|
||||
SinglePlotArea area = sManager.getArea();
|
||||
PlotPlayer player = PlotPlayer.wrap(fp.parent);
|
||||
|
||||
fp.sendMessage(BBC.getPrefix() + "Claiming world");
|
||||
Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot o) {
|
||||
int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(area.worldname);
|
||||
int diff = player.getAllowedPlots() - currentPlots;
|
||||
if (diff < 1) {
|
||||
Captions.CANT_CLAIM_MORE_PLOTS_NUM.send(player, -diff);
|
||||
return;
|
||||
Function<File, Boolean> function = new Function<File, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(File folder) {
|
||||
if (folder != null) {
|
||||
try {
|
||||
generator.setFolder(folder);
|
||||
fp.sendMessage(BBC.getPrefix() + "Generating " + folder);
|
||||
generator.generate();
|
||||
generator.setPacketViewer(null);
|
||||
generator.setImageViewer(null);
|
||||
settings.remove();
|
||||
fp.sendMessage(BBC.getPrefix() + "Done!");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
fp.sendMessage("Unable to generate world... (see console)?");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
if (area.getMeta("lastPlot") == null) {
|
||||
area.setMeta("lastPlot", new PlotId(0, 0));
|
||||
}
|
||||
PlotId lastId = (PlotId) area.getMeta("lastPlot");
|
||||
while (true) {
|
||||
lastId = Auto.getNextPlotId(lastId, 1);
|
||||
if (area.canClaim(player, lastId, lastId)) {
|
||||
break;
|
||||
try {
|
||||
new PlotLoader().load(fp, settings, function);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
function.apply(generator.getFolder().getParentFile());
|
||||
}
|
||||
|
||||
File folder = generator.getFolder();
|
||||
if (folder != null) {
|
||||
World world = FaweAPI.getWorld(folder.getName());
|
||||
if (world != null) {
|
||||
if (fp.getWorld() != world) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
Location spawn = new Location(world, world.getSpawnPosition().toVector3());
|
||||
fp.getPlayer().setPosition(spawn);
|
||||
}
|
||||
}
|
||||
area.setMeta("lastPlot", lastId);
|
||||
this.value = area.getPlot(lastId);
|
||||
this.value.setOwner(player.getUUID());
|
||||
});
|
||||
}
|
||||
});
|
||||
if (plot == null) return;
|
||||
|
||||
File folder = getFolder(plot.getWorldName());
|
||||
HeightMapMCAGenerator generator = settings.getGenerator();
|
||||
generator.setFolder(folder);
|
||||
|
||||
fp.sendMessage(BBC.getPrefix() + "Generating");
|
||||
generator.generate();
|
||||
generator.setPacketViewer(null);
|
||||
generator.setImageViewer(null);
|
||||
settings.remove();
|
||||
fp.sendMessage(BBC.getPrefix() + "Done!");
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
plot.teleportPlayer(player);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fp.sendMessage(BBC.getPrefix() + "Must have the `worlds` component enabled in the PlotSquared config.yml");
|
||||
} else {
|
||||
fp.sendMessage("Unable to import world (" + folder.getName() + ") please do so manually");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,11 +511,11 @@ public class CFICommands extends MethodCommands {
|
||||
" - If a mask is used, the biome will be set anywhere the mask applies"
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void biome(FawePlayer fp, BaseBiome biome, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
if (image != null) gen.setBiome(load(image), (byte) biome.getId(), !disableWhiteOnly);
|
||||
else if (mask != null) gen.setBiome(mask, (byte) biome.getId());
|
||||
else gen.setBiome((byte) biome.getId());
|
||||
if (image != null) gen.setBiome(load(image), biome, !disableWhiteOnly);
|
||||
else if (mask != null) gen.setBiome(mask, biome);
|
||||
else gen.setBiome(biome);
|
||||
msg("Set biome!").send(fp);
|
||||
assertSettings(fp).resetComponent();
|
||||
component(fp);
|
||||
|
@ -0,0 +1,96 @@
|
||||
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;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.Auto;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
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 {
|
||||
@Deprecated
|
||||
public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start, com.github.intellectualsites.plotsquared.plot.object.RunnableVal<Plot> whenDone) {
|
||||
final Plot plot = area.getNextFreePlot(player, start);
|
||||
if (plot == null) {
|
||||
whenDone.run(null);
|
||||
return;
|
||||
}
|
||||
whenDone.value = plot;
|
||||
plot.owner = player.getUUID();
|
||||
DBFunc.createPlotSafe(plot, whenDone, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
autoClaimFromDatabase(player, area, plot.getId(), whenDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void load(FawePlayer fp, CFICommands.CFISettings settings, Function<File, Boolean> createTask) throws IOException {
|
||||
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager;
|
||||
SinglePlotArea area = sManager.getArea();
|
||||
PlotPlayer player = PlotPlayer.wrap(fp.parent);
|
||||
|
||||
fp.sendMessage(BBC.getPrefix() + "Claiming world");
|
||||
Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot o) {
|
||||
int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(area.worldname);
|
||||
int diff = player.getAllowedPlots() - currentPlots;
|
||||
if (diff < 1) {
|
||||
Captions.CANT_CLAIM_MORE_PLOTS_NUM.send(player, -diff);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area.getMeta("lastPlot") == null) {
|
||||
area.setMeta("lastPlot", new PlotId(0, 0));
|
||||
}
|
||||
PlotId lastId = (PlotId) area.getMeta("lastPlot");
|
||||
while (true) {
|
||||
lastId = Auto.getNextPlotId(lastId, 1);
|
||||
if (area.canClaim(player, lastId, lastId)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
area.setMeta("lastPlot", lastId);
|
||||
this.value = area.getPlot(lastId);
|
||||
this.value.setOwner(player.getUUID());
|
||||
}
|
||||
});
|
||||
if (plot != null) {
|
||||
|
||||
File folder = CFICommands.getFolder(plot.getWorldName());
|
||||
Boolean result = createTask.apply(folder);
|
||||
if (result == Boolean.TRUE) {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
plot.teleportPlayer(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
createTask.apply(null);
|
||||
}
|
||||
}
|
@ -79,16 +79,12 @@ public class Rollback extends FaweCommand {
|
||||
long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000;
|
||||
total += edit.getBDFile().length();
|
||||
int size = summary.getSize();
|
||||
Map<Integer, Double> percents = summary.getPercents();
|
||||
Map<BlockState, Double> percents = summary.getPercents();
|
||||
StringBuilder percentString = new StringBuilder();
|
||||
String prefix = "";
|
||||
for (Map.Entry<Integer, Double> entry : percents.entrySet()) {
|
||||
int id = entry.getKey();
|
||||
BlockStateHolder state = null;
|
||||
try {
|
||||
state = BlockState.getFromInternalId(id);
|
||||
} catch (Throwable ignore) {};
|
||||
String itemName = state == null ? "#" + id : state.getAsString();
|
||||
for (Map.Entry<BlockState, Double> entry : percents.entrySet()) {
|
||||
BlockState state = entry.getKey();
|
||||
String itemName = "#" + state;
|
||||
percentString.append(prefix).append(entry.getValue()).append("% ").append(itemName);
|
||||
prefix = ", ";
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -52,6 +53,14 @@ public class SuggestInputParseException extends InputParseException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static SuggestInputParseException of(String input, List<Object> values) {
|
||||
throw new SuggestInputParseException("No value: " + input, input, () ->
|
||||
values.stream()
|
||||
.map(v -> v.toString())
|
||||
.filter(v -> v.startsWith(input))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Throwable getCause() {
|
||||
return cause.getCause();
|
||||
|
@ -72,7 +72,6 @@ public enum BBC {
|
||||
|
||||
COMMAND_COPY("%s0 blocks were copied.", "WorldEdit.Copy"),
|
||||
|
||||
|
||||
COMMAND_CUT_SLOW("%s0 blocks were cut.", "WorldEdit.Cut"),
|
||||
COMMAND_CUT_LAZY("%s0 blocks will be removed on paste", "WorldEdit.Cut"),
|
||||
|
||||
@ -93,6 +92,7 @@ public enum BBC {
|
||||
COMMAND_HISTORY_OTHER_ERROR("Unable to find session for %s0.", "WorldEdit.History"),
|
||||
COMMAND_REDO_SUCCESS("Redo successful%s0.", "WorldEdit.History"),
|
||||
COMMAND_UNDO_ERROR("Nothing left to undo. (See also `/inspect` and `/frb`)", "WorldEdit.History"),
|
||||
COMMAND_UNDO_DISABLED("Undo disabled, use: //fast", "WorldEdit.History"),
|
||||
COMMAND_UNDO_SUCCESS("Undo successful%s0.", "WorldEdit.History"),
|
||||
|
||||
OPERATION("Operation queued (%s0)", "WorldEdit.Operation"),
|
||||
@ -155,6 +155,7 @@ public enum BBC {
|
||||
TOOL_NONE("Tool unbound from your current item.", "WorldEdit.Tool"),
|
||||
TOOL_INFO("Info tool bound to %s0.", "WorldEdit.Tool"),
|
||||
TOOL_TREE("Tree tool bound to %s0.", "WorldEdit.Tool"),
|
||||
TOOL_TREE_ERROR_BLOCK("A tree can't go here", "WorldEdit.Tool"),
|
||||
TOOL_TREE_ERROR("Tree type %s0 is unknown.", "WorldEdit.Tool"),
|
||||
TOOL_REPL("Block replacer tool bound to %s0.", "WorldEdit.Tool"),
|
||||
TOOL_CYCLER("Block data cycler tool bound to %s0.", "WorldEdit.Tool"),
|
||||
@ -162,6 +163,8 @@ public enum BBC {
|
||||
TOOL_RANGE_ERROR("Maximum range: %s0.", "WorldEdit.Tool"),
|
||||
TOOL_RADIUS_ERROR("Maximum allowed brush radius: %s0.", "WorldEdit.Tool"),
|
||||
TOOL_DELTREE("Floating tree remover tool bound to %s0.", "WorldEdit.Tool"),
|
||||
TOOL_DELTREE_ERROR("That's not a tree", "WorldEdit.Tool"),
|
||||
TOOL_DELTREE_FLOATING_ERROR("That's not a floating tree", "WorldEdit.Tool"),
|
||||
TOOL_FARWAND("Far wand tool bound to %s0.", "WorldEdit.Tool"),
|
||||
TOOL_LRBUILD_BOUND("Long-range building tool bound to %s0.", "WorldEdit.Tool"),
|
||||
TOOL_LRBUILD_INFO("Left-click set to %s0; right-click set to %s1.", "WorldEdit.Tool"),
|
||||
@ -174,6 +177,14 @@ public enum BBC {
|
||||
SNAPSHOT_NEWEST("Now using newest snapshot.", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_LIST_HEADER("Snapshots for world (%s0):", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_LIST_FOOTER("Use /snap use [snapshot] or /snap use latest.", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_NOT_CONFIGURED("Snapshot/backup restore is not configured.", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_NOT_AVAILABLE("No snapshots are available. See console for details.", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_NOT_FOUND_WORLD("No snapshots were found for this world.", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_NOT_FOUND("No snapshots were found.", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_INVALID_INDEX("Invalid index, must be equal or higher then 1.", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_ERROR_DATE("Could not detect the date inputted.", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_ERROR_RESTORE("Errors prevented any blocks from being restored.", "WorldEdit.Snapshot"),
|
||||
SNAPSHOT_ERROR_RESTORE_CHUNKS("No chunks could be loaded. (Bad archive?)", "WorldEdit.Snapshot"),
|
||||
|
||||
BIOME_LIST_HEADER("Biomes (page %s0/%s1):", "WorldEdit.Biome"),
|
||||
BIOME_CHANGED("Biomes were changed in %s0 columns.", "WorldEdit.Biome"),
|
||||
@ -225,6 +236,10 @@ public enum BBC {
|
||||
TIMEZONE_SET("Timezone set for this session to: %s0", "WorldEdit.Timezone"),
|
||||
TIMEZONE_DISPLAY("The current time in that timezone is: %s0", "WorldEdit.Timezone"),
|
||||
|
||||
BLOCK_CYCLER_CANNOT_CYCLE("That block's data cannot be cycled!", "WorldEdit.Cycler"),
|
||||
BLOCK_CYCLER_LIMIT("Max blocks change limit reached.", "WorldEdit.Cycler"),
|
||||
BLOCK_CYCLER_NO_PERM("&cYou are not permitted to cycle the data value of that block.", "WorldEdit.Cycler"),
|
||||
|
||||
COMMAND_INVALID_SYNTAX("The command was not used properly (no more help available).", "WorldEdit.Command"),
|
||||
|
||||
COMMAND_CLARIFYING_BRACKET("&7Added clarifying bracket for &c%s0", "WorldEdit.Help"),
|
||||
@ -243,6 +258,7 @@ public enum BBC {
|
||||
|
||||
COMMAND_SYNTAX("&cUsage: &7%s0", "Error"),
|
||||
NO_PERM("&cYou are lacking the permission node: %s0", "Error"),
|
||||
BLOCK_NOT_ALLOWED("You are not allowed to use", "Error"),
|
||||
SETTING_DISABLE("&cLacking setting: %s0", "Error"),
|
||||
BRUSH_NOT_FOUND("&cAvailable brushes: %s0", "Error"),
|
||||
BRUSH_INCOMPATIBLE("&cBrush not compatible with this version", "Error"),
|
||||
@ -298,6 +314,10 @@ public enum BBC {
|
||||
SEL_LIST("For a list of selection types use:&c //sel list", "Selection"),
|
||||
SEL_MODES("Select one of the modes below:", "Selection"),
|
||||
|
||||
SCRIPTING_NO_PERM("&cYou do not have permission to execute this craft script", "WorldEdit.Scripting"),
|
||||
SCRIPTING_CS("Use /cs with a script name first.", "WorldEdit.Scripting"),
|
||||
SCRIPTING_ERROR("An error occured while executing a craft script", "WorldEdit.Scripting"),
|
||||
|
||||
TIP_SEL_LIST("Tip: See the different selection modes with &c//sel list", "Tips"),
|
||||
TIP_SELECT_CONNECTED("Tip: Select all connected blocks with //sel fuzzy", "Tips"),
|
||||
TIP_SET_POS1("Tip: Use pos1 as a pattern with &c//set pos1", "Tips"),
|
||||
|
@ -9,9 +9,12 @@ public class Settings extends Config {
|
||||
@Ignore
|
||||
public static final Settings IMP = new Settings();
|
||||
|
||||
@Ignore
|
||||
public boolean PROTOCOL_SUPPORT_FIX = false;
|
||||
|
||||
@Comment("These first 6 aren't configurable") // This is a comment
|
||||
@Final // Indicates that this value isn't configurable
|
||||
public String ISSUES = "https://github.com/boy0001/FastAsyncWorldedit/issues";
|
||||
public String ISSUES = "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues";
|
||||
@Final
|
||||
public String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/";
|
||||
@Final
|
||||
@ -24,14 +27,8 @@ public class Settings extends Config {
|
||||
public String PLATFORM; // These values are set from FAWE before loading
|
||||
|
||||
@Comment({"Options: cn, de, es, fr, it, nl, ru, tr",
|
||||
"Create a PR to contribute a translation: https://github.com/boy0001/FastAsyncWorldedit/new/master/core/src/main/resources",})
|
||||
"Create a PR to contribute a translation: https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/tree/master/worldedit-core/src/main/resources",})
|
||||
public String LANGUAGE = "";
|
||||
@Comment({"Enable or disable automatic updates",
|
||||
" - true = update automatically in the background",
|
||||
" - confirm = prompt an admin to confirm each update",
|
||||
" - false = do not update the plugin"
|
||||
})
|
||||
public String UPDATE = "false";
|
||||
@Comment("Send anonymous usage statistics")
|
||||
public boolean METRICS = true;
|
||||
@Comment({
|
||||
@ -69,6 +66,13 @@ public class Settings extends Config {
|
||||
public PATHS PATHS;
|
||||
@Create
|
||||
public REGION_RESTRICTIONS_OPTIONS REGION_RESTRICTIONS_OPTIONS;
|
||||
@Create
|
||||
public ENABLED_COMPONENTS ENABLED_COMPONENTS;
|
||||
|
||||
@Comment("Enable or disable core components")
|
||||
public static final class ENABLED_COMPONENTS {
|
||||
public boolean COMMANDS = true;
|
||||
}
|
||||
|
||||
@Comment("Paths for various directories")
|
||||
public static final class PATHS {
|
||||
|
@ -1,34 +1,32 @@
|
||||
package com.boydti.fawe.example;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T> {
|
||||
|
||||
public final int[][] ids;
|
||||
public final int[][] setBlocks;
|
||||
public final short[] count;
|
||||
public final short[] air;
|
||||
public final byte[] heightMap;
|
||||
|
||||
public byte[] biomes;
|
||||
public BiomeType[] biomes;
|
||||
public HashMap<Short, CompoundTag> tiles;
|
||||
public HashSet<CompoundTag> entities;
|
||||
public HashSet<UUID> entityRemoves;
|
||||
|
||||
public T chunk;
|
||||
|
||||
public IntFaweChunk(FaweQueue parent, int x, int z, int[][] ids, short[] count, short[] air, byte[] heightMap) {
|
||||
public IntFaweChunk(FaweQueue parent, int x, int z, int[][] setBlocks, short[] count, short[] air) {
|
||||
super(parent, x, z);
|
||||
this.ids = ids;
|
||||
this.setBlocks = setBlocks;
|
||||
this.count = count;
|
||||
this.air = air;
|
||||
this.heightMap = heightMap;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,10 +38,9 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
*/
|
||||
public IntFaweChunk(FaweQueue parent, int x, int z) {
|
||||
super(parent, x, z);
|
||||
this.ids = new int[HEIGHT >> 4][];
|
||||
this.setBlocks = new int[HEIGHT >> 4][];
|
||||
this.count = new short[HEIGHT >> 4];
|
||||
this.air = new short[HEIGHT >> 4];
|
||||
this.heightMap = new byte[256];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,8 +101,8 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
@Override
|
||||
public int getBitMask() {
|
||||
int bitMask = 0;
|
||||
for (int section = 0; section < ids.length; section++) {
|
||||
if (ids[section] != null) {
|
||||
for (int section = 0; section < setBlocks.length; section++) {
|
||||
if (setBlocks[section] != null) {
|
||||
bitMask += 1 << section;
|
||||
}
|
||||
}
|
||||
@ -120,27 +117,26 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
*/
|
||||
@Override
|
||||
public int[] getIdArray(final int i) {
|
||||
return this.ids[i];
|
||||
return this.setBlocks[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[][] getCombinedIdArrays() {
|
||||
return this.ids;
|
||||
return this.setBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBiomeArray() {
|
||||
public BiomeType[] getBiomeArray() {
|
||||
return this.biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockCombinedId(int x, int y, int z) {
|
||||
short i = FaweCache.CACHE_I[y][z][x];
|
||||
int[] array = getIdArray(i);
|
||||
int[] array = getIdArray(y >> 4);
|
||||
if (array == null) {
|
||||
return 0;
|
||||
}
|
||||
return array[FaweCache.CACHE_J[y][z][x]];
|
||||
return array[(((y & 0xF) << 8) | (z << 4) | x)];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -194,19 +190,39 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, int combinedId) {
|
||||
final int i = FaweCache.CACHE_I[y][z][x];
|
||||
final int j = FaweCache.CACHE_J[y][z][x];
|
||||
int[] vs = this.ids[i];
|
||||
final int i = y >> 4;
|
||||
int[] vs = this.setBlocks[i];
|
||||
if (vs == null) {
|
||||
vs = this.ids[i] = new int[4096];
|
||||
vs = this.setBlocks[i] = new int[4096];
|
||||
}
|
||||
vs[j] = combinedId;
|
||||
this.count[i]++;
|
||||
if (BlockTypes.getFromStateId(combinedId).getMaterial().isAir()) {
|
||||
this.air[i]++;
|
||||
return;
|
||||
int index = (((y & 15) << 8) | (z << 4) | x);
|
||||
int existing = vs[index];
|
||||
vs[index] = combinedId;
|
||||
switch (existing) {
|
||||
case 0:
|
||||
this.count[i]++;
|
||||
switch (combinedId) {
|
||||
case 0:
|
||||
case BlockID.AIR:
|
||||
case BlockID.CAVE_AIR:
|
||||
case BlockID.VOID_AIR:
|
||||
this.air[i]++;
|
||||
}
|
||||
break;
|
||||
case BlockID.AIR:
|
||||
case BlockID.CAVE_AIR:
|
||||
case BlockID.VOID_AIR:
|
||||
switch (combinedId) {
|
||||
case 0:
|
||||
case BlockID.AIR:
|
||||
case BlockID.CAVE_AIR:
|
||||
case BlockID.VOID_AIR:
|
||||
break;
|
||||
default:
|
||||
this.air[i]--;
|
||||
|
||||
}
|
||||
}
|
||||
heightMap[z << 4 | x] = (byte) y;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -216,11 +232,10 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(final int x, final int z, byte biome) {
|
||||
public void setBiome(final int x, final int z, BiomeType biome) {
|
||||
if (this.biomes == null) {
|
||||
this.biomes = new byte[256];
|
||||
this.biomes = new BiomeType[256];
|
||||
}
|
||||
if (biome == 0) biome = -1;
|
||||
biomes[((z & 15) << 4) + (x & 15)] = biome;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
@ -119,7 +119,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
|
||||
public abstract WORLD getImpWorld();
|
||||
|
||||
public abstract boolean regenerateChunk(WORLD world, int x, int z, BaseBiome biome, Long seed);
|
||||
public abstract boolean regenerateChunk(WORLD world, int x, int z, BiomeType biome, Long seed);
|
||||
|
||||
@Override
|
||||
public abstract FaweChunk getFaweChunk(int x, int z);
|
||||
@ -140,16 +140,10 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(int x, int z, BaseBiome biome, Long seed) {
|
||||
public boolean regenerateChunk(int x, int z, BiomeType biome, Long seed) {
|
||||
return regenerateChunk(getWorld(), x, z, biome, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotifyTask(int x, int z, Runnable runnable) {
|
||||
FaweChunk chunk = map.getFaweChunk(x, z);
|
||||
chunk.addNotifyTask(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, int id) {
|
||||
int cx = x >> 4;
|
||||
@ -193,7 +187,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
FaweChunk chunk = map.getFaweChunk(cx, cz);
|
||||
@ -385,7 +379,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
return getCombinedId4Data(lastSection, x, y, z);
|
||||
}
|
||||
|
||||
public abstract int getBiome(CHUNK chunk, int x, int z);
|
||||
public abstract BiomeType getBiome(CHUNK chunk, int x, int z);
|
||||
|
||||
public abstract CompoundTag getTileEntity(CHUNK chunk, int x, int y, int z);
|
||||
|
||||
@ -753,7 +747,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
lastSectionY = -1;
|
||||
@ -765,12 +759,12 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
lastChunkSections = getSections(lastChunk);
|
||||
} else {
|
||||
lastChunkSections = null;
|
||||
return 0;
|
||||
return null;
|
||||
}
|
||||
} else if (lastChunk == null) {
|
||||
return 0;
|
||||
return null;
|
||||
}
|
||||
return getBiome(lastChunk, x, z) & 0xFF;
|
||||
return getBiome(lastChunk, x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +76,8 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
byte[] fix = new byte[(maxY + 1) >> 4];
|
||||
boolean sky = hasSky();
|
||||
if (sky) {
|
||||
for (int i = cfc.ids.length - 1; i >= 0; i--) {
|
||||
int layers = FaweChunk.HEIGHT >> 4;
|
||||
for (int i = layers - 1; i >= 0; i--) {
|
||||
int air = cfc.getAir(i);
|
||||
int solid = cfc.getCount(i);
|
||||
if (air == 4096) {
|
||||
@ -107,8 +108,6 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void setHeightMap(FaweChunk chunk, byte[] heightMap);
|
||||
|
||||
public abstract void setFullbright(CHUNKSECTION sections);
|
||||
|
||||
public boolean removeLighting(CHUNKSECTION sections, RelightMode mode, boolean hasSky) {
|
||||
@ -143,13 +142,12 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
if ((y < 0) || (y > maxY)) {
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
final int i = FaweCache.CACHE_I[y][z][x];
|
||||
final int i = y >> 4;
|
||||
final char[] section = sections[i];
|
||||
if (section == null) {
|
||||
return 0;
|
||||
}
|
||||
final int j = FaweCache.CACHE_J[y][z][x];
|
||||
return section[j] >> 4;
|
||||
return section[(((y & 0xF) << 8) | (z << 4) | x)] >> 4;
|
||||
}
|
||||
|
||||
public void saveChunk(CHUNK chunk) {
|
||||
@ -222,6 +220,4 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
public abstract void setBlockLight(SECTION section, int x, int y, int z, int value);
|
||||
|
||||
public abstract void refreshChunk(FaweChunk fs);
|
||||
|
||||
public abstract IntFaweChunk getPrevious(IntFaweChunk fs, CHUNKSECTION sections, Map<?, ?> tiles, Collection<?>[] entities, Set<UUID> createdEntities, boolean all) throws Exception;
|
||||
}
|
||||
|
@ -409,8 +409,8 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
}
|
||||
|
||||
byte[] cacheX = FaweCache.CACHE_X[0];
|
||||
byte[] cacheZ = FaweCache.CACHE_Z[0];
|
||||
// byte[] cacheX = FaweCache.CACHE_X[0];
|
||||
// byte[] cacheZ = FaweCache.CACHE_Z[0];
|
||||
for (int y = FaweChunk.HEIGHT - 1; y > 0; y--) {
|
||||
for (RelightSkyEntry chunk : chunks) { // Propogate skylight
|
||||
int layer = y >> 4;
|
||||
@ -434,58 +434,58 @@ public class NMSRelighter implements Relighter {
|
||||
queue.removeSectionLighting(section, y >> 4, true);
|
||||
}
|
||||
|
||||
for (int j = 0; j <= maxY; j++) {
|
||||
int x = cacheX[j];
|
||||
int z = cacheZ[j];
|
||||
byte value = mask[j];
|
||||
byte pair = (byte) queue.getOpacityBrightnessPair(section, x, y, z);
|
||||
int opacity = MathMan.unpair16x(pair);
|
||||
int brightness = MathMan.unpair16y(pair);
|
||||
if (brightness > 1 && (brightness != 15 || opacity != 15)) {
|
||||
addLightUpdate(bx + x, y, bz + z);
|
||||
}
|
||||
switch (value) {
|
||||
case 0:
|
||||
if (opacity > 1) {
|
||||
queue.setSkyLight(section, x, y, z, 0);
|
||||
for (int z = 0, j = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++, j++) {
|
||||
byte value = mask[j];
|
||||
byte pair = (byte) queue.getOpacityBrightnessPair(section, x, y, z);
|
||||
int opacity = MathMan.unpair16x(pair);
|
||||
int brightness = MathMan.unpair16y(pair);
|
||||
if (brightness > 1 && (brightness != 15 || opacity != 15)) {
|
||||
addLightUpdate(bx + x, y, bz + z);
|
||||
}
|
||||
switch (value) {
|
||||
case 0:
|
||||
if (opacity > 1) {
|
||||
queue.setSkyLight(section, x, y, z, 0);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
if (opacity >= value) {
|
||||
mask[j] = 0;
|
||||
queue.setSkyLight(section, x, y, z, 0);
|
||||
continue;
|
||||
}
|
||||
if (opacity <= 1) {
|
||||
mask[j] = --value;
|
||||
} else {
|
||||
mask[j] = value = (byte) Math.max(0, value - opacity);
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
if (opacity > 1) {
|
||||
value -= opacity;
|
||||
mask[j] = value;
|
||||
}
|
||||
queue.setSkyLight(section, x, y, z, value);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
if (opacity >= value) {
|
||||
mask[j] = 0;
|
||||
queue.setSkyLight(section, x, y, z, 0);
|
||||
continue;
|
||||
}
|
||||
if (opacity <= 1) {
|
||||
mask[j] = --value;
|
||||
} else {
|
||||
mask[j] = value = (byte) Math.max(0, value - opacity);
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
if (opacity > 1) {
|
||||
value -= opacity;
|
||||
mask[j] = value;
|
||||
}
|
||||
queue.setSkyLight(section, x, y, z, value);
|
||||
continue;
|
||||
}
|
||||
chunk.smooth = true;
|
||||
queue.setSkyLight(section, x, y, z, value);
|
||||
}
|
||||
chunk.smooth = true;
|
||||
queue.setSkyLight(section, x, y, z, value);
|
||||
}
|
||||
queue.saveChunk(chunkObj);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.boydti.fawe.example;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -37,8 +37,8 @@ public class NullFaweChunk extends FaweChunk<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBiomeArray() {
|
||||
return new byte[256];
|
||||
public BiomeType[] getBiomeArray() {
|
||||
return new BiomeType[256];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,12 +97,7 @@ public class NullFaweChunk extends FaweChunk<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, BaseBiome biome) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, byte biome) {
|
||||
public void setBiome(int x, int z, BiomeType biome) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@ public class NullQueueIntFaweChunk extends IntFaweChunk {
|
||||
super(null, cx, cz);
|
||||
}
|
||||
|
||||
public NullQueueIntFaweChunk(int x, int z, int[][] ids, short[] count, short[] air, byte[] heightMap) {
|
||||
super(null, x, z, ids, count, air, heightMap);
|
||||
public NullQueueIntFaweChunk(int x, int z, int[][] ids, short[] count, short[] air) {
|
||||
super(null, x, z, ids, count, air);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -21,9 +21,9 @@ public class NullQueueIntFaweChunk extends IntFaweChunk {
|
||||
@Override
|
||||
public IntFaweChunk copy(boolean shallow) {
|
||||
if (shallow) {
|
||||
return new NullQueueIntFaweChunk(getX(), getZ(), ids, count, air, heightMap);
|
||||
return new NullQueueIntFaweChunk(getX(), getZ(), setBlocks, count, air);
|
||||
} else {
|
||||
return new NullQueueIntFaweChunk(getX(), getZ(), (int[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), heightMap.clone());
|
||||
return new NullQueueIntFaweChunk(getX(), getZ(), (int[][]) MainUtil.copyNd(setBlocks), count.clone(), air.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,8 @@ public class SimpleIntFaweChunk extends IntFaweChunk {
|
||||
super(parent, x, z);
|
||||
}
|
||||
|
||||
public SimpleIntFaweChunk(FaweQueue parent, int x, int z, int[][] ids, short[] count, short[] air, byte[] heightMap) {
|
||||
super(parent, x, z, ids, count, air, heightMap);
|
||||
public SimpleIntFaweChunk(FaweQueue parent, int x, int z, int[][] ids, short[] count, short[] air) {
|
||||
super(parent, x, z, ids, count, air);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -23,10 +23,10 @@ public class SimpleIntFaweChunk extends IntFaweChunk {
|
||||
public IntFaweChunk copy(boolean shallow) {
|
||||
SimpleIntFaweChunk copy;
|
||||
if (shallow) {
|
||||
copy = new SimpleIntFaweChunk(getParent(), getX(), getZ(), ids, count, air, heightMap);
|
||||
copy = new SimpleIntFaweChunk(getParent(), getX(), getZ(), setBlocks, count, air);
|
||||
copy.biomes = biomes;
|
||||
} else {
|
||||
copy = new SimpleIntFaweChunk(getParent(), getX(), getZ(), (int[][]) MainUtil.copyNd(ids), count.clone(), air.clone(), heightMap.clone());
|
||||
copy = new SimpleIntFaweChunk(getParent(), getX(), getZ(), (int[][]) MainUtil.copyNd(setBlocks), count.clone(), air.clone());
|
||||
copy.biomes = biomes != null ? biomes.clone() : null;
|
||||
}
|
||||
return copy;
|
||||
@ -37,4 +37,4 @@ public class SimpleIntFaweChunk extends IntFaweChunk {
|
||||
getParent().setChunk(this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ package com.boydti.fawe.installer;
|
||||
import com.boydti.fawe.FaweVersion;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
@ -149,11 +151,11 @@ public class InstallerFrame extends JFrame {
|
||||
java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
||||
String versionString = scanner.next().trim();
|
||||
scanner.close();
|
||||
FaweVersion version = new FaweVersion(versionString);
|
||||
FaweVersion version = null;
|
||||
String date = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||
String build = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build;
|
||||
String commit = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash);
|
||||
String footerMessage = "FAWE v" + version.major + "." + version.minor + "." + version.patch + " by Empire92 (c) 2017 (GPL v3.0)";
|
||||
String footerMessage = "FAWE v" + version.year + "." + version.month + "." + version.day + " by Empire92 (c) 2017 (GPL v3.0)";
|
||||
URL licenseUrl = new URL("https://github.com/boy0001/FastAsyncWorldedit/blob/master/LICENSE");
|
||||
URLButton licenseButton = new URLButton(licenseUrl, footerMessage);
|
||||
bottomBar.add(licenseButton);
|
||||
|
@ -22,6 +22,7 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.*;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
@ -118,7 +119,7 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
ByteReader biomeReader = new ByteReader() {
|
||||
@Override
|
||||
public void run(int index, int value) {
|
||||
fc.setBiome(index, value);
|
||||
fc.setBiome(index, BiomeTypes.get(value));
|
||||
}
|
||||
};
|
||||
NBTStreamReader<Integer, Integer> initializer23 = new NBTStreamReader<Integer, Integer>() {
|
||||
@ -196,24 +197,24 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
|
||||
BlockType type = block.getBlockType();
|
||||
switch (type.getResource().toUpperCase()) {
|
||||
case "ACACIA_STAIRS":
|
||||
case "BIRCH_STAIRS":
|
||||
case "BRICK_STAIRS":
|
||||
case "COBBLESTONE_STAIRS":
|
||||
case "DARK_OAK_STAIRS":
|
||||
case "DARK_PRISMARINE_STAIRS":
|
||||
case "JUNGLE_STAIRS":
|
||||
case "NETHER_BRICK_STAIRS":
|
||||
case "OAK_STAIRS":
|
||||
case "PRISMARINE_BRICK_STAIRS":
|
||||
case "PRISMARINE_STAIRS":
|
||||
case "PURPUR_STAIRS":
|
||||
case "QUARTZ_STAIRS":
|
||||
case "RED_SANDSTONE_STAIRS":
|
||||
case "SANDSTONE_STAIRS":
|
||||
case "SPRUCE_STAIRS":
|
||||
case "STONE_BRICK_STAIRS":
|
||||
switch (type.getInternalId()) {
|
||||
case BlockID.ACACIA_STAIRS:
|
||||
case BlockID.BIRCH_STAIRS:
|
||||
case BlockID.BRICK_STAIRS:
|
||||
case BlockID.COBBLESTONE_STAIRS:
|
||||
case BlockID.DARK_OAK_STAIRS:
|
||||
case BlockID.DARK_PRISMARINE_STAIRS:
|
||||
case BlockID.JUNGLE_STAIRS:
|
||||
case BlockID.NETHER_BRICK_STAIRS:
|
||||
case BlockID.OAK_STAIRS:
|
||||
case BlockID.PRISMARINE_BRICK_STAIRS:
|
||||
case BlockID.PRISMARINE_STAIRS:
|
||||
case BlockID.PURPUR_STAIRS:
|
||||
case BlockID.QUARTZ_STAIRS:
|
||||
case BlockID.RED_SANDSTONE_STAIRS:
|
||||
case BlockID.SANDSTONE_STAIRS:
|
||||
case BlockID.SPRUCE_STAIRS:
|
||||
case BlockID.STONE_BRICK_STAIRS:
|
||||
Object half = block.getState(PropertyKey.HALF);
|
||||
Direction facing = block.getState(PropertyKey.FACING);
|
||||
|
||||
@ -300,38 +301,38 @@ public class SchematicStreamer extends NBTStreamer {
|
||||
}
|
||||
|
||||
private int group(BlockType type) {
|
||||
switch (type.getResource().toUpperCase()) {
|
||||
case "ACACIA_FENCE":
|
||||
case "BIRCH_FENCE":
|
||||
case "DARK_OAK_FENCE":
|
||||
case "JUNGLE_FENCE":
|
||||
case "OAK_FENCE":
|
||||
case "SPRUCE_FENCE":
|
||||
switch (type.getInternalId()) {
|
||||
case BlockID.ACACIA_FENCE:
|
||||
case BlockID.BIRCH_FENCE:
|
||||
case BlockID.DARK_OAK_FENCE:
|
||||
case BlockID.JUNGLE_FENCE:
|
||||
case BlockID.OAK_FENCE:
|
||||
case BlockID.SPRUCE_FENCE:
|
||||
return 0;
|
||||
case "NETHER_BRICK_FENCE":
|
||||
case BlockID.NETHER_BRICK_FENCE:
|
||||
return 1;
|
||||
case "COBBLESTONE_WALL":
|
||||
case "MOSSY_COBBLESTONE_WALL":
|
||||
case BlockID.COBBLESTONE_WALL:
|
||||
case BlockID.MOSSY_COBBLESTONE_WALL:
|
||||
return 2;
|
||||
case "IRON_BARS":
|
||||
case "BLACK_STAINED_GLASS_PANE":
|
||||
case "BLUE_STAINED_GLASS_PANE":
|
||||
case "BROWN_MUSHROOM_BLOCK":
|
||||
case "BROWN_STAINED_GLASS_PANE":
|
||||
case "CYAN_STAINED_GLASS_PANE":
|
||||
case "GLASS_PANE":
|
||||
case "GRAY_STAINED_GLASS_PANE":
|
||||
case "GREEN_STAINED_GLASS_PANE":
|
||||
case "LIGHT_BLUE_STAINED_GLASS_PANE":
|
||||
case "LIGHT_GRAY_STAINED_GLASS_PANE":
|
||||
case "LIME_STAINED_GLASS_PANE":
|
||||
case "MAGENTA_STAINED_GLASS_PANE":
|
||||
case "ORANGE_STAINED_GLASS_PANE":
|
||||
case "PINK_STAINED_GLASS_PANE":
|
||||
case "PURPLE_STAINED_GLASS_PANE":
|
||||
case "RED_STAINED_GLASS_PANE":
|
||||
case "WHITE_STAINED_GLASS_PANE":
|
||||
case "YELLOW_STAINED_GLASS_PANE":
|
||||
case BlockID.IRON_BARS:
|
||||
case BlockID.BLACK_STAINED_GLASS_PANE:
|
||||
case BlockID.BLUE_STAINED_GLASS_PANE:
|
||||
case BlockID.BROWN_MUSHROOM_BLOCK:
|
||||
case BlockID.BROWN_STAINED_GLASS_PANE:
|
||||
case BlockID.CYAN_STAINED_GLASS_PANE:
|
||||
case BlockID.GLASS_PANE:
|
||||
case BlockID.GRAY_STAINED_GLASS_PANE:
|
||||
case BlockID.GREEN_STAINED_GLASS_PANE:
|
||||
case BlockID.LIGHT_BLUE_STAINED_GLASS_PANE:
|
||||
case BlockID.LIGHT_GRAY_STAINED_GLASS_PANE:
|
||||
case BlockID.LIME_STAINED_GLASS_PANE:
|
||||
case BlockID.MAGENTA_STAINED_GLASS_PANE:
|
||||
case BlockID.ORANGE_STAINED_GLASS_PANE:
|
||||
case BlockID.PINK_STAINED_GLASS_PANE:
|
||||
case BlockID.PURPLE_STAINED_GLASS_PANE:
|
||||
case BlockID.RED_STAINED_GLASS_PANE:
|
||||
case BlockID.WHITE_STAINED_GLASS_PANE:
|
||||
case BlockID.YELLOW_STAINED_GLASS_PANE:
|
||||
return 3;
|
||||
default:
|
||||
return -1;
|
||||
|
@ -0,0 +1,162 @@
|
||||
package com.boydti.fawe.jnbt.anvil;
|
||||
|
||||
public final class BitArray4096 {
|
||||
|
||||
private final int bitsPerEntry;
|
||||
private final int maxSeqLocIndex;
|
||||
private final int maxEntryValue;
|
||||
private final long[] data;
|
||||
private final int longLen;
|
||||
|
||||
public BitArray4096(long[] buffer, int bitsPerEntry) {
|
||||
this.bitsPerEntry = bitsPerEntry;
|
||||
this.maxSeqLocIndex = 64 - bitsPerEntry;
|
||||
maxEntryValue = (1 << bitsPerEntry) - 1;
|
||||
this.longLen = (this.bitsPerEntry * 4096) >> 6;
|
||||
if (buffer.length < longLen) {
|
||||
System.out.println("Invalid buffer " + buffer.length + " | " + longLen);
|
||||
this.data = new long[longLen];
|
||||
} else {
|
||||
this.data = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
public BitArray4096(int bitsPerEntry) {
|
||||
this.bitsPerEntry = bitsPerEntry;
|
||||
this.maxSeqLocIndex = 64 - bitsPerEntry;
|
||||
maxEntryValue = (1 << bitsPerEntry) - 1;
|
||||
this.longLen = (this.bitsPerEntry * 4096) >> 6;
|
||||
this.data = new long[longLen];
|
||||
}
|
||||
|
||||
public final void setAt(int index, int value) {
|
||||
if (longLen == 0) return;
|
||||
int bitIndexStart = index * bitsPerEntry;
|
||||
int longIndexStart = bitIndexStart >> 6;
|
||||
int localBitIndexStart = bitIndexStart & 63;
|
||||
this.data[longIndexStart] = this.data[longIndexStart] & ~((long) maxEntryValue << localBitIndexStart) | ((long) value) << localBitIndexStart;
|
||||
|
||||
if(localBitIndexStart > maxSeqLocIndex) {
|
||||
int longIndexEnd = longIndexStart + 1;
|
||||
int localShiftStart = 64 - localBitIndexStart;
|
||||
int localShiftEnd = bitsPerEntry - localShiftStart;
|
||||
this.data[longIndexEnd] = this.data[longIndexEnd] >>> localShiftEnd << localShiftEnd | (((long) value) >> localShiftStart);
|
||||
}
|
||||
}
|
||||
|
||||
public final int getAt(int index) {
|
||||
if (longLen == 0) return 0;
|
||||
int bitIndexStart = index * bitsPerEntry;
|
||||
|
||||
int longIndexStart = bitIndexStart >> 6;
|
||||
|
||||
int localBitIndexStart = bitIndexStart & 63;
|
||||
if(localBitIndexStart <= maxSeqLocIndex) {
|
||||
return (int)(this.data[longIndexStart] >>> localBitIndexStart & maxEntryValue);
|
||||
} else {
|
||||
int localShift = 64 - localBitIndexStart;
|
||||
return (int) ((this.data[longIndexStart] >>> localBitIndexStart | this.data[longIndexStart + 1] << localShift) & maxEntryValue);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return longLen;
|
||||
}
|
||||
|
||||
public final void fromRawSlow(char[] arr) {
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
setAt(i, arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public final void fromRaw(int[] arr) {
|
||||
final long[] data = this.data;
|
||||
final int bitsPerEntry = this.bitsPerEntry;
|
||||
final int maxSeqLocIndex = this.maxSeqLocIndex;
|
||||
|
||||
int localStart = 0;
|
||||
int lastVal;
|
||||
int arrI = 0;
|
||||
long l = 0;
|
||||
long nextVal;
|
||||
for (int i = 0; i < longLen; i++) {
|
||||
for (; localStart <= maxSeqLocIndex; localStart += bitsPerEntry) {
|
||||
lastVal = arr[arrI++];
|
||||
l |= ((long) lastVal << localStart);
|
||||
}
|
||||
if (localStart < 64) {
|
||||
if (i != longLen - 1) {
|
||||
lastVal = arr[arrI++];
|
||||
int shift = 64 - localStart;
|
||||
|
||||
nextVal = lastVal >> shift;
|
||||
|
||||
l |= ((lastVal - (nextVal << shift)) << localStart);
|
||||
|
||||
data[i] = l;
|
||||
data[i + 1] = l = nextVal;
|
||||
|
||||
localStart -= maxSeqLocIndex;
|
||||
}
|
||||
} else {
|
||||
localStart = 0;
|
||||
data[i] = l;
|
||||
l = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BitArray4096 growSlow(int bitsPerEntry) {
|
||||
BitArray4096 newBitArray = new BitArray4096(bitsPerEntry);
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
newBitArray.setAt(i, getAt(i));
|
||||
}
|
||||
return newBitArray;
|
||||
}
|
||||
|
||||
public final char[] toRawSlow() {
|
||||
char[] arr = new char[4096];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
arr[i] = (char) getAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public final int[] toRaw() {
|
||||
return toRaw(new int[4096]);
|
||||
}
|
||||
|
||||
public final int[] toRaw(int[] buffer) {
|
||||
final long[] data = this.data;
|
||||
final int dataLength = longLen;
|
||||
final int bitsPerEntry = this.bitsPerEntry;
|
||||
final int maxEntryValue = this.maxEntryValue;
|
||||
final int maxSeqLocIndex = this.maxSeqLocIndex;
|
||||
|
||||
int localStart = 0;
|
||||
char lastVal;
|
||||
int arrI = 0;
|
||||
long l;
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
l = data[i];
|
||||
for (; localStart <= maxSeqLocIndex; localStart += bitsPerEntry) {
|
||||
lastVal = (char) (l >>> localStart & maxEntryValue);
|
||||
buffer[arrI++] = lastVal;
|
||||
}
|
||||
if (localStart < 64) {
|
||||
if (i != dataLength - 1) {
|
||||
lastVal = (char) (l >>> localStart);
|
||||
localStart -= maxSeqLocIndex;
|
||||
l = data[i + 1];
|
||||
int localShift = bitsPerEntry - localStart;
|
||||
lastVal |= l << localShift;
|
||||
lastVal &= maxEntryValue;
|
||||
buffer[arrI++] = lastVal;
|
||||
}
|
||||
} else {
|
||||
localStart = 0;
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ 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;
|
||||
|
||||
@ -82,13 +83,16 @@ public final class HeightMapMCADrawer {
|
||||
int waterId = gen.primtives.waterId;
|
||||
int waterColor = 0;
|
||||
BlockType waterType = BlockTypes.get(waterId);
|
||||
String s = waterType.getResource().toUpperCase();
|
||||
if (waterType == BlockTypes.WATER) {
|
||||
color = tu.averageColor((0x11 << 16) + (0x66 << 8) + (0xCC), color);
|
||||
} else if (waterType == BlockTypes.LAVA) {
|
||||
color = (0xCC << 16) + (0x33 << 8) + (0);
|
||||
} else {
|
||||
color = tu.getColor(waterType);
|
||||
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;
|
||||
|
@ -3,6 +3,9 @@ package com.boydti.fawe.jnbt.anvil;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.SimpleIntFaweChunk;
|
||||
import com.boydti.fawe.jnbt.anvil.HeightMapMCADrawer;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAChunk;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAWriter;
|
||||
import com.boydti.fawe.object.*;
|
||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||
import com.boydti.fawe.object.change.StreamChange;
|
||||
@ -17,6 +20,9 @@ import com.boydti.fawe.util.image.ImageViewer;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -33,7 +39,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -75,8 +81,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
protected int worldThickness = 0;
|
||||
protected boolean randomVariation = true;
|
||||
protected int biomePriority = 0;
|
||||
protected int waterId = BlockTypes.WATER.getInternalId();
|
||||
protected int bedrockId = 7;
|
||||
protected int waterId = BlockID.WATER;
|
||||
protected int bedrockId = BlockID.BEDROCK;
|
||||
protected boolean modifiedMain = false;
|
||||
|
||||
@Override
|
||||
@ -209,7 +215,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
|
||||
public HeightMapMCAGenerator(int width, int length, File regionFolder) {
|
||||
super(width, length, regionFolder);
|
||||
int area = getArea();
|
||||
|
||||
blocks = new DifferentialBlockBuffer(width, length);
|
||||
heights = new DifferentialArray(new byte[getArea()]);
|
||||
@ -217,8 +222,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
floor = new DifferentialArray(new int[getArea()]);
|
||||
main = new DifferentialArray(new int[getArea()]);
|
||||
|
||||
int stone = BlockTypes.STONE.getInternalId();
|
||||
int grass = BlockTypes.GRASS_BLOCK.getInternalId();
|
||||
int stone = BlockID.STONE;
|
||||
int grass = BlockTypes.GRASS_BLOCK.getDefaultState().with(PropertyKey.SNOWY, false).getInternalId();
|
||||
Arrays.fill(main.getIntArray(), stone);
|
||||
Arrays.fill(floor.getIntArray(), grass);
|
||||
}
|
||||
@ -295,7 +300,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int ecx = Math.min(lenCX - 1, pcx + 15);
|
||||
int ecz = Math.min(lenCZ - 1, pcz + 15);
|
||||
|
||||
MCAChunk chunk = new MCAChunk(this, 0, 0);
|
||||
for (int cz = scz; cz <= ecz; cz++) {
|
||||
for (int cx = scx; cx <= ecx; cx++) {
|
||||
final int finalCX = cx;
|
||||
@ -446,16 +450,20 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
private final void setLayerHeight(int index, int blockHeight, int layerHeight) {
|
||||
int floorState = floor.get()[index];
|
||||
BlockType type = BlockTypes.getFromStateId(floorState);
|
||||
if (type == BlockTypes.SNOW || type == BlockTypes.SNOW_BLOCK) {
|
||||
if (layerHeight != 0) {
|
||||
this.heights.setByte(index, (byte) (blockHeight + 1));
|
||||
this.floor.setInt(index, (BlockTypes.SNOW.getInternalId() + layerHeight));
|
||||
} else {
|
||||
switch (type.getInternalId()) {
|
||||
case BlockID.SNOW:
|
||||
case BlockID.SNOW_BLOCK:
|
||||
if (layerHeight != 0) {
|
||||
this.heights.setByte(index, (byte) (blockHeight + 1));
|
||||
this.floor.setInt(index, (BlockTypes.SNOW.getInternalId() + layerHeight));
|
||||
} else {
|
||||
this.heights.setByte(index, (byte) (blockHeight));
|
||||
this.floor.setInt(index, (BlockTypes.SNOW_BLOCK.getInternalId()));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this.heights.setByte(index, (byte) (blockHeight));
|
||||
this.floor.setInt(index, (BlockTypes.SNOW_BLOCK.getInternalId()));
|
||||
}
|
||||
} else {
|
||||
this.heights.setByte(index, (byte) (blockHeight));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,16 +476,20 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
private final void setLayerHeightRaw(int index, int blockHeight, int layerHeight) {
|
||||
int floorState = floor.get()[index];
|
||||
BlockType type = BlockTypes.getFromStateId(floorState);
|
||||
if (type == BlockTypes.SNOW || type == BlockTypes.SNOW_BLOCK) {
|
||||
if (layerHeight != 0) {
|
||||
this.heights.getByteArray()[index] = (byte) (blockHeight + 1);
|
||||
this.floor.getIntArray()[index] = (BlockTypes.SNOW.getInternalId() + layerHeight);
|
||||
} else {
|
||||
switch (type.getInternalId()) {
|
||||
case BlockID.SNOW:
|
||||
case BlockID.SNOW_BLOCK:
|
||||
if (layerHeight != 0) {
|
||||
this.heights.getByteArray()[index] = (byte) (blockHeight + 1);
|
||||
this.floor.getIntArray()[index] = (BlockTypes.SNOW.getInternalId() + layerHeight);
|
||||
} else {
|
||||
this.heights.getByteArray()[index] = (byte) (blockHeight);
|
||||
this.floor.getIntArray()[index] = (BlockTypes.SNOW_BLOCK.getInternalId());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this.heights.getByteArray()[index] = (byte) (blockHeight);
|
||||
this.floor.getIntArray()[index] = (BlockTypes.SNOW_BLOCK.getInternalId());
|
||||
}
|
||||
} else {
|
||||
this.heights.getByteArray()[index] = (byte) (blockHeight);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,7 +520,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
int newHeight = table.average(x, z, index);
|
||||
setLayerHeightRaw(index, newHeight);
|
||||
}
|
||||
@ -689,7 +701,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return this.setBiome(position.getBlockX(), position.getBlockZ(), biome);
|
||||
}
|
||||
|
||||
@ -741,10 +753,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
int index = z * getWidth() + x;
|
||||
if (index < 0 || index >= getArea()) return false;
|
||||
biomes.setByte(index, (byte) biome.getId());
|
||||
biomes.setByte(index, (byte) biome.getInternalId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -758,16 +770,15 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
return getSnapshot(null, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
private FaweChunk getSnapshot(final MCAChunk chunk, int chunkX, int chunkZ) {
|
||||
return new LazyFaweChunk<MCAChunk>(this, chunkX, chunkZ) {
|
||||
private FaweChunk getSnapshot(final WritableMCAChunk chunk, int chunkX, int chunkZ) {
|
||||
return new LazyFaweChunk<WritableMCAChunk>(this, chunkX, chunkZ) {
|
||||
@Override
|
||||
public MCAChunk getChunk() {
|
||||
MCAChunk tmp = chunk;
|
||||
public WritableMCAChunk getChunk() {
|
||||
WritableMCAChunk tmp = chunk;
|
||||
if (tmp == null) {
|
||||
tmp = new MCAChunk(HeightMapMCAGenerator.this, chunkX, chunkZ);
|
||||
} else {
|
||||
tmp.setLoc(HeightMapMCAGenerator.this, chunkX, chunkZ);
|
||||
tmp = new WritableMCAChunk();
|
||||
}
|
||||
tmp.setLoc(HeightMapMCAGenerator.this, chunkX, chunkZ);
|
||||
int cbx = chunkX << 4;
|
||||
int cbz = chunkZ << 4;
|
||||
int csx = Math.max(0, cbx);
|
||||
@ -781,7 +792,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
|
||||
@Override
|
||||
public void addToQueue() {
|
||||
MCAChunk cached = getCachedChunk();
|
||||
WritableMCAChunk cached = getCachedChunk();
|
||||
if (cached != null) setChunk(cached);
|
||||
}
|
||||
};
|
||||
@ -829,7 +840,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(int x, int z, @Nullable BaseBiome biome, @Nullable Long seed) {
|
||||
public boolean regenerateChunk(int x, int z, @Nullable BiomeType biome, @Nullable Long seed) {
|
||||
// Unsupported
|
||||
return false;
|
||||
}
|
||||
@ -915,15 +926,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotifyTask(int x, int z, Runnable runnable) {
|
||||
if (runnable != null) runnable.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
int index = z * getWidth() + x;
|
||||
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
|
||||
return biomes.getByte(index) & 0xFF;
|
||||
return BiomeTypes.get(biomes.getByte(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1010,8 +1016,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return FaweCache.CACHE_BIOME[getBiomeId(position.getBlockX(), position.getBlockZ())];
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return getBiomeType(position.getBlockX(), position.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1069,9 +1075,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
return heights.getByte(index) & 0xFF;
|
||||
}
|
||||
|
||||
public void setBiome(BufferedImage img, byte biome, boolean white) {
|
||||
public void setBiome(BufferedImage img, BiomeType biome, boolean white) {
|
||||
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
|
||||
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
|
||||
byte biomeByte = (byte) biome.getInternalId();
|
||||
biomes.record(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -1081,8 +1088,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
biomeArr[index] = biome;
|
||||
.nextInt(256) <= height) {
|
||||
biomeArr[index] = biomeByte;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1133,7 +1140,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
if (imgMask != null) {
|
||||
int height = imgMask.getRGB(x, z) & 0xFF;
|
||||
if (height != 255 && (height <= 0 || !whiteOnly || ThreadLocalRandom
|
||||
.current().nextInt(256) > height)) continue;
|
||||
.current().nextInt(256) > height)) continue;
|
||||
}
|
||||
int color = img.getRGB(x, z);
|
||||
if (textureUtil.getIsBlockCloserThanBiome(buffer, color, primtives.biomePriority)) {
|
||||
@ -1218,7 +1225,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = mask.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
int color = img.getRGB(x, z);
|
||||
BlockType block = textureUtil.getNearestBlock(color);
|
||||
if (block != null) {
|
||||
@ -1317,8 +1324,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}));
|
||||
}
|
||||
|
||||
public void setBiome(Mask mask, byte biome) {
|
||||
public void setBiome(Mask mask, BiomeType biome) {
|
||||
int index = 0;
|
||||
byte biomeByte = (byte) biome.getInternalId();
|
||||
for (int z = 0; z < getLength(); z++) {
|
||||
mutable.mutZ(z);
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
@ -1326,7 +1334,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (mask.test(mutable)) {
|
||||
biomes.setByte(index, biome);
|
||||
biomes.setByte(index, biomeByte);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1336,7 +1344,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
if (pattern instanceof BlockStateHolder) {
|
||||
setOverlay(img, ((BlockStateHolder) pattern).getInternalId(), white);
|
||||
} else if (pattern instanceof BlockType) {
|
||||
setOverlay(img, ((BlockType) pattern).getInternalId(), white);
|
||||
setOverlay(img, ((BlockType) pattern).getInternalId(), white);
|
||||
} else {
|
||||
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
|
||||
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
|
||||
@ -1352,7 +1360,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(height);
|
||||
overlayArr[index] = pattern.apply(mutable).getInternalId();
|
||||
@ -1380,7 +1388,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(height);
|
||||
mainArr[index] = pattern.apply(mutable).getInternalId();
|
||||
@ -1406,7 +1414,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(height);
|
||||
floorArr[index] = pattern.apply(mutable).getInternalId();
|
||||
@ -1434,7 +1442,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(height);
|
||||
int combined = pattern.apply(mutable).getInternalId();
|
||||
@ -1528,8 +1536,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
}
|
||||
|
||||
public void setBiome(int biome) {
|
||||
biomes.record(() -> Arrays.fill(biomes.get(), (byte) biome));
|
||||
public void setBiome(BiomeType biome) {
|
||||
biomes.record(() -> Arrays.fill(biomes.get(), (byte) biome.getInternalId()));
|
||||
}
|
||||
|
||||
public void setFloor(Pattern value) {
|
||||
@ -1638,328 +1646,158 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@Override
|
||||
public MCAChunk write(MCAChunk chunk, int csx, int cex, int csz, int cez) {
|
||||
// TODO FIXME
|
||||
// byte[] heights = this.heights.get();
|
||||
// byte[] biomes = this.biomes.get();
|
||||
// int[] main = this.main.get();
|
||||
// int[] floor = this.floor.get();
|
||||
// int[] overlay = this.overlay != null ? this.overlay.get() : null;
|
||||
// try {
|
||||
// int[] indexes = indexStore.get();
|
||||
// for (int i = 0; i < chunk.ids.length; i++) {
|
||||
// byte[] idsArray = chunk.ids[i];
|
||||
// if (idsArray != null) {
|
||||
// Arrays.fill(idsArray, (byte) 0);
|
||||
// Arrays.fill(chunk.data[i], (byte) 0);
|
||||
// }
|
||||
// }
|
||||
// int index;
|
||||
// int maxY = 0;
|
||||
// int minY = Integer.MAX_VALUE;
|
||||
// int[] heightMap = chunk.getHeightMapArray();
|
||||
// int globalIndex;
|
||||
// for (int z = csz; z <= cez; z++) {
|
||||
// globalIndex = z * getWidth() + csx;
|
||||
// index = (z & 15) << 4;
|
||||
// for (int x = csx; x <= cex; x++, index++, globalIndex++) {
|
||||
// indexes[index] = globalIndex;
|
||||
// int height = heights[globalIndex] & 0xFF;
|
||||
// heightMap[index] = height;
|
||||
// maxY = Math.max(maxY, height);
|
||||
// minY = Math.min(minY, height);
|
||||
// }
|
||||
// }
|
||||
// boolean hasOverlay = this.overlay != null;
|
||||
// if (hasOverlay) {
|
||||
// maxY++;
|
||||
// }
|
||||
// int maxLayer = maxY >> 4;
|
||||
// int fillLayers = Math.max(0, (minY - 1)) >> 4;
|
||||
// for (int layer = 0; layer <= maxLayer; layer++) {
|
||||
// if (chunk.ids[layer] == null) {
|
||||
// chunk.ids[layer] = new byte[4096];
|
||||
// chunk.data[layer] = new byte[2048];
|
||||
// chunk.skyLight[layer] = new byte[2048];
|
||||
// chunk.blockLight[layer] = new byte[2048];
|
||||
// }
|
||||
// }
|
||||
// if (primtives.waterHeight != 0) {
|
||||
// maxY = Math.max(maxY, primtives.waterHeight);
|
||||
// int maxWaterLayer = ((primtives.waterHeight + 15) >> 4);
|
||||
// for (int layer = 0; layer < maxWaterLayer; layer++) {
|
||||
// boolean fillAll = (layer << 4) + 15 <= primtives.waterHeight;
|
||||
// byte[] ids = chunk.ids[layer];
|
||||
// if (ids == null) {
|
||||
// chunk.ids[layer] = ids = new byte[4096];
|
||||
// chunk.data[layer] = new byte[2048];
|
||||
// chunk.skyLight[layer] = new byte[2048];
|
||||
// chunk.blockLight[layer] = new byte[2048];
|
||||
// Arrays.fill(chunk.skyLight[layer], (byte) 255);
|
||||
// }
|
||||
// if (fillAll) {
|
||||
// Arrays.fill(ids, primtives.waterId);
|
||||
// } else {
|
||||
// int maxIndex = (primtives.waterHeight & 15) << 8;
|
||||
// Arrays.fill(ids, 0, maxIndex, primtives.waterId);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (primtives.modifiedMain) { // If the main block is modified, we can't short circuit this
|
||||
// for (int layer = 0; layer < fillLayers; layer++) {
|
||||
// byte[] layerIds = chunk.ids[layer];
|
||||
// byte[] layerDatas = chunk.data[layer];
|
||||
// for (int z = csz; z <= cez; z++) {
|
||||
// index = (z & 15) << 4;
|
||||
// for (int x = csx; x <= cex; x++, index++) {
|
||||
// globalIndex = indexes[index];
|
||||
// char mainCombined = main[globalIndex];
|
||||
// byte id = (byte) FaweCache.getId(mainCombined);
|
||||
// int data = FaweCache.getData(mainCombined);
|
||||
// if (data != 0) {
|
||||
// for (int y = 0; y < 16; y++) {
|
||||
// int mainIndex = index + (y << 8);
|
||||
// chunk.setNibble(mainIndex, layerDatas, data);
|
||||
// }
|
||||
// }
|
||||
// for (int y = 0; y < 16; y++) {
|
||||
// layerIds[index + (y << 8)] = id;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// for (int layer = 0; layer < fillLayers; layer++) {
|
||||
// Arrays.fill(chunk.ids[layer], (byte) 1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int layer = fillLayers; layer <= maxLayer; layer++) {
|
||||
// Arrays.fill(chunk.skyLight[layer], (byte) 255);
|
||||
// byte[] layerIds = chunk.ids[layer];
|
||||
// byte[] layerDatas = chunk.data[layer];
|
||||
// int startY = layer << 4;
|
||||
// int endY = startY + 15;
|
||||
// for (int z = csz; z <= cez; z++) {
|
||||
// index = (z & 15) << 4;
|
||||
// for (int x = csx; x <= cex; x++, index++) {
|
||||
// globalIndex = indexes[index];
|
||||
// int height = heightMap[index];
|
||||
// int diff;
|
||||
// if (height > endY) {
|
||||
// diff = 16;
|
||||
// } else if (height >= startY) {
|
||||
// diff = height - startY;
|
||||
// char floorCombined = floor[globalIndex];
|
||||
// int id = FaweCache.getId(floorCombined);
|
||||
// int floorIndex = index + ((height & 15) << 8);
|
||||
// layerIds[floorIndex] = (byte) id;
|
||||
// int data = FaweCache.getData(floorCombined);
|
||||
// if (data != 0) {
|
||||
// chunk.setNibble(floorIndex, layerDatas, data);
|
||||
// }
|
||||
// if (hasOverlay && height >= startY - 1 && height < endY) {
|
||||
// char overlayCombined = overlay[globalIndex];
|
||||
// id = FaweCache.getId(overlayCombined);
|
||||
// int overlayIndex = index + (((height + 1) & 15) << 8);
|
||||
// layerIds[overlayIndex] = (byte) id;
|
||||
// data = FaweCache.getData(overlayCombined);
|
||||
// if (data != 0) {
|
||||
// chunk.setNibble(overlayIndex, layerDatas, data);
|
||||
// }
|
||||
// }
|
||||
// } else if (hasOverlay && height == startY - 1) {
|
||||
// char overlayCombined = overlay[globalIndex];
|
||||
// int id = FaweCache.getId(overlayCombined);
|
||||
// int overlayIndex = index + (((height + 1) & 15) << 8);
|
||||
// layerIds[overlayIndex] = (byte) id;
|
||||
// int data = FaweCache.getData(overlayCombined);
|
||||
// if (data != 0) {
|
||||
// chunk.setNibble(overlayIndex, layerDatas, data);
|
||||
// }
|
||||
// continue;
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
// char mainCombined = main[globalIndex];
|
||||
// byte id = (byte) FaweCache.getId(mainCombined);
|
||||
// int data = FaweCache.getData(mainCombined);
|
||||
// if (data != 0) {
|
||||
// for (int y = 0; y < diff; y++) {
|
||||
// int mainIndex = index + (y << 8);
|
||||
// chunk.setNibble(mainIndex, layerDatas, data);
|
||||
// }
|
||||
// }
|
||||
// for (int y = 0; y < diff; y++) {
|
||||
// layerIds[index + (y << 8)] = id;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int maxYMod = 15 + (maxLayer << 4);
|
||||
// for (int layer = (maxY >> 4) + 1; layer < 16; layer++) {
|
||||
// chunk.ids[layer] = null;
|
||||
// chunk.data[layer] = null;
|
||||
// }
|
||||
//
|
||||
// if (primtives.bedrockId != 0) { // Bedrock
|
||||
// byte[] layerIds = chunk.ids[0];
|
||||
// for (int z = csz; z <= cez; z++) {
|
||||
// index = (z & 15) << 4;
|
||||
// for (int x = csx; x <= cex; x++) {
|
||||
// layerIds[index++] = primtives.bedrockId;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// char[][][] localBlocks = getChunkArray(chunk.getX(), chunk.getZ());
|
||||
// if (localBlocks != null) {
|
||||
// for (int layer = 0; layer < 16; layer++) {
|
||||
// int by = layer << 4;
|
||||
// int ty = by + 15;
|
||||
// index = 0;
|
||||
// for (int y = by; y <= ty; y++, index += 256) {
|
||||
// char[][] yBlocks = localBlocks[y];
|
||||
// if (yBlocks != null) {
|
||||
// if (chunk.ids[layer] == null) {
|
||||
// chunk.ids[layer] = new byte[4096];
|
||||
// chunk.data[layer] = new byte[2048];
|
||||
// chunk.skyLight[layer] = new byte[2048];
|
||||
// chunk.blockLight[layer] = new byte[2048];
|
||||
// Arrays.fill(chunk.skyLight[layer], (byte) 255);
|
||||
// }
|
||||
// byte[] idsLayer = chunk.ids[layer];
|
||||
// byte[] dataLayer = chunk.data[layer];
|
||||
// for (int z = 0; z < yBlocks.length; z++) {
|
||||
// char[] zBlocks = yBlocks[z];
|
||||
// if (zBlocks != null) {
|
||||
// int zIndex = index + (z << 4);
|
||||
// for (int x = 0; x < zBlocks.length; x++, zIndex++) {
|
||||
// char combined = zBlocks[x];
|
||||
// if (combined == 0) continue;
|
||||
// int id = FaweCache.getId(combined);
|
||||
// int data = FaweCache.getData(combined);
|
||||
// if (data == 0) {
|
||||
// chunk.setIdUnsafe(idsLayer, zIndex, (byte) id);
|
||||
// } else {
|
||||
// chunk.setBlockUnsafe(idsLayer, dataLayer, zIndex, (byte) id, FaweCache.getData(combined));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (primtives.floorThickness != 0 || primtives.worldThickness != 0) {
|
||||
// // Use biomes array as temporary buffer
|
||||
// byte[] minArr = chunk.biomes;
|
||||
// for (int z = csz; z <= cez; z++) {
|
||||
// index = (z & 15) << 4;
|
||||
// for (int x = csx; x <= cex; x++, index++) {
|
||||
// int gi = indexes[index];
|
||||
// int height = heightMap[index];
|
||||
// int min = height;
|
||||
// if (x > 0) min = Math.min(heights[gi - 1] & 0xFF, min);
|
||||
// if (x < getWidth() - 1) min = Math.min(heights[gi + 1] & 0xFF, min);
|
||||
// if (z > 0) min = Math.min(heights[gi - getWidth()] & 0xFF, min);
|
||||
// if (z < getLength() - 1) min = Math.min(heights[gi + getWidth()] & 0xFF, min);
|
||||
// minArr[index] = (byte) min;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int minLayer = Math.max(0, (minY - primtives.floorThickness) >> 4);
|
||||
//
|
||||
// if (primtives.floorThickness != 0) {
|
||||
// for (int layer = minLayer; layer <= maxLayer; layer++) {
|
||||
// byte[] layerIds = chunk.ids[layer];
|
||||
// byte[] layerDatas = chunk.data[layer];
|
||||
// int startY = layer << 4;
|
||||
// int endY = startY + 15;
|
||||
// for (int z = csz; z <= cez; z++) {
|
||||
// index = (z & 15) << 4;
|
||||
// for (int x = csx; x <= cex; x++, index++) {
|
||||
// globalIndex = indexes[index];
|
||||
// int height = heightMap[index];
|
||||
//
|
||||
// int min = (minArr[index] & 0xFF) - primtives.floorThickness;
|
||||
// int localMin = min - startY;
|
||||
//
|
||||
// int max = height + 1;
|
||||
// if (min < startY) min = startY;
|
||||
// if (max > endY) max = endY + 1;
|
||||
//
|
||||
//
|
||||
// if (min < max) {
|
||||
// char floorCombined = floor[globalIndex];
|
||||
// final byte id = (byte) FaweCache.getId(floorCombined);
|
||||
// final int data = FaweCache.getData(floorCombined);
|
||||
// for (int y = min; y < max; y++) {
|
||||
// int floorIndex = index + ((y & 15) << 8);
|
||||
// layerIds[floorIndex] = id;
|
||||
// if (data != 0) {
|
||||
// chunk.setNibble(floorIndex, layerDatas, data);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (primtives.worldThickness != 0) {
|
||||
// for (int layer = 0; layer < minLayer; layer++) {
|
||||
// chunk.ids[layer] = null;
|
||||
// chunk.data[layer] = null;
|
||||
// }
|
||||
// for (int layer = minLayer; layer <= maxLayer; layer++) {
|
||||
// byte[] layerIds = chunk.ids[layer];
|
||||
// byte[] layerDatas = chunk.data[layer];
|
||||
// int startY = layer << 4;
|
||||
// int endY = startY + 15;
|
||||
// for (int z = csz; z <= cez; z++) {
|
||||
// index = (z & 15) << 4;
|
||||
// for (int x = csx; x <= cex; x++, index++) {
|
||||
// globalIndex = indexes[index];
|
||||
// int height = heightMap[index];
|
||||
//
|
||||
// int min = (minArr[index] & 0xFF) - primtives.worldThickness;
|
||||
// int localMin = min - startY;
|
||||
// if (localMin > 0) {
|
||||
// char floorCombined = floor[globalIndex];
|
||||
// final byte id = (byte) FaweCache.getId(floorCombined);
|
||||
// final int data = FaweCache.getData(floorCombined);
|
||||
//
|
||||
// for (int y = 0; y < localMin; y++) {
|
||||
// int floorIndex = index + ((y & 15) << 8);
|
||||
// layerIds[floorIndex] = 0;
|
||||
// if (data != 0) {
|
||||
// chunk.setNibble(floorIndex, layerDatas, 0);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int layer = fillLayers; layer <= maxLayer; layer++) {
|
||||
// Arrays.fill(chunk.skyLight[layer], (byte) 255);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < 256; i++) {
|
||||
// chunk.biomes[i] = biomes[indexes[i]];
|
||||
// }
|
||||
//
|
||||
//
|
||||
// } catch (Throwable e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
public WritableMCAChunk write(WritableMCAChunk chunk, int csx, int cex, int csz, int cez) {
|
||||
byte[] heights = this.heights.get();
|
||||
byte[] biomes = this.biomes.get();
|
||||
int[] main = this.main.get();
|
||||
int[] floor = this.floor.get();
|
||||
int[] overlay = this.overlay != null ? this.overlay.get() : null;
|
||||
try {
|
||||
int[] indexes = indexStore.get();
|
||||
|
||||
int index;
|
||||
int maxY = 0;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int[] heightMap = chunk.biomes;
|
||||
int globalIndex;
|
||||
for (int z = csz; z <= cez; z++) {
|
||||
globalIndex = z * getWidth() + csx;
|
||||
index = (z & 15) << 4;
|
||||
for (int x = csx; x <= cex; x++, index++, globalIndex++) {
|
||||
indexes[index] = globalIndex;
|
||||
int height = heights[globalIndex] & 0xFF;
|
||||
heightMap[index] = height;
|
||||
maxY = Math.max(maxY, height);
|
||||
minY = Math.min(minY, height);
|
||||
}
|
||||
}
|
||||
boolean hasOverlay = this.overlay != null;
|
||||
if (hasOverlay) {
|
||||
maxY++;
|
||||
}
|
||||
int maxLayer = maxY >> 4;
|
||||
for (int layer = 0; layer <= maxLayer; layer++) {
|
||||
chunk.hasSections[layer] = true;
|
||||
}
|
||||
if (primtives.waterHeight != 0) {
|
||||
int maxIndex = (primtives.waterHeight) << 8;
|
||||
Arrays.fill(chunk.blocks, 0, maxIndex, primtives.waterId);
|
||||
}
|
||||
|
||||
if (primtives.modifiedMain) { // If the main block is modified, we can't short circuit this
|
||||
for (int z = csz; z <= cez; z++) {
|
||||
index = (z & 15) << 4;
|
||||
for (int x = csx; x <= cex; x++, index++) {
|
||||
globalIndex = indexes[index];
|
||||
int mainCombined = main[globalIndex];
|
||||
for (int y = 0; y < minY; y++) {
|
||||
chunk.blocks[index + (y << 8)] = mainCombined;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int maxIndex = minY << 8;
|
||||
Arrays.fill(chunk.blocks, 0, maxIndex, BlockID.STONE);
|
||||
}
|
||||
|
||||
final boolean hasFloorThickness = primtives.floorThickness != 0 || primtives.worldThickness != 0;
|
||||
if (primtives.worldThickness != 0) {
|
||||
int endLayer = ((minY - primtives.worldThickness + 1) >> 4);
|
||||
for (int layer = 0; layer < endLayer; layer++) {
|
||||
chunk.hasSections[layer] = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = csz; z <= cez; z++) {
|
||||
index = (z & 15) << 4;
|
||||
for (int x = csx; x <= cex; x++, index++) {
|
||||
globalIndex = indexes[index];
|
||||
int height = heightMap[index];
|
||||
int maxMainY = height;
|
||||
int minMainY = minY;
|
||||
|
||||
int mainCombined = main[globalIndex];
|
||||
|
||||
int floorCombined = floor[globalIndex];
|
||||
if (hasFloorThickness) {
|
||||
if (x > 0) maxMainY = Math.min(heights[globalIndex - 1] & 0xFF, maxMainY);
|
||||
if (x < getWidth() - 1) maxMainY = Math.min(heights[globalIndex + 1] & 0xFF, maxMainY);
|
||||
if (z > 0) maxMainY = Math.min(heights[globalIndex - getWidth()] & 0xFF, maxMainY);
|
||||
if (z < getLength() - 1) maxMainY = Math.min(heights[globalIndex + getWidth()] & 0xFF, maxMainY);
|
||||
|
||||
int min = maxMainY;
|
||||
|
||||
if (primtives.floorThickness != 0) {
|
||||
maxMainY = Math.max(0, maxMainY - (primtives.floorThickness - 1));
|
||||
for (int y = maxMainY; y <= height; y++) {
|
||||
chunk.blocks[index + (y << 8)] = floorCombined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
chunk.blocks[index + ((height) << 8)] = floorCombined;
|
||||
}
|
||||
|
||||
if (primtives.worldThickness != 0) {
|
||||
minMainY = Math.max(minY, min - primtives.worldThickness + 1);
|
||||
for (int y = minY; y < minMainY; y++) {
|
||||
chunk.blocks[index + (y << 8)] = BlockID.AIR;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
chunk.blocks[index + ((height) << 8)] = floorCombined;
|
||||
}
|
||||
|
||||
for (int y = minMainY; y < maxMainY; y++) {
|
||||
chunk.blocks[index + (y << 8)] = mainCombined;
|
||||
}
|
||||
|
||||
if (hasOverlay) {
|
||||
int overlayCombined = overlay[globalIndex];
|
||||
int overlayIndex = index + ((height + 1) << 8);
|
||||
chunk.blocks[overlayIndex] = overlayCombined;
|
||||
}
|
||||
|
||||
if (primtives.bedrockId != 0) {
|
||||
chunk.blocks[index] = primtives.bedrockId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int[][][] localBlocks = getChunkArray(chunk.getX(), chunk.getZ());
|
||||
if (localBlocks != null) {
|
||||
index = 0;
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
int by = layer << 4;
|
||||
int ty = by + 15;
|
||||
for (int y = by; y <= ty; y++, index += 256) {
|
||||
int[][] yBlocks = localBlocks[y];
|
||||
if (yBlocks != null) {
|
||||
chunk.hasSections[layer] = true;
|
||||
for (int z = 0; z < yBlocks.length; z++) {
|
||||
int[] zBlocks = yBlocks[z];
|
||||
if (zBlocks != null) {
|
||||
int zIndex = index + (z << 4);
|
||||
for (int x = 0; x < zBlocks.length; x++, zIndex++) {
|
||||
int combined = zBlocks[x];
|
||||
if (combined == 0) continue;
|
||||
chunk.blocks[zIndex] = combined;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
chunk.biomes[i] = biomes[indexes[i]];
|
||||
}
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@ -2081,7 +1919,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
overlay.get()[index] = combined;
|
||||
}
|
||||
}
|
||||
@ -2100,7 +1938,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
main.get()[index] = combined;
|
||||
}
|
||||
}
|
||||
@ -2118,7 +1956,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
floor.get()[index] = combined;
|
||||
}
|
||||
}
|
||||
@ -2137,7 +1975,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
.nextInt(256) <= height) {
|
||||
main.get()[index] = combined;
|
||||
floor.get()[index] = combined;
|
||||
}
|
||||
@ -2275,27 +2113,27 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropItem(Vector3 position, BaseItemStack item) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void dropItem(Vector3 position, BaseItemStack item) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@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 boolean playEffect(Vector3 position, int type, int data) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getSpawnPosition() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getSpawnPosition() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ 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;
|
||||
@ -19,19 +22,7 @@ import java.util.function.BiConsumer;
|
||||
|
||||
public class MCAChunk extends FaweChunk<Void> {
|
||||
|
||||
// ids: byte[16][4096]
|
||||
// data: byte[16][2048]
|
||||
// skylight: byte[16][2048]
|
||||
// blocklight: byte[16][2048]
|
||||
// entities: Map<Short, CompoundTag>
|
||||
// tiles: List<CompoundTag>
|
||||
// biomes: byte[256]
|
||||
// compressedSize: int
|
||||
// modified: boolean
|
||||
// deleted: boolean
|
||||
|
||||
public byte[][] ids;
|
||||
public byte[][] data;
|
||||
public int[][] ids;
|
||||
public byte[][] skyLight;
|
||||
public byte[][] blockLight;
|
||||
public byte[] biomes;
|
||||
@ -46,8 +37,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
|
||||
public MCAChunk(FaweQueue queue, int x, int z) {
|
||||
super(queue, x, z);
|
||||
this.ids = new byte[16][];
|
||||
this.data = new byte[16][];
|
||||
this.ids = new int[16][];
|
||||
this.skyLight = new byte[16][];
|
||||
this.blockLight = new byte[16][];
|
||||
this.biomes = new byte[256];
|
||||
@ -62,7 +52,6 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
super(parent.getParent(), parent.getX(), parent.getZ());
|
||||
if (shallow) {
|
||||
this.ids = parent.ids;
|
||||
this.data = parent.data;
|
||||
this.skyLight = parent.skyLight;
|
||||
this.blockLight = parent.blockLight;
|
||||
this.biomes = parent.biomes;
|
||||
@ -74,8 +63,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
this.modified = parent.modified;
|
||||
this.deleted = parent.deleted;
|
||||
} else {
|
||||
this.ids = (byte[][]) MainUtil.copyNd(parent.ids);
|
||||
this.data = (byte[][]) MainUtil.copyNd(parent.data);
|
||||
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();
|
||||
@ -90,6 +78,9 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
}
|
||||
|
||||
public void write(NBTOutputStream nbtOut) throws IOException {
|
||||
|
||||
|
||||
|
||||
nbtOut.writeNamedTagName("", NBTConstants.TYPE_COMPOUND);
|
||||
nbtOut.writeLazyCompoundTag("Level", out -> {
|
||||
out.writeNamedTag("V", (byte) 1);
|
||||
@ -122,7 +113,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
}
|
||||
nbtOut.getOutputStream().writeInt(len);
|
||||
for (int layer = 0; layer < ids.length; layer++) {
|
||||
byte[] idLayer = ids[layer];
|
||||
int[] idLayer = ids[layer];
|
||||
if (idLayer == null) {
|
||||
continue;
|
||||
}
|
||||
@ -130,7 +121,6 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
out.writeNamedTag("BlockLight", blockLight[layer]);
|
||||
out.writeNamedTag("SkyLight", skyLight[layer]);
|
||||
out.writeNamedTag("Blocks", idLayer);
|
||||
out.writeNamedTag("Data", data[layer]);
|
||||
out.writeEndTag();
|
||||
}
|
||||
});
|
||||
@ -178,50 +168,43 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
for (int otherY = minY, thisY = minY + offsetY; otherY <= maxY; otherY++, thisY++) {
|
||||
int thisLayer = thisY >> 4;
|
||||
int otherLayer = otherY >> 4;
|
||||
byte[] thisIds = ids[thisLayer];
|
||||
byte[] otherIds = other.ids[otherLayer];
|
||||
int[] thisIds = ids[thisLayer];
|
||||
int[] otherIds = other.ids[otherLayer];
|
||||
if (otherIds == null) {
|
||||
if (thisIds != null) {
|
||||
int indexY = (thisY & 15) << 8;
|
||||
byte[] thisData = data[thisLayer];
|
||||
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;
|
||||
ArrayUtil.fill(thisIds, startIndex, endIndex + 1, (byte) 0);
|
||||
Arrays.fill(thisIds, startIndex, endIndex + 1, 0);
|
||||
int startIndexShift = startIndex >> 1;
|
||||
int endIndexShift = endIndex >> 1;
|
||||
if ((startIndex & 1) != 0) {
|
||||
startIndexShift++;
|
||||
setNibble(startIndex, thisData, (byte) 0);
|
||||
setNibble(startIndex, thisSkyLight, (byte) 0);
|
||||
setNibble(startIndex, thisBlockLight, (byte) 0);
|
||||
}
|
||||
if ((endIndex & 1) != 1) {
|
||||
endIndexShift--;
|
||||
setNibble(endIndex, thisData, (byte) 0);
|
||||
setNibble(endIndex, thisSkyLight, (byte) 0);
|
||||
setNibble(endIndex, thisBlockLight, (byte) 0);
|
||||
}
|
||||
ArrayUtil.fill(thisData, startIndexShift, endIndexShift + 1, (byte) 0);
|
||||
ArrayUtil.fill(thisSkyLight, startIndexShift, endIndexShift + 1, (byte) 0);
|
||||
ArrayUtil.fill(thisBlockLight, startIndexShift, endIndexShift + 1, (byte) 0);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
} else if (thisIds == null) {
|
||||
ids[thisLayer] = thisIds = new byte[4096];
|
||||
data[thisLayer] = new byte[2048];
|
||||
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[] thisData = data[thisLayer];
|
||||
byte[] thisSkyLight = skyLight[thisLayer];
|
||||
byte[] thisBlockLight = blockLight[thisLayer];
|
||||
byte[] otherData = other.data[otherLayer];
|
||||
byte[] otherSkyLight = other.skyLight[otherLayer];
|
||||
byte[] otherBlockLight = other.blockLight[otherLayer];
|
||||
for (int otherZ = minZ, thisZ = minZ + offsetZ; otherZ <= maxZ; otherZ++, thisZ++) {
|
||||
@ -234,27 +217,21 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
int startIndexShift = startIndex >> 1;
|
||||
int endIndexShift = endIndex >> 1;
|
||||
int otherStartIndexShift = otherStartIndex >> 1;
|
||||
int otherEndIndexShift = otherEndIndex >> 1;
|
||||
if ((startIndex & 1) != 0) {
|
||||
startIndexShift++;
|
||||
otherStartIndexShift++;
|
||||
setNibble(startIndex, thisData, getNibble(otherStartIndex, otherData));
|
||||
setNibble(startIndex, thisSkyLight, getNibble(otherStartIndex, otherSkyLight));
|
||||
setNibble(startIndex, thisBlockLight, getNibble(otherStartIndex, otherBlockLight));
|
||||
}
|
||||
if ((endIndex & 1) != 1) {
|
||||
endIndexShift--;
|
||||
otherEndIndexShift--;
|
||||
setNibble(endIndex, thisData, getNibble(otherEndIndex, otherData));
|
||||
setNibble(endIndex, thisSkyLight, getNibble(otherEndIndex, otherSkyLight));
|
||||
setNibble(endIndex, thisBlockLight, getNibble(otherEndIndex, otherBlockLight));
|
||||
}
|
||||
System.arraycopy(otherData, otherStartIndexShift, thisData, startIndexShift, endIndexShift - startIndexShift + 1);
|
||||
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, thisData, getNibble(otherIndex, otherData));
|
||||
setNibble(thisIndex, thisSkyLight, getNibble(otherIndex, otherSkyLight));
|
||||
setNibble(thisIndex, thisBlockLight, getNibble(otherIndex, otherBlockLight));
|
||||
}
|
||||
@ -293,14 +270,13 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
int startLayer = minY >> 4;
|
||||
int endLayer = maxY >> 4;
|
||||
for (int thisLayer = startLayer + offsetLayer, otherLayer = startLayer; thisLayer <= endLayer; thisLayer++, otherLayer++) {
|
||||
byte[] otherIds = other.ids[otherLayer];
|
||||
byte[] currentIds = ids[thisLayer];
|
||||
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;
|
||||
data[thisLayer] = other.data[otherLayer];
|
||||
skyLight[thisLayer] = other.skyLight[otherLayer];
|
||||
blockLight[thisLayer] = other.blockLight[otherLayer];
|
||||
} else {
|
||||
@ -315,20 +291,17 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
int indexEndShift = indexEnd >> 1;
|
||||
if (otherIds == null) {
|
||||
if (currentIds != null) {
|
||||
ArrayUtil.fill(currentIds, indexStart, indexEnd, (byte) 0);
|
||||
ArrayUtil.fill(data[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
||||
Arrays.fill(currentIds, indexStart, indexEnd, 0);
|
||||
ArrayUtil.fill(skyLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
||||
ArrayUtil.fill(blockLight[thisLayer], indexStartShift, indexEndShift, (byte) 0);
|
||||
}
|
||||
} else {
|
||||
if (currentIds == null) {
|
||||
currentIds = this.ids[thisLayer] = new byte[4096];
|
||||
this.data[thisLayer] = new byte[2048];
|
||||
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.data[otherLayer], indexStartShift, data[thisLayer], indexStartShift, indexEndShift - indexStartShift);
|
||||
System.arraycopy(other.skyLight[otherLayer], indexStartShift, skyLight[thisLayer], indexStartShift, indexEndShift - indexStartShift);
|
||||
System.arraycopy(other.blockLight[otherLayer], indexStartShift, blockLight[thisLayer], indexStartShift, indexEndShift - indexStartShift);
|
||||
}
|
||||
@ -338,29 +311,26 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
for (int otherY = minY, thisY = minY + offsetY; otherY <= maxY; otherY++, thisY++) {
|
||||
int otherLayer = otherY >> 4;
|
||||
int thisLayer = thisY >> 4;
|
||||
byte[] thisIds = this.ids[thisLayer];
|
||||
byte[] otherIds = other.ids[otherLayer];
|
||||
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;
|
||||
}
|
||||
ArrayUtil.fill(thisIds, thisStartIndex, thisStartIndex + 256, (byte) 0);
|
||||
ArrayUtil.fill(this.data[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
||||
Arrays.fill(thisIds, thisStartIndex, thisStartIndex + 256, 0);
|
||||
ArrayUtil.fill(this.skyLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
||||
ArrayUtil.fill(this.blockLight[thisLayer], thisStartIndexShift, thisStartIndexShift + 128, (byte) 0);
|
||||
continue;
|
||||
} else if (thisIds == null) {
|
||||
ids[thisLayer] = thisIds = new byte[4096];
|
||||
data[thisLayer] = new byte[2048];
|
||||
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.data[otherLayer], otherStartIndexShift, data[thisLayer], thisStartIndexShift, 128);
|
||||
System.arraycopy(other.skyLight[otherLayer], otherStartIndexShift, skyLight[thisLayer], thisStartIndexShift, 128);
|
||||
System.arraycopy(other.blockLight[otherLayer], otherStartIndexShift, blockLight[thisLayer], thisStartIndexShift, 128);
|
||||
}
|
||||
@ -386,7 +356,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
}
|
||||
if (!other.entities.isEmpty()) {
|
||||
for (Map.Entry<UUID, CompoundTag> entry : other.entities.entrySet()) {
|
||||
// TODO
|
||||
// TODO FIXME
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -436,7 +406,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
level.put("HeightMap", heightMap);
|
||||
ArrayList<HashMap<String, Object>> sections = new ArrayList<>();
|
||||
for (int layer = 0; layer < ids.length; layer++) {
|
||||
byte[] idLayer = ids[layer];
|
||||
int[] idLayer = ids[layer];
|
||||
if (idLayer == null) {
|
||||
continue;
|
||||
}
|
||||
@ -445,7 +415,6 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
map.put("BlockLight", blockLight[layer]);
|
||||
map.put("SkyLight", skyLight[layer]);
|
||||
map.put("Blocks", idLayer);
|
||||
map.put("Data", data[layer]);
|
||||
sections.add(map);
|
||||
}
|
||||
level.put("Sections", sections);
|
||||
@ -456,8 +425,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
|
||||
public MCAChunk(NBTInputStream nis, FaweQueue parent, int x, int z, boolean readPos) throws IOException {
|
||||
super(parent, x, z);
|
||||
ids = new byte[16][];
|
||||
data = new byte[16][];
|
||||
ids = new int[16][];
|
||||
skyLight = new byte[16][];
|
||||
blockLight = new byte[16][];
|
||||
NBTStreamer streamer = new NBTStreamer(nis);
|
||||
@ -467,8 +435,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
(BiConsumer<Integer, Long>) (index, value) -> lastUpdate = value);
|
||||
streamer.addReader(".Level.Sections.#", (BiConsumer<Integer, CompoundTag>) (index, tag) -> {
|
||||
int layer = tag.getByte("Y");
|
||||
ids[layer] = tag.getByteArray("Blocks");
|
||||
data[layer] = tag.getByteArray("Data");
|
||||
ids[layer] = tag.getIntArray("Blocks");
|
||||
skyLight[layer] = tag.getByteArray("SkyLight");
|
||||
blockLight[layer] = tag.getByteArray("BlockLight");
|
||||
});
|
||||
@ -590,9 +557,9 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, byte biome) {
|
||||
public void setBiome(int x, int z, BiomeType biome) {
|
||||
setModified();
|
||||
biomes[x + (z << 4)] = biome;
|
||||
biomes[x + (z << 4)] = (byte) biome.getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -625,27 +592,26 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
|
||||
@Override
|
||||
public int getBlockCombinedId(int x, int y, int z) {
|
||||
// TODO FIXME
|
||||
return 0;
|
||||
// int layer = y >> 4;
|
||||
// byte[] idLayer = ids[layer];
|
||||
// if (idLayer == null) {
|
||||
// return 0;
|
||||
// }
|
||||
// int j = FaweCache.CACHE_J[y][z & 15][x & 15];
|
||||
// int id = idLayer[j] & 0xFF;
|
||||
// if (FaweCache.hasData(id)) {
|
||||
// byte[] dataLayer = data[layer];
|
||||
// if (dataLayer != null) {
|
||||
// return (id << 4) + getNibble(j, dataLayer);
|
||||
// }
|
||||
// }
|
||||
// return id << 4;
|
||||
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 byte[] getBiomeArray() {
|
||||
return this.biomes;
|
||||
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
|
||||
@ -660,8 +626,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
if (skyLayer == null) {
|
||||
return;
|
||||
}
|
||||
int index = FaweCache.CACHE_J[y][z & 15][x & 15];
|
||||
setNibble(index, skyLayer, value);
|
||||
setNibble((((y & 15) << 8) | ((z & 15) << 4) | (x & 15)), skyLayer, value);
|
||||
}
|
||||
|
||||
public void setBlockLight(int x, int y, int z, int value) {
|
||||
@ -671,8 +636,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
if (blockLayer == null) {
|
||||
return;
|
||||
}
|
||||
int index = FaweCache.CACHE_J[y][z & 15][x & 15];
|
||||
setNibble(index, blockLayer, value);
|
||||
setNibble((((y & 15) << 8) | ((z & 15) << 4) | (x & 15)), blockLayer, value);
|
||||
}
|
||||
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
@ -681,8 +645,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
if (skyLayer == null) {
|
||||
return 0;
|
||||
}
|
||||
int index = FaweCache.CACHE_J[y][z & 15][x & 15];
|
||||
return getNibble(index, skyLayer);
|
||||
return getNibble((((y & 15) << 8) | ((z & 15) << 4) | (x & 15)), skyLayer);
|
||||
}
|
||||
|
||||
public int getBlockLight(int x, int y, int z) {
|
||||
@ -691,8 +654,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
if (blockLayer == null) {
|
||||
return 0;
|
||||
}
|
||||
int index = FaweCache.CACHE_J[y][z & 15][x & 15];
|
||||
return getNibble(index, blockLayer);
|
||||
return getNibble((((y & 15) << 8) | ((z & 15) << 4) | (x & 15)), blockLayer);
|
||||
}
|
||||
|
||||
public void setFullbright() {
|
||||
@ -754,25 +716,20 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, int combinedId) {
|
||||
// TODO FIXME
|
||||
// setModified();
|
||||
// int layer = y >> 4;
|
||||
// byte[] idsLayer = ids[layer];
|
||||
// if (idsLayer == null) {
|
||||
// idsLayer = this.ids[layer] = new byte[4096];
|
||||
// this.data[layer] = new byte[2048];
|
||||
// this.skyLight[layer] = new byte[2048];
|
||||
// this.blockLight[layer] = new byte[2048];
|
||||
// }
|
||||
// int j = FaweCache.CACHE_J[y][z & 15][x & 15];
|
||||
// idsLayer[j] = (byte) id;
|
||||
// byte[] dataLayer = this.data[layer];
|
||||
// setNibble(j, dataLayer, data);
|
||||
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(byte biome) {
|
||||
Arrays.fill(biomes, biome);
|
||||
public void setBiome(BiomeType biome) {
|
||||
Arrays.fill(biomes, (byte) biome.getInternalId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -781,7 +738,7 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
entities.remove(uuid);
|
||||
}
|
||||
|
||||
private final boolean idsEqual(byte[] a, byte[] b) {
|
||||
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;
|
||||
@ -791,17 +748,17 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
return true;
|
||||
}
|
||||
|
||||
private final boolean idsEqual(byte[][] a, byte[][] b, boolean matchNullToAir) {
|
||||
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 (byte c : b[i]) {
|
||||
for (int c : b[i]) {
|
||||
if (c != 0) return false;
|
||||
}
|
||||
} else if (a[i] != null) {
|
||||
for (byte c : a[i]) {
|
||||
for (int c : a[i]) {
|
||||
if (c != 0) return false;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ 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.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@ -86,13 +86,13 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiome(FaweChunk faweChunk, int x, int z) {
|
||||
public BiomeType getBiome(FaweChunk faweChunk, int x, int z) {
|
||||
if (faweChunk instanceof MCAChunk) {
|
||||
return ((MCAChunk) faweChunk).getBiomeArray()[((z & 0xF) << 4 | x & 0xF)];
|
||||
return ((MCAChunk) faweChunk).getBiomeType(x, z);
|
||||
} else if (parent != null) {
|
||||
return parent.getBiomeId(x, z);
|
||||
return parent.getBiomeType(x, z);
|
||||
} else {
|
||||
return 0;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,12 +643,7 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(FaweQueue faweQueue, int x, int z, BaseBiome biome, Long seed) {
|
||||
throw new UnsupportedOperationException("Not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntFaweChunk getPrevious(IntFaweChunk fs, FaweChunk sections, Map<?, ?> tiles, Collection<?>[] entities, Set<UUID> createdEntities, boolean all) throws Exception {
|
||||
public boolean regenerateChunk(FaweQueue faweQueue, int x, int z, BiomeType biome, Long seed) {
|
||||
throw new UnsupportedOperationException("Not supported");
|
||||
}
|
||||
|
||||
@ -657,21 +652,6 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
|
||||
MCAChunk mca = (MCAChunk) chunk;
|
||||
if (mca != null) {
|
||||
int[] otherMap = mca.getHeightMapArray();
|
||||
for (int i = 0; i < heightMap.length; i++) {
|
||||
int newHeight = heightMap[i] & 0xFF;
|
||||
int currentHeight = otherMap[i];
|
||||
if (newHeight > currentHeight) {
|
||||
otherMap[i] = newHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFullbright(FaweChunk sections) {
|
||||
if (sections.getClass() == MCAChunk.class) {
|
||||
|
@ -19,7 +19,7 @@ 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.BaseBiome;
|
||||
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;
|
||||
@ -108,12 +108,12 @@ public class MCAWorld implements SimpleWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return extent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return extent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,11 @@ package com.boydti.fawe.jnbt.anvil;
|
||||
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
||||
import com.boydti.fawe.object.io.BufferedRandomAccessFile;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.Deflater;
|
||||
@ -67,22 +70,21 @@ public abstract class MCAWriter {
|
||||
|
||||
public abstract boolean shouldWrite(int chunkX, int chunkZ);
|
||||
|
||||
public abstract MCAChunk write(MCAChunk input, int startX, int endX, int startZ, int endZ);
|
||||
public abstract WritableMCAChunk write(WritableMCAChunk input, int startX, int endX, int startZ, int endZ);
|
||||
|
||||
public void generate() throws IOException {
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
final ForkJoinPool pool = new ForkJoinPool();
|
||||
int bcx = 0;
|
||||
int bcz = 0;
|
||||
int tcx = (width - 1) >> 4;
|
||||
int tcz = (length - 1) >> 4;
|
||||
final ThreadLocal<MCAChunk> chunkStore = new ThreadLocal<MCAChunk>() {
|
||||
final ThreadLocal<WritableMCAChunk> chunkStore = new ThreadLocal<WritableMCAChunk>() {
|
||||
@Override
|
||||
protected MCAChunk initialValue() {
|
||||
MCAChunk chunk = new MCAChunk(null, 0, 0);
|
||||
chunk.biomes = new byte[256];
|
||||
protected WritableMCAChunk initialValue() {
|
||||
WritableMCAChunk chunk = new WritableMCAChunk();
|
||||
Arrays.fill(chunk.blocks, BlockID.AIR);
|
||||
// Arrays.fill(chunk.skyLight, (byte) 255);
|
||||
return chunk;
|
||||
}
|
||||
};
|
||||
@ -111,16 +113,15 @@ public abstract class MCAWriter {
|
||||
int mcaXMax = mcaXMin + ((width - 1) >> 9);
|
||||
int mcaZMax = mcaZMin + ((length - 1) >> 9);
|
||||
|
||||
final byte[] header = new byte[4096];
|
||||
|
||||
for (int mcaZ = mcaXMin; mcaZ <= mcaZMax; mcaZ++) {
|
||||
for (int mcaX = mcaXMin; mcaX <= mcaXMax; mcaX++) {
|
||||
final int fmcaX = mcaX;
|
||||
final int fmcaZ = mcaZ;
|
||||
File file = new File(folder, "r." + (mcaX + (getOffsetX() >> 9)) + "." + (mcaZ + (getOffsetZ() >> 9)) + ".mca");
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
final BufferedRandomAccessFile raf = new BufferedRandomAccessFile(file, "rw", fileBuf);
|
||||
final byte[] header = new byte[4096];
|
||||
final byte[][] compressed = new byte[1024][];
|
||||
int bx = mcaX << 9;
|
||||
int bz = mcaZ << 9;
|
||||
@ -137,76 +138,70 @@ public abstract class MCAWriter {
|
||||
final int fcx = cx;
|
||||
final int fcz = cz;
|
||||
if (shouldWrite(cx, cz)) {
|
||||
pool.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
MCAChunk chunk = chunkStore.get();
|
||||
chunk.setLoc(null, fcx, fcz);
|
||||
chunk = write(chunk, csx, cex, csz, cez);
|
||||
if (chunk != null) {
|
||||
// Generation offset
|
||||
chunk.setLoc(null, fcx + (getOffsetX() >> 4), fcz + (getOffsetZ() >> 4));
|
||||
// Compress
|
||||
byte[] bytes = chunk.toBytes(byteStore1.get());
|
||||
byte[] compressedBytes = MainUtil.compress(bytes, byteStore2.get(), deflateStore.get());
|
||||
int blocks = (compressed.length + 4095) >> 12;
|
||||
compressed[((fcx & 31)) + ((fcz & 31) << 5)] = compressedBytes.clone();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
pool.submit(() -> {
|
||||
try {
|
||||
WritableMCAChunk chunk = chunkStore.get();
|
||||
chunk.clear(fcx, fcz);
|
||||
chunk = write(chunk, csx, cex, csz, cez);
|
||||
if (chunk != null) {
|
||||
// Generation offset
|
||||
chunk.setLoc( fcx + (getOffsetX() >> 4), fcz + (getOffsetZ() >> 4));
|
||||
|
||||
// Compress
|
||||
byte[] bytes = chunk.toBytes(byteStore1.get());
|
||||
byte[] compressedBytes = MainUtil.compress(bytes, byteStore2.get(), deflateStore.get());
|
||||
|
||||
// TODO optimize (avoid cloning) by add a synchronized block and write to the RAF here instead of below
|
||||
compressed[((fcx & 31)) + ((fcz & 31) << 5)] = compressedBytes.clone();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
|
||||
pool.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pool.submit(() -> {
|
||||
try {
|
||||
int totalLength = 8192;
|
||||
for (int i = 0; i < compressed.length; i++) {
|
||||
byte[] compressedBytes = compressed[i];
|
||||
if (compressedBytes != null) {
|
||||
int blocks = ((4095 + compressedBytes.length + 5) / 4096) * 4096;
|
||||
totalLength += blocks;
|
||||
}
|
||||
}
|
||||
raf.setLength(totalLength);
|
||||
int offset = 8192;
|
||||
for (int i = 0; i < compressed.length; i++) {
|
||||
byte[] compressedBytes = compressed[i];
|
||||
if (compressedBytes != null) {
|
||||
// Set header
|
||||
int index = i << 2;
|
||||
int offsetMedium = offset >> 12;
|
||||
int blocks = ((4095 + compressedBytes.length + 5) / 4096);
|
||||
header[index] = (byte) (offsetMedium >> 16);
|
||||
header[index + 1] = (byte) ((offsetMedium >> 8));
|
||||
header[index + 2] = (byte) ((offsetMedium >> 0));
|
||||
header[index + 3] = (byte) (blocks);
|
||||
// Write bytes
|
||||
raf.seek(offset);
|
||||
raf.writeInt(compressedBytes.length + 1);
|
||||
raf.write(2);
|
||||
raf.write(compressedBytes);
|
||||
offset += blocks * 4096;
|
||||
}
|
||||
}
|
||||
raf.seek(0);
|
||||
raf.write(header);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
int totalLength = 8192;
|
||||
for (int i = 0; i < compressed.length; i++) {
|
||||
byte[] compressedBytes = compressed[i];
|
||||
if (compressedBytes != null) {
|
||||
int blocks = ((4095 + compressedBytes.length + 5) / 4096) * 4096;
|
||||
totalLength += blocks;
|
||||
}
|
||||
}
|
||||
raf.setLength(totalLength);
|
||||
int offset = 8192;
|
||||
for (int i = 0; i < compressed.length; i++) {
|
||||
byte[] compressedBytes = compressed[i];
|
||||
if (compressedBytes != null) {
|
||||
// Set header
|
||||
int index = i << 2;
|
||||
int offsetMedium = offset >> 12;
|
||||
int blocks = ((4095 + compressedBytes.length + 5) / 4096);
|
||||
header[index] = (byte) (offsetMedium >> 16);
|
||||
header[index + 1] = (byte) ((offsetMedium >> 8));
|
||||
header[index + 2] = (byte) ((offsetMedium >> 0));
|
||||
header[index + 3] = (byte) (blocks);
|
||||
// Write bytes
|
||||
int cx = (fmcaX << 5) + (i & 31);
|
||||
int cz = (fmcaZ << 5) + (i >> 5);
|
||||
raf.seek(offset);
|
||||
raf.writeInt(compressedBytes.length + 1);
|
||||
raf.write(2);
|
||||
raf.write(compressedBytes);
|
||||
offset += blocks * 4096;
|
||||
}
|
||||
}
|
||||
raf.seek(0);
|
||||
raf.write(header);
|
||||
raf.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
raf.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -12,8 +12,7 @@ import javax.annotation.Nullable;
|
||||
public class MutableMCABackedBaseBlock extends BaseBlock {
|
||||
|
||||
private MCAChunk chunk;
|
||||
private byte[] data;
|
||||
private byte[] ids;
|
||||
private int[] ids;
|
||||
private int index;
|
||||
private int x;
|
||||
private int y;
|
||||
@ -29,7 +28,6 @@ public class MutableMCABackedBaseBlock extends BaseBlock {
|
||||
|
||||
public void setArrays(int layer) {
|
||||
ids = chunk.ids[layer];
|
||||
data = chunk.data[layer];
|
||||
}
|
||||
|
||||
public MCAChunk getChunk() {
|
||||
@ -79,11 +77,7 @@ public class MutableMCABackedBaseBlock extends BaseBlock {
|
||||
return chunk.getTile(x, y, z);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setId(int id) {
|
||||
// ids[index] = (byte) id;
|
||||
// chunk.setModified();
|
||||
// }
|
||||
|
||||
//
|
||||
// @Override
|
||||
// public void setData(int value) {
|
||||
|
@ -0,0 +1,419 @@
|
||||
package com.boydti.fawe.jnbt.anvil;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTConstants;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class WritableMCAChunk extends FaweChunk<Void> {
|
||||
public final boolean[] hasSections = new boolean[16];
|
||||
public final byte[] skyLight = new byte[65536];
|
||||
public final byte[] blockLight = new byte[65536];
|
||||
|
||||
public boolean hasBiomes = false;
|
||||
public final int[] biomes = new int[256];
|
||||
|
||||
public final int[] blocks = new int[65536];
|
||||
|
||||
public Map<Short, CompoundTag> tiles = new HashMap<>();
|
||||
public Map<UUID, CompoundTag> entities = new HashMap<>();
|
||||
public long inhabitedTime = System.currentTimeMillis();
|
||||
public long lastUpdate;
|
||||
|
||||
public int modified;
|
||||
public boolean deleted;
|
||||
|
||||
public int chunkX, chunkZ;
|
||||
|
||||
protected WritableMCAChunk() {
|
||||
super(null, 0, 0);
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return chunkX;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return chunkZ;
|
||||
}
|
||||
|
||||
public void setLoc(int X, int Z) {
|
||||
this.chunkX = X;
|
||||
this.chunkZ = Z;
|
||||
}
|
||||
|
||||
public void clear(int X, int Z) {
|
||||
this.chunkX = X;
|
||||
this.chunkZ = Z;
|
||||
if (!tiles.isEmpty()) {
|
||||
tiles.clear();
|
||||
}
|
||||
if (!entities.isEmpty()) {
|
||||
entities.clear();
|
||||
}
|
||||
modified = 0;
|
||||
deleted = false;
|
||||
hasBiomes = false;
|
||||
// TODO optimize
|
||||
for (int i = 0; i < 65536; i++) {
|
||||
blocks[i] = BlockID.AIR;
|
||||
}
|
||||
Arrays.fill(hasSections, false);
|
||||
}
|
||||
|
||||
public void write(NBTOutputStream nbtOut) throws IOException {
|
||||
int[] blockToPalette = FaweCache.BLOCK_TO_PALETTE.get();
|
||||
int[] paletteToBlock = FaweCache.PALETTE_TO_BLOCK.get();
|
||||
long[] blockstates = FaweCache.BLOCK_STATES.get();
|
||||
int[] blocksCopy = FaweCache.SECTION_BLOCKS.get();
|
||||
|
||||
nbtOut.writeNamedTagName("", NBTConstants.TYPE_COMPOUND);
|
||||
nbtOut.writeNamedTag("DataVersion", 1631);
|
||||
nbtOut.writeLazyCompoundTag("Level", out -> {
|
||||
// out.writeNamedTag("V", (byte) 1);
|
||||
out.writeNamedTag("Status", "decorated");
|
||||
out.writeNamedTag("xPos", getX());
|
||||
out.writeNamedTag("zPos", getZ());
|
||||
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);
|
||||
}
|
||||
int len = 0;
|
||||
for (int layer = 0; layer < hasSections.length; layer++) {
|
||||
if (hasSections[layer]) len++;
|
||||
}
|
||||
out.writeNamedTagName("Sections", NBTConstants.TYPE_LIST);
|
||||
nbtOut.writeByte(NBTConstants.TYPE_COMPOUND);
|
||||
nbtOut.writeInt(len);
|
||||
|
||||
for (int layer = 0; layer < hasSections.length; layer++) {
|
||||
if (!hasSections[layer]) continue;
|
||||
out.writeNamedTag("Y", (byte) layer);
|
||||
|
||||
int blockIndexStart = layer << 12;
|
||||
int blockIndexEnd = blockIndexStart + 4096;
|
||||
int num_palette = 0;
|
||||
try {
|
||||
for (int i = blockIndexStart, j = 0; i < blockIndexEnd; i++, j++) {
|
||||
int stateId = blocks[i];
|
||||
int ordinal = BlockState.getFromInternalId(stateId).getOrdinal(); // TODO fixme Remove all use of BlockTypes.BIT_OFFSET so that this conversion isn't necessary
|
||||
int palette = blockToPalette[ordinal];
|
||||
if (palette == Integer.MAX_VALUE) {
|
||||
BlockState state = BlockTypes.states[ordinal];
|
||||
blockToPalette[ordinal] = palette = num_palette;
|
||||
paletteToBlock[num_palette] = ordinal;
|
||||
num_palette++;
|
||||
}
|
||||
blocksCopy[j] = palette;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_palette; i++) {
|
||||
blockToPalette[paletteToBlock[i]] = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
out.writeNamedTagName("Palette", NBTConstants.TYPE_LIST);
|
||||
out.writeByte(NBTConstants.TYPE_COMPOUND);
|
||||
out.writeInt(num_palette);
|
||||
|
||||
for (int i = 0; i < num_palette; i++) {
|
||||
int ordinal = paletteToBlock[i];
|
||||
BlockState state = BlockTypes.states[ordinal];
|
||||
BlockType type = state.getBlockType();
|
||||
out.writeNamedTag("Name", type.getId());
|
||||
|
||||
// Has no properties
|
||||
if (type.getDefaultState() != state) {
|
||||
// Write properties
|
||||
out.writeNamedTagName("Properties", NBTConstants.TYPE_COMPOUND);
|
||||
for (Property<?> property : type.getProperties()) {
|
||||
String key = property.getName();
|
||||
Object value = state.getState(property);
|
||||
String valueStr = value.toString();
|
||||
if (Character.isUpperCase(valueStr.charAt(0))) {
|
||||
System.out.println("Invalid uppercase value " + value);
|
||||
valueStr = valueStr.toLowerCase();
|
||||
}
|
||||
out.writeNamedTag(key, valueStr);
|
||||
}
|
||||
out.writeEndTag();
|
||||
}
|
||||
out.writeEndTag();
|
||||
}
|
||||
|
||||
|
||||
// BlockStates
|
||||
int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
|
||||
int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6;
|
||||
if (num_palette == 1) {
|
||||
// Set a value, because minecraft needs it for some reason
|
||||
blockstates[0] = 0;
|
||||
blockBitArrayEnd = 1;
|
||||
} else {
|
||||
BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry);
|
||||
bitArray.fromRaw(blocksCopy);
|
||||
}
|
||||
|
||||
out.writeNamedTagName("BlockStates", NBTConstants.TYPE_LONG_ARRAY);
|
||||
out.writeInt(blockBitArrayEnd);
|
||||
for (int i = 0; i < blockBitArrayEnd; i++) out.writeLong(blockstates[i]);
|
||||
|
||||
|
||||
out.writeNamedTagName("BlockLight", NBTConstants.TYPE_BYTE_ARRAY);
|
||||
out.writeInt(2048);
|
||||
out.write(blockLight, layer << 11, 1 << 11);
|
||||
|
||||
out.writeNamedTagName("SkyLight", NBTConstants.TYPE_BYTE_ARRAY);
|
||||
out.writeInt(2048);
|
||||
out.write(skyLight, layer << 11, 1 << 11);
|
||||
|
||||
|
||||
out.writeEndTag();
|
||||
|
||||
// cleanup
|
||||
} catch (Throwable e) {
|
||||
Arrays.fill(blockToPalette, Integer.MAX_VALUE);
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
nbtOut.writeEndTag();
|
||||
}
|
||||
|
||||
public byte[] toBytes(byte[] buffer) throws IOException {
|
||||
if (buffer == null) {
|
||||
buffer = new byte[8192];
|
||||
}
|
||||
FastByteArrayOutputStream buffered = new FastByteArrayOutputStream(buffer);
|
||||
DataOutputStream dataOut = new DataOutputStream(buffered);
|
||||
try (NBTOutputStream nbtOut = new NBTOutputStream((DataOutput) dataOut)) {
|
||||
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 setDeleted(boolean deleted) {
|
||||
setModified();
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return modified != 0;
|
||||
}
|
||||
|
||||
public int getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public final void setModified() {
|
||||
this.modified++;
|
||||
}
|
||||
|
||||
public int getBitMask() {
|
||||
int bitMask = 0;
|
||||
for (int section = 0; section < hasSections.length; section++) {
|
||||
if (hasSections[section]) {
|
||||
bitMask += 1 << section;
|
||||
}
|
||||
}
|
||||
return bitMask;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEntity(CompoundTag entityTag) {
|
||||
setModified();
|
||||
long least = entityTag.getLong("UUIDLeast");
|
||||
long most = entityTag.getLong("UUIDMost");
|
||||
entities.put(new UUID(most, least), entityTag);
|
||||
}
|
||||
|
||||
public void setBiome(int x, int z, BiomeType biome) {
|
||||
setModified();
|
||||
biomes[x + (z << 4)] = biome.getInternalId();
|
||||
}
|
||||
|
||||
public Set<CompoundTag> getEntities() {
|
||||
return new HashSet<>(entities.values());
|
||||
}
|
||||
|
||||
public Map<Short, CompoundTag> getTiles() {
|
||||
return tiles == null ? new HashMap<>() : tiles;
|
||||
}
|
||||
|
||||
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 hasSections[cy];
|
||||
}
|
||||
|
||||
private final int getIndex(int x, int y, int z) {
|
||||
return x | (z << 4) | (y << 8);
|
||||
}
|
||||
|
||||
public int getBlockCombinedId(int x, int y, int z) {
|
||||
return blocks[x | (z << 4) | (y << 8)];
|
||||
}
|
||||
|
||||
public BiomeType[] getBiomeArray() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<UUID> getEntityRemoves() {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
public void setSkyLight(int x, int y, int z, int value) {
|
||||
setNibble(getIndex(x, y, z), skyLight, value);
|
||||
}
|
||||
|
||||
public void setBlockLight(int x, int y, int z, int value) {
|
||||
setNibble(getIndex(x, y, z), blockLight, value);
|
||||
}
|
||||
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
if (!hasSections[y >> 4]) return 0;
|
||||
return getNibble(getIndex(x, y, z), skyLight);
|
||||
}
|
||||
|
||||
public int getBlockLight(int x, int y, int z) {
|
||||
if (!hasSections[y >> 4]) return 0;
|
||||
return getNibble(getIndex(x, y, z), blockLight);
|
||||
}
|
||||
|
||||
public void setFullbright() {
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
if (hasSections[layer]) {
|
||||
Arrays.fill(skyLight, layer << 7, ((layer + 1) << 7), (byte) 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeLight() {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
removeLight(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeLight(int i) {
|
||||
if (hasSections[i]) {
|
||||
Arrays.fill(skyLight, i << 7, ((i + 1) << 7), (byte) 0);
|
||||
Arrays.fill(blockLight, i << 7, ((i + 1) << 7), (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 setBlock(int x, int y, int z, int combinedId) {
|
||||
blocks[getIndex(x, y, z)] = combinedId;
|
||||
}
|
||||
|
||||
public void setBiome(BiomeType biome) {
|
||||
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");
|
||||
}
|
||||
}
|
@ -29,10 +29,10 @@ public class CountIdFilter extends MCAFilterCounter {
|
||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong count) {
|
||||
// TODO FIXME
|
||||
for (int layer = 0; layer < chunk.ids.length; layer++) {
|
||||
byte[] ids = chunk.ids[layer];
|
||||
int[] ids = chunk.ids[layer];
|
||||
if (ids != null) {
|
||||
for (byte i : ids) {
|
||||
if (allowedId[i & 0xFF]) {
|
||||
for (int i : ids) {
|
||||
if (allowedId[BlockTypes.getFromStateId(i).getInternalId()]) {
|
||||
count.increment();
|
||||
}
|
||||
}
|
||||
|
@ -1,85 +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.jnbt.anvil.MCAFilterCounter;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.number.MutableLong;
|
||||
|
||||
// TODO FIXME
|
||||
public class DebugFixAir extends MCAFilterCounter {
|
||||
@Override
|
||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
||||
none:
|
||||
{
|
||||
some:
|
||||
{
|
||||
for (int layer = 0; layer < chunk.ids.length; layer++) {
|
||||
byte[] idLayer = chunk.ids[layer];
|
||||
if (idLayer == null) continue;
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
if (idLayer[i] != 0) {
|
||||
if (layer != 0) break some;
|
||||
break none;
|
||||
}
|
||||
}
|
||||
{ // Possibly dead code depending on the generator
|
||||
chunk.ids[layer] = null;
|
||||
chunk.data[layer] = null;
|
||||
chunk.setModified();
|
||||
}
|
||||
}
|
||||
cache.add(Character.MAX_VALUE);
|
||||
chunk.setDeleted(true);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (chunk.ids[i] == null) return null;
|
||||
}
|
||||
// // layer 0
|
||||
// boolean modified = false;
|
||||
// byte[] ids0 = chunk.ids[0];
|
||||
// for (int i = 0; i < 256; i++) {
|
||||
// if (ids0[i] == 0) {
|
||||
// if (!modified) {
|
||||
// modified = true;
|
||||
// }
|
||||
// for (int layer = 0; layer < 4; layer++) {
|
||||
// byte[] arr = chunk.ids[layer];
|
||||
// for (int y = i; y < 4096; y += 256) {
|
||||
// arr[y] = BlockTypes.DIRT;
|
||||
// }
|
||||
// }
|
||||
// ids0[i] = BlockTypes.BEDROCK;
|
||||
// if (chunk.ids[4][i] == 0) chunk.ids[4][i] = BlockTypes.GRASS;
|
||||
// cache.add(256);
|
||||
// }
|
||||
// }
|
||||
// if (modified) {
|
||||
// Arrays.fill(chunk.skyLight[4], (byte) 255);
|
||||
// chunk.setModified();
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishFile(MCAFile file, MutableLong cache) {
|
||||
Fawe.debug(" - apply " + file.getFile());
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,13 +3,13 @@ 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.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
public class DeleteBiomeFilterSimple extends MCAFilterCounter {
|
||||
private final int id;
|
||||
|
||||
public DeleteBiomeFilterSimple(BaseBiome biome) {
|
||||
this.id = biome.getId();
|
||||
public DeleteBiomeFilterSimple(BiomeType biome) {
|
||||
this.id = biome.getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -167,10 +167,10 @@ public class PlotTrimFilter extends DeleteUninhabitedFilter {
|
||||
}
|
||||
if (referenceIsVoid) {
|
||||
for (int i = 0; i < chunk.ids.length; i++) {
|
||||
byte[] arr = chunk.ids[i];
|
||||
int[] arr = chunk.ids[i];
|
||||
if (arr != null) {
|
||||
for (byte b : arr) {
|
||||
if (b != 0) return;
|
||||
for (int b : arr) {
|
||||
if (!BlockTypes.getFromStateId(b).getMaterial().isAir()) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import com.boydti.fawe.jnbt.anvil.MCAChunk;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
|
||||
import com.boydti.fawe.object.number.MutableLong;
|
||||
import com.boydti.fawe.util.ArrayUtil;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RemoveLayerFilter extends MCAFilterCounter {
|
||||
private final int startLayer;
|
||||
@ -23,7 +26,7 @@ public class RemoveLayerFilter extends MCAFilterCounter {
|
||||
@Override
|
||||
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
|
||||
for (int layer = startLayer; layer <= endLayer; layer++) {
|
||||
byte[] ids = chunk.ids[layer];
|
||||
int[] ids = chunk.ids[layer];
|
||||
if (ids == null) {
|
||||
return null;
|
||||
}
|
||||
@ -41,7 +44,7 @@ public class RemoveLayerFilter extends MCAFilterCounter {
|
||||
for (int y = startY; y <= endY; y++) {
|
||||
int indexStart = y << 8;
|
||||
int indexEnd = indexStart + 255;
|
||||
ArrayUtil.fill(ids, indexStart, indexEnd + 1, (byte) 0);
|
||||
Arrays.fill(ids, indexStart, indexEnd + 1, BlockTypes.AIR.getInternalId());
|
||||
}
|
||||
chunk.setModified();
|
||||
}
|
||||
|
@ -5,21 +5,21 @@ 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++) {
|
||||
byte[] idLayer = chunk.ids[layer];
|
||||
int[] idLayer = chunk.ids[layer];
|
||||
if (idLayer == null) continue;
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
if (idLayer[i] != 0) {
|
||||
if (!BlockTypes.getFromStateId(idLayer[i]).getMaterial().isAir()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
{ // Possibly dead code depending on the generator
|
||||
chunk.ids[layer] = null;
|
||||
chunk.data[layer] = null;
|
||||
chunk.setModified();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -176,8 +177,11 @@ public class CavesGen extends GenBase {
|
||||
BlockStateHolder material = chunk.getLazyBlock(bx + local_x, local_y, bz + local_z);
|
||||
BlockStateHolder materialAbove = chunk.getLazyBlock(bx + local_x, local_y + 1, bz + local_z);
|
||||
BlockType blockType = material.getBlockType();
|
||||
if (blockType == BlockTypes.MYCELIUM || blockType == BlockTypes.GRASS) {
|
||||
grassFound = true;
|
||||
switch (blockType.getInternalId()) {
|
||||
case BlockID.MYCELIUM:
|
||||
case BlockID.GRASS:
|
||||
grassFound = true;
|
||||
|
||||
}
|
||||
if (this.isSuitableBlock(material, materialAbove)) {
|
||||
if (local_y - 1 < 10) {
|
||||
@ -206,13 +210,13 @@ public class CavesGen extends GenBase {
|
||||
}
|
||||
|
||||
protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) {
|
||||
switch (material.getBlockType().getResource().toUpperCase()) {
|
||||
case "AIR":
|
||||
case "CAVE_AIR":
|
||||
case "VOID_AIR":
|
||||
case "WATER":
|
||||
case "LAVA":
|
||||
case "BEDROCK":
|
||||
switch (material.getBlockType().getInternalId()) {
|
||||
case BlockID.AIR:
|
||||
case BlockID.CAVE_AIR:
|
||||
case BlockID.VOID_AIR:
|
||||
case BlockID.WATER:
|
||||
case BlockID.LAVA:
|
||||
case BlockID.BEDROCK:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
|
@ -4,7 +4,11 @@ import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
import com.boydti.fawe.object.queue.DelegateFaweQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -25,8 +29,28 @@ public class ChangeSetFaweQueue extends DelegateFaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, int combinedId) {
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 p, B block) throws WorldEditException {
|
||||
return setBlock(p.getX(), p.getY(), p.getZ(), block.getInternalId(), block.getNbtData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||
return setBlock(x, y, z, block.getInternalId(), block.getNbtData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, int combinedId, CompoundTag nbt) {
|
||||
if (setBlock(x, y, z, combinedId)) {
|
||||
if (nbt != null) {
|
||||
set.addTileCreate(nbt);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, int combinedId) {
|
||||
if (super.setBlock(x, y, z, combinedId)) {
|
||||
int combinedFrom = getParent().getCombinedId4Data(x, y, z);
|
||||
BlockType typeFrom = BlockTypes.getFromStateId(combinedFrom);
|
||||
@ -43,11 +67,11 @@ public class ChangeSetFaweQueue extends DelegateFaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
if (super.setBiome(x, z, biome)) {
|
||||
int oldBiome = getParent().getBiomeId(x, z);
|
||||
if (oldBiome != biome.getId()) {
|
||||
set.addBiomeChange(x, z, FaweCache.getBiome(oldBiome), biome);
|
||||
BiomeType oldBiome = getParent().getBiomeType(x, z);
|
||||
if (oldBiome != biome) {
|
||||
set.addBiomeChange(x, z, oldBiome, biome);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.boydti.fawe.util.MainUtil;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
@ -16,12 +16,10 @@ import java.util.concurrent.Callable;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class FaweChunk<T> implements Callable<FaweChunk> {
|
||||
public static int HEIGHT = 256;
|
||||
|
||||
private FaweQueue parent;
|
||||
private int x, z;
|
||||
public static int HEIGHT = 256;
|
||||
|
||||
private final ArrayDeque<Runnable> tasks = new ArrayDeque<>(0);
|
||||
|
||||
/**
|
||||
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
||||
@ -167,7 +165,11 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract byte[] getBiomeArray();
|
||||
public abstract BiomeType[] getBiomeArray();
|
||||
|
||||
public BiomeType getBiomeType(int x, int z) {
|
||||
return getBiomeArray()[(x & 15) + ((z & 15) << 4)];
|
||||
}
|
||||
|
||||
public void forEachQueuedBlock(FaweChunkVisitor onEach) {
|
||||
for (int y = 0; y < HEIGHT; y++) {
|
||||
@ -213,28 +215,6 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a task to run when this chunk is dispatched
|
||||
*
|
||||
* @param run
|
||||
*/
|
||||
public void addNotifyTask(Runnable run) {
|
||||
if (run != null) {
|
||||
tasks.add(run);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasNotifyTasks() {
|
||||
return tasks.size() > 0;
|
||||
}
|
||||
|
||||
public void executeNotifyTasks() {
|
||||
for (Runnable task : tasks) {
|
||||
task.run();
|
||||
}
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying chunk object
|
||||
*
|
||||
@ -289,13 +269,9 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
|
||||
*/
|
||||
public abstract CompoundTag getTile(int x, int y, int z);
|
||||
|
||||
public void setBiome(final int x, final int z, final BaseBiome biome) {
|
||||
setBiome(x, z, (byte) biome.getId());
|
||||
}
|
||||
public abstract void setBiome(final int x, final int z, final BiomeType biome);
|
||||
|
||||
public abstract void setBiome(final int x, final int z, final byte biome);
|
||||
|
||||
public void setBiome(final byte biome) {
|
||||
public void setBiome(final BiomeType biome) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
setBiome(x, z, biome);
|
||||
|
@ -74,17 +74,10 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
}
|
||||
if (obj instanceof Player) {
|
||||
Player actor = LocationMaskedPlayerWrapper.unwrap((Player) obj);
|
||||
if (obj.getClass().getSimpleName().equals("PlayerProxy")) {
|
||||
try {
|
||||
Field fieldBasePlayer = actor.getClass().getDeclaredField("basePlayer");
|
||||
fieldBasePlayer.setAccessible(true);
|
||||
Player player = (Player) fieldBasePlayer.get(actor);
|
||||
FawePlayer<Object> result = wrap(player);
|
||||
return (FawePlayer<V>) (result == null ? wrap(player.getName()) : result);
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
return Fawe.imp().wrap(actor.getName());
|
||||
}
|
||||
if (obj instanceof PlayerProxy) {
|
||||
Player player = ((PlayerProxy) obj).getBasePlayer();
|
||||
FawePlayer<Object> result = wrap(player);
|
||||
return (FawePlayer<V>) (result == null ? wrap(player.getName()) : result);
|
||||
} else if (obj instanceof PlayerWrapper) {
|
||||
return wrap(((PlayerWrapper) obj).getParent());
|
||||
} else {
|
||||
@ -124,10 +117,6 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
if (Settings.IMP.CLIPBOARD.USE_DISK) {
|
||||
loadClipboardFromDisk();
|
||||
}
|
||||
Updater updater = Fawe.get().getUpdater();
|
||||
if (updater != null && updater.hasPending(this)) {
|
||||
TaskManager.IMP.async(() -> updater.confirmUpdate(this));
|
||||
}
|
||||
}
|
||||
|
||||
public int cancel(boolean close) {
|
||||
@ -630,7 +619,6 @@ public abstract class FawePlayer<T> extends Metadatable {
|
||||
cancel(true);
|
||||
if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) {
|
||||
session = getSession();
|
||||
WorldEdit.getInstance().getSessionManager().remove(toWorldEditPlayer());
|
||||
session.setClipboard(null);
|
||||
session.clearHistory();
|
||||
session.unregisterTools(getPlayer());
|
||||
|
@ -21,7 +21,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -107,7 +107,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
default BaseBiome getBiome(BlockVector2 position) {
|
||||
default BiomeType getBiome(BlockVector2 position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
default boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return setBiome(position.getBlockX(), position.getBlockZ(), biome);
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
|
||||
void removeEntity(int x, int y, int z, UUID uuid);
|
||||
|
||||
boolean setBiome(final int x, final int z, final BaseBiome biome);
|
||||
boolean setBiome(final int x, final int z, final BiomeType biome);
|
||||
|
||||
FaweChunk getFaweChunk(int x, int z);
|
||||
|
||||
@ -333,7 +333,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
return regenerateChunk(x, z, null, null);
|
||||
}
|
||||
|
||||
boolean regenerateChunk(int x, int z, @Nullable BaseBiome biome, @Nullable Long seed);
|
||||
boolean regenerateChunk(int x, int z, @Nullable BiomeType biome, @Nullable Long seed);
|
||||
|
||||
default void startSet(boolean parallel) {
|
||||
}
|
||||
@ -394,13 +394,11 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
*/
|
||||
void clear();
|
||||
|
||||
void addNotifyTask(int x, int z, Runnable runnable);
|
||||
|
||||
default boolean hasBlock(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getCombinedId4Data(x, y, z) != 0;
|
||||
}
|
||||
|
||||
int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException;
|
||||
BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException;
|
||||
|
||||
int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException;
|
||||
|
||||
|
@ -17,7 +17,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -61,7 +61,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||
BaseBlock previous = queue.getFullBlock(BlockVector3.at(x, y, z)).toBaseBlock();
|
||||
BaseBlock previous = queue.getFullBlock(mutable.setComponents(x, y, z)).toBaseBlock();
|
||||
if (previous.getInternalId() == block.getInternalId()) {
|
||||
if (!previous.hasNbtData() && (block instanceof BaseBlock && !((BaseBlock)block).hasNbtData())) {
|
||||
return false;
|
||||
@ -105,8 +105,8 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome newBiome) {
|
||||
BaseBiome oldBiome = this.getBiome(position);
|
||||
public boolean setBiome(BlockVector2 position, BiomeType newBiome) {
|
||||
BiomeType oldBiome = this.getBiome(position);
|
||||
if (oldBiome.getId() != newBiome.getId()) {
|
||||
this.changeSet.addBiomeChange(position.getBlockX(), position.getBlockZ(), oldBiome, newBiome);
|
||||
return getExtent().setBiome(position, newBiome);
|
||||
@ -116,8 +116,8 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BaseBiome newBiome) {
|
||||
BaseBiome oldBiome = this.getBiome(BlockVector2.at(x, z));
|
||||
public boolean setBiome(int x, int y, int z, BiomeType newBiome) {
|
||||
BiomeType oldBiome = this.getBiome(BlockVector2.at(x, z));
|
||||
if (oldBiome.getId() != newBiome.getId()) {
|
||||
this.changeSet.addBiomeChange(x, z, oldBiome, newBiome);
|
||||
return getExtent().setBiome(x, y, z, newBiome);
|
||||
|
@ -11,7 +11,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class MaskedFaweQueue extends DelegateFaweQueue {
|
||||
@ -88,7 +88,15 @@ public class MaskedFaweQueue extends DelegateFaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
if (region.contains(x, y, z)) {
|
||||
return super.setBiome(x, y, z, biome);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
if (region.contains(position.getBlockX(), position.getBlockZ())) {
|
||||
return super.setBiome(position, biome);
|
||||
}
|
||||
@ -96,7 +104,7 @@ public class MaskedFaweQueue extends DelegateFaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
if (region.contains(x, z)) {
|
||||
return super.setBiome(x, z, biome);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
@ -49,7 +49,7 @@ public class NullChangeSet extends FaweChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomeChange(int x, int z, BaseBiome from, BaseBiome to) {
|
||||
public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
||||
return;
|
||||
}
|
||||
if (this.vertex == null) {
|
||||
vertex = getVertex(pos1, pos2, slack);
|
||||
vertex = getVertex(pos1.toVector3(), pos2.toVector3(), slack);
|
||||
if (this.direction) {
|
||||
BBC.BRUSH_CATENARY_DIRECTION.send(editSession.getPlayer(), 2);
|
||||
return;
|
||||
@ -79,8 +79,8 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static BlockVector3 getVertex(BlockVector3 pos1, BlockVector3 pos2, double lenPercent) {
|
||||
if (lenPercent <= 1) return MathUtils.midpoint(pos1, pos2);
|
||||
public static BlockVector3 getVertex(Vector3 pos1, Vector3 pos2, double lenPercent) {
|
||||
if (lenPercent <= 1) return pos1.add(pos2).divide(2).toBlockPoint();
|
||||
double curveLen = pos1.distance(pos2) * lenPercent;
|
||||
double dy = pos2.getY() - pos1.getY();
|
||||
double dx = pos2.getX() - pos1.getX();
|
||||
@ -93,6 +93,6 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
||||
double z = (dh/2)/a;
|
||||
double oY = (dy - curveLen * (Math.cosh(z) / Math.sinh(z))) / 2;
|
||||
double vertY = a * 1 + oY;
|
||||
return pos1.add(pos2.subtract(pos1).multiply(MathMan.roundInt(vertX / dh)).add(0, MathMan.roundInt(vertY), 0)).round();
|
||||
return pos1.add(pos2.subtract(pos1).multiply(vertX / dh).add(0, vertY, 0)).round().toBlockPoint();
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
if (super.test(vector) && vector.getBlockY() >= minY) {
|
||||
BaseBlock block = editSession.getFullBlock(position);
|
||||
BaseBlock block = editSession.getFullBlock(vector);
|
||||
if (!block.getBlockType().getMaterial().isAir()) {
|
||||
builder.add(vector, EditSession.nullBlock.toBaseBlock(), block);
|
||||
return true;
|
||||
|
@ -25,7 +25,7 @@ public class SurfaceSpline implements Brush {
|
||||
this.quality = quality;
|
||||
}
|
||||
|
||||
private ArrayList<Vector3> path = new ArrayList<>();
|
||||
private ArrayList<BlockVector3> path = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, BlockVector3 pos, Pattern pattern, double radius) throws MaxChangedBlocksException {
|
||||
@ -35,7 +35,7 @@ public class SurfaceSpline implements Brush {
|
||||
int max = editSession.getNearestSurfaceTerrainBlock(pos.getBlockX(), pos.getBlockZ(), pos.getBlockY(), 0, editSession.getMaxY());
|
||||
if (max == -1) return;
|
||||
// pos.mutY(max);
|
||||
path.add(Vector3.at(pos.getBlockX(), max, pos.getBlockZ()));
|
||||
path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ()));
|
||||
editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_PRIMARY_2.s());
|
||||
if (!vis) return;
|
||||
}
|
||||
@ -43,8 +43,8 @@ public class SurfaceSpline implements Brush {
|
||||
final List<Node> nodes = new ArrayList<>(path.size());
|
||||
final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();
|
||||
|
||||
for (final Vector3 nodevector : path) {
|
||||
final Node n = new Node(nodevector);
|
||||
for (final BlockVector3 nodevector : path) {
|
||||
final Node n = new Node(nodevector.toVector3());
|
||||
n.setTension(tension);
|
||||
n.setBias(bias);
|
||||
n.setContinuity(continuity);
|
||||
|
@ -9,6 +9,7 @@ import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
@ -18,7 +19,7 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
@ -41,7 +42,7 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(int x, int z, @Nullable BaseBiome biome, @Nullable Long seed) {
|
||||
public boolean regenerateChunk(int x, int z, @Nullable BiomeType biome, @Nullable Long seed) {
|
||||
return unsupported();
|
||||
}
|
||||
|
||||
@ -56,13 +57,8 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotifyTask(int x, int z, Runnable runnable) {
|
||||
if (runnable != null) runnable.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return FaweCache.getBiome(0);
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return BiomeTypes.FOREST;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -232,7 +228,7 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
return unsupported();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.boydti.fawe.object.collection.SparseBitSet;
|
||||
import com.boydti.fawe.object.visitor.FaweChunkVisitor;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -87,8 +88,8 @@ public class VisualChunk extends FaweChunk<FaweChunk> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBiomeArray() {
|
||||
return new byte[256];
|
||||
public BiomeType[] getBiomeArray() {
|
||||
return new BiomeType[256];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -154,7 +155,7 @@ public class VisualChunk extends FaweChunk<FaweChunk> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, byte biome) {
|
||||
public void setBiome(int x, int z, BiomeType biome) {
|
||||
// Unsupported
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
@ -61,7 +61,7 @@ public class VisualExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
// Do nothing
|
||||
return false;
|
||||
}
|
||||
|
@ -4,32 +4,33 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
|
||||
public class MutableBiomeChange implements Change {
|
||||
|
||||
private MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
private BaseBiome from;
|
||||
private BaseBiome to;
|
||||
private int from;
|
||||
private int to;
|
||||
|
||||
public MutableBiomeChange() {
|
||||
this.from = new BaseBiome(0);
|
||||
this.to = new BaseBiome(0);
|
||||
this.from = 0;
|
||||
this.to = 0;
|
||||
}
|
||||
|
||||
public void setBiome(int x, int z, int from, int to) {
|
||||
mutable.setComponents(x, z);
|
||||
this.from.setId(from);
|
||||
this.to.setId(to);
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo(UndoContext context) throws WorldEditException {
|
||||
context.getExtent().setBiome(mutable, from);
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.get(from));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo(UndoContext context) throws WorldEditException {
|
||||
context.getExtent().setBiome(mutable, to);
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.get(to));
|
||||
}
|
||||
}
|
||||
|
@ -68,4 +68,4 @@ public class MutableChunkChange implements Change {
|
||||
queue.setChunk(to);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import com.sk89q.worldedit.history.change.EntityCreate;
|
||||
import com.sk89q.worldedit.history.change.EntityRemove;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Iterator;
|
||||
@ -89,7 +89,7 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomeChange(int x, int z, BaseBiome from, BaseBiome to) {
|
||||
public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) {
|
||||
parent.addBiomeChange(x, z, from, to);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@ -79,7 +79,7 @@ public class AnvilHistory extends FaweChangeSet implements IAnvilHistory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomeChange(int x, int z, BaseBiome from, BaseBiome to) {
|
||||
public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) {
|
||||
throw new UnsupportedOperationException("Only anvil operations are supported");
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import com.boydti.fawe.object.change.CFIChange;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
@ -65,7 +65,7 @@ public class CFIChangeSet extends FaweChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomeChange(int x, int z, BaseBiome from, BaseBiome to) {
|
||||
public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) {
|
||||
throw new UnsupportedOperationException("Only CFI operations are supported");
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
@ -59,7 +59,7 @@ public class CPUOptimizedChangeSet extends FaweChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomeChange(int x, int z, BaseBiome from, BaseBiome to) {
|
||||
public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) {
|
||||
throw new UnsupportedOperationException("Invalid mode");
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,8 @@ import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import java.io.DataOutput;
|
||||
import java.io.File;
|
||||
@ -18,6 +20,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -455,7 +458,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
public int maxZ;
|
||||
|
||||
public DiskStorageSummary(int x, int z) {
|
||||
blocks = new int[256];
|
||||
blocks = new int[BlockTypes.states.length];
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
minX = x;
|
||||
@ -465,7 +468,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
|
||||
public void add(int x, int z, int id) {
|
||||
blocks[id]++;
|
||||
blocks[BlockState.getFromInternalId(id).getOrdinal()]++;
|
||||
if (x < minX) {
|
||||
minX = x;
|
||||
} else if (x > maxX) {
|
||||
@ -478,22 +481,23 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getBlocks() {
|
||||
Int2ObjectOpenHashMap<Integer> map = new Int2ObjectOpenHashMap<>();
|
||||
public Map<BlockState, Integer> getBlocks() {
|
||||
HashMap<BlockState, Integer> map = new HashMap<>();
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
if (blocks[i] != 0) {
|
||||
map.put(i, (Integer) blocks[i]);
|
||||
BlockState state = BlockTypes.states[i];
|
||||
map.put(state, (Integer) blocks[i]);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public Map<Integer, Double> getPercents() {
|
||||
Map<Integer, Integer> map = getBlocks();
|
||||
public Map<BlockState, Double> getPercents() {
|
||||
Map<BlockState, Integer> map = getBlocks();
|
||||
int count = getSize();
|
||||
Int2ObjectOpenHashMap<Double> newMap = new Int2ObjectOpenHashMap<>();
|
||||
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
|
||||
int id = entry.getKey();
|
||||
Map<BlockState, Double> newMap = new HashMap<>();
|
||||
for (Map.Entry<BlockState, Integer> entry : map.entrySet()) {
|
||||
BlockState id = entry.getKey();
|
||||
int changes = entry.getValue();
|
||||
double percent = ((changes * 1000l) / count) / 10d;
|
||||
newMap.put(id, (Double) percent);
|
||||
|
@ -15,6 +15,7 @@ import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
@ -25,7 +26,7 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Iterator;
|
||||
@ -141,7 +142,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
|
||||
public abstract void addEntityCreate(CompoundTag tag);
|
||||
|
||||
public abstract void addBiomeChange(int x, int z, BaseBiome from, BaseBiome to);
|
||||
public abstract void addBiomeChange(int x, int z, BiomeType from, BiomeType to);
|
||||
|
||||
public Iterator<Change> getIterator(BlockBag blockBag, int mode, boolean redo) {
|
||||
return getIterator(redo);
|
||||
@ -266,23 +267,21 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
int bx = cx << 4;
|
||||
int bz = cz << 4;
|
||||
synchronized (FaweChangeSet.this) {
|
||||
// Biome changes
|
||||
if (previous.getBiomeArray() != null) {
|
||||
byte[] previousBiomes = previous.getBiomeArray();
|
||||
byte[] nextBiomes = next.getBiomeArray();
|
||||
BiomeType[] previousBiomes = previous.getBiomeArray();
|
||||
if (previousBiomes != null) {
|
||||
BiomeType[] nextBiomes = next.getBiomeArray();
|
||||
int index = 0;
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int zz = bz + z;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
byte idFrom = previousBiomes[index];
|
||||
byte idTo = nextBiomes[index];
|
||||
if (idFrom != idTo && idTo != 0) {
|
||||
addBiomeChange(bx + x, zz, FaweCache.getBiome(idFrom & 0xFF), FaweCache.getBiome(idTo & 0xFF));
|
||||
BiomeType idFrom = previousBiomes[index];
|
||||
BiomeType idTo = nextBiomes[index];
|
||||
if (idFrom != idTo && idTo != null) {
|
||||
addBiomeChange(bx + x, zz, idFrom, idTo);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
}
|
||||
// Block changes
|
||||
for (int layer = 0; layer < layers; layer++) {
|
||||
@ -303,10 +302,16 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
switch (combinedIdCurrent) {
|
||||
case 0:
|
||||
continue;
|
||||
case 1:
|
||||
combinedIdCurrent = 0;
|
||||
default:
|
||||
int combinedIdPrevious = previousLayer != null ? previousLayer[index] : 0;
|
||||
int combinedIdPrevious;
|
||||
if (previousLayer != null) {
|
||||
combinedIdPrevious = previousLayer[index];
|
||||
if (combinedIdPrevious == 0) {
|
||||
combinedIdPrevious = BlockID.AIR;
|
||||
}
|
||||
} else {
|
||||
combinedIdPrevious = BlockID.AIR;
|
||||
}
|
||||
if (combinedIdCurrent != combinedIdPrevious) {
|
||||
add(xx, yy, zz, combinedIdPrevious, combinedIdCurrent);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.io.EOFException;
|
||||
@ -325,7 +325,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiomeChange(int x, int z, BaseBiome from, BaseBiome to) {
|
||||
public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) {
|
||||
blockSize++;
|
||||
try {
|
||||
OutputStream os = getBiomeOS();
|
||||
@ -337,8 +337,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
os.write((byte) (z >> 16));
|
||||
os.write((byte) (z >> 8));
|
||||
os.write((byte) (z));
|
||||
os.write(from.getId());
|
||||
os.write(to.getId());
|
||||
((FaweOutputStream) os).writeVarInt(from.getInternalId());
|
||||
((FaweOutputStream) os).writeVarInt(to.getInternalId());
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
@ -462,8 +462,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
if (int1 != -1) {
|
||||
int x = ((int1 << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
|
||||
int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
|
||||
int from = is.read();
|
||||
int to = is.read();
|
||||
int from = ((FaweInputStream) is).readVarInt();
|
||||
int to = ((FaweInputStream) is).readVarInt();
|
||||
change.setBiome(x, z, from, to);
|
||||
return change;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -42,17 +42,17 @@ public class AbstractDelegateFaweClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, int biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
return parent.setBiome(x, z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int x, int z) {
|
||||
public BiomeType getBiome(int x, int z) {
|
||||
return parent.getBiome(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int index) {
|
||||
public BiomeType getBiome(int index) {
|
||||
return parent.getBiome(index);
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class AbstractDelegateFaweClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int index, int biome) {
|
||||
public void setBiome(int index, BiomeType biome) {
|
||||
parent.setBiome(index, biome);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -33,7 +33,7 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
private int area;
|
||||
private int volume;
|
||||
|
||||
private byte[] biomes = null;
|
||||
private BiomeType[] biomes = null;
|
||||
private int[] states;
|
||||
|
||||
private final HashMap<IntegerTrio, CompoundTag> nbtMapLoc;
|
||||
@ -59,17 +59,17 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, int biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
setBiome(getIndex(x, 0, z), biome);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int index, int biome) {
|
||||
public void setBiome(int index, BiomeType biome) {
|
||||
if (biomes == null) {
|
||||
biomes = new byte[area];
|
||||
biomes = new BiomeType[area];
|
||||
}
|
||||
biomes[index] = (byte) biome;
|
||||
biomes[index] = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,21 +78,21 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
int index = 0;
|
||||
for (int z = 0; z < length; z++) {
|
||||
for (int x = 0; x < width; x++, index++) {
|
||||
task.run(index, biomes[index] & 0xFF);
|
||||
task.run(index, biomes[index].getInternalId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int index) {
|
||||
public BiomeType getBiome(int index) {
|
||||
if (!hasBiomes()) {
|
||||
return EditSession.nullBiome;
|
||||
return null;
|
||||
}
|
||||
return FaweCache.CACHE_BIOME[biomes[index] & 0xFF];
|
||||
return biomes[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int x, int z) {
|
||||
public BiomeType getBiome(int x, int z) {
|
||||
return getBiome(getIndex(x, 0, z));
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -19,7 +20,7 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -127,25 +128,25 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, int biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
setBiome(getIndex(x, 0, z), biome);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int index, int biome) {
|
||||
public void setBiome(int index, BiomeType biome) {
|
||||
if (initBiome()) {
|
||||
mbb.put(HEADER_SIZE + (volume << 2) + index, (byte) biome);
|
||||
mbb.put(HEADER_SIZE + (volume << 2) + index, (byte) biome.getInternalId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int index) {
|
||||
public BiomeType getBiome(int index) {
|
||||
if (!hasBiomes()) {
|
||||
return EditSession.nullBiome;
|
||||
return null;
|
||||
}
|
||||
int biomeId = mbb.get(HEADER_SIZE + (volume << 2) + index) & 0xFF;
|
||||
return FaweCache.CACHE_BIOME[biomeId];
|
||||
return BiomeTypes.get(biomeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,7 +163,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int x, int z) {
|
||||
public BiomeType getBiome(int x, int z) {
|
||||
return getBiome(getIndex(x, 0, z));
|
||||
}
|
||||
|
||||
@ -378,8 +379,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
trio.set(x, y, z);
|
||||
CompoundTag nbt = nbtMap.get(trio);
|
||||
if (nbt != null) {
|
||||
BaseBlock block = new BaseBlock(state, nbt);
|
||||
task.run(x, y, z, block);
|
||||
task.run(x, y, z, state.toBaseBlock(nbt));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -410,8 +410,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||
trio.set(x, y, z);
|
||||
CompoundTag nbt = nbtMap.get(trio);
|
||||
if (nbt != null) {
|
||||
BaseBlock block = new BaseBlock(state, nbt);
|
||||
task.run(x, y, z, block);
|
||||
task.run(x, y, z, state.toBaseBlock(nbt));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -84,8 +84,8 @@ public class EmptyClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return EditSession.nullBiome;
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,7 +94,7 @@ public class EmptyClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -33,15 +33,15 @@ public abstract class FaweClipboard {
|
||||
|
||||
public abstract boolean hasBiomes();
|
||||
|
||||
public abstract boolean setBiome(int x, int z, int biome);
|
||||
public abstract boolean setBiome(int x, int z, BiomeType biome);
|
||||
|
||||
public abstract BaseBiome getBiome(int x, int z);
|
||||
public abstract BiomeType getBiome(int x, int z);
|
||||
|
||||
public abstract BaseBiome getBiome(int index);
|
||||
public abstract BiomeType getBiome(int index);
|
||||
|
||||
public abstract BaseBlock getBlock(int index);
|
||||
|
||||
public abstract void setBiome(int index, int biome);
|
||||
public abstract void setBiome(int index, BiomeType biome);
|
||||
|
||||
public abstract boolean setTile(int x, int y, int z, CompoundTag tag);
|
||||
|
||||
|
@ -10,13 +10,14 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -92,17 +93,17 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, int biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
setBiome(getIndex(x, 0, z), biome);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int index, int biome) {
|
||||
public void setBiome(int index, BiomeType biome) {
|
||||
if (biomes == null) {
|
||||
biomes = new byte[area];
|
||||
}
|
||||
biomes[index] = (byte) biome;
|
||||
biomes[index] = (byte) biome.getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,15 +118,15 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int index) {
|
||||
public BiomeType getBiome(int index) {
|
||||
if (!hasBiomes()) {
|
||||
return EditSession.nullBiome;
|
||||
return null;
|
||||
}
|
||||
return FaweCache.CACHE_BIOME[biomes[index] & 0xFF];
|
||||
return BiomeTypes.get(biomes[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int x, int z) {
|
||||
public BiomeType getBiome(int x, int z) {
|
||||
return getBiome(getIndex(x, 0, z));
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.boydti.fawe.object.clipboard;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
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;
|
||||
@ -31,12 +31,12 @@ public class OffsetFaweClipboard extends AbstractDelegateFaweClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, int biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
return super.setBiome(ox + x, oz + z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int x, int z) {
|
||||
public BiomeType getBiome(int x, int z) {
|
||||
return super.getBiome(ox + x, oz + z);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -51,17 +51,17 @@ public abstract class ReadOnlyClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int index) {
|
||||
public BiomeType getBiome(int index) {
|
||||
throw new UnsupportedOperationException("World based clipboards do not provide index access");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, int biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
throw new UnsupportedOperationException("Clipboard is immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int index, int biome) {
|
||||
public void setBiome(int index, BiomeType biome) {
|
||||
throw new UnsupportedOperationException("Clipboard is immutable");
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public abstract class ReadOnlyClipboard extends FaweClipboard {
|
||||
int index = 0;
|
||||
for (int z = 0; z <= dim.getBlockZ(); z++) {
|
||||
for (int x = 0; x <= dim.getBlockX(); x++, index++) {
|
||||
task.run(index, getBiome(x, z).getId());
|
||||
task.run(index, getBiome(x, z).getInternalId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@ public abstract class ReadOnlyClipboard extends FaweClipboard {
|
||||
public abstract BaseBlock getBlock(int x, int y, int z);
|
||||
|
||||
@Override
|
||||
public abstract BaseBiome getBiome(int x, int z);
|
||||
public abstract BiomeType getBiome(int x, int z);
|
||||
|
||||
@Override
|
||||
public abstract List<? extends Entity> getEntities();
|
||||
|
@ -16,7 +16,7 @@ import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -55,7 +55,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(int x, int z) {
|
||||
public BiomeType getBiome(int x, int z) {
|
||||
return extent.getBiome(MutableBlockVector2.setComponents(mx + x, mz + z));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,233 @@
|
||||
package com.boydti.fawe.object.collection;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static it.unimi.dsi.fastutil.HashCommon.arraySize;
|
||||
|
||||
public class ObjObjMap<K, V>
|
||||
{
|
||||
private static final Object FREE_KEY = new Object();
|
||||
private static final Object REMOVED_KEY = new Object();
|
||||
|
||||
/** Keys and values */
|
||||
private Object[] m_data;
|
||||
|
||||
/** Value for the null key (if inserted into a map) */
|
||||
private Object m_nullValue;
|
||||
private boolean m_hasNull;
|
||||
|
||||
/** Fill factor, must be between (0 and 1) */
|
||||
private final float m_fillFactor;
|
||||
/** We will resize a map once it reaches this size */
|
||||
private int m_threshold;
|
||||
/** Current map size */
|
||||
private int m_size;
|
||||
/** Mask to calculate the original position */
|
||||
private int m_mask;
|
||||
/** Mask to wrap the actual array pointer */
|
||||
private int m_mask2;
|
||||
|
||||
public ObjObjMap( final int size, final float fillFactor )
|
||||
{
|
||||
if ( fillFactor <= 0 || fillFactor >= 1 )
|
||||
throw new IllegalArgumentException( "FillFactor must be in (0, 1)" );
|
||||
if ( size <= 0 )
|
||||
throw new IllegalArgumentException( "Size must be positive!" );
|
||||
final int capacity = arraySize(size, fillFactor);
|
||||
m_mask = capacity - 1;
|
||||
m_mask2 = capacity * 2 - 1;
|
||||
m_fillFactor = fillFactor;
|
||||
|
||||
m_data = new Object[capacity * 2];
|
||||
Arrays.fill( m_data, FREE_KEY );
|
||||
|
||||
m_threshold = (int) (capacity * fillFactor);
|
||||
}
|
||||
|
||||
public V get( @Nonnull final K key )
|
||||
{
|
||||
// if ( key == null )
|
||||
// return (V) m_nullValue; //we null it on remove, so safe not to check a flag here
|
||||
|
||||
int ptr = (key.hashCode() & m_mask) << 1;
|
||||
Object k = m_data[ ptr ];
|
||||
|
||||
// if ( k == FREE_KEY )
|
||||
// return null; //end of chain already
|
||||
if ( k == ( key ) ) //we check FREE and REMOVED prior to this call
|
||||
return (V) m_data[ ptr + 1 ];
|
||||
while ( true )
|
||||
{
|
||||
ptr = (ptr + 2) & m_mask2; //that's next index
|
||||
k = m_data[ ptr ];
|
||||
// if ( k == FREE_KEY )
|
||||
// return null;
|
||||
if ( k == ( key ) )
|
||||
return (V) m_data[ ptr + 1 ];
|
||||
}
|
||||
}
|
||||
|
||||
public V put( final K key, final V value )
|
||||
{
|
||||
if ( key == null )
|
||||
return insertNullKey(value);
|
||||
|
||||
int ptr = getStartIndex(key) << 1;
|
||||
Object k = m_data[ptr];
|
||||
|
||||
if ( k == FREE_KEY ) //end of chain already
|
||||
{
|
||||
m_data[ ptr ] = key;
|
||||
m_data[ ptr + 1 ] = value;
|
||||
if ( m_size >= m_threshold )
|
||||
rehash( m_data.length * 2 ); //size is set inside
|
||||
else
|
||||
++m_size;
|
||||
return null;
|
||||
}
|
||||
else if ( k == ( key ) ) //we check FREE and REMOVED prior to this call
|
||||
{
|
||||
final Object ret = m_data[ ptr + 1 ];
|
||||
m_data[ ptr + 1 ] = value;
|
||||
return (V) ret;
|
||||
}
|
||||
|
||||
int firstRemoved = -1;
|
||||
if ( k == REMOVED_KEY )
|
||||
firstRemoved = ptr; //we may find a key later
|
||||
|
||||
while ( true )
|
||||
{
|
||||
ptr = ( ptr + 2 ) & m_mask2; //that's next index calculation
|
||||
k = m_data[ ptr ];
|
||||
if ( k == FREE_KEY )
|
||||
{
|
||||
if ( firstRemoved != -1 )
|
||||
ptr = firstRemoved;
|
||||
m_data[ ptr ] = key;
|
||||
m_data[ ptr + 1 ] = value;
|
||||
if ( m_size >= m_threshold )
|
||||
rehash( m_data.length * 2 ); //size is set inside
|
||||
else
|
||||
++m_size;
|
||||
return null;
|
||||
}
|
||||
else if ( k == ( key ) )
|
||||
{
|
||||
final Object ret = m_data[ ptr + 1 ];
|
||||
m_data[ ptr + 1 ] = value;
|
||||
return (V) ret;
|
||||
}
|
||||
else if ( k == REMOVED_KEY )
|
||||
{
|
||||
if ( firstRemoved == -1 )
|
||||
firstRemoved = ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public V remove( final K key )
|
||||
{
|
||||
if ( key == null )
|
||||
return removeNullKey();
|
||||
|
||||
int ptr = getStartIndex(key) << 1;
|
||||
Object k = m_data[ ptr ];
|
||||
if ( k == FREE_KEY )
|
||||
return null; //end of chain already
|
||||
else if ( k == ( key ) ) //we check FREE and REMOVED prior to this call
|
||||
{
|
||||
--m_size;
|
||||
if ( m_data[ ( ptr + 2 ) & m_mask2 ] == FREE_KEY )
|
||||
m_data[ ptr ] = FREE_KEY;
|
||||
else
|
||||
m_data[ ptr ] = REMOVED_KEY;
|
||||
final V ret = (V) m_data[ ptr + 1 ];
|
||||
m_data[ ptr + 1 ] = null;
|
||||
return ret;
|
||||
}
|
||||
while ( true )
|
||||
{
|
||||
ptr = ( ptr + 2 ) & m_mask2; //that's next index calculation
|
||||
k = m_data[ ptr ];
|
||||
if ( k == FREE_KEY )
|
||||
return null;
|
||||
else if ( k == ( key ) )
|
||||
{
|
||||
--m_size;
|
||||
if ( m_data[ ( ptr + 2 ) & m_mask2 ] == FREE_KEY )
|
||||
m_data[ ptr ] = FREE_KEY;
|
||||
else
|
||||
m_data[ ptr ] = REMOVED_KEY;
|
||||
final V ret = (V) m_data[ ptr + 1 ];
|
||||
m_data[ ptr + 1 ] = null;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private V insertNullKey(final V value)
|
||||
{
|
||||
if ( m_hasNull )
|
||||
{
|
||||
final Object ret = m_nullValue;
|
||||
m_nullValue = value;
|
||||
return (V) ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nullValue = value;
|
||||
++m_size;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private V removeNullKey()
|
||||
{
|
||||
if ( m_hasNull )
|
||||
{
|
||||
final Object ret = m_nullValue;
|
||||
m_nullValue = null;
|
||||
m_hasNull = false;
|
||||
--m_size;
|
||||
return (V) ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
private void rehash( final int newCapacity )
|
||||
{
|
||||
m_threshold = (int) (newCapacity/2 * m_fillFactor);
|
||||
m_mask = newCapacity/2 - 1;
|
||||
m_mask2 = newCapacity - 1;
|
||||
|
||||
final int oldCapacity = m_data.length;
|
||||
final Object[] oldData = m_data;
|
||||
|
||||
m_data = new Object[ newCapacity ];
|
||||
Arrays.fill( m_data, FREE_KEY );
|
||||
|
||||
m_size = m_hasNull ? 1 : 0;
|
||||
|
||||
for ( int i = 0; i < oldCapacity; i += 2 ) {
|
||||
final Object oldKey = oldData[ i ];
|
||||
if( oldKey != FREE_KEY && oldKey != REMOVED_KEY )
|
||||
put( (K)oldKey, (V)oldData[ i + 1 ]);
|
||||
}
|
||||
}
|
||||
|
||||
public int getStartIndex( final Object key )
|
||||
{
|
||||
//key is not null here
|
||||
return key.hashCode() & m_mask;
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
@ -36,17 +36,17 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return super.setBiome(position.add(dx, dz), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return super.setBiome(x + dx, y + dy, z + dz, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return super.getBiome(position.add(dx, dz));
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -55,7 +55,7 @@ public class EmptyExtent implements Extent {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -65,12 +65,12 @@ public class EmptyExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -17,8 +16,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -106,8 +104,8 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(final BlockVector2 position) {
|
||||
return FaweCache.CACHE_BIOME[queue.getBiomeId(position.getBlockX(), position.getBlockZ())];
|
||||
public BiomeType getBiome(final BlockVector2 position) {
|
||||
return queue.getBiomeType(position.getBlockX(), position.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -165,7 +163,7 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final BlockVector2 position, final BaseBiome biome) {
|
||||
public boolean setBiome(final BlockVector2 position, final BiomeType biome) {
|
||||
queue.setBiome(position.getBlockX(), position.getBlockZ(), biome);
|
||||
return true;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -79,7 +79,7 @@ public abstract class FaweRegionExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
if (!contains(position)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
|
||||
@ -90,7 +90,7 @@ public abstract class FaweRegionExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
if (!contains(x, y, z)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
|
||||
@ -101,12 +101,12 @@ public abstract class FaweRegionExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
if (!contains(position)) {
|
||||
if (!limit.MAX_FAILS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
|
||||
}
|
||||
return EditSession.nullBiome;
|
||||
return null;
|
||||
}
|
||||
return super.getBiome(position);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -46,7 +46,7 @@ public class MultiTransform extends RandomTransform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
boolean result = false;
|
||||
for (AbstractDelegateExtent extent : extents) result |= extent.setBiome(position, biome);
|
||||
return result;
|
||||
|
@ -14,7 +14,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -48,7 +48,7 @@ public class NullExtent extends FaweRegionExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(final BlockVector2 arg0) {
|
||||
public BiomeType getBiome(final BlockVector2 arg0) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
@ -75,7 +75,7 @@ public class NullExtent extends FaweRegionExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final BlockVector2 arg0, final BaseBiome arg1) {
|
||||
public boolean setBiome(final BlockVector2 arg0, final BiomeType arg1) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}else {
|
||||
|
@ -5,7 +5,7 @@ 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.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class OffsetExtent extends ResettableExtent {
|
||||
@ -20,12 +20,12 @@ public class OffsetExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return getExtent().setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz), biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return getExtent().setBiome(x + dx, y + dy, z + dz, biome);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableVector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class PositionTransformExtent extends ResettableExtent {
|
||||
@ -67,7 +67,7 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(0);
|
||||
@ -86,7 +86,7 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(0);
|
||||
|
@ -16,7 +16,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.List;
|
||||
@ -48,7 +48,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(final BlockVector2 position) {
|
||||
public BiomeType getBiome(final BlockVector2 position) {
|
||||
return super.getBiome(position);
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final BlockVector2 position, final BaseBiome biome) {
|
||||
public boolean setBiome(final BlockVector2 position, final BiomeType biome) {
|
||||
if (!limit.MAX_CHANGES()) {
|
||||
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
||||
return false;
|
||||
|
@ -6,7 +6,7 @@ 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.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.SplittableRandom;
|
||||
@ -26,7 +26,7 @@ public class RandomOffsetTransform extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 pos, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 pos, BiomeType biome) {
|
||||
int x = pos.getBlockX() + random.nextInt(1 + (dx << 1)) - dx;
|
||||
int z = pos.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz;
|
||||
return getExtent().setBiome(mutable.setComponents(x, z), biome);
|
||||
|
@ -9,7 +9,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -80,7 +80,7 @@ public class ScaleTransform extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
boolean result = false;
|
||||
MutableBlockVector3 pos = new MutableBlockVector3(getPos(position.getBlockX(), 0, position.getBlockZ()));
|
||||
double sx = pos.getX();
|
||||
|
@ -11,7 +11,7 @@ import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -50,7 +50,7 @@ public abstract class SelectTransform extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return getExtent(position).setBiome(position, biome);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
|
||||
@ -16,7 +16,7 @@ public class TemporalExtent extends AbstractDelegateExtent {
|
||||
private BlockStateHolder<?> block = EditSession.nullBlock;
|
||||
|
||||
private int bx, bz = Integer.MAX_VALUE;
|
||||
private BaseBiome biome = EditSession.nullBiome;
|
||||
private BiomeType biome = null;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -35,7 +35,7 @@ public class TemporalExtent extends AbstractDelegateExtent {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public void set(int x, int z, BaseBiome biome) {
|
||||
public void set(int x, int z, BiomeType biome) {
|
||||
this.bx = x;
|
||||
this.bz = z;
|
||||
this.biome = biome;
|
||||
@ -86,7 +86,7 @@ public class TemporalExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
if (position.getX() == bx && position.getZ() == bz) {
|
||||
return biome;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class TransformExtent extends BlockTransformExtent {
|
||||
@ -79,26 +79,26 @@ public class TransformExtent extends BlockTransformExtent {
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
return transformBlock(super.getLazyBlock(getPos(x, y, z)), false).toImmutableState();
|
||||
return transform(super.getLazyBlock(getPos(x, y, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(BlockVector3 position) {
|
||||
return transformBlock(super.getLazyBlock(getPos(position)), false).toImmutableState();
|
||||
return transform(super.getLazyBlock(getPos(position)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return transformBlock(super.getBlock(getPos(position)), false).toImmutableState();
|
||||
return transform(super.getBlock(getPos(position)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return transformBlock(super.getFullBlock(getPos(position)), false);
|
||||
return transform(super.getFullBlock(getPos(position)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(0);
|
||||
@ -106,18 +106,18 @@ public class TransformExtent extends BlockTransformExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||
return super.setBlock(getPos(x, y, z), transformBlock((BlockState)block, false));
|
||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||
return super.setBlock(getPos(x, y, z), transformInverse(block));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||
return super.setBlock(getPos(location), transformBlock((BlockState)block, false));
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return super.setBlock(getPos(location), transformInverse(block));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(0);
|
||||
|
@ -5,13 +5,13 @@ import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
public class BiomeMask extends AbstractExtentMask implements ResettableMask {
|
||||
private final BaseBiome biome;
|
||||
private final BiomeType biome;
|
||||
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
|
||||
public BiomeMask(Extent extent, BaseBiome biome) {
|
||||
public BiomeMask(Extent extent, BiomeType biome) {
|
||||
super(extent);
|
||||
this.biome = biome;
|
||||
}
|
||||
|
@ -6,14 +6,14 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BiomePattern extends ExistingPattern {
|
||||
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
private final BaseBiome biome;
|
||||
private final BiomeType biome;
|
||||
|
||||
public BiomePattern(Extent extent, BaseBiome biome) {
|
||||
public BiomePattern(Extent extent, BiomeType biome) {
|
||||
super(extent);
|
||||
this.biome = biome;
|
||||
}
|
||||
@ -36,7 +36,7 @@ public class BiomePattern extends ExistingPattern {
|
||||
return BiomePattern.this;
|
||||
}
|
||||
|
||||
public BaseBiome getBiome() {
|
||||
public BiomeType getBiome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
public class IdDataMaskPattern extends AbstractExtentPattern {
|
||||
private final Pattern pattern;
|
||||
private final int bitMask;
|
||||
private final BaseBlock mutable = new BaseBlock(BlockTypes.AIR);
|
||||
|
||||
public IdDataMaskPattern(Extent extent, Pattern parent, int bitMask) {
|
||||
super(extent);
|
||||
|
@ -13,7 +13,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -102,8 +102,8 @@ public class PatternExtent extends AbstractPattern implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return new BaseBiome(0);
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -112,7 +112,7 @@ public class PatternExtent extends AbstractPattern implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -111,11 +111,13 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
} else {
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
int statesIndex = current.modifyIndex(stateId, i) >> BlockTypes.BIT_OFFSET;
|
||||
BlockState state = BlockState.getFromInternalId(statesIndex);
|
||||
BlockState state = type.withPropertyId(statesIndex);
|
||||
|
||||
int existingOrdinal = transformed[state.getOrdinal()];
|
||||
int existing = BlockTypes.states[existingOrdinal].getInternalId();
|
||||
//states[statesIndex] << BlockTypes.BIT_OFFSET;
|
||||
transformed[state.getOrdinal()] = property.modifyIndex(existing, index) >> BlockTypes.BIT_OFFSET;
|
||||
BlockState newState = state.withPropertyId(property.modifyIndex(existing, index) >> BlockTypes.BIT_OFFSET);
|
||||
transformed[state.getOrdinal()] = newState.getOrdinal();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -203,7 +205,7 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
if (newOrdinal != ordinal) {
|
||||
CompoundTag nbt = block.getNbtData();
|
||||
BlockState newState = BlockState.getFromOrdinal(newOrdinal);
|
||||
return nbt != null ? new BaseBlock(newState, nbt) : newState.toBaseBlock();
|
||||
return newState.toBaseBlock(nbt);
|
||||
}
|
||||
return orDefault;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ 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.BaseBiome;
|
||||
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;
|
||||
@ -58,12 +58,12 @@ public class FaweQueueDelegateExtent extends DelegateFaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return parentExtent.getBiome(BlockVector2.at(x, z)).getId();
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return parentExtent.getBiome(BlockVector2.at(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return parentExtent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class FaweQueueDelegateExtent extends DelegateFaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return parentExtent.getBiome(position);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ 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.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
@ -76,7 +76,7 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
default BaseBiome getBiome(BlockVector2 position) {
|
||||
default BiomeType getBiome(BlockVector2 position) {
|
||||
return getQueue().getBiome(position);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
default boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
return getQueue().setBiome(position, biome);
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean setBiome(int x, int z, BaseBiome biome) {
|
||||
default boolean setBiome(int x, int z, BiomeType biome) {
|
||||
return getQueue().setBiome(x, z, biome);
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean regenerateChunk(int x, int z, @Nullable BaseBiome biome, @Nullable Long seed) {
|
||||
default boolean regenerateChunk(int x, int z, @Nullable BiomeType biome, @Nullable Long seed) {
|
||||
return getQueue().regenerateChunk(x, z, biome, seed);
|
||||
}
|
||||
|
||||
@ -332,19 +332,14 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
||||
getQueue().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
default void addNotifyTask(int x, int z, Runnable runnable) {
|
||||
getQueue().addNotifyTask(x, z, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean hasBlock(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getQueue().hasBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
default int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getQueue().getBiomeId(x, z);
|
||||
default BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getQueue().getBiomeType(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,7 +6,7 @@ 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.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Map;
|
||||
@ -91,7 +91,7 @@ public abstract class LazyFaweChunk<T extends FaweChunk> extends FaweChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBiomeArray() {
|
||||
public BiomeType[] getBiomeArray() {
|
||||
return internalGetOrCacheChunk().getBiomeArray();
|
||||
}
|
||||
|
||||
@ -115,21 +115,6 @@ public abstract class LazyFaweChunk<T extends FaweChunk> extends FaweChunk {
|
||||
internalGetOrCacheChunk().fillCuboid(x1, x2, y1, y2, z1, z2, combinedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotifyTask(Runnable run) {
|
||||
internalGetOrCacheChunk().addNotifyTask(run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNotifyTasks() {
|
||||
return internalGetOrCacheChunk().hasNotifyTasks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeNotifyTasks() {
|
||||
internalGetOrCacheChunk().executeNotifyTasks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTile(int x, int y, int z, CompoundTag tile) {
|
||||
internalGetOrCacheChunk().setTile(x, y, z, tile);
|
||||
@ -171,17 +156,12 @@ public abstract class LazyFaweChunk<T extends FaweChunk> extends FaweChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, BaseBiome biome) {
|
||||
public void setBiome(int x, int z, BiomeType biome) {
|
||||
internalGetOrCacheChunk().setBiome(x, z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, byte biome) {
|
||||
internalGetOrCacheChunk().setBiome(x, z, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(byte biome) {
|
||||
public void setBiome(BiomeType biome) {
|
||||
internalGetOrCacheChunk().setBiome(biome);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ 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.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -53,7 +53,7 @@ public class NullFaweQueue implements FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, BaseBiome biome) {
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public class NullFaweQueue implements FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(int x, int z, @Nullable BaseBiome biome, @Nullable Long seed) {
|
||||
public boolean regenerateChunk(int x, int z, @Nullable BiomeType biome, @Nullable Long seed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -178,13 +178,8 @@ public class NullFaweQueue implements FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotifyTask(int x, int z, Runnable runnable) {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return 0;
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -206,6 +206,7 @@ public class Schematic {
|
||||
final int relx = to.getBlockX() + bot.getBlockX() - origin.getBlockX();
|
||||
final int rely = to.getBlockY() + bot.getBlockY() - origin.getBlockY();
|
||||
final int relz = to.getBlockZ() + bot.getBlockZ() - origin.getBlockZ();
|
||||
|
||||
BlockArrayClipboard bac = (BlockArrayClipboard) clipboard;
|
||||
if (copyBiomes) {
|
||||
bac.IMP.forEach(new FaweClipboard.BlockReader() {
|
||||
|
@ -122,7 +122,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
||||
if (state.getBlockType().getMaterial().hasContainer()) {
|
||||
CompoundTag nbt = (CompoundTag) blockMap.get("nbt");
|
||||
if (nbt != null) {
|
||||
BaseBlock block = new BaseBlock(state, nbt);
|
||||
BaseBlock block = state.toBaseBlock(nbt);
|
||||
clipboard.setBlock(x, y, z, block);
|
||||
continue;
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TargetBlock;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
@ -282,12 +283,11 @@ public class SchemVis extends ImmutableVirtualWorld {
|
||||
*/
|
||||
private void select(MCAChunk chunk) {
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
byte[] ids = chunk.ids[layer];
|
||||
int[] ids = chunk.ids[layer];
|
||||
if (ids != null) {
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
// TODO FIXME update to 1.13
|
||||
if (ids[i] != 0) ids[i] = (byte) BlockTypes.WHITE_STAINED_GLASS.getInternalId();
|
||||
Arrays.fill(chunk.data[layer], (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -578,9 +578,9 @@ public class SchemVis extends ImmutableVirtualWorld {
|
||||
public void sendChunk(int x, int z, int bitMask) { /* do nothing - never used*/ }
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
// TODO later (currently not used)
|
||||
return 0;
|
||||
return BiomeTypes.FOREST;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -630,7 +630,7 @@ public class SchemVis extends ImmutableVirtualWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
@ -11,13 +11,15 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
// TODO FIXME
|
||||
@ -84,7 +86,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
|
||||
return PlotBlock.get(state.getInternalBlockTypeId(), state.getInternalPropertiesId());
|
||||
}
|
||||
|
||||
private BaseBiome biome;
|
||||
private BiomeType biome;
|
||||
private String lastBiome;
|
||||
private BiomeRegistry reg;
|
||||
|
||||
@ -94,7 +96,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
|
||||
if (reg == null) {
|
||||
reg = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS).getRegistries().getBiomeRegistry();
|
||||
}
|
||||
List<BaseBiome> biomes = reg.getBiomes();
|
||||
Collection<BiomeType> biomes = BiomeTypes.values();
|
||||
lastBiome = biome;
|
||||
this.biome = Biomes.findBiomeByName(biomes, biome, reg);
|
||||
}
|
||||
|
@ -23,9 +23,12 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
@ -55,8 +58,8 @@ public class PlotSetBiome extends Command {
|
||||
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
final HashSet<RegionWrapper> regions = plot.getRegions();
|
||||
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
|
||||
final BaseBiome biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
|
||||
Collection<BiomeType> knownBiomes = BiomeTypes.values();
|
||||
final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
|
||||
if (biome == null) {
|
||||
String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), Captions.BLOCK_LIST_SEPARATER.s());
|
||||
Captions.NEED_BIOME.send(player);
|
||||
|
@ -15,6 +15,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -34,7 +36,7 @@ public class PlotTrim {
|
||||
private final MCAQueue originalQueue;
|
||||
private final File root;
|
||||
private final File originalRoot;
|
||||
private byte[][] ids;
|
||||
private int[][] ids;
|
||||
private boolean deleteUnowned = true;
|
||||
|
||||
public PlotTrim(PlotPlayer player, PlotArea area, String worldName, boolean deleteUnowned) {
|
||||
@ -49,7 +51,7 @@ public class PlotTrim {
|
||||
this.deleteUnowned = deleteUnowned;
|
||||
}
|
||||
|
||||
public void setChunk(byte[][] ids) {
|
||||
public void setChunk(int[][] ids) {
|
||||
checkNotNull(ids);
|
||||
this.ids = ids;
|
||||
}
|
||||
@ -182,7 +184,7 @@ public class PlotTrim {
|
||||
|
||||
private int count = 0;
|
||||
|
||||
private boolean isEqual(byte[] a, byte[] b) {
|
||||
private boolean isEqual(int[] a, int[] b) {
|
||||
if (a == b) {
|
||||
return true;
|
||||
}
|
||||
@ -195,9 +197,9 @@ public class PlotTrim {
|
||||
return isEmpty(b);
|
||||
}
|
||||
|
||||
private boolean isEmpty(byte[] a) {
|
||||
for (byte b : a) {
|
||||
if (b != 0) {
|
||||
private boolean isEmpty(int[] a) {
|
||||
for (int b : a) {
|
||||
if (!BlockTypes.getFromStateId(b).getMaterial().isAir()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public final class BrushCache {
|
||||
Map<String, Tag> map;
|
||||
if (nbt == null) {
|
||||
if (tool == null) {
|
||||
item.setNbtData(null);
|
||||
return tool;
|
||||
}
|
||||
nbt = new CompoundTag(map = new HashMap<>());
|
||||
@ -113,7 +114,6 @@ public final class BrushCache {
|
||||
map.remove("display");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return tool;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import sun.reflect.ConstructorAccessor;
|
||||
import sun.reflect.FieldAccessor;
|
||||
import sun.reflect.ReflectionFactory;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -12,6 +14,7 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class StringMan {
|
||||
public static String replaceFromMap(final String string, final Map<String, String> replacements) {
|
||||
@ -323,6 +326,57 @@ public class StringMan {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Comparator<String> blockStateComparator(String input) {
|
||||
return new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return blockStateStringDistance(input, o1) - blockStateStringDistance(input, o2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean blockStateMatches(String input, String item) {
|
||||
return blockStateStringDistance(input, item) != Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public static int blockStateStringDistance(String input, String item) {
|
||||
int distance = 0;
|
||||
boolean sequentail = false;
|
||||
int j = 0;
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char ai = input.charAt(i);
|
||||
outer:
|
||||
while (true) {
|
||||
if (j >= item.length()) return Integer.MAX_VALUE;
|
||||
|
||||
char bj = item.charAt(j++);
|
||||
if (sequentail) {
|
||||
switch (bj) {
|
||||
case ':':
|
||||
case '_':
|
||||
sequentail = false;
|
||||
if (bj == ai) break outer;
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (bj != ai) {
|
||||
distance++;
|
||||
switch (bj) {
|
||||
case ':':
|
||||
case '_':
|
||||
continue;
|
||||
default:
|
||||
sequentail = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
|
||||
public static int getLevenshteinDistance(String s, String t) {
|
||||
int n = s.length();
|
||||
int m = t.length();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user