9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-22 16:49:14 +00:00

Fixed bad math for MAX_HEIGHT and FAST_MAX_HEIGHT.

This commit is contained in:
Vatuu
2022-05-22 03:02:50 +02:00
parent 62f7fc17d1
commit d37b298f07
2 changed files with 26 additions and 27 deletions

View File

@@ -244,12 +244,12 @@ public class Iris extends VolmitPlugin implements Listener {
return f; return f;
} }
public static void warn(String string) { public static void warn(String format, Object... objs) {
msg(C.YELLOW + string); msg(C.YELLOW + String.format(format, objs));
} }
public static void error(String string) { public static void error(String format, Object... objs) {
msg(C.RED + string); msg(C.RED + String.format(format, objs));
} }
public static void debug(String string) { public static void debug(String string) {

View File

@@ -534,19 +534,19 @@ public class IrisObject extends IrisRegistrant {
} else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) { } else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) {
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone(); BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
int x1 = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX();
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) { int x2 = x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX();
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) { for(int i = Math.min(x1, x2); i <= Math.max(x1, x2); i++) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty; int z1 = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ();
int z2 = z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ();
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { for(int ii = Math.min(z1, z2); ii <= Math.max(z1, z2); ii++) {
int h = placer.getHighest(i, ii, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, ii) || placer.isCarved(i, h - 1, ii) || placer.isCarved(i, h - 2, ii) || placer.isCarved(i, h - 3, ii)) {
bail = true; bail = true;
break; break;
} }
if(h > y)
if(h > y) {
y = h; y = h;
}
} }
} }
} else if(config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT)) { } else if(config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT)) {
@@ -571,17 +571,19 @@ public class IrisObject extends IrisRegistrant {
y = rdata.getEngine().getHeight() + 1; y = rdata.getEngine().getHeight() + 1;
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ()); BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone(); BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
int x1 = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX();
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) { int x2 = x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX();
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) { for(int i = Math.min(x1, x2); i <= Math.max(x1, x2); i++) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty; int z1 = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ();
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) { int z2 = z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ();
for(int ii = Math.min(z1, z2); ii <= Math.max(z1, z2); ii++) {
int h = placer.getHighest(i, ii, getLoader(), config.isUnderwater()) + rty;
if(placer.isCarved(i, h, ii) || placer.isCarved(i, h - 1, ii) || placer.isCarved(i, h - 2, ii) || placer.isCarved(i, h - 3, ii)) {
bail = true; bail = true;
break; break;
} }
if(h < y) { if(h < y)
y = h; y = h;
}
} }
} }
} else if(config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT)) { } else if(config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT)) {
@@ -745,6 +747,7 @@ public class IrisObject extends IrisRegistrant {
data = config.getRotation().rotate(data, spinx, spiny, spinz); data = config.getRotation().rotate(data, spinx, spiny, spinz);
xx = x + (int) Math.round(i.getX()); xx = x + (int) Math.round(i.getX());
int yy = y + (int) Math.round(i.getY()); int yy = y + (int) Math.round(i.getY());
zz = z + (int) Math.round(i.getZ()); zz = z + (int) Math.round(i.getZ());
@@ -787,7 +790,6 @@ public class IrisObject extends IrisRegistrant {
if(!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) { if(!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {
placer.set(xx, yy, zz, data); placer.set(xx, yy, zz, data);
if(tile != null) { if(tile != null) {
placer.setTile(xx, yy, zz, tile); placer.setTile(xx, yy, zz, tile);
} }
@@ -852,17 +854,14 @@ public class IrisObject extends IrisRegistrant {
int yg = placer.getHighest(xx, zz, getLoader(), true); int yg = placer.getHighest(xx, zz, getLoader(), true);
if(config.isWaterloggable() && yg <= placer.getFluidHeight() && d instanceof Waterlogged) { if(config.isWaterloggable() && yg <= placer.getFluidHeight() && d instanceof Waterlogged)
((Waterlogged) d).setWaterlogged(true); ((Waterlogged) d).setWaterlogged(true);
}
if(yv >= 0 && config.isBottom()) { if(yv >= 0 && config.isBottom())
y += Math.floorDiv(h, 2); y += Math.floorDiv(h, 2);
}
for(int j = lowest + y; j > yg - config.getOverStilt() - 1; j--) { for(int j = lowest + y; j > yg - config.getOverStilt() - 1; j--)
placer.set(xx, j, zz, d); placer.set(xx, j, zz, d);
}
} }
readLock.unlock(); readLock.unlock();