Skip to content

Commit 6a0d3bc

Browse files
TheMeinerLPAm-Goneiam4722202468DasBabyPixelTheMode
committed
Pull upstream (#73)
* Fix entity position desync when spawned in an 8 block radius from world center (0,0,0) (Minestom#2299) * fix: entity spawn pos desync * Fix tests * Update API for swept entity <-> entity collisions (Minestom#2343) * Update API for swept entity <-> entity collisions * Move EntityCollisionResult to its own class (Minestom#2345) * Move EntityCollisionResult to its own class * Return directional information from entity collision (Minestom#2346) * fix entity collisions (Minestom#2348) * Ability to get collision shape position from PhysicsResult (Minestom#2355) * ability to get collision shape position from PhysicsResult * Coordinate limit to prevent potential overflow * fix some jcstress files * clear remaining hephaistos usage * Make BoundingBox/ShapeImpl records (Minestom#2371) * Use a single int for all block states (Minestom#2373) * Light cleanup (Minestom#2372) * record namespace (Minestom#2374) * Add EquipmentSlot.BODY (Minestom#2325) * Add EquipmentSlot.BODY * EntityEquipmentPacket should now have 7 entries * Simplify isHand check * Fix tests --------- Co-authored-by: Matt Worzala <35708499+mworzala@users.noreply.github.com> * unused cache * Implement Graph Cache in CommandManager (Minestom#2360) * update dependencies * Remove caffeine dependency from EventNode (Minestom#2375) * Remove mojang utils cache * fix team visibility (Minestom#2186) * Fix chunks not being refreshed when view distance updates (Minestom#2197) * Fix chunks not being refreshed when view distance updates * give more control of collisions to the entities colliding (Minestom#2350) * give more control of collisions to the entities colliding * Playsound exclude (Minestom#2381) * Add Instance::playSoundExcept * Uh... * fix: saturation not working in food item component (Minestom#2382) * fix missing inversion in DataComponentMap#diff handling for removed entries (Minestom#2359) * More Vec operator, more min/max methods * Remove no longer exists methods * Disable failed test * Improve AtomicReference handling * Fix test execution when loading chunk outside of the main thread * Improve AtomicReference handling in some tests --------- Co-authored-by: Am Gone <67794767+Am-Gone@users.noreply.github.com> Co-authored-by: iam <iam4722202468@users.noreply.github.com> Co-authored-by: Lorenz Wrobel <43410952+DasBabyPixel@users.noreply.github.com> Co-authored-by: themode <themode@outlook.fr> Co-authored-by: TogAr2 <59421074+TogAr2@users.noreply.github.com> Co-authored-by: Matt Worzala <35708499+mworzala@users.noreply.github.com> Co-authored-by: Kerman <46640204+KermanIsPretty@users.noreply.github.com> Co-authored-by: bea4dev <34712108+bea4dev@users.noreply.github.com> Co-authored-by: GreatWyrm <alecmusante@gmail.com> Co-authored-by: Samuel <pifnpafnpouf@gmail.com> Co-authored-by: SLH <114884726+SLH335@users.noreply.github.com> Co-authored-by: Floweynt <50057682+Floweynt@users.noreply.github.com> Co-authored-by: theEvilReaper <steffenwx@gmail.com>
1 parent b75f365 commit 6a0d3bc

9 files changed

+49
-2
lines changed

src/test/java/net/minestom/server/ServerProcessTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void init() {
2121
assertDoesNotThrow(() -> process.get().start(new InetSocketAddress("localhost", 25565)));
2222
assertThrows(Exception.class, () -> process.get().start(new InetSocketAddress("localhost", 25566)));
2323
assertDoesNotThrow(() -> process.get().stop());
24+
process.set(null);
2425
}
2526

2627
@Test

src/test/java/net/minestom/server/collision/EntityProjectileCollisionIntegrationTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ void blockShootAndBlockRemoval(Env env) {
7171
assertNotNull(event);
7272
assertNotNull(event2);
7373
assertEquals(blockPosition.withY(y -> y - 1), new Vec(event.getCollisionPosition().blockX(), event.getCollisionPosition().blockY(), event.getCollisionPosition().blockZ()));
74+
eventRef.set(null);
75+
eventRef2.set(null);
7476
}
7577

7678
@Test
@@ -151,6 +153,6 @@ void entitySelfShoot(Env env) {
151153
assertNotNull(event);
152154
assertSame(shooter, event.getTarget());
153155
assertTrue(shooter.getBoundingBox().intersectEntity(shooter.getPosition(), projectile));
156+
eventRef.set(null);
154157
}
155-
156158
}

src/test/java/net/minestom/server/command/CommandParseTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ void singleCommandOptionalArgs() {
8989
assertValid(foo, "foo T", b);
9090
expectedFirstArg.set("A");
9191
assertValid(foo, "foo", b);
92+
expectedFirstArg.set(null);
9293
}
9394

9495
@Test

src/test/java/net/minestom/server/command/CommandSyntaxSingleTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ private static void assertSyntax(List<Argument<?>> args, String input, ExpectedE
174174
if (expectedValues != null) {
175175
assertEquals(expectedValues, values.get());
176176
}
177+
178+
result.set(null);
179+
values.set(null);
177180
}
178181

179182
private static void assertSyntax(List<Argument<?>> args, String input, ExpectedExecution expectedExecution) {

src/test/java/net/minestom/server/entity/player/PlayerMovementIntegrationTest.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ void teleportConfirm(Env env) {
4747
p1.addPacketToQueue(new ClientPlayerPositionPacket(new Pos(0.2, 40, 0), true));
4848
p1.interpretPacketQueue();
4949
assertEquals(new Pos(0.2, 40, 0), p1.getPosition());
50+
p1.remove();
51+
env.destroyInstance(instance);
5052
}
5153

5254
// FIXME
@@ -119,6 +121,8 @@ void chunkUpdateDebounceTest(Env env) {
119121
player.addPacketToQueue(new ClientPlayerPositionPacket(new Vec(16.5, 40, -16.5), true));
120122
player.interpretPacketQueue();
121123
chunkDataPacketCollector.assertCount(viewDiameter * 2 - 1);
124+
player.remove();
125+
env.destroyInstance(flatInstance);
122126
}
123127

124128
@Test
@@ -140,6 +144,39 @@ void testClientViewDistanceSettings(Env env) {
140144
player.addPacketToQueue(new ClientPlayerPositionPacket(new Vec(160.5, 40, 160.5), true));
141145
player.interpretPacketQueue();
142146
chunkDataPacketCollector.assertCount(MathUtils.square(viewDistance * 2 + 1));
147+
player.remove();
148+
env.destroyInstance(flatInstance);
149+
}
150+
151+
@Test
152+
public void testSettingsViewDistanceExpansionAndShrink(Env env) {
153+
int startingViewDistance = 8;
154+
byte endViewDistance = 12;
155+
byte finalViewDistance = 10;
156+
var instance = env.createFlatInstance();
157+
var connection = env.createConnection();
158+
Pos startingPlayerPos = new Pos(0, 42, 0);
159+
var player = connection.connect(instance, startingPlayerPos).join();
160+
161+
int chunkDifference = ChunkUtils.getChunkCount(endViewDistance) - ChunkUtils.getChunkCount(startingViewDistance);
162+
// Preload chunks, otherwise our first tracker.assertCount call will fail randomly due to chunks being loaded off the main thread
163+
Set<CompletableFuture<Chunk>> chunks = new HashSet<>();
164+
ChunkUtils.forChunksInRange(0, 0, endViewDistance, (v1, v2) -> chunks.add(instance.loadChunk(v1, v2)));
165+
CompletableFuture.allOf(chunks.toArray(CompletableFuture[]::new)).join();
166+
167+
var tracker = connection.trackIncoming(ChunkDataPacket.class);
168+
player.addPacketToQueue(new ClientSettingsPacket("en_US", endViewDistance, ChatMessageType.FULL, false, (byte) 0, Player.MainHand.RIGHT, false, true));
169+
player.interpretPacketQueue();
170+
tracker.assertCount(chunkDifference);
171+
172+
var tracker1 = connection.trackIncoming(UnloadChunkPacket.class);
173+
player.addPacketToQueue(new ClientSettingsPacket("en_US", finalViewDistance, ChatMessageType.FULL, false, (byte) 0, Player.MainHand.RIGHT, false, true));
174+
player.interpretPacketQueue();
175+
176+
int chunkDifference1 = ChunkUtils.getChunkCount(endViewDistance) - ChunkUtils.getChunkCount(finalViewDistance);
177+
tracker1.assertCount(chunkDifference1);
178+
player.remove();
179+
env.destroyInstance(instance);
143180
}
144181

145182
@Test

src/test/java/net/minestom/server/instance/GeneratorIntegrationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void exceptionCatch(Env env) {
4747
instance.loadChunk(0, 0).join();
4848

4949
assertSame(exception, ref.get());
50+
ref.set(null);
5051
}
5152

5253
@Test

src/test/java/net/minestom/server/instance/InstanceBlockIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ void blockNbt(Env env) {
8383

8484
@Test
8585
public void handlerPresentInPlacementRuleUpdate(Env env) {
86-
8786
AtomicReference<Block> currentBlock = new AtomicReference<>();
8887
env.process().block().registerHandler(SuspiciousGravelBlockHandler.INSTANCE.getNamespaceId(), () -> SuspiciousGravelBlockHandler.INSTANCE);
8988
env.process().block().registerBlockPlacementRule(new BlockPlacementRule(Block.SUSPICIOUS_GRAVEL) {
@@ -105,5 +104,6 @@ public void handlerPresentInPlacementRuleUpdate(Env env) {
105104
instance.setBlock(1, 50, 0, theBlock);
106105

107106
assertEquals(theBlock, currentBlock.get());
107+
currentBlock.set(null);
108108
}
109109
}

src/test/java/net/minestom/server/instance/anvil/AnvilLoaderIntegrationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void parallelSaveNonexistentFiles(Env env) throws Exception {
7474
});
7575
instance.saveChunksToStorage().join();
7676
assertNull(exception.get());
77+
exception.set(null);
7778
}
7879

7980
@Test

src/test/java/net/minestom/server/instance/generator/GeneratorForkConsumerIntegrationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void empty(Env env) {
3232
});
3333
instance.loadChunk(0, 0).join();
3434
assertNull(failed.get(), "Failed: " + failed.get());
35+
failed.set(null);
3536
}
3637

3738
@Test

0 commit comments

Comments
 (0)