forked from SteamWar/SteamWar
Update VariantSelector and implement Database Folder for Schematics
This commit is contained in:
@@ -26,19 +26,19 @@ import lombok.RequiredArgsConstructor;
|
||||
@Getter
|
||||
public enum RegionType {
|
||||
|
||||
GLOBAL(ConnectionType.Global),
|
||||
GLOBAL(ConnectionType.Void),
|
||||
/**
|
||||
* This should not be used by the DynamicRegionSystem
|
||||
*/
|
||||
NORMAL(ConnectionType.Closed),
|
||||
NORMAL(ConnectionType.Plot),
|
||||
|
||||
SPAWN(ConnectionType.Closed),
|
||||
SPAWN(ConnectionType.Plot),
|
||||
SPAWN_PATH(ConnectionType.Path),
|
||||
SPAWN_EXTENSION(ConnectionType.Closed),
|
||||
SPAWN_EXTENSION(ConnectionType.Plot),
|
||||
PATH(ConnectionType.Path),
|
||||
|
||||
DRY(ConnectionType.Closed),
|
||||
DRY_SPECIAL(ConnectionType.Closed),
|
||||
DRY(ConnectionType.Void),
|
||||
DRY_SPECIAL(ConnectionType.Plot),
|
||||
WET(ConnectionType.Water),
|
||||
WET_SPECIAL(ConnectionType.Water),
|
||||
;
|
||||
@@ -66,10 +66,10 @@ public enum RegionType {
|
||||
}
|
||||
|
||||
public enum ConnectionType {
|
||||
Closed,
|
||||
Plot,
|
||||
Path,
|
||||
Water,
|
||||
Global,
|
||||
Void,
|
||||
Garden,
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -99,7 +99,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
moveInteractionEntities(Point.fromLocation(player.getLocation()));
|
||||
|
||||
CArea area = new CArea(entityServer);
|
||||
area.setPos1And2(new Location(null, -Tile.maxTile, 1, -Tile.maxTile), new Location(null, Tile.maxTile, 1, Tile.maxTile));
|
||||
area.setPos1And2(new Location(null, -Tile.maxTile, 51, -Tile.maxTile), new Location(null, Tile.maxTile, 51, Tile.maxTile));
|
||||
area.setBlock(Material.BEDROCK.createBlockData());
|
||||
|
||||
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::showHotbar, 0, 20);
|
||||
@@ -141,7 +141,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
List<RInteraction> interactionList = entityServer.getEntitiesByType(RInteraction.class);
|
||||
for (int x = -5; x <= 5; x++) {
|
||||
for (int z = -5; z <= 5; z++) {
|
||||
interactionList.removeFirst().move(position.getX() + x + 0.5, 0, position.getZ() + z + 0.5, 0, 0, (byte) 0);
|
||||
interactionList.removeFirst().move(position.getX() + x + 0.5, 50, position.getZ() + z + 0.5, 0, 0, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
for (RInteraction interaction : entityServer.getEntitiesByType(RInteraction.class)) {
|
||||
float x = (float) (interaction.getX() - 0.5);
|
||||
float z = (float) (interaction.getZ() - 0.5);
|
||||
if (intersection.test(x, (float) 0.95, z, x + 1, (float) 1.05, z + 1)) {
|
||||
if (intersection.test(x, (float) 50.95, z, x + 1, (float) 51.05, z + 1)) {
|
||||
int tileX = (int) x;
|
||||
int tileZ = (int) z;
|
||||
if (type.visualize(area, tileX, tileZ)) {
|
||||
@@ -216,7 +216,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
for (RInteraction interaction : entityServer.getEntitiesByType(RInteraction.class)) {
|
||||
float x = (float) (interaction.getX() - 0.5);
|
||||
float z = (float) (interaction.getZ() - 0.5);
|
||||
if (intersection.test(x, (float) 0.95, z, x + 1, (float) 1.05, z + 1)) {
|
||||
if (intersection.test(x, (float) 50.95, z, x + 1, (float) 51.05, z + 1)) {
|
||||
int tileX = (int) x;
|
||||
int tileZ = (int) z;
|
||||
type.run(event.getPlayer(), tileX, tileZ);
|
||||
@@ -318,8 +318,8 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
}
|
||||
|
||||
private boolean selectSpawn(CArea area) {
|
||||
Location minLoc = new Location(null, -1, 1, -1);
|
||||
Location maxLoc = new Location(null, 1, 1, 1);
|
||||
Location minLoc = new Location(null, -1, 51, -1);
|
||||
Location maxLoc = new Location(null, 1, 51, 1);
|
||||
area.setBlock(DELETE);
|
||||
area.setPos1And2(minLoc, maxLoc);
|
||||
valid = true;
|
||||
@@ -333,8 +333,8 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
valid = false;
|
||||
return false;
|
||||
}
|
||||
Location minLoc = new Location(null, minTile.getTileX(), 1, minTile.getTileZ());
|
||||
Location maxLoc = new Location(null, maxTile.getTileX(), 1, maxTile.getTileZ());
|
||||
Location minLoc = new Location(null, minTile.getTileX(), 51, minTile.getTileZ());
|
||||
Location maxLoc = new Location(null, maxTile.getTileX(), 51, maxTile.getTileZ());
|
||||
area.setBlock(DELETE);
|
||||
area.setPos1And2(minLoc, maxLoc);
|
||||
valid = true;
|
||||
@@ -496,7 +496,7 @@ public class DynamicRegionEditor implements SWPlayer.Component, Listener {
|
||||
area.setBlock(INVALID);
|
||||
valid = false;
|
||||
}
|
||||
area.setPos1And2(new Location(null, tileX, 1, tileZ), new Location(null, tileX + widthX, 1, tileZ + widthZ));
|
||||
area.setPos1And2(new Location(null, tileX, 51, tileZ), new Location(null, tileX + widthX, 51, tileZ + widthZ));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ public class DynamicRegionVisualizer implements SWPlayer.Component {
|
||||
private final REntityServer entityServer = new REntityServer();
|
||||
|
||||
private DynamicRegionVisualizer() {
|
||||
RTextDisplay text = new RTextDisplay(entityServer, new Location(null, 0.5, 1.1, 0.5));
|
||||
RTextDisplay text = new RTextDisplay(entityServer, new Location(null, 0.5, 51.1, 0.5));
|
||||
text.setText("Spawn");
|
||||
text.setBillboard(Display.Billboard.VERTICAL);
|
||||
text.setBackgroundColor(0);
|
||||
@@ -73,7 +73,7 @@ public class DynamicRegionVisualizer implements SWPlayer.Component {
|
||||
|
||||
public static Point toVisualization(Location worldLocation) {
|
||||
Tile tile = Tile.fromLocation(worldLocation).orElseThrow();
|
||||
return new Point(tile.getTileX(), 0, tile.getTileZ());
|
||||
return new Point(tile.getTileX(), 50, tile.getTileZ());
|
||||
}
|
||||
|
||||
private static class CRegion extends CEntity {
|
||||
@@ -96,7 +96,7 @@ public class DynamicRegionVisualizer implements SWPlayer.Component {
|
||||
area.setPos1And2(point.toLocation((World) null).add(0, 1 - CArea.DEFAULT_WIDTH, 0), point.toLocation((World) null).add(widthX - 1, 1 - CArea.DEFAULT_WIDTH, widthZ - 1));
|
||||
entities.add(area);
|
||||
|
||||
RTextDisplay text = new RTextDisplay(server, point.toLocation((World) null).add(widthX / 2.0, 1.1, widthZ / 2.0));
|
||||
RTextDisplay text = new RTextDisplay(server, point.toLocation((World) null).add(widthX / 2.0, 51.1, widthZ / 2.0));
|
||||
text.setText(data.name());
|
||||
text.setBillboard(Display.Billboard.VERTICAL);
|
||||
text.setBackgroundColor(0);
|
||||
|
||||
+18
-3
@@ -29,10 +29,13 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@UtilityClass
|
||||
public class PasteUtils {
|
||||
@@ -52,11 +55,23 @@ public class PasteUtils {
|
||||
|
||||
public static EditSession paste(File file, Point minPoint, int rotate) {
|
||||
try (Clipboard clipboard = FlatteningWrapper.impl.loadSchematic(file)) {
|
||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
BlockVector3 to = minPoint.toBlockVector3().subtract(offset);
|
||||
return clipboard.paste(BukkitAdapter.adapt(Bukkit.getWorlds().get(0)), to, false, true, new AffineTransform().rotateY(rotate));
|
||||
return paste(clipboard, minPoint, rotate);
|
||||
} catch (SecurityException exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static EditSession paste(SchematicNode schematic, Point minPoint, int rotate) {
|
||||
try (Clipboard clipboard = new SchematicData(schematic).load()) {
|
||||
return paste(clipboard, minPoint, rotate);
|
||||
} catch (SecurityException | IOException exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static EditSession paste(Clipboard clipboard, Point minPoint, int rotate) {
|
||||
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
|
||||
BlockVector3 to = minPoint.toBlockVector3().subtract(offset);
|
||||
return clipboard.paste(BukkitAdapter.adapt(Bukkit.getWorlds().get(0)), to, false, true, new AffineTransform().rotateY(rotate));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,10 @@ public class Tile {
|
||||
return new Location(null, getMinX(tileX), 0, getMinZ(tileZ));
|
||||
}
|
||||
|
||||
public Point getMinPoint() {
|
||||
return new Point(getMinX(tileX), 0, getMinZ(tileZ));
|
||||
}
|
||||
|
||||
public Location getMinLocation() {
|
||||
return getMinLocation(tileX, tileZ);
|
||||
}
|
||||
|
||||
+43
-8
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.region.dynamic;
|
||||
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -34,7 +35,7 @@ public abstract class VariantSelector {
|
||||
private static final Random RANDOM = new Random();
|
||||
public static final VariantSelector EMPTY = new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
@@ -42,14 +43,14 @@ public abstract class VariantSelector {
|
||||
private VariantSelector() {
|
||||
}
|
||||
|
||||
public abstract Optional<File> select();
|
||||
public abstract Optional<SchematicNode> select();
|
||||
|
||||
public final VariantSelector or(VariantSelector other) {
|
||||
if (this == EMPTY) return other;
|
||||
VariantSelector self = this;
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
public Optional<SchematicNode> select() {
|
||||
return self.select().or(() -> other.select());
|
||||
}
|
||||
};
|
||||
@@ -60,7 +61,7 @@ public abstract class VariantSelector {
|
||||
VariantSelector self = this;
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
public Optional<SchematicNode> select() {
|
||||
LocalDate date = LocalDate.now();
|
||||
if (date.getDayOfMonth() == day && date.getMonth() == month) {
|
||||
return self.select();
|
||||
@@ -78,8 +79,9 @@ public abstract class VariantSelector {
|
||||
final File file = files[0];
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
return Optional.of(file);
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.empty();
|
||||
// return Optional.of(file);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -88,8 +90,41 @@ public abstract class VariantSelector {
|
||||
final int filesCount = files.length;
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<File> select() {
|
||||
return Optional.of(files[RANDOM.nextInt(filesCount)]);
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.empty();
|
||||
// return Optional.of(files[RANDOM.nextInt(filesCount)]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static VariantSelector Folder(int folderId) {
|
||||
SchematicNode[] schematics = SchematicNode.getSchematicNodeInNode(folderId).toArray(SchematicNode[]::new);
|
||||
if (schematics.length == 0) return EMPTY;
|
||||
if (schematics.length == 1) {
|
||||
final SchematicNode node = schematics[0];
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.of(node);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
final int count = schematics.length;
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.of(schematics[RANDOM.nextInt(count)]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static VariantSelector Schematic(int schematicId) {
|
||||
SchematicNode schematic = SchematicNode.getSchematicNode(schematicId);
|
||||
return new VariantSelector() {
|
||||
@Override
|
||||
public Optional<SchematicNode> select() {
|
||||
return Optional.of(schematic);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ public class AreaBlock extends Region.Area {
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
EditSession editSession = pasteBuilder
|
||||
.with(PasteBuilder.ClipboardProvider.file(selector.select().orElse(null)))
|
||||
.with(PasteBuilder.ClipboardProvider.schematic(selector.select().orElse(null)))
|
||||
.pastePoint(copyPoint)
|
||||
.run();
|
||||
region.getHistory()
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@ import de.steamwar.bausystem.region.dynamic.PasteUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
@@ -66,7 +67,7 @@ public class AreaTile extends Region.Area {
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
File resetFile = selector.select().orElse(null);
|
||||
if (resetFile != null) PasteUtils.paste(resetFile, minPoint, 0);
|
||||
SchematicNode reset = selector.select().orElse(null);
|
||||
if (reset != null) PasteUtils.paste(reset, minPoint, 0);
|
||||
}
|
||||
}
|
||||
|
||||
+47
-44
@@ -31,6 +31,7 @@ import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.region.dynamic.spawn.SpawnRegion;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -46,15 +47,15 @@ public class PathArea extends Region.Area {
|
||||
private static final File PATH_DIR = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/path");
|
||||
private static final File FALLBACK_SCHEM = new File(PATH_DIR, "Fallback.schem");
|
||||
|
||||
private static final VariantSelector CENTER_NORMAL = VariantSelector.Get(new File(PATH_DIR, "center/normal"));
|
||||
private static final VariantSelector CENTER = VariantSelector.Folder(179927);
|
||||
|
||||
private static final VariantSelector SIDE_GLOBAL = VariantSelector.Get(new File(PATH_DIR, "side/global"));
|
||||
private static final VariantSelector CORNER_INNER_GLOBAL = VariantSelector.Get(new File(PATH_DIR, "cinner/global"));
|
||||
private static final VariantSelector CORNER_OUTER_GLOBAL = VariantSelector.Get(new File(PATH_DIR, "couter/global"));
|
||||
private static final VariantSelector SIDE_VOID = VariantSelector.Folder(179930);
|
||||
private static final VariantSelector CORNER_INNER_VOID = VariantSelector.Folder(179937);
|
||||
private static final VariantSelector CORNER_OUTER_VOID = VariantSelector.Folder(179942);
|
||||
|
||||
private static final VariantSelector SIDE_WATER = VariantSelector.Get(new File(PATH_DIR, "side/water"));
|
||||
private static final VariantSelector CORNER_INNER_WATER = VariantSelector.Get(new File(PATH_DIR, "cinner/water"));
|
||||
private static final VariantSelector CORNER_OUTER_WATER = VariantSelector.Get(new File(PATH_DIR, "couter/water"));
|
||||
private static final VariantSelector SIDE_WATER = VariantSelector.Folder(179931);
|
||||
private static final VariantSelector CORNER_INNER_WATER = VariantSelector.Folder(179938);
|
||||
private static final VariantSelector CORNER_OUTER_WATER = VariantSelector.Folder(179943);
|
||||
|
||||
private static final VariantSelector SIDE_CLOSED = VariantSelector.Get(new File(PATH_DIR, "side/closed"));
|
||||
private static final VariantSelector CORNER_INNER_CLOSED = VariantSelector.Get(new File(PATH_DIR, "cinner/closed"));
|
||||
@@ -67,23 +68,23 @@ public class PathArea extends Region.Area {
|
||||
private static final VariantSelector CORNER_OUTER_GARDEN = VariantSelector.Get(new File(PATH_DIR, "couter/garden"));
|
||||
|
||||
private static final SelectorSide SELECTOR_SIDE = new SelectorSide()
|
||||
.Case(Path, CENTER_NORMAL)
|
||||
.Case(Global, SIDE_GLOBAL)
|
||||
.Case(Path, CENTER)
|
||||
.Case(Void, SIDE_VOID)
|
||||
.Case(Water, SIDE_WATER)
|
||||
.Case(Closed, SIDE_CLOSED)
|
||||
.Case(Plot, SIDE_CLOSED)
|
||||
.Case(Garden, SIDE_GARDEN_CONNECTED);
|
||||
|
||||
private static final SelectorCorner SELECTOR_CORNER = new SelectorCorner()
|
||||
// Path to Path
|
||||
.Case(Path, Path, Path, CENTER_NORMAL, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Path, CENTER, RotationCorrection.UsingOrdinal)
|
||||
// Path to Global
|
||||
.Case(Path, Global, Global, SIDE_GLOBAL, RotationCorrection.WithCorrection)
|
||||
.Case(Global, Path, Path, SIDE_GLOBAL)
|
||||
.Case(Global, Path, Global, SIDE_GLOBAL)
|
||||
.Case(Path, Global, Path, SIDE_GLOBAL, RotationCorrection.WithCorrection)
|
||||
.Case(Global, Global, Global, CORNER_OUTER_GLOBAL, RotationCorrection.UsingOrdinal)
|
||||
.Case(Global, Global, Path, CORNER_OUTER_GLOBAL, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Global, CORNER_INNER_GLOBAL, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Void, Void, SIDE_VOID, RotationCorrection.WithCorrection)
|
||||
.Case(Void, Path, Path, SIDE_VOID)
|
||||
.Case(Void, Path, Void, SIDE_VOID)
|
||||
.Case(Path, Void, Path, SIDE_VOID, RotationCorrection.WithCorrection)
|
||||
.Case(Void, Void, Void, CORNER_OUTER_VOID, RotationCorrection.UsingOrdinal)
|
||||
.Case(Void, Void, Path, CORNER_OUTER_VOID, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Void, CORNER_INNER_VOID, RotationCorrection.UsingOrdinal)
|
||||
// Path to Water
|
||||
.Case(Path, Water, Water, SIDE_WATER, RotationCorrection.WithCorrection)
|
||||
.Case(Water, Path, Path, SIDE_WATER)
|
||||
@@ -93,13 +94,13 @@ public class PathArea extends Region.Area {
|
||||
.Case(Water, Water, Path, CORNER_OUTER_WATER, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Water, CORNER_INNER_WATER, RotationCorrection.UsingOrdinal)
|
||||
// Path to Closed
|
||||
.Case(Path, Closed, Closed, SIDE_CLOSED, RotationCorrection.WithCorrection)
|
||||
.Case(Closed, Path, Path, SIDE_CLOSED)
|
||||
.Case(Closed, Path, Closed, SIDE_CLOSED)
|
||||
.Case(Path, Closed, Path, SIDE_CLOSED, RotationCorrection.WithCorrection)
|
||||
.Case(Closed, Closed, Closed, CORNER_OUTER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
.Case(Closed, Closed, Path, CORNER_OUTER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Closed, CORNER_INNER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Plot, Plot, SIDE_CLOSED, RotationCorrection.WithCorrection)
|
||||
.Case(Plot, Path, Path, SIDE_CLOSED)
|
||||
.Case(Plot, Path, Plot, SIDE_CLOSED)
|
||||
.Case(Path, Plot, Path, SIDE_CLOSED, RotationCorrection.WithCorrection)
|
||||
.Case(Plot, Plot, Plot, CORNER_OUTER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
.Case(Plot, Plot, Path, CORNER_OUTER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
.Case(Path, Path, Plot, CORNER_INNER_CLOSED, RotationCorrection.UsingOrdinal)
|
||||
// Path to Garden
|
||||
.Case(Path, Garden, Garden, SIDE_GARDEN, RotationCorrection.WithCorrection)
|
||||
.Case(Garden, Path, Path, SIDE_GARDEN)
|
||||
@@ -159,27 +160,29 @@ public class PathArea extends Region.Area {
|
||||
}
|
||||
|
||||
public void reset(PathSide side) {
|
||||
File resetFile = null;
|
||||
SchematicNode reset = null;
|
||||
VariantSelector selector = SELECTOR_SIDE.Select(tile, side);
|
||||
if (selector != null) resetFile = selector.select().orElse(null);
|
||||
if (selector == null || resetFile == null) {
|
||||
if (selector != null) reset = selector.select().orElse(null);
|
||||
if (selector == null || reset == null) {
|
||||
if (!BauSystem.DEV_SERVER) return;
|
||||
resetFile = FALLBACK_SCHEM;
|
||||
// reset = FALLBACK_SCHEM;
|
||||
return;
|
||||
}
|
||||
|
||||
PasteUtils.paste(resetFile, minPoint.add(side.pasteOffsetX, 0, side.pasteOffsetZ), side.rotate);
|
||||
PasteUtils.paste(reset, minPoint.add(side.pasteOffsetX, 0, side.pasteOffsetZ), side.rotate);
|
||||
}
|
||||
|
||||
public void reset(PathCorner corner) {
|
||||
File resetFile = null;
|
||||
SchematicNode reset = null;
|
||||
Pair<VariantSelector, RotationCorrection> pair = SELECTOR_CORNER.Select(tile, corner);
|
||||
VariantSelector selector = pair.getKey();
|
||||
RotationCorrection rotationCorrection = pair.getValue();
|
||||
if (selector != null) resetFile = selector.select().orElse(null);
|
||||
if (selector == null || resetFile == null) {
|
||||
if (selector != null) reset = selector.select().orElse(null);
|
||||
if (selector == null || reset == null) {
|
||||
if (!BauSystem.DEV_SERVER) return;
|
||||
resetFile = FALLBACK_SCHEM;
|
||||
rotationCorrection = RotationCorrection.Unchanged;
|
||||
// reset = FALLBACK_SCHEM;
|
||||
// rotationCorrection = RotationCorrection.Unchanged;
|
||||
return;
|
||||
}
|
||||
|
||||
int rotate = corner.rotate;
|
||||
@@ -194,22 +197,22 @@ public class PathArea extends Region.Area {
|
||||
break;
|
||||
}
|
||||
|
||||
PasteUtils.paste(resetFile, minPoint.add(corner.pasteOffsetX, 0, corner.pasteOffsetZ), rotate);
|
||||
PasteUtils.paste(reset, minPoint.add(corner.pasteOffsetX, 0, corner.pasteOffsetZ), rotate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
if (region.isGarden()) {
|
||||
File resetFile = GARDEN.select().orElse(null);
|
||||
if (resetFile != null) {
|
||||
PasteUtils.paste(resetFile, minPoint, 0);
|
||||
SchematicNode reset = GARDEN.select().orElse(null);
|
||||
if (reset != null) {
|
||||
PasteUtils.paste(reset, minPoint, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
File resetFile = CENTER_NORMAL.select().orElse(null);
|
||||
if (resetFile != null) {
|
||||
PasteUtils.paste(resetFile, minPoint.add(7, 0, 7), 0);
|
||||
SchematicNode reset = CENTER.select().orElse(null);
|
||||
if (reset != null) {
|
||||
PasteUtils.paste(reset, minPoint.add(7, 0, 7), 0);
|
||||
}
|
||||
|
||||
for (PathSide side : PathSide.values()) {
|
||||
@@ -227,7 +230,7 @@ public class PathArea extends Region.Area {
|
||||
optionalTile = optionalTile.flatMap(t -> t.add(optionalSide.tileOffsetX, optionalSide.tileOffsetZ));
|
||||
}
|
||||
if (optionalTile.isEmpty()) {
|
||||
return Global;
|
||||
return Void;
|
||||
}
|
||||
tile = optionalTile.get();
|
||||
Region region = DynamicRegionSystem.INSTANCE.get(tile);
|
||||
@@ -238,7 +241,7 @@ public class PathArea extends Region.Area {
|
||||
if (optionalSide == null && side.opposite().equals(spawnRegion.getPathSide())) {
|
||||
return spawnPathConnection;
|
||||
} else {
|
||||
return Closed;
|
||||
return Plot;
|
||||
}
|
||||
}
|
||||
return region.getType().getConnectionType();
|
||||
|
||||
-2
@@ -29,9 +29,7 @@ import lombok.NonNull;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RegionConstructorData(
|
||||
identifier = "path",
|
||||
|
||||
+2
-2
@@ -59,8 +59,8 @@ class SelectorCorner {
|
||||
}
|
||||
|
||||
public Pair<VariantSelector, PathArea.RotationCorrection> Select(Tile tile, PathCorner corner) {
|
||||
RegionType.ConnectionType left = PathArea.getConnectionType(tile, corner.side1, null, RegionType.ConnectionType.Closed);
|
||||
RegionType.ConnectionType right = PathArea.getConnectionType(tile, corner.side2, null, RegionType.ConnectionType.Closed);
|
||||
RegionType.ConnectionType left = PathArea.getConnectionType(tile, corner.side1, null, RegionType.ConnectionType.Plot);
|
||||
RegionType.ConnectionType right = PathArea.getConnectionType(tile, corner.side2, null, RegionType.ConnectionType.Plot);
|
||||
RegionType.ConnectionType diagonal = PathArea.getConnectionType(tile, corner.side1, corner.side2);
|
||||
int index = getIndex(left, right, diagonal);
|
||||
return new Pair<>(selectors[index], rotationCorrections[index]);
|
||||
|
||||
+5
-1
@@ -24,7 +24,9 @@ import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionType;
|
||||
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
|
||||
import de.steamwar.bausystem.region.dynamic.PasteUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import lombok.NonNull;
|
||||
|
||||
@@ -32,6 +34,8 @@ import java.util.List;
|
||||
|
||||
public class SpawnArea extends Region.Area {
|
||||
|
||||
private static final VariantSelector SPAWN_BIG = VariantSelector.Schematic(179980);
|
||||
|
||||
private final Tile tile;
|
||||
|
||||
public SpawnArea(Tile tile) {
|
||||
@@ -60,7 +64,7 @@ public class SpawnArea extends Region.Area {
|
||||
.toList();
|
||||
|
||||
if (regions.stream().map(DynamicRegion::getType).allMatch(RegionType::isSpawn)) {
|
||||
// TODO: Implement big spawn!
|
||||
PasteUtils.paste(SPAWN_BIG.select().orElseThrow(), Tile.TILE_NN.getMinPoint().setY(WORLD_MIN_Y), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -28,6 +28,7 @@ import de.steamwar.bausystem.region.dynamic.PasteUtils;
|
||||
import de.steamwar.bausystem.region.dynamic.Tile;
|
||||
import de.steamwar.bausystem.region.dynamic.VariantSelector;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -103,8 +104,8 @@ public class SpecialArea extends Region.Area {
|
||||
|
||||
@Override
|
||||
public void place(PasteBuilder pasteBuilder, boolean extension) {
|
||||
File resetFile = resetFiles.select().orElse(null);
|
||||
if (resetFile != null) PasteUtils.paste(resetFile, minPoint, 0);
|
||||
SchematicNode reset = resetFiles.select().orElse(null);
|
||||
if (reset != null) PasteUtils.paste(reset, minPoint, 0);
|
||||
resetting = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user