@Override public boolean hasPermanentBlockEntity(Vector3i blockPos) { if (GameThread.isCurrentThread()) { EntityRef blockEntity = blockEntityLookup.get(blockPos); return blockEntity != null && !temporaryBlockEntities.contains(blockEntity); } logger.error("Attempted check whether a block entity is permanent, off thread"); return false; }
@Override public EntityRef getExistingBlockEntityAt(Vector3i blockPosition) { if (GameThread.isCurrentThread()) { EntityRef result = blockEntityLookup.get(blockPosition); return (result == null) ? EntityRef.NULL : result; } logger.error("Attempted to get block entity off-thread"); return EntityRef.NULL; }
@Override public EntityRef getEntityAt(Vector3i blockPosition) { if (GameThread.isCurrentThread()) { EntityRef entity = getExistingEntityAt(blockPosition); if (!entity.exists()) { return getBlockEntityAt(blockPosition); } return entity; } logger.error("Attempted to get block entity off-thread"); return EntityRef.NULL; }
@Override public EntityRef getBlockEntityAt(Vector3i blockPosition) { if (GameThread.isCurrentThread()) { EntityRef blockEntity = getExistingBlockEntityAt(blockPosition); if (!blockEntity.exists() && isBlockRelevant(blockPosition.x, blockPosition.y, blockPosition.z)) { Block block = getBlock(blockPosition.x, blockPosition.y, blockPosition.z); blockEntity = createBlockEntity(blockPosition, block); } return blockEntity; } logger.error("Attempted to get block entity off-thread"); return EntityRef.NULL; }
@Override @SafeVarargs public final Block setBlockRetainComponent( Vector3i pos, Block type, Class<? extends Component>... components) { if (GameThread.isCurrentThread()) { EntityRef blockEntity = getBlockEntityAt(pos); Block oldType = super.setBlock(pos, type); if (oldType != null) { updateBlockEntity(blockEntity, pos, oldType, type, false, Sets.newHashSet(components)); } return oldType; } return null; }
@Override public Block setBlockForceUpdateEntity(Vector3i pos, Block type) { if (GameThread.isCurrentThread()) { EntityRef blockEntity = getBlockEntityAt(pos); Block oldType = super.setBlock(pos, type); if (oldType != null) { updateBlockEntity( blockEntity, pos, oldType, type, true, Collections.<Class<? extends Component>>emptySet()); } return oldType; } return null; }