Skip to content

Commit

Permalink
Fix out of bounds error for erode and pull brushes (#2554)
Browse files Browse the repository at this point in the history
- Fixes #2380
  • Loading branch information
Zeranny authored Jan 28, 2024
1 parent b919633 commit 763a497
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public void erosion(
final int by = target.getBlockY();
final int bz = target.getBlockZ();

for (int x = -brushSize, relx = 0; x <= brushSize; x++, relx++) {
for (int x = -brushSize, relx = 0; x <= brushSize && relx < buffer1.getWidth(); x++, relx++) {
int x0 = x + bx;
for (int y = -brushSize, rely = 0; y <= brushSize; y++, rely++) {
for (int y = -brushSize, rely = 0; y <= brushSize && rely < buffer1.getHeight(); y++, rely++) {
int y0 = y + by;
for (int z = -brushSize, relz = 0; z <= brushSize; z++, relz++) {
for (int z = -brushSize, relz = 0; z <= brushSize && relz < buffer1.getLength(); z++, relz++) {
int z0 = z + bz;
BlockState state = es.getBlock(x0, y0, z0);
buffer1.setBlock(relx, rely, relz, state);
Expand Down Expand Up @@ -115,11 +115,11 @@ private void fillIteration(
Clipboard current, Clipboard target
) {
int[] frequency = null;
for (int x = -brushSize, relx = 0; x <= brushSize; x++, relx++) {
for (int x = -brushSize, relx = 0; x <= brushSize && relx < target.getWidth(); x++, relx++) {
int x2 = x * x;
for (int z = -brushSize, relz = 0; z <= brushSize; z++, relz++) {
for (int z = -brushSize, relz = 0; z <= brushSize && relz < target.getLength(); z++, relz++) {
int x2y2 = x2 + z * z;
for (int y = -brushSize, rely = 0; y <= brushSize; y++, rely++) {
for (int y = -brushSize, rely = 0; y <= brushSize && rely < target.getHeight(); y++, rely++) {
int cube = x2y2 + y * y;
target.setBlock(relx, rely, relz, current.getBlock(relx, rely, relz));
if (cube >= brushSizeSquared) {
Expand Down Expand Up @@ -166,11 +166,11 @@ private void erosionIteration(
Clipboard current, Clipboard target
) {
int[] frequency = null;
for (int x = -brushSize, relx = 0; x <= brushSize; x++, relx++) {
for (int x = -brushSize, relx = 0; x <= brushSize && relx < target.getWidth(); x++, relx++) {
int x2 = x * x;
for (int z = -brushSize, relz = 0; z <= brushSize; z++, relz++) {
for (int z = -brushSize, relz = 0; z <= brushSize && relz < target.getLength(); z++, relz++) {
int x2y2 = x2 + z * z;
for (int y = -brushSize, rely = 0; y <= brushSize; y++, rely++) {
for (int y = -brushSize, rely = 0; y <= brushSize && rely < target.getHeight(); y++, rely++) {
int cube = x2y2 + y * y;
target.setBlock(relx, rely, relz, current.getBlock(relx, rely, relz));
if (cube >= brushSizeSquared) {
Expand Down

0 comments on commit 763a497

Please sign in to comment.