mirror of
https://github.com/cabaletta/baritone
synced 2025-02-20 05:57:05 +00:00
Merge pull request #4007 from ZacSharp/pr/schematics/mask/fixBinaryOperatorMaskOOB
Don't call `partOfMask` out of bounds in `BinaryOperatorMask`
This commit is contained in:
commit
b0ebbf4dfb
@ -33,7 +33,7 @@ public final class BinaryOperatorMask extends AbstractMask {
|
||||
private final BooleanBinaryOperator operator;
|
||||
|
||||
public BinaryOperatorMask(Mask a, Mask b, BooleanBinaryOperator operator) {
|
||||
super(a.widthX(), a.heightY(), a.lengthZ());
|
||||
super(Math.max(a.widthX(), b.widthX()), Math.max(a.heightY(), b.heightY()), Math.max(a.lengthZ(), b.lengthZ()));
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.operator = operator;
|
||||
@ -42,11 +42,15 @@ public final class BinaryOperatorMask extends AbstractMask {
|
||||
@Override
|
||||
public boolean partOfMask(int x, int y, int z, IBlockState currentState) {
|
||||
return this.operator.applyAsBoolean(
|
||||
this.a.partOfMask(x, y, z, currentState),
|
||||
this.b.partOfMask(x, y, z, currentState)
|
||||
partOfMask(a, x, y, z, currentState),
|
||||
partOfMask(b, x, y, z, currentState)
|
||||
);
|
||||
}
|
||||
|
||||
private static boolean partOfMask(Mask mask, int x, int y, int z, IBlockState currentState) {
|
||||
return x < mask.widthX() && y < mask.heightY() && z < mask.lengthZ() && mask.partOfMask(x, y, z, currentState);
|
||||
}
|
||||
|
||||
public static final class Static extends AbstractMask implements StaticMask {
|
||||
|
||||
private final StaticMask a;
|
||||
@ -54,7 +58,7 @@ public final class BinaryOperatorMask extends AbstractMask {
|
||||
private final BooleanBinaryOperator operator;
|
||||
|
||||
public Static(StaticMask a, StaticMask b, BooleanBinaryOperator operator) {
|
||||
super(a.widthX(), a.heightY(), a.lengthZ());
|
||||
super(Math.max(a.widthX(), b.widthX()), Math.max(a.heightY(), b.heightY()), Math.max(a.lengthZ(), b.lengthZ()));
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.operator = operator;
|
||||
@ -63,9 +67,13 @@ public final class BinaryOperatorMask extends AbstractMask {
|
||||
@Override
|
||||
public boolean partOfMask(int x, int y, int z) {
|
||||
return this.operator.applyAsBoolean(
|
||||
this.a.partOfMask(x, y, z),
|
||||
this.b.partOfMask(x, y, z)
|
||||
partOfMask(a, x, y, z),
|
||||
partOfMask(b, x, y, z)
|
||||
);
|
||||
}
|
||||
|
||||
private static boolean partOfMask(StaticMask mask, int x, int y, int z) {
|
||||
return x < mask.widthX() && y < mask.heightY() && z < mask.lengthZ() && mask.partOfMask(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user