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 BlockData blockData;
public Cuboid cuboid; public Cuboid cuboid;
public double volume() {
return cuboid.getDx() * cuboid.getDy() * cuboid.getDz();
}
static { static {
addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0); addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0);
addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16); addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16);

Datei anzeigen

@ -34,7 +34,13 @@ public class Cuboid {
private double dz; private double dz;
public boolean intersects(Cuboid cuboid) { 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) { public Cuboid add(Point point) {

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -28,7 +28,10 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; 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; import java.util.function.BiPredicate;
public class ExpandingTracesState implements LaufbauState { public class ExpandingTracesState implements LaufbauState {