mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Linear Patterns require flooring division (#2079)
Use floorDiv in linear patterns
This commit is contained in:
parent
214954bb09
commit
158e51191f
@ -7,6 +7,8 @@ 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 com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
|
import static java.lang.Math.floorDiv;
|
||||||
|
|
||||||
public class Linear2DBlockPattern extends AbstractPattern {
|
public class Linear2DBlockPattern extends AbstractPattern {
|
||||||
|
|
||||||
private final Pattern[] patternsArray;
|
private final Pattern[] patternsArray;
|
||||||
@ -37,7 +39,8 @@ public class Linear2DBlockPattern extends AbstractPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
int index = (get.getBlockX() / this.xScale + get.getBlockZ() / this.zScale) % patternsArray.length;
|
int index = (floorDiv(get.getBlockX(), this.xScale)
|
||||||
|
+ floorDiv(get.getBlockZ(), this.zScale)) % patternsArray.length;
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
index += patternsArray.length;
|
index += patternsArray.length;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ 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 com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
|
import static java.lang.Math.floorDiv;
|
||||||
|
|
||||||
public class Linear3DBlockPattern extends AbstractPattern {
|
public class Linear3DBlockPattern extends AbstractPattern {
|
||||||
|
|
||||||
private final Pattern[] patternsArray;
|
private final Pattern[] patternsArray;
|
||||||
@ -41,8 +43,8 @@ public class Linear3DBlockPattern extends AbstractPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
int index = (get.getBlockX() / this.xScale
|
int index = (floorDiv(get.getBlockX(), this.xScale)
|
||||||
+ get.getBlockY() / this.yScale + get.getBlockZ() / this.zScale) % patternsArray.length;
|
+ floorDiv(get.getBlockY(), this.yScale) + floorDiv(get.getBlockZ(), this.zScale)) % patternsArray.length;
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
index += patternsArray.length;
|
index += patternsArray.length;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user