forked from SteamWar/SteamWar
Format code
This commit is contained in:
@@ -46,17 +46,17 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
|
||||
public static Portal getPortal(Location from, Location to) {
|
||||
ChunkCoords in = new ChunkCoords(from);
|
||||
ChunkCoords out = new ChunkCoords(to);
|
||||
for(ChunkCoords coords : perChunk(Math.min(in.x, out.x), Math.max(in.x, out.x), Math.min(in.z, out.z), Math.max(in.z, out.z))) {
|
||||
for(Portal portal : chunkPortals.getOrDefault(coords, Collections.emptyList())) {
|
||||
for (ChunkCoords coords : perChunk(Math.min(in.x, out.x), Math.max(in.x, out.x), Math.min(in.z, out.z), Math.max(in.z, out.z))) {
|
||||
for (Portal portal : chunkPortals.getOrDefault(coords, Collections.emptyList())) {
|
||||
Vector normalizedFrom = portal.normalize(from);
|
||||
Vector normalizedTo = portal.normalize(to);
|
||||
|
||||
if(portal.depth == 0.0) {
|
||||
if (portal.depth == 0.0) {
|
||||
normalizedFrom.setX(normalizedFrom.getX() > 0 ? 2 : -1);
|
||||
normalizedTo.setX(normalizedTo.getX() > 0 ? 2 : -1);
|
||||
}
|
||||
|
||||
if(inside(normalizedFrom.getX(), normalizedTo.getX()) && inside(normalizedFrom.getY(), normalizedTo.getY()) && inside(normalizedFrom.getZ(), normalizedTo.getZ())) {
|
||||
if (inside(normalizedFrom.getX(), normalizedTo.getX()) && inside(normalizedFrom.getY(), normalizedTo.getY()) && inside(normalizedFrom.getZ(), normalizedTo.getZ())) {
|
||||
return portal;
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
|
||||
|
||||
Vector orientation = pos2.toVector().subtract(pos1.toVector());
|
||||
this.yRotation = Math.atan2(orientation.getX(), orientation.getZ());
|
||||
this.pos1Vector = pos1.toVector().subtract(new Vector(depth/2, 0, 0).rotateAroundY(yRotation));
|
||||
this.pos1Vector = pos1.toVector().subtract(new Vector(depth / 2, 0, 0).rotateAroundY(yRotation));
|
||||
this.rotatedShape = new Vector(depth == 0.0 ? 1.0 : depth, orientation.getY(), orientation.clone().setY(0).length());
|
||||
|
||||
this.handler = handlerConstructor.apply(this);
|
||||
@@ -263,7 +263,7 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof ChunkCoords))
|
||||
if (!(obj instanceof ChunkCoords))
|
||||
return false;
|
||||
|
||||
ChunkCoords coords = (ChunkCoords) obj;
|
||||
|
||||
Reference in New Issue
Block a user