Search in sources :

Example 6 with ChunkDataShort

use of com.builtbroken.mc.lib.world.map.data.s.ChunkDataShort in project Engine by VoltzEngine-Project.

the class ExtendedBlockDataMap method setValue.

/**
     * Sets the extended data value
     *
     * @param x     - location in the world
     * @param y     - location in the world
     * @param z     - location in the world
     * @param value - new data
     * @return old data
     */
public short setValue(int x, int y, int z, short value) {
    ChunkDataShort chunk = getChunkFromBlockCoords(x, z);
    if (chunk != null) {
        short prev = chunk.getValue(x & 15, y, z & 15);
        chunk.setValue(x & 15, y, z & 15, value);
        return prev;
    } else {
        chunk = add(new ChunkDataShort(x >> 4, z >> 4));
        chunk.setValue(x & 15, y, z & 15, value);
    }
    return 0;
}
Also used : ChunkDataShort(com.builtbroken.mc.lib.world.map.data.s.ChunkDataShort)

Example 7 with ChunkDataShort

use of com.builtbroken.mc.lib.world.map.data.s.ChunkDataShort in project Engine by VoltzEngine-Project.

the class TestChunkDataShort method testAllSlots.

@Test
public void testAllSlots() {
    //Test that every slot works
    ChunkDataShort chunk = new ChunkDataShort(10, 13);
    for (int x = 0; x < 16; x++) {
        for (int y = 0; y < 256; y++) {
            for (int z = 0; z < 16; z++) {
                int r = MathHelper.randomShort();
                chunk.setValue(x, y, z, r);
                assertEquals(r, chunk.getValue(x, y, z));
            }
        }
    }
}
Also used : ChunkDataShort(com.builtbroken.mc.lib.world.map.data.s.ChunkDataShort) Test(org.junit.Test)

Aggregations

ChunkDataShort (com.builtbroken.mc.lib.world.map.data.s.ChunkDataShort)7 Test (org.junit.Test)5 ChunkSectionShort (com.builtbroken.mc.lib.world.map.data.s.ChunkSectionShort)1