/** * Sets the block id, data and auxData for the block at (x, y, z), if the current data matches the * expected data.<br> * <br> * * @param x the x coordinate * @param y the y coordinate * @param z the z coordinate * @param expect the expected block value * @param newValue the new block value * @return true if the block was set */ public final boolean compareAndSetBlock( int x, int y, int z, BlockFullState<T> expect, BlockFullState<T> newValue) { return compareAndSetBlock( x, y, z, expect.getId(), expect.getData(), expect.getAuxData(), newValue.getId(), newValue.getData(), newValue.getAuxData()); }
/** * Atomically gets the full set of data associated with the block.<br> * <br> * * @param x the x coordinate * @param y the y coordinate * @param z the z coordinate * @param fullState a BlockFullState object to store the return value, or null to generate a new * one * @return the full state of the block */ public final BlockFullState<T> getFullData(int x, int y, int z, BlockFullState<T> fullData) { if (fullData == null) { fullData = new BlockFullState<T>(); } int index = getIndex(x, y, z); int spins = 0; boolean interrupted = false; try { while (true) { if (spins++ > SPINS) { interrupted |= atomicWait(); } checkCompressing(); int seq = getSequence(x, y, z); short blockId = blockIds.get(index); if (auxStore.isReserved(blockId)) { fullData.setId(auxStore.getId(blockId)); fullData.setData(auxStore.getData(blockId)); fullData.setAuxData(auxStore.getAuxData(blockId)); if (testSequence(x, y, z, seq)) { return fullData; } } else { fullData.setId(blockId); fullData.setData((short) 0); fullData.setAuxData(null); return fullData; } } } finally { if (interrupted) { Thread.currentThread().interrupt(); } } }
/** * Sets the block id, data and auxData for the block at (x, y, z).<br> * <br> * If the data is 0 and the auxData is null, then the block will be stored as a single short.<br> * * @param x the x coordinate * @param y the y coordinate * @param z the z coordinate * @param fullState the new state of the Block */ public final void setBlock(int x, int y, int z, BlockFullState<T> fullState) { setBlock(x, y, z, fullState.getId(), fullState.getData(), fullState.getAuxData()); }