Fixed RotatingServerContext
- RotatingServerContext now rotates coordinates, too - Fixed a bug caused by the implementation of push methods by TransformingServerContext - Fixed unbounded recursion in WorldGenericRO.hasTile(Vec3i, BlockFace, int)
This commit is contained in:
parent
54c66d28d6
commit
82872c7cf3
@ -137,7 +137,8 @@ public interface WorldGenericRO<
|
|||||||
* @return {@code true} iff the tile exists
|
* @return {@code true} iff the tile exists
|
||||||
*/
|
*/
|
||||||
default boolean hasTile(Vec3i location, BlockFace face, int layer) {
|
default boolean hasTile(Vec3i location, BlockFace face, int layer) {
|
||||||
return hasTile(location, face, layer);
|
TS stack = getTilesOrNull(location, face);
|
||||||
|
return stack != null && stack.size() > layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean isChunkLoaded(Vec3i chunkPos) {
|
default boolean isChunkLoaded(Vec3i chunkPos) {
|
||||||
|
@ -19,6 +19,7 @@ package ru.windcorp.progressia.server.world.context.impl;
|
|||||||
|
|
||||||
import glm.vec._3.i.Vec3i;
|
import glm.vec._3.i.Vec3i;
|
||||||
import ru.windcorp.progressia.common.world.rels.AbsFace;
|
import ru.windcorp.progressia.common.world.rels.AbsFace;
|
||||||
|
import ru.windcorp.progressia.common.world.rels.AxisRotations;
|
||||||
import ru.windcorp.progressia.common.world.rels.RelFace;
|
import ru.windcorp.progressia.common.world.rels.RelFace;
|
||||||
import ru.windcorp.progressia.server.world.context.ServerTileContext;
|
import ru.windcorp.progressia.server.world.context.ServerTileContext;
|
||||||
|
|
||||||
@ -31,14 +32,18 @@ public class RotatingServerContext extends TransformingServerContext {
|
|||||||
this.up = up;
|
this.up = up;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbsFace getUp() {
|
||||||
|
return up;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void transform(Vec3i userLocation, Vec3i output) {
|
protected void transform(Vec3i userLocation, Vec3i output) {
|
||||||
output.set(userLocation.x, userLocation.y, userLocation.z);
|
AxisRotations.resolve(userLocation, up, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void untransform(Vec3i parentLocation, Vec3i output) {
|
protected void untransform(Vec3i parentLocation, Vec3i output) {
|
||||||
output.set(parentLocation.x, parentLocation.y, parentLocation.z);
|
AxisRotations.relativize(parentLocation, up, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,7 @@ public abstract class TransformingServerContext extends FilterServerContext {
|
|||||||
private final Vec3i location = new Vec3i();
|
private final Vec3i location = new Vec3i();
|
||||||
private boolean isLocationValid = false;
|
private boolean isLocationValid = false;
|
||||||
|
|
||||||
private RelFace face;
|
private RelFace face = null;
|
||||||
|
|
||||||
private final List<Vec3i> vectorCache = new ArrayList<>(1);
|
private final List<Vec3i> vectorCache = new ArrayList<>(1);
|
||||||
|
|
||||||
@ -107,28 +107,40 @@ public abstract class TransformingServerContext extends FilterServerContext {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerBlockContext push(Vec3i userLocation) {
|
public ServerBlockContext push(Vec3i userLocation) {
|
||||||
transform(userLocation, location);
|
Vec3i parentLocation = grabVector(userLocation);
|
||||||
|
super.push(parentLocation);
|
||||||
|
releaseVector(parentLocation);
|
||||||
|
|
||||||
|
location.set(userLocation.x, userLocation.y, userLocation.z);
|
||||||
isLocationValid = true;
|
isLocationValid = true;
|
||||||
super.push(location);
|
|
||||||
face = null;
|
face = null;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerTileStackContext push(Vec3i userLocation, RelFace userFace) {
|
public ServerTileStackContext push(Vec3i userLocation, RelFace userFace) {
|
||||||
transform(userLocation, location);
|
Vec3i parentLocation = grabVector(userLocation);
|
||||||
|
super.push(parentLocation, transform(userFace));
|
||||||
|
releaseVector(parentLocation);
|
||||||
|
|
||||||
|
location.set(userLocation.x, userLocation.y, userLocation.z);
|
||||||
isLocationValid = true;
|
isLocationValid = true;
|
||||||
face = transform(userFace);
|
face = userFace;
|
||||||
super.push(location, face);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerTileContext push(Vec3i userLocation, RelFace userFace, int layer) {
|
public ServerTileContext push(Vec3i userLocation, RelFace userFace, int layer) {
|
||||||
transform(userLocation, location);
|
Vec3i parentLocation = grabVector(userLocation);
|
||||||
|
super.push(parentLocation, transform(userFace), layer);
|
||||||
|
releaseVector(parentLocation);
|
||||||
|
|
||||||
|
location.set(userLocation.x, userLocation.y, userLocation.z);
|
||||||
isLocationValid = true;
|
isLocationValid = true;
|
||||||
face = transform(userFace);
|
face = userFace;
|
||||||
super.push(location, face, layer);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user