SteamWar/BauSystem2.0
Archiviert
12
0

Update Laufbau
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-02-05 18:29:58 +01:00
Ursprung 8f06dcfc85
Commit b04ab92a78
7 geänderte Dateien mit 123 neuen und 100 gelöschten Zeilen

Datei anzeigen

@ -46,21 +46,6 @@ public class BlockBoundingBox {
addPixel(Material.GRASS_PATH.createBlockData(), 0, 0, 0, 16, 15, 16); addPixel(Material.GRASS_PATH.createBlockData(), 0, 0, 0, 16, 15, 16);
addPixel(Material.SOUL_SAND.createBlockData(), 0, 0, 0, 16, 14, 16); addPixel(Material.SOUL_SAND.createBlockData(), 0, 0, 0, 16, 14, 16);
addPixel(Material.HONEY_BLOCK.createBlockData(), 1, 0, 1, 14, 15, 14);
Grindstone floorGrindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
floorGrindstone.setAttachedFace(FaceAttachable.AttachedFace.FLOOR);
addPixel(floorGrindstone, 2, 0, 2, 12, 16, 12);
Grindstone northSouthGrindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
northSouthGrindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
northSouthGrindstone.setFacing(BlockFace.NORTH);
addPixel(northSouthGrindstone, 2, 2, 0, 12, 12, 16);
Grindstone eastWestGrindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
eastWestGrindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
eastWestGrindstone.setFacing(BlockFace.EAST);
addPixel(eastWestGrindstone, 0, 2, 2, 16, 12, 12);
Hopper hopper = (Hopper) Material.HOPPER.createBlockData(); Hopper hopper = (Hopper) Material.HOPPER.createBlockData();
hopper.setFacing(BlockFace.NORTH); hopper.setFacing(BlockFace.NORTH);
@ -96,48 +81,19 @@ public class BlockBoundingBox {
doubleTurtleEgg.setHatch(0); doubleTurtleEgg.setHatch(0);
addPixel(doubleTurtleEgg, 1, 0, 1, 14, 7, 14); addPixel(doubleTurtleEgg, 1, 0, 1, 14, 7, 14);
Bell doubleAttachedBellEast = (Bell) Material.BELL.createBlockData(); Grindstone floorGrindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
doubleAttachedBellEast.setAttachment(Bell.Attachment.DOUBLE_WALL); floorGrindstone.setAttachedFace(FaceAttachable.AttachedFace.FLOOR);
doubleAttachedBellEast.setFacing(BlockFace.EAST); addPixel(floorGrindstone, 2, 0, 2, 12, 16, 12);
addPixel(doubleAttachedBellEast, 0, 4, 4, 16, 11, 8);
Bell doubleAttachedBellNorth = (Bell) Material.BELL.createBlockData(); Grindstone northSouthGrindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
doubleAttachedBellNorth.setAttachment(Bell.Attachment.DOUBLE_WALL); northSouthGrindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
doubleAttachedBellNorth.setFacing(BlockFace.NORTH); northSouthGrindstone.setFacing(BlockFace.NORTH);
addPixel(doubleAttachedBellNorth, 4, 4, 0, 8, 11, 16); addPixel(northSouthGrindstone, 2, 2, 0, 12, 12, 16);
Bell floorBellNorth = (Bell) Material.BELL.createBlockData(); Grindstone eastWestGrindstone = (Grindstone) Material.GRINDSTONE.createBlockData();
floorBellNorth.setAttachment(Bell.Attachment.FLOOR); eastWestGrindstone.setAttachedFace(FaceAttachable.AttachedFace.WALL);
addPixel(floorBellNorth, 0, 0, 4, 16, 16, 8); eastWestGrindstone.setFacing(BlockFace.EAST);
addPixel(eastWestGrindstone, 0, 2, 2, 16, 12, 12);
Bell floorBellEast = (Bell) Material.BELL.createBlockData();
floorBellEast.setAttachment(Bell.Attachment.FLOOR);
floorBellEast.setFacing(BlockFace.EAST);
addPixel(floorBellEast, 4, 0, 0, 8, 16, 16);
Bell ceilingBell = (Bell) Material.BELL.createBlockData();
ceilingBell.setAttachment(Bell.Attachment.CEILING);
addPixel(ceilingBell, 4, 4, 4, 8, 12, 8);
Bell singleAttachedBellNorth = (Bell) Material.BELL.createBlockData();
singleAttachedBellNorth.setAttachment(Bell.Attachment.SINGLE_WALL);
singleAttachedBellNorth.setFacing(BlockFace.NORTH);
addPixel(singleAttachedBellNorth, 4, 4, 0, 8, 11, 13);
Bell singleAttachedBellSouth = (Bell) Material.BELL.createBlockData();
singleAttachedBellSouth.setAttachment(Bell.Attachment.SINGLE_WALL);
singleAttachedBellSouth.setFacing(BlockFace.SOUTH);
addPixel(singleAttachedBellSouth, 4, 4, 3, 8, 11, 13);
Bell singleAttachedBellWest = (Bell) Material.BELL.createBlockData();
singleAttachedBellWest.setAttachment(Bell.Attachment.SINGLE_WALL);
singleAttachedBellWest.setFacing(BlockFace.WEST);
addPixel(singleAttachedBellWest, 0, 4, 4, 13, 11, 8);
Bell singleAttachedBellEast = (Bell) Material.BELL.createBlockData();
singleAttachedBellEast.setAttachment(Bell.Attachment.SINGLE_WALL);
singleAttachedBellEast.setFacing(BlockFace.EAST);
addPixel(singleAttachedBellEast, 3, 4, 4, 13, 11, 8);
addPixel(Material.CHEST.createBlockData(), 1, 0, 1, 14, 14, 14); addPixel(Material.CHEST.createBlockData(), 1, 0, 1, 14, 14, 14);
@ -210,6 +166,49 @@ public class BlockBoundingBox {
singleSeaPickle.setPickles(1); singleSeaPickle.setPickles(1);
addPixel(singleSeaPickle, 6, 0, 6, 4, 6, 4); addPixel(singleSeaPickle, 6, 0, 6, 4, 6, 4);
Bell doubleAttachedBellEast = (Bell) Material.BELL.createBlockData();
doubleAttachedBellEast.setAttachment(Bell.Attachment.DOUBLE_WALL);
doubleAttachedBellEast.setFacing(BlockFace.EAST);
addPixel(doubleAttachedBellEast, 0, 4, 4, 16, 11, 8);
Bell doubleAttachedBellNorth = (Bell) Material.BELL.createBlockData();
doubleAttachedBellNorth.setAttachment(Bell.Attachment.DOUBLE_WALL);
doubleAttachedBellNorth.setFacing(BlockFace.NORTH);
addPixel(doubleAttachedBellNorth, 4, 4, 0, 8, 11, 16);
Bell floorBellNorth = (Bell) Material.BELL.createBlockData();
floorBellNorth.setAttachment(Bell.Attachment.FLOOR);
addPixel(floorBellNorth, 0, 0, 4, 16, 16, 8);
Bell floorBellEast = (Bell) Material.BELL.createBlockData();
floorBellEast.setAttachment(Bell.Attachment.FLOOR);
floorBellEast.setFacing(BlockFace.EAST);
addPixel(floorBellEast, 4, 0, 0, 8, 16, 16);
Bell ceilingBell = (Bell) Material.BELL.createBlockData();
ceilingBell.setAttachment(Bell.Attachment.CEILING);
addPixel(ceilingBell, 4, 4, 4, 8, 12, 8);
Bell singleAttachedBellNorth = (Bell) Material.BELL.createBlockData();
singleAttachedBellNorth.setAttachment(Bell.Attachment.SINGLE_WALL);
singleAttachedBellNorth.setFacing(BlockFace.NORTH);
addPixel(singleAttachedBellNorth, 4, 4, 0, 8, 11, 13);
Bell singleAttachedBellSouth = (Bell) Material.BELL.createBlockData();
singleAttachedBellSouth.setAttachment(Bell.Attachment.SINGLE_WALL);
singleAttachedBellSouth.setFacing(BlockFace.SOUTH);
addPixel(singleAttachedBellSouth, 4, 4, 3, 8, 11, 13);
Bell singleAttachedBellWest = (Bell) Material.BELL.createBlockData();
singleAttachedBellWest.setAttachment(Bell.Attachment.SINGLE_WALL);
singleAttachedBellWest.setFacing(BlockFace.WEST);
addPixel(singleAttachedBellWest, 0, 4, 4, 13, 11, 8);
Bell singleAttachedBellEast = (Bell) Material.BELL.createBlockData();
singleAttachedBellEast.setAttachment(Bell.Attachment.SINGLE_WALL);
singleAttachedBellEast.setFacing(BlockFace.EAST);
addPixel(singleAttachedBellEast, 3, 4, 4, 13, 11, 8);
addPixel(Material.FLOWER_POT.createBlockData(), 5, 0, 5, 6, 6, 6); addPixel(Material.FLOWER_POT.createBlockData(), 5, 0, 5, 6, 6, 6);
addPixel(Material.DAYLIGHT_DETECTOR.createBlockData(), 0, 0, 0, 16, 6, 16); addPixel(Material.DAYLIGHT_DETECTOR.createBlockData(), 0, 0, 0, 16, 6, 16);
@ -230,6 +229,7 @@ public class BlockBoundingBox {
snowLayers2.setLayers(2); snowLayers2.setLayers(2);
addPixel(snowLayers2, 0, 0, 0, 16, 2, 16); addPixel(snowLayers2, 0, 0, 0, 16, 2, 16);
addPixel(Material.LILY_PAD.createBlockData(), 1, 0, 1, 14, 1.5, 14);
addPixel(Material.WHITE_CARPET.createBlockData(), 0, 0, 0, 16, 1, 16); addPixel(Material.WHITE_CARPET.createBlockData(), 0, 0, 0, 16, 1, 16);
Directional endRodBottomTop = (Directional) Material.END_ROD.createBlockData(); Directional endRodBottomTop = (Directional) Material.END_ROD.createBlockData();

Datei anzeigen

@ -34,47 +34,18 @@ public class Cuboid {
private double dz; private double dz;
public boolean intersects(Cuboid cuboid) { public boolean intersects(Cuboid cuboid) {
Cuboid helpCuboid = helpIntersect(cuboid); return expand(cuboid).hasInside(cuboid);
Cuboid c1 = helpIntersect(helpCuboid);
Cuboid c2 = cuboid.helpIntersect(c1);
if (c1.dx == 0 && c2.dx == 0) {
return false;
}
if (c1.dy == 0 && c2.dy == 0) {
return false;
}
if (c1.dz == 0 && c2.dz == 0) {
return false;
}
return c1.equals(c2);
}
private Cuboid helpIntersect(Cuboid cuboid) {
double minX = Math.max(x, cuboid.x);
double minY = Math.max(y, cuboid.y);
double minZ = Math.max(z, cuboid.z);
double maxX = Math.min(x + dx, cuboid.x + cuboid.dx);
double maxY = Math.min(y + dy, cuboid.y + cuboid.dy);
double maxZ = Math.min(z + dz, cuboid.z + cuboid.dz);
double nx = round(Math.min(minX, maxX));
double ny = round(Math.min(minY, maxY));
double nz = round(Math.min(minZ, maxZ));
double dx = round(Math.max(minX, maxX) - nx);
double dy = round(Math.max(minY, maxY) - ny);
double dz = round(Math.max(minZ, maxZ) - nz);
return new Cuboid(nx, ny, nz, dx, dy, dz);
}
private static double round(double value) {
value *= 100000000000000L;
value = Math.round(value);
value /= 100000000000000L;
return value;
} }
public Cuboid add(Point point) { public Cuboid add(Point point) {
return new Cuboid(x + point.getX(), y + point.getY(), z + point.getZ(), dx, dy, dz); return new Cuboid(x + point.getX(), y + point.getY(), z + point.getZ(), dx, dy, dz);
} }
public Cuboid expand(Cuboid cuboid) {
return new Cuboid(x - cuboid.dx, y - cuboid.dy, z - cuboid.dz, dx + cuboid.dx, dy + cuboid.dy, dz + cuboid.dz);
}
public boolean hasInside(Cuboid cuboid) {
return x <= cuboid.x && x + dx >= cuboid.x && y <= cuboid.y && y + dy >= cuboid.y && z <= cuboid.z && z + dz >= cuboid.z;
}
} }

Datei anzeigen

@ -19,7 +19,10 @@
package de.steamwar.bausystem.features.slaves.laufbau; package de.steamwar.bausystem.features.slaves.laufbau;
import com.sk89q.worldedit.EditSession;
import de.steamwar.bausystem.features.slaves.WorldEditUtils;
import de.steamwar.bausystem.features.slaves.laufbau.states.*; import de.steamwar.bausystem.features.slaves.laufbau.states.*;
import lombok.Getter;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -41,6 +44,9 @@ public class Laufbau {
private CreatingInnerBlocksState creatingInnerBlocksState = null; private CreatingInnerBlocksState creatingInnerBlocksState = null;
private CreatingOuterBlocksState creatingOuterBlocksState = null; private CreatingOuterBlocksState creatingOuterBlocksState = null;
@Getter
private EditSession editSession;
public Laufbau(Location pos1, Location pos2, boolean preferingBlastResistance) { public Laufbau(Location pos1, Location pos2, boolean preferingBlastResistance) {
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()));
@ -49,6 +55,8 @@ public class Laufbau {
this.preferingBlastResistance = preferingBlastResistance; this.preferingBlastResistance = preferingBlastResistance;
filteringTracesState = new FilteringTracesState(world, this::inRegion); filteringTracesState = new FilteringTracesState(world, this::inRegion);
editSession = WorldEditUtils.getEditSession(world);
} }
private LaufbauState getActive() { private LaufbauState getActive() {
@ -78,11 +86,11 @@ public class Laufbau {
return; return;
} }
if (creatingInnerBlocksState != null) { if (creatingInnerBlocksState != null) {
creatingOuterBlocksState = new CreatingOuterBlocksState(shrinkingOuterPointsState.getShrunkOuterPoints(), world); creatingOuterBlocksState = new CreatingOuterBlocksState(shrinkingOuterPointsState.getShrunkOuterPoints(), world, editSession);
return; return;
} }
if (shrinkingOuterPointsState != null) { if (shrinkingOuterPointsState != null) {
creatingInnerBlocksState = new CreatingInnerBlocksState(splittingPointsState.getInnerPoints(), world, processingTracesState.getCuboidList(), splittingPointsState.getIntersectedCuboid(), preferingBlastResistance); creatingInnerBlocksState = new CreatingInnerBlocksState(splittingPointsState.getInnerPoints(), world, processingTracesState.getCuboidList(), splittingPointsState.getIntersectedCuboid(), editSession, preferingBlastResistance);
return; return;
} }
if (splittingPointsState != null) { if (splittingPointsState != null) {

Datei anzeigen

@ -80,6 +80,7 @@ public class LaufbauCommand extends SWCommand {
while (true) { while (true) {
if (!laufbau.hasNext()) { if (!laufbau.hasNext()) {
BauSystem.MESSAGE.send("LAUFBAU_DONE", player); BauSystem.MESSAGE.send("LAUFBAU_DONE", player);
WorldEditUtils.addToPlayer(player, laufbau.getEditSession());
cancel(); cancel();
return; return;
} }

Datei anzeigen

@ -19,11 +19,13 @@
package de.steamwar.bausystem.features.slaves.laufbau.states; package de.steamwar.bausystem.features.slaves.laufbau.states;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Point;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@ -41,13 +43,15 @@ public class CreatingInnerBlocksState implements LaufbauState {
private World world; private World world;
private List<Cuboid> cuboidList; private List<Cuboid> cuboidList;
private Map<Point, List<Cuboid>> intersectedCuboid; private Map<Point, List<Cuboid>> intersectedCuboid;
private EditSession editSession;
private boolean preferingBlastResistance; private boolean preferingBlastResistance;
public CreatingInnerBlocksState(List<Point> innerBlocks, World world, List<Cuboid> cuboidList, Map<Point, List<Cuboid>> intersectedCuboid, boolean preferingBlastResistance) { public CreatingInnerBlocksState(List<Point> innerBlocks, World world, List<Cuboid> cuboidList, Map<Point, List<Cuboid>> intersectedCuboid, EditSession editSession, boolean preferingBlastResistance) {
this.innerBlocks = innerBlocks; this.innerBlocks = innerBlocks;
this.world = world; this.world = world;
this.cuboidList = cuboidList; this.cuboidList = cuboidList;
this.intersectedCuboid = intersectedCuboid; this.intersectedCuboid = intersectedCuboid;
this.editSession = editSession;
this.preferingBlastResistance = preferingBlastResistance; this.preferingBlastResistance = preferingBlastResistance;
} }
@ -112,9 +116,21 @@ public class CreatingInnerBlocksState implements LaufbauState {
} }
} }
Location location = new Location(world, point.getX(), point.getY(), point.getZ()); Location location = new Location(world, point.getX(), point.getY(), point.getZ());
if (!location.getBlock().getType().isAir()) {
return;
}
try {
editSession.setBlock(BukkitAdapter.asBlockVector(location), BukkitAdapter.adapt(highestBlockData));
location.getBlock().setBlockData(highestBlockData, false);
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
// ignored
}
/*
BlockData finalHighestBlockData = highestBlockData; BlockData finalHighestBlockData = highestBlockData;
Bukkit.getOnlinePlayers().forEach(player -> { Bukkit.getOnlinePlayers().forEach(player -> {
player.sendBlockChange(location, finalHighestBlockData); player.sendBlockChange(location, finalHighestBlockData);
}); });
*/
} }
} }

Datei anzeigen

@ -19,6 +19,11 @@
package de.steamwar.bausystem.features.slaves.laufbau.states; package de.steamwar.bausystem.features.slaves.laufbau.states;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Point;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -32,14 +37,22 @@ import java.util.List;
public class CreatingOuterBlocksState implements LaufbauState { public class CreatingOuterBlocksState implements LaufbauState {
private static final BaseBlock STONE;
static {
STONE = BlockTypes.get("minecraft:stone").getDefaultState().toBaseBlock();
}
private List<Point> outerBlocks; private List<Point> outerBlocks;
private int index = 0; private int index = 0;
private World world; private World world;
private EditSession editSession;
public CreatingOuterBlocksState(List<Point> outerBlocks, World world) { public CreatingOuterBlocksState(List<Point> outerBlocks, World world, EditSession editSession) {
this.outerBlocks = outerBlocks; this.outerBlocks = outerBlocks;
this.world = world; this.world = world;
this.editSession = editSession;
} }
@Override @Override
@ -57,10 +70,22 @@ public class CreatingOuterBlocksState implements LaufbauState {
Point point = outerBlocks.get(index); Point point = outerBlocks.get(index);
index++; index++;
BlockData fullBlock = Material.STONE.createBlockData();
Location location = new Location(world, point.getX(), point.getY(), point.getZ()); Location location = new Location(world, point.getX(), point.getY(), point.getZ());
if (!location.getBlock().getType().isAir()) {
return;
}
try {
editSession.setBlock(BukkitAdapter.asBlockVector(location), STONE);
location.getBlock().setType(Material.STONE, false);
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
// ingored
}
/*
BlockData fullBlock = Material.STONE.createBlockData();
Bukkit.getOnlinePlayers().forEach(player -> { Bukkit.getOnlinePlayers().forEach(player -> {
player.sendBlockChange(location, fullBlock); player.sendBlockChange(location, fullBlock);
}); });
*/
} }
} }

Datei anzeigen

@ -29,6 +29,8 @@ import java.util.*;
public class SplittingPointsState implements LaufbauState { public class SplittingPointsState implements LaufbauState {
private static final Cuboid ONE = new Cuboid(0, 0, 0, 1, 1, 1);
private List<Point> blocks; private List<Point> blocks;
private int totalBlocks; private int totalBlocks;
private List<Cuboid> cuboidList; private List<Cuboid> cuboidList;
@ -62,7 +64,7 @@ public class SplittingPointsState implements LaufbauState {
public void next() { public void next() {
Point point = blocks.remove(0); Point point = blocks.remove(0);
boolean isInCuboid = false; boolean isInCuboid = false;
Cuboid tempCuboid = new Cuboid(0, 0, 0, 1, 1, 1).add(point); Cuboid tempCuboid = ONE.add(point);
List<Cuboid> intersectedCuboids = new ArrayList<>(); List<Cuboid> intersectedCuboids = new ArrayList<>();
for (Cuboid cuboid : cuboidList) { for (Cuboid cuboid : cuboidList) {
if (cuboid.intersects(tempCuboid)) { if (cuboid.intersects(tempCuboid)) {