mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Added Pattern.next(int, int, int).
This method can be used to avoid creating short-lived vectors in tight loops.
This commit is contained in:
parent
8610dc2c89
commit
02a70cca4a
@ -54,10 +54,22 @@ public class ClipboardPattern implements Pattern {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public BaseBlock next(Vector pos) {
|
public BaseBlock next(Vector pos) {
|
||||||
int x = Math.abs(pos.getBlockX()) % size.getBlockX();
|
return next(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||||
int y = Math.abs(pos.getBlockY()) % size.getBlockY();
|
}
|
||||||
int z = Math.abs(pos.getBlockZ()) % size.getBlockZ();
|
|
||||||
|
|
||||||
return clipboard.getPoint(new Vector(x, y, z));
|
/**
|
||||||
|
* Get next block.
|
||||||
|
*
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param z
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public BaseBlock next(int x, int y, int z) {
|
||||||
|
int xp = Math.abs(x) % size.getBlockX();
|
||||||
|
int yp = Math.abs(y) % size.getBlockY();
|
||||||
|
int zp = Math.abs(z) % size.getBlockZ();
|
||||||
|
|
||||||
|
return clipboard.getPoint(new Vector(xp, yp, zp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,13 @@ public interface Pattern {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public BaseBlock next(Vector pos);
|
public BaseBlock next(Vector pos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a block for a position. This return value of this method does
|
||||||
|
* not have to be consistent for the same position.
|
||||||
|
*
|
||||||
|
* @param pos
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public BaseBlock next(int x, int y, int z);
|
||||||
}
|
}
|
||||||
|
@ -82,4 +82,8 @@ public class RandomFillPattern implements Pattern {
|
|||||||
|
|
||||||
throw new RuntimeException("ProportionalFillPattern");
|
throw new RuntimeException("ProportionalFillPattern");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseBlock next(int x, int y, int z) {
|
||||||
|
return next(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,10 @@ public class SingleBlockPattern implements Pattern {
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseBlock next(int x, int y, int z) {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the block.
|
* Get the block.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user