Grass tiles have regained the ability to disappear under blocks
- Test:Grass now (again) randomly disappears under opaque blocks - Fixed a truly egregious bug in AbstractContextRO.pop() - Fixed BlockContext.pushRelative(AbsRelation) - Some changes in toString methods in contexts
This commit is contained in:
parent
a03c783fc9
commit
78a1c25554
@ -46,7 +46,7 @@ public interface BlockDataContext
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BlockDataContext pushRelative(AbsRelation direction) {
|
default BlockDataContext pushRelative(AbsRelation direction) {
|
||||||
return push(direction.getVector());
|
return push(getLocation().add_(direction.getVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +45,7 @@ public interface BlockDataContextRO
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BlockDataContextRO pushRelative(AbsRelation direction) {
|
default BlockDataContextRO pushRelative(AbsRelation direction) {
|
||||||
return push(direction.getVector());
|
return push(getLocation().add_(direction.getVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +58,8 @@ public abstract class AbstractContextRO<
|
|||||||
throw new IllegalStateException("Cannot pop(): already top frame");
|
throw new IllegalStateException("Cannot pop(): already top frame");
|
||||||
}
|
}
|
||||||
|
|
||||||
frame = frameStack.pop();
|
frameStack.pop();
|
||||||
|
frame = frameStack.peek();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -149,7 +149,7 @@ public interface BlockGenericContextRO<
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BlockGenericContextRO<B, T, E> pushRelative(AbsRelation direction) {
|
default BlockGenericContextRO<B, T, E> pushRelative(AbsRelation direction) {
|
||||||
return push(direction.getVector());
|
return push(getLocation().add_(direction.getVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,7 +92,7 @@ public interface BlockGenericContextWO<
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BlockGenericContextWO<B, T, E> pushRelative(AbsRelation direction) {
|
default BlockGenericContextWO<B, T, E> pushRelative(AbsRelation direction) {
|
||||||
return push(direction.getVector());
|
return push(getLocation().add_(direction.getVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,7 +146,7 @@ class WorldContexts {
|
|||||||
* @see #pop()
|
* @see #pop()
|
||||||
*/
|
*/
|
||||||
default Block pushRelative(AbsRelation direction) {
|
default Block pushRelative(AbsRelation direction) {
|
||||||
return push(direction.getVector());
|
return push(getLocation().add_(direction.getVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,7 @@ public interface ServerBlockContext extends BlockDataContext, ServerWorldContext
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default ServerBlockContext.Logic pushRelative(AbsRelation direction) {
|
default ServerBlockContext.Logic pushRelative(AbsRelation direction) {
|
||||||
return push(direction.getVector());
|
return push(getLocation().add_(direction.getVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,7 +71,7 @@ public interface ServerBlockContext extends BlockDataContext, ServerWorldContext
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default ServerBlockContext pushRelative(AbsRelation direction) {
|
default ServerBlockContext pushRelative(AbsRelation direction) {
|
||||||
return push(direction.getVector());
|
return push(getLocation().add_(direction.getVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,7 +46,7 @@ public interface ServerBlockContextRO extends ServerWorldContextRO, BlockDataCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default ServerBlockContextRO.Logic pushRelative(AbsRelation direction) {
|
default ServerBlockContextRO.Logic pushRelative(AbsRelation direction) {
|
||||||
return push(direction.getVector());
|
return push(getLocation().add_(direction.getVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,7 +76,7 @@ public interface ServerBlockContextRO extends ServerWorldContextRO, BlockDataCon
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default ServerBlockContextRO pushRelative(AbsRelation direction) {
|
default ServerBlockContextRO pushRelative(AbsRelation direction) {
|
||||||
return push(direction.getVector());
|
return push(getLocation().add_(direction.getVector()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,7 @@ public interface DefaultServerContextBuilders {
|
|||||||
|
|
||||||
DefaultServerContext build();
|
DefaultServerContext build();
|
||||||
|
|
||||||
public interface Empty /* does not extend RSCB */ {
|
public interface Empty /* does not extend DSCB */ {
|
||||||
|
|
||||||
WithWorld in(Server server, WorldData world);
|
WithWorld in(Server server, WorldData world);
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ class DefaultServerContextImpl extends DefaultServerContext
|
|||||||
switch (getRole()) {
|
switch (getRole()) {
|
||||||
case TILE:
|
case TILE:
|
||||||
result = String.format(
|
result = String.format(
|
||||||
"ServerTileContext[x=%d, y=%d, z=%d, %s, index=%d]",
|
"ServerTileContext [x=%+4d, y=%+4d, z=%+4d, %s, index=%d]",
|
||||||
frame.location.x,
|
frame.location.x,
|
||||||
frame.location.y,
|
frame.location.y,
|
||||||
frame.location.z,
|
frame.location.z,
|
||||||
@ -160,16 +160,16 @@ class DefaultServerContextImpl extends DefaultServerContext
|
|||||||
break;
|
break;
|
||||||
case TILE_STACK:
|
case TILE_STACK:
|
||||||
result = String
|
result = String
|
||||||
.format("ServerBlockFaceContext[x=%d, y=%d, z=%d, %s]", frame.location.x, frame.location.y, frame.location.z, frame.face);
|
.format("ServerBlockFaceContext [x=%+4d, y=%+4d, z=%+4d, %s]", frame.location.x, frame.location.y, frame.location.z, frame.face);
|
||||||
break;
|
break;
|
||||||
case LOCATION:
|
case LOCATION:
|
||||||
result = String.format("ServerBlockContext[x=%d, y=%d, z=%d]", frame.location.x, frame.location.y, frame.location.z);
|
result = String.format("ServerBlockContext [x=%+4d, y=%+4d, z=%+4d]", frame.location.x, frame.location.y, frame.location.z);
|
||||||
break;
|
break;
|
||||||
case WORLD:
|
case WORLD:
|
||||||
result = String.format("ServerWorldContext");
|
result = "ServerWorldContext";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = "Uninitialized ReusableServerContext";
|
result = "Uninitialized DefaultServerContext";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,6 @@ class DefaultServerContextImpl extends DefaultServerContext
|
|||||||
public Empty reuse() {
|
public Empty reuse() {
|
||||||
|
|
||||||
server = null;
|
server = null;
|
||||||
// worldLogic = null;
|
|
||||||
world = null;
|
world = null;
|
||||||
|
|
||||||
while (isSubcontexting()) {
|
while (isSubcontexting()) {
|
||||||
|
@ -52,6 +52,11 @@ public abstract class FilterServerContext implements ServerTileContext {
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getClass().getSimpleName() + " [" + parent + "]";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLayer() {
|
public int getLayer() {
|
||||||
return parent.getLayer();
|
return parent.getLayer();
|
||||||
|
@ -178,12 +178,16 @@ public class TickChunk extends Evaluation {
|
|||||||
ServerTileContext tileContext = context.push(i);
|
ServerTileContext tileContext = context.push(i);
|
||||||
|
|
||||||
TileLogic logic = tileContext.logic().getTile();
|
TileLogic logic = tileContext.logic().getTile();
|
||||||
if (!(logic instanceof TickableTile))
|
if (!(logic instanceof TickableTile)) {
|
||||||
return;
|
tileContext.pop();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
TickableTile tickable = (TickableTile) logic;
|
TickableTile tickable = (TickableTile) logic;
|
||||||
|
|
||||||
if (tickable.getTickingPolicy(tileContext) != TickingPolicy.RANDOM)
|
if (tickable.getTickingPolicy(tileContext) != TickingPolicy.RANDOM) {
|
||||||
return;
|
tileContext.pop();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
tickable.tick(tileContext);
|
tickable.tick(tileContext);
|
||||||
|
|
||||||
tileContext.pop();
|
tileContext.pop();
|
||||||
|
@ -49,9 +49,7 @@ public class HangingTileLogic extends TileLogic implements UpdateableTile {
|
|||||||
|
|
||||||
context.pushOpposite();
|
context.pushOpposite();
|
||||||
BlockLogic complHost = context.logic().getBlock();
|
BlockLogic complHost = context.logic().getBlock();
|
||||||
boolean result = complHost == null || !complHost.isSolid(context, context.getFace());
|
return context.popAndReturn(complHost == null || !complHost.isSolid(context, context.getFace()));
|
||||||
context.pop();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBeSquashed(ServerTileContextRO context) {
|
public boolean canBeSquashed(ServerTileContextRO context) {
|
||||||
|
@ -50,7 +50,7 @@ public class TestTileLogicGrass extends HangingTileLogic implements TickableTile
|
|||||||
@Override
|
@Override
|
||||||
public void tick(ServerTileContext context) {
|
public void tick(ServerTileContext context) {
|
||||||
if (!isLocationSuitable(context)) {
|
if (!isLocationSuitable(context)) {
|
||||||
// context.removeThisTile();
|
context.removeTile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user