Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SpawnDistance Multiple Selection #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/main/java/com/ryandw11/structure/structure/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,13 @@ else if (block == null) {
}

// Check to see if the structure is far enough away from spawn.
if (Math.abs(block.getX()) < getStructureLocation().getXLimitation())
return false;
if (Math.abs(block.getZ()) < getStructureLocation().getZLimitation())
return false;
if (getStructureLocation().isInner()) {
if (Math.abs(block.getX()) > getStructureLocation().getXLimitation()
|| Math.abs(block.getZ()) > getStructureLocation().getZLimitation()) return false;
} else {
if (Math.abs(block.getX()) < getStructureLocation().getXLimitation()
|| Math.abs(block.getZ()) < getStructureLocation().getZLimitation()) return false;
}

if (!CustomStructures.getInstance().getStructureHandler().validDistance(this, block.getLocation()))
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class StructureLocation implements StructureProperty {
private List<String> biomes;
private double distanceFromOthers;
private double distanceFromSame;
private boolean inner;
private int xLimitation;
private int zLimitation;

Expand Down Expand Up @@ -76,6 +77,10 @@ public StructureLocation(FileConfiguration fileConfiguration) {

xLimitation = 0;
zLimitation = 0;
inner = false;
if (cs.contains("SpawnDistance.inner")) {
inner = cs.getBoolean("SpawnDistance.inner");
}
if (cs.contains("SpawnDistance.x")) {
xLimitation = cs.getInt("SpawnDistance.x");
}
Expand Down Expand Up @@ -211,6 +216,14 @@ public boolean hasBiome(Biome b) {
return false;
}

public boolean isInner() {
return inner;
}

public void setInner(boolean inner) {
this.inner = inner;
}

/**
* Set the X-axis limitation.
*
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/structures/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ StructureLocation:
DistanceFromOthers: 200
# Set a custom spawn distance for the structures.
SpawnDistance:
# If true, spawn inside the region, otherwise spawn outside the region
inner: true
x: 10
z: 10

Expand Down