mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 08:28:35 +00:00
Add and apply .editorconfig from P2 (#1195)
* Consistenty use javax annotations. - Unfortunately jetbrains annotations seem to be exposed transitively via core somewhere, but with the correct IDE settings, annotations can be defaulted to javax - Cleaning up of import order in #1195 - Must be merged before #1195 * Add and apply .editorconfig from P2 - Does not rearrange entries * Address some comments * add back some javadoc comments * Address final comments Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
@ -27,8 +27,8 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Base extent class for buffering changes between {@link #setBlock(BlockVector3, BlockStateHolder)}
|
||||
@ -36,6 +36,7 @@ import javax.annotation.Nullable;
|
||||
* handled, by returning buffered blocks.
|
||||
*/
|
||||
public abstract class AbstractBufferingExtent extends AbstractDelegateExtent {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
@ -48,7 +49,8 @@ public abstract class AbstractBufferingExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public abstract <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException;
|
||||
|
||||
protected final <T extends BlockStateHolder<T>> boolean setDelegateBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||
protected final <T extends BlockStateHolder<T>> boolean setDelegateBlock(BlockVector3 location, T block) throws
|
||||
WorldEditException {
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
|
||||
@ -74,7 +76,7 @@ public abstract class AbstractBufferingExtent extends AbstractDelegateExtent {
|
||||
* Gets a block from the buffer.
|
||||
*
|
||||
* @deprecated New subclasses should override {@link #getBufferedFullBlock(BlockVector3)}
|
||||
* instead
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
protected Optional<BaseBlock> getBufferedBlock(BlockVector3 position) {
|
||||
@ -86,12 +88,10 @@ public abstract class AbstractBufferingExtent extends AbstractDelegateExtent {
|
||||
*
|
||||
* @param position The position
|
||||
* @return The buffered block, or null
|
||||
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
|
||||
* for details
|
||||
*/
|
||||
@NonAbstractForCompatibility(
|
||||
delegateName = "getBufferedBlock",
|
||||
delegateParams = { BlockVector3.class }
|
||||
delegateName = "getBufferedBlock",
|
||||
delegateParams = {BlockVector3.class}
|
||||
)
|
||||
@Nullable
|
||||
protected BaseBlock getBufferedFullBlock(BlockVector3 position) {
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.extent.HistoryExtent;
|
||||
import com.fastasyncworldedit.core.history.changeset.AbstractChangeSet;
|
||||
import com.fastasyncworldedit.core.internal.exception.FaweException;
|
||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -43,9 +43,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.apache.logging.log4j.LogManager.getLogger;
|
||||
@ -155,10 +155,8 @@ public class AbstractDelegateExtent implements Extent {
|
||||
return new OperationQueue(ours, other);
|
||||
} else if (ours != null) {
|
||||
return ours;
|
||||
} else if (other != null) {
|
||||
return other;
|
||||
} else {
|
||||
return null;
|
||||
return other;
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,8 +316,10 @@ public class AbstractDelegateExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, @Range(from = 0, to = 255) int y,
|
||||
int z, T block) throws WorldEditException {
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(
|
||||
int x, @Range(from = 0, to = 255) int y,
|
||||
int z, T block
|
||||
) throws WorldEditException {
|
||||
return extent.setBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,9 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -50,7 +50,7 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param extent the extent
|
||||
* @param changeSet the change set
|
||||
*/
|
||||
public ChangeSetExtent(Extent extent, ChangeSet changeSet) {
|
||||
@ -102,6 +102,7 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
private class TrackedEntity implements Entity {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
private TrackedEntity(Entity entity) {
|
||||
@ -145,5 +146,7 @@ public class ChangeSetExtent extends AbstractDelegateExtent {
|
||||
public <T> T getFacet(Class<? extends T> cls) {
|
||||
return entity.getFacet(cls);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,15 +20,22 @@
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.queue.Filter;
|
||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.extent.NullExtent;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.WorldCopyClipboard;
|
||||
import com.fastasyncworldedit.core.extent.filter.block.ExtentFilterBlock;
|
||||
import com.fastasyncworldedit.core.extent.processor.ProcessorScope;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.function.generator.CavesGen;
|
||||
import com.fastasyncworldedit.core.function.generator.GenBase;
|
||||
import com.fastasyncworldedit.core.function.generator.OreGen;
|
||||
import com.fastasyncworldedit.core.function.generator.Resource;
|
||||
import com.fastasyncworldedit.core.function.generator.SchemGen;
|
||||
import com.fastasyncworldedit.core.history.changeset.AbstractChangeSet;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.WorldCopyClipboard;
|
||||
import com.fastasyncworldedit.core.internal.exception.FaweException;
|
||||
import com.fastasyncworldedit.core.extent.NullExtent;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.fastasyncworldedit.core.queue.Filter;
|
||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.registry.state.PropertyGroup;
|
||||
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -37,11 +44,6 @@ import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
||||
import com.sk89q.worldedit.function.block.BlockReplace;
|
||||
import com.fastasyncworldedit.core.function.generator.CavesGen;
|
||||
import com.fastasyncworldedit.core.function.generator.GenBase;
|
||||
import com.fastasyncworldedit.core.function.generator.OreGen;
|
||||
import com.fastasyncworldedit.core.function.generator.Resource;
|
||||
import com.fastasyncworldedit.core.function.generator.SchemGen;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
@ -53,11 +55,9 @@ import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.fastasyncworldedit.core.registry.state.PropertyGroup;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
@ -69,13 +69,13 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -138,7 +138,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
/**
|
||||
* Create an entity at the given location.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @param entity the entity
|
||||
* @param location the location
|
||||
* @return a reference to the created entity, or null if the entity could not be created
|
||||
*/
|
||||
@ -148,15 +148,17 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Create an entity at the given location.
|
||||
*
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z coordinate
|
||||
* @param uuid the unique identifier of the entity
|
||||
*/
|
||||
default void removeEntity(int x, int y, int z, UUID uuid) {}
|
||||
default void removeEntity(int x, int y, int z, UUID uuid) {
|
||||
}
|
||||
|
||||
/*
|
||||
Queue based methods
|
||||
@ -314,7 +316,16 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
return state ? failedMin : failedMax;
|
||||
}
|
||||
|
||||
default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
|
||||
default int getNearestSurfaceTerrainBlock(
|
||||
int x,
|
||||
int z,
|
||||
int y,
|
||||
int minY,
|
||||
int maxY,
|
||||
int failedMin,
|
||||
int failedMax,
|
||||
boolean ignoreAir
|
||||
) {
|
||||
y = Math.max(minY, Math.min(maxY, y));
|
||||
int clearanceAbove = maxY - y;
|
||||
int clearanceBelow = y - minY;
|
||||
@ -369,7 +380,8 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
}
|
||||
|
||||
default void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
||||
default void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws
|
||||
WorldEditException {
|
||||
spawnResource(region, new SchemGen(mask, this, clipboards, rotate), rarity, 1);
|
||||
}
|
||||
|
||||
@ -393,7 +405,16 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
return pt.containedWithin(min, max);
|
||||
}
|
||||
|
||||
default void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
||||
default void addOre(
|
||||
Region region,
|
||||
Mask mask,
|
||||
Pattern material,
|
||||
int size,
|
||||
int frequency,
|
||||
int rarity,
|
||||
int minY,
|
||||
int maxY
|
||||
) throws WorldEditException {
|
||||
spawnResource(region, new OreGen(this, mask, material, size, minY, maxY), rarity, frequency);
|
||||
}
|
||||
|
||||
@ -532,7 +553,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
/**
|
||||
* Count the number of blocks of a list of types in a region.
|
||||
*
|
||||
* @param region the region
|
||||
* @param region the region
|
||||
* @param searchBlocks the list of blocks to search
|
||||
* @return the number of blocks that matched the block
|
||||
*/
|
||||
@ -544,7 +565,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
/**
|
||||
* Count the number of blocks of a list of types in a region.
|
||||
*
|
||||
* @param region the region
|
||||
* @param region the region
|
||||
* @param searchMask mask to match
|
||||
* @return the number of blocks that matched the mask
|
||||
*/
|
||||
@ -560,11 +581,11 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
* Sets all the blocks inside a region to a given block type.
|
||||
*
|
||||
* @param region the region
|
||||
* @param block the block
|
||||
* @param block the block
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
default <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||
default <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(block);
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
@ -581,7 +602,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
/**
|
||||
* Sets all the blocks inside a region to a given pattern.
|
||||
*
|
||||
* @param region the region
|
||||
* @param region the region
|
||||
* @param pattern the pattern that provides the replacement block
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
@ -608,13 +629,14 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
* Replaces all the blocks matching a given filter, within a given region, to a block
|
||||
* returned by a given pattern.
|
||||
*
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param replacement the replacement block
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
default <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
|
||||
default <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws
|
||||
MaxChangedBlocksException {
|
||||
return replaceBlocks(region, filter, (Pattern) replacement);
|
||||
}
|
||||
|
||||
@ -622,8 +644,8 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
* Replaces all the blocks matching a given filter, within a given region, to a block
|
||||
* returned by a given pattern.
|
||||
*
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param pattern the pattern that provides the new blocks
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
@ -637,8 +659,8 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
* Replaces all the blocks matching a given mask, within a given region, to a block
|
||||
* returned by a given pattern.
|
||||
*
|
||||
* @param region the region to replace the blocks within
|
||||
* @param mask the mask that blocks must match
|
||||
* @param region the region to replace the blocks within
|
||||
* @param mask the mask that blocks must match
|
||||
* @param pattern the pattern that provides the new blocks
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
@ -663,7 +685,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
* If the center sits between two blocks on a certain axis, then two blocks
|
||||
* will be placed to mark the center.
|
||||
*
|
||||
* @param region the region to find the center of
|
||||
* @param region the region to find the center of
|
||||
* @param pattern the replacement pattern
|
||||
* @return the number of blocks placed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
@ -677,7 +699,9 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
this instanceof World ? (World) this : null, // Causes clamping of Y range
|
||||
BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
|
||||
BlockVector3.at(MathUtils.roundHalfUp(center.getX()),
|
||||
center.getY(), MathUtils.roundHalfUp(center.getZ())));
|
||||
center.getY(), MathUtils.roundHalfUp(center.getZ())
|
||||
)
|
||||
);
|
||||
return setBlocks(centerRegion, pattern);
|
||||
}
|
||||
|
||||
@ -708,7 +732,8 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
|
||||
/**
|
||||
* Have an extent processed
|
||||
* - Either block (Extent) processing or chunk processing
|
||||
* - Either block (Extent) processing or chunk processing
|
||||
*
|
||||
* @param processor
|
||||
* @return processed Extent
|
||||
*/
|
||||
@ -736,7 +761,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
|
||||
default <T extends Filter> T apply(Region region, T filter, boolean full) {
|
||||
return apply((Iterable<BlockVector3>) region, filter);
|
||||
return apply(region, filter);
|
||||
}
|
||||
|
||||
default <T extends Filter> T apply(Iterable<BlockVector3> positions, T filter) {
|
||||
|
@ -20,12 +20,12 @@
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.processor.heightmap.HeightMapType;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.util.DeprecationUtil;
|
||||
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -83,7 +83,8 @@ public interface InputExtent {
|
||||
* @return the biome at the location
|
||||
* @deprecated Biomes in Minecraft are 3D now, use {@link InputExtent#getBiome(BlockVector3)}
|
||||
*/
|
||||
@Deprecated default BiomeType getBiome(BlockVector2 position) {
|
||||
@Deprecated
|
||||
default BiomeType getBiome(BlockVector2 position) {
|
||||
return getBiomeType(position.getX(), 0, position.getZ());
|
||||
}
|
||||
|
||||
@ -107,16 +108,17 @@ public interface InputExtent {
|
||||
*
|
||||
* @param position the (x, y, z) location to check the biome at
|
||||
* @return the biome at the location
|
||||
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
|
||||
* for details
|
||||
* @see NonAbstractForCompatibility This must be overridden by new subclasses.
|
||||
*/
|
||||
@NonAbstractForCompatibility(delegateName = "getBiome", delegateParams = {BlockVector2.class}) default BiomeType getBiome(BlockVector3 position) {
|
||||
@NonAbstractForCompatibility(delegateName = "getBiome", delegateParams = {BlockVector2.class})
|
||||
default BiomeType getBiome(BlockVector3 position) {
|
||||
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||
|
||||
return getBiome(position.toBlockVector2());
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Get the light level at the given location.
|
||||
*
|
||||
|
@ -20,15 +20,15 @@
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.extent.filter.block.CharFilterBlock;
|
||||
import com.fastasyncworldedit.core.extent.filter.block.ChunkFilterBlock;
|
||||
import com.fastasyncworldedit.core.extent.filter.block.FilterBlock;
|
||||
import com.fastasyncworldedit.core.extent.processor.ProcessorScope;
|
||||
import com.fastasyncworldedit.core.queue.Filter;
|
||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.queue.IChunk;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
import com.fastasyncworldedit.core.queue.IChunkSet;
|
||||
import com.fastasyncworldedit.core.extent.filter.block.CharFilterBlock;
|
||||
import com.fastasyncworldedit.core.extent.filter.block.ChunkFilterBlock;
|
||||
import com.fastasyncworldedit.core.extent.filter.block.FilterBlock;
|
||||
import com.fastasyncworldedit.core.extent.processor.ProcessorScope;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
@ -55,7 +55,7 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param mask the mask
|
||||
* @param mask the mask
|
||||
*/
|
||||
public MaskingExtent(Extent extent, Mask mask) {
|
||||
super(extent);
|
||||
|
@ -34,15 +34,16 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An extent that returns air blocks for all blocks and does not
|
||||
* pass on any changes.
|
||||
*/
|
||||
public class NullExtent implements Extent {
|
||||
|
||||
public static final NullExtent INSTANCE = new NullExtent();
|
||||
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.extent;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.processor.heightmap.HeightMapType;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
@ -27,7 +28,6 @@ import com.sk89q.worldedit.internal.util.DeprecationUtil;
|
||||
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -51,7 +51,7 @@ public interface OutputExtent {
|
||||
* example, the approximate number of changes.</p>
|
||||
*
|
||||
* @param position position of the block
|
||||
* @param block block to set
|
||||
* @param block block to set
|
||||
* @return true if the block was successfully set (return value may not be accurate)
|
||||
* @throws WorldEditException thrown on an error
|
||||
* @deprecated It is recommended that you use {@link #setBlock(int, int, int, BlockStateHolder)} in FAWE
|
||||
@ -88,22 +88,22 @@ public interface OutputExtent {
|
||||
* Set the biome.
|
||||
*
|
||||
* @param position the (x, z) location to set the biome at
|
||||
* @param biome the biome to set to
|
||||
* @param biome the biome to set to
|
||||
* @return true if the biome was successfully set (return value may not be accurate)
|
||||
* @deprecated Biomes in Minecraft are 3D now, use {@link OutputExtent#setBiome(BlockVector3, BiomeType)}
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
boolean result = false;
|
||||
for (int y = 0; y < 256; y ++) {
|
||||
for (int y = 0; y < 256; y++) {
|
||||
result |= setBiome(position.toBlockVector3().mutY(y), biome);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NonAbstractForCompatibility(
|
||||
delegateName = "setBiome",
|
||||
delegateParams = { int.class, int.class, int.class, BiomeType.class }
|
||||
delegateName = "setBiome",
|
||||
delegateParams = {int.class, int.class, int.class, BiomeType.class}
|
||||
)
|
||||
// The defaults need to remain for compatibility (the actual implementation still needs to override one of these)
|
||||
default boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
@ -113,24 +113,23 @@ public interface OutputExtent {
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Set the biome.
|
||||
*
|
||||
* <p>
|
||||
* As implementation varies per Minecraft version, this may set more than
|
||||
* this position's biome. On versions prior to 1.15, this will set the entire
|
||||
* column. On later versions it will set the 4x4x4 cube.
|
||||
* As implementation varies per Minecraft version, this may set more than
|
||||
* this position's biome. On versions prior to 1.15, this will set the entire
|
||||
* column. On later versions it will set the 4x4x4 cube.
|
||||
* </p>
|
||||
*
|
||||
* @param position the (x, y, z) location to set the biome at
|
||||
* @param biome the biome to set to
|
||||
* @param biome the biome to set to
|
||||
* @return true if the biome was successfully set (return value may not be accurate)
|
||||
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
|
||||
* for details
|
||||
*/
|
||||
@NonAbstractForCompatibility(
|
||||
delegateName = "setBiome",
|
||||
delegateParams = { BlockVector3.class, BiomeType.class }
|
||||
delegateName = "setBiome",
|
||||
delegateParams = {BlockVector3.class, BiomeType.class}
|
||||
)
|
||||
default boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
DeprecationUtil.checkDelegatingOverride(getClass());
|
||||
@ -142,7 +141,7 @@ public interface OutputExtent {
|
||||
* Set the light value.
|
||||
*
|
||||
* @param position position of the block
|
||||
* @param value light level to set
|
||||
* @param value light level to set
|
||||
*/
|
||||
default void setBlockLight(BlockVector3 position, int value) {
|
||||
setBlockLight(position.getX(), position.getY(), position.getZ(), value);
|
||||
@ -155,7 +154,7 @@ public interface OutputExtent {
|
||||
* Set the sky light value.
|
||||
*
|
||||
* @param position position of the block
|
||||
* @param value light level to set
|
||||
* @param value light level to set
|
||||
*/
|
||||
default void setSkyLight(BlockVector3 position, int value) {
|
||||
setSkyLight(position.getX(), position.getY(), position.getZ(), value);
|
||||
@ -174,5 +173,7 @@ public interface OutputExtent {
|
||||
*
|
||||
* @return an operation or null if there is none to execute
|
||||
*/
|
||||
@Nullable Operation commit();
|
||||
@Nullable
|
||||
Operation commit();
|
||||
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ import com.sk89q.worldedit.util.collection.BlockMap;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An extent that can report back if an operation fails due to the extent(s) below it.
|
||||
@ -110,4 +110,5 @@ public class TracingExtent extends AbstractDelegateExtent {
|
||||
public String toString() {
|
||||
return "TracingExtent{delegate=" + getExtent() + "}";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class ExtentBuffer extends AbstractBufferingExtent {
|
||||
* of the given mask.
|
||||
*
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||
* @param mask the mask
|
||||
* @param mask the mask
|
||||
*/
|
||||
public ExtentBuffer(Extent delegate, Mask mask) {
|
||||
super(delegate);
|
||||
@ -81,4 +81,5 @@ public class ExtentBuffer extends AbstractBufferingExtent {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
* of the given mask.
|
||||
*
|
||||
* @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls
|
||||
* @param mask the mask
|
||||
* @param mask the mask
|
||||
*/
|
||||
public ForgetfulExtentBuffer(Extent delegate, Mask mask) {
|
||||
super(delegate);
|
||||
@ -233,4 +233,5 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ public class LastAccessExtentCache extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
private static class CachedBlock<B extends BlockStateHolder<B>> {
|
||||
|
||||
private final BlockVector3 position;
|
||||
private final B block;
|
||||
|
||||
@ -92,6 +93,7 @@ public class LastAccessExtentCache extends AbstractDelegateExtent {
|
||||
this.position = position;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,17 +19,17 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
import com.fastasyncworldedit.core.function.visitor.Order;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector2;
|
||||
import com.fastasyncworldedit.core.math.OffsetBlockVector3;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.fastasyncworldedit.core.function.visitor.Order;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector2;
|
||||
import com.fastasyncworldedit.core.math.OffsetBlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
@ -37,13 +37,13 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -210,10 +210,11 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
ClipboardEntity ce = (ClipboardEntity) e;
|
||||
Location oldloc = ce.getLocation();
|
||||
Location loc = new Location(oldloc.getExtent(),
|
||||
oldloc.getX() + origin.getBlockX(),
|
||||
oldloc.getY() + origin.getBlockY(),
|
||||
oldloc.getZ() + origin.getBlockZ(),
|
||||
oldloc.getYaw(), oldloc.getPitch());
|
||||
oldloc.getX() + origin.getBlockX(),
|
||||
oldloc.getY() + origin.getBlockY(),
|
||||
oldloc.getZ() + origin.getBlockZ(),
|
||||
oldloc.getYaw(), oldloc.getPitch()
|
||||
);
|
||||
return new ClipboardEntity(loc, ce.entity);
|
||||
}
|
||||
return e;
|
||||
@ -228,10 +229,11 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
ClipboardEntity ce = (ClipboardEntity) e;
|
||||
Location oldloc = ce.getLocation();
|
||||
Location loc = new Location(oldloc.getExtent(),
|
||||
oldloc.getX() + origin.getBlockX(),
|
||||
oldloc.getY() + origin.getBlockY(),
|
||||
oldloc.getZ() + origin.getBlockZ(),
|
||||
oldloc.getYaw(), oldloc.getPitch());
|
||||
oldloc.getX() + origin.getBlockX(),
|
||||
oldloc.getY() + origin.getBlockY(),
|
||||
oldloc.getZ() + origin.getBlockZ(),
|
||||
oldloc.getYaw(), oldloc.getPitch()
|
||||
);
|
||||
return new ClipboardEntity(loc, ce.entity);
|
||||
}
|
||||
return e;
|
||||
@ -242,10 +244,11 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
@Nullable
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
Location l = new Location(location.getExtent(),
|
||||
location.getX() - origin.getBlockX(),
|
||||
location.getY() - origin.getBlockY(),
|
||||
location.getZ() - origin.getBlockZ(),
|
||||
location.getYaw(), location.getPitch());
|
||||
location.getX() - origin.getBlockX(),
|
||||
location.getY() - origin.getBlockY(),
|
||||
location.getZ() - origin.getBlockZ(),
|
||||
location.getYaw(), location.getPitch()
|
||||
);
|
||||
return getParent().createEntity(l, entity);
|
||||
}
|
||||
|
||||
@ -291,7 +294,7 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
public Iterator<BlockVector2> iterator2d() {
|
||||
MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
return Iterators.transform(getParent().iterator2d(), input ->
|
||||
mutable.setComponents(input.getX() + origin.getX(), input.getZ() + origin.getZ()));
|
||||
mutable.setComponents(input.getX() + origin.getX(), input.getZ() + origin.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -321,10 +324,12 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Stores entity data.
|
||||
*/
|
||||
public static class ClipboardEntity implements Entity {
|
||||
|
||||
private final BaseEntity entity;
|
||||
private final Clipboard clipboard;
|
||||
private final double x;
|
||||
@ -391,6 +396,7 @@ public class BlockArrayClipboard implements Clipboard {
|
||||
Entity result = clipboard.createEntity(loc, entity);
|
||||
return result != null;
|
||||
}
|
||||
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard;
|
||||
|
||||
import com.fastasyncworldedit.core.queue.Filter;
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.CPUOptimizedClipboard;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.DiskOptimizedClipboard;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.MemoryOptimizedClipboard;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.ReadOnlyClipboard;
|
||||
import com.fastasyncworldedit.core.function.visitor.Order;
|
||||
import com.fastasyncworldedit.core.queue.Filter;
|
||||
import com.fastasyncworldedit.core.util.EditSessionBuilder;
|
||||
import com.fastasyncworldedit.core.util.MaskTraverser;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -38,7 +39,6 @@ import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.fastasyncworldedit.core.function.visitor.Order;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
@ -47,8 +47,9 @@ import com.sk89q.worldedit.regions.Regions;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -57,7 +58,6 @@ import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -69,10 +69,12 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
//FAWE start
|
||||
static Clipboard create(Region region) {
|
||||
checkNotNull(region);
|
||||
checkNotNull(region.getWorld(),
|
||||
"World cannot be null (use the other constructor for the region)");
|
||||
checkNotNull(
|
||||
region.getWorld(),
|
||||
"World cannot be null (use the other constructor for the region)"
|
||||
);
|
||||
EditSession session = new EditSessionBuilder(region.getWorld()).allowedRegionsEverywhere()
|
||||
.autoQueue(false).build();
|
||||
.autoQueue(false).build();
|
||||
return ReadOnlyClipboard.of(session, region);
|
||||
}
|
||||
|
||||
@ -130,6 +132,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Remove entity from clipboard.
|
||||
*/
|
||||
@ -216,16 +219,20 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
|
||||
@Nullable Transform transform) {
|
||||
default EditSession paste(
|
||||
World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
|
||||
@Nullable Transform transform
|
||||
) {
|
||||
return paste(world, to, allowUndo, pasteAir, true, transform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paste this schematic in a world.
|
||||
*/
|
||||
default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
|
||||
boolean copyEntities, @Nullable Transform transform) {
|
||||
default EditSession paste(
|
||||
World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
|
||||
boolean copyEntities, @Nullable Transform transform
|
||||
) {
|
||||
checkNotNull(world);
|
||||
checkNotNull(to);
|
||||
EditSession editSession;
|
||||
@ -233,7 +240,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
editSession = (EditSession) world;
|
||||
} else {
|
||||
EditSessionBuilder builder = new EditSessionBuilder(world).autoQueue(true)
|
||||
.checkMemory(false).allowedRegionsEverywhere().limitUnlimited();
|
||||
.checkMemory(false).allowedRegionsEverywhere().limitUnlimited();
|
||||
if (allowUndo) {
|
||||
editSession = builder.build();
|
||||
} else {
|
||||
@ -250,7 +257,8 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
return editSession;
|
||||
}
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(extent, this.getRegion(),
|
||||
this.getOrigin(), editSession, to);
|
||||
this.getOrigin(), editSession, to
|
||||
);
|
||||
if (transform != null && !transform.isIdentity()) {
|
||||
copy.setTransform(transform);
|
||||
}
|
||||
@ -272,11 +280,13 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
return editSession;
|
||||
}
|
||||
|
||||
default void paste(Extent extent, BlockVector3 to, boolean pasteAir,
|
||||
@Nullable Transform transform) {
|
||||
default void paste(
|
||||
Extent extent, BlockVector3 to, boolean pasteAir,
|
||||
@Nullable Transform transform
|
||||
) {
|
||||
if (extent instanceof World) {
|
||||
EditSessionBuilder builder = new EditSessionBuilder((World) extent).autoQueue(true)
|
||||
.checkMemory(false).allowedRegionsEverywhere().limitUnlimited().changeSetNull();
|
||||
.checkMemory(false).allowedRegionsEverywhere().limitUnlimited().changeSetNull();
|
||||
extent = builder.build();
|
||||
}
|
||||
|
||||
@ -285,7 +295,8 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
source = new BlockTransformExtent(this, transform);
|
||||
}
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(source, this.getRegion(), this.getOrigin(),
|
||||
extent, to);
|
||||
extent, to
|
||||
);
|
||||
if (transform != null) {
|
||||
copy.setTransform(transform);
|
||||
}
|
||||
@ -312,7 +323,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
default void paste(Extent extent, BlockVector3 to, boolean pasteAir, boolean pasteEntities, boolean pasteBiomes) {
|
||||
if (extent instanceof World) {
|
||||
EditSessionBuilder builder = new EditSessionBuilder((World) extent).autoQueue(true)
|
||||
.checkMemory(false).allowedRegionsEverywhere().limitUnlimited().changeSetNull();
|
||||
.checkMemory(false).allowedRegionsEverywhere().limitUnlimited().changeSetNull();
|
||||
extent = builder.build();
|
||||
}
|
||||
|
||||
@ -350,13 +361,14 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
|
||||
for (Entity entity : this.getEntities()) {
|
||||
// skip players on pasting schematic
|
||||
if (entity.getState() != null && entity.getState().getType().getId()
|
||||
.equals("minecraft:player")) {
|
||||
.equals("minecraft:player")) {
|
||||
continue;
|
||||
}
|
||||
Location pos = entity.getLocation();
|
||||
Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX,
|
||||
pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(),
|
||||
pos.getPitch());
|
||||
pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(),
|
||||
pos.getPitch()
|
||||
);
|
||||
extent.createEntity(newPos, entity.getState());
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ abstract class StoredEntity implements Entity {
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param location the location
|
||||
* @param entity the entity (which will be copied)
|
||||
* @param entity the entity (which will be copied)
|
||||
*/
|
||||
StoredEntity(Location location, BaseEntity entity) {
|
||||
checkNotNull(location);
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.extent.clipboard.io;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriter;
|
||||
import com.fastasyncworldedit.core.internal.io.ResettableFileInputStream;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.schematic.MinecraftStructure;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.schematic.PNGWriter;
|
||||
import com.fastasyncworldedit.core.internal.io.ResettableFileInputStream;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
@ -52,7 +52,6 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||
|
||||
//FAWE start - register fast clipboard io
|
||||
FAST("fast", "fawe") {
|
||||
|
||||
@Override
|
||||
public String getPrimaryFileExtension() {
|
||||
return "schem";
|
||||
@ -94,7 +93,6 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||
* The Schematic format used by MCEdit.
|
||||
*/
|
||||
MCEDIT_SCHEMATIC("mcedit", "mce", "schematic") {
|
||||
|
||||
@Override
|
||||
public String getPrimaryFileExtension() {
|
||||
return "schematic";
|
||||
@ -122,11 +120,11 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||
},
|
||||
|
||||
SPONGE_SCHEMATIC("sponge", "schem") {
|
||||
|
||||
@Override
|
||||
public String getPrimaryFileExtension() {
|
||||
return "schem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClipboardReader getReader(InputStream inputStream) throws IOException {
|
||||
NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(inputStream));
|
||||
@ -163,7 +161,6 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||
|
||||
//FAWE start - recover schematics with bad entity data & register other clipboard formats
|
||||
BROKENENTITY("brokenentity", "legacyentity", "le", "be", "brokenentities", "legacyentities") {
|
||||
|
||||
@Override
|
||||
public String getPrimaryFileExtension() {
|
||||
return "schem";
|
||||
@ -239,7 +236,6 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||
* Isometric PNG writer.
|
||||
*/
|
||||
PNG("png", "image") {
|
||||
|
||||
@Override
|
||||
public ClipboardReader getReader(InputStream inputStream) {
|
||||
return null;
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.clipboard.io;
|
||||
|
||||
import com.fastasyncworldedit.core.util.task.RunnableVal;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
import com.fastasyncworldedit.core.util.task.RunnableVal;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
@ -100,10 +100,12 @@ public interface ClipboardFormat {
|
||||
Set<String> getFileExtensions();
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Sets the actor's clipboard.
|
||||
* @param actor the actor
|
||||
* @param uri the URI of the schematic to hold
|
||||
*
|
||||
* @param actor the actor
|
||||
* @param uri the URI of the schematic to hold
|
||||
* @param inputStream the input stream
|
||||
* @throws IOException thrown on I/O error
|
||||
*/
|
||||
|
@ -76,8 +76,8 @@ public class ClipboardFormats {
|
||||
if (old != null) {
|
||||
aliasMap.put(lowKey, old);
|
||||
WorldEdit.logger.warn(
|
||||
format.getClass().getName() + " cannot override existing alias '" + lowKey
|
||||
+ "' used by " + old.getClass().getName());
|
||||
format.getClass().getName() + " cannot override existing alias '" + lowKey
|
||||
+ "' used by " + old.getClass().getName());
|
||||
}
|
||||
}
|
||||
for (String ext : format.getFileExtensions()) {
|
||||
@ -96,8 +96,7 @@ public class ClipboardFormats {
|
||||
/**
|
||||
* Find the clipboard format named by the given alias.
|
||||
*
|
||||
* @param alias
|
||||
* the alias
|
||||
* @param alias the alias
|
||||
* @return the format, otherwise null if none is matched
|
||||
*/
|
||||
@Nullable
|
||||
@ -109,8 +108,7 @@ public class ClipboardFormats {
|
||||
/**
|
||||
* Detect the format of given a file.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
* @param file the file
|
||||
* @return the format, otherwise null if one cannot be detected
|
||||
*/
|
||||
@Nullable
|
||||
@ -151,6 +149,7 @@ public class ClipboardFormats {
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Detect the format using the given extension.
|
||||
*
|
||||
@ -171,7 +170,12 @@ public class ClipboardFormats {
|
||||
|
||||
}
|
||||
|
||||
public static MultiClipboardHolder loadAllFromInput(Actor player, String input, ClipboardFormat format, boolean message) throws IOException {
|
||||
public static MultiClipboardHolder loadAllFromInput(
|
||||
Actor player,
|
||||
String input,
|
||||
ClipboardFormat format,
|
||||
boolean message
|
||||
) throws IOException {
|
||||
checkNotNull(player);
|
||||
checkNotNull(input);
|
||||
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||
@ -185,20 +189,20 @@ public class ClipboardFormats {
|
||||
}
|
||||
URL base = new URL(Settings.IMP.WEB.URL);
|
||||
input = new URL(base, "uploads/" + input.substring(4) + "."
|
||||
+ format.getPrimaryFileExtension()).toString();
|
||||
+ format.getPrimaryFileExtension()).toString();
|
||||
}
|
||||
if (input.startsWith("http")) {
|
||||
return null;
|
||||
}
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS
|
||||
&& Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find()
|
||||
&& !player.hasPermission("worldedit.schematic.load.other")) {
|
||||
&& Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find()
|
||||
&& !player.hasPermission("worldedit.schematic.load.other")) {
|
||||
player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other"));
|
||||
return null;
|
||||
}
|
||||
File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS
|
||||
? new File(working, player.getUniqueId().toString()) : working;
|
||||
? new File(working, player.getUniqueId().toString()) : working;
|
||||
File f;
|
||||
if (input.startsWith("#")) {
|
||||
String[] extensions;
|
||||
@ -216,8 +220,8 @@ public class ClipboardFormats {
|
||||
}
|
||||
} else {
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS
|
||||
&& Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find()
|
||||
&& !player.hasPermission("worldedit.schematic.load.other")) {
|
||||
&& Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find()
|
||||
&& !player.hasPermission("worldedit.schematic.load.other")) {
|
||||
if (message) {
|
||||
player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other"));
|
||||
}
|
||||
@ -238,8 +242,8 @@ public class ClipboardFormats {
|
||||
if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) {
|
||||
if (message) {
|
||||
player.printError(
|
||||
"Schematic " + input + " does not exist! (" + ((f != null) && f.exists()) + "|"
|
||||
+ f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")");
|
||||
"Schematic " + input + " does not exist! (" + ((f != null) && f.exists()) + "|"
|
||||
+ f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -80,16 +80,16 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
private final DataFixer fixer;
|
||||
private static final ImmutableList<NBTCompatibilityHandler> COMPATIBILITY_HANDLERS
|
||||
= ImmutableList.of(
|
||||
new SignCompatibilityHandler(),
|
||||
new FlowerPotCompatibilityHandler(),
|
||||
new NoteBlockCompatibilityHandler(),
|
||||
new SkullBlockCompatibilityHandler(),
|
||||
new BannerBlockCompatibilityHandler(),
|
||||
new BedBlockCompatibilityHandler()
|
||||
new SignCompatibilityHandler(),
|
||||
new FlowerPotCompatibilityHandler(),
|
||||
new NoteBlockCompatibilityHandler(),
|
||||
new SkullBlockCompatibilityHandler(),
|
||||
new BannerBlockCompatibilityHandler(),
|
||||
new BedBlockCompatibilityHandler()
|
||||
);
|
||||
private static final ImmutableList<EntityNBTCompatibilityHandler> ENTITY_COMPATIBILITY_HANDLERS
|
||||
= ImmutableList.of(
|
||||
new Pre13HangingCompatibilityHandler()
|
||||
new Pre13HangingCompatibilityHandler()
|
||||
);
|
||||
|
||||
/**
|
||||
@ -223,7 +223,11 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
|
||||
if (fixer != null && t != null) {
|
||||
//FAWE start
|
||||
t = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, t.asBinaryTag(), -1));
|
||||
t = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(
|
||||
DataFixer.FixTypes.BLOCK_ENTITY,
|
||||
t.asBinaryTag(),
|
||||
-1
|
||||
));
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@ -285,10 +289,18 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
if (tag instanceof CompoundTag) {
|
||||
CompoundTag compound = (CompoundTag) tag;
|
||||
if (fixer != null) {
|
||||
compound = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(DataFixer.FixTypes.ENTITY, compound.asBinaryTag(), -1));
|
||||
compound = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(
|
||||
DataFixer.FixTypes.ENTITY,
|
||||
compound.asBinaryTag(),
|
||||
-1
|
||||
));
|
||||
}
|
||||
String id = convertEntityId(compound.getString("id"));
|
||||
Location location = NBTConversions.toLocation(clipboard, compound.getListTag("Pos"), compound.getListTag("Rotation"));
|
||||
Location location = NBTConversions.toLocation(
|
||||
clipboard,
|
||||
compound.getListTag("Pos"),
|
||||
compound.getListTag("Rotation")
|
||||
);
|
||||
if (!id.isEmpty()) {
|
||||
EntityType entityType = EntityTypes.get(id.toLowerCase(Locale.ROOT));
|
||||
if (entityType != null) {
|
||||
@ -312,38 +324,70 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
|
||||
private String convertEntityId(String id) {
|
||||
switch (id) {
|
||||
case "AreaEffectCloud": return "area_effect_cloud";
|
||||
case "ArmorStand": return "armor_stand";
|
||||
case "CaveSpider": return "cave_spider";
|
||||
case "MinecartChest": return "chest_minecart";
|
||||
case "DragonFireball": return "dragon_fireball";
|
||||
case "ThrownEgg": return "egg";
|
||||
case "EnderDragon": return "ender_dragon";
|
||||
case "ThrownEnderpearl": return "ender_pearl";
|
||||
case "FallingSand": return "falling_block";
|
||||
case "FireworksRocketEntity": return "fireworks_rocket";
|
||||
case "MinecartFurnace": return "furnace_minecart";
|
||||
case "MinecartHopper": return "hopper_minecart";
|
||||
case "EntityHorse": return "horse";
|
||||
case "ItemFrame": return "item_frame";
|
||||
case "LeashKnot": return "leash_knot";
|
||||
case "LightningBolt": return "lightning_bolt";
|
||||
case "LavaSlime": return "magma_cube";
|
||||
case "MinecartRideable": return "minecart";
|
||||
case "MushroomCow": return "mooshroom";
|
||||
case "Ozelot": return "ocelot";
|
||||
case "PolarBear": return "polar_bear";
|
||||
case "ThrownPotion": return "potion";
|
||||
case "ShulkerBullet": return "shulker_bullet";
|
||||
case "SmallFireball": return "small_fireball";
|
||||
case "MinecartSpawner": return "spawner_minecart";
|
||||
case "SpectralArrow": return "spectral_arrow";
|
||||
case "PrimedTnt": return "tnt";
|
||||
case "MinecartTNT": return "tnt_minecart";
|
||||
case "VillagerGolem": return "villager_golem";
|
||||
case "WitherBoss": return "wither";
|
||||
case "WitherSkull": return "wither_skull";
|
||||
case "PigZombie": return "zombie_pigman";
|
||||
case "AreaEffectCloud":
|
||||
return "area_effect_cloud";
|
||||
case "ArmorStand":
|
||||
return "armor_stand";
|
||||
case "CaveSpider":
|
||||
return "cave_spider";
|
||||
case "MinecartChest":
|
||||
return "chest_minecart";
|
||||
case "DragonFireball":
|
||||
return "dragon_fireball";
|
||||
case "ThrownEgg":
|
||||
return "egg";
|
||||
case "EnderDragon":
|
||||
return "ender_dragon";
|
||||
case "ThrownEnderpearl":
|
||||
return "ender_pearl";
|
||||
case "FallingSand":
|
||||
return "falling_block";
|
||||
case "FireworksRocketEntity":
|
||||
return "fireworks_rocket";
|
||||
case "MinecartFurnace":
|
||||
return "furnace_minecart";
|
||||
case "MinecartHopper":
|
||||
return "hopper_minecart";
|
||||
case "EntityHorse":
|
||||
return "horse";
|
||||
case "ItemFrame":
|
||||
return "item_frame";
|
||||
case "LeashKnot":
|
||||
return "leash_knot";
|
||||
case "LightningBolt":
|
||||
return "lightning_bolt";
|
||||
case "LavaSlime":
|
||||
return "magma_cube";
|
||||
case "MinecartRideable":
|
||||
return "minecart";
|
||||
case "MushroomCow":
|
||||
return "mooshroom";
|
||||
case "Ozelot":
|
||||
return "ocelot";
|
||||
case "PolarBear":
|
||||
return "polar_bear";
|
||||
case "ThrownPotion":
|
||||
return "potion";
|
||||
case "ShulkerBullet":
|
||||
return "shulker_bullet";
|
||||
case "SmallFireball":
|
||||
return "small_fireball";
|
||||
case "MinecartSpawner":
|
||||
return "spawner_minecart";
|
||||
case "SpectralArrow":
|
||||
return "spectral_arrow";
|
||||
case "PrimedTnt":
|
||||
return "tnt";
|
||||
case "MinecartTNT":
|
||||
return "tnt_minecart";
|
||||
case "VillagerGolem":
|
||||
return "villager_golem";
|
||||
case "WitherBoss":
|
||||
return "wither";
|
||||
case "WitherSkull":
|
||||
return "wither_skull";
|
||||
case "PigZombie":
|
||||
return "zombie_pigman";
|
||||
case "XPOrb":
|
||||
case "xp_orb":
|
||||
return "experience_orb";
|
||||
@ -356,17 +400,25 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
case "EnderCrystal":
|
||||
case "ender_crystal":
|
||||
return "end_crystal";
|
||||
case "fireworks_rocket": return "firework_rocket";
|
||||
case "fireworks_rocket":
|
||||
return "firework_rocket";
|
||||
case "MinecartCommandBlock":
|
||||
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";
|
||||
default: return id;
|
||||
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";
|
||||
default:
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,4 +482,5 @@ public class MCEditSchematicReader extends NBTSchematicReader {
|
||||
public void close() throws IOException {
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.extent.clipboard.io;
|
||||
|
||||
import com.sk89q.jnbt.Tag;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Base class for NBT schematic readers.
|
||||
@ -58,4 +58,5 @@ public abstract class NBTSchematicReader implements ClipboardReader {
|
||||
|
||||
return expected.cast(test);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
Map<String, Tag> schematic = schematicTag.getValue();
|
||||
|
||||
final Platform platform = WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.WORLD_EDITING);
|
||||
.queryCapability(Capability.WORLD_EDITING);
|
||||
int liveDataVersion = platform.getDataVersion();
|
||||
|
||||
if (schematicVersion == 1) {
|
||||
@ -103,22 +103,29 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
} else if (schematicVersion == 2) {
|
||||
dataVersion = requireTag(schematic, "DataVersion", IntTag.class).getValue();
|
||||
if (dataVersion < 0) {
|
||||
LOGGER.warn("Schematic has an unknown data version ({}). Data may be incompatible.",
|
||||
dataVersion);
|
||||
LOGGER.warn(
|
||||
"Schematic has an unknown data version ({}). Data may be incompatible.",
|
||||
dataVersion
|
||||
);
|
||||
// Do not DFU unknown data
|
||||
dataVersion = liveDataVersion;
|
||||
}
|
||||
if (dataVersion > liveDataVersion) {
|
||||
LOGGER.warn("Schematic was made in a newer Minecraft version ({} > {}). Data may be incompatible.",
|
||||
dataVersion, liveDataVersion);
|
||||
dataVersion, liveDataVersion
|
||||
);
|
||||
} else if (dataVersion < liveDataVersion) {
|
||||
fixer = platform.getDataFixer();
|
||||
if (fixer != null) {
|
||||
LOGGER.debug("Schematic was made in an older Minecraft version ({} < {}), will attempt DFU.",
|
||||
dataVersion, liveDataVersion);
|
||||
dataVersion, liveDataVersion
|
||||
);
|
||||
} else {
|
||||
LOGGER.info("Schematic was made in an older Minecraft version ({} < {}), but DFU is not available. Data may be incompatible.",
|
||||
dataVersion, liveDataVersion);
|
||||
LOGGER.info(
|
||||
"Schematic was made in an older Minecraft version ({} < {}), but DFU is not available. Data may be incompatible.",
|
||||
dataVersion,
|
||||
liveDataVersion
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,11 +181,11 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
int[] offsetParts;
|
||||
if (offsetTag != null) {
|
||||
offsetParts = offsetTag.getValue();
|
||||
if (offsetParts.length != 3) {
|
||||
if (offsetParts.length != 3) {
|
||||
throw new IOException("Invalid offset specified in schematic.");
|
||||
}
|
||||
} else {
|
||||
offsetParts = new int[] {0, 0, 0};
|
||||
offsetParts = new int[]{0, 0, 0};
|
||||
}
|
||||
|
||||
BlockVector3 min = BlockVector3.at(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||
@ -252,7 +259,8 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
if (fixer != null) {
|
||||
//FAWE start
|
||||
tileEntity = ((CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY,
|
||||
new CompoundTag(values).asBinaryTag(), dataVersion))).getValue();
|
||||
new CompoundTag(values).asBinaryTag(), dataVersion
|
||||
))).getValue();
|
||||
//FAWE end
|
||||
} else {
|
||||
tileEntity = values;
|
||||
@ -291,7 +299,10 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
BlockVector3 pt = BlockVector3.at(x, y, z);
|
||||
try {
|
||||
if (tileEntitiesMap.containsKey(pt)) {
|
||||
clipboard.setBlock(clipboard.getMinimumPoint().add(pt), state.toBaseBlock(new CompoundTag(tileEntitiesMap.get(pt))));
|
||||
clipboard.setBlock(
|
||||
clipboard.getMinimumPoint().add(pt),
|
||||
state.toBaseBlock(new CompoundTag(tileEntitiesMap.get(pt)))
|
||||
);
|
||||
} else {
|
||||
clipboard.setBlock(clipboard.getMinimumPoint().add(pt), state);
|
||||
}
|
||||
@ -334,7 +345,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
BiomeType biome = BiomeTypes.get(key);
|
||||
if (biome == null) {
|
||||
LOGGER.warn("Unknown biome type :" + key
|
||||
+ " in palette. Are you missing a mod or using a schematic made in a newer version of Minecraft?");
|
||||
+ " in palette. Are you missing a mod or using a schematic made in a newer version of Minecraft?");
|
||||
}
|
||||
Tag idTag = palettePart.getValue();
|
||||
if (!(idTag instanceof IntTag)) {
|
||||
@ -392,15 +403,21 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
|
||||
if (fixer != null) {
|
||||
//FAWE start
|
||||
entityTag = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(DataFixer.FixTypes.ENTITY, entityTag.asBinaryTag(), dataVersion));
|
||||
entityTag = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(
|
||||
DataFixer.FixTypes.ENTITY,
|
||||
entityTag.asBinaryTag(),
|
||||
dataVersion
|
||||
));
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
EntityType entityType = EntityTypes.get(id);
|
||||
if (entityType != null) {
|
||||
Location location = NBTConversions.toLocation(clipboard,
|
||||
Location location = NBTConversions.toLocation(
|
||||
clipboard,
|
||||
requireTag(tags, "Pos", ListTag.class),
|
||||
requireTag(tags, "Rotation", ListTag.class));
|
||||
requireTag(tags, "Rotation", ListTag.class)
|
||||
);
|
||||
BaseEntity state = new BaseEntity(entityType, entityTag);
|
||||
clipboard.createEntity(location, state);
|
||||
} else {
|
||||
@ -413,4 +430,5 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
public void close() throws IOException {
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
Map<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Version", new IntTag(CURRENT_VERSION));
|
||||
schematic.put("DataVersion", new IntTag(
|
||||
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion()));
|
||||
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion()));
|
||||
|
||||
Map<String, Tag> metadata = new HashMap<>();
|
||||
metadata.put("WEOffsetX", new IntTag(offset.getBlockX()));
|
||||
@ -121,9 +121,9 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
|
||||
// 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(),
|
||||
min.getBlockX(),
|
||||
min.getBlockY(),
|
||||
min.getBlockZ(),
|
||||
}));
|
||||
|
||||
int paletteMax = 0;
|
||||
@ -152,7 +152,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
values.remove("z");
|
||||
|
||||
values.put("Id", new StringTag(block.getNbtId()));
|
||||
values.put("Pos", new IntArrayTag(new int[] { x, y, z }));
|
||||
values.put("Pos", new IntArrayTag(new int[]{x, y, z}));
|
||||
|
||||
tileEntities.add(new CompoundTag(values));
|
||||
}
|
||||
@ -270,4 +270,5 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
public void close() throws IOException {
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -164,4 +164,5 @@ public class BannerBlockCompatibilityHandler implements NBTCompatibilityHandler
|
||||
}
|
||||
return color + (isWall ? "_wall_banner" : "_banner");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -138,4 +138,5 @@ public class BedBlockCompatibilityHandler implements NBTCompatibilityHandler {
|
||||
}
|
||||
return color + "_bed";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,9 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
|
||||
public interface EntityNBTCompatibilityHandler {
|
||||
|
||||
boolean isAffectedEntity(EntityType type, CompoundTag entityTag);
|
||||
|
||||
CompoundTag updateNBT(EntityType type, CompoundTag entityTag);
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import java.util.Map;
|
||||
|
||||
public class FlowerPotCompatibilityHandler implements NBTCompatibilityHandler {
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean isAffectedBlock(B block) {
|
||||
return block.getBlockType() == BlockTypes.FLOWER_POT;
|
||||
@ -94,4 +95,5 @@ public class FlowerPotCompatibilityHandler implements NBTCompatibilityHandler {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import java.util.Map;
|
||||
|
||||
public interface NBTCompatibilityHandler {
|
||||
|
||||
<B extends BlockStateHolder<B>> boolean isAffectedBlock(B block);
|
||||
|
||||
<B extends BlockStateHolder<B>> BlockStateHolder<?> updateNBT(B block, Map<String, Tag> values);
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import java.util.Map;
|
||||
|
||||
public class NoteBlockCompatibilityHandler implements NBTCompatibilityHandler {
|
||||
|
||||
private static final IntegerProperty NoteProperty;
|
||||
|
||||
static {
|
||||
@ -60,4 +61,5 @@ public class NoteBlockCompatibilityHandler implements NBTCompatibilityHandler {
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,4 +71,5 @@ public class SignCompatibilityHandler implements NBTCompatibilityHandler {
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class SkullBlockCompatibilityHandler implements NBTCompatibilityHandler {
|
||||
private static final Property<Direction> FacingProperty;
|
||||
|
||||
static {
|
||||
Property<Direction> tempFacing;
|
||||
Property<Direction> tempFacing;
|
||||
try {
|
||||
tempFacing = BlockTypes.SKELETON_WALL_SKULL.getProperty("facing");
|
||||
} catch (NullPointerException | IllegalArgumentException | ClassCastException e) {
|
||||
@ -97,4 +97,5 @@ public class SkullBlockCompatibilityHandler implements NBTCompatibilityHandler {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public abstract class BlockBag {
|
||||
* Store a block.
|
||||
*
|
||||
* @param blockState The block state
|
||||
* @param amount The amount
|
||||
* @param amount The amount
|
||||
* @throws BlockBagException on error
|
||||
*/
|
||||
public abstract void storeBlock(BlockState blockState, int amount) throws BlockBagException;
|
||||
@ -129,4 +129,5 @@ public abstract class BlockBag {
|
||||
* @param pos the position
|
||||
*/
|
||||
public abstract void addSingleSourcePosition(Location pos);
|
||||
|
||||
}
|
||||
|
@ -23,4 +23,5 @@ package com.sk89q.worldedit.extent.inventory;
|
||||
* Thrown when a block bag detects a problem.
|
||||
*/
|
||||
public class BlockBagException extends Exception {
|
||||
|
||||
}
|
||||
|
@ -29,10 +29,10 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Applies a {@link BlockBag} to operations.
|
||||
@ -41,14 +41,14 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
||||
|
||||
//FAWE start
|
||||
private final boolean mine;
|
||||
private int[] missingBlocks = new int[BlockTypes.size()];
|
||||
private final int[] missingBlocks = new int[BlockTypes.size()];
|
||||
//FAWE end
|
||||
private BlockBag blockBag;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param extent the extent
|
||||
* @param blockBag the block bag
|
||||
*/
|
||||
//FAWE start
|
||||
@ -137,4 +137,5 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
||||
|
||||
return super.setBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,4 +23,5 @@ package com.sk89q.worldedit.extent.inventory;
|
||||
* Thrown when there are no more blocks left.
|
||||
*/
|
||||
public class OutOfBlocksException extends BlockBagException {
|
||||
|
||||
}
|
||||
|
@ -45,4 +45,5 @@ public class OutOfSpaceException extends BlockBagException {
|
||||
public BlockType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,4 +23,5 @@ package com.sk89q.worldedit.extent.inventory;
|
||||
* Thrown when a block that can't be placed is used.
|
||||
*/
|
||||
public class UnplaceableBlockException extends BlockBagException {
|
||||
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class MultiStageReorder extends AbstractBufferingExtent implements Reorde
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param extent the extent
|
||||
* @param enabled true to enable
|
||||
*/
|
||||
public MultiStageReorder(Extent extent, boolean enabled) {
|
||||
@ -225,7 +225,9 @@ public class MultiStageReorder extends AbstractBufferingExtent implements Reorde
|
||||
PlacementPriority srcPriority = getPlacementPriority(existing);
|
||||
|
||||
if (srcPriority != PlacementPriority.FIRST) {
|
||||
BaseBlock replacement = (block.getBlockType().getMaterial().isAir() ? block : BlockTypes.AIR.getDefaultState()).toBaseBlock();
|
||||
BaseBlock replacement = (block.getBlockType().getMaterial().isAir()
|
||||
? block
|
||||
: BlockTypes.AIR.getDefaultState()).toBaseBlock();
|
||||
|
||||
switch (srcPriority) {
|
||||
case FINAL:
|
||||
@ -283,4 +285,5 @@ public class MultiStageReorder extends AbstractBufferingExtent implements Reorde
|
||||
|
||||
return new OperationQueue(operations);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.extent.transform;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.registry.state.PropertyKey;
|
||||
import com.fastasyncworldedit.core.registry.state.PropertyKeySet;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -36,8 +38,6 @@ import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.fastasyncworldedit.core.registry.state.PropertyKey;
|
||||
import com.fastasyncworldedit.core.registry.state.PropertyKeySet;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -46,8 +46,9 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -56,7 +57,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.util.Direction.ASCENDING_EAST;
|
||||
@ -206,7 +206,10 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
return null;
|
||||
}
|
||||
case "hinge": {
|
||||
return adapt(combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST), combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST));
|
||||
return adapt(
|
||||
combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST),
|
||||
combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST)
|
||||
);
|
||||
}
|
||||
case "shape": {
|
||||
if (values.contains("left")) {
|
||||
@ -221,16 +224,32 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
result.add(combine(NORTH, EAST, SOUTH, WEST));
|
||||
continue;
|
||||
case "inner_left":
|
||||
result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("outer_right"), property.getIndexFor("outer_left")));
|
||||
result.add(orIndex(
|
||||
combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST),
|
||||
property.getIndexFor("outer_right"),
|
||||
property.getIndexFor("outer_left")
|
||||
));
|
||||
continue;
|
||||
case "inner_right":
|
||||
result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("outer_right"), property.getIndexFor("outer_left")));
|
||||
result.add(orIndex(
|
||||
combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST),
|
||||
property.getIndexFor("outer_right"),
|
||||
property.getIndexFor("outer_left")
|
||||
));
|
||||
continue;
|
||||
case "outer_left":
|
||||
result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right")));
|
||||
result.add(orIndex(
|
||||
combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST),
|
||||
property.getIndexFor("inner_left"),
|
||||
property.getIndexFor("inner_right")
|
||||
));
|
||||
continue;
|
||||
case "outer_right":
|
||||
result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right")));
|
||||
result.add(orIndex(
|
||||
combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST),
|
||||
property.getIndexFor("inner_left"),
|
||||
property.getIndexFor("inner_right")
|
||||
));
|
||||
continue;
|
||||
default:
|
||||
LOGGER.warn("Unknown direction {}", value);
|
||||
@ -377,7 +396,10 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY());
|
||||
applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ());
|
||||
|
||||
Direction newDirection = Direction.findClosest(applyAbsolute, Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL);
|
||||
Direction newDirection = Direction.findClosest(
|
||||
applyAbsolute,
|
||||
Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL
|
||||
);
|
||||
|
||||
if (newDirection != null) {
|
||||
Map<String, Tag> values = new HashMap<>(tag.getValue());
|
||||
@ -396,7 +418,8 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
|
||||
BlockType type = state.getBlockType();
|
||||
// Rotate North, East, South, West
|
||||
if (type.hasProperty(PropertyKey.NORTH) && type.hasProperty(PropertyKey.EAST) && type.hasProperty(PropertyKey.SOUTH) && type.hasProperty(PropertyKey.WEST)) {
|
||||
if (type.hasProperty(PropertyKey.NORTH) && type.hasProperty(PropertyKey.EAST) && type.hasProperty(PropertyKey.SOUTH) && type
|
||||
.hasProperty(PropertyKey.WEST)) {
|
||||
Direction newNorth = findClosest(transform.apply(NORTH.toVector()), Flag.CARDINAL);
|
||||
Direction newEast = findClosest(transform.apply(EAST.toVector()), Flag.CARDINAL);
|
||||
Direction newSouth = findClosest(transform.apply(SOUTH.toVector()), Flag.CARDINAL);
|
||||
@ -424,7 +447,11 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
int oldIndex = property.getIndex(state.getInternalId());
|
||||
if (oldIndex >= directions.length) {
|
||||
if (Settings.IMP.ENABLED_COMPONENTS.DEBUG) {
|
||||
LOGGER.warn(String.format("Index outside direction array length found for block:{%s} property:{%s}", state.getBlockType().getId(), property.getName()));
|
||||
LOGGER.warn(String.format(
|
||||
"Index outside direction array length found for block:{%s} property:{%s}",
|
||||
state.getBlockType().getId(),
|
||||
property.getName()
|
||||
));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -474,7 +501,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
/**
|
||||
* Transform a block without making a copy.
|
||||
*
|
||||
* @param block the block
|
||||
* @param block the block
|
||||
* @param reverse true to transform in the opposite direction
|
||||
* @return the same block
|
||||
*/
|
||||
@ -525,7 +552,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
*
|
||||
* <p>The provided block is <em>not</em> modified.</p>
|
||||
*
|
||||
* @param block the block
|
||||
* @param block the block
|
||||
* @param transform the transform
|
||||
* @return the same block
|
||||
*/
|
||||
|
@ -41,7 +41,7 @@ public class BlockChangeLimiter extends AbstractDelegateExtent {
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param limit the limit (>= 0) or -1 for no limit
|
||||
* @param limit the limit (>= 0) or -1 for no limit
|
||||
*/
|
||||
public BlockChangeLimiter(Extent extent, int limit) {
|
||||
super(extent);
|
||||
@ -86,4 +86,5 @@ public class BlockChangeLimiter extends AbstractDelegateExtent {
|
||||
}
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param world the world
|
||||
* @param world the world
|
||||
*/
|
||||
public DataValidatorExtent(Extent extent, World world) {
|
||||
super(extent);
|
||||
|
@ -47,4 +47,5 @@ public class BiomeQuirkExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
return super.setBiome(position, biome) || success;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class BlockQuirkExtent extends AbstractDelegateExtent {
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param world the world
|
||||
* @param world the world
|
||||
*/
|
||||
public BlockQuirkExtent(Extent extent, World world) {
|
||||
super(extent);
|
||||
|
@ -40,8 +40,8 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param world the world
|
||||
* @param extent the extent
|
||||
* @param world the world
|
||||
* @param enabled true to enable
|
||||
*/
|
||||
public ChunkLoadingExtent(Extent extent, World world, boolean enabled) {
|
||||
@ -55,7 +55,7 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent {
|
||||
* Create a new instance with chunk loading enabled.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param world the world
|
||||
* @param world the world
|
||||
*/
|
||||
public ChunkLoadingExtent(Extent extent, World world) {
|
||||
this(extent, world, true);
|
||||
@ -76,4 +76,5 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
return super.setBiome(position, biome);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -124,4 +124,5 @@ public class SideEffectExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param world the world
|
||||
* @param world the world
|
||||
*/
|
||||
public SurvivalModeExtent(Extent extent, World world) {
|
||||
super(extent);
|
||||
|
@ -47,7 +47,7 @@ public class WatchdogTickingExtent extends AbstractDelegateExtent {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param extent the extent
|
||||
* @param watchdog the watchdog to reset
|
||||
*/
|
||||
public WatchdogTickingExtent(Extent extent, Watchdog watchdog) {
|
||||
@ -91,4 +91,5 @@ public class WatchdogTickingExtent extends AbstractDelegateExtent {
|
||||
onOperation();
|
||||
return super.setBiome(position, biome);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user