-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code cleanup and added atomic chunks
- Loading branch information
Showing
6 changed files
with
92 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/main/java/dev/hilligans/ourcraft/World/NewWorldSystem/GlobalPaletteAtomicSubChunk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/dev/hilligans/ourcraft/World/NewWorldSystem/IAtomicChunk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.hilligans.ourcraft.World.NewWorldSystem; | ||
|
||
import dev.hilligans.ourcraft.Block.BlockState.IBlockState; | ||
import dev.hilligans.ourcraft.Server.Concurrent.Lock; | ||
|
||
public interface IAtomicChunk extends IChunk { | ||
|
||
|
||
/** | ||
* @param lock a lock provided to the chunk in the event that a subchunk isn't atomic and needs to grab the lock, the lock must also be manually freed after | ||
*/ | ||
void setBlockStateAtomic(Lock lock, long x, long y, long z, IBlockState blockState); | ||
|
||
|
||
/** | ||
* Used to replace an old blockstate with a new one | ||
* useful if you want to do say a plant growing, so you can change the blockstate without having to grab the write lock | ||
* @param lock a lock provided to the chunk in the event that a subchunk isn't atomic and needs to grab the lock, the lock must also be manually freed after | ||
* @param x x pos in subchunk | ||
* @param y y pos in subchunk | ||
* @param z z pos in subchunk | ||
* @param expected the blockstate to replace if it still exists | ||
* @param to the new blockstate | ||
* @return true if the expected blockstate match and the block was set, false otherwise | ||
*/ | ||
boolean swapBlockStateAtomic(Lock lock, long x, long y, long z, IBlockState expected, IBlockState to); | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...ft/Server/Concurrent/IAtomicSubChunk.java → ...World/NewWorldSystem/IAtomicSubChunk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters