Skip to content

Commit 34ee793

Browse files
committed
API: New DirectChunk API that supports light, biomes and direct chunk modification
1 parent 7ce4c24 commit 34ee793

13 files changed

+607
-62
lines changed

src/org/primesoft/asyncworldedit/api/directChunk/IBaseChunkData.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
package org.primesoft.asyncworldedit.api.directChunk;
4242

4343
import com.sk89q.jnbt.CompoundTag;
44-
import com.sk89q.worldedit.BlockVector2D;
4544
import com.sk89q.worldedit.Vector;
4645
import com.sk89q.worldedit.blocks.BaseBlock;
4746
import com.sk89q.worldedit.entity.Entity;
@@ -50,22 +49,7 @@
5049
*
5150
* @author SBPrime
5251
*/
53-
public interface IBaseChunkData {
54-
55-
/**
56-
* Get the chunk coords
57-
*
58-
* @return
59-
*/
60-
BlockVector2D getChunkCoords();
61-
62-
/**
63-
* Set the chunk coords
64-
*
65-
* @param coords
66-
*/
67-
void setChunkCoords(BlockVector2D coords);
68-
52+
public interface IBaseChunkData extends ISimpleChunkData {
6953
/**
7054
* Set chunk block
7155
*
@@ -76,15 +60,30 @@ public interface IBaseChunkData {
7660
*/
7761
void setBlock(int x, int y, int z, BaseBlock b);
7862

63+
7964
/**
65+
* Set chunk tile eneity
66+
*
67+
* @param x X coordinate inside chunk (0-15)
68+
* @param y Y coordinate inside chunk (0-15)
69+
* @param z Z coordinate inside chunk (0-15)
70+
* @param id Material ID of the tile entitiy
71+
* @param ct Tile entity NBT data
72+
*/
73+
void setTileEntity(int x, int y, int z, char id, CompoundTag ct);
74+
75+
76+
/**
8077
* Set chunk block
8178
*
8279
* @param x X coordinate inside chunk (0-15)
8380
* @param y Y coordinate inside chunk (0-15)
8481
* @param z Z coordinate inside chunk (0-15)
85-
* @param id Material ID
82+
* @param b WorldEdit block
83+
* @param emission The block emission level
8684
*/
87-
void setBlock(int x, int y, int z, char id);
85+
void setBlockAndEmission(int x, int y, int z, BaseBlock b, byte emission);
86+
8887

8988
/**
9089
* Set chunk tile eneity
@@ -94,8 +93,10 @@ public interface IBaseChunkData {
9493
* @param z Z coordinate inside chunk (0-15)
9594
* @param id Material ID of the tile entitiy
9695
* @param ct Tile entity NBT data
96+
* @param emission The block emission level
9797
*/
98-
void setTileEntity(int x, int y, int z, char id, CompoundTag ct);
98+
void setTileEntityAndEmission(int x, int y, int z, char id, CompoundTag ct, byte emission);
99+
99100

100101
/**
101102
* Remove entity from chunk
@@ -121,7 +122,6 @@ public interface IBaseChunkData {
121122
*/
122123
ISerializedEntity addEntity(Vector pos, Entity entity);
123124

124-
125125
/**
126126
* Get block from chunk data
127127
*
@@ -131,11 +131,11 @@ public interface IBaseChunkData {
131131
* @return
132132
*/
133133
BaseBlock getBlock(int x, int y, int z);
134-
135-
134+
136135
/**
137136
* Get the chunk entities
138-
* @return
137+
*
138+
* @return
139139
*/
140-
ISerializedEntity[] getEntity();
141-
}
140+
ISerializedEntity[] getEntity();
141+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* AsyncWorldEdit API
3+
* Copyright (c) 2016, SBPrime <https://github.com/SBPrime/>
4+
* Copyright (c) AsyncWorldEdit API contributors
5+
*
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted free of charge provided that the following
10+
* conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice, this
13+
* list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution,
17+
* 3. Redistributions of source code, with or without modification, in any form
18+
* other then free of charge is not allowed,
19+
* 4. Redistributions in binary form in any form other then free of charge is
20+
* not allowed.
21+
* 5. Any derived work based on or containing parts of this software must reproduce
22+
* the above copyright notice, this list of conditions and the following
23+
* disclaimer in the documentation and/or other materials provided with the
24+
* derived work.
25+
* 6. The original author of the software is allowed to change the license
26+
* terms or the entire license of the software as he sees fit.
27+
* 7. The original author of the software is allowed to sublicense the software
28+
* or its parts using any license terms he sees fit.
29+
*
30+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
34+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40+
*/
41+
package org.primesoft.asyncworldedit.api.directChunk;
42+
43+
/**
44+
*
45+
* @author SBPrime
46+
*/
47+
public interface IBiomeEntry extends IVector2dEntry {
48+
49+
/**
50+
* Get the bime ID
51+
*
52+
* @return
53+
*/
54+
byte getId();
55+
}

src/org/primesoft/asyncworldedit/api/directChunk/IBlockEntry.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
*
4747
* @author SBPrime
4848
*/
49-
public interface IBlockEntry {
50-
49+
public interface IBlockEntry extends IVectorEntry {
5150
/**
5251
* Get the block ID
5352
*
@@ -61,11 +60,30 @@ public interface IBlockEntry {
6160
* @return
6261
*/
6362
CompoundTag getNbt();
64-
65-
int getX();
66-
67-
int getY();
68-
69-
int getZ();
7063

64+
65+
/**
66+
* Get the light emission level
67+
* @return
68+
*/
69+
byte getEmission();
70+
71+
/**
72+
* Set the light emission level
73+
* @param level
74+
*/
75+
void setEmission(byte level);
76+
77+
78+
/**
79+
* Does the entry have light data
80+
* @return
81+
*/
82+
boolean hasLight();
83+
84+
/**
85+
* Does the entry have block data
86+
* @return
87+
*/
88+
boolean hasBlock();
7189
}

src/org/primesoft/asyncworldedit/api/directChunk/IChangesetData.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,11 @@ public interface IChangesetData {
6464
* Get the stored blocks
6565
* @return
6666
*/
67-
IBlockEntry[] getChangedBlocks();
67+
IBlockEntry[] getChangedBlocks();
68+
69+
/**
70+
* Get the stored biomes
71+
* @return
72+
*/
73+
IBiomeEntry[] getChangedBiomes();
6874
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* AsyncWorldEdit API
3+
* Copyright (c) 2015, SBPrime <https://github.com/SBPrime/>
4+
* Copyright (c) AsyncWorldEdit API contributors
5+
*
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted free of charge provided that the following
10+
* conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice, this
13+
* list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution,
17+
* 3. Redistributions of source code, with or without modification, in any form
18+
* other then free of charge is not allowed,
19+
* 4. Redistributions in binary form in any form other then free of charge is
20+
* not allowed.
21+
* 5. Any derived work based on or containing parts of this software must reproduce
22+
* the above copyright notice, this list of conditions and the following
23+
* disclaimer in the documentation and/or other materials provided with the
24+
* derived work.
25+
* 6. The original author of the software is allowed to change the license
26+
* terms or the entire license of the software as he sees fit.
27+
* 7. The original author of the software is allowed to sublicense the software
28+
* or its parts using any license terms he sees fit.
29+
*
30+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
34+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40+
*/
41+
package org.primesoft.asyncworldedit.api.directChunk;
42+
43+
import com.sk89q.worldedit.BlockVector2D;
44+
45+
/**
46+
*
47+
* @author SBPrime
48+
*/
49+
public interface IChunkDataCommon {
50+
51+
/**
52+
* Get the chunk coords
53+
*
54+
* @return
55+
*/
56+
BlockVector2D getChunkCoords();
57+
58+
/**
59+
* Set the chunk coords
60+
*
61+
* @param coords
62+
*/
63+
void setChunkCoords(BlockVector2D coords);
64+
}

src/org/primesoft/asyncworldedit/api/directChunk/IChunkUndoData.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,30 @@
4747
* @author SBPrime
4848
*/
4949
public interface IChunkUndoData {
50-
51-
public UUID[] getAddedEntitys();
50+
/**
51+
* Get the list of added entities
52+
*
53+
* @return
54+
*/
55+
UUID[] getAddedEntitys();
5256

53-
public ISerializedEntity[] getRemovedEntitys();
57+
/**
58+
* Get the list of removed entities
59+
*
60+
* @return
61+
*/
62+
ISerializedEntity[] getRemovedEntitys();
5463

55-
public IBlockEntry[] getBlocks();
64+
65+
/**
66+
* Get the changed blocks
67+
* @return
68+
*/
69+
IBlockEntry[] getBlocks();
70+
71+
/**
72+
* Get the changed biomes
73+
* @return
74+
*/
75+
IBiomeEntry[] getChangedBiomes();
5676
}

0 commit comments

Comments
 (0)