mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 04:38:35 +00:00
Current progress with update
This commit is contained in:
@ -22,32 +22,29 @@ package com.sk89q.worldedit.extent;
|
||||
import com.boydti.fawe.jnbt.anvil.generator.GenBase;
|
||||
import com.boydti.fawe.jnbt.anvil.generator.Resource;
|
||||
import com.boydti.fawe.object.extent.LightingExtent;
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* A base class for {@link Extent}s that merely passes extents onto another.
|
||||
*/
|
||||
@ -79,12 +76,12 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getBlockType(Vector position) {
|
||||
public BlockType getBlockType(BlockVector3 position) {
|
||||
return extent.getBlockType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getFullBlock(Vector position) {
|
||||
public BlockState getFullBlock(BlockVector3 position) {
|
||||
return extent.getFullBlock(position);
|
||||
}
|
||||
|
||||
@ -127,11 +124,6 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
return extent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
return extent.getLazyBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
mutable.mutX(x);
|
||||
@ -141,7 +133,7 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(Vector position) {
|
||||
public BlockState getLazyBlock(BlockVector3 position) {
|
||||
return extent.getLazyBlock(position);
|
||||
}
|
||||
|
||||
@ -152,9 +144,13 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
mutable.mutZ(z);
|
||||
return setBlock(mutable, block);
|
||||
}
|
||||
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return extent.getBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return extent.setBlock(location, block);
|
||||
}
|
||||
|
||||
@ -175,12 +171,12 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return extent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return extent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@ -195,12 +191,12 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return extent.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return extent.getMaximumPoint();
|
||||
}
|
||||
|
||||
@ -254,7 +250,7 @@ public class AbstractDelegateExtent implements LightingExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector pt) {
|
||||
public boolean contains(BlockVector3 pt) {
|
||||
return extent.contains(pt);
|
||||
}
|
||||
|
||||
|
@ -19,20 +19,32 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
import com.sk89q.worldedit.history.change.EntityCreate;
|
||||
import com.sk89q.worldedit.history.change.EntityRemove;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
<<<<<<< HEAD
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -59,9 +71,15 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
BlockStateHolder previous = getBlock(location);
|
||||
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
||||
=======
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
BaseBlock previous = getFullBlock(location);
|
||||
changeSet.add(new BlockChange(location, previous, block));
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,11 @@ import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.registry.state.PropertyGroup;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
@ -63,7 +66,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
*
|
||||
* @return the minimum point
|
||||
*/
|
||||
Vector getMinimumPoint();
|
||||
BlockVector3 getMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the maximum point in the extent.
|
||||
@ -73,7 +76,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
*
|
||||
* @return the maximum point
|
||||
*/
|
||||
Vector getMaximumPoint();
|
||||
BlockVector3 getMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get a list of all entities within the given region.
|
||||
@ -114,25 +117,25 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
default BlockState getBlock(Vector position) {
|
||||
default BlockState getBlock(BlockVector3 position) {
|
||||
return getFullBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
default BlockState getLazyBlock(Vector position) {
|
||||
default BlockState getLazyBlock(BlockVector3 position) {
|
||||
return getFullBlock(position);
|
||||
}
|
||||
|
||||
default BlockState getLazyBlock(int x, int y, int z) {
|
||||
return getLazyBlock(MutableBlockVector.get(x, y, z));
|
||||
return getLazyBlock(new BlockVector3(x, y, z));
|
||||
}
|
||||
|
||||
default boolean setBlock(int x, int y, int z, BlockStateHolder state) throws WorldEditException {
|
||||
return setBlock(MutableBlockVector.get(x, y, z), state);
|
||||
return setBlock(new BlockVector3(x, y, z), state);
|
||||
}
|
||||
|
||||
default boolean setBiome(int x, int y, int z, BaseBiome biome) {
|
||||
return setBiome(MutableBlockVector2D.get(x, z), biome);
|
||||
return setBiome(new BlockVector2(x, z), biome);
|
||||
}
|
||||
|
||||
default int getHighestTerrainBlock(final int x, final int z, int minY, int maxY) {
|
||||
@ -252,7 +255,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
|
||||
default void generate(Region region, GenBase gen) throws WorldEditException {
|
||||
for (Vector2D chunkPos : region.getChunks()) {
|
||||
for (BlockVector2 chunkPos : region.getChunks()) {
|
||||
gen.generate(chunkPos, this);
|
||||
}
|
||||
}
|
||||
@ -263,7 +266,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
|
||||
default void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
for (Vector2D chunkPos : region.getChunks()) {
|
||||
for (BlockVector2 chunkPos : region.getChunks()) {
|
||||
for (int i = 0; i < frequency; i++) {
|
||||
if (random.nextInt(100) > rarity) {
|
||||
continue;
|
||||
@ -275,9 +278,9 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
}
|
||||
|
||||
default boolean contains(Vector pt) {
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
default boolean contains(BlockVector3 pt) {
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
return (pt.containedWithin(min, max));
|
||||
}
|
||||
|
||||
@ -309,7 +312,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
default List<Countable<BlockType>> getBlockDistribution(final Region region) {
|
||||
int[] counter = new int[BlockTypes.size()];
|
||||
|
||||
for (final Vector pt : region) {
|
||||
for (final BlockVector3 pt : region) {
|
||||
BlockType type = getBlockType(pt);
|
||||
counter[type.getInternalId()]++;
|
||||
}
|
||||
@ -333,7 +336,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
default List<Countable<BlockStateHolder>> getBlockDistributionWithData(final Region region) {
|
||||
int[][] counter = new int[BlockTypes.size()][];
|
||||
|
||||
for (final Vector pt : region) {
|
||||
for (final BlockVector3 pt : region) {
|
||||
BlockStateHolder blk = this.getBlock(pt);
|
||||
BlockType type = blk.getBlockType();
|
||||
int[] stateCounter = counter[type.getInternalId()];
|
||||
|
@ -19,14 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
@ -49,9 +45,9 @@ public interface InputExtent {
|
||||
* @param position position of the block
|
||||
* @return the block
|
||||
*/
|
||||
BlockState getBlock(Vector position);
|
||||
BlockState getBlock(BlockVector3 position);
|
||||
|
||||
default BlockType getBlockType(Vector position) {
|
||||
default BlockType getBlockType(BlockVector3 position) {
|
||||
return getBlock(position).getBlockType();
|
||||
}
|
||||
|
||||
@ -76,7 +72,7 @@ public interface InputExtent {
|
||||
* @param position position of the block
|
||||
* @return the block
|
||||
*/
|
||||
BlockState getLazyBlock(Vector position);
|
||||
BlockState getLazyBlock(BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Get a immutable snapshot of the block at the given location.
|
||||
@ -84,7 +80,7 @@ public interface InputExtent {
|
||||
* @param position position of the block
|
||||
* @return the block
|
||||
*/
|
||||
BlockState getFullBlock(Vector position);
|
||||
BlockState getFullBlock(BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Get the biome at the given location.
|
||||
@ -95,6 +91,6 @@ public interface InputExtent {
|
||||
* @param position the (x, z) location to check the biome at
|
||||
* @return the biome at the location
|
||||
*/
|
||||
BaseBiome getBiome(Vector2D position);
|
||||
BaseBiome getBiome(BlockVector2 position);
|
||||
|
||||
}
|
||||
|
@ -19,14 +19,23 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
|
||||
@ -72,7 +81,7 @@ public class MaskingExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return mask.test(location) && super.setBlock(location, block);
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||
@ -32,9 +31,24 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
=======
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
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;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
@ -46,18 +60,21 @@ import java.util.List;
|
||||
*/
|
||||
public class NullExtent implements Extent {
|
||||
|
||||
<<<<<<< HEAD
|
||||
private final Vector nullPoint = new Vector(0, 0, 0);
|
||||
|
||||
public static final NullExtent INSTANCE = new NullExtent();
|
||||
|
||||
=======
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return nullPoint;
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return nullPoint;
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,11 +94,12 @@ public class NullExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public BlockState getLazyBlock(Vector position) {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
@ -89,21 +107,25 @@ public class NullExtent implements Extent {
|
||||
@Override
|
||||
public BlockState getFullBlock(Vector position) {
|
||||
return new BaseBlock(getBlock(position));
|
||||
=======
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return getBlock(position).toBaseBlock();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -51,7 +51,7 @@ public interface OutputExtent {
|
||||
* @return true if the block was successfully set (return value may not be accurate)
|
||||
* @throws WorldEditException thrown on an error
|
||||
*/
|
||||
boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException;
|
||||
boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException;
|
||||
|
||||
/**
|
||||
* Set the biome.
|
||||
@ -60,7 +60,7 @@ public interface OutputExtent {
|
||||
* @param biome the biome to set to
|
||||
* @return true if the biome was successfully set (return value may not be accurate)
|
||||
*/
|
||||
boolean setBiome(Vector2D position, BaseBiome biome);
|
||||
boolean setBiome(BlockVector2 position, BaseBiome biome);
|
||||
|
||||
/**
|
||||
* Return an {@link Operation} that should be called to tie up loose ends
|
||||
|
@ -21,8 +21,6 @@ package com.sk89q.worldedit.extent.buffer;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -32,6 +30,8 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
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;
|
||||
@ -45,19 +45,19 @@ import java.util.Map;
|
||||
* actual application of the changes.
|
||||
*
|
||||
* <p>This buffer will not attempt to return results from the buffer when
|
||||
* accessor methods (such as {@link #getBlock(Vector)}) are called.</p>
|
||||
* accessor methods (such as {@link #getBlock(BlockVector3)}) are called.</p>
|
||||
*/
|
||||
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
|
||||
|
||||
private final Map<BlockVector, BlockStateHolder> buffer = new LinkedHashMap<>();
|
||||
private final Map<BlockVector3, BlockStateHolder> buffer = new LinkedHashMap<>();
|
||||
private final Mask mask;
|
||||
private Vector min = null;
|
||||
private Vector max = null;
|
||||
private BlockVector3 min = null;
|
||||
private BlockVector3 max = null;
|
||||
|
||||
/**
|
||||
* Create a new extent buffer that will buffer every change.
|
||||
*
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(Vector)}, etc. calls
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||
*/
|
||||
public ForgetfulExtentBuffer(Extent delegate) {
|
||||
this(delegate, Masks.alwaysTrue());
|
||||
@ -67,7 +67,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
* Create a new extent buffer that will buffer changes that meet the criteria
|
||||
* of the given mask.
|
||||
*
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(Vector)}, etc. calls
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||
* @param mask the mask
|
||||
*/
|
||||
public ForgetfulExtentBuffer(Extent delegate, Mask mask) {
|
||||
@ -78,22 +78,22 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
// Update minimum
|
||||
if (min == null) {
|
||||
min = location;
|
||||
} else {
|
||||
min = Vector.getMinimum(min, location);
|
||||
min = min.getMinimum(location);
|
||||
}
|
||||
|
||||
// Update maximum
|
||||
if (max == null) {
|
||||
max = location;
|
||||
} else {
|
||||
max = Vector.getMaximum(max, location);
|
||||
max = max.getMaximum(location);
|
||||
}
|
||||
|
||||
BlockVector blockVector = location.toBlockVector();
|
||||
BlockVector3 blockVector = location;
|
||||
if (mask.test(blockVector)) {
|
||||
buffer.put(blockVector, block);
|
||||
return true;
|
||||
@ -103,8 +103,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(Vector pos) {
|
||||
BlockStateHolder block = buffer.get(pos.toBlockVector());
|
||||
public BlockStateHolder apply(BlockVector3 pos) {
|
||||
BlockStateHolder block = buffer.get(pos);
|
||||
if (block != null) {
|
||||
return block;
|
||||
} else {
|
||||
@ -120,32 +120,32 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
public Region asRegion() {
|
||||
return new AbstractRegion(null) {
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return min != null ? min : new Vector();
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return min != null ? min : BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return max != null ? max : new Vector();
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return max != null ? max : BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new UnsupportedOperationException("Cannot change the size of this region");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new UnsupportedOperationException("Cannot change the size of this region");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
return buffer.containsKey(position.toBlockVector());
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return buffer.containsKey(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return buffer.keySet().iterator();
|
||||
}
|
||||
};
|
||||
|
@ -19,15 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.cache;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Returns the same cached {@link BlockState} for repeated calls to
|
||||
* {@link #getBlock(Vector)} with the same position.
|
||||
* {@link #getBlock(BlockVector3)} with the same position.
|
||||
*/
|
||||
public class LastAccessExtentCache extends AbstractDelegateExtent {
|
||||
|
||||
@ -43,23 +43,22 @@ public class LastAccessExtentCache extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
BlockVector blockVector = position.toBlockVector();
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
CachedBlock lastBlock = this.lastBlock;
|
||||
if (lastBlock != null && lastBlock.position.equals(blockVector)) {
|
||||
if (lastBlock != null && lastBlock.position.equals(position)) {
|
||||
return lastBlock.block;
|
||||
} else {
|
||||
BlockState block = super.getBlock(position);
|
||||
this.lastBlock = new CachedBlock(blockVector, block);
|
||||
this.lastBlock = new CachedBlock(position, block);
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
private static class CachedBlock {
|
||||
private final BlockVector position;
|
||||
private final BlockVector3 position;
|
||||
private final BlockState block;
|
||||
|
||||
private CachedBlock(BlockVector position, BlockState block) {
|
||||
private CachedBlock(BlockVector3 position, BlockState block) {
|
||||
this.position = position;
|
||||
this.block = block;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard;
|
||||
import com.boydti.fawe.object.clipboard.FaweClipboard;
|
||||
@ -32,12 +33,24 @@ import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import java.io.Closeable;
|
||||
@ -56,6 +69,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable {
|
||||
|
||||
<<<<<<< HEAD
|
||||
private Region region;
|
||||
public FaweClipboard IMP;
|
||||
private Vector size;
|
||||
@ -75,6 +89,12 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
this.my = origin.getBlockY();
|
||||
this.mz = origin.getBlockZ();
|
||||
}
|
||||
=======
|
||||
private final Region region;
|
||||
private BlockVector3 origin;
|
||||
private final BlockStateHolder[][][] blocks;
|
||||
private final List<ClipboardEntity> entities = new ArrayList<>();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -94,6 +114,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
this.mz = origin.getBlockZ();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public BlockArrayClipboard(Region region, FaweClipboard clipboard) {
|
||||
checkNotNull(region);
|
||||
this.region = region.clone();
|
||||
@ -125,6 +146,10 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
@Override
|
||||
public void close() {
|
||||
IMP.close();
|
||||
=======
|
||||
BlockVector3 dimensions = getDimensions();
|
||||
blocks = new BlockStateHolder[dimensions.getBlockX()][dimensions.getBlockY()][dimensions.getBlockZ()];
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,36 +162,42 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getOrigin() {
|
||||
public BlockVector3 getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrigin(Vector origin) {
|
||||
public void setOrigin(BlockVector3 origin) {
|
||||
this.origin = origin;
|
||||
IMP.setOrigin(origin.subtract(region.getMinimumPoint()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getDimensions() {
|
||||
public BlockVector3 getDimensions() {
|
||||
return region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
<<<<<<< HEAD
|
||||
List<Entity> filtered = new ArrayList<Entity>();
|
||||
for (Entity entity : getEntities()) {
|
||||
if (region.contains(entity.getLocation().toVector())) {
|
||||
=======
|
||||
List<Entity> filtered = new ArrayList<>();
|
||||
for (Entity entity : entities) {
|
||||
if (region.contains(entity.getLocation().toVector().toBlockPoint())) {
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
filtered.add(entity);
|
||||
}
|
||||
}
|
||||
@ -185,12 +216,20 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
if (region.contains(position)) {
|
||||
<<<<<<< HEAD
|
||||
int x = position.getBlockX() - mx;
|
||||
int y = position.getBlockY() - my;
|
||||
int z = position.getBlockZ() - mz;
|
||||
return IMP.getBlock(x, y, z);
|
||||
=======
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
||||
if (block != null) {
|
||||
return block.toImmutableState();
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
return EditSession.nullBlock;
|
||||
}
|
||||
@ -200,9 +239,20 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public BlockState getLazyBlock(Vector position) {
|
||||
return getBlock(position);
|
||||
}
|
||||
=======
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
if (region.contains(position)) {
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()];
|
||||
if (block != null) {
|
||||
return block.toBaseBlock();
|
||||
}
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
@Override
|
||||
public BlockState getFullBlock(Vector position) {
|
||||
@ -210,12 +260,22 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
if (region.contains(location)) {
|
||||
final int x = location.getBlockX();
|
||||
final int y = location.getBlockY();
|
||||
final int z = location.getBlockZ();
|
||||
return setBlock(x, y, z, block);
|
||||
=======
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
if (region.contains(position)) {
|
||||
BlockVector3 v = position.subtract(region.getMinimumPoint());
|
||||
blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = block;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -236,6 +296,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
int x = position.getBlockX() - mx;
|
||||
int z = position.getBlockZ() - mz;
|
||||
@ -248,6 +309,15 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
||||
int z = position.getBlockZ() - mz;
|
||||
IMP.setBiome(x, z, biome.getId());
|
||||
return true;
|
||||
=======
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return new BaseBiome(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return false;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
@ -42,20 +42,20 @@ public interface Clipboard extends Extent {
|
||||
*
|
||||
* @return the dimensions
|
||||
*/
|
||||
Vector getDimensions();
|
||||
BlockVector3 getDimensions();
|
||||
|
||||
/**
|
||||
* Get the origin point from which the copy was made from.
|
||||
*
|
||||
* @return the origin
|
||||
*/
|
||||
Vector getOrigin();
|
||||
BlockVector3 getOrigin();
|
||||
|
||||
/**
|
||||
* Set the origin point from which the copy was made from.
|
||||
*
|
||||
* @param origin the origin
|
||||
*/
|
||||
void setOrigin(Vector origin);
|
||||
void setOrigin(BlockVector3 origin);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,316 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard.io;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.jnbt.ByteArrayTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NamedTag;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.SignCompatibilityHandler;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.storage.NBTConversions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Reads schematic files that are compatible with MCEdit and other editors.
|
||||
*/
|
||||
public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
|
||||
private static final List<NBTCompatibilityHandler> COMPATIBILITY_HANDLERS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
COMPATIBILITY_HANDLERS.add(new SignCompatibilityHandler());
|
||||
// TODO Add a handler for skulls, flower pots, note blocks, etc.
|
||||
}
|
||||
|
||||
private static final Logger log = Logger.getLogger(MCEditSchematicReader.class.getCanonicalName());
|
||||
private final NBTInputStream inputStream;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param inputStream the input stream to read from
|
||||
*/
|
||||
public MCEditSchematicReader(NBTInputStream inputStream) {
|
||||
checkNotNull(inputStream);
|
||||
this.inputStream = inputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clipboard read() throws IOException {
|
||||
// Schematic tag
|
||||
NamedTag rootTag = inputStream.readNamedTag();
|
||||
if (!rootTag.getName().equals("Schematic")) {
|
||||
throw new IOException("Tag 'Schematic' does not exist or is not first");
|
||||
}
|
||||
CompoundTag schematicTag = (CompoundTag) rootTag.getTag();
|
||||
|
||||
// Check
|
||||
Map<String, Tag> schematic = schematicTag.getValue();
|
||||
if (!schematic.containsKey("Blocks")) {
|
||||
throw new IOException("Schematic file is missing a 'Blocks' tag");
|
||||
}
|
||||
|
||||
// Check type of Schematic
|
||||
String materials = requireTag(schematic, "Materials", StringTag.class).getValue();
|
||||
if (!materials.equals("Alpha")) {
|
||||
throw new IOException("Schematic file is not an Alpha schematic");
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// Metadata
|
||||
// ====================================================================
|
||||
|
||||
BlockVector3 origin;
|
||||
Region region;
|
||||
|
||||
// Get information
|
||||
short width = requireTag(schematic, "Width", ShortTag.class).getValue();
|
||||
short height = requireTag(schematic, "Height", ShortTag.class).getValue();
|
||||
short length = requireTag(schematic, "Length", ShortTag.class).getValue();
|
||||
|
||||
try {
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
origin = min.subtract(offset);
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
} catch (IOException ignored) {
|
||||
origin = BlockVector3.ZERO;
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// Blocks
|
||||
// ====================================================================
|
||||
|
||||
// Get blocks
|
||||
byte[] blockId = requireTag(schematic, "Blocks", ByteArrayTag.class).getValue();
|
||||
byte[] blockData = requireTag(schematic, "Data", ByteArrayTag.class).getValue();
|
||||
byte[] addId = new byte[0];
|
||||
short[] blocks = new short[blockId.length]; // Have to later combine IDs
|
||||
|
||||
// We support 4096 block IDs using the same method as vanilla Minecraft, where
|
||||
// the highest 4 bits are stored in a separate byte array.
|
||||
if (schematic.containsKey("AddBlocks")) {
|
||||
addId = requireTag(schematic, "AddBlocks", ByteArrayTag.class).getValue();
|
||||
}
|
||||
|
||||
// Combine the AddBlocks data with the first 8-bit block ID
|
||||
for (int index = 0; index < blockId.length; index++) {
|
||||
if ((index >> 1) >= addId.length) { // No corresponding AddBlocks index
|
||||
blocks[index] = (short) (blockId[index] & 0xFF);
|
||||
} else {
|
||||
if ((index & 1) == 0) {
|
||||
blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (blockId[index] & 0xFF));
|
||||
} else {
|
||||
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (blockId[index] & 0xFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Need to pull out tile entities
|
||||
List<Tag> tileEntities = requireTag(schematic, "TileEntities", ListTag.class).getValue();
|
||||
Map<BlockVector3, Map<String, Tag>> tileEntitiesMap = new HashMap<>();
|
||||
|
||||
for (Tag tag : tileEntities) {
|
||||
if (!(tag instanceof CompoundTag)) continue;
|
||||
CompoundTag t = (CompoundTag) tag;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Tag> entry : t.getValue().entrySet()) {
|
||||
switch (entry.getKey()) {
|
||||
case "x":
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
x = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
case "y":
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
y = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
case "z":
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
z = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
int index = y * width * length + z * width + x;
|
||||
BlockState block = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
|
||||
if (block != null) {
|
||||
for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) {
|
||||
if (handler.isAffectedBlock(block)) {
|
||||
handler.updateNBT(block, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlockVector3 vec = new BlockVector3(x, y, z);
|
||||
tileEntitiesMap.put(vec, values);
|
||||
}
|
||||
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||
clipboard.setOrigin(origin);
|
||||
|
||||
// Don't log a torrent of errors
|
||||
int failedBlockSets = 0;
|
||||
|
||||
for (int x = 0; x < width; ++x) {
|
||||
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);
|
||||
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
|
||||
|
||||
try {
|
||||
if (state != null) {
|
||||
if (tileEntitiesMap.containsKey(pt)) {
|
||||
clipboard.setBlock(region.getMinimumPoint().add(pt), state.toBaseBlock(new CompoundTag(tileEntitiesMap.get(pt))));
|
||||
} else {
|
||||
clipboard.setBlock(region.getMinimumPoint().add(pt), state);
|
||||
}
|
||||
} else {
|
||||
log.warning("Unknown block when pasting schematic: " + blocks[index] + ":" + blockData[index] + ". Please report this issue.");
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
switch (failedBlockSets) {
|
||||
case 0:
|
||||
log.log(Level.WARNING, "Failed to set block on a Clipboard", e);
|
||||
break;
|
||||
case 1:
|
||||
log.log(Level.WARNING, "Failed to set block on a Clipboard (again) -- no more messages will be logged", e);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
failedBlockSets++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// Entities
|
||||
// ====================================================================
|
||||
|
||||
try {
|
||||
List<Tag> entityTags = requireTag(schematic, "Entities", ListTag.class).getValue();
|
||||
|
||||
for (Tag tag : entityTags) {
|
||||
if (tag instanceof CompoundTag) {
|
||||
CompoundTag compound = (CompoundTag) tag;
|
||||
String id = convertEntityId(compound.getString("id"));
|
||||
Location location = NBTConversions.toLocation(clipboard, compound.getListTag("Pos"), compound.getListTag("Rotation"));
|
||||
|
||||
if (!id.isEmpty()) {
|
||||
EntityType entityType = EntityTypes.get(id.toLowerCase());
|
||||
if (entityType != null) {
|
||||
BaseEntity state = new BaseEntity(entityType, compound);
|
||||
clipboard.createEntity(location, state);
|
||||
} else {
|
||||
log.warning("Unknown entity when pasting schematic: " + id.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException ignored) { // No entities? No problem
|
||||
}
|
||||
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
private String convertEntityId(String id) {
|
||||
switch(id) {
|
||||
case "xp_orb":
|
||||
return "experience_orb";
|
||||
case "xp_bottle":
|
||||
return "experience_bottle";
|
||||
case "eye_of_ender_signal":
|
||||
return "eye_of_ender";
|
||||
case "ender_crystal":
|
||||
return "end_crystal";
|
||||
case "fireworks_rocket":
|
||||
return "firework_rocket";
|
||||
case "commandblock_minecart":
|
||||
return "command_block_minecart";
|
||||
case "snowman":
|
||||
return "snow_golem";
|
||||
case "villager_golem":
|
||||
return "iron_golem";
|
||||
case "evocation_fangs":
|
||||
return "evoker_fangs";
|
||||
case "evocation_illager":
|
||||
return "evoker";
|
||||
case "vindication_illager":
|
||||
return "vindicator";
|
||||
case "illusion_illager":
|
||||
return "illusioner";
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
@ -42,8 +42,12 @@ import com.sk89q.jnbt.NamedTag;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -51,6 +55,7 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -103,10 +108,18 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
return read(UUID.randomUUID());
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
@Override
|
||||
public Clipboard read(UUID uuid) throws IOException {
|
||||
return readVersion1(uuid);
|
||||
}
|
||||
=======
|
||||
private Clipboard readVersion1(Map<String, Tag> schematic) throws IOException {
|
||||
BlockVector3 origin;
|
||||
Region region;
|
||||
|
||||
Map<String, Tag> metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
private int width, height, length;
|
||||
private int offsetX, offsetY, offsetZ;
|
||||
@ -121,12 +134,35 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
return fc = new MemoryOptimizedClipboard(size, 1, 1);
|
||||
=======
|
||||
|
||||
BlockVector3 min = new BlockVector3(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 = new BlockVector3(offsetX, offsetY, offsetZ);
|
||||
origin = min.subtract(offset);
|
||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
} else {
|
||||
origin = min;
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
|
||||
}
|
||||
|
||||
int paletteMax = requireTag(schematic, "PaletteMax", IntTag.class).getValue();
|
||||
Map<String, Tag> paletteObject = requireTag(schematic, "Palette", CompoundTag.class).getValue();
|
||||
if (paletteObject.size() != paletteMax) {
|
||||
throw new IOException("Differing given palette size to actual size");
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,6 +188,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
|
||||
@ -161,6 +198,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(new BlockVector3(pos[0], pos[1], pos[2]), tileEntity);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
});
|
||||
streamer.addReader("Schematic.Biomes.#", new NBTStreamer.LazyReader() {
|
||||
@ -207,6 +261,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
Fawe.debug("Invalid entity: " + id);
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
});
|
||||
streamer.readFully();
|
||||
if (fc == null) setupClipboard(length * width * height, uuid);
|
||||
@ -225,6 +280,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 = new BlockVector3(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);
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
} else {
|
||||
for (int index = 0; index < volume; index++) {
|
||||
|
@ -27,15 +27,23 @@ import com.sk89q.jnbt.NBTConstants;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
=======
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -75,9 +83,15 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
public void write1(Clipboard clipboard) throws IOException {
|
||||
// metadata
|
||||
Region region = clipboard.getRegion();
|
||||
<<<<<<< HEAD
|
||||
Vector origin = clipboard.getOrigin();
|
||||
BlockVector min = region.getMinimumPoint().toBlockVector();
|
||||
Vector offset = min.subtract(origin);
|
||||
=======
|
||||
BlockVector3 origin = clipboard.getOrigin();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 offset = min.subtract(origin);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
int width = region.getWidth();
|
||||
int height = region.getHeight();
|
||||
int length = region.getLength();
|
||||
@ -90,6 +104,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
if (length > MAX_SIZE) {
|
||||
throw new IllegalArgumentException("Length of region too large for a .schematic");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
// output
|
||||
final DataOutput rawStream = outputStream.getOutputStream();
|
||||
outputStream.writeLazyCompoundTag("Schematic", out -> {
|
||||
@ -142,6 +157,49 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
}));
|
||||
numTiles[0]++;
|
||||
tilesOut.writeTagPayload(tile);
|
||||
=======
|
||||
|
||||
Map<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Version", new IntTag(1));
|
||||
|
||||
Map<String, Tag> metadata = new HashMap<>();
|
||||
metadata.put("WEOffsetX", new IntTag(offset.getBlockX()));
|
||||
metadata.put("WEOffsetY", new IntTag(offset.getBlockY()));
|
||||
metadata.put("WEOffsetZ", new IntTag(offset.getBlockZ()));
|
||||
|
||||
schematic.put("Metadata", new CompoundTag(metadata));
|
||||
|
||||
schematic.put("Width", new ShortTag((short) width));
|
||||
schematic.put("Height", new ShortTag((short) height));
|
||||
schematic.put("Length", new ShortTag((short) length));
|
||||
|
||||
// The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin'
|
||||
schematic.put("Offset", new IntArrayTag(new int[]{
|
||||
min.getBlockX(),
|
||||
min.getBlockY(),
|
||||
min.getBlockZ(),
|
||||
}));
|
||||
|
||||
int paletteMax = 0;
|
||||
Map<String, Integer> palette = new HashMap<>();
|
||||
|
||||
List<CompoundTag> tileEntities = new ArrayList<>();
|
||||
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length);
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
int y0 = min.getBlockY() + y;
|
||||
for (int z = 0; z < length; z++) {
|
||||
int z0 = min.getBlockZ() + z;
|
||||
for (int x = 0; x < width; x++) {
|
||||
int x0 = min.getBlockX() + x;
|
||||
BlockVector3 point = new BlockVector3(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
|
||||
}
|
||||
int ordinal = block.getOrdinal();
|
||||
char value = palette[ordinal];
|
||||
|
@ -1,10 +1,18 @@
|
||||
package com.sk89q.worldedit.extent.inventory;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
=======
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -82,9 +90,15 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean setBlock(Vector pos, BlockStateHolder block) throws WorldEditException {
|
||||
return setBlock(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), block);
|
||||
}
|
||||
=======
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
if (blockBag != null) {
|
||||
BlockState existing = getExtent().getBlock(position);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.extent.reorder;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.collection.LocatedBlockList;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* A special extent that batches changes into Minecraft chunks. This helps
|
||||
* improve the speed of setting the blocks, since chunks do not need to be
|
||||
* loaded repeatedly, however it does take more memory due to caching the
|
||||
* blocks.
|
||||
*/
|
||||
public class ChunkBatchingExtent extends AbstractDelegateExtent {
|
||||
|
||||
/**
|
||||
* Comparator optimized for sorting chunks by the region file they reside
|
||||
* in. This allows for file caches to be used while loading the chunk.
|
||||
*/
|
||||
private static final Comparator<BlockVector2> REGION_OPTIMIZED_SORT =
|
||||
Comparator.comparing((BlockVector2 vec) -> vec.divide(32), BlockVector2.COMPARING_GRID_ARRANGEMENT)
|
||||
.thenComparing(BlockVector2.COMPARING_GRID_ARRANGEMENT);
|
||||
|
||||
private final SortedMap<BlockVector2, LocatedBlockList> batches = new TreeMap<>(REGION_OPTIMIZED_SORT);
|
||||
private boolean enabled;
|
||||
|
||||
public ChunkBatchingExtent(Extent extent) {
|
||||
this(extent, true);
|
||||
}
|
||||
|
||||
public ChunkBatchingExtent(Extent extent, boolean enabled) {
|
||||
super(extent);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (!enabled) {
|
||||
return getExtent().setBlock(location, block);
|
||||
}
|
||||
BlockVector2 chunkPos = new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
batches.computeIfAbsent(chunkPos, k -> new LocatedBlockList()).add(location, block);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Operation commitBefore() {
|
||||
if (!enabled) {
|
||||
return null;
|
||||
}
|
||||
return new Operation() {
|
||||
|
||||
// we get modified between create/resume -- only create this on resume to prevent CME
|
||||
private Iterator<LocatedBlockList> batchIterator;
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
if (batchIterator == null) {
|
||||
batchIterator = batches.values().iterator();
|
||||
}
|
||||
if (!batchIterator.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
new SetLocatedBlocks(getExtent(), batchIterator.next()).resume(run);
|
||||
batchIterator.remove();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -19,9 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.reorder;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import com.google.common.collect.Iterables;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.Blocks;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
@ -30,6 +34,11 @@ import com.sk89q.worldedit.function.operation.BlockMapEntryPlacer;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.function.operation.SetLocatedBlocks;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.collection.TupleArrayList;
|
||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||
@ -94,8 +103,13 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
BlockStateHolder existing = getBlock(location);
|
||||
=======
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
BlockState existing = getBlock(location);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
if (!enabled) {
|
||||
return super.setBlock(location, block);
|
||||
@ -103,18 +117,30 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
|
||||
if (Blocks.shouldPlaceLast(block.getBlockType())) {
|
||||
// Place torches, etc. last
|
||||
<<<<<<< HEAD
|
||||
stage2.put(location.toBlockVector(), block);
|
||||
return !existing.equalsFuzzy(block);
|
||||
} else if (Blocks.shouldPlaceFinal(block.getBlockType())) {
|
||||
// Place signs, reed, etc even later
|
||||
stage3.put(location.toBlockVector(), block);
|
||||
=======
|
||||
stage2.add(location, block);
|
||||
return !existing.equalsFuzzy(block);
|
||||
} else if (Blocks.shouldPlaceFinal(block.getBlockType())) {
|
||||
// Place signs, reed, etc even later
|
||||
stage3.add(location, block);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return !existing.equalsFuzzy(block);
|
||||
} else if (Blocks.shouldPlaceLast(existing.getBlockType())) {
|
||||
// Destroy torches, etc. first
|
||||
super.setBlock(location, BlockTypes.AIR.getDefaultState());
|
||||
return super.setBlock(location, block);
|
||||
} else {
|
||||
<<<<<<< HEAD
|
||||
stage1.put(location.toBlockVector(), block);
|
||||
=======
|
||||
stage1.add(location, block);
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return !existing.equalsFuzzy(block);
|
||||
}
|
||||
}
|
||||
@ -134,21 +160,28 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
Extent extent = getExtent();
|
||||
|
||||
<<<<<<< HEAD
|
||||
final Set<BlockVector> blocks = new HashSet<>();
|
||||
final Map<BlockVector, BlockStateHolder> blockTypes = new HashMap<>();
|
||||
for (Map.Entry<BlockVector, BlockStateHolder> entry : stage3) {
|
||||
final BlockVector pt = entry.getKey();
|
||||
=======
|
||||
final Set<BlockVector3> blocks = new HashSet<>();
|
||||
final Map<BlockVector3, BlockStateHolder> blockTypes = new HashMap<>();
|
||||
for (LocatedBlock entry : stage3) {
|
||||
final BlockVector3 pt = entry.getLocation();
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
blocks.add(pt);
|
||||
blockTypes.put(pt, entry.getValue());
|
||||
}
|
||||
|
||||
while (!blocks.isEmpty()) {
|
||||
BlockVector current = blocks.iterator().next();
|
||||
BlockVector3 current = blocks.iterator().next();
|
||||
if (!blocks.contains(current)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Deque<BlockVector> walked = new LinkedList<>();
|
||||
final Deque<BlockVector3> walked = new LinkedList<>();
|
||||
|
||||
while (true) {
|
||||
walked.addFirst(current);
|
||||
@ -161,13 +194,13 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
Property<Object> halfProperty = blockStateHolder.getBlockType().getProperty("half");
|
||||
if (blockStateHolder.getState(halfProperty).equals("lower")) {
|
||||
// Deal with lower door halves being attached to the floor AND the upper half
|
||||
BlockVector upperBlock = current.add(0, 1, 0).toBlockVector();
|
||||
BlockVector3 upperBlock = current.add(0, 1, 0);
|
||||
if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) {
|
||||
walked.addFirst(upperBlock);
|
||||
}
|
||||
}
|
||||
} else if (BlockCategories.RAILS.contains(blockStateHolder.getBlockType())) {
|
||||
BlockVector lowerBlock = current.add(0, -1, 0).toBlockVector();
|
||||
BlockVector3 lowerBlock = current.add(0, -1, 0);
|
||||
if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) {
|
||||
walked.addFirst(lowerBlock);
|
||||
}
|
||||
@ -191,7 +224,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockVector pt : walked) {
|
||||
for (BlockVector3 pt : walked) {
|
||||
extent.setBlock(pt, blockTypes.get(pt));
|
||||
blocks.remove(pt);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.sk89q.worldedit.extent.transform;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
@ -14,9 +15,25 @@ import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
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.math.transform.Transform;
|
||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
=======
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -60,11 +77,70 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
|
||||
case ROTATION:
|
||||
|
||||
<<<<<<< HEAD
|
||||
case AXIS:
|
||||
|
||||
case FACING:
|
||||
|
||||
case SHAPE:
|
||||
=======
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return transformBlock(super.getBlock(position), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return transformBlock(super.getFullBlock(position), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
return super.setBlock(location, transformBlock(block, true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transform the given block using the given transform.
|
||||
*
|
||||
* <p>The provided block is modified.</p>
|
||||
*
|
||||
* @param block the block
|
||||
* @param transform the transform
|
||||
* @return the same block
|
||||
*/
|
||||
public static <T extends BlockStateHolder> T transform(T block, Transform transform) {
|
||||
return transform(block, transform, block);
|
||||
}
|
||||
|
||||
private static final Set<String> directionNames = Sets.newHashSet("north", "south", "east", "west");
|
||||
|
||||
/**
|
||||
* Transform the given block using the given transform.
|
||||
*
|
||||
* @param block the block
|
||||
* @param transform the transform
|
||||
* @param changedBlock the block to change
|
||||
* @return the changed block
|
||||
*/
|
||||
private static <T extends BlockStateHolder> T transform(T block, Transform transform, T changedBlock) {
|
||||
checkNotNull(block);
|
||||
checkNotNull(transform);
|
||||
|
||||
List<? extends Property> properties = block.getBlockType().getProperties();
|
||||
|
||||
for (Property property : properties) {
|
||||
if (property instanceof DirectionalProperty) {
|
||||
Direction value = (Direction) block.getState(property);
|
||||
if (value != null) {
|
||||
Vector3 newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector());
|
||||
if (newValue != null) {
|
||||
changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
case NORTH:
|
||||
case EAST:
|
||||
@ -76,12 +152,19 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
<<<<<<< HEAD
|
||||
private static Integer getNewStateIndex(Transform transform, List<Direction> directions, int oldIndex) {
|
||||
Direction oldDirection = directions.get(oldIndex);
|
||||
Vector oldVector = oldDirection.toVector();
|
||||
Vector newVector = transform.apply(oldVector).subtract(transform.apply(Vector.ZERO)).normalize();
|
||||
int newIndex = oldIndex;
|
||||
double closest = oldVector.toVector().normalize().dot(newVector);
|
||||
=======
|
||||
private static Vector3 getNewStateValue(DirectionalProperty state, Transform transform, Vector3 oldDirection) {
|
||||
Vector3 newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
Vector3 newValue = null;
|
||||
double closest = -2;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
boolean found = false;
|
||||
|
||||
for (int i = 0; i < directions.size(); i++) {
|
||||
|
@ -20,14 +20,18 @@
|
||||
package com.sk89q.worldedit.extent.validation;
|
||||
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
<<<<<<< HEAD
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
=======
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
/**
|
||||
* Limits the number of blocks that can be changed before a
|
||||
@ -78,7 +82,7 @@ public class BlockChangeLimiter extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (limit >= 0) {
|
||||
if (count >= limit) {
|
||||
throw new MaxChangedBlocksException(limit);
|
||||
|
@ -19,13 +19,19 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.validation;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -50,7 +56,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
final int y = location.getBlockY();
|
||||
final BlockType type = block.getBlockType();
|
||||
if (y < 0 || y > world.getMaxY()) {
|
||||
|
@ -21,8 +21,14 @@ package com.sk89q.worldedit.extent.world;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -52,7 +58,7 @@ public class BlockQuirkExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
||||
BlockType existing = getExtent().getBlock(position).getBlockType();
|
||||
|
||||
if (existing.getMaterial().hasContainer()) {
|
||||
|
@ -19,12 +19,18 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.world;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -62,7 +68,7 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
world.checkLoadedChunk(location);
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
|
@ -19,14 +19,21 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.world;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -41,7 +48,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class FastModeExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final World world;
|
||||
private final Set<BlockVector2D> dirtyChunks = new HashSet<>();
|
||||
private final Set<BlockVector2> dirtyChunks = new HashSet<>();
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
@ -85,9 +92,9 @@ public class FastModeExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (enabled) {
|
||||
dirtyChunks.add(new BlockVector2D(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||
dirtyChunks.add(new BlockVector2(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||
return world.setBlock(location, block, false);
|
||||
} else {
|
||||
return world.setBlock(location, block, true);
|
||||
|
@ -19,11 +19,17 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.world;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
=======
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -80,7 +86,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BlockStateHolder block) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
||||
if (toolUse && block.getBlockType().getMaterial().isAir()) {
|
||||
world.simulateBlockMine(location);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user