mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 04:38:35 +00:00
Move vectors to static creators, for caching
This commit is contained in:
committed by
IronApollo
parent
a9919d130c
commit
4d6045813c
@ -129,7 +129,7 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
// mutable.mutX(x);
|
||||
// mutable.mutY(y);
|
||||
// mutable.mutZ(z);
|
||||
return extent.getLazyBlock(new BlockVector3(x, y, z));
|
||||
return extent.getLazyBlock(BlockVector3.at(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -142,7 +142,7 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
// mutable.mutX(x);
|
||||
// mutable.mutY(y);
|
||||
// mutable.mutZ(z);
|
||||
return setBlock(new BlockVector3(x, y, z), block);
|
||||
return setBlock(BlockVector3.at(x, y, z), block);
|
||||
}
|
||||
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
|
@ -127,15 +127,15 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
|
||||
default BlockState getLazyBlock(int x, int y, int z) {
|
||||
return getLazyBlock(new BlockVector3(x, y, z));
|
||||
return getLazyBlock(BlockVector3.at(x, y, z));
|
||||
}
|
||||
|
||||
default boolean setBlock(int x, int y, int z, BlockStateHolder state) throws WorldEditException {
|
||||
return setBlock(new BlockVector3(x, y, z), state);
|
||||
return setBlock(BlockVector3.at(x, y, z), state);
|
||||
}
|
||||
|
||||
default boolean setBiome(int x, int y, int z, BaseBiome biome) {
|
||||
return setBiome(new BlockVector2(x, z), biome);
|
||||
return setBiome(BlockVector2.at(x, z), biome);
|
||||
}
|
||||
|
||||
default int getHighestTerrainBlock(final int x, final int z, int minY, int maxY) {
|
||||
|
@ -84,7 +84,7 @@ public class MaskingExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BaseBiome biome) {
|
||||
return mask.test(new BlockVector3(x, y, z)) && super.setBiome(x, y, z, biome);
|
||||
return mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome);
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ import java.util.List;
|
||||
*/
|
||||
public class NullExtent implements Extent {
|
||||
|
||||
private final BlockVector3 nullPoint = new BlockVector3(0, 0, 0);
|
||||
private final BlockVector3 nullPoint = BlockVector3.at(0, 0, 0);
|
||||
|
||||
public static final NullExtent INSTANCE = new NullExtent();
|
||||
|
||||
|
@ -31,7 +31,6 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.extent.cache;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
/**
|
||||
|
@ -312,11 +312,11 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
|
||||
@Override
|
||||
public int getOpacity(int x, int y, int z) {
|
||||
return getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().getLightOpacity();
|
||||
return getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().getLightOpacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightness(int x, int y, int z) {
|
||||
return getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().getLightValue();
|
||||
return getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().getLightValue();
|
||||
}
|
||||
}
|
@ -117,12 +117,12 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
int originX = requireTag(schematic, "WEOriginX", IntTag.class).getValue();
|
||||
int originY = requireTag(schematic, "WEOriginY", IntTag.class).getValue();
|
||||
int originZ = requireTag(schematic, "WEOriginZ", IntTag.class).getValue();
|
||||
BlockVector3 min = new BlockVector3(originX, originY, originZ);
|
||||
BlockVector3 min = BlockVector3.at(originX, originY, originZ);
|
||||
|
||||
int offsetX = requireTag(schematic, "WEOffsetX", IntTag.class).getValue();
|
||||
int offsetY = requireTag(schematic, "WEOffsetY", IntTag.class).getValue();
|
||||
int offsetZ = requireTag(schematic, "WEOffsetZ", IntTag.class).getValue();
|
||||
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
|
||||
BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ);
|
||||
|
||||
origin = min.subtract(offset);
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
@ -206,7 +206,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
}
|
||||
|
||||
BlockVector3 vec = new BlockVector3(x, y, z);
|
||||
BlockVector3 vec = BlockVector3.at(x, y, z);
|
||||
tileEntitiesMap.put(vec, values);
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int z = 0; z < length; ++z) {
|
||||
int index = y * width * length + z * width + x;
|
||||
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
BlockVector3 pt = BlockVector3.at(x, y, z);
|
||||
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
|
||||
|
||||
try {
|
||||
|
@ -122,14 +122,28 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
private FaweClipboard setupClipboard(int size, UUID uuid) {
|
||||
if (fc != null) {
|
||||
if (fc.getDimensions().getX() == 0) {
|
||||
fc.setDimensions(new BlockVector3(size, 1, 1));
|
||||
fc.setDimensions(BlockVector3.at(size, 1, 1));
|
||||
}
|
||||
return fc;
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
if (Settings.IMP.CLIPBOARD.USE_DISK) {
|
||||
return fc = new DiskOptimizedClipboard(size, 1, 1, uuid);
|
||||
} else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) {
|
||||
return fc = new CPUOptimizedClipboard(size, 1, 1);
|
||||
//=======
|
||||
//
|
||||
// BlockVector3 min = BlockVector3.at(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||
//
|
||||
// if (metadata.containsKey("WEOffsetX")) {
|
||||
// // We appear to have WorldEdit Metadata
|
||||
// int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
|
||||
// int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
|
||||
// int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
|
||||
// BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ);
|
||||
// origin = min.subtract(offset);
|
||||
// region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
} else {
|
||||
return fc = new MemoryOptimizedClipboard(size, 1, 1);
|
||||
}
|
||||
@ -310,7 +324,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
private Clipboard readVersion1(UUID uuid) throws IOException {
|
||||
width = height = length = offsetX = offsetY = offsetZ = Integer.MIN_VALUE;
|
||||
|
||||
final BlockArrayClipboard clipboard = new BlockArrayClipboard(new CuboidRegion(new BlockVector3(0, 0, 0), new BlockVector3(0, 0, 0)), fc);
|
||||
final BlockArrayClipboard clipboard = new BlockArrayClipboard(new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(0, 0, 0)), fc);
|
||||
FastByteArrayOutputStream blocksOut = new FastByteArrayOutputStream();
|
||||
FastByteArrayOutputStream biomesOut = new FastByteArrayOutputStream();
|
||||
|
||||
@ -318,7 +332,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
streamer.addReader("Schematic.Width", (BiConsumer<Integer, Short>) (i, v) -> width = v);
|
||||
streamer.addReader("Schematic.Height", (BiConsumer<Integer, Short>) (i, v) -> height = v);
|
||||
streamer.addReader("Schematic.Length", (BiConsumer<Integer, Short>) (i, v) -> length = v);
|
||||
streamer.addReader("Schematic.Offset", (BiConsumer<Integer, int[]>) (i, v) -> min = new BlockVector3(v[0], v[1], v[2]));
|
||||
streamer.addReader("Schematic.Offset", (BiConsumer<Integer, int[]>) (i, v) -> min = BlockVector3.at(v[0], v[1], v[2]));
|
||||
streamer.addReader("Schematic.Metadata.WEOffsetX", (BiConsumer<Integer, Integer>) (i, v) -> offsetX = v);
|
||||
streamer.addReader("Schematic.Metadata.WEOffsetY", (BiConsumer<Integer, Integer>) (i, v) -> offsetY = v);
|
||||
streamer.addReader("Schematic.Metadata.WEOffsetZ", (BiConsumer<Integer, Integer>) (i, v) -> offsetZ = v);
|
||||
@ -329,6 +343,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
int index = ((IntTag) entry.getValue()).getValue();
|
||||
palette[index] = (char) state.getOrdinal();
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
});
|
||||
streamer.addReader("Schematic.BlockData.#", new NBTStreamer.LazyReader() {
|
||||
@Override
|
||||
@ -338,6 +353,23 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//=======
|
||||
// palette.put(id, state);
|
||||
// }
|
||||
//
|
||||
// byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue();
|
||||
//
|
||||
// Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
// try {
|
||||
// List<Map<String, Tag>> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream()
|
||||
// .map(tag -> (CompoundTag) tag)
|
||||
// .map(CompoundTag::getValue)
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// for (Map<String, Tag> tileEntity : tileEntityTags) {
|
||||
// int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
|
||||
// tileEntitiesMap.put(BlockVector3.at(pos[0], pos[1], pos[2]), tileEntity);
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
}
|
||||
});
|
||||
streamer.addReader("Schematic.Biomes.#", new NBTStreamer.LazyReader() {
|
||||
@ -362,6 +394,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
int z = pos[2];
|
||||
fc.setTile(x, y, z, value);
|
||||
}
|
||||
//<<<<<<< HEAD
|
||||
});
|
||||
streamer.addReader("Schematic.Entities.#", new BiConsumer<Integer, CompoundTag>() {
|
||||
@Override
|
||||
@ -390,7 +423,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
BlockVector3 origin = min;
|
||||
CuboidRegion region;
|
||||
if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) {
|
||||
origin = origin.subtract(new BlockVector3(offsetX, offsetY, offsetZ));
|
||||
origin = origin.subtract(BlockVector3.at(offsetX, offsetY, offsetZ));
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
} else {
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
@ -402,6 +435,21 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
for (int index = 0; index < volume; index++) {
|
||||
BlockState state = BlockTypes.states[palette[fis.read()]];
|
||||
fc.setBlock(index, state);
|
||||
//=======
|
||||
// // index = (y * length + z) * width + x
|
||||
// int y = index / (width * length);
|
||||
// int z = (index % (width * length)) / width;
|
||||
// int x = (index % (width * length)) % width;
|
||||
// BlockState state = palette.get(value);
|
||||
// BlockVector3 pt = BlockVector3.at(x, y, z);
|
||||
// try {
|
||||
// if (tileEntitiesMap.containsKey(pt)) {
|
||||
// Map<String, Tag> values = Maps.newHashMap(tileEntitiesMap.get(pt));
|
||||
// for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) {
|
||||
// if (handler.isAffectedBlock(state)) {
|
||||
// handler.updateNBT(state, values);
|
||||
// }
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
}
|
||||
} else {
|
||||
for (int index = 0; index < volume; index++) {
|
||||
@ -419,7 +467,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
}
|
||||
}
|
||||
fc.setDimensions(new BlockVector3(width, height, length));
|
||||
fc.setDimensions(BlockVector3.at(width, height, length));
|
||||
clipboard.init(region, fc);
|
||||
clipboard.setOrigin(origin);
|
||||
return clipboard;
|
||||
|
@ -178,13 +178,13 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
// int z0 = min.getBlockZ() + z;
|
||||
// for (int x = 0; x < width; x++) {
|
||||
// int x0 = min.getBlockX() + x;
|
||||
// BlockVector3 point = new BlockVector3(x0, y0, z0);
|
||||
// BlockVector3 point = BlockVector3.at(x0, y0, z0);
|
||||
// BaseBlock block = clipboard.getFullBlock(point);
|
||||
// if (block.getNbtData() != null) {
|
||||
// Map<String, Tag> values = new HashMap<>();
|
||||
// for (Map.Entry<String, Tag> entry : block.getNbtData().getValue().entrySet()) {
|
||||
// values.put(entry.getKey(), entry.getValue());
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
}
|
||||
int ordinal = block.getOrdinal();
|
||||
char value = palette[ordinal];
|
||||
|
@ -77,7 +77,7 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent {
|
||||
if (!enabled) {
|
||||
return getExtent().setBlock(location, block);
|
||||
}
|
||||
BlockVector2 chunkPos = new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
BlockVector2 chunkPos = BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
batches.computeIfAbsent(chunkPos, k -> new LocatedBlockList()).add(location, block);
|
||||
return true;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class FastModeExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (enabled) {
|
||||
dirtyChunks.add(new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||
dirtyChunks.add(BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||
return world.setBlock(location, block, false);
|
||||
} else {
|
||||
return world.setBlock(location, block, true);
|
||||
|
@ -93,7 +93,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||
if (toolUse && block.getBlockType().getMaterial().isAir()) {
|
||||
world.simulateBlockMine(new BlockVector3(x, y, z));
|
||||
world.simulateBlockMine(BlockVector3.at(x, y, z));
|
||||
return true;
|
||||
} else {
|
||||
return super.setBlock(x, y, z, block);
|
||||
|
Reference in New Issue
Block a user