mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-24 19:46:34 +01:00
Fixes #442
This commit is contained in:
parent
b16276e1ac
commit
74baf5fee8
@ -2711,11 +2711,13 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
|||||||
public int deformRegion(final Region region, final Vector zero, final Vector unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException {
|
public int deformRegion(final Region region, final Vector zero, final Vector unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException {
|
||||||
final Expression expression = Expression.compile(expressionString, "x", "y", "z");
|
final Expression expression = Expression.compile(expressionString, "x", "y", "z");
|
||||||
expression.optimize();
|
expression.optimize();
|
||||||
final RValue x = expression.getVariable("x", false);
|
final RValue x = expression.getVariable("x", false).optimize();
|
||||||
final RValue y = expression.getVariable("y", false);
|
final RValue y = expression.getVariable("y", false).optimize();
|
||||||
final RValue z = expression.getVariable("z", false);
|
final RValue z = expression.getVariable("z", false).optimize();
|
||||||
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
||||||
expression.setEnvironment(environment);
|
expression.setEnvironment(environment);
|
||||||
|
final Vector zero2 = zero.add(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||||
|
|
||||||
private MutableBlockVector mutable = new MutableBlockVector();
|
private MutableBlockVector mutable = new MutableBlockVector();
|
||||||
@ -2723,18 +2725,19 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(Vector position) throws WorldEditException {
|
||||||
try {
|
try {
|
||||||
int mx = (position.getBlockX() - zero.getBlockX()) / unit.getBlockX();
|
// offset, scale
|
||||||
int my = (position.getBlockY() - zero.getBlockY()) / unit.getBlockY();
|
double sx = (position.getX() - zero.getX()) / unit.getX();
|
||||||
int mz = (position.getBlockZ() - zero.getBlockZ()) / unit.getBlockZ();
|
double sy = (position.getY() - zero.getY()) / unit.getY();
|
||||||
mutable.setComponents(mx, my, mz);
|
double sz = (position.getZ() - zero.getZ()) / unit.getZ();
|
||||||
// final Vector scaled = position.subtract(zero).divide(unit);
|
|
||||||
// transform
|
// transform
|
||||||
expression.evaluate(mutable.getX(), mutable.getY(), mutable.getZ());
|
expression.evaluate(sx, sy, sz);
|
||||||
final BlockVector sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue());
|
int xv = (int) (x.getValue() * unit.getX() + zero2.getX());
|
||||||
|
int yv = (int) (y.getValue() * unit.getY() + zero2.getY());
|
||||||
|
int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ());
|
||||||
// read block from world
|
// read block from world
|
||||||
BaseBlock material = FaweCache.CACHE_BLOCK[queue.getCombinedId4DataDebug(sourcePosition.getBlockX(), sourcePosition.getBlockY(), sourcePosition.getBlockZ(), 0, EditSession.this)];
|
BaseBlock material = FaweCache.CACHE_BLOCK[queue.getCombinedId4DataDebug(xv, yv, zv, 0, EditSession.this)];
|
||||||
// queue operation
|
// queue operation
|
||||||
return extent.setBlock(position, material);
|
return setBlockFast(position, material);
|
||||||
} catch (EvaluationException e) {
|
} catch (EvaluationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user