mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Fixed issues regarding block transformations and using the BaseBlock to apply a function.
This commit is contained in:
parent
0e5847e1ce
commit
511c279153
@ -23,7 +23,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||||
mutable.mutX((location.getX() + dx));
|
mutable.mutX((location.getX() + dx));
|
||||||
mutable.mutY((location.getY() + dy));
|
mutable.mutY((location.getY() + dy));
|
||||||
mutable.mutZ((location.getZ() + dz));
|
mutable.mutZ((location.getZ() + dz));
|
||||||
@ -31,7 +31,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
mutable.mutX(x + dx);
|
mutable.mutX(x + dx);
|
||||||
mutable.mutY(y + dy);
|
mutable.mutY(y + dy);
|
||||||
mutable.mutZ(z + dz);
|
mutable.mutZ(z + dz);
|
||||||
|
@ -49,42 +49,74 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(final BlockVector2 arg0) {
|
public BaseBiome getBiome(final BlockVector2 arg0) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(final BlockVector3 arg0) {
|
public BlockState getBlock(final BlockVector3 arg0) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(final BlockVector3 arg0) {
|
public BlockState getLazyBlock(final BlockVector3 arg0) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final BlockVector2 arg0, final BaseBiome arg1) {
|
public boolean setBiome(final BlockVector2 arg0, final BaseBiome arg1) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(final BlockVector3 arg0, final BlockStateHolder arg1) throws WorldEditException {
|
public boolean setBlock(final BlockVector3 arg0, final BlockStateHolder arg1) throws WorldEditException {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getLazyBlock(int x, int y, int z) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -109,12 +141,20 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int z) {
|
public boolean contains(int x, int z) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int y, int z) {
|
public boolean contains(int x, int y, int z) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -135,17 +175,29 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
||||||
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,29 +43,13 @@ public class PositionTransformExtent extends ResettableExtent {
|
|||||||
mutable.mutY(((pos.getY() - min.getY())));
|
mutable.mutY(((pos.getY() - min.getY())));
|
||||||
mutable.mutZ(((pos.getZ() - min.getZ())));
|
mutable.mutZ(((pos.getZ() - min.getZ())));
|
||||||
MutableVector tmp = new MutableVector(transform.apply(mutable.toVector3()));
|
MutableVector tmp = new MutableVector(transform.apply(mutable.toVector3()));
|
||||||
tmp.mutX((tmp.getX() + min.getX()));
|
BlockVector3 result = min.add(tmp.toBlockPoint());
|
||||||
tmp.mutY((tmp.getY() + min.getY()));
|
return result;
|
||||||
tmp.mutZ((tmp.getZ() + min.getZ()));
|
|
||||||
return tmp.toBlockPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
private BlockVector3 getPos(int x, int y, int z) {
|
|
||||||
if (min == null) {
|
|
||||||
min = BlockVector3.at(x, y, z);
|
|
||||||
}
|
|
||||||
mutable.mutX(((x - min.getX())));
|
|
||||||
mutable.mutY(((y - min.getY())));
|
|
||||||
mutable.mutZ(((z - min.getZ())));
|
|
||||||
MutableVector tmp = new MutableVector(transform.apply(mutable.toVector3()));
|
|
||||||
tmp.mutX((tmp.getX() + min.getX()));
|
|
||||||
tmp.mutY((tmp.getY() + min.getY()));
|
|
||||||
tmp.mutZ((tmp.getZ() + min.getZ()));
|
|
||||||
return tmp.toBlockPoint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getLazyBlock(int x, int y, int z) {
|
||||||
return super.getLazyBlock(getPos(x, y, z));
|
return super.getLazyBlock(getPos(BlockVector3.at(x, y, z)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,13 +71,13 @@ public class PositionTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||||
return super.setBlock(getPos(x, y, z), block);
|
return super.setBlock(getPos(BlockVector3.at(x, y, z)), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||||
return super.setBlock(getPos(location), block);
|
return super.setBlock(getPos(location), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,6 +542,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
return new NullExtent(extent, BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
|
return new NullExtent(extent, BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
|
||||||
}
|
}
|
||||||
final Extent toReturn = event.getExtent();
|
final Extent toReturn = event.getExtent();
|
||||||
|
// if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) {
|
||||||
|
// return new NullExtent(toReturn, null);
|
||||||
|
// return new AbstractDelegateExtent(toReturn);
|
||||||
|
// });
|
||||||
if (!(toReturn instanceof AbstractDelegateExtent)) {
|
if (!(toReturn instanceof AbstractDelegateExtent)) {
|
||||||
Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
|
Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
|
||||||
return extent;
|
return extent;
|
||||||
|
@ -145,15 +145,15 @@ public class AbstractDelegateExtent implements LightingExtent {
|
|||||||
return setBlock(BlockVector3.at(x, y, z), block);
|
return setBlock(BlockVector3.at(x, y, z), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
|
||||||
return extent.getBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||||
return extent.setBlock(location, block);
|
return extent.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
|
return extent.getBlock(position);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Entity createEntity(Location location, BaseEntity entity) {
|
public Entity createEntity(Location location, BaseEntity entity) {
|
||||||
|
@ -109,6 +109,11 @@ public class NullExtent implements Extent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -26,7 +26,7 @@ import com.sk89q.worldedit.extent.Extent;
|
|||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
@ -52,13 +52,6 @@ public class BlockReplace implements RegionFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//<<<<<<< HEAD
|
|
||||||
// public boolean apply(Vector position) throws WorldEditException {
|
|
||||||
// return pattern.apply(extent, position, position);
|
|
||||||
//=======
|
|
||||||
// public boolean apply(BlockVector3 position) throws WorldEditException {
|
|
||||||
// return extent.setBlock(position, pattern.apply(position));
|
|
||||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
return pattern.apply(extent, position, position);
|
return pattern.apply(extent, position, position);
|
||||||
}
|
}
|
||||||
|
@ -244,8 +244,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
// TODO Auto-generated method stub
|
return this.toImmutableState().apply(extent, get, set);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user