returns false on 'set' when setblock fails.

This commit is contained in:
gnembon committed 2020-11-25 00:14:46 -04:00
1 parent 4c6d449553
commit 5615bddf9b
1 file changed
+5 -2
@@ -739,11 +739,12 @@ public class WorldAccess {
return (c_, t_) -> Value.FALSE; return (c_, t_) -> Value.FALSE;
BlockState finalSourceBlockState = sourceBlockState; BlockState finalSourceBlockState = sourceBlockState;
BlockPos targetPos = targetLocator.block.getPos(); BlockPos targetPos = targetLocator.block.getPos();
Boolean[] result = new Boolean[]{true};
cc.s.getMinecraftServer().submitAndJoin( () -> cc.s.getMinecraftServer().submitAndJoin( () ->
{ {
Clearable.clear(world.getBlockEntity(targetPos)); Clearable.clear(world.getBlockEntity(targetPos));
world.setBlockState(targetPos, finalSourceBlockState, 2); boolean success = world.setBlockState(targetPos, finalSourceBlockState, 2);
if (finalData != null) if (success && finalData != null)
{ {
BlockEntity be = world.getBlockEntity(targetPos); BlockEntity be = world.getBlockEntity(targetPos);
if (be != null) if (be != null)
@@ -756,7 +757,9 @@ public class WorldAccess {
be.markDirty(); be.markDirty();
} }
} }
result[0] = success;
}); });
if (!result[0]) return LazyValue.FALSE;
Value retval = new BlockValue(finalSourceBlockState, world, targetLocator.block.getPos()); Value retval = new BlockValue(finalSourceBlockState, world, targetLocator.block.getPos());
return (c_, t_) -> retval; return (c_, t_) -> retval;
}); });