SteamWar/BauSystem
Archiviert
13
0

added getMinPoint and getMaxPoint to region

Dieser Commit ist enthalten in:
Zeanon 2021-04-03 14:34:52 +02:00
Ursprung 2131cc9423
Commit 5b8f7b10df
6 geänderte Dateien mit 82 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -18,6 +18,7 @@
<version>1.0</version>
<build>
<defaultGoal>clean verify -U</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>

Datei anzeigen

@ -18,6 +18,7 @@
<version>1.0</version>
<build>
<defaultGoal>clean verify -U</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>

Datei anzeigen

@ -18,6 +18,7 @@
<version>1.0</version>
<build>
<defaultGoal>clean verify -U</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>

Datei anzeigen

@ -18,6 +18,7 @@
<version>1.0</version>
<build>
<defaultGoal>clean verify -U</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
@ -79,5 +80,11 @@
<scope>system</scope>
<systemPath>${main.basedir}/lib/WorldEdit-1.15.jar</systemPath>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -21,10 +21,13 @@ package de.steamwar.bausystem.world;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3;
import de.steamwar.bausystem.commands.CommandTNT.TNTMode;
import de.steamwar.core.VersionedCallable;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import java.awt.*;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
@ -80,9 +83,7 @@ public class Region {
}
private final String name;
private final int minX;
private final int minY;
private final int minZ;
private final Point minPoint;
private final Prototype prototype;
private final String optionsLinkedWith; // nullable
private Region linkedRegion = null; // nullable
@ -95,9 +96,7 @@ public class Region {
private Region(ConfigurationSection config) {
name = config.getName();
minX = config.getInt("minX");
minY = config.getInt("minY");
minZ = config.getInt("minZ");
minPoint = new Point(config.getInt("minX"), config.getInt("minY"), config.getInt("minZ"));
prototype = Prototype.prototypes.get(config.getString("prototype"));
optionsLinkedWith = config.getString("optionsLinkedWith", null);
if (!hasTestblock()) tntMode = TNTMode.OFF;
@ -106,9 +105,7 @@ public class Region {
public Region(String name) {
this.name = name;
this.minX = 0;
this.minY = 0;
this.minZ = 0;
this.minPoint = new Point(0, 0, 0);
this.prototype = null;
this.optionsLinkedWith = null;
tntMode = TNTMode.OFF;
@ -158,6 +155,14 @@ public class Region {
setLinkedRegion(region -> region.fire = fire);
}
public Point getMinPoint() {
return prototype.getMinPoint(this);
}
public Point getMaxPoint() {
return prototype.getMaxPoint(this);
}
public boolean inRegion(Location l) {
return prototype.inRegion(this, l);
}
@ -356,22 +361,38 @@ public class Region {
prototypes.put(config.getName(), this);
}
public Point getMinPoint(Region region) {
return new Point(
region.minPoint.getX() + offsetX,
region.minPoint.getY() + offsetY,
region.minPoint.getZ() + offsetZ
);
}
public Point getMaxPoint(Region region) {
return new Point(
region.minPoint.getX() + offsetX + sizeX,
region.minPoint.getY() + offsetY + sizeY,
region.minPoint.getZ() + offsetZ + sizeZ
);
}
public boolean inRegion(Region region, Location l) {
return inRange(l.getX(), region.minX + offsetX, sizeX) &&
inRange(l.getY(), region.minY + offsetY, sizeY) &&
inRange(l.getZ(), region.minZ + offsetZ, sizeZ);
return inRange(l.getX(), region.minPoint.getX() + offsetX, sizeX) &&
inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY) &&
inRange(l.getZ(), region.minPoint.getZ() + offsetZ, sizeZ);
}
public boolean inRegionExtension(Region region, Location l) {
return inRange(l.getX(), region.minX + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) &&
inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY) &&
inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ);
return inRange(l.getX(), region.minPoint.getX() + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) &&
inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY + extensionPositiveY) &&
inRange(l.getZ(), region.minPoint.getZ() + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ);
}
public EditSession reset(Region region, Schematic schem) throws IOException, NoClipboardException {
int x = region.minX + offsetX + sizeX / 2;
int y = region.minY + offsetY;
int z = region.minZ + offsetZ + sizeZ / 2;
int x = region.minPoint.getX() + offsetX + sizeX / 2;
int y = region.minPoint.getY() + offsetY;
int z = region.minPoint.getZ() + offsetZ + sizeZ / 2;
if (schem == null)
return paste(new File(schematic), x, y, z, rotate);
else
@ -383,9 +404,9 @@ public class Region {
}
public EditSession protect(Region region, Schematic schem) throws IOException, NoClipboardException {
int x = region.minX + offsetX + sizeX / 2;
int y = region.minY + testblock.offsetY - 1;
int z = region.minZ + offsetZ + sizeZ / 2;
int x = region.minPoint.getX() + offsetX + sizeX / 2;
int y = region.minPoint.getY() + testblock.offsetY - 1;
int z = region.minPoint.getZ() + offsetZ + sizeZ / 2;
if (schem == null)
return paste(new File(protectSchematic), x, y, z, rotate);
else
@ -414,4 +435,33 @@ public class Region {
new VersionedCallable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15));
}
}
public static class Point {
final int x;
final int y;
final int z;
public Point(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public BlockVector3 toBlockVector3() {
return BlockVector3.at(this.x, this.y, this.z);
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getZ() {
return this.z;
}
}
}

Datei anzeigen

@ -15,6 +15,7 @@
</properties>
<build>
<defaultGoal>clean verify -U</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>