Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
5d28c33e7c
Commit
9c3560a3ff
@ -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);
|
||||||
|
@ -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) {
|
||||||
|
@ -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;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
|
||||||
|
|
||||||
for (BlockBoundingBox blockDataWithBoundingBox : blockDataWithBoundingBoxList) {
|
if (!preferingBlastResistance) {
|
||||||
if (currentHighest.getDx() < blockDataWithBoundingBox.cuboid.getDx() &&
|
for (BlockBoundingBox blockDataWithBoundingBox : blockDataWithBoundingBoxList) {
|
||||||
currentHighest.getDy() < blockDataWithBoundingBox.cuboid.getDy() &&
|
if (highest.volume() < blockDataWithBoundingBox.volume()) {
|
||||||
currentHighest.getDz() < blockDataWithBoundingBox.cuboid.getDz()) {
|
highest = blockDataWithBoundingBox;
|
||||||
currentHighest = blockDataWithBoundingBox.cuboid;
|
}
|
||||||
highestBlockData = blockDataWithBoundingBox.blockData;
|
if (preferingBlastResistance) {
|
||||||
}
|
if (highest.blockData.getMaterial().getBlastResistance() < blockDataWithBoundingBox.blockData.getMaterial().getBlastResistance()) {
|
||||||
if (preferingBlastResistance) {
|
if (highest.volume() > blockDataWithBoundingBox.volume()) {
|
||||||
if (highestBlockData.getMaterial().getBlastResistance() < blockDataWithBoundingBox.blockData.getMaterial().getBlastResistance() &&
|
highest = blockDataWithBoundingBox;
|
||||||
(currentHighest.getDx() >= blockDataWithBoundingBox.cuboid.getDx() ||
|
}
|
||||||
currentHighest.getDy() >= blockDataWithBoundingBox.cuboid.getDy() ||
|
}
|
||||||
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
|
||||||
|
@ -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 {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren