From b399ec3a3d39ff0abb272c958274af8541448b73 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Sun, 18 Apr 2021 18:20:27 +0200 Subject: [PATCH] add generatePrototypeData --- .../de/steamwar/bausystem/region/Point.java | 8 ++++++ .../de/steamwar/bausystem/region/Region.java | 28 +++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/BauSystem_API/src/de/steamwar/bausystem/region/Point.java b/BauSystem_API/src/de/steamwar/bausystem/region/Point.java index d9084af5..5d8d626e 100644 --- a/BauSystem_API/src/de/steamwar/bausystem/region/Point.java +++ b/BauSystem_API/src/de/steamwar/bausystem/region/Point.java @@ -32,4 +32,12 @@ public class Point { private final int x; private final int y; private final int z; + + public Point add(int x, int y, int z) { + return new Point(this.x + x, this.y + y, this.z + z); + } + + public Point substract(int x, int y, int z) { + return new Point(this.x - x, this.y - y, this.z - z); + } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index 32616786..17ba6b10 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -82,16 +82,33 @@ public class Region { }); } this.flagStorage = flagStorage; - generatePrototypeData(prototype); + generatePrototypeData(prototype, regionConfig.getPlainValue("minPoint")); } - private void generatePrototypeData(Prototype prototype) { - if (prototype != null && !prototypes.contains(prototype)) { + private void generatePrototypeData(Prototype prototype, Point point) { + if (prototype == null) { + return; + } + + if (!prototypes.contains(prototype)) { return; } this.prototype = prototype; - // TODO: implement generation + this.minPoint = point; + this.maxPoint = point.add(prototype.getSizeX(), prototype.getSizeY(), prototype.getSizeZ()); + + this.minPointTestblock = point.add(prototype.getTestblock().getOffsetX(), prototype.getTestblock().getOffsetY(), prototype.getTestblock().getOffsetZ()); + this.maxPointTestblock = this.minPointTestblock.add(prototype.getTestblock().getSizeX(), prototype.getTestblock().getSizeY(), prototype.getTestblock().getSizeZ()); + + this.minPointTestblockExtension = this.minPointTestblock.substract(prototype.getTestblock().getExtensionNegativeX(), prototype.getTestblock().getExtensionNegativeY(), prototype.getTestblock().getExtensionNegativeZ()); + this.maxPointTestblockExtension = this.maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX(), prototype.getTestblock().getExtensionPositiveY(), prototype.getTestblock().getExtensionPositiveZ()); + + this.minPointBuild = point.add(prototype.getBuild().getOffsetX(), prototype.getBuild().getOffsetY(), prototype.getBuild().getOffsetZ()); + this.maxPointBuild = this.minPointBuild.add(prototype.getBuild().getSizeX(), prototype.getBuild().getSizeY(), prototype.getBuild().getSizeZ()); + + this.minPointBuildExtension = this.minPointBuild.substract(prototype.getBuild().getExtensionNegativeX(), prototype.getBuild().getExtensionNegativeY(), prototype.getBuild().getExtensionNegativeZ()); + this.maxPointBuildExtension = this.maxPointBuild.add(prototype.getBuild().getExtensionPositiveX(), prototype.getBuild().getExtensionPositiveY(), prototype.getBuild().getExtensionPositiveZ()); } public boolean inRegion(Location location, RegionType regionType, RegionExtensionType regionExtensionType) { @@ -134,5 +151,4 @@ public class Region { public String getDisplayName() { return prototype != null ? prototype.getDisplayName() : ""; } - -} +} \ No newline at end of file