summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorryanbennitt <ryanbennitt@googlemail.com>2016-01-01 14:03:17 +0000
committermd_5 <git@md-5.net>2016-01-03 15:21:05 +1100
commit07c300164aa0318c0064d629ff71247c96731e7c (patch)
tree3fe6c3c629eeed2294b0ddc45a1bb4b496c48c78 /src/main/java/org
parentd3e0b6feadd3d47c440b0d212f3a0962b69f2134 (diff)
downloadcraftbukkit-07c300164aa0318c0064d629ff71247c96731e7c.tar
craftbukkit-07c300164aa0318c0064d629ff71247c96731e7c.tar.gz
craftbukkit-07c300164aa0318c0064d629ff71247c96731e7c.tar.lz
craftbukkit-07c300164aa0318c0064d629ff71247c96731e7c.tar.xz
craftbukkit-07c300164aa0318c0064d629ff71247c96731e7c.zip
SPIGOT-1390: Fixed issues with Array.fill upper bound in setRegion
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
index 438bed8c..01264a7e 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
@@ -97,7 +97,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
if (xMin >= xMax || yMin >= yMax || zMin >= zMax) {
return;
}
- char typeChar = (char) (blockId << 4 | data);
+ char typeChar = (char) ((blockId << 4) | data);
if (xMin == 0 && xMax == 0x10) {
if (zMin == 0 && zMax == 0x10) {
for (int y = yMin & 0xf0; y < yMax; y += 0x10) {
@@ -110,7 +110,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
// First chunk section
Arrays.fill(section, (yMin & 0xf) << 8, 0x1000, typeChar);
}
- } else if (y + 0x10 >= yMax) {
+ } else if (y + 0x10 > yMax) {
// Last chunk section
Arrays.fill(section, 0, (yMax & 0xf) << 8, typeChar);
} else {
@@ -123,7 +123,8 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
char[] section = getChunkSection(y, true);
int offsetBase = (y & 0xf) << 8;
int min = offsetBase | (zMin << 4);
- int max = offsetBase | (zMax << 4);
+ // Need to add zMax as it can be 16, which overlaps the y coordinate bits
+ int max = offsetBase + (zMax << 4);
Arrays.fill(section, min, max, typeChar);
}
}
@@ -132,8 +133,9 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
char[] section = getChunkSection(y, true);
int offsetBase = (y & 0xf) << 8;
for (int z = zMin; z < zMax; z++) {
- int offset = offsetBase | z << 4;
- Arrays.fill(section, offset | xMin, offset | xMax, typeChar);
+ int offset = offsetBase | (z << 4);
+ // Need to add xMax as it can be 16, which overlaps the z coordinate bits
+ Arrays.fill(section, offset | xMin, offset + xMax, typeChar);
}
}
}