mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 19:18:12 +01:00
Ensure that block placements send BlockChangePacket
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
57976a1595
commit
d3fa4c810f
@ -15,6 +15,10 @@ public interface TestConnection {
|
|||||||
|
|
||||||
<T extends ServerPacket> @NotNull PacketTracker<T> trackIncoming(@NotNull Class<T> type);
|
<T extends ServerPacket> @NotNull PacketTracker<T> trackIncoming(@NotNull Class<T> type);
|
||||||
|
|
||||||
|
default @NotNull PacketTracker<ServerPacket> trackIncoming(){
|
||||||
|
return trackIncoming(ServerPacket.class);
|
||||||
|
}
|
||||||
|
|
||||||
interface PacketTracker<T> {
|
interface PacketTracker<T> {
|
||||||
@NotNull List<@NotNull T> collect();
|
@NotNull List<@NotNull T> collect();
|
||||||
|
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package net.minestom.server.instance;
|
||||||
|
|
||||||
|
import net.minestom.server.api.Env;
|
||||||
|
import net.minestom.server.api.EnvTest;
|
||||||
|
import net.minestom.server.coordinate.Pos;
|
||||||
|
import net.minestom.server.coordinate.Vec;
|
||||||
|
import net.minestom.server.instance.block.Block;
|
||||||
|
import net.minestom.server.network.packet.server.play.BlockChangePacket;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
@EnvTest
|
||||||
|
public class InstanceBlockIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void playerUpdate(Env env) {
|
||||||
|
var instance = env.createFlatInstance();
|
||||||
|
var connection = env.createConnection();
|
||||||
|
connection.connect(instance, new Pos(0, 40, 0)).join();
|
||||||
|
|
||||||
|
var tracker = connection.trackIncoming();
|
||||||
|
// Replace air
|
||||||
|
tracker = connection.trackIncoming();
|
||||||
|
instance.setBlock(5, 41, 0, Block.STONE);
|
||||||
|
tracker.assertSingle(BlockChangePacket.class, packet -> {
|
||||||
|
assertEquals(new Vec(5, 41, 0), packet.blockPosition());
|
||||||
|
assertEquals(Block.STONE.stateId(), packet.blockStateId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user