mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
More Kotlin
This commit is contained in:
parent
0cad7f229b
commit
88359f0215
@ -382,7 +382,7 @@
|
|||||||
// int z = location.getBlockZ();
|
// int z = location.getBlockZ();
|
||||||
//
|
//
|
||||||
// org.bukkit.block.Block bukkitBlock = location.getBlock();
|
// org.bukkit.block.Block bukkitBlock = location.getBlock();
|
||||||
// BaseBlock block = FaweCache.IMP.getBlock(bukkitBlock.getTypeId(), bukkitBlock.getData());
|
// BaseBlock block = FaweCache.INSTANCE.getBlock(bukkitBlock.getTypeId(), bukkitBlock.getData());
|
||||||
//
|
//
|
||||||
// // Read the NBT data
|
// // Read the NBT data
|
||||||
// Object nmsWorld = getHandleWorld.invoke(craftWorld);
|
// Object nmsWorld = getHandleWorld.invoke(craftWorld);
|
||||||
|
@ -208,10 +208,10 @@ public final class BukkitAdapter_1_13 extends NMSAdapter {
|
|||||||
if (set == null) {
|
if (set == null) {
|
||||||
return newChunkSection(layer, light);
|
return newChunkSection(layer, light);
|
||||||
}
|
}
|
||||||
final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get();
|
final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get();
|
||||||
final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get();
|
final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
|
||||||
final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get();
|
final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get();
|
||||||
final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get();
|
final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
|
||||||
try {
|
try {
|
||||||
int[] num_palette_buffer = new int[1];
|
int[] num_palette_buffer = new int[1];
|
||||||
int air;
|
int air;
|
||||||
|
@ -493,9 +493,9 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
|
|||||||
ChunkSection section = getSections()[layer];
|
ChunkSection section = getSections()[layer];
|
||||||
// Section is null, return empty array
|
// Section is null, return empty array
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
return FaweCache.IMP.EMPTY_CHAR_4096;
|
return FaweCache.INSTANCE.getEMPTY_CHAR_4096();
|
||||||
}
|
}
|
||||||
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
|
if (data == null || data == FaweCache.INSTANCE.getEMPTY_CHAR_4096()) {
|
||||||
data = new char[4096];
|
data = new char[4096];
|
||||||
}
|
}
|
||||||
DelegateLock lock = BukkitAdapter_1_13.applyLock(section);
|
DelegateLock lock = BukkitAdapter_1_13.applyLock(section);
|
||||||
@ -522,8 +522,8 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
|
|||||||
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
|
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
|
||||||
} else {
|
} else {
|
||||||
num_palette = 0;
|
num_palette = 0;
|
||||||
int[] paletteToBlockInts = FaweCache.IMP.PALETTE_TO_BLOCK.get();
|
int[] paletteToBlockInts = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
|
||||||
char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
|
char[] paletteToBlockChars = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
char paletteVal = data[i];
|
char paletteVal = data[i];
|
||||||
@ -549,7 +549,7 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
|
char[] paletteToOrdinal = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
|
||||||
try {
|
try {
|
||||||
if (num_palette != 1) {
|
if (num_palette != 1) {
|
||||||
for (int i = 0; i < num_palette; i++) {
|
for (int i = 0; i < num_palette; i++) {
|
||||||
|
@ -201,10 +201,10 @@ public final class BukkitAdapter_1_14 extends NMSAdapter {
|
|||||||
if (set == null) {
|
if (set == null) {
|
||||||
return newChunkSection(layer);
|
return newChunkSection(layer);
|
||||||
}
|
}
|
||||||
final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get();
|
final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get();
|
||||||
final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get();
|
final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
|
||||||
final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get();
|
final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get();
|
||||||
final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get();
|
final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
|
||||||
try {
|
try {
|
||||||
int[] num_palette_buffer = new int[1];
|
int[] num_palette_buffer = new int[1];
|
||||||
int air;
|
int air;
|
||||||
|
@ -490,9 +490,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
ChunkSection section = getSections()[layer];
|
ChunkSection section = getSections()[layer];
|
||||||
// Section is null, return empty array
|
// Section is null, return empty array
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
return FaweCache.IMP.EMPTY_CHAR_4096;
|
return FaweCache.INSTANCE.getEMPTY_CHAR_4096();
|
||||||
}
|
}
|
||||||
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
|
if (data == null || data == FaweCache.INSTANCE.getEMPTY_CHAR_4096()) {
|
||||||
data = new char[4096];
|
data = new char[4096];
|
||||||
}
|
}
|
||||||
DelegateLock lock = BukkitAdapter_1_14.applyLock(section);
|
DelegateLock lock = BukkitAdapter_1_14.applyLock(section);
|
||||||
@ -519,8 +519,8 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
|
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
|
||||||
} else {
|
} else {
|
||||||
num_palette = 0;
|
num_palette = 0;
|
||||||
int[] paletteToBlockInts = FaweCache.IMP.PALETTE_TO_BLOCK.get();
|
int[] paletteToBlockInts = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
|
||||||
char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
|
char[] paletteToBlockChars = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
char paletteVal = data[i];
|
char paletteVal = data[i];
|
||||||
@ -546,7 +546,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
|
char[] paletteToOrdinal = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
|
||||||
try {
|
try {
|
||||||
if (num_palette != 1) {
|
if (num_palette != 1) {
|
||||||
for (int i = 0; i < num_palette; i++) {
|
for (int i = 0; i < num_palette; i++) {
|
||||||
|
@ -179,10 +179,10 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
|
|||||||
if (set == null) {
|
if (set == null) {
|
||||||
return newChunkSection(layer);
|
return newChunkSection(layer);
|
||||||
}
|
}
|
||||||
final int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get();
|
final int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get();
|
||||||
final int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get();
|
final int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
|
||||||
final long[] blockStates = FaweCache.IMP.BLOCK_STATES.get();
|
final long[] blockStates = FaweCache.INSTANCE.getBLOCK_STATES().get();
|
||||||
final int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get();
|
final int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
|
||||||
try {
|
try {
|
||||||
int[] num_palette_buffer = new int[1];
|
int[] num_palette_buffer = new int[1];
|
||||||
int air;
|
int air;
|
||||||
|
@ -96,7 +96,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
|
|||||||
BiomeStorage index = getChunk().getBiomeIndex();
|
BiomeStorage index = getChunk().getBiomeIndex();
|
||||||
BiomeBase base = null;
|
BiomeBase base = null;
|
||||||
if (y == -1) {
|
if (y == -1) {
|
||||||
for (y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
for (y = 0; y < FaweCache.WORLD_HEIGHT; y++) {
|
||||||
base = index.getBiome(x, y, z);
|
base = index.getBiome(x, y, z);
|
||||||
if (base != null) break;
|
if (base != null) break;
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
|
|||||||
if (biome != null) {
|
if (biome != null) {
|
||||||
final Biome craftBiome = BukkitAdapter.adapt(biome);
|
final Biome craftBiome = BukkitAdapter.adapt(biome);
|
||||||
BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(craftBiome);
|
BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(craftBiome);
|
||||||
for (int y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) {
|
for (int y = 0; y < FaweCache.WORLD_HEIGHT; y++) {
|
||||||
currentBiomes.setBiome(x, y, z, nmsBiome);
|
currentBiomes.setBiome(x, y, z, nmsBiome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -502,9 +502,9 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
|
|||||||
ChunkSection section = getSections()[layer];
|
ChunkSection section = getSections()[layer];
|
||||||
// Section is null, return empty array
|
// Section is null, return empty array
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
return FaweCache.IMP.EMPTY_CHAR_4096;
|
return FaweCache.INSTANCE.getEMPTY_CHAR_4096();
|
||||||
}
|
}
|
||||||
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
|
if (data == null || data == FaweCache.INSTANCE.getEMPTY_CHAR_4096()) {
|
||||||
data = new char[4096];
|
data = new char[4096];
|
||||||
}
|
}
|
||||||
DelegateLock lock = BukkitAdapter_1_15.applyLock(section);
|
DelegateLock lock = BukkitAdapter_1_15.applyLock(section);
|
||||||
@ -531,8 +531,8 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
|
|||||||
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
|
num_palette = ((DataPaletteHash<IBlockData>) palette).b();
|
||||||
} else {
|
} else {
|
||||||
num_palette = 0;
|
num_palette = 0;
|
||||||
int[] paletteToBlockInts = FaweCache.IMP.PALETTE_TO_BLOCK.get();
|
int[] paletteToBlockInts = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
|
||||||
char[] paletteToBlockChars = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
|
char[] paletteToBlockChars = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 4096; i++) {
|
||||||
char paletteVal = data[i];
|
char paletteVal = data[i];
|
||||||
@ -558,7 +558,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
char[] paletteToOrdinal = FaweCache.IMP.PALETTE_TO_BLOCK_CHAR.get();
|
char[] paletteToOrdinal = FaweCache.INSTANCE.getPALETTE_TO_BLOCK_CHAR().get();
|
||||||
try {
|
try {
|
||||||
if (num_palette != 1) {
|
if (num_palette != 1) {
|
||||||
for (int i = 0; i < num_palette; i++) {
|
for (int i = 0; i < num_palette; i++) {
|
||||||
|
@ -93,7 +93,7 @@ public class CFIPacketListener implements Listener {
|
|||||||
case VOID_AIR:
|
case VOID_AIR:
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
BlockStateHolder block = BukkitAdapter.asBlockState(hand);
|
BlockState block = BukkitAdapter.asBlockState(hand);
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
gen.setBlock(pt, block);
|
gen.setBlock(pt, block);
|
||||||
return;
|
return;
|
||||||
@ -123,7 +123,7 @@ public class CFIPacketListener implements Listener {
|
|||||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.MAP_CHUNK) {
|
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.MAP_CHUNK) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
if (!event.isServerPacket() || FaweCache.IMP.CHUNK_FLAG.get().get()) return;
|
if (!event.isServerPacket() || FaweCache.INSTANCE.getCHUNK_FLAG().get().get()) return;
|
||||||
VirtualWorld gen = getGenerator(event);
|
VirtualWorld gen = getGenerator(event);
|
||||||
if (gen != null) {
|
if (gen != null) {
|
||||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||||
|
@ -312,9 +312,10 @@ public class AsyncBlock implements Block {
|
|||||||
return this.getWorld().getHumidity(this.getX(), this.getZ());
|
return this.getWorld().getHumidity(this.getX(), this.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public PistonMoveReaction getPistonMoveReaction() {
|
public PistonMoveReaction getPistonMoveReaction() {
|
||||||
return null;
|
return PistonMoveReaction.IGNORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -332,6 +333,10 @@ public class AsyncBlock implements Block {
|
|||||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool));
|
return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean breakNaturally(@NotNull ItemStack tool, boolean value) {
|
||||||
|
return TaskManager.IMP.sync(() -> getUnsafeBlock().breakNaturally(tool));
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull @Override
|
@NotNull @Override
|
||||||
public Collection<ItemStack> getDrops() {
|
public Collection<ItemStack> getDrops() {
|
||||||
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops());
|
return TaskManager.IMP.sync(() -> getUnsafeBlock().getDrops());
|
||||||
|
@ -1249,12 +1249,7 @@ public class AsyncWorld extends PassthroughExtent implements World {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHighestBlockYAt(int x, int z, com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
|
public int getHighestBlockYAt(int x, int z, com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
|
||||||
return TaskManager.IMP.sync(new Supplier<Integer>() {
|
return TaskManager.IMP.sync(() -> parent.getHighestBlockYAt(x, z, heightmap));
|
||||||
@Override
|
|
||||||
public Integer get() {
|
|
||||||
return parent.getHighestBlockYAt(x, z, heightmap);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +54,7 @@ public final class AsyncDataContainer implements PersistentDataContainer {
|
|||||||
Validate.notNull(key, "The provided key for the custom value was null");
|
Validate.notNull(key, "The provided key for the custom value was null");
|
||||||
Validate.notNull(type, "The provided type for the custom value was null");
|
Validate.notNull(type, "The provided type for the custom value was null");
|
||||||
Validate.notNull(value, "The provided value for the custom value was null");
|
Validate.notNull(value, "The provided value for the custom value was null");
|
||||||
get().put(key.toString(), FaweCache.IMP.asTag(type.toPrimitive(value, null)));
|
get().put(key.toString(), FaweCache.INSTANCE.asTag(type.toPrimitive(value, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T, Z> boolean has(NamespacedKey key, PersistentDataType<T, Z> type) {
|
public <T, Z> boolean has(NamespacedKey key, PersistentDataType<T, Z> type) {
|
||||||
|
@ -347,10 +347,10 @@ public final class FAWE_Spigot_v1_13_R2 extends CachedBukkitAdapter implements I
|
|||||||
packet.setNativePacket(nmsPacket);
|
packet.setNativePacket(nmsPacket);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
FaweCache.IMP.CHUNK_FLAG.get().set(true);
|
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(true);
|
||||||
current.playerConnection.sendPacket(nmsPacket);
|
current.playerConnection.sendPacket(nmsPacket);
|
||||||
} finally {
|
} finally {
|
||||||
FaweCache.IMP.CHUNK_FLAG.get().set(false);
|
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,10 +347,10 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
|
|||||||
packet.setNativePacket(nmsPacket);
|
packet.setNativePacket(nmsPacket);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
FaweCache.IMP.CHUNK_FLAG.get().set(true);
|
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(true);
|
||||||
entityPlayer.playerConnection.sendPacket(nmsPacket);
|
entityPlayer.playerConnection.sendPacket(nmsPacket);
|
||||||
} finally {
|
} finally {
|
||||||
FaweCache.IMP.CHUNK_FLAG.get().set(false);
|
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -25,6 +25,8 @@ import com.bekvon.bukkit.residence.commands.server;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||||
import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent;
|
import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent;
|
||||||
import com.boydti.fawe.bukkit.adapter.mc1_14.BlockMaterial_1_14;
|
import com.boydti.fawe.bukkit.adapter.mc1_14.BlockMaterial_1_14;
|
||||||
@ -343,10 +345,10 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
|
|||||||
packet.setNativePacket(nmsPacket);
|
packet.setNativePacket(nmsPacket);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
FaweCache.IMP.CHUNK_FLAG.get().set(true);
|
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(true);
|
||||||
entityPlayer.playerConnection.sendPacket(nmsPacket);
|
entityPlayer.playerConnection.sendPacket(nmsPacket);
|
||||||
} finally {
|
} finally {
|
||||||
FaweCache.IMP.CHUNK_FLAG.get().set(false);
|
FaweCache.INSTANCE.getCHUNK_FLAG().get().set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -431,7 +433,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
|
|||||||
// We need to also pull one more chunk in every direction
|
// We need to also pull one more chunk in every direction
|
||||||
Fawe.get().getQueueHandler().startSet(true);
|
Fawe.get().getQueueHandler().startSet(true);
|
||||||
try {
|
try {
|
||||||
SingleThreadQueueExtent extent = new SingleThreadQueueExtent();
|
IQueueExtent<IQueueChunk> extent = new SingleThreadQueueExtent();
|
||||||
extent.init(null, (x, z) -> new BukkitGetBlocks_1_15(freshWorld, x, z) {
|
extent.init(null, (x, z) -> new BukkitGetBlocks_1_15(freshWorld, x, z) {
|
||||||
@Override
|
@Override
|
||||||
public Chunk ensureLoaded(World nmsWorld, int X, int Z) {
|
public Chunk ensureLoaded(World nmsWorld, int X, int Z) {
|
||||||
|
@ -1,545 +0,0 @@
|
|||||||
package com.boydti.fawe;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
|
||||||
|
|
||||||
import com.boydti.fawe.beta.Trimable;
|
|
||||||
import com.boydti.fawe.beta.implementation.queue.Pool;
|
|
||||||
import com.boydti.fawe.beta.implementation.queue.QueuePool;
|
|
||||||
import com.boydti.fawe.config.Settings;
|
|
||||||
import com.boydti.fawe.object.collection.BitArray4096;
|
|
||||||
import com.boydti.fawe.object.collection.CleanableThreadLocal;
|
|
||||||
import com.boydti.fawe.object.collection.VariableThreadLocal;
|
|
||||||
import com.boydti.fawe.object.exception.FaweBlockBagException;
|
|
||||||
import com.boydti.fawe.object.exception.FaweChunkLoadException;
|
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
|
||||||
import com.boydti.fawe.util.IOUtil;
|
|
||||||
import com.boydti.fawe.util.MathMan;
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import com.google.common.cache.CacheLoader;
|
|
||||||
import com.google.common.cache.LoadingCache;
|
|
||||||
import com.sk89q.jnbt.ByteArrayTag;
|
|
||||||
import com.sk89q.jnbt.ByteTag;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.DoubleTag;
|
|
||||||
import com.sk89q.jnbt.EndTag;
|
|
||||||
import com.sk89q.jnbt.FloatTag;
|
|
||||||
import com.sk89q.jnbt.IntArrayTag;
|
|
||||||
import com.sk89q.jnbt.IntTag;
|
|
||||||
import com.sk89q.jnbt.ListTag;
|
|
||||||
import com.sk89q.jnbt.LongArrayTag;
|
|
||||||
import com.sk89q.jnbt.LongTag;
|
|
||||||
import com.sk89q.jnbt.ShortTag;
|
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
|
||||||
import com.sk89q.worldedit.math.MutableVector3;
|
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.IdentityHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
|
||||||
import java.util.concurrent.CancellationException;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public enum FaweCache implements Trimable {
|
|
||||||
IMP
|
|
||||||
; // singleton
|
|
||||||
|
|
||||||
public final int BLOCKS_PER_LAYER = 4096;
|
|
||||||
public final int CHUNK_LAYERS = 16;
|
|
||||||
public final int WORLD_HEIGHT = CHUNK_LAYERS << 4;
|
|
||||||
public final int WORLD_MAX_Y = WORLD_HEIGHT - 1;
|
|
||||||
|
|
||||||
public final char[] EMPTY_CHAR_4096 = new char[4096];
|
|
||||||
|
|
||||||
private final IdentityHashMap<Class<?>, CleanableThreadLocal> REGISTERED_SINGLETONS = new IdentityHashMap<>();
|
|
||||||
private final IdentityHashMap<Class<?>, Pool> REGISTERED_POOLS = new IdentityHashMap<>();
|
|
||||||
|
|
||||||
/*
|
|
||||||
Palette buffers / cache
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized boolean trim(boolean aggressive) {
|
|
||||||
if (aggressive) {
|
|
||||||
CleanableThreadLocal.cleanAll();
|
|
||||||
} else {
|
|
||||||
CHUNK_FLAG.clean();
|
|
||||||
BYTE_BUFFER_8192.clean();
|
|
||||||
BLOCK_TO_PALETTE.clean();
|
|
||||||
PALETTE_TO_BLOCK.clean();
|
|
||||||
BLOCK_STATES.clean();
|
|
||||||
SECTION_BLOCKS.clean();
|
|
||||||
PALETTE_CACHE.clean();
|
|
||||||
PALETTE_TO_BLOCK_CHAR.clean();
|
|
||||||
INDEX_STORE.clean();
|
|
||||||
|
|
||||||
MUTABLE_VECTOR3.clean();
|
|
||||||
MUTABLE_BLOCKVECTOR3.clean();
|
|
||||||
SECTION_BITS_TO_CHAR.clean();
|
|
||||||
for (Map.Entry<Class<?>, CleanableThreadLocal> entry : REGISTERED_SINGLETONS.entrySet()) {
|
|
||||||
entry.getValue().clean();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Map.Entry<Class<?>, Pool> entry : REGISTERED_POOLS.entrySet()) {
|
|
||||||
Pool pool = entry.getValue();
|
|
||||||
pool.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final <T> Pool<T> getPool(Class<T> clazz) {
|
|
||||||
Pool<T> pool = REGISTERED_POOLS.get(clazz);
|
|
||||||
if (pool == null) {
|
|
||||||
synchronized (this) {
|
|
||||||
pool = REGISTERED_POOLS.get(clazz);
|
|
||||||
if (pool == null) {
|
|
||||||
getLogger(FaweCache.class).debug("Not registered " + clazz);
|
|
||||||
Supplier<T> supplier = IOUtil.supplier(clazz::newInstance);
|
|
||||||
pool = supplier::get;
|
|
||||||
REGISTERED_POOLS.put(clazz, pool);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final <T> T getFromPool(Class<T> clazz) {
|
|
||||||
Pool<T> pool = getPool(clazz);
|
|
||||||
return pool.poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final <T> T getSingleton(Class<T> clazz) {
|
|
||||||
CleanableThreadLocal<T> cache = REGISTERED_SINGLETONS.get(clazz);
|
|
||||||
if (cache == null) {
|
|
||||||
synchronized (this) {
|
|
||||||
cache = REGISTERED_SINGLETONS.get(clazz);
|
|
||||||
if (cache == null) {
|
|
||||||
getLogger(FaweCache.class).debug("Not registered " + clazz);
|
|
||||||
cache = new CleanableThreadLocal<>(IOUtil.supplier(clazz::newInstance));
|
|
||||||
REGISTERED_SINGLETONS.put(clazz, cache);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cache.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized <T> CleanableThreadLocal<T> registerSingleton(Class<T> clazz, Supplier<T> cache) {
|
|
||||||
checkNotNull(cache);
|
|
||||||
CleanableThreadLocal<T> local = new CleanableThreadLocal<>(cache);
|
|
||||||
CleanableThreadLocal previous = REGISTERED_SINGLETONS.putIfAbsent(clazz, local);
|
|
||||||
if (previous != null) {
|
|
||||||
throw new IllegalStateException("Previous key");
|
|
||||||
}
|
|
||||||
return local;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized <T> Pool<T> registerPool(Class<T> clazz, Supplier<T> cache, boolean buffer) {
|
|
||||||
checkNotNull(cache);
|
|
||||||
Pool<T> pool;
|
|
||||||
if (buffer) {
|
|
||||||
pool = new QueuePool<>(cache);
|
|
||||||
} else {
|
|
||||||
pool = cache::get;
|
|
||||||
}
|
|
||||||
Pool<T> previous = REGISTERED_POOLS.putIfAbsent(clazz, pool);
|
|
||||||
if (previous != null) {
|
|
||||||
throw new IllegalStateException("Previous key");
|
|
||||||
}
|
|
||||||
return pool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T, V> LoadingCache<T, V> createCache(Supplier<V> withInitial) {
|
|
||||||
return CacheBuilder.newBuilder().build(new CacheLoader<T, V>() {
|
|
||||||
@Override
|
|
||||||
public V load(T key) {
|
|
||||||
return withInitial.get();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T, V> LoadingCache<T, V> createCache(Function<T, V> withInitial) {
|
|
||||||
return CacheBuilder.newBuilder().build(new CacheLoader<T, V>() {
|
|
||||||
@Override
|
|
||||||
public V load(T key) {
|
|
||||||
return withInitial.apply(key);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Exceptions
|
|
||||||
*/
|
|
||||||
public static final FaweChunkLoadException CHUNK = new FaweChunkLoadException();
|
|
||||||
public static final FaweBlockBagException BLOCK_BAG = new FaweBlockBagException();
|
|
||||||
public static final FaweException MANUAL = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual"));
|
|
||||||
public static final FaweException NO_REGION = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.no.region"));
|
|
||||||
public static final FaweException OUTSIDE_REGION = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region"));
|
|
||||||
public static final FaweException MAX_CHECKS = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.checks"));
|
|
||||||
public static final FaweException MAX_CHANGES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.changes"));
|
|
||||||
public static final FaweException LOW_MEMORY = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory"));
|
|
||||||
public static final FaweException MAX_ENTITIES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.entities"));
|
|
||||||
public static final FaweException MAX_TILES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.tiles"));
|
|
||||||
public static final FaweException MAX_ITERATIONS = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.iterations"));
|
|
||||||
|
|
||||||
/*
|
|
||||||
thread cache
|
|
||||||
*/
|
|
||||||
public final CleanableThreadLocal<AtomicBoolean> CHUNK_FLAG = new CleanableThreadLocal<>(AtomicBoolean::new); // resets to false
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<long[]> LONG_BUFFER_1024 = new CleanableThreadLocal<>(() -> new long[1024]);
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<byte[]> BYTE_BUFFER_8192 = new CleanableThreadLocal<>(() -> new byte[8192]);
|
|
||||||
|
|
||||||
public final VariableThreadLocal BYTE_BUFFER_VAR = new VariableThreadLocal();
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<int[]> BLOCK_TO_PALETTE = new CleanableThreadLocal<>(() -> {
|
|
||||||
int[] result = new int[BlockTypesCache.states.length];
|
|
||||||
Arrays.fill(result, Integer.MAX_VALUE);
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<char[]> SECTION_BITS_TO_CHAR = new CleanableThreadLocal<>(() -> new char[4096]);
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<int[]> PALETTE_TO_BLOCK = new CleanableThreadLocal<>(() -> new int[Character.MAX_VALUE + 1]);
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<char[]> PALETTE_TO_BLOCK_CHAR = new CleanableThreadLocal<>(
|
|
||||||
() -> new char[Character.MAX_VALUE + 1], a -> {
|
|
||||||
Arrays.fill(a, Character.MAX_VALUE);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<long[]> BLOCK_STATES = new CleanableThreadLocal<>(() -> new long[2048]);
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<int[]> SECTION_BLOCKS = new CleanableThreadLocal<>(() -> new int[4096]);
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<int[]> INDEX_STORE = new CleanableThreadLocal<>(() -> new int[256]);
|
|
||||||
|
|
||||||
public final CleanableThreadLocal<int[]> HEIGHT_STORE = new CleanableThreadLocal<>(() -> new int[256]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds data for a palette used in a chunk section
|
|
||||||
*/
|
|
||||||
public static final class Palette {
|
|
||||||
public int bitsPerEntry;
|
|
||||||
|
|
||||||
public int paletteToBlockLength;
|
|
||||||
/**
|
|
||||||
* Reusable buffer array, MUST check paletteToBlockLength for actual length
|
|
||||||
*/
|
|
||||||
public int[] paletteToBlock;
|
|
||||||
|
|
||||||
public int blockStatesLength;
|
|
||||||
/**
|
|
||||||
* Reusable buffer array, MUST check blockStatesLength for actual length
|
|
||||||
*/
|
|
||||||
public long[] blockStates;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final CleanableThreadLocal<Palette> PALETTE_CACHE = new CleanableThreadLocal<>(Palette::new);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert raw char array to palette
|
|
||||||
* @param layerOffset
|
|
||||||
* @param blocks
|
|
||||||
* @return palette
|
|
||||||
*/
|
|
||||||
public Palette toPalette(int layerOffset, char[] blocks) {
|
|
||||||
return toPalette(layerOffset, null, blocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert raw int array to palette
|
|
||||||
* @param layerOffset
|
|
||||||
* @param blocks
|
|
||||||
* @return palette
|
|
||||||
*/
|
|
||||||
public Palette toPalette(int layerOffset, int[] blocks) {
|
|
||||||
return toPalette(layerOffset, blocks, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Palette toPalette(int layerOffset, int[] blocksInts, char[] blocksChars) {
|
|
||||||
int[] blockToPalette = BLOCK_TO_PALETTE.get();
|
|
||||||
int[] paletteToBlock = PALETTE_TO_BLOCK.get();
|
|
||||||
long[] blockStates = BLOCK_STATES.get();
|
|
||||||
int[] blocksCopy = SECTION_BLOCKS.get();
|
|
||||||
|
|
||||||
int blockIndexStart = layerOffset << 12;
|
|
||||||
int blockIndexEnd = blockIndexStart + 4096;
|
|
||||||
int num_palette = 0;
|
|
||||||
try {
|
|
||||||
if (blocksChars != null) {
|
|
||||||
for (int i = blockIndexStart, j = 0; i < blockIndexEnd; i++, j++) {
|
|
||||||
int ordinal = blocksChars[i];
|
|
||||||
int palette = blockToPalette[ordinal];
|
|
||||||
if (palette == Integer.MAX_VALUE) {
|
|
||||||
blockToPalette[ordinal] = palette = num_palette;
|
|
||||||
paletteToBlock[num_palette] = ordinal;
|
|
||||||
num_palette++;
|
|
||||||
}
|
|
||||||
blocksCopy[j] = palette;
|
|
||||||
}
|
|
||||||
} else if (blocksInts != null) {
|
|
||||||
for (int i = blockIndexStart, j = 0; i < blockIndexEnd; i++, j++) {
|
|
||||||
int ordinal = blocksInts[i];
|
|
||||||
int palette = blockToPalette[ordinal];
|
|
||||||
if (palette == Integer.MAX_VALUE) {
|
|
||||||
// BlockState state = BlockTypesCache.states[ordinal];
|
|
||||||
blockToPalette[ordinal] = palette = num_palette;
|
|
||||||
paletteToBlock[num_palette] = ordinal;
|
|
||||||
num_palette++;
|
|
||||||
}
|
|
||||||
blocksCopy[j] = palette;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < num_palette; i++) {
|
|
||||||
blockToPalette[paletteToBlock[i]] = Integer.MAX_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// BlockStates
|
|
||||||
int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
|
|
||||||
if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) {
|
|
||||||
bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry
|
|
||||||
} else {
|
|
||||||
bitsPerEntry = Math.max(bitsPerEntry, 1); // For some reason minecraft needs 4096 bits to store 0 entries
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct palette
|
|
||||||
Palette palette = PALETTE_CACHE.get();
|
|
||||||
palette.bitsPerEntry = bitsPerEntry;
|
|
||||||
palette.paletteToBlockLength = num_palette;
|
|
||||||
palette.paletteToBlock = paletteToBlock;
|
|
||||||
|
|
||||||
palette.blockStatesLength = blockBitArrayEnd;
|
|
||||||
palette.blockStates = blockStates;
|
|
||||||
|
|
||||||
return palette;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Arrays.fill(blockToPalette, Integer.MAX_VALUE);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Vector cache
|
|
||||||
*/
|
|
||||||
|
|
||||||
public CleanableThreadLocal<MutableBlockVector3> MUTABLE_BLOCKVECTOR3 = new CleanableThreadLocal<>(MutableBlockVector3::new);
|
|
||||||
|
|
||||||
public CleanableThreadLocal<MutableVector3> MUTABLE_VECTOR3 = new CleanableThreadLocal<MutableVector3>(MutableVector3::new) {
|
|
||||||
@Override
|
|
||||||
public MutableVector3 init() {
|
|
||||||
return new MutableVector3();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Conversion methods between JNBT tags and raw values
|
|
||||||
*/
|
|
||||||
public Map<String, Object> asMap(Object... pairs) {
|
|
||||||
HashMap<String, Object> map = new HashMap<>(pairs.length >> 1);
|
|
||||||
for (int i = 0; i < pairs.length; i += 2) {
|
|
||||||
String key = (String) pairs[i];
|
|
||||||
Object value = pairs[i + 1];
|
|
||||||
map.put(key, value);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShortTag asTag(short value) {
|
|
||||||
return new ShortTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntTag asTag(int value) {
|
|
||||||
return new IntTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DoubleTag asTag(double value) {
|
|
||||||
return new DoubleTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ByteTag asTag(byte value) {
|
|
||||||
return new ByteTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FloatTag asTag(float value) {
|
|
||||||
return new FloatTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LongTag asTag(long value) {
|
|
||||||
return new LongTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ByteArrayTag asTag(byte[] value) {
|
|
||||||
return new ByteArrayTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntArrayTag asTag(int[] value) {
|
|
||||||
return new IntArrayTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LongArrayTag asTag(long[] value) {
|
|
||||||
return new LongArrayTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringTag asTag(String value) {
|
|
||||||
return new StringTag(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompoundTag asTag(Map<String, Object> value) {
|
|
||||||
HashMap<String, Tag> map = new HashMap<>();
|
|
||||||
for (Map.Entry<String, Object> entry : value.entrySet()) {
|
|
||||||
Object child = entry.getValue();
|
|
||||||
Tag tag = asTag(child);
|
|
||||||
map.put(entry.getKey(), tag);
|
|
||||||
}
|
|
||||||
return new CompoundTag(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tag asTag(Object value) {
|
|
||||||
if (value instanceof Integer) {
|
|
||||||
return asTag((int) value);
|
|
||||||
} else if (value instanceof Short) {
|
|
||||||
return asTag((short) value);
|
|
||||||
} else if (value instanceof Double) {
|
|
||||||
return asTag((double) value);
|
|
||||||
} else if (value instanceof Byte) {
|
|
||||||
return asTag((byte) value);
|
|
||||||
} else if (value instanceof Float) {
|
|
||||||
return asTag((float) value);
|
|
||||||
} else if (value instanceof Long) {
|
|
||||||
return asTag((long) value);
|
|
||||||
} else if (value instanceof String) {
|
|
||||||
return asTag((String) value);
|
|
||||||
} else if (value instanceof Map) {
|
|
||||||
return asTag((Map<String, Object>) value);
|
|
||||||
} else if (value instanceof Collection) {
|
|
||||||
return asTag((Collection) value);
|
|
||||||
} else if (value instanceof Object[]) {
|
|
||||||
return asTag((Object[]) value);
|
|
||||||
} else if (value instanceof byte[]) {
|
|
||||||
return asTag((byte[]) value);
|
|
||||||
} else if (value instanceof int[]) {
|
|
||||||
return asTag((int[]) value);
|
|
||||||
} else if (value instanceof long[]) {
|
|
||||||
return asTag((long[]) value);
|
|
||||||
} else if (value instanceof Tag) {
|
|
||||||
return (Tag) value;
|
|
||||||
} else if (value instanceof Boolean) {
|
|
||||||
return asTag((byte) ((boolean) value ? 1 : 0));
|
|
||||||
} else if (value == null) {
|
|
||||||
System.out.println("Invalid nbt: " + value);
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
Class<?> clazz = value.getClass();
|
|
||||||
if (clazz.getName().startsWith("com.intellectualcrafters.jnbt")) {
|
|
||||||
try {
|
|
||||||
if (clazz.getName().equals("com.intellectualcrafters.jnbt.EndTag")) {
|
|
||||||
return new EndTag();
|
|
||||||
}
|
|
||||||
Field field = clazz.getDeclaredField("value");
|
|
||||||
field.setAccessible(true);
|
|
||||||
return asTag(field.get(value));
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("Invalid nbt: " + value);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ListTag asTag(Object... values) {
|
|
||||||
Class<? extends Tag> clazz = null;
|
|
||||||
List<Tag> list = new ArrayList<>(values.length);
|
|
||||||
for (Object value : values) {
|
|
||||||
Tag tag = asTag(value);
|
|
||||||
if (clazz == null) {
|
|
||||||
clazz = tag.getClass();
|
|
||||||
}
|
|
||||||
list.add(tag);
|
|
||||||
}
|
|
||||||
if (clazz == null) clazz = EndTag.class;
|
|
||||||
return new ListTag(clazz, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ListTag asTag(Collection values) {
|
|
||||||
Class<? extends Tag> clazz = null;
|
|
||||||
List<Tag> list = new ArrayList<>(values.size());
|
|
||||||
for (Object value : values) {
|
|
||||||
Tag tag = asTag(value);
|
|
||||||
if (clazz == null) {
|
|
||||||
clazz = tag.getClass();
|
|
||||||
}
|
|
||||||
list.add(tag);
|
|
||||||
}
|
|
||||||
if (clazz == null) clazz = EndTag.class;
|
|
||||||
return new ListTag(clazz, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Thread stuff
|
|
||||||
*/
|
|
||||||
public ThreadPoolExecutor newBlockingExecutor() {
|
|
||||||
int nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS;
|
|
||||||
ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(nThreads);
|
|
||||||
return new ThreadPoolExecutor(nThreads, nThreads,
|
|
||||||
0L, TimeUnit.MILLISECONDS, queue
|
|
||||||
, Executors.defaultThreadFactory(),
|
|
||||||
new ThreadPoolExecutor.CallerRunsPolicy()) {
|
|
||||||
protected void afterExecute(Runnable r, Throwable t) {
|
|
||||||
try {
|
|
||||||
super.afterExecute(r, t);
|
|
||||||
if (t == null && r instanceof Future<?>) {
|
|
||||||
try {
|
|
||||||
Future<?> future = (Future<?>) r;
|
|
||||||
if (future.isDone()) {
|
|
||||||
future.get();
|
|
||||||
}
|
|
||||||
} catch (CancellationException ce) {
|
|
||||||
t = ce;
|
|
||||||
} catch (ExecutionException ee) {
|
|
||||||
t = ee.getCause();
|
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (t != null) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
521
worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt
Normal file
521
worldedit-core/src/main/java/com/boydti/fawe/FaweCache.kt
Normal file
@ -0,0 +1,521 @@
|
|||||||
|
package com.boydti.fawe
|
||||||
|
|
||||||
|
import com.boydti.fawe.`object`.collection.BitArray4096
|
||||||
|
import com.boydti.fawe.`object`.collection.CleanableThreadLocal
|
||||||
|
import com.boydti.fawe.`object`.collection.VariableThreadLocal
|
||||||
|
import com.boydti.fawe.`object`.exception.FaweBlockBagException
|
||||||
|
import com.boydti.fawe.`object`.exception.FaweChunkLoadException
|
||||||
|
import com.boydti.fawe.`object`.exception.FaweException
|
||||||
|
import com.boydti.fawe.beta.Trimable
|
||||||
|
import com.boydti.fawe.beta.implementation.queue.Pool
|
||||||
|
import com.boydti.fawe.beta.implementation.queue.QueuePool
|
||||||
|
import com.boydti.fawe.config.Settings
|
||||||
|
import com.boydti.fawe.util.IOUtil
|
||||||
|
import com.boydti.fawe.util.MathMan
|
||||||
|
import com.google.common.base.Preconditions.checkNotNull
|
||||||
|
import com.google.common.cache.CacheBuilder
|
||||||
|
import com.google.common.cache.CacheLoader
|
||||||
|
import com.google.common.cache.LoadingCache
|
||||||
|
import com.sk89q.jnbt.*
|
||||||
|
import com.sk89q.worldedit.math.MutableBlockVector3
|
||||||
|
import com.sk89q.worldedit.math.MutableVector3
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypesCache
|
||||||
|
import org.slf4j.LoggerFactory.getLogger
|
||||||
|
import java.util.*
|
||||||
|
import java.util.concurrent.*
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
import java.util.function.Function
|
||||||
|
import java.util.function.Supplier
|
||||||
|
|
||||||
|
object FaweCache : Trimable {
|
||||||
|
|
||||||
|
const val BLOCKS_PER_LAYER = 4096
|
||||||
|
const val CHUNK_LAYERS = 16
|
||||||
|
const val WORLD_HEIGHT = CHUNK_LAYERS shl 4
|
||||||
|
const val WORLD_MAX_Y = WORLD_HEIGHT - 1
|
||||||
|
|
||||||
|
val EMPTY_CHAR_4096 = CharArray(4096)
|
||||||
|
|
||||||
|
private val REGISTERED_SINGLETONS = IdentityHashMap<Class<*>, CleanableThreadLocal<*>>()
|
||||||
|
private val REGISTERED_POOLS = IdentityHashMap<Class<*>, Pool<*>>()
|
||||||
|
|
||||||
|
/*
|
||||||
|
thread cache
|
||||||
|
*/
|
||||||
|
val CHUNK_FLAG = CleanableThreadLocal(Supplier { AtomicBoolean() }) // resets to false
|
||||||
|
|
||||||
|
val LONG_BUFFER_1024 = CleanableThreadLocal { LongArray(1024) }
|
||||||
|
|
||||||
|
val BYTE_BUFFER_8192 = CleanableThreadLocal { ByteArray(8192) }
|
||||||
|
|
||||||
|
val BYTE_BUFFER_VAR = VariableThreadLocal()
|
||||||
|
|
||||||
|
val BLOCK_TO_PALETTE = CleanableThreadLocal {
|
||||||
|
val result = IntArray(BlockTypesCache.states.size)
|
||||||
|
Arrays.fill(result, Integer.MAX_VALUE)
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
val SECTION_BITS_TO_CHAR = CleanableThreadLocal { CharArray(4096) }
|
||||||
|
|
||||||
|
val PALETTE_TO_BLOCK = CleanableThreadLocal { IntArray(Character.MAX_VALUE.toInt() + 1) }
|
||||||
|
|
||||||
|
val PALETTE_TO_BLOCK_CHAR = CleanableThreadLocal<CharArray>(
|
||||||
|
fun(): CharArray {
|
||||||
|
return CharArray(Char.MAX_VALUE.toInt() + 1)
|
||||||
|
}, fun(a: CharArray): Unit = Arrays.fill(a, Char.MAX_VALUE)
|
||||||
|
)
|
||||||
|
|
||||||
|
val BLOCK_STATES = CleanableThreadLocal { LongArray(2048) }
|
||||||
|
|
||||||
|
val SECTION_BLOCKS = CleanableThreadLocal { IntArray(4096) }
|
||||||
|
|
||||||
|
val INDEX_STORE = CleanableThreadLocal { IntArray(256) }
|
||||||
|
|
||||||
|
val HEIGHT_STORE = CleanableThreadLocal { IntArray(256) }
|
||||||
|
|
||||||
|
private val PALETTE_CACHE = CleanableThreadLocal(Supplier { Palette() })
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Vector cache
|
||||||
|
*/
|
||||||
|
|
||||||
|
var MUTABLE_BLOCKVECTOR3 = CleanableThreadLocal(Supplier { MutableBlockVector3() })
|
||||||
|
|
||||||
|
var MUTABLE_VECTOR3: CleanableThreadLocal<MutableVector3> = object : CleanableThreadLocal<MutableVector3>(Supplier { MutableVector3() }) {
|
||||||
|
override fun init(): MutableVector3 {
|
||||||
|
return MutableVector3()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Palette buffers / cache
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
override fun trim(aggressive: Boolean): Boolean {
|
||||||
|
if (aggressive) {
|
||||||
|
CleanableThreadLocal.cleanAll()
|
||||||
|
} else {
|
||||||
|
CHUNK_FLAG.clean()
|
||||||
|
BYTE_BUFFER_8192.clean()
|
||||||
|
BLOCK_TO_PALETTE.clean()
|
||||||
|
PALETTE_TO_BLOCK.clean()
|
||||||
|
BLOCK_STATES.clean()
|
||||||
|
SECTION_BLOCKS.clean()
|
||||||
|
PALETTE_CACHE.clean()
|
||||||
|
PALETTE_TO_BLOCK_CHAR.clean()
|
||||||
|
INDEX_STORE.clean()
|
||||||
|
|
||||||
|
MUTABLE_VECTOR3.clean()
|
||||||
|
MUTABLE_BLOCKVECTOR3.clean()
|
||||||
|
SECTION_BITS_TO_CHAR.clean()
|
||||||
|
for ((_, value) in REGISTERED_SINGLETONS) {
|
||||||
|
value.clean()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ((_, pool) in REGISTERED_POOLS) {
|
||||||
|
pool.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> getPool(clazz: Class<T>): Pool<T>? {
|
||||||
|
var pool: Pool<T>? = REGISTERED_POOLS[clazz] as Pool<T>?
|
||||||
|
if (pool == null) {
|
||||||
|
synchronized(this) {
|
||||||
|
pool = REGISTERED_POOLS[clazz] as Pool<T>?
|
||||||
|
if (pool == null) {
|
||||||
|
getLogger(FaweCache::class.java).debug("Not registered $clazz")
|
||||||
|
val supplier = IOUtil.supplier<T> { clazz.newInstance() }
|
||||||
|
pool = Pool { supplier.get() }
|
||||||
|
REGISTERED_POOLS[clazz] = pool
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pool
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> getFromPool(clazz: Class<T>): T? {
|
||||||
|
val pool = getPool(clazz)
|
||||||
|
return pool?.poll()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> getSingleton(clazz: Class<T>): T {
|
||||||
|
var cache: CleanableThreadLocal<T>? = REGISTERED_SINGLETONS[clazz] as CleanableThreadLocal<T>?
|
||||||
|
if (cache == null) {
|
||||||
|
synchronized(this) {
|
||||||
|
cache = REGISTERED_SINGLETONS[clazz] as CleanableThreadLocal<T>?
|
||||||
|
if (cache == null) {
|
||||||
|
getLogger(FaweCache::class.java).debug("Not registered $clazz")
|
||||||
|
cache = CleanableThreadLocal(IOUtil.supplier { clazz.newInstance() })
|
||||||
|
REGISTERED_SINGLETONS[clazz] = cache
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cache!!.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun <T> registerSingleton(clazz: Class<T>, cache: Supplier<T>): CleanableThreadLocal<T> {
|
||||||
|
checkNotNull(cache)
|
||||||
|
val local = CleanableThreadLocal(cache)
|
||||||
|
val previous = (REGISTERED_SINGLETONS as java.util.Map<Class<*>, CleanableThreadLocal<*>>).putIfAbsent(clazz, local)
|
||||||
|
check(previous == null) { "Previous key" }
|
||||||
|
return local
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun <T> registerPool(clazz: Class<T>, cache: Supplier<T>, buffer: Boolean): Pool<T> {
|
||||||
|
checkNotNull(cache)
|
||||||
|
val pool: Pool<T>
|
||||||
|
if (buffer) {
|
||||||
|
pool = QueuePool(cache)
|
||||||
|
} else {
|
||||||
|
pool = Pool { cache.get() }
|
||||||
|
}
|
||||||
|
val previous = (REGISTERED_POOLS as java.util.Map<Class<*>, Pool<*>>).putIfAbsent(clazz, pool)
|
||||||
|
check(previous == null) { "Previous key" }
|
||||||
|
return pool
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T, V> createCache(withInitial: Supplier<V>): LoadingCache<T, V> {
|
||||||
|
return CacheBuilder.newBuilder().build(object : CacheLoader<T, V>() {
|
||||||
|
override fun load(key: T): V {
|
||||||
|
return withInitial.get()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T, V> createCache(withInitial: Function<T, V>): LoadingCache<T, V> {
|
||||||
|
return CacheBuilder.newBuilder().build(object : CacheLoader<T, V>() {
|
||||||
|
override fun load(key: T): V {
|
||||||
|
return withInitial.apply(key)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds data for a palette used in a chunk section
|
||||||
|
*/
|
||||||
|
class Palette {
|
||||||
|
var bitsPerEntry: Int = 0
|
||||||
|
|
||||||
|
var paletteToBlockLength: Int = 0
|
||||||
|
/**
|
||||||
|
* Reusable buffer array, MUST check paletteToBlockLength for actual length
|
||||||
|
*/
|
||||||
|
var paletteToBlock: IntArray? = null
|
||||||
|
|
||||||
|
var blockStatesLength: Int = 0
|
||||||
|
/**
|
||||||
|
* Reusable buffer array, MUST check blockStatesLength for actual length
|
||||||
|
*/
|
||||||
|
var blockStates: LongArray? = null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert raw char array to palette
|
||||||
|
* @param layerOffset
|
||||||
|
* @param blocks
|
||||||
|
* @return palette
|
||||||
|
*/
|
||||||
|
fun toPalette(layerOffset: Int, blocks: CharArray): Palette {
|
||||||
|
return toPalette(layerOffset, null, blocks)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert raw int array to palette
|
||||||
|
* @param layerOffset
|
||||||
|
* @param blocks
|
||||||
|
* @return palette
|
||||||
|
*/
|
||||||
|
fun toPalette(layerOffset: Int, blocks: IntArray): Palette {
|
||||||
|
return toPalette(layerOffset, blocks, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toPalette(layerOffset: Int, blocksInts: IntArray?, blocksChars: CharArray?): Palette {
|
||||||
|
val blockToPalette = BLOCK_TO_PALETTE.get()
|
||||||
|
val paletteToBlock = PALETTE_TO_BLOCK.get()
|
||||||
|
val blockStates = BLOCK_STATES.get()
|
||||||
|
val blocksCopy = SECTION_BLOCKS.get()
|
||||||
|
|
||||||
|
val blockIndexStart = layerOffset shl 12
|
||||||
|
val blockIndexEnd = blockIndexStart + 4096
|
||||||
|
var num_palette = 0
|
||||||
|
try {
|
||||||
|
if (blocksChars != null) {
|
||||||
|
var i = blockIndexStart
|
||||||
|
var j = 0
|
||||||
|
while (i < blockIndexEnd) {
|
||||||
|
val ordinal = blocksChars[i].toInt()
|
||||||
|
var palette = blockToPalette[ordinal]
|
||||||
|
if (palette == Integer.MAX_VALUE) {
|
||||||
|
palette = num_palette
|
||||||
|
blockToPalette[ordinal] = palette
|
||||||
|
paletteToBlock[num_palette] = ordinal
|
||||||
|
num_palette++
|
||||||
|
}
|
||||||
|
blocksCopy[j] = palette
|
||||||
|
i++
|
||||||
|
j++
|
||||||
|
}
|
||||||
|
} else if (blocksInts != null) {
|
||||||
|
var i = blockIndexStart
|
||||||
|
var j = 0
|
||||||
|
while (i < blockIndexEnd) {
|
||||||
|
val ordinal = blocksInts[i]
|
||||||
|
var palette = blockToPalette[ordinal]
|
||||||
|
if (palette == Integer.MAX_VALUE) {
|
||||||
|
// BlockState state = BlockTypesCache.states[ordinal];
|
||||||
|
palette = num_palette
|
||||||
|
blockToPalette[ordinal] = palette
|
||||||
|
paletteToBlock[num_palette] = ordinal
|
||||||
|
num_palette++
|
||||||
|
}
|
||||||
|
blocksCopy[j] = palette
|
||||||
|
i++
|
||||||
|
j++
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw IllegalArgumentException()
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i in 0 until num_palette) {
|
||||||
|
blockToPalette[paletteToBlock[i]] = Integer.MAX_VALUE
|
||||||
|
}
|
||||||
|
|
||||||
|
// BlockStates
|
||||||
|
var bitsPerEntry = MathMan.log2nlz(num_palette - 1)
|
||||||
|
if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) {
|
||||||
|
bitsPerEntry = Math.max(bitsPerEntry, 4) // Protocol support breaks <4 bits per entry
|
||||||
|
} else {
|
||||||
|
bitsPerEntry = Math.max(bitsPerEntry, 1) // For some reason minecraft needs 4096 bits to store 0 entries
|
||||||
|
}
|
||||||
|
var blockBitArrayEnd = bitsPerEntry * 4096 shr 6
|
||||||
|
if (num_palette == 1) {
|
||||||
|
// Set a value, because minecraft needs it for some reason
|
||||||
|
blockStates[0] = 0
|
||||||
|
blockBitArrayEnd = 1
|
||||||
|
} else {
|
||||||
|
val bitArray = BitArray4096(blockStates, bitsPerEntry)
|
||||||
|
bitArray.fromRaw(blocksCopy)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct palette
|
||||||
|
val palette = PALETTE_CACHE.get()
|
||||||
|
palette.bitsPerEntry = bitsPerEntry
|
||||||
|
palette.paletteToBlockLength = num_palette
|
||||||
|
palette.paletteToBlock = paletteToBlock
|
||||||
|
|
||||||
|
palette.blockStatesLength = blockBitArrayEnd
|
||||||
|
palette.blockStates = blockStates
|
||||||
|
|
||||||
|
return palette
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
e.printStackTrace()
|
||||||
|
Arrays.fill(blockToPalette, Integer.MAX_VALUE)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Conversion methods between JNBT tags and raw values
|
||||||
|
*/
|
||||||
|
fun asMap(vararg pairs: Any): Map<String, Any> {
|
||||||
|
val map = HashMap<String, Any>(pairs.size shr 1)
|
||||||
|
var i = 0
|
||||||
|
while (i < pairs.size) {
|
||||||
|
val key = pairs[i] as String
|
||||||
|
val value = pairs[i + 1]
|
||||||
|
map[key] = value
|
||||||
|
i += 2
|
||||||
|
}
|
||||||
|
return map
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: Short): ShortTag {
|
||||||
|
return ShortTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: Int): IntTag {
|
||||||
|
return IntTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: Double): DoubleTag {
|
||||||
|
return DoubleTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: Byte): ByteTag {
|
||||||
|
return ByteTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: Float): FloatTag {
|
||||||
|
return FloatTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: Long): LongTag {
|
||||||
|
return LongTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: ByteArray): ByteArrayTag {
|
||||||
|
return ByteArrayTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: IntArray): IntArrayTag {
|
||||||
|
return IntArrayTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: LongArray): LongArrayTag {
|
||||||
|
return LongArrayTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: String): StringTag {
|
||||||
|
return StringTag(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: Map<String, Any>): CompoundTag {
|
||||||
|
val map = HashMap<String, Tag>()
|
||||||
|
for ((key, child) in value) {
|
||||||
|
val tag = asTag(child)
|
||||||
|
map[key] = tag
|
||||||
|
}
|
||||||
|
return CompoundTag(map)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(value: Any?): Tag? {
|
||||||
|
if (value is Int) {
|
||||||
|
return asTag(value)
|
||||||
|
} else if (value is Short) {
|
||||||
|
return asTag(value)
|
||||||
|
} else if (value is Double) {
|
||||||
|
return asTag(value)
|
||||||
|
} else if (value is Byte) {
|
||||||
|
return asTag(value)
|
||||||
|
} else if (value is Float) {
|
||||||
|
return asTag(value)
|
||||||
|
} else if (value is Long) {
|
||||||
|
return asTag(value)
|
||||||
|
} else if (value is String) {
|
||||||
|
return asTag(value as String?)
|
||||||
|
} else if (value is Map<*, *>) {
|
||||||
|
return asTag((value as Map<String, Any>?)!!)
|
||||||
|
} else if (value is Collection<*>) {
|
||||||
|
return asTag((value as Collection<*>?)!!)
|
||||||
|
} else if (value is Array<*>) {
|
||||||
|
return asTag(*(value as Array<Any>?)!!)
|
||||||
|
} else if (value is ByteArray) {
|
||||||
|
return asTag(value as ByteArray?)
|
||||||
|
} else if (value is IntArray) {
|
||||||
|
return asTag(value as IntArray?)
|
||||||
|
} else if (value is LongArray) {
|
||||||
|
return asTag(value as LongArray?)
|
||||||
|
} else if (value is Tag) {
|
||||||
|
return value
|
||||||
|
} else if (value is Boolean) {
|
||||||
|
return asTag((if (value) 1 else 0).toByte())
|
||||||
|
} else if (value == null) {
|
||||||
|
println("Invalid nbt: " + value!!)
|
||||||
|
return null
|
||||||
|
} else {
|
||||||
|
val clazz = value.javaClass
|
||||||
|
if (clazz.name.startsWith("com.intellectualcrafters.jnbt")) {
|
||||||
|
try {
|
||||||
|
if (clazz.name == "com.intellectualcrafters.jnbt.EndTag") {
|
||||||
|
return EndTag()
|
||||||
|
}
|
||||||
|
val field = clazz.getDeclaredField("value")
|
||||||
|
field.isAccessible = true
|
||||||
|
return asTag(field.get(value))
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
println("Invalid nbt: $value")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(vararg values: Any): ListTag {
|
||||||
|
var clazz: Class<out Tag>? = null
|
||||||
|
val list = ArrayList<Tag>(values.size)
|
||||||
|
for (value in values) {
|
||||||
|
val tag = asTag(value)
|
||||||
|
if (clazz == null) {
|
||||||
|
clazz = tag.javaClass
|
||||||
|
}
|
||||||
|
list.add(tag)
|
||||||
|
}
|
||||||
|
if (clazz == null) clazz = EndTag::class.java
|
||||||
|
return ListTag(clazz, list)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun asTag(values: Collection<*>): ListTag {
|
||||||
|
var clazz: Class<out Tag>? = null
|
||||||
|
val list: ArrayList<Tag> = ArrayList<Tag>(values.size)
|
||||||
|
for (value in values) {
|
||||||
|
val tag = asTag(value)
|
||||||
|
if (clazz == null) {
|
||||||
|
clazz = tag!!.javaClass
|
||||||
|
}
|
||||||
|
if (tag != null) {
|
||||||
|
list.add(tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (clazz == null) clazz = EndTag::class.java
|
||||||
|
return ListTag(clazz, list)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Thread stuff
|
||||||
|
*/
|
||||||
|
fun newBlockingExecutor(): ThreadPoolExecutor {
|
||||||
|
val nThreads = Settings.IMP.QUEUE.PARALLEL_THREADS
|
||||||
|
val queue = ArrayBlockingQueue<Runnable>(nThreads)
|
||||||
|
return object : ThreadPoolExecutor(nThreads, nThreads,
|
||||||
|
0L, TimeUnit.MILLISECONDS, queue, Executors.defaultThreadFactory(),
|
||||||
|
ThreadPoolExecutor.CallerRunsPolicy()) {
|
||||||
|
override fun afterExecute(r: Runnable?, t: Throwable?) {
|
||||||
|
var t = t
|
||||||
|
try {
|
||||||
|
super.afterExecute(r, t)
|
||||||
|
if (t == null && r is Future<*>) {
|
||||||
|
try {
|
||||||
|
val future = r as Future<*>?
|
||||||
|
if (future!!.isDone) {
|
||||||
|
future.get()
|
||||||
|
}
|
||||||
|
} catch (ce: CancellationException) {
|
||||||
|
t = ce
|
||||||
|
} catch (ee: ExecutionException) {
|
||||||
|
t = ee.cause
|
||||||
|
} catch (ie: InterruptedException) {
|
||||||
|
Thread.currentThread().interrupt()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
t?.printStackTrace()
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val CHUNK = FaweChunkLoadException()
|
||||||
|
val BLOCK_BAG = FaweBlockBagException()
|
||||||
|
val MANUAL = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual"))
|
||||||
|
val NO_REGION = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.no.region"))
|
||||||
|
val OUTSIDE_REGION = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region"))
|
||||||
|
val MAX_CHECKS = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.checks"))
|
||||||
|
val MAX_CHANGES = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.changes"))
|
||||||
|
val LOW_MEMORY = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory"))
|
||||||
|
val MAX_ENTITIES = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.entities"))
|
||||||
|
val MAX_TILES = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.tiles"))
|
||||||
|
val MAX_ITERATIONS = FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.iterations"))
|
||||||
|
}
|
@ -34,7 +34,7 @@ public class CombinedBlocks implements IBlocks {
|
|||||||
@Override
|
@Override
|
||||||
public int getBitMask() {
|
public int getBitMask() {
|
||||||
int bitMask = addMask;
|
int bitMask = addMask;
|
||||||
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) {
|
||||||
if (primary.hasSection(layer)) {
|
if (primary.hasSection(layer)) {
|
||||||
bitMask |= (1 << layer);
|
bitMask |= (1 << layer);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public interface IBatchProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int maxLayer = (maxY + 1) >> 4;
|
int maxLayer = (maxY + 1) >> 4;
|
||||||
for (int layer = maxLayer; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
for (int layer = maxLayer; layer < FaweCache.CHUNK_LAYERS; layer++) {
|
||||||
if (set.hasSection(layer)) {
|
if (set.hasSection(layer)) {
|
||||||
if (layer == minLayer) {
|
if (layer == minLayer) {
|
||||||
char[] arr = set.load(layer);
|
char[] arr = set.load(layer);
|
||||||
|
@ -36,7 +36,7 @@ public interface IBlocks extends Trimable {
|
|||||||
BiomeType getBiomeType(int x, int y, int z);
|
BiomeType getBiomeType(int x, int y, int z);
|
||||||
|
|
||||||
default int getBitMask() {
|
default int getBitMask() {
|
||||||
return IntStream.range(0, FaweCache.IMP.CHUNK_LAYERS).filter(this::hasSection)
|
return IntStream.range(0, FaweCache.CHUNK_LAYERS).filter(this::hasSection)
|
||||||
.map(layer -> (1 << layer)).sum();
|
.map(layer -> (1 << layer)).sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ public interface IBlocks extends Trimable {
|
|||||||
FaweOutputStream sectionWriter = new FaweOutputStream(sectionByteArray);
|
FaweOutputStream sectionWriter = new FaweOutputStream(sectionByteArray);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) {
|
||||||
if (!this.hasSection(layer) || (bitMask & (1 << layer)) == 0) continue;
|
if (!this.hasSection(layer) || (bitMask & (1 << layer)) == 0) continue;
|
||||||
|
|
||||||
char[] ids = this.load(layer);
|
char[] ids = this.load(layer);
|
||||||
@ -92,12 +92,12 @@ public interface IBlocks extends Trimable {
|
|||||||
// }
|
// }
|
||||||
// sectionWriter.write(bits.getData());
|
// sectionWriter.write(bits.getData());
|
||||||
// } else {
|
// } else {
|
||||||
FaweCache.Palette palette = FaweCache.IMP.toPalette(0, ids);
|
FaweCache.Palette palette = FaweCache.INSTANCE.toPalette(0, ids);
|
||||||
|
|
||||||
sectionWriter.writeByte(palette.bitsPerEntry); // bits per block
|
sectionWriter.writeByte(palette.getBitsPerEntry()); // bits per block
|
||||||
sectionWriter.writeVarInt(palette.paletteToBlockLength);
|
sectionWriter.writeVarInt(palette.getPaletteToBlockLength());
|
||||||
for (int i = 0; i < palette.paletteToBlockLength; i++) {
|
for (int i = 0; i < palette.getPaletteToBlockLength(); i++) {
|
||||||
int ordinal = palette.paletteToBlock[i];
|
int ordinal = palette.getPaletteToBlock()[i];
|
||||||
switch (ordinal) {
|
switch (ordinal) {
|
||||||
case BlockID.__RESERVED__:
|
case BlockID.__RESERVED__:
|
||||||
case BlockID.CAVE_AIR:
|
case BlockID.CAVE_AIR:
|
||||||
@ -112,9 +112,9 @@ public interface IBlocks extends Trimable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sectionWriter.writeVarInt(palette.blockStatesLength);
|
sectionWriter.writeVarInt(palette.getBlockStatesLength());
|
||||||
for (int i = 0; i < palette.blockStatesLength; i++) {
|
for (int i = 0; i < palette.getBlockStatesLength(); i++) {
|
||||||
sectionWriter.writeLong(palette.blockStates[i]);
|
sectionWriter.writeLong(palette.getBlockStates()[i]);
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
@ -1,369 +0,0 @@
|
|||||||
package com.boydti.fawe.beta;
|
|
||||||
|
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
||||||
import com.sk89q.worldedit.function.generator.GenBase;
|
|
||||||
import com.sk89q.worldedit.function.generator.Resource;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
|
||||||
import com.sk89q.worldedit.util.Countable;
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegate for IQueueExtent
|
|
||||||
*/
|
|
||||||
public interface IDelegateQueueExtent<T extends IQueueChunk> extends IQueueExtent<T> {
|
|
||||||
|
|
||||||
IQueueExtent<T> getParent();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean isQueueEnabled() {
|
|
||||||
return getParent().isQueueEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void enableQueue() {
|
|
||||||
getParent().enableQueue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void disableQueue() {
|
|
||||||
getParent().disableQueue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void init(Extent extent, IChunkCache<IChunkGet> get, IChunkCache<IChunkSet> set) {
|
|
||||||
getParent().init(extent, get, set);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default IChunkGet getCachedGet(int x, int z) {
|
|
||||||
return getParent().getCachedGet(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default IChunkSet getCachedSet(int x, int z) {
|
|
||||||
return getParent().getCachedSet(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default T getOrCreateChunk(int x, int z) {
|
|
||||||
return getParent().getOrCreateChunk(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default <V extends Future<V>> V submit(T chunk) {
|
|
||||||
return getParent().submit(chunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B state) {
|
|
||||||
return getParent().setBlock(x, y, z, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
|
||||||
return getParent().setTile(x, y, z, tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean setBiome(int x, int y, int z, BiomeType biome) {
|
|
||||||
return getParent().setBiome(x, y, z, biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default BlockState getBlock(int x, int y, int z) {
|
|
||||||
return getParent().getBlock(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default BaseBlock getFullBlock(int x, int y, int z) {
|
|
||||||
return getParent().getFullBlock(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default BlockVector3 getMinimumPoint() {
|
|
||||||
return getParent().getMinimumPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default BlockVector3 getMaximumPoint() {
|
|
||||||
return getParent().getMaximumPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default T create(boolean isFull) {
|
|
||||||
return getParent().create(isFull);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default T wrap(T root) {
|
|
||||||
return getParent().wrap(root);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void flush() {
|
|
||||||
getParent().flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default ChunkFilterBlock initFilterBlock() {
|
|
||||||
return getParent().initFilterBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int size() {
|
|
||||||
return getParent().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean isEmpty() {
|
|
||||||
return getParent().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean trim(boolean aggressive) {
|
|
||||||
return getParent().trim(aggressive);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void recycle() {
|
|
||||||
getParent().recycle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default List<? extends Entity> getEntities(Region region) {
|
|
||||||
return getParent().getEntities(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default List<? extends Entity> getEntities() {
|
|
||||||
return getParent().getEntities();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
default Entity createEntity(Location location, BaseEntity entity) {
|
|
||||||
return getParent().createEntity(location, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void removeEntity(int x, int y, int z, UUID uuid) {
|
|
||||||
getParent().removeEntity(x, y, z, uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean isWorld() {
|
|
||||||
return getParent().isWorld();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean regenerateChunk(int x, int z, @Nullable BiomeType type, @Nullable Long seed) {
|
|
||||||
return getParent().regenerateChunk(x, z, type, seed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
|
||||||
return getParent().getHighestTerrainBlock(x, z, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
|
||||||
return getParent().getHighestTerrainBlock(x, z, minY, maxY, filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
|
||||||
return getParent().getNearestSurfaceLayer(x, z, y, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
|
|
||||||
return getParent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
|
||||||
return getParent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
|
||||||
return getParent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
|
|
||||||
return getParent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
|
|
||||||
return getParent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void addCaves(Region region) throws WorldEditException {
|
|
||||||
getParent().addCaves(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void generate(Region region, GenBase gen) throws WorldEditException {
|
|
||||||
getParent().generate(region, gen);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
|
||||||
getParent().addSchems(region, mask, clipboards, rarity, rotate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
|
||||||
getParent().spawnResource(region, gen, rarity, frequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean contains(BlockVector3 pt) {
|
|
||||||
return getParent().contains(pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
|
||||||
getParent().addOre(region, mask, material, size, frequency, rarity, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default void addOres(Region region, Mask mask) throws WorldEditException {
|
|
||||||
getParent().addOres(region, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default List<Countable<BlockType>> getBlockDistribution(Region region) {
|
|
||||||
return getParent().getBlockDistribution(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
|
|
||||||
return getParent().getBlockDistributionWithData(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
default Operation commit() {
|
|
||||||
return getParent().commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean cancel() {
|
|
||||||
return getParent().cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int getMaxY() {
|
|
||||||
return getParent().getMaxY();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default Clipboard lazyCopy(Region region) {
|
|
||||||
return getParent().lazyCopy(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
|
||||||
return getParent().countBlocks(region, searchBlocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int countBlocks(Region region, Mask searchMask) {
|
|
||||||
return getParent().countBlocks(region, searchMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
|
||||||
return getParent().setBlocks(region, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
|
||||||
return getParent().setBlocks(region, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
|
|
||||||
return getParent().replaceBlocks(region, filter, replacement);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
|
||||||
return getParent().replaceBlocks(region, filter, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
|
||||||
return getParent().replaceBlocks(region, mask, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
|
||||||
return getParent().center(region, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default int setBlocks(Set<BlockVector3> vset, Pattern pattern) {
|
|
||||||
return getParent().setBlocks(vset, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default BlockState getBlock(BlockVector3 position) {
|
|
||||||
return getParent().getBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default BaseBlock getFullBlock(BlockVector3 position) {
|
|
||||||
return getParent().getFullBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default BiomeType getBiome(BlockVector2 position) {
|
|
||||||
return getParent().getBiome(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default BiomeType getBiomeType(int x, int y, int z) {
|
|
||||||
return getParent().getBiomeType(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block) throws WorldEditException {
|
|
||||||
return getParent().setBlock(position, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default boolean setBiome(BlockVector2 position, BiomeType biome) {
|
|
||||||
return getParent().setBiome(position, biome);
|
|
||||||
}
|
|
||||||
}
|
|
@ -78,7 +78,7 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BlockVector3 getMaximumPoint() {
|
default BlockVector3 getMaximumPoint() {
|
||||||
return BlockVector3.at(30000000, FaweCache.IMP.WORLD_MAX_Y, 30000000);
|
return BlockVector3.at(30000000, FaweCache.WORLD_MAX_Y, 30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +84,7 @@ public class BitSetBlocks implements IChunkSet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] load(int layer) {
|
public char[] load(int layer) {
|
||||||
char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get();
|
||||||
MemBlockSet.IRow nullRowY = row.getRow(layer);
|
MemBlockSet.IRow nullRowY = row.getRow(layer);
|
||||||
if (nullRowY instanceof MemBlockSet.RowY) {
|
if (nullRowY instanceof MemBlockSet.RowY) {
|
||||||
char value = blockState.getOrdinalChar();
|
char value = blockState.getOrdinalChar();
|
||||||
|
@ -24,7 +24,7 @@ import java.util.UUID;
|
|||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
||||||
private static Pool<CharSetBlocks> POOL = FaweCache.IMP.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL);
|
private static Pool<CharSetBlocks> POOL = FaweCache.INSTANCE.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL);
|
||||||
public static CharSetBlocks newInstance() {
|
public static CharSetBlocks newInstance() {
|
||||||
return POOL.poll();
|
return POOL.poll();
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public class FallbackChunkGet implements IChunkGet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] load(int layer) {
|
public char[] load(int layer) {
|
||||||
char[] arr = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
char[] arr = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get();
|
||||||
int by = layer << 4;
|
int by = layer << 4;
|
||||||
for (int y = 0, i = 0; y < 16; y++) {
|
for (int y = 0, i = 0; y < 16; y++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
|
@ -55,7 +55,7 @@ object NullChunkGet : IChunkGet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun load(layer: Int): CharArray {
|
override fun load(layer: Int): CharArray {
|
||||||
return FaweCache.IMP.EMPTY_CHAR_4096
|
return FaweCache.EMPTY_CHAR_4096
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hasSection(layer: Int): Boolean {
|
override fun hasSection(layer: Int): Boolean {
|
||||||
|
@ -29,7 +29,7 @@ import javax.annotation.Nullable;
|
|||||||
*/
|
*/
|
||||||
public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||||
|
|
||||||
private static Pool<ChunkHolder> POOL = FaweCache.IMP.registerPool(ChunkHolder.class, ChunkHolder::new, Settings.IMP.QUEUE.POOL);
|
private static Pool<ChunkHolder> POOL = FaweCache.INSTANCE.registerPool(ChunkHolder.class, ChunkHolder::new, Settings.IMP.QUEUE.POOL);
|
||||||
|
|
||||||
public static ChunkHolder newInstance() {
|
public static ChunkHolder newInstance() {
|
||||||
return POOL.poll();
|
return POOL.poll();
|
||||||
|
@ -1,150 +0,0 @@
|
|||||||
package com.boydti.fawe.beta.implementation.chunk;
|
|
||||||
|
|
||||||
import com.boydti.fawe.beta.Filter;
|
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
|
||||||
import com.boydti.fawe.beta.IQueueChunk;
|
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public enum NullChunk implements IQueueChunk {
|
|
||||||
INSTANCE;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getX() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getZ() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Future call() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, boolean full) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEntity(CompoundTag tag) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeEntity(UUID uuid) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<UUID> getEntityRemoves() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiomeType[] getBiomes() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBlocks(int layer, char[] data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiomeType getBiomeType(int x, int y, int z) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasSection(int layer) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getBlock(int x, int y, int z) {
|
|
||||||
return BlockTypes.__RESERVED__.getDefaultState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
|
||||||
return BlockTypes.__RESERVED__.getDefaultState().toBaseBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<BlockVector3, CompoundTag> getTiles() {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag getTile(int x, int y, int z) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<CompoundTag> getEntities() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public char[] load(int layer) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag getEntity(UUID uuid) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Future call(IChunkSet set, Runnable finalize) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean trim(boolean aggressive) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,121 @@
|
|||||||
|
package com.boydti.fawe.beta.implementation.chunk
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.Filter
|
||||||
|
import com.boydti.fawe.beta.IChunkSet
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk
|
||||||
|
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock
|
||||||
|
import com.sk89q.jnbt.CompoundTag
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3
|
||||||
|
import com.sk89q.worldedit.regions.Region
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes
|
||||||
|
import java.util.UUID
|
||||||
|
import java.util.concurrent.Future
|
||||||
|
|
||||||
|
object NullChunk : IQueueChunk<Nothing> {
|
||||||
|
|
||||||
|
override fun getX(): Int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getZ(): Int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isEmpty(): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun call(): Nothing? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun filterBlocks(filter: Filter, block: ChunkFilterBlock, region: Region?, full: Boolean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
override fun setBiome(x: Int, y: Int, z: Int, biome: BiomeType): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTile(x: Int, y: Int, z: Int, tag: CompoundTag): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setEntity(tag: CompoundTag) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun removeEntity(uuid: UUID) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getEntityRemoves(): Set<UUID>? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getBiomes(): Array<BiomeType>? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <B : BlockStateHolder<B>> setBlock(x: Int, y: Int, z: Int, block: B): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setBlocks(layer: Int, data: CharArray) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getBiomeType(x: Int, y: Int, z: Int): BiomeType? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hasSection(layer: Int): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getBlock(x: Int, y: Int, z: Int): BlockState {
|
||||||
|
return BlockTypes.__RESERVED__!!.defaultState
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getFullBlock(x: Int, y: Int, z: Int): BaseBlock {
|
||||||
|
return BlockTypes.__RESERVED__!!.defaultState.toBaseBlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getTiles(): Map<BlockVector3, CompoundTag> {
|
||||||
|
return emptyMap()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getTile(x: Int, y: Int, z: Int): CompoundTag? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getEntities(): Set<CompoundTag> {
|
||||||
|
return emptySet()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun load(layer: Int): CharArray? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getEntity(uuid: UUID): CompoundTag? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <T : Future<T>?> call(set: IChunkSet?, finalize: Runnable?): T? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun trim(aggressive: Boolean): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -67,7 +67,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
this.layer = layer;
|
this.layer = layer;
|
||||||
final IBlocks get = (CharGetBlocks) iget;
|
final IBlocks get = (CharGetBlocks) iget;
|
||||||
if (!get.hasSection(layer)) {
|
if (!get.hasSection(layer)) {
|
||||||
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
|
getArr = FaweCache.INSTANCE.getEMPTY_CHAR_4096();
|
||||||
} else {
|
} else {
|
||||||
getArr = get.load(layer);
|
getArr = get.load(layer);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class ChunkPacket implements Function<byte[], byte[]>, Supplier<byte[]> {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (sectionBytes == null) {
|
if (sectionBytes == null) {
|
||||||
IBlocks tmpChunk = getChunk();
|
IBlocks tmpChunk = getChunk();
|
||||||
byte[] buf = FaweCache.IMP.BYTE_BUFFER_8192.get();
|
byte[] buf = FaweCache.INSTANCE.getBYTE_BUFFER_8192().get();
|
||||||
sectionBytes = tmpChunk.toByteArray(buf, tmpChunk.getBitMask(), this.full);
|
sectionBytes = tmpChunk.toByteArray(buf, tmpChunk.getBitMask(), this.full);
|
||||||
}
|
}
|
||||||
tmp = sectionBytes;
|
tmp = sectionBytes;
|
||||||
@ -83,13 +83,13 @@ public class ChunkPacket implements Function<byte[], byte[]>, Supplier<byte[]> {
|
|||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public byte[] get() {
|
public byte[] get() {
|
||||||
return apply(FaweCache.IMP.BYTE_BUFFER_8192.get());
|
return apply(FaweCache.INSTANCE.getBYTE_BUFFER_8192().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundTag getHeightMap() {
|
public CompoundTag getHeightMap() {
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put("MOTION_BLOCKING", new long[36]);
|
map.put("MOTION_BLOCKING", new long[36]);
|
||||||
CompoundTag tag = FaweCache.IMP.asTag(map);
|
CompoundTag tag = FaweCache.INSTANCE.asTag(map);
|
||||||
// TODO
|
// TODO
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||||
try {
|
try {
|
||||||
return getExtent().getHighestTerrainBlock(x, z, minY, maxY);
|
return getExtent().getHighestTerrainBlock(x, z, minY, maxY);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -132,7 +132,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
||||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||||
try {
|
try {
|
||||||
return getExtent().getHighestTerrainBlock(x, z, minY, maxY, filter);
|
return getExtent().getHighestTerrainBlock(x, z, minY, maxY, filter);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -145,7 +145,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
||||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||||
try {
|
try {
|
||||||
return getExtent().getNearestSurfaceLayer(x, z, y, minY, maxY);
|
return getExtent().getNearestSurfaceLayer(x, z, y, minY, maxY);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -158,7 +158,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
|
||||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||||
try {
|
try {
|
||||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -171,7 +171,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
||||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||||
try {
|
try {
|
||||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -184,7 +184,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
||||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||||
try {
|
try {
|
||||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -197,7 +197,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
|
||||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||||
try {
|
try {
|
||||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
@ -210,7 +210,7 @@ public class LimitExtent extends PassthroughExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
|
||||||
limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT);
|
limit.THROW_MAX_CHECKS(FaweCache.WORLD_HEIGHT);
|
||||||
try {
|
try {
|
||||||
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
||||||
} catch (FaweException e) {
|
} catch (FaweException e) {
|
||||||
|
@ -9,11 +9,9 @@ import com.boydti.fawe.beta.implementation.filter.CountFilter;
|
|||||||
import com.boydti.fawe.beta.implementation.filter.DistrFilter;
|
import com.boydti.fawe.beta.implementation.filter.DistrFilter;
|
||||||
import com.boydti.fawe.beta.implementation.processors.BatchProcessorHolder;
|
import com.boydti.fawe.beta.implementation.processors.BatchProcessorHolder;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.changeset.AbstractChangeSet;
|
|
||||||
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
|
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
|
||||||
import com.boydti.fawe.object.extent.NullExtent;
|
import com.boydti.fawe.object.extent.NullExtent;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.extent.PassthroughExtent;
|
import com.sk89q.worldedit.extent.PassthroughExtent;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||||
@ -60,7 +58,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
|||||||
@Override
|
@Override
|
||||||
public boolean cancel() {
|
public boolean cancel() {
|
||||||
if (super.cancel()) {
|
if (super.cancel()) {
|
||||||
processor.setProcessor(new NullExtent(this, FaweCache.MANUAL));
|
processor.setProcessor(new NullExtent(this, FaweCache.INSTANCE.getMANUAL()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -77,11 +75,6 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
|||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Extent enableHistory(AbstractChangeSet changeSet) {
|
|
||||||
return super.enableHistory(changeSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
||||||
// The chunks positions to iterate over
|
// The chunks positions to iterate over
|
||||||
@ -187,10 +180,6 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
|||||||
return apply(region, new DistrFilter(), false).getTypeDistribution();
|
return apply(region, new DistrFilter(), false).getTypeDistribution();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To optimize
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazily copy a region
|
* Lazily copy a region
|
||||||
*
|
*
|
||||||
@ -199,7 +188,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Clipboard lazyCopy(Region region) {
|
public Clipboard lazyCopy(Region region) {
|
||||||
WorldCopyClipboard clipboard = new WorldCopyClipboard(() -> this, region);
|
Clipboard clipboard = new WorldCopyClipboard(() -> this, region);
|
||||||
clipboard.setOrigin(region.getMinimumPoint());
|
clipboard.setOrigin(region.getMinimumPoint());
|
||||||
return clipboard;
|
return clipboard;
|
||||||
}
|
}
|
||||||
@ -213,7 +202,7 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
||||||
BlockMask mask = new BlockMask(this, searchBlocks);
|
Mask mask = new BlockMask(this, searchBlocks);
|
||||||
return countBlocks(region, mask);
|
return countBlocks(region, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public abstract class QueueHandler implements Trimable, Runnable {
|
|||||||
|
|
||||||
private ForkJoinPool forkJoinPoolPrimary = new ForkJoinPool();
|
private ForkJoinPool forkJoinPoolPrimary = new ForkJoinPool();
|
||||||
private ForkJoinPool forkJoinPoolSecondary = new ForkJoinPool();
|
private ForkJoinPool forkJoinPoolSecondary = new ForkJoinPool();
|
||||||
private ThreadPoolExecutor blockingExecutor = FaweCache.IMP.newBlockingExecutor();
|
private ThreadPoolExecutor blockingExecutor = FaweCache.INSTANCE.newBlockingExecutor();
|
||||||
private ConcurrentLinkedQueue<FutureTask> syncTasks = new ConcurrentLinkedQueue<>();
|
private ConcurrentLinkedQueue<FutureTask> syncTasks = new ConcurrentLinkedQueue<>();
|
||||||
private ConcurrentLinkedQueue<FutureTask> syncWhenFree = new ConcurrentLinkedQueue<>();
|
private ConcurrentLinkedQueue<FutureTask> syncWhenFree = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
|
@ -209,7 +209,6 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
|||||||
lastChunk = NullChunk.INSTANCE;
|
lastChunk = NullChunk.INSTANCE;
|
||||||
return NullChunk.INSTANCE;
|
return NullChunk.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
IQueueChunk chunk = chunks.get(pair);
|
IQueueChunk chunk = chunks.get(pair);
|
||||||
if (chunk instanceof ReferenceChunk) {
|
if (chunk instanceof ReferenceChunk) {
|
||||||
chunk = ((ReferenceChunk) chunk).getParent();
|
chunk = ((ReferenceChunk) chunk).getParent();
|
||||||
|
@ -475,7 +475,7 @@ public class AnvilCommands {
|
|||||||
// });
|
// });
|
||||||
// if (useData) {
|
// if (useData) {
|
||||||
// for (long[] c : map) {
|
// for (long[] c : map) {
|
||||||
// BaseBlock block = FaweCache.IMP.CACHE_BLOCK[(int) c[0]];
|
// BaseBlock block = FaweCache.INSTANCE.CACHE_BLOCK[(int) c[0]];
|
||||||
// String name = BlockType.fromID(block.getId()).getName();
|
// String name = BlockType.fromID(block.getId()).getName();
|
||||||
// String str = String.format("%-7s (%.3f%%) %s #%d:%d",
|
// String str = String.format("%-7s (%.3f%%) %s #%d:%d",
|
||||||
// String.valueOf(c[1]),
|
// String.valueOf(c[1]),
|
||||||
|
@ -72,7 +72,7 @@ public class MCAChunk implements IChunk {
|
|||||||
|
|
||||||
int bitsPerEntry = MathMan.log2nlz(section.palette.length - 1);
|
int bitsPerEntry = MathMan.log2nlz(section.palette.length - 1);
|
||||||
BitArray4096 bitArray = new BitArray4096(section.blocks, bitsPerEntry);
|
BitArray4096 bitArray = new BitArray4096(section.blocks, bitsPerEntry);
|
||||||
char[] buffer = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
char[] buffer = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get();
|
||||||
bitArray.toRaw(buffer);
|
bitArray.toRaw(buffer);
|
||||||
int offset = section.layer << 12;
|
int offset = section.layer << 12;
|
||||||
for (int i = 0; i < buffer.length; i++) {
|
for (int i = 0; i < buffer.length; i++) {
|
||||||
@ -152,20 +152,20 @@ public class MCAChunk implements IChunk {
|
|||||||
StreamDelegate blockStates = layer.add("BlockStates");
|
StreamDelegate blockStates = layer.add("BlockStates");
|
||||||
blockStates.withInfo((length, type) -> {
|
blockStates.withInfo((length, type) -> {
|
||||||
if (section.blocks == null) {
|
if (section.blocks == null) {
|
||||||
section.blocks = FaweCache.IMP.LONG_BUFFER_1024.get();
|
section.blocks = FaweCache.INSTANCE.getLONG_BUFFER_1024().get();
|
||||||
}
|
}
|
||||||
section.blocksLength = length;
|
section.blocksLength = length;
|
||||||
});
|
});
|
||||||
blockStates.withLong((index, value) -> section.blocks[index] = value);
|
blockStates.withLong((index, value) -> section.blocks[index] = value);
|
||||||
level.add("TileEntities").withElem((ValueReader<Map<String, Object>>) (index, value) -> {
|
level.add("TileEntities").withElem((ValueReader<Map<String, Object>>) (index, value) -> {
|
||||||
CompoundTag tile = FaweCache.IMP.asTag(value);
|
CompoundTag tile = FaweCache.INSTANCE.asTag(value);
|
||||||
int x = tile.getInt("x") & 15;
|
int x = tile.getInt("x") & 15;
|
||||||
int y = tile.getInt("y");
|
int y = tile.getInt("y");
|
||||||
int z = tile.getInt("z") & 15;
|
int z = tile.getInt("z") & 15;
|
||||||
tiles.put(x, y, z, tile);
|
tiles.put(x, y, z, tile);
|
||||||
});
|
});
|
||||||
level.add("Entities").withElem((ValueReader<Map<String, Object>>) (index, value) -> {
|
level.add("Entities").withElem((ValueReader<Map<String, Object>>) (index, value) -> {
|
||||||
CompoundTag entity = FaweCache.IMP.asTag(value);
|
CompoundTag entity = FaweCache.INSTANCE.asTag(value);
|
||||||
entities.put(entity.getUUID(), entity);
|
entities.put(entity.getUUID(), entity);
|
||||||
});
|
});
|
||||||
level.add("Biomes").withInt((index, value) -> biomes[index] = BiomeTypes.getLegacy(value));
|
level.add("Biomes").withInt((index, value) -> biomes[index] = BiomeTypes.getLegacy(value));
|
||||||
@ -218,10 +218,10 @@ public class MCAChunk implements IChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void write(NBTOutputStream nbtOut) throws IOException {
|
public void write(NBTOutputStream nbtOut) throws IOException {
|
||||||
int[] blockToPalette = FaweCache.IMP.BLOCK_TO_PALETTE.get();
|
int[] blockToPalette = FaweCache.INSTANCE.getBLOCK_TO_PALETTE().get();
|
||||||
int[] paletteToBlock = FaweCache.IMP.PALETTE_TO_BLOCK.get();
|
int[] paletteToBlock = FaweCache.INSTANCE.getPALETTE_TO_BLOCK().get();
|
||||||
long[] blockstates = FaweCache.IMP.BLOCK_STATES.get();
|
long[] blockstates = FaweCache.INSTANCE.getBLOCK_STATES().get();
|
||||||
int[] blocksCopy = FaweCache.IMP.SECTION_BLOCKS.get();
|
int[] blocksCopy = FaweCache.INSTANCE.getSECTION_BLOCKS().get();
|
||||||
|
|
||||||
nbtOut.writeNamedTagName("", NBTConstants.TYPE_COMPOUND);
|
nbtOut.writeNamedTagName("", NBTConstants.TYPE_COMPOUND);
|
||||||
nbtOut.writeNamedTag("DataVersion", 1631);
|
nbtOut.writeNamedTag("DataVersion", 1631);
|
||||||
@ -524,7 +524,7 @@ public class MCAChunk implements IChunk {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] load(int layer) {
|
public char[] load(int layer) {
|
||||||
char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
|
char[] tmp = FaweCache.INSTANCE.getSECTION_BITS_TO_CHAR().get();
|
||||||
int offset = layer << 12;
|
int offset = layer << 12;
|
||||||
System.arraycopy(blocks, offset, tmp, 0, 4096);
|
System.arraycopy(blocks, offset, tmp, 0, 4096);
|
||||||
return tmp;
|
return tmp;
|
||||||
|
@ -138,7 +138,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
return BlockVector3.at((this.X << 9) + 511, FaweCache.IMP.WORLD_MAX_Y, (this.Z << 9) + 511);
|
return BlockVector3.at((this.X << 9) + 511, FaweCache.WORLD_MAX_Y, (this.Z << 9) + 511);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -361,7 +361,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh
|
|||||||
raf.seek(offset);
|
raf.seek(offset);
|
||||||
int size = raf.readInt();
|
int size = raf.readInt();
|
||||||
int compression = raf.read();
|
int compression = raf.read();
|
||||||
byte[] data = FaweCache.IMP.BYTE_BUFFER_VAR.get(size);
|
byte[] data = FaweCache.INSTANCE.getBYTE_BUFFER_VAR().get(size);
|
||||||
raf.readFully(data, 0, size);
|
raf.readFully(data, 0, size);
|
||||||
FastByteArrayInputStream result = new FastByteArrayInputStream(data, 0, size);
|
FastByteArrayInputStream result = new FastByteArrayInputStream(data, 0, size);
|
||||||
return result;
|
return result;
|
||||||
@ -379,7 +379,7 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh
|
|||||||
|
|
||||||
private NBTInputStream getChunkIS(InputStream is) throws IllegalAccessException {
|
private NBTInputStream getChunkIS(InputStream is) throws IllegalAccessException {
|
||||||
InflaterInputStream iis = new InflaterInputStream(is, new Inflater(), 1);
|
InflaterInputStream iis = new InflaterInputStream(is, new Inflater(), 1);
|
||||||
fieldBuf2.set(iis, FaweCache.IMP.BYTE_BUFFER_8192.get());
|
fieldBuf2.set(iis, FaweCache.INSTANCE.getBYTE_BUFFER_8192().get());
|
||||||
BufferedInputStream bis = new BufferedInputStream(iis);
|
BufferedInputStream bis = new BufferedInputStream(iis);
|
||||||
NBTInputStream nis = new NBTInputStream(bis);
|
NBTInputStream nis = new NBTInputStream(bis);
|
||||||
return nis;
|
return nis;
|
||||||
@ -414,13 +414,13 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh
|
|||||||
if (chunk.isDeleted()) {
|
if (chunk.isDeleted()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
byte[] writeBuffer = FaweCache.IMP.BYTE_BUFFER_VAR.get(4096);
|
byte[] writeBuffer = FaweCache.INSTANCE.getBYTE_BUFFER_VAR().get(4096);
|
||||||
FastByteArrayOutputStream uncompressed = chunk.toBytes(writeBuffer);
|
FastByteArrayOutputStream uncompressed = chunk.toBytes(writeBuffer);
|
||||||
if (uncompressed.array.length > writeBuffer.length) {
|
if (uncompressed.array.length > writeBuffer.length) {
|
||||||
FaweCache.IMP.BYTE_BUFFER_VAR.set(uncompressed.array);
|
FaweCache.INSTANCE.getBYTE_BUFFER_VAR().set(uncompressed.array);
|
||||||
}
|
}
|
||||||
writeBuffer = uncompressed.array;
|
writeBuffer = uncompressed.array;
|
||||||
byte[] buffer = FaweCache.IMP.BYTE_BUFFER_8192.get();
|
byte[] buffer = FaweCache.INSTANCE.getBYTE_BUFFER_8192().get();
|
||||||
int length = uncompressed.length;
|
int length = uncompressed.length;
|
||||||
uncompressed.reset();
|
uncompressed.reset();
|
||||||
// cheat, reusing the same buffer to read/write
|
// cheat, reusing the same buffer to read/write
|
||||||
|
@ -55,10 +55,10 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet {
|
|||||||
// loc.x = x;
|
// loc.x = x;
|
||||||
// loc.y = y;
|
// loc.y = y;
|
||||||
// loc.z = z;
|
// loc.z = z;
|
||||||
// oldBlock.id = FaweCache.IMP.getId(combinedId4DataFrom);
|
// oldBlock.id = FaweCache.INSTANCE.getId(combinedId4DataFrom);
|
||||||
// oldBlock.data = FaweCache.IMP.getData(combinedId4DataFrom);
|
// oldBlock.data = FaweCache.INSTANCE.getData(combinedId4DataFrom);
|
||||||
// newBlock.id = FaweCache.IMP.getId(combinedId4DataTo);
|
// newBlock.id = FaweCache.INSTANCE.getId(combinedId4DataTo);
|
||||||
// newBlock.data = FaweCache.IMP.getData(combinedId4DataTo);
|
// newBlock.data = FaweCache.INSTANCE.getData(combinedId4DataTo);
|
||||||
// // Log to BlocksHub and parent
|
// // Log to BlocksHub and parent
|
||||||
// api.logBlock(loc, player, world, oldBlock, newBlock);
|
// api.logBlock(loc, player, world, oldBlock, newBlock);
|
||||||
parent.add(x, y, z, combinedId4DataFrom, combinedId4DataTo);
|
parent.add(x, y, z, combinedId4DataFrom, combinedId4DataTo);
|
||||||
|
@ -48,10 +48,10 @@ public class DataAnglePattern extends AbstractPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||||
BlockStateHolder block = extent.getBlock(getPosition);
|
BlockState block = extent.getBlock(getPosition);
|
||||||
int slope = getSlope(block, getPosition, extent);
|
int slope = getSlope(block, getPosition, extent);
|
||||||
if (slope == -1) return false;
|
if (slope == -1) return false;
|
||||||
int data = (Math.min(slope, 255)) >> 4;
|
int data = Math.min(slope, 255) >> 4;
|
||||||
return extent.setBlock(setPosition, block.withPropertyId(data));
|
return extent.setBlock(setPosition, block.withPropertyId(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,51 +136,51 @@ public class FaweLimit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHANGES() {
|
public void THROW_MAX_CHANGES() {
|
||||||
if (MAX_CHANGES-- <= 0) throw FaweCache.MAX_CHANGES;
|
if (MAX_CHANGES-- <= 0) throw FaweCache.INSTANCE.getMAX_CHANGES();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_FAILS() {
|
public void THROW_MAX_FAILS() {
|
||||||
if (MAX_FAILS-- <= 0) throw FaweCache.MAX_CHECKS;
|
if (MAX_FAILS-- <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHECKS() {
|
public void THROW_MAX_CHECKS() {
|
||||||
if (MAX_CHECKS-- <= 0) throw FaweCache.MAX_CHECKS;
|
if (MAX_CHECKS-- <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_ITERATIONS() {
|
public void THROW_MAX_ITERATIONS() {
|
||||||
if (MAX_ITERATIONS-- <= 0) throw FaweCache.MAX_ITERATIONS;
|
if (MAX_ITERATIONS-- <= 0) throw FaweCache.INSTANCE.getMAX_ITERATIONS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_BLOCKSTATES() {
|
public void THROW_MAX_BLOCKSTATES() {
|
||||||
if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.MAX_TILES;
|
if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.INSTANCE.getMAX_TILES();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_ENTITIES() {
|
public void THROW_MAX_ENTITIES() {
|
||||||
if (MAX_ENTITIES-- <= 0) throw FaweCache.MAX_ENTITIES;
|
if (MAX_ENTITIES-- <= 0) throw FaweCache.INSTANCE.getMAX_ENTITIES();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHANGES(int amt) {
|
public void THROW_MAX_CHANGES(int amt) {
|
||||||
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
|
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHANGES();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_FAILS(int amt) {
|
public void THROW_MAX_FAILS(int amt) {
|
||||||
if ((MAX_FAILS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
if ((MAX_FAILS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_CHECKS(int amt) {
|
public void THROW_MAX_CHECKS(int amt) {
|
||||||
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_ITERATIONS(int amt) {
|
public void THROW_MAX_ITERATIONS(int amt) {
|
||||||
if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.MAX_ITERATIONS;
|
if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_ITERATIONS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_BLOCKSTATES(int amt) {
|
public void THROW_MAX_BLOCKSTATES(int amt) {
|
||||||
if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.MAX_TILES;
|
if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_TILES();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void THROW_MAX_ENTITIES(int amt) {
|
public void THROW_MAX_ENTITIES(int amt) {
|
||||||
if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.MAX_ENTITIES;
|
if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.INSTANCE.getMAX_ENTITIES();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnlimited() {
|
public boolean isUnlimited() {
|
||||||
@ -193,7 +193,7 @@ public class FaweLimit {
|
|||||||
MAX_HISTORY == Integer.MAX_VALUE &&
|
MAX_HISTORY == Integer.MAX_VALUE &&
|
||||||
INVENTORY_MODE == 0 &&
|
INVENTORY_MODE == 0 &&
|
||||||
SPEED_REDUCTION == 0 &&
|
SPEED_REDUCTION == 0 &&
|
||||||
FAST_PLACEMENT == true &&
|
FAST_PLACEMENT &&
|
||||||
(STRIP_NBT == null || STRIP_NBT.isEmpty());
|
(STRIP_NBT == null || STRIP_NBT.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import com.sk89q.worldedit.math.MutableVector3;
|
|||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ public class ImageBrush implements Brush {
|
|||||||
case 255:
|
case 255:
|
||||||
return color;
|
return color;
|
||||||
default:
|
default:
|
||||||
BlockStateHolder block = extent.getBlock(pos);
|
BlockState block = extent.getBlock(pos);
|
||||||
TextureUtil tu = session.getTextureUtil();
|
TextureUtil tu = session.getTextureUtil();
|
||||||
int existingColor = tu.getColor(block.getBlockType());
|
int existingColor = tu.getColor(block.getBlockType());
|
||||||
return tu.combineTransparency(color, existingColor);
|
return tu.combineTransparency(color, existingColor);
|
||||||
|
@ -75,7 +75,7 @@ public class LayerBrush implements Brush {
|
|||||||
}
|
}
|
||||||
}, pos -> {
|
}, pos -> {
|
||||||
int depth = visitor.getDepth();
|
int depth = visitor.getDepth();
|
||||||
BlockStateHolder currentPattern = layers[depth];
|
BlockState currentPattern = layers[depth];
|
||||||
return currentPattern.apply(editSession, pos, pos);
|
return currentPattern.apply(editSession, pos, pos);
|
||||||
}, layers.length - 1);
|
}, layers.length - 1);
|
||||||
for (BlockVector3 pos : visited) {
|
for (BlockVector3 pos : visited) {
|
||||||
|
@ -13,6 +13,7 @@ import com.sk89q.worldedit.function.operation.Operations;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
public class RecurseBrush implements Brush {
|
public class RecurseBrush implements Brush {
|
||||||
@ -32,7 +33,7 @@ public class RecurseBrush implements Brush {
|
|||||||
mask = mask.withExtent(editSession);
|
mask = mask.withExtent(editSession);
|
||||||
}
|
}
|
||||||
final int radius = (int) size;
|
final int radius = (int) size;
|
||||||
BlockStateHolder block = editSession.getBlock(position);
|
BlockState block = editSession.getBlock(position);
|
||||||
if (block.getBlockType().getMaterial().isAir()) {
|
if (block.getBlockType().getMaterial().isAir()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class SplineBrush implements Brush, ResettableTool {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
if (newPos) {
|
if (newPos) {
|
||||||
if (positionSets.size() >= MAX_POINTS) {
|
if (positionSets.size() >= MAX_POINTS) {
|
||||||
throw FaweCache.MAX_CHECKS;
|
throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||||
}
|
}
|
||||||
final ArrayList<BlockVector3> points = new ArrayList<>();
|
final ArrayList<BlockVector3> points = new ArrayList<>();
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
|
@ -1563,12 +1563,12 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
char[] floor = this.floor.get();
|
char[] floor = this.floor.get();
|
||||||
char[] overlay = this.overlay != null ? this.overlay.get() : null;
|
char[] overlay = this.overlay != null ? this.overlay.get() : null;
|
||||||
try {
|
try {
|
||||||
int[] indexes = FaweCache.IMP.INDEX_STORE.get();
|
int[] indexes = FaweCache.INSTANCE.getINDEX_STORE().get();
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
int maxY = 0;
|
int maxY = 0;
|
||||||
int minY = Integer.MAX_VALUE;
|
int minY = Integer.MAX_VALUE;
|
||||||
int[] heightMap = FaweCache.IMP.HEIGHT_STORE.get();
|
int[] heightMap = FaweCache.INSTANCE.getHEIGHT_STORE().get();
|
||||||
int globalIndex;
|
int globalIndex;
|
||||||
for (int z = csz; z <= cez; z++) {
|
for (int z = csz; z <= cez; z++) {
|
||||||
globalIndex = z * getWidth() + csx;
|
globalIndex = z * getWidth() + csx;
|
||||||
|
@ -171,7 +171,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor, C
|
|||||||
// add each block and tile
|
// add each block and tile
|
||||||
char[] blocksGet = get.load(layer);
|
char[] blocksGet = get.load(layer);
|
||||||
if (blocksGet == null) {
|
if (blocksGet == null) {
|
||||||
blocksGet = FaweCache.IMP.EMPTY_CHAR_4096;
|
blocksGet = FaweCache.INSTANCE.getEMPTY_CHAR_4096();
|
||||||
}
|
}
|
||||||
char[] blocksSet = set.load(layer);
|
char[] blocksSet = set.load(layer);
|
||||||
|
|
||||||
|
@ -87,10 +87,10 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
|
|||||||
try {
|
try {
|
||||||
blockBag.fetchPlacedBlock(typeTo.getDefaultState());
|
blockBag.fetchPlacedBlock(typeTo.getDefaultState());
|
||||||
} catch (UnplaceableBlockException e) {
|
} catch (UnplaceableBlockException e) {
|
||||||
throw FaweCache.BLOCK_BAG;
|
throw FaweCache.INSTANCE.getBLOCK_BAG();
|
||||||
} catch (BlockBagException e) {
|
} catch (BlockBagException e) {
|
||||||
missingBlocks[typeTo.getInternalId()]++;
|
missingBlocks[typeTo.getInternalId()]++;
|
||||||
throw FaweCache.BLOCK_BAG;
|
throw FaweCache.INSTANCE.getBLOCK_BAG();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mine) {
|
if (mine) {
|
||||||
|
@ -223,7 +223,7 @@ public class ClipboardRemapper {
|
|||||||
// String name = entry.getKey();
|
// String name = entry.getKey();
|
||||||
// int id = value.get("id").getAsInt();
|
// int id = value.get("id").getAsInt();
|
||||||
// int data = value.get("data").getAsInt();
|
// int data = value.get("data").getAsInt();
|
||||||
// int combined = FaweCache.IMP.getCombined(id, data);
|
// int combined = FaweCache.INSTANCE.getCombined(id, data);
|
||||||
// map.putIfAbsent(name, new ArrayList<>());
|
// map.putIfAbsent(name, new ArrayList<>());
|
||||||
// map.get(name).add(combined);
|
// map.get(name).add(combined);
|
||||||
// }
|
// }
|
||||||
@ -496,7 +496,7 @@ public class ClipboardRemapper {
|
|||||||
// int combined = block.getCombined();
|
// int combined = block.getCombined();
|
||||||
// if (remap[combined]) {
|
// if (remap[combined]) {
|
||||||
// char value = remapCombined[combined];
|
// char value = remapCombined[combined];
|
||||||
// BaseBlock newBlock = FaweCache.IMP.CACHE_BLOCK[value];
|
// BaseBlock newBlock = FaweCache.INSTANCE.CACHE_BLOCK[value];
|
||||||
// newBlock.setNbtData(block.getNbtData());
|
// newBlock.setNbtData(block.getNbtData());
|
||||||
// return newBlock;
|
// return newBlock;
|
||||||
// }
|
// }
|
||||||
|
@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
*/
|
*/
|
||||||
public final class MemBlockSet extends BlockSet {
|
public final class MemBlockSet extends BlockSet {
|
||||||
public final static int BITS_PER_WORD = 6;
|
public final static int BITS_PER_WORD = 6;
|
||||||
public final static int WORDS = FaweCache.IMP.BLOCKS_PER_LAYER >> BITS_PER_WORD;
|
public final static int WORDS = FaweCache.BLOCKS_PER_LAYER >> BITS_PER_WORD;
|
||||||
public final static IRow NULL_ROW_X = new NullRowX();
|
public final static IRow NULL_ROW_X = new NullRowX();
|
||||||
public final static IRow NULL_ROW_Z = new NullRowZ();
|
public final static IRow NULL_ROW_Z = new NullRowZ();
|
||||||
public final static IRow NULL_ROW_Y = new NullRowY();
|
public final static IRow NULL_ROW_Y = new NullRowY();
|
||||||
@ -357,8 +357,8 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
maxy = y + 1;
|
maxy = y + 1;
|
||||||
}
|
}
|
||||||
by = (Y << 4) + y;
|
by = (Y << 4) + y;
|
||||||
if (by == FaweCache.IMP.WORLD_MAX_Y)
|
if (by == FaweCache.WORLD_MAX_Y)
|
||||||
return FaweCache.IMP.WORLD_MAX_Y;
|
return FaweCache.WORLD_MAX_Y;
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -827,7 +827,7 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
public final IRow[] rows;
|
public final IRow[] rows;
|
||||||
|
|
||||||
public RowZ() {
|
public RowZ() {
|
||||||
this.rows = new IRow[FaweCache.IMP.CHUNK_LAYERS];
|
this.rows = new IRow[FaweCache.CHUNK_LAYERS];
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -874,7 +874,7 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
for (int i = 0; i < FaweCache.IMP.CHUNK_LAYERS; i++) rows[i] = NULL_ROW_Y;
|
for (int i = 0; i < FaweCache.CHUNK_LAYERS; i++) rows[i] = NULL_ROW_Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||||
if (!contains(x, y, z)) {
|
if (!contains(x, y, z)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
if (!contains(x, y, z)) {
|
if (!contains(x, y, z)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public BiomeType getBiome(BlockVector2 position) {
|
public BiomeType getBiome(BlockVector2 position) {
|
||||||
if (!contains(position)) {
|
if (!contains(position)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public BiomeType getBiomeType(int x, int y, int z) {
|
public BiomeType getBiomeType(int x, int y, int z) {
|
||||||
if (!contains(x, z)) {
|
if (!contains(x, z)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
if (!contains(position)) {
|
if (!contains(position)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
if (!contains(position)) {
|
if (!contains(position)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return BlockTypes.AIR.getDefaultState();
|
return BlockTypes.AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public int getBlockLight(int x, int y, int z) {
|
public int getBlockLight(int x, int y, int z) {
|
||||||
if (!contains(x, y, z)) {
|
if (!contains(x, y, z)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public int getBrightness(int x, int y, int z) {
|
public int getBrightness(int x, int y, int z) {
|
||||||
if (!contains(x, y, z)) {
|
if (!contains(x, y, z)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public int getLight(int x, int y, int z) {
|
public int getLight(int x, int y, int z) {
|
||||||
if (!contains(x, y, z)) {
|
if (!contains(x, y, z)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public int getOpacity(int x, int y, int z) {
|
public int getOpacity(int x, int y, int z) {
|
||||||
if (!contains(x, y, z)) {
|
if (!contains(x, y, z)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public int getSkyLight(int x, int y, int z) {
|
public int getSkyLight(int x, int y, int z) {
|
||||||
if (!contains(x, y, z)) {
|
if (!contains(x, y, z)) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
|
|||||||
public Entity createEntity(Location location, BaseEntity entity) {
|
public Entity createEntity(Location location, BaseEntity entity) {
|
||||||
if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
|
if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
|
||||||
if (!limit.MAX_FAILS()) {
|
if (!limit.MAX_FAILS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getOUTSIDE_REGION());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class MemoryCheckingExtent extends PassthroughExtent {
|
|||||||
this.player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin"));
|
this.player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WEManager.IMP.cancelEdit(this, FaweCache.LOW_MEMORY);
|
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getLOW_MEMORY());
|
||||||
}
|
}
|
||||||
return super.getExtent();
|
return super.getExtent();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public NullExtent() {
|
public NullExtent() {
|
||||||
this(new com.sk89q.worldedit.extent.NullExtent(), FaweCache.MANUAL);
|
this(new com.sk89q.worldedit.extent.NullExtent(), FaweCache.INSTANCE.getMANUAL());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,7 +38,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!limit.MAX_ENTITIES()) {
|
if (!limit.MAX_ENTITIES()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_ENTITIES);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_ENTITIES());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return super.createEntity(location, entity);
|
return super.createEntity(location, entity);
|
||||||
@ -47,7 +47,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
if (!limit.MAX_CHECKS()) {
|
if (!limit.MAX_CHECKS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHECKS());
|
||||||
return BlockTypes.AIR.getDefaultState();
|
return BlockTypes.AIR.getDefaultState();
|
||||||
} else {
|
} else {
|
||||||
return extent.getBlock(x, y, z);
|
return extent.getBlock(x, y, z);
|
||||||
@ -57,7 +57,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 pos) {
|
public BaseBlock getFullBlock(BlockVector3 pos) {
|
||||||
if (!limit.MAX_CHECKS()) {
|
if (!limit.MAX_CHECKS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHECKS);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHECKS());
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
} else {
|
} else {
|
||||||
return extent.getFullBlock(pos);
|
return extent.getFullBlock(pos);
|
||||||
@ -79,18 +79,18 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
if (!limit.MAX_BLOCKSTATES()) {
|
if (!limit.MAX_BLOCKSTATES()) {
|
||||||
WEManager.IMP.cancelEdit(this, FaweCache.MAX_TILES);
|
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_TILES());
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!limit.MAX_CHANGES()) {
|
if (!limit.MAX_CHANGES()) {
|
||||||
WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES);
|
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_CHANGES());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return extent.setBlock(x, y, z, block);
|
return extent.setBlock(x, y, z, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!limit.MAX_CHANGES()) {
|
if (!limit.MAX_CHANGES()) {
|
||||||
WEManager.IMP.cancelEdit(this, FaweCache.MAX_CHANGES);
|
WEManager.IMP.cancelEdit(this, FaweCache.INSTANCE.getMAX_CHANGES());
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return extent.setBlock(x, y, z, block);
|
return extent.setBlock(x, y, z, block);
|
||||||
@ -100,7 +100,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||||
if (!limit.MAX_CHANGES()) {
|
if (!limit.MAX_CHANGES()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHANGES);
|
WEManager.IMP.cancelEditSafe(this, FaweCache.INSTANCE.getMAX_CHANGES());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return super.setBiome(position, biome);
|
return super.setBiome(position, biome);
|
||||||
|
@ -31,10 +31,10 @@ public abstract class FaweBlockMatcher {
|
|||||||
// public boolean apply(BaseBlock oldBlock) {
|
// public boolean apply(BaseBlock oldBlock) {
|
||||||
// int currentId = oldBlock.getId();
|
// int currentId = oldBlock.getId();
|
||||||
// oldBlock.setId(id);
|
// oldBlock.setId(id);
|
||||||
// if (FaweCache.IMP.hasData(currentId)) {
|
// if (FaweCache.INSTANCE.hasData(currentId)) {
|
||||||
// oldBlock.setData(0);
|
// oldBlock.setData(0);
|
||||||
// }
|
// }
|
||||||
// if (FaweCache.IMP.hasNBT(currentId)) {
|
// if (FaweCache.INSTANCE.hasNBT(currentId)) {
|
||||||
// oldBlock.setNbtData(null);
|
// oldBlock.setNbtData(null);
|
||||||
// }
|
// }
|
||||||
// return true;
|
// return true;
|
||||||
@ -47,7 +47,7 @@ public abstract class FaweBlockMatcher {
|
|||||||
// int currentId = oldBlock.getId();
|
// int currentId = oldBlock.getId();
|
||||||
// oldBlock.setId(id);
|
// oldBlock.setId(id);
|
||||||
// oldBlock.setData(data);
|
// oldBlock.setData(data);
|
||||||
// if (FaweCache.IMP.hasNBT(currentId)) {
|
// if (FaweCache.INSTANCE.hasNBT(currentId)) {
|
||||||
// oldBlock.setNbtData(null);
|
// oldBlock.setNbtData(null);
|
||||||
// }
|
// }
|
||||||
// return true;
|
// return true;
|
||||||
@ -67,10 +67,10 @@ public abstract class FaweBlockMatcher {
|
|||||||
// BaseBlock replace = array[random.random(size)];
|
// BaseBlock replace = array[random.random(size)];
|
||||||
// int currentId = block.getId();
|
// int currentId = block.getId();
|
||||||
// block.setId(replace.getId());
|
// block.setId(replace.getId());
|
||||||
// if (FaweCache.IMP.hasNBT(currentId)) {
|
// if (FaweCache.INSTANCE.hasNBT(currentId)) {
|
||||||
// block.setNbtData(null);
|
// block.setNbtData(null);
|
||||||
// }
|
// }
|
||||||
// if (FaweCache.IMP.hasData(currentId) || replace.getData() != 0) {
|
// if (FaweCache.INSTANCE.hasData(currentId) || replace.getData() != 0) {
|
||||||
// block.setData(replace.getData());
|
// block.setData(replace.getData());
|
||||||
// }
|
// }
|
||||||
// return true;
|
// return true;
|
||||||
@ -82,7 +82,7 @@ public abstract class FaweBlockMatcher {
|
|||||||
public static FaweBlockMatcher fromBlock(BaseBlock block, boolean checkData) {
|
public static FaweBlockMatcher fromBlock(BaseBlock block, boolean checkData) {
|
||||||
// final int id = block.getId();
|
// final int id = block.getId();
|
||||||
// final int data = block.getData();
|
// final int data = block.getData();
|
||||||
// if (checkData && FaweCache.IMP.hasData(id)) {
|
// if (checkData && FaweCache.INSTANCE.hasData(id)) {
|
||||||
// return new FaweBlockMatcher() {
|
// return new FaweBlockMatcher() {
|
||||||
// @Override
|
// @Override
|
||||||
// public boolean apply(BaseBlock block) {
|
// public boolean apply(BaseBlock block) {
|
||||||
@ -104,13 +104,13 @@ public abstract class FaweBlockMatcher {
|
|||||||
// if (searchBlocks.size() == 1) {
|
// if (searchBlocks.size() == 1) {
|
||||||
// return fromBlock(searchBlocks.iterator().next(), checkData);
|
// return fromBlock(searchBlocks.iterator().next(), checkData);
|
||||||
// }
|
// }
|
||||||
// final boolean[] allowedId = new boolean[FaweCache.IMP.getId(Character.MAX_VALUE)];
|
// final boolean[] allowedId = new boolean[FaweCache.INSTANCE.getId(Character.MAX_VALUE)];
|
||||||
// for (BaseBlock block : searchBlocks) {
|
// for (BaseBlock block : searchBlocks) {
|
||||||
// allowedId[block.getId()] = true;
|
// allowedId[block.getId()] = true;
|
||||||
// }
|
// }
|
||||||
// final boolean[] allowed = new boolean[Character.MAX_VALUE];
|
// final boolean[] allowed = new boolean[Character.MAX_VALUE];
|
||||||
// for (BaseBlock block : searchBlocks) {
|
// for (BaseBlock block : searchBlocks) {
|
||||||
// allowed[FaweCache.IMP.getCombined(block)] = true;
|
// allowed[FaweCache.INSTANCE.getCombined(block)] = true;
|
||||||
// }
|
// }
|
||||||
// if (checkData) {
|
// if (checkData) {
|
||||||
// return new FaweBlockMatcher() {
|
// return new FaweBlockMatcher() {
|
||||||
@ -118,7 +118,7 @@ public abstract class FaweBlockMatcher {
|
|||||||
// public boolean apply(BaseBlock block) {
|
// public boolean apply(BaseBlock block) {
|
||||||
// int id = block.getId();
|
// int id = block.getId();
|
||||||
// if (allowedId[id]) {
|
// if (allowedId[id]) {
|
||||||
// if (FaweCache.IMP.hasData(id)) {
|
// if (FaweCache.INSTANCE.hasData(id)) {
|
||||||
// return allowed[(id << 4) + block.getData()];
|
// return allowed[(id << 4) + block.getData()];
|
||||||
// }
|
// }
|
||||||
// return true;
|
// return true;
|
||||||
|
@ -162,7 +162,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
if (width > WARN_SIZE || height > WARN_SIZE || length > WARN_SIZE) {
|
if (width > WARN_SIZE || height > WARN_SIZE || length > WARN_SIZE) {
|
||||||
getLogger(MinecraftStructure.class).debug("A structure longer than 32 is unsupported by minecraft (but probably still works)");
|
getLogger(MinecraftStructure.class).debug("A structure longer than 32 is unsupported by minecraft (but probably still works)");
|
||||||
}
|
}
|
||||||
Map<String, Object> structure = FaweCache.IMP.asMap("version", 1, "author", owner);
|
Map<String, Object> structure = FaweCache.INSTANCE.asMap("version", 1, "author", owner);
|
||||||
// ignored: version / owner
|
// ignored: version / owner
|
||||||
MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
|
MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
|
||||||
Int2ObjectArrayMap<Integer> indexes = new Int2ObjectArrayMap<>();
|
Int2ObjectArrayMap<Integer> indexes = new Int2ObjectArrayMap<>();
|
||||||
@ -212,10 +212,10 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
List<Integer> pos = Arrays.asList(point.getX() - min.getX(),
|
List<Integer> pos = Arrays.asList(point.getX() - min.getX(),
|
||||||
point.getY() - min.getY(), point.getZ() - min.getZ());
|
point.getY() - min.getY(), point.getZ() - min.getZ());
|
||||||
if (!block.hasNbtData()) {
|
if (!block.hasNbtData()) {
|
||||||
blocks.add(FaweCache.IMP.asMap("state", index, "pos", pos));
|
blocks.add(FaweCache.INSTANCE.asMap("state", index, "pos", pos));
|
||||||
} else {
|
} else {
|
||||||
blocks.add(
|
blocks.add(
|
||||||
FaweCache.IMP.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
|
FaweCache.INSTANCE.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,14 +235,14 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
// Replace rotation data
|
// Replace rotation data
|
||||||
nbtMap.put("Rotation", writeRotation(entity.getLocation()));
|
nbtMap.put("Rotation", writeRotation(entity.getLocation()));
|
||||||
nbtMap.put("id", new StringTag(state.getType().getId()));
|
nbtMap.put("id", new StringTag(state.getType().getId()));
|
||||||
Map<String, Object> entityMap = FaweCache.IMP.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt);
|
Map<String, Object> entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt);
|
||||||
entities.add(entityMap);
|
entities.add(entityMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!entities.isEmpty()) {
|
if (!entities.isEmpty()) {
|
||||||
structure.put("entities", entities);
|
structure.put("entities", entities);
|
||||||
}
|
}
|
||||||
out.writeNamedTag("", FaweCache.IMP.asTag(structure));
|
out.writeNamedTag("", FaweCache.INSTANCE.asTag(structure));
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||||
IMP.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.IMP.asTag(tag));
|
IMP.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.INSTANCE.asTag(tag));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class FaweSchematicHandler extends SchematicHandler {
|
|||||||
com.github.intellectualsites.plotsquared.plot.util.TaskManager.runTask(whenDone);
|
com.github.intellectualsites.plotsquared.plot.util.TaskManager.runTask(whenDone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CompoundTag weTag = (CompoundTag) FaweCache.IMP.asTag(tag);
|
CompoundTag weTag = (CompoundTag) FaweCache.INSTANCE.asTag(tag);
|
||||||
if (weTag instanceof CompressedSchematicTag) {
|
if (weTag instanceof CompressedSchematicTag) {
|
||||||
Clipboard clipboard = ((CompressedSchematicTag) weTag).getSource();
|
Clipboard clipboard = ((CompressedSchematicTag) weTag).getSource();
|
||||||
URL url = FaweAPI.upload(clipboard, BuiltInClipboardFormat.SPONGE_SCHEMATIC);
|
URL url = FaweAPI.upload(clipboard, BuiltInClipboardFormat.SPONGE_SCHEMATIC);
|
||||||
|
@ -92,7 +92,7 @@ public final class BrushCache {
|
|||||||
} else {
|
} else {
|
||||||
displayMap = ReflectionUtils.getMap(display.getValue());
|
displayMap = ReflectionUtils.getMap(display.getValue());
|
||||||
}
|
}
|
||||||
displayMap.put("Lore", FaweCache.IMP.asTag(json.split("\\r?\\n")));
|
displayMap.put("Lore", FaweCache.INSTANCE.asTag(json.split("\\r?\\n")));
|
||||||
String primary = (String) tool.getPrimary().getSettings().get(BrushSettings.SettingType.BRUSH);
|
String primary = (String) tool.getPrimary().getSettings().get(BrushSettings.SettingType.BRUSH);
|
||||||
String secondary = (String) tool.getSecondary().getSettings().get(BrushSettings.SettingType.BRUSH);
|
String secondary = (String) tool.getSecondary().getSettings().get(BrushSettings.SettingType.BRUSH);
|
||||||
if (primary == null) primary = secondary;
|
if (primary == null) primary = secondary;
|
||||||
|
@ -232,11 +232,11 @@ public class EditSessionBuilder {
|
|||||||
event.setExtent(extent);
|
event.setExtent(extent);
|
||||||
eventBus.post(event);
|
eventBus.post(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return new NullExtent(extent, FaweCache.MANUAL);
|
return new NullExtent(extent, FaweCache.INSTANCE.getMANUAL());
|
||||||
}
|
}
|
||||||
final Extent toReturn = event.getExtent();
|
final Extent toReturn = event.getExtent();
|
||||||
if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) {
|
if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) {
|
||||||
return new NullExtent(toReturn, FaweCache.MANUAL);
|
return new NullExtent(toReturn, FaweCache.INSTANCE.getMANUAL());
|
||||||
}
|
}
|
||||||
// if (!(toReturn instanceof AbstractDelegateExtent)) {
|
// if (!(toReturn instanceof AbstractDelegateExtent)) {
|
||||||
// Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
|
// Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
|
||||||
@ -316,7 +316,7 @@ public class EditSessionBuilder {
|
|||||||
if (Permission.hasPermission(player, "worldedit.fast")) {
|
if (Permission.hasPermission(player, "worldedit.fast")) {
|
||||||
player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin"));
|
player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin"));
|
||||||
}
|
}
|
||||||
throw FaweCache.LOW_MEMORY;
|
throw FaweCache.INSTANCE.getLOW_MEMORY();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// this.originalLimit = limit;
|
// this.originalLimit = limit;
|
||||||
@ -420,7 +420,7 @@ public class EditSessionBuilder {
|
|||||||
FaweRegionExtent regionExtent = null;
|
FaweRegionExtent regionExtent = null;
|
||||||
if (allowedRegions != null) {
|
if (allowedRegions != null) {
|
||||||
if (allowedRegions.length == 0) {
|
if (allowedRegions.length == 0) {
|
||||||
regionExtent = new NullExtent(this.extent, FaweCache.NO_REGION);
|
regionExtent = new NullExtent(this.extent, FaweCache.INSTANCE.getNO_REGION());
|
||||||
} else {
|
} else {
|
||||||
// this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
// this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
||||||
if (allowedRegions.length == 1) {
|
if (allowedRegions.length == 1) {
|
||||||
|
@ -58,7 +58,7 @@ public class SchemSync implements Runnable {
|
|||||||
|
|
||||||
private void close(Error error) throws IOException {
|
private void close(Error error) throws IOException {
|
||||||
this.clientSocket.getOutputStream().write(error.ordinal());
|
this.clientSocket.getOutputStream().write(error.ordinal());
|
||||||
throw FaweCache.MANUAL;
|
throw FaweCache.INSTANCE.getMANUAL();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2802,7 +2802,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
BlockVector3 max = region.getMaximumPoint();
|
BlockVector3 max = region.getMaximumPoint();
|
||||||
BlockVector3 min = region.getMinimumPoint();
|
BlockVector3 min = region.getMinimumPoint();
|
||||||
if (!fe.contains(max.getBlockX(), max.getBlockY(), max.getBlockZ()) && !fe.contains(min.getBlockX(), min.getBlockY(), min.getBlockZ())) {
|
if (!fe.contains(max.getBlockX(), max.getBlockY(), max.getBlockZ()) && !fe.contains(min.getBlockX(), min.getBlockY(), min.getBlockZ())) {
|
||||||
throw FaweCache.OUTSIDE_REGION;
|
throw FaweCache.INSTANCE.getOUTSIDE_REGION();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Set<BlockVector2> chunks = region.getChunks();
|
final Set<BlockVector2> chunks = region.getChunks();
|
||||||
|
@ -128,7 +128,7 @@ public class ClipboardCommands {
|
|||||||
((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1);
|
((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1);
|
||||||
FaweLimit limit = actor.getLimit();
|
FaweLimit limit = actor.getLimit();
|
||||||
if (volume >= limit.MAX_CHECKS) {
|
if (volume >= limit.MAX_CHECKS) {
|
||||||
throw FaweCache.MAX_CHECKS;
|
throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||||
}
|
}
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
|
|
||||||
@ -246,10 +246,10 @@ public class ClipboardCommands {
|
|||||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||||
FaweLimit limit = actor.getLimit();
|
FaweLimit limit = actor.getLimit();
|
||||||
if (volume >= limit.MAX_CHECKS) {
|
if (volume >= limit.MAX_CHECKS) {
|
||||||
throw FaweCache.MAX_CHECKS;
|
throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||||
}
|
}
|
||||||
if (volume >= limit.MAX_CHANGES) {
|
if (volume >= limit.MAX_CHANGES) {
|
||||||
throw FaweCache.MAX_CHANGES;
|
throw FaweCache.INSTANCE.getMAX_CHANGES();
|
||||||
}
|
}
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ public class RegionCommands {
|
|||||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||||
FaweLimit limit = actor.getLimit();
|
FaweLimit limit = actor.getLimit();
|
||||||
if (volume >= limit.MAX_CHECKS) {
|
if (volume >= limit.MAX_CHECKS) {
|
||||||
throw FaweCache.MAX_CHECKS;
|
throw FaweCache.INSTANCE.getMAX_CHECKS();
|
||||||
}
|
}
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
try {
|
try {
|
||||||
|
@ -34,6 +34,7 @@ import com.sk89q.worldedit.function.mask.Mask;
|
|||||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||||
import com.sk89q.worldedit.function.mask.MaskUnion;
|
import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
@ -167,7 +168,7 @@ public class DefaultMaskParser extends FaweParser<Mask> {
|
|||||||
if (mask == null) {
|
if (mask == null) {
|
||||||
context.setPreferringWildcard(false);
|
context.setPreferringWildcard(false);
|
||||||
context.setRestricted(false);
|
context.setRestricted(false);
|
||||||
BlockStateHolder block = worldEdit.getBlockFactory().parseFromInput(full, context);
|
BaseBlock block = worldEdit.getBlockFactory().parseFromInput(full, context);
|
||||||
builder.add(block);
|
builder.add(block);
|
||||||
mask = builder.build(extent);
|
mask = builder.build(extent);
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
default boolean cancel() {
|
default boolean cancel() {
|
||||||
ExtentTraverser<Extent> traverser = new ExtentTraverser<>(this);
|
ExtentTraverser<Extent> traverser = new ExtentTraverser<>(this);
|
||||||
|
|
||||||
NullExtent nullExtent = new NullExtent(this, FaweCache.MANUAL);
|
NullExtent nullExtent = new NullExtent(this, FaweCache.INSTANCE.getMANUAL());
|
||||||
|
|
||||||
ExtentTraverser<Extent> next = traverser.next();
|
ExtentTraverser<Extent> next = traverser.next();
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
@ -523,7 +523,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
default <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
default <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||||
checkNotNull(region);
|
checkNotNull(region);
|
||||||
checkNotNull(block);
|
checkNotNull(block);
|
||||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
|
|
||||||
int changes = 0;
|
int changes = 0;
|
||||||
for (BlockVector3 pos : region) {
|
for (BlockVector3 pos : region) {
|
||||||
|
@ -51,7 +51,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
public class MaskingExtent extends AbstractDelegateExtent implements IBatchProcessor, Filter {
|
public class MaskingExtent extends AbstractDelegateExtent implements IBatchProcessor, Filter {
|
||||||
|
|
||||||
private Mask mask;
|
private Mask mask;
|
||||||
private LoadingCache<Long, ChunkFilterBlock> threadIdToFilter = FaweCache.IMP.createCache(() -> new CharFilterBlock(getExtent()));
|
private LoadingCache<Long, ChunkFilterBlock> threadIdToFilter = FaweCache.INSTANCE.createCache(() -> new CharFilterBlock(getExtent()));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
|
@ -268,7 +268,7 @@ public class FastSchematicReader extends NBTSchematicReader {
|
|||||||
// tiles
|
// tiles
|
||||||
if (tiles != null && !tiles.isEmpty()) {
|
if (tiles != null && !tiles.isEmpty()) {
|
||||||
for (Map<String, Object> tileRaw : tiles) {
|
for (Map<String, Object> tileRaw : tiles) {
|
||||||
CompoundTag tile = FaweCache.IMP.asTag(tileRaw);
|
CompoundTag tile = FaweCache.INSTANCE.asTag(tileRaw);
|
||||||
|
|
||||||
int[] pos = tile.getIntArray("Pos");
|
int[] pos = tile.getIntArray("Pos");
|
||||||
int x,y,z;
|
int x,y,z;
|
||||||
@ -303,7 +303,7 @@ public class FastSchematicReader extends NBTSchematicReader {
|
|||||||
// entities
|
// entities
|
||||||
if (entities != null && !entities.isEmpty()) {
|
if (entities != null && !entities.isEmpty()) {
|
||||||
for (Map<String, Object> entRaw : entities) {
|
for (Map<String, Object> entRaw : entities) {
|
||||||
CompoundTag ent = FaweCache.IMP.asTag(entRaw);
|
CompoundTag ent = FaweCache.INSTANCE.asTag(entRaw);
|
||||||
|
|
||||||
Map<String, Tag> value = ent.getValue();
|
Map<String, Tag> value = ent.getValue();
|
||||||
StringTag id = (StringTag) value.get("Id");
|
StringTag id = (StringTag) value.get("Id");
|
||||||
|
@ -322,7 +322,7 @@ public class SchematicReader implements ClipboardReader {
|
|||||||
if (tiles != null && !tiles.isEmpty()) {
|
if (tiles != null && !tiles.isEmpty()) {
|
||||||
outer:
|
outer:
|
||||||
for (Map<String, Object> tileRaw : tiles) {
|
for (Map<String, Object> tileRaw : tiles) {
|
||||||
CompoundTag tile = FaweCache.IMP.asTag(tileRaw);
|
CompoundTag tile = FaweCache.INSTANCE.asTag(tileRaw);
|
||||||
int x = (int) tileRaw.get("x");
|
int x = (int) tileRaw.get("x");
|
||||||
int y = (int) tileRaw.get("y");
|
int y = (int) tileRaw.get("y");
|
||||||
int z = (int) tileRaw.get("z");
|
int z = (int) tileRaw.get("z");
|
||||||
@ -350,7 +350,7 @@ public class SchematicReader implements ClipboardReader {
|
|||||||
entRaw.put("Id", id);
|
entRaw.put("Id", id);
|
||||||
EntityType type = EntityTypes.parse(id);
|
EntityType type = EntityTypes.parse(id);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
CompoundTag ent = FaweCache.IMP.asTag(entRaw);
|
CompoundTag ent = FaweCache.INSTANCE.asTag(entRaw);
|
||||||
for (EntityNBTCompatibilityHandler compat : ENTITY_COMPATIBILITY_HANDLERS) {
|
for (EntityNBTCompatibilityHandler compat : ENTITY_COMPATIBILITY_HANDLERS) {
|
||||||
if (compat.isAffectedEntity(type, ent)) {
|
if (compat.isAffectedEntity(type, ent)) {
|
||||||
ent = compat.updateNBT(type, ent);
|
ent = compat.updateNBT(type, ent);
|
||||||
|
@ -107,10 +107,10 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
try {
|
try {
|
||||||
blockBag.fetchPlacedBlock(block.toImmutableState());
|
blockBag.fetchPlacedBlock(block.toImmutableState());
|
||||||
} catch (UnplaceableBlockException e) {
|
} catch (UnplaceableBlockException e) {
|
||||||
throw FaweCache.BLOCK_BAG;
|
throw FaweCache.INSTANCE.getBLOCK_BAG();
|
||||||
} catch (BlockBagException e) {
|
} catch (BlockBagException e) {
|
||||||
missingBlocks[block.getBlockType().getInternalId()]++;
|
missingBlocks[block.getBlockType().getInternalId()]++;
|
||||||
throw FaweCache.BLOCK_BAG;
|
throw FaweCache.INSTANCE.getBLOCK_BAG();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mine) {
|
if (mine) {
|
||||||
|
@ -5,6 +5,7 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.world.block.BlockID;
|
import com.sk89q.worldedit.world.block.BlockID;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -145,11 +146,11 @@ public class CavesGen extends GenBase {
|
|||||||
|
|
||||||
// Search for water
|
// Search for water
|
||||||
boolean waterFound = false;
|
boolean waterFound = false;
|
||||||
for (int local_x = m; (!waterFound) && (local_x < n); local_x++) {
|
for (int local_x = m; !waterFound && (local_x < n); local_x++) {
|
||||||
for (int local_z = i3; (!waterFound) && (local_z < i4); local_z++) {
|
for (int local_z = i3; !waterFound && (local_z < i4); local_z++) {
|
||||||
for (int local_y = i2 + 1; (!waterFound) && (local_y >= i1 - 1); local_y--) {
|
for (int local_y = i2 + 1; !waterFound && (local_y >= i1 - 1); local_y--) {
|
||||||
if (local_y < 255) {
|
if (local_y < 255) {
|
||||||
BlockStateHolder material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
BlockState material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
||||||
if (material.getBlockType() == BlockTypes.WATER) {
|
if (material.getBlockType() == BlockTypes.WATER) {
|
||||||
waterFound = true;
|
waterFound = true;
|
||||||
}
|
}
|
||||||
@ -173,8 +174,8 @@ public class CavesGen extends GenBase {
|
|||||||
for (int local_y = i2; local_y > i1; local_y--) {
|
for (int local_y = i2; local_y > i1; local_y--) {
|
||||||
double d11 = ((local_y - 1) + 0.5D - y) / d4;
|
double d11 = ((local_y - 1) + 0.5D - y) / d4;
|
||||||
if ((d11 > -0.7D) && (d9 * d9 + d11 * d11 + d10 * d10 < 1.0D)) {
|
if ((d11 > -0.7D) && (d9 * d9 + d11 * d11 + d10 * d10 < 1.0D)) {
|
||||||
BlockStateHolder material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
BlockState material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
||||||
BlockStateHolder materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z);
|
BlockState materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z);
|
||||||
BlockType blockType = material.getBlockType();
|
BlockType blockType = material.getBlockType();
|
||||||
switch (blockType.getInternalId()) {
|
switch (blockType.getInternalId()) {
|
||||||
case BlockID.MYCELIUM:
|
case BlockID.MYCELIUM:
|
||||||
@ -191,7 +192,7 @@ public class CavesGen extends GenBase {
|
|||||||
// If grass was just deleted, try to
|
// If grass was just deleted, try to
|
||||||
// move it down
|
// move it down
|
||||||
if (grassFound) {
|
if (grassFound) {
|
||||||
BlockStateHolder block = chunk.getBlock(bx + local_x, local_y - 1, bz + local_z);
|
BlockState block = chunk.getBlock(bx + local_x, local_y - 1, bz + local_z);
|
||||||
if (block.getBlockType() == BlockTypes.DIRT) {
|
if (block.getBlockType() == BlockTypes.DIRT) {
|
||||||
chunk.setBlock(bx + local_x, local_y - 1, bz + local_z, BlockTypes.STONE.getDefaultState());
|
chunk.setBlock(bx + local_x, local_y - 1, bz + local_z, BlockTypes.STONE.getDefaultState());
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
public class InverseSingleBlockStateMask extends ABlockMask {
|
public class InverseSingleBlockStateMask extends ABlockMask {
|
||||||
private final char ordinal;
|
private final char ordinal;
|
||||||
|
|
||||||
public BlockStateHolder getBlockState() {
|
public BlockState getBlockState() {
|
||||||
return BlockState.getFromOrdinal(ordinal);
|
return BlockState.getFromOrdinal(ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
public class SingleBlockStateMask extends ABlockMask {
|
public class SingleBlockStateMask extends ABlockMask {
|
||||||
private final char ordinal;
|
private final char ordinal;
|
||||||
|
|
||||||
public BlockStateHolder getBlockState() {
|
public BlockState getBlockState() {
|
||||||
return BlockState.getFromOrdinal(ordinal);
|
return BlockState.getFromOrdinal(ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package com.sk89q.worldedit.function.pattern;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a {@link BlockStateHolder} for a given position.
|
|
||||||
* - Adapts the vector apply to integer
|
|
||||||
*/
|
|
||||||
public interface FawePattern extends Pattern {
|
|
||||||
//
|
|
||||||
// @Deprecated
|
|
||||||
// default BaseBlock apply(BlockVector3 position) {
|
|
||||||
// throw new UnsupportedOperationException("Please use apply(extent, get, set)");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Return a {@link BlockStateHolder} for the given position.
|
|
||||||
// *
|
|
||||||
// * @return a block
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException;
|
|
||||||
}
|
|
@ -13,7 +13,7 @@ public class MutableBlockVector3 extends BlockVector3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MutableBlockVector3 get(int x, int y, int z) {
|
public static MutableBlockVector3 get(int x, int y, int z) {
|
||||||
return FaweCache.IMP.MUTABLE_BLOCKVECTOR3.get().setComponents(x, y, z);
|
return FaweCache.INSTANCE.getMUTABLE_BLOCKVECTOR3().get().setComponents(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableBlockVector3() {}
|
public MutableBlockVector3() {}
|
||||||
|
@ -10,11 +10,11 @@ public class MutableVector3 extends Vector3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MutableVector3 get(int x, int y, int z) {
|
public static MutableVector3 get(int x, int y, int z) {
|
||||||
return FaweCache.IMP.MUTABLE_VECTOR3.get().setComponents(x, y, z);
|
return FaweCache.INSTANCE.getMUTABLE_VECTOR3().get().setComponents(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MutableVector3 get(double x, double y, double z) {
|
public static MutableVector3 get(double x, double y, double z) {
|
||||||
return FaweCache.IMP.MUTABLE_VECTOR3.get().setComponents(x, y, z);
|
return FaweCache.INSTANCE.getMUTABLE_VECTOR3().get().setComponents(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableVector3(double x, double y, double z) {
|
public MutableVector3(double x, double y, double z) {
|
||||||
|
@ -144,7 +144,6 @@ public class HeightMap {
|
|||||||
* @param filter the filter
|
* @param filter the filter
|
||||||
* @param iterations the number of iterations
|
* @param iterations the number of iterations
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int applyFilter(HeightMapFilter filter, int iterations) throws MaxChangedBlocksException {
|
public int applyFilter(HeightMapFilter filter, int iterations) throws MaxChangedBlocksException {
|
||||||
@ -173,7 +172,7 @@ public class HeightMap {
|
|||||||
|
|
||||||
int blocksChanged = 0;
|
int blocksChanged = 0;
|
||||||
|
|
||||||
BlockStateHolder tmpBlock = BlockTypes.AIR.getDefaultState();
|
BlockStateHolder<BlockState> tmpBlock = BlockTypes.AIR.getDefaultState();
|
||||||
|
|
||||||
int maxY4 = maxY << 4;
|
int maxY4 = maxY << 4;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -197,13 +196,13 @@ public class HeightMap {
|
|||||||
// Depending on growing or shrinking we need to start at the bottom or top
|
// Depending on growing or shrinking we need to start at the bottom or top
|
||||||
if (newHeight > curHeight) {
|
if (newHeight > curHeight) {
|
||||||
// Set the top block of the column to be the same type (this might go wrong with rounding)
|
// Set the top block of the column to be the same type (this might go wrong with rounding)
|
||||||
BlockStateHolder existing = session.getBlock(xr, curBlock, zr);
|
BlockStateHolder<BlockState> existing = session.getBlock(xr, curBlock, zr);
|
||||||
|
|
||||||
// Skip water/lava
|
// Skip water/lava
|
||||||
if (existing.getBlockType().getMaterial().isMovementBlocker()) {
|
if (existing.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
// Grow -- start from 1 below top replacing airblocks
|
// Grow -- start from 1 below top replacing airblocks
|
||||||
for (int setY = newBlock - 1, getY = curBlock; setY >= curBlock; --setY, getY--) {
|
for (int setY = newBlock - 1, getY = curBlock; setY >= curBlock; --setY, getY--) {
|
||||||
BlockStateHolder get = session.getBlock(xr, getY, zr);
|
BlockStateHolder<BlockState> get = session.getBlock(xr, getY, zr);
|
||||||
if (get != BlockTypes.AIR.getDefaultState()) tmpBlock = get;
|
if (get != BlockTypes.AIR.getDefaultState()) tmpBlock = get;
|
||||||
session.setBlock(xr, setY, zr, tmpBlock);
|
session.setBlock(xr, setY, zr, tmpBlock);
|
||||||
++blocksChanged;
|
++blocksChanged;
|
||||||
@ -228,7 +227,7 @@ public class HeightMap {
|
|||||||
// Set the top block of the column to be the same type
|
// Set the top block of the column to be the same type
|
||||||
// (this could otherwise go wrong with rounding)
|
// (this could otherwise go wrong with rounding)
|
||||||
int setData = newHeight & 15;
|
int setData = newHeight & 15;
|
||||||
BlockStateHolder existing = session.getBlock(xr, curBlock, zr);
|
BlockStateHolder<BlockState> existing = session.getBlock(xr, curBlock, zr);
|
||||||
if (setData != 0) {
|
if (setData != 0) {
|
||||||
existing = PropertyGroup.LEVEL.set(existing, setData - 1);
|
existing = PropertyGroup.LEVEL.set(existing, setData - 1);
|
||||||
session.setBlock(xr, newBlock, zr, existing);
|
session.setBlock(xr, newBlock, zr, existing);
|
||||||
@ -248,7 +247,6 @@ public class HeightMap {
|
|||||||
*
|
*
|
||||||
* @param data the data
|
* @param data the data
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int apply(int[] data) throws MaxChangedBlocksException {
|
public int apply(int[] data) throws MaxChangedBlocksException {
|
||||||
|
@ -124,8 +124,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
if (pos1 == null || pos2 == null) {
|
if (pos1 == null || pos2 == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pos1 = pos1.clampY(world == null ? 0 : 0, world == null ? FaweCache.IMP.WORLD_MAX_Y : world.getMaxY());
|
pos1 = pos1.clampY(world == null ? 0 : 0, world == null ? FaweCache.WORLD_MAX_Y : world.getMaxY());
|
||||||
pos2 = pos2.clampY(world == null ? 0 : 0, world == null ? FaweCache.IMP.WORLD_MAX_Y : world.getMaxY());
|
pos2 = pos2.clampY(world == null ? 0 : 0, world == null ? FaweCache.WORLD_MAX_Y : world.getMaxY());
|
||||||
minX = Math.min(pos1.getX(), pos2.getX());
|
minX = Math.min(pos1.getX(), pos2.getX());
|
||||||
minY = Math.min(pos1.getY(), pos2.getY());
|
minY = Math.min(pos1.getY(), pos2.getY());
|
||||||
minZ = Math.min(pos1.getZ(), pos2.getZ());
|
minZ = Math.min(pos1.getZ(), pos2.getZ());
|
||||||
@ -730,7 +730,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
boolean trimZ = lowerZ != 0 || upperZ != 15;
|
boolean trimZ = lowerZ != 0 || upperZ != 15;
|
||||||
|
|
||||||
int indexY, index;
|
int indexY, index;
|
||||||
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
for (int layer = 0; layer < FaweCache.CHUNK_LAYERS; layer++) {
|
||||||
if (set.hasSection(layer)) {
|
if (set.hasSection(layer)) {
|
||||||
char[] arr = set.load(layer);
|
char[] arr = set.load(layer);
|
||||||
if (trimX || trimZ) {
|
if (trimX || trimZ) {
|
||||||
|
@ -80,7 +80,7 @@ public class PropertyGroup<G, A> {
|
|||||||
|
|
||||||
private static final Function VOID_FUNCTION = o -> o;
|
private static final Function VOID_FUNCTION = o -> o;
|
||||||
|
|
||||||
public G get(BlockStateHolder state) {
|
public <B extends BlockStateHolder<B>> G get(BlockStateHolder<B> state) {
|
||||||
BlockType type = state.getBlockType();
|
BlockType type = state.getBlockType();
|
||||||
PropertyFunction func = states[type.getInternalId()];
|
PropertyFunction func = states[type.getInternalId()];
|
||||||
if (func == null) return defaultValue;
|
if (func == null) return defaultValue;
|
||||||
@ -88,7 +88,7 @@ public class PropertyGroup<G, A> {
|
|||||||
return (G) func.getFunc.apply(value);
|
return (G) func.getFunc.apply(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockStateHolder set(BlockStateHolder state, A value) {
|
public <B extends BlockStateHolder<B>> BlockStateHolder<B> set(BlockStateHolder<B> state, A value) {
|
||||||
BlockType type = state.getBlockType();
|
BlockType type = state.getBlockType();
|
||||||
PropertyFunction func = states[type.getInternalId()];
|
PropertyFunction func = states[type.getInternalId()];
|
||||||
if (func != null) {
|
if (func != null) {
|
||||||
|
@ -35,7 +35,7 @@ import com.sk89q.worldedit.extent.NullExtent;
|
|||||||
import com.sk89q.worldedit.extent.OutputExtent;
|
import com.sk89q.worldedit.extent.OutputExtent;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.SingleBlockStateMask;
|
import com.sk89q.worldedit.function.mask.SingleBlockStateMask;
|
||||||
import com.sk89q.worldedit.function.pattern.FawePattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
@ -51,7 +51,7 @@ import java.util.stream.Stream;
|
|||||||
* An immutable class that represents the state a block can be in.
|
* An immutable class that represents the state a block can be in.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||||
private final int internalId;
|
private final int internalId;
|
||||||
private final int ordinal;
|
private final int ordinal;
|
||||||
private final char ordinalChar;
|
private final char ordinalChar;
|
||||||
|
@ -21,12 +21,10 @@ package com.sk89q.worldedit.world.block;
|
|||||||
|
|
||||||
import com.boydti.fawe.beta.ITileInput;
|
import com.boydti.fawe.beta.ITileInput;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
|
||||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||||
import com.sk89q.worldedit.extent.OutputExtent;
|
import com.sk89q.worldedit.extent.OutputExtent;
|
||||||
import com.sk89q.worldedit.function.pattern.FawePattern;
|
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
@ -37,7 +35,7 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public interface BlockStateHolder<B extends BlockStateHolder<B>> extends FawePattern, TileEntityBlock {
|
public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEntityBlock, Pattern {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the block type
|
* Get the block type
|
||||||
|
@ -25,14 +25,13 @@ import com.sk89q.worldedit.extension.platform.Capability;
|
|||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.NullExtent;
|
import com.sk89q.worldedit.extent.NullExtent;
|
||||||
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
||||||
import com.sk89q.worldedit.function.pattern.FawePattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.Keyed;
|
import com.sk89q.worldedit.registry.Keyed;
|
||||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
import com.sk89q.worldedit.util.concurrency.LazyReference;
|
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
@ -48,7 +47,7 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
public class BlockType implements FawePattern, Keyed {
|
public class BlockType implements Keyed, Pattern {
|
||||||
|
|
||||||
public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type");
|
public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type");
|
||||||
|
|
||||||
|
@ -21,36 +21,16 @@ package com.sk89q.worldedit.world.block;
|
|||||||
|
|
||||||
import com.boydti.fawe.command.SuggestInputParseException;
|
import com.boydti.fawe.command.SuggestInputParseException;
|
||||||
import com.boydti.fawe.object.string.JoinedCharSequence;
|
import com.boydti.fawe.object.string.JoinedCharSequence;
|
||||||
import com.boydti.fawe.util.MathMan;
|
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
|
||||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
|
||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
|
||||||
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
|
||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||||
import com.sk89q.worldedit.world.registry.Registries;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a list of common Block String IDs.
|
* Stores a list of common Block String IDs.
|
||||||
@ -777,7 +757,7 @@ public final class BlockTypes {
|
|||||||
if (result != null) return result;
|
if (result != null) return result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BlockStateHolder block = LegacyMapper.getInstance().getBlockFromLegacy(input);
|
BlockStateHolder<BlockState> block = LegacyMapper.getInstance().getBlockFromLegacy(input);
|
||||||
if (block != null) return block.getBlockType();
|
if (block != null) return block.getBlockType();
|
||||||
} catch (NumberFormatException | IndexOutOfBoundsException e) {
|
} catch (NumberFormatException | IndexOutOfBoundsException e) {
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user