SteamWar/BauSystem2.0
Archiviert
12
0

Update blast resistance mode
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-02-06 13:29:25 +01:00
Ursprung 5d28c33e7c
Commit 9c3560a3ff
5 geänderte Dateien mit 35 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -40,6 +40,10 @@ public class BlockBoundingBox {
public BlockData blockData;
public Cuboid cuboid;
public double volume() {
return cuboid.getDx() * cuboid.getDy() * cuboid.getDz();
}
static {
addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0);
addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16);

Datei anzeigen

@ -34,7 +34,13 @@ public class Cuboid {
private double dz;
public boolean intersects(Cuboid cuboid) {
return expand(cuboid).hasInside(cuboid);
double minx = x - cuboid.dx;
double miny = y - cuboid.dy;
double minz = z - cuboid.dz;
double maxx = minx + dx + cuboid.dx;
double maxy = miny + dy + cuboid.dy;
double maxz = minz + dz + cuboid.dz;
return maxx > cuboid.x && maxy > cuboid.y && maxz > cuboid.z && minx < cuboid.x && miny < cuboid.y && minz < cuboid.z;
}
public Cuboid add(Point point) {

Datei anzeigen

@ -65,20 +65,13 @@ public class Laufbau {
editSession = WorldEditUtils.getEditSession(world);
if (preferingBlastResistance) {
elements.sort(Comparator.comparing(blockBoundingBox -> {
double element = 1;
if (blockBoundingBox.cuboid.getDx() != 0) {
element *= blockBoundingBox.cuboid.getDx();
elements.sort((o1, o2) -> {
int compared = Double.compare(o1.blockData.getMaterial().getBlastResistance(), o2.blockData.getMaterial().getBlastResistance());
if (compared != 0) {
return -compared;
}
if (blockBoundingBox.cuboid.getDy() != 0) {
element *= blockBoundingBox.cuboid.getDy();
}
if (blockBoundingBox.cuboid.getDz() != 0) {
element *= blockBoundingBox.cuboid.getDz();
}
element *= blockBoundingBox.blockData.getMaterial().getBlastResistance();
return -element;
}));
return -Double.compare(o1.volume(), o2.volume());
});
}
}

Datei anzeigen

@ -95,23 +95,19 @@ public class CreatingInnerBlocksState implements LaufbauState {
return;
}
Cuboid currentHighest = blockDataWithBoundingBoxList.get(0).cuboid;
BlockData highestBlockData = blockDataWithBoundingBoxList.get(0).blockData;
BlockBoundingBox highest = blockDataWithBoundingBoxList.get(0);
for (BlockBoundingBox blockDataWithBoundingBox : blockDataWithBoundingBoxList) {
if (currentHighest.getDx() < blockDataWithBoundingBox.cuboid.getDx() &&
currentHighest.getDy() < blockDataWithBoundingBox.cuboid.getDy() &&
currentHighest.getDz() < blockDataWithBoundingBox.cuboid.getDz()) {
currentHighest = blockDataWithBoundingBox.cuboid;
highestBlockData = blockDataWithBoundingBox.blockData;
}
if (preferingBlastResistance) {
if (highestBlockData.getMaterial().getBlastResistance() < blockDataWithBoundingBox.blockData.getMaterial().getBlastResistance() &&
(currentHighest.getDx() >= blockDataWithBoundingBox.cuboid.getDx() ||
currentHighest.getDy() >= blockDataWithBoundingBox.cuboid.getDy() ||
currentHighest.getDz() >= blockDataWithBoundingBox.cuboid.getDz())) {
currentHighest = blockDataWithBoundingBox.cuboid;
highestBlockData = blockDataWithBoundingBox.blockData;
if (!preferingBlastResistance) {
for (BlockBoundingBox blockDataWithBoundingBox : blockDataWithBoundingBoxList) {
if (highest.volume() < blockDataWithBoundingBox.volume()) {
highest = blockDataWithBoundingBox;
}
if (preferingBlastResistance) {
if (highest.blockData.getMaterial().getBlastResistance() < blockDataWithBoundingBox.blockData.getMaterial().getBlastResistance()) {
if (highest.volume() > blockDataWithBoundingBox.volume()) {
highest = blockDataWithBoundingBox;
}
}
}
}
}
@ -120,8 +116,8 @@ public class CreatingInnerBlocksState implements LaufbauState {
return;
}
try {
editSession.setBlock(BukkitAdapter.asBlockVector(location), BukkitAdapter.adapt(highestBlockData));
location.getBlock().setBlockData(highestBlockData, false);
editSession.setBlock(BukkitAdapter.asBlockVector(location), BukkitAdapter.adapt(highest.blockData));
location.getBlock().setBlockData(highest.blockData, false);
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
// ignored

Datei anzeigen

@ -28,7 +28,10 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.BiPredicate;
public class ExpandingTracesState implements LaufbauState {