forked from lishid/Orebfuscator
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve overall memory footprint per player (#359)
* fix: memory leak if player login is cancelled * feat: reduce memory footprint of proximity block data * chore: streamline nms instance constructor * fix: ci warning
- Loading branch information
Showing
36 changed files
with
323 additions
and
308 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
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
44 changes: 44 additions & 0 deletions
44
orebfuscator-common/src/test/java/net/imprex/orebfuscator/util/BlockPosTest.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,44 @@ | ||
package net.imprex.orebfuscator.util; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
public class BlockPosTest { | ||
|
||
@Test | ||
public void testLongFormat() { | ||
BlockPos positionA = new BlockPos(-52134, BlockPos.MAX_Y, 6243234); | ||
BlockPos positionB = new BlockPos(0, BlockPos.MIN_Y, -4); | ||
BlockPos positionC = new BlockPos(15, 0, -5663423); | ||
BlockPos positionD = new BlockPos(21523, 16, -5663423); | ||
|
||
long valueA = positionA.toLong(); | ||
long valueB = positionB.toLong(); | ||
long valueC = positionC.toLong(); | ||
long valueD = positionD.toLong(); | ||
|
||
assertEquals(positionA, BlockPos.fromLong(valueA)); | ||
assertEquals(positionB, BlockPos.fromLong(valueB)); | ||
assertEquals(positionC, BlockPos.fromLong(valueC)); | ||
assertEquals(positionD, BlockPos.fromLong(valueD)); | ||
} | ||
|
||
@Test | ||
public void testSectionPos() { | ||
final int chunkX = -42 << 4; | ||
final int chunkZ = 6521 << 4; | ||
|
||
BlockPos positionA = new BlockPos(chunkX + 8, BlockPos.MAX_Y, chunkZ); | ||
BlockPos positionB = new BlockPos(chunkX, BlockPos.MIN_Y, chunkZ + 15); | ||
BlockPos positionC = new BlockPos(chunkX + 15, 0, chunkZ + 4); | ||
|
||
int sectionPosA = positionA.toSectionPos(); | ||
int sectionPosB = positionB.toSectionPos(); | ||
int sectionPosC = positionC.toSectionPos(); | ||
|
||
assertEquals(positionA, BlockPos.fromSectionPos(chunkX, chunkZ, sectionPosA)); | ||
assertEquals(positionB, BlockPos.fromSectionPos(chunkX, chunkZ, sectionPosB)); | ||
assertEquals(positionC, BlockPos.fromSectionPos(chunkX, chunkZ, sectionPosC)); | ||
} | ||
} |
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
Oops, something went wrong.