Fixed issues regarding block transformations and using the BaseBlock to apply a function.

This commit is contained in:
IronApollo
2019-02-07 09:04:14 -05:00
parent 0e5847e1ce
commit 511c279153
9 changed files with 90 additions and 53 deletions

View File

@ -23,7 +23,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
}
@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.mutY((location.getY() + dy));
mutable.mutZ((location.getZ() + dz));
@ -31,7 +31,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
}
@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.mutY(y + dy);
mutable.mutZ(z + dz);

View File

@ -41,7 +41,7 @@ public class NullExtent extends FaweRegionExtent {
super(new com.sk89q.worldedit.extent.NullExtent(), FaweLimit.MAX);
this.reason = BBC.WORLDEDIT_CANCEL_REASON_MANUAL;
}
@Override
public ResettableExtent setExtent(Extent extent) {
return this;
@ -49,42 +49,74 @@ public class NullExtent extends FaweRegionExtent {
@Override
public BaseBiome getBiome(final BlockVector2 arg0) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return null;
}
}
@Override
public BlockState getBlock(final BlockVector3 arg0) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return null;
}
}
@Override
public BlockState getLazyBlock(final BlockVector3 arg0) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return null;
}
}
@Override
public boolean setBiome(final BlockVector2 arg0, final BaseBiome arg1) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return false;
}
}
@Override
public boolean setBlock(final BlockVector3 arg0, final BlockStateHolder arg1) throws WorldEditException {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return false;
}
}
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return false;
}
}
@Override
public BlockState getLazyBlock(int x, int y, int z) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return null;
}
}
@Override
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return null;
}
}
@Override
@ -109,12 +141,20 @@ public class NullExtent extends FaweRegionExtent {
@Override
public boolean contains(int x, int z) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return false;
}
}
@Override
public boolean contains(int x, int y, int z) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return false;
}
}
@Override
@ -135,17 +175,29 @@ public class NullExtent extends FaweRegionExtent {
@Override
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return -1;
}
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return -1;
}
}
@Override
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
throw new FaweException(reason);
if(reason != null) {
throw new FaweException(reason);
}else {
return -1;
}
}
@Override

View File

@ -43,29 +43,13 @@ public class PositionTransformExtent extends ResettableExtent {
mutable.mutY(((pos.getY() - min.getY())));
mutable.mutZ(((pos.getZ() - 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();
}
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();
BlockVector3 result = min.add(tmp.toBlockPoint());
return result;
}
@Override
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
@ -87,13 +71,13 @@ public class PositionTransformExtent extends ResettableExtent {
}
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
return super.setBlock(getPos(x, y, z), block);
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
return super.setBlock(getPos(BlockVector3.at(x, y, z)), block);
}
@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);
}