Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
00cfa1676b
Commit
1a3559b7ac
@ -33,12 +33,16 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.data.Bisected;
|
import org.bukkit.block.data.Bisected;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.type.Campfire;
|
||||||
|
import org.bukkit.block.data.type.Fence;
|
||||||
import org.bukkit.block.data.type.Slab;
|
import org.bukkit.block.data.type.Slab;
|
||||||
import org.bukkit.block.data.type.TrapDoor;
|
import org.bukkit.block.data.type.TrapDoor;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class Laufbau {
|
public class Laufbau {
|
||||||
|
|
||||||
@ -48,31 +52,29 @@ public class Laufbau {
|
|||||||
private static class BlockDataWithBoundingBox {
|
private static class BlockDataWithBoundingBox {
|
||||||
private BlockData blockData;
|
private BlockData blockData;
|
||||||
private Cuboid cuboid;
|
private Cuboid cuboid;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof BlockDataWithBoundingBox)) return false;
|
|
||||||
BlockDataWithBoundingBox that = (BlockDataWithBoundingBox) o;
|
|
||||||
return that.blockData.getClass() == this.blockData.getClass();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private static List<BlockDataWithBoundingBox> elements = new ArrayList<>();
|
||||||
public int hashCode() {
|
|
||||||
return blockData.getClass().hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Set<BlockDataWithBoundingBox> elements = new HashSet<>();
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
elements.add(new BlockDataWithBoundingBox(Material.AIR.createBlockData(), new Cuboid(0, 0, 0, 0, 0, 0)));
|
elements.add(new BlockDataWithBoundingBox(Material.AIR.createBlockData(), new Cuboid(0, 0, 0, 0, 0, 0)));
|
||||||
elements.add(new BlockDataWithBoundingBox(Material.END_STONE.createBlockData(), new Cuboid(0, 0, 0, 1, 1, 1)));
|
elements.add(new BlockDataWithBoundingBox(Material.END_STONE.createBlockData(), new Cuboid(0, 0, 0, 1, 1, 1)));
|
||||||
|
|
||||||
|
BlockData soulSand = Material.SOUL_SAND.createBlockData();
|
||||||
|
elements.add(new BlockDataWithBoundingBox(soulSand, new Cuboid(0, 0, 0, 1, 0.9375, 1)));
|
||||||
|
|
||||||
|
BlockData stoneCutter = Material.STONECUTTER.createBlockData();
|
||||||
|
elements.add(new BlockDataWithBoundingBox(stoneCutter, new Cuboid(0, 0, 0, 1, 0.5625, 1)));
|
||||||
|
|
||||||
Slab bottomSlab = (Slab) Material.END_STONE_BRICK_SLAB.createBlockData();
|
Slab bottomSlab = (Slab) Material.END_STONE_BRICK_SLAB.createBlockData();
|
||||||
bottomSlab.setType(Slab.Type.BOTTOM);
|
bottomSlab.setType(Slab.Type.BOTTOM);
|
||||||
elements.add(new BlockDataWithBoundingBox(bottomSlab, new Cuboid(0, 0, 0, 1, 0.5, 1)));
|
elements.add(new BlockDataWithBoundingBox(bottomSlab, new Cuboid(0, 0, 0, 1, 0.5, 1)));
|
||||||
|
|
||||||
|
Campfire campfire = (Campfire) Material.CAMPFIRE.createBlockData();
|
||||||
|
campfire.setSignalFire(false);
|
||||||
|
campfire.setLit(false);
|
||||||
|
elements.add(new BlockDataWithBoundingBox(campfire, new Cuboid(0, 0, 0, 1, 0.4375, 1)));
|
||||||
|
|
||||||
Slab topSlab = (Slab) Material.END_STONE_BRICK_SLAB.createBlockData();
|
Slab topSlab = (Slab) Material.END_STONE_BRICK_SLAB.createBlockData();
|
||||||
topSlab.setType(Slab.Type.TOP);
|
topSlab.setType(Slab.Type.TOP);
|
||||||
elements.add(new BlockDataWithBoundingBox(topSlab, new Cuboid(0, 0.5, 0, 1, 0.5, 1)));
|
elements.add(new BlockDataWithBoundingBox(topSlab, new Cuboid(0, 0.5, 0, 1, 0.5, 1)));
|
||||||
@ -84,6 +86,15 @@ public class Laufbau {
|
|||||||
TrapDoor topTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
TrapDoor topTrapDoor = (TrapDoor) Material.IRON_TRAPDOOR.createBlockData();
|
||||||
topTrapDoor.setHalf(Bisected.Half.TOP);
|
topTrapDoor.setHalf(Bisected.Half.TOP);
|
||||||
elements.add(new BlockDataWithBoundingBox(topTrapDoor, new Cuboid(0, 0.8125, 0, 1, 0.1875, 1)));
|
elements.add(new BlockDataWithBoundingBox(topTrapDoor, new Cuboid(0, 0.8125, 0, 1, 0.1875, 1)));
|
||||||
|
|
||||||
|
Fence endStoneBrickWall = (Fence) Material.END_STONE_BRICK_WALL.createBlockData();
|
||||||
|
elements.add(new BlockDataWithBoundingBox(endStoneBrickWall, new Cuboid(0.25, 0, 0.25, 0.5, 1.5, 0.5)));
|
||||||
|
|
||||||
|
Fence fence = (Fence) Material.OAK_FENCE.createBlockData();
|
||||||
|
elements.add(new BlockDataWithBoundingBox(fence, new Cuboid(0.375, 0, 0.375, 0.25, 1.5, 0.25)));
|
||||||
|
|
||||||
|
Fence ironBar = (Fence) Material.IRON_BARS.createBlockData();
|
||||||
|
elements.add(new BlockDataWithBoundingBox(ironBar, new Cuboid(0.4375, 0, 0.4375, 0.125, 1, 0.125)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<TNTPosition> tntPositions = new HashSet<>();
|
private Set<TNTPosition> tntPositions = new HashSet<>();
|
||||||
@ -94,41 +105,6 @@ public class Laufbau {
|
|||||||
private Location pos2;
|
private Location pos2;
|
||||||
|
|
||||||
public Laufbau(Location pos1, Location pos2, Material blockMaterial, Material slabMaterial) {
|
public Laufbau(Location pos1, Location pos2, Material blockMaterial, Material slabMaterial) {
|
||||||
if (false) {
|
|
||||||
{
|
|
||||||
Cuboid c1 = new Cuboid(0, 0, 0, 1, 1, 1);
|
|
||||||
System.out.println(c1.intersects(c1));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// FALSE! -> Wrong for now
|
|
||||||
Cuboid c1 = new Cuboid(0, 0, 0, 1, 1, 1);
|
|
||||||
Cuboid c2 = new Cuboid(1, 0, 0, 1, 1, 1);
|
|
||||||
System.out.println(c1.intersects(c2));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// FALSE!
|
|
||||||
Cuboid c1 = new Cuboid(0, 0, 0, 1, 1, 1);
|
|
||||||
Cuboid c2 = new Cuboid(1.1, 0, 0, 1, 1, 1);
|
|
||||||
System.out.println(c1.intersects(c2));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
Cuboid c1 = new Cuboid(0, 0, 0, 3, 3, 3);
|
|
||||||
Cuboid c2 = new Cuboid(1, 1, 1, 1, 1, 1);
|
|
||||||
System.out.println(c1.intersects(c2));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
Cuboid c1 = new Cuboid(0, 0, 0, 3, 1, 3);
|
|
||||||
Cuboid c2 = new Cuboid(0, 0, 1, 1, 1, 3);
|
|
||||||
System.out.println(c1.intersects(c2));
|
|
||||||
}
|
|
||||||
{
|
|
||||||
Cuboid c1 = new Cuboid(0, 0, 0, 3, 1, 3);
|
|
||||||
Cuboid c2 = new Cuboid(0, 0.5, 0, 1, 1, 1);
|
|
||||||
System.out.println(c1.intersects(c2));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.world = pos1.getWorld();
|
this.world = pos1.getWorld();
|
||||||
this.pos1 = new Location(world, Math.min(pos1.getBlockX(), pos2.getBlockX()), Math.min(pos1.getBlockY(), pos2.getBlockY()), Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.pos1 = new Location(world, Math.min(pos1.getBlockX(), pos2.getBlockX()), Math.min(pos1.getBlockY(), pos2.getBlockY()), Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
this.pos2 = new Location(world, Math.max(pos1.getBlockX(), pos2.getBlockX()), Math.max(pos1.getBlockY(), pos2.getBlockY()), Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.pos2 = new Location(world, Math.max(pos1.getBlockX(), pos2.getBlockX()), Math.max(pos1.getBlockY(), pos2.getBlockY()), Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
@ -213,12 +189,11 @@ public class Laufbau {
|
|||||||
return !blockMap3.contains(p1) && !blockMap3.contains(p2) && !blockMap3.contains(p3) && !blockMap3.contains(p4) && !blockMap3.contains(p5) && !blockMap3.contains(p6);
|
return !blockMap3.contains(p1) && !blockMap3.contains(p2) && !blockMap3.contains(p3) && !blockMap3.contains(p4) && !blockMap3.contains(p5) && !blockMap3.contains(p6);
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<Point, BlockDataWithBoundingBox> blockDataMap = new HashMap<>();
|
|
||||||
blockMap3.forEach(point -> {
|
blockMap3.forEach(point -> {
|
||||||
List<BlockDataWithBoundingBox> blockDataWithBoundingBoxList = new ArrayList<>();
|
List<BlockDataWithBoundingBox> blockDataWithBoundingBoxList = new ArrayList<>();
|
||||||
for (BlockDataWithBoundingBox blockDataWithBoundingBox : elements) {
|
for (BlockDataWithBoundingBox blockDataWithBoundingBox : elements) {
|
||||||
Cuboid tempCuboid = blockDataWithBoundingBox.cuboid.add(point);
|
Cuboid tempCuboid = blockDataWithBoundingBox.cuboid.add(point);
|
||||||
// Bukkit.getLogger().log(Level.INFO, tempCuboid.toString());
|
// Bukkit.getLogger().info(tempCuboid.toString());
|
||||||
boolean isInCuboid = false;
|
boolean isInCuboid = false;
|
||||||
for (Cuboid cuboid : cuboidList) {
|
for (Cuboid cuboid : cuboidList) {
|
||||||
if (cuboid.intersects(tempCuboid)) {
|
if (cuboid.intersects(tempCuboid)) {
|
||||||
@ -232,18 +207,27 @@ public class Laufbau {
|
|||||||
if (blockDataWithBoundingBoxList.isEmpty()) {
|
if (blockDataWithBoundingBoxList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (blockDataWithBoundingBoxList.size() == 1) {
|
|
||||||
blockDataMap.put(point, blockDataWithBoundingBoxList.get(0));
|
Cuboid currentHighest = blockDataWithBoundingBoxList.get(0).cuboid;
|
||||||
return;
|
BlockData highestBlockData = blockDataWithBoundingBoxList.get(0).blockData;
|
||||||
|
|
||||||
|
for (BlockDataWithBoundingBox blockDataWithBoundingBox : blockDataWithBoundingBoxList) {
|
||||||
|
if (currentHighest.getDx() < blockDataWithBoundingBox.cuboid.getDx() &&
|
||||||
|
currentHighest.getDy() < blockDataWithBoundingBox.cuboid.getDy() &&
|
||||||
|
currentHighest.getDz() < blockDataWithBoundingBox.cuboid.getDz()) {
|
||||||
|
currentHighest = blockDataWithBoundingBox.cuboid;
|
||||||
|
highestBlockData = blockDataWithBoundingBox.blockData;
|
||||||
}
|
}
|
||||||
Bukkit.getLogger().log(Level.INFO, blockDataWithBoundingBoxList.size() + " " + blockDataWithBoundingBoxList);
|
}
|
||||||
// System.out.println(blockDataWithBoundingBoxList.size() + " " + blockDataWithBoundingBoxList);
|
// blockDataMap.put(point, new BlockDataWithBoundingBox(highestBlockData, currentHighest));
|
||||||
|
Location location = new Location(world, point.getX(), point.getY(), point.getZ());
|
||||||
|
BlockData finalHighestBlockData = highestBlockData;
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
|
player.sendBlockChange(location, finalHighestBlockData);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
System.out.println(blockMap3.size());
|
|
||||||
|
|
||||||
display(blockMap2);
|
display(blockMap2);
|
||||||
// System.out.println(blockMap2);
|
|
||||||
// System.out.println(blockMap2.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(Set<Point> blockMap) {
|
private void display(Set<Point> blockMap) {
|
||||||
@ -321,7 +305,7 @@ public class Laufbau {
|
|||||||
return new Cuboid(nx, ny, nz, dx, dy, dz);
|
return new Cuboid(nx, ny, nz, dx, dy, dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double round(double value) {
|
private static double round(double value) {
|
||||||
value *= 100000000000000L;
|
value *= 100000000000000L;
|
||||||
value = Math.round(value);
|
value = Math.round(value);
|
||||||
value /= 100000000000000L;
|
value /= 100000000000000L;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren