Contexts now only accept RelFace; fixed tile placement crash

This commit is contained in:
OLEGSHA 2021-08-16 13:05:57 +03:00
parent 82872c7cf3
commit a6fd81ba1e
Signed by: OLEGSHA
GPG Key ID: E57A4B08D64AFF7A
18 changed files with 94 additions and 143 deletions

View File

@ -21,8 +21,8 @@ import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.block.BlockData;
import ru.windcorp.progressia.common.world.entity.EntityData;
import ru.windcorp.progressia.common.world.generic.context.BlockGenericContextWO;
import ru.windcorp.progressia.common.world.rels.AbsRelation;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.rels.RelRelation;
import ru.windcorp.progressia.common.world.tile.TileData;
public interface BlockDataContext
@ -45,8 +45,8 @@ public interface BlockDataContext
}
@Override
default BlockDataContext pushRelative(AbsRelation direction) {
return push(getLocation().add_(direction.getVector()));
default BlockDataContext pushRelative(RelRelation direction) {
return push(getLocation().add_(direction.getRelVector()));
}
@Override

View File

@ -21,8 +21,8 @@ import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.block.BlockData;
import ru.windcorp.progressia.common.world.entity.EntityData;
import ru.windcorp.progressia.common.world.generic.context.BlockGenericContextRO;
import ru.windcorp.progressia.common.world.rels.AbsRelation;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.rels.RelRelation;
import ru.windcorp.progressia.common.world.tile.TileData;
public interface BlockDataContextRO
@ -44,8 +44,8 @@ public interface BlockDataContextRO
}
@Override
default BlockDataContextRO pushRelative(AbsRelation direction) {
return push(getLocation().add_(direction.getVector()));
default BlockDataContextRO pushRelative(RelRelation direction) {
return push(getLocation().add_(direction.getRelVector()));
}
@Override

View File

@ -20,9 +20,8 @@ package ru.windcorp.progressia.common.world.generic.context;
import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.context.Context;
import ru.windcorp.progressia.common.world.generic.*;
import ru.windcorp.progressia.common.world.rels.AbsRelation;
import ru.windcorp.progressia.common.world.rels.BlockFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.rels.RelRelation;
/**
* A {@link Context} referencing a world with a block location specified. The
@ -68,7 +67,7 @@ public interface BlockGenericContextRO<
* @param layer the layer of the tile
* @return {@code true} iff the tile exists
*/
default boolean hasTile(BlockFace face, int layer) {
default boolean hasTile(RelFace face, int layer) {
return hasTile(getLocation(), face, layer);
}
@ -80,7 +79,7 @@ public interface BlockGenericContextRO<
* @param tag the tag of the tile
* @return {@code true} iff the tile exists
*/
default boolean isTagValid(BlockFace face, int tag) {
default boolean isTagValid(RelFace face, int tag) {
return isTagValid(getLocation(), face, tag);
}
@ -97,7 +96,7 @@ public interface BlockGenericContextRO<
* @param layer the layer of the tile stack that the tile occupies
* @return the tile or {@code null} if the position does not contain a tile
*/
default T getTile(BlockFace face, int layer) {
default T getTile(RelFace face, int layer) {
return getTile(getLocation(), face, layer);
}
@ -115,7 +114,7 @@ public interface BlockGenericContextRO<
* @param tag the tag of the tile
* @return the tile or {@code null} if the position does not contain a tile
*/
default T getTileByTag(BlockFace face, int tag) {
default T getTileByTag(RelFace face, int tag) {
return getTileByTag(getLocation(), face, tag);
}
@ -129,7 +128,7 @@ public interface BlockGenericContextRO<
* @return the count of tiles in the tile stack or {@code -1} if the tile
* stack could not exist
*/
default int getTileCount(BlockFace face) {
default int getTileCount(RelFace face) {
return getTileCount(face);
}
@ -148,8 +147,8 @@ public interface BlockGenericContextRO<
}
@Override
default BlockGenericContextRO<B, T, E> pushRelative(AbsRelation direction) {
return push(getLocation().add_(direction.getVector()));
default BlockGenericContextRO<B, T, E> pushRelative(RelRelation direction) {
return push(getLocation().add_(direction.getRelVector()));
}
@Override

View File

@ -20,9 +20,8 @@ package ru.windcorp.progressia.common.world.generic.context;
import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.context.Context;
import ru.windcorp.progressia.common.world.generic.*;
import ru.windcorp.progressia.common.world.rels.AbsRelation;
import ru.windcorp.progressia.common.world.rels.BlockFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.rels.RelRelation;
/**
* A writable {@link Context} referencing a world with a block location
@ -59,7 +58,7 @@ public interface BlockGenericContextWO<
* @param face the face of the block to add the tile to
* @param tile the tile to add
*/
default void addTile(BlockFace face, T tile) {
default void addTile(RelFace face, T tile) {
addTile(getLocation(), face, tile);
}
@ -72,7 +71,7 @@ public interface BlockGenericContextWO<
* @param face the of the block to remove the tile from
* @param tag the tag of the tile to remove
*/
default void removeTile(BlockFace face, int tag) {
default void removeTile(RelFace face, int tag) {
removeTile(getLocation(), face, tag);
}
@ -91,8 +90,8 @@ public interface BlockGenericContextWO<
}
@Override
default BlockGenericContextWO<B, T, E> pushRelative(AbsRelation direction) {
return push(getLocation().add_(direction.getVector()));
default BlockGenericContextWO<B, T, E> pushRelative(RelRelation direction) {
return push(getLocation().add_(direction.getRelVector()));
}
@Override

View File

@ -21,9 +21,9 @@ package ru.windcorp.progressia.common.world.generic.context;
import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.context.Context;
import ru.windcorp.progressia.common.world.rels.AbsFace;
import ru.windcorp.progressia.common.world.rels.AbsRelation;
import ru.windcorp.progressia.common.world.rels.BlockFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.rels.RelRelation;
/**
* This class defines several {@link Context} subinterfaces that are further
@ -139,7 +139,7 @@ class WorldContexts {
* system
* @return the face expressed in absolute coordinate system
*/
AbsFace toAbsolute(BlockFace contextFace);
AbsFace toAbsolute(RelFace contextFace);
/**
* Converts the provided face given in the absolute coordinate
@ -221,8 +221,8 @@ class WorldContexts {
* @return this object
* @see #pop()
*/
default Block pushRelative(AbsRelation direction) {
return push(getLocation().add_(direction.getVector()));
default Block pushRelative(RelRelation direction) {
return push(getLocation().add_(direction.getRelVector()));
}
/**

View File

@ -20,11 +20,9 @@ package ru.windcorp.progressia.common.world.generic.context;
import java.util.Collection;
import java.util.function.Consumer;
import glm.vec._3.Vec3;
import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.context.Context;
import ru.windcorp.progressia.common.world.generic.*;
import ru.windcorp.progressia.common.world.rels.BlockFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
/**
@ -76,7 +74,7 @@ public interface WorldGenericContextRO<
* @param layer the layer of the tile stack that the tile occupies
* @return the tile or {@code null} if the position does not contain a tile
*/
T getTile(Vec3i location, BlockFace face, int layer);
T getTile(Vec3i location, RelFace face, int layer);
/**
* Retrieves the tile at the specified position and the tile's tag. This
@ -92,7 +90,7 @@ public interface WorldGenericContextRO<
* @param tag the tag of the tile
* @return the tile or {@code null} if the position does not contain a tile
*/
T getTileByTag(Vec3i location, BlockFace face, int tag);
T getTileByTag(Vec3i location, RelFace face, int tag);
/**
* Determines whether the specified position has a tile.
@ -102,7 +100,7 @@ public interface WorldGenericContextRO<
* @param layer the layer of the tile
* @return {@code true} iff the tile exists
*/
boolean hasTile(Vec3i location, BlockFace face, int layer);
boolean hasTile(Vec3i location, RelFace face, int layer);
/**
* Determines whether the specified position has a tile with the given tag.
@ -112,7 +110,7 @@ public interface WorldGenericContextRO<
* @param tag the tag of the tile
* @return {@code true} iff the tile exists
*/
boolean isTagValid(Vec3i location, BlockFace face, int tag);
boolean isTagValid(Vec3i location, RelFace face, int tag);
/**
* Counts the amount of tiles in the specified tile stack.
@ -124,7 +122,7 @@ public interface WorldGenericContextRO<
* @return the count of tiles in the tile stack or {@code -1} if the tile
* stack could not exist
*/
int getTileCount(Vec3i location, BlockFace face);
int getTileCount(Vec3i location, RelFace face);
/**
* Retrieves a listing of all entities. {@link #forEachEntity(Consumer)}
@ -143,52 +141,6 @@ public interface WorldGenericContextRO<
*/
E getEntity(long entityId);
/*
* Convenience methods
*/
/**
* Iterates all entities safely
*/
default void forEachEntity(Consumer<? super E> action) {
getEntities().forEach(action);
}
/**
* Iterates all entities in cuboid safely
*/
default void forEachEntityIn(Vec3i min, Vec3i max, Consumer<? super E> action) {
forEachEntity(e -> {
Vec3 pos = e.getPosition();
if (pos.x < min.x || pos.y < min.y || pos.z < min.z || pos.x > max.x || pos.y > max.y || pos.z > max.z) {
action.accept(e);
}
});
}
/**
* Iterates all entities in cuboid safely
*/
default void forEachEntityIn(Vec3 min, Vec3 max, Consumer<? super E> action) {
forEachEntity(e -> {
Vec3 pos = e.getPosition();
if (pos.x < min.x || pos.y < min.y || pos.z < min.z || pos.x > max.x || pos.y > max.y || pos.z > max.z) {
action.accept(e);
}
});
}
/**
* Iterates all entities with ID safely
*/
default void forEachEntityWithId(String id, Consumer<? super E> action) {
forEachEntity(e -> {
if (id.equals(e.getId())) {
action.accept(e);
}
});
}
/*
* Subcontexting
*/

View File

@ -22,7 +22,6 @@ import ru.windcorp.progressia.common.state.StateChange;
import ru.windcorp.progressia.common.state.StatefulObject;
import ru.windcorp.progressia.common.world.context.Context;
import ru.windcorp.progressia.common.world.generic.*;
import ru.windcorp.progressia.common.world.rels.BlockFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
/**
@ -76,7 +75,7 @@ public interface WorldGenericContextWO<
* @param face the face of the block to add the tile to
* @param tile the tile to add
*/
void addTile(Vec3i location, BlockFace face, T tile);
void addTile(Vec3i location, RelFace face, T tile);
/**
* Requests that a tile identified by its tag is removed from the specified
@ -88,7 +87,7 @@ public interface WorldGenericContextWO<
* @param face the of the block to remove the tile from
* @param tag the tag of the tile to remove
*/
void removeTile(Vec3i location, BlockFace face, int tag);
void removeTile(Vec3i location, RelFace face, int tag);
/**
* Requests that the referenced tile is removed from its tile stack. If the

View File

@ -44,7 +44,7 @@ public class PacketAddTile extends PacketAffectTile {
}
public void set(TileData tile, Vec3i blockInWorld, AbsFace face) {
super.set(blockInWorld, face, -1);
super.set(blockInWorld, face, TAG_NOT_APPLICABLE);
this.tileId = tile.getId();
}

View File

@ -34,6 +34,12 @@ public abstract class PacketAffectTile extends PacketAffectChunk {
private AbsFace face;
private int tag;
/**
* Indicates to the safeguards in {@link #set(Vec3i, AbsFace, int)} that the
* concept of a tile tag is not applicable to this action.
*/
protected static final int TAG_NOT_APPLICABLE = -2;
public PacketAffectTile(String id) {
super(id);
}
@ -51,8 +57,8 @@ public abstract class PacketAffectTile extends PacketAffectChunk {
}
public void set(Vec3i blockInWorld, AbsFace face, int tag) {
if (tag < 0) {
throw new IllegalArgumentException("Cannot affect tile with tag -1");
if (tag < 0 && tag != TAG_NOT_APPLICABLE) {
throw new IllegalArgumentException("Cannot affect tile with tag " + tag);
}
this.blockInWorld.set(blockInWorld.x, blockInWorld.y, blockInWorld.z);

View File

@ -19,8 +19,8 @@ package ru.windcorp.progressia.server.world.context;
import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.context.BlockDataContext;
import ru.windcorp.progressia.common.world.rels.AbsRelation;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.rels.RelRelation;
public interface ServerBlockContext extends BlockDataContext, ServerWorldContext, ServerBlockContextRO {
@ -40,8 +40,8 @@ public interface ServerBlockContext extends BlockDataContext, ServerWorldContext
}
@Override
default ServerBlockContext.Logic pushRelative(AbsRelation direction) {
return push(getLocation().add_(direction.getVector()));
default ServerBlockContext.Logic pushRelative(RelRelation direction) {
return push(getLocation().add_(direction.getRelVector()));
}
@Override
@ -70,8 +70,8 @@ public interface ServerBlockContext extends BlockDataContext, ServerWorldContext
}
@Override
default ServerBlockContext pushRelative(AbsRelation direction) {
return push(getLocation().add_(direction.getVector()));
default ServerBlockContext pushRelative(RelRelation direction) {
return push(getLocation().add_(direction.getRelVector()));
}
@Override

View File

@ -21,8 +21,8 @@ import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.context.BlockDataContextRO;
import ru.windcorp.progressia.common.world.entity.EntityData;
import ru.windcorp.progressia.common.world.generic.context.BlockGenericContextRO;
import ru.windcorp.progressia.common.world.rels.AbsRelation;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.rels.RelRelation;
import ru.windcorp.progressia.server.world.block.BlockLogic;
import ru.windcorp.progressia.server.world.tile.TileLogic;
@ -45,8 +45,8 @@ public interface ServerBlockContextRO extends ServerWorldContextRO, BlockDataCon
}
@Override
default ServerBlockContextRO.Logic pushRelative(AbsRelation direction) {
return push(getLocation().add_(direction.getVector()));
default ServerBlockContextRO.Logic pushRelative(RelRelation direction) {
return push(getLocation().add_(direction.getRelVector()));
}
@Override
@ -75,8 +75,8 @@ public interface ServerBlockContextRO extends ServerWorldContextRO, BlockDataCon
}
@Override
default ServerBlockContextRO pushRelative(AbsRelation direction) {
return push(getLocation().add_(direction.getVector()));
default ServerBlockContextRO pushRelative(RelRelation direction) {
return push(getLocation().add_(direction.getRelVector()));
}
@Override

View File

@ -318,7 +318,7 @@ class DefaultServerContextImpl extends DefaultServerContext
}
@Override
public AbsFace toAbsolute(BlockFace contextFace) {
public AbsFace toAbsolute(RelFace contextFace) {
return contextFace.resolve(AbsFace.POS_Z);
}
@ -362,19 +362,19 @@ class DefaultServerContextImpl extends DefaultServerContext
}
@Override
public TileData getTile(Vec3i location, BlockFace face, int layer) {
public TileData getTile(Vec3i location, RelFace face, int layer) {
assert requireContextRole(Role.WORLD);
return world.getTile(location, face, layer);
}
@Override
public boolean hasTile(Vec3i location, BlockFace face, int layer) {
public boolean hasTile(Vec3i location, RelFace face, int layer) {
assert requireContextRole(Role.WORLD);
return world.hasTile(location, face, layer);
}
@Override
public TileData getTileByTag(Vec3i location, BlockFace face, int tag) {
public TileData getTileByTag(Vec3i location, RelFace face, int tag) {
assert requireContextRole(Role.WORLD);
TileDataStack stack = world.getTilesOrNull(location, face);
if (stack == null)
@ -386,7 +386,7 @@ class DefaultServerContextImpl extends DefaultServerContext
}
@Override
public boolean isTagValid(Vec3i location, BlockFace face, int tag) {
public boolean isTagValid(Vec3i location, RelFace face, int tag) {
assert requireContextRole(Role.WORLD);
TileDataStack stack = world.getTilesOrNull(location, face);
if (stack == null)
@ -404,7 +404,7 @@ class DefaultServerContextImpl extends DefaultServerContext
}
@Override
public int getTileCount(Vec3i location, BlockFace face) {
public int getTileCount(Vec3i location, RelFace face) {
assert requireContextRole(Role.TILE_STACK);
TileDataStack stack = world.getTilesOrNull(frame.location, frame.face);
if (stack == null)
@ -453,13 +453,13 @@ class DefaultServerContextImpl extends DefaultServerContext
}
@Override
public void addTile(Vec3i location, BlockFace face, TileData tile) {
public void addTile(Vec3i location, RelFace face, TileData tile) {
assert requireContextRole(Role.WORLD);
world.getTiles(location, face).addFarthest(tile);
}
@Override
public void removeTile(Vec3i location, BlockFace face, int tag) {
public void removeTile(Vec3i location, RelFace face, int tag) {
assert requireContextRole(Role.WORLD);
TileDataStack stack = world.getTilesOrNull(location, face);
if (stack == null)

View File

@ -24,7 +24,6 @@ import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.block.BlockData;
import ru.windcorp.progressia.common.world.entity.EntityData;
import ru.windcorp.progressia.common.world.rels.AbsFace;
import ru.windcorp.progressia.common.world.rels.BlockFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.tile.TileData;
import ru.windcorp.progressia.server.Server;
@ -97,7 +96,7 @@ public class DefaultServerContextLogic implements ServerTileContext.Logic {
}
@Override
public AbsFace toAbsolute(BlockFace contextFace) {
public AbsFace toAbsolute(RelFace contextFace) {
return parent.toAbsolute(contextFace);
}
@ -112,13 +111,13 @@ public class DefaultServerContextLogic implements ServerTileContext.Logic {
}
@Override
public TileLogic getTile(Vec3i location, BlockFace face, int layer) {
public TileLogic getTile(Vec3i location, RelFace face, int layer) {
TileData data = parent.getTile(location, face, layer);
return data == null ? null : TileLogicRegistry.getInstance().get(data.getId());
}
@Override
public TileLogic getTileByTag(Vec3i location, BlockFace face, int tag) {
public TileLogic getTileByTag(Vec3i location, RelFace face, int tag) {
TileData data = parent.getTileByTag(location, face, tag);
return data == null ? null : TileLogicRegistry.getInstance().get(data.getId());
}
@ -129,12 +128,12 @@ public class DefaultServerContextLogic implements ServerTileContext.Logic {
}
@Override
public boolean hasTile(Vec3i location, BlockFace face, int layer) {
public boolean hasTile(Vec3i location, RelFace face, int layer) {
return parent.hasTile(location, face, layer);
}
@Override
public boolean isTagValid(Vec3i location, BlockFace face, int tag) {
public boolean isTagValid(Vec3i location, RelFace face, int tag) {
return parent.isTagValid(location, face, tag);
}
@ -144,7 +143,7 @@ public class DefaultServerContextLogic implements ServerTileContext.Logic {
}
@Override
public int getTileCount(Vec3i location, BlockFace face) {
public int getTileCount(Vec3i location, RelFace face) {
return parent.getTileCount(location, face);
}

View File

@ -28,7 +28,6 @@ import ru.windcorp.progressia.common.world.block.BlockData;
import ru.windcorp.progressia.common.world.entity.EntityData;
import ru.windcorp.progressia.common.world.generic.EntityGeneric;
import ru.windcorp.progressia.common.world.rels.AbsFace;
import ru.windcorp.progressia.common.world.rels.BlockFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.tile.TileData;
import ru.windcorp.progressia.server.Server;
@ -99,12 +98,12 @@ public abstract class FilterServerContext implements ServerTileContext {
}
@Override
public void addTile(Vec3i location, BlockFace face, TileData tile) {
public void addTile(Vec3i location, RelFace face, TileData tile) {
parent.addTile(location, face, tile);
}
@Override
public void removeTile(Vec3i location, BlockFace face, int tag) {
public void removeTile(Vec3i location, RelFace face, int tag) {
parent.removeTile(location, face, tag);
}
@ -149,27 +148,27 @@ public abstract class FilterServerContext implements ServerTileContext {
}
@Override
public TileData getTile(Vec3i location, BlockFace face, int layer) {
public TileData getTile(Vec3i location, RelFace face, int layer) {
return parent.getTile(location, face, layer);
}
@Override
public TileData getTileByTag(Vec3i location, BlockFace face, int tag) {
public TileData getTileByTag(Vec3i location, RelFace face, int tag) {
return parent.getTileByTag(location, face, tag);
}
@Override
public boolean hasTile(Vec3i location, BlockFace face, int layer) {
public boolean hasTile(Vec3i location, RelFace face, int layer) {
return parent.hasTile(location, face, layer);
}
@Override
public boolean isTagValid(Vec3i location, BlockFace face, int tag) {
public boolean isTagValid(Vec3i location, RelFace face, int tag) {
return parent.isTagValid(location, face, tag);
}
@Override
public int getTileCount(Vec3i location, BlockFace face) {
public int getTileCount(Vec3i location, RelFace face) {
return parent.getTileCount(location, face);
}
@ -212,7 +211,7 @@ public abstract class FilterServerContext implements ServerTileContext {
}
@Override
public AbsFace toAbsolute(BlockFace contextFace) {
public AbsFace toAbsolute(RelFace contextFace) {
return parent.toAbsolute(contextFace);
}

View File

@ -24,6 +24,7 @@ import ru.windcorp.progressia.common.world.block.BlockData;
import ru.windcorp.progressia.common.world.entity.EntityData;
import ru.windcorp.progressia.common.world.generic.EntityGeneric;
import ru.windcorp.progressia.common.world.rels.BlockFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.tile.TileData;
import ru.windcorp.progressia.server.world.context.ServerTileContext;
@ -83,7 +84,7 @@ public class ReportingServerContext extends FilterServerContext {
}
@Override
public void addTile(Vec3i location, BlockFace face, TileData tile) {
public void addTile(Vec3i location, RelFace face, TileData tile) {
if (passToParent) {
super.addTile(location, face, tile);
}
@ -93,7 +94,7 @@ public class ReportingServerContext extends FilterServerContext {
}
@Override
public void removeTile(Vec3i location, BlockFace face, int tag) {
public void removeTile(Vec3i location, RelFace face, int tag) {
if (passToParent) {
super.removeTile(location, face, tag);
}

View File

@ -23,7 +23,6 @@ import java.util.List;
import glm.vec._3.i.Vec3i;
import ru.windcorp.progressia.common.world.block.BlockData;
import ru.windcorp.progressia.common.world.rels.AbsFace;
import ru.windcorp.progressia.common.world.rels.BlockFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.tile.TileData;
import ru.windcorp.progressia.server.world.context.ServerBlockContext;
@ -163,8 +162,8 @@ public abstract class TransformingServerContext extends FilterServerContext {
}
@Override
public AbsFace toAbsolute(BlockFace contextFace) {
return super.toAbsolute(transform(contextFace.relativize(AbsFace.POS_Z)));
public AbsFace toAbsolute(RelFace contextFace) {
return super.toAbsolute(transform(contextFace));
}
@Override
@ -206,77 +205,77 @@ public abstract class TransformingServerContext extends FilterServerContext {
}
@Override
public boolean hasTile(Vec3i userLocation, BlockFace userFace, int layer) {
public boolean hasTile(Vec3i userLocation, RelFace userFace, int layer) {
Vec3i parentLocation = grabVector(userLocation);
try {
return super.hasTile(parentLocation, transform(userFace.relativize(AbsFace.POS_Z)), layer);
return super.hasTile(parentLocation, transform(userFace), layer);
} finally {
releaseVector(parentLocation);
}
}
@Override
public TileData getTile(Vec3i userLocation, BlockFace userFace, int layer) {
public TileData getTile(Vec3i userLocation, RelFace userFace, int layer) {
Vec3i parentLocation = grabVector(userLocation);
try {
return super.getTile(parentLocation, transform(userFace.relativize(AbsFace.POS_Z)), layer);
return super.getTile(parentLocation, transform(userFace), layer);
} finally {
releaseVector(parentLocation);
}
}
@Override
public boolean isTagValid(Vec3i userLocation, BlockFace userFace, int tag) {
public boolean isTagValid(Vec3i userLocation, RelFace userFace, int tag) {
Vec3i parentLocation = grabVector(userLocation);
try {
return super.isTagValid(parentLocation, transform(userFace.relativize(AbsFace.POS_Z)), tag);
return super.isTagValid(parentLocation, transform(userFace), tag);
} finally {
releaseVector(parentLocation);
}
}
@Override
public TileData getTileByTag(Vec3i userLocation, BlockFace userFace, int tag) {
public TileData getTileByTag(Vec3i userLocation, RelFace userFace, int tag) {
Vec3i parentLocation = grabVector(userLocation);
try {
return super.getTileByTag(parentLocation, transform(userFace.relativize(AbsFace.POS_Z)), tag);
return super.getTileByTag(parentLocation, transform(userFace), tag);
} finally {
releaseVector(parentLocation);
}
}
@Override
public int getTileCount(Vec3i userLocation, BlockFace userFace) {
public int getTileCount(Vec3i userLocation, RelFace userFace) {
Vec3i parentLocation = grabVector(userLocation);
try {
return super.getTileCount(parentLocation, transform(userFace.relativize(AbsFace.POS_Z)));
return super.getTileCount(parentLocation, transform(userFace));
} finally {
releaseVector(parentLocation);
}
}
@Override
public void addTile(Vec3i userLocation, BlockFace userFace, TileData tile) {
public void addTile(Vec3i userLocation, RelFace userFace, TileData tile) {
Vec3i parentLocation = grabVector(userLocation);
try {
super.addTile(parentLocation, transform(userFace.relativize(AbsFace.POS_Z)), tile);
super.addTile(parentLocation, transform(userFace), tile);
} finally {
releaseVector(parentLocation);
}
}
@Override
public void removeTile(Vec3i userLocation, BlockFace userFace, int tag) {
public void removeTile(Vec3i userLocation, RelFace userFace, int tag) {
Vec3i parentLocation = grabVector(userLocation);
try {
super.removeTile(parentLocation, transform(userFace.relativize(AbsFace.POS_Z)), tag);
super.removeTile(parentLocation, transform(userFace), tag);
} finally {
releaseVector(parentLocation);
}

View File

@ -428,7 +428,7 @@ public class TestContent {
return;
if (server.getWorld().getData().getTiles(blockInWorld, face).isFull())
return;
server.createAbsoluteContext().addTile(blockInWorld, face, tile);
server.createAbsoluteContext().addTile(blockInWorld, face.relativize(AbsFace.POS_Z), tile);
}
private static void registerMisc() {

View File

@ -18,7 +18,6 @@
package ru.windcorp.progressia.test;
import ru.windcorp.progressia.common.world.rels.AbsFace;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.server.world.block.BlockLogic;
import ru.windcorp.progressia.server.world.context.ServerTileContext;
@ -65,8 +64,7 @@ public class TestTileLogicGrass extends HangingTileLogic implements TickableTile
}
private boolean isBlockAboveTransparent(ServerTileContextRO context) {
// TODO rework
context.pushRelative(RelFace.UP.resolve(AbsFace.POS_Z));
context.pushRelative(RelFace.UP);
BlockLogic block = context.logic().getBlock();
return context.popAndReturn(block == null || block.isTransparent(context));
}