mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
parent
ef0daa08bb
commit
833c5fe365
@ -157,17 +157,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
|
||||
final IntegerBiConsumer chunkAdder = (chunkX, chunkZ) -> {
|
||||
// Load new chunks
|
||||
this.instance.loadOptionalChunk(chunkX, chunkZ).thenAccept(chunk -> {
|
||||
if (chunk == null) return;
|
||||
chunkQueueLock.lock();
|
||||
try {
|
||||
chunkQueue.enqueue(ChunkUtils.getChunkIndex(chunkX, chunkZ));
|
||||
} catch (Exception e) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
} finally {
|
||||
chunkQueueLock.unlock();
|
||||
}
|
||||
});
|
||||
this.instance.loadOptionalChunk(chunkX, chunkZ).thenAccept(this::sendChunk);
|
||||
};
|
||||
final IntegerBiConsumer chunkRemover = (chunkX, chunkZ) -> {
|
||||
// Unload old chunks
|
||||
|
@ -221,10 +221,13 @@ public class AnvilLoader implements IChunkLoader {
|
||||
Block[] convertedPalette = new Block[blockPalette.getSize()];
|
||||
for (int i = 0; i < convertedPalette.length; i++) {
|
||||
final NBTCompound paletteEntry = blockPalette.get(i);
|
||||
final String blockName = Objects.requireNonNull(paletteEntry.getString("Name"));
|
||||
String blockName = Objects.requireNonNull(paletteEntry.getString("Name"));
|
||||
if (blockName.equals("minecraft:air")) {
|
||||
convertedPalette[i] = Block.AIR;
|
||||
} else {
|
||||
if (blockName.equals("minecraft:grass")) {
|
||||
blockName = "minecraft:short_grass";
|
||||
}
|
||||
Block block = Objects.requireNonNull(Block.fromNamespaceId(blockName));
|
||||
// Properties
|
||||
final Map<String, String> properties = new HashMap<>();
|
||||
|
@ -41,6 +41,9 @@ public class WorldBorder {
|
||||
this.speed = 0;
|
||||
|
||||
this.portalTeleportBoundary = ServerFlag.WORLD_BORDER_SIZE;
|
||||
|
||||
// Update immediately so the current size is present on init
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,7 +107,7 @@ public class BlockPlacementListener {
|
||||
|
||||
var placementBlock = instance.getBlock(placementPosition);
|
||||
var placementRule = BLOCK_MANAGER.getBlockPlacementRule(placementBlock);
|
||||
if (!placementBlock.registry().isReplaceable() && (placementRule == null || !placementRule.isSelfReplaceable(
|
||||
if (!placementBlock.registry().isReplaceable() && !(placementRule != null && placementRule.isSelfReplaceable(
|
||||
new BlockPlacementRule.Replacement(placementBlock, blockFace, cursorPosition, useMaterial)))) {
|
||||
// If the block is still not replaceable, cancel the placement
|
||||
canPlaceBlock = false;
|
||||
|
@ -130,7 +130,7 @@ public class CommandSyntaxSingleTest {
|
||||
// enchant block block enchant
|
||||
{
|
||||
var context1 = new CommandContext("minecraft:sharpness minecraft:stone");
|
||||
var context2 = new CommandContext("minecraft:grass minecraft:efficiency");
|
||||
var context2 = new CommandContext("minecraft:grass_block minecraft:efficiency");
|
||||
|
||||
context1.setArg("enchant", Enchantment.SHARPNESS, "minecraft:sharpness");
|
||||
context1.setArg("block", Block.STONE, "minecraft:stone");
|
||||
|
@ -71,8 +71,8 @@ public class PlayerMovementIntegrationTest {
|
||||
ChunkUtils.forChunksInRange(0, 0, viewDiameter+2, (x, z) -> chunks.add(flatInstance.loadChunk(x, z)));
|
||||
CompletableFuture.allOf(chunks.toArray(CompletableFuture[]::new)).join();
|
||||
final TestConnection connection = env.createConnection();
|
||||
final CompletableFuture<@NotNull Player> future = connection.connect(flatInstance, new Pos(0.5, 40, 0.5));
|
||||
Collector<ChunkDataPacket> chunkDataPacketCollector = connection.trackIncoming(ChunkDataPacket.class);
|
||||
final CompletableFuture<@NotNull Player> future = connection.connect(flatInstance, new Pos(0.5, 40, 0.5));
|
||||
final Player player = future.join();
|
||||
// Initial join
|
||||
chunkDataPacketCollector.assertCount(MathUtils.square(viewDiameter));
|
||||
|
@ -82,7 +82,7 @@ public class BlockTest {
|
||||
Point start = Block.LANTERN.registry().collisionShape().relativeStart();
|
||||
Point end = Block.LANTERN.registry().collisionShape().relativeEnd();
|
||||
|
||||
assertEquals(start, new Vec(0.312, 0, 0.312));
|
||||
assertEquals(end, new Vec(0.687, 0.562, 0.687));
|
||||
assertEquals(start, new Vec(0.3125, 0, 0.3125));
|
||||
assertEquals(end, new Vec(0.6875, 0.5625, 0.6875));
|
||||
}
|
||||
}
|
||||
|
@ -158,8 +158,10 @@ public class LightParityIntegrationTest {
|
||||
for (int z = 0; z < Chunk.CHUNK_SECTION_SIZE; z++) {
|
||||
for (int y = 0; y < Chunk.CHUNK_SECTION_SIZE; y++) {
|
||||
final BlockState blockState = section.get(x, y, z);
|
||||
final String blockName = blockState.getName();
|
||||
Block block = Objects.requireNonNull(Block.fromNamespaceId(blockName))
|
||||
String blockName = blockState.getName();
|
||||
if (blockName.equals("minecraft:grass"))
|
||||
blockName = "minecraft:short_grass";
|
||||
Block block = Objects.requireNonNull(Block.fromNamespaceId(blockName), blockName)
|
||||
.withProperties(blockState.getProperties());
|
||||
palette.set(x, y, z, block.stateId());
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void test2dOffsetppp() {
|
||||
Vec s = new Vec(0, 0.1, 0);
|
||||
Vec s = new Vec(0, 0.1, 0);
|
||||
Vec e = new Vec(2, 1, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 4);
|
||||
|
||||
@ -30,7 +30,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void test2dOffsetppn() {
|
||||
Vec s = new Vec(0, 0.1, 0);
|
||||
Vec s = new Vec(0, 0.1, 0);
|
||||
Vec e = new Vec(-2, 1, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 4);
|
||||
|
||||
@ -45,7 +45,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void test2dOffsetnpp() {
|
||||
Vec s = new Vec(0, -0.1, 0);
|
||||
Vec s = new Vec(0, -0.1, 0);
|
||||
Vec e = new Vec(2, 1, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 4);
|
||||
|
||||
@ -60,7 +60,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void test2dOffsetnnp() {
|
||||
Vec s = new Vec(0, -0.1, 0);
|
||||
Vec s = new Vec(0, -0.1, 0);
|
||||
Vec e = new Vec(-2, 1, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 4);
|
||||
|
||||
@ -76,7 +76,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void testZeroVelocity() {
|
||||
Vec s = new Vec(0, 0, 0);
|
||||
Vec s = new Vec(0, 0, 0);
|
||||
Vec e = new Vec(0, 0, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 4);
|
||||
assertFalse(iterator.hasNext());
|
||||
@ -93,67 +93,67 @@ public class BlockIteratorTest {
|
||||
points.add(iterator.next());
|
||||
}
|
||||
|
||||
Point[] validPoints = new Point[] {
|
||||
new Vec(42.0, 0.0, 51.0),
|
||||
new Vec(42.0, 0.0, 50.0),
|
||||
new Vec(41.0, 0.0, 50.0),
|
||||
new Vec(42.0, 0.0, 49.0),
|
||||
new Vec(41.0, 0.0, 49.0),
|
||||
new Vec(41.0, 0.0, 48.0),
|
||||
new Vec(41.0, 0.0, 47.0),
|
||||
new Vec(40.0, 0.0, 47.0),
|
||||
new Vec(41.0, 0.0, 46.0),
|
||||
new Vec(40.0, 0.0, 46.0),
|
||||
new Vec(40.0, 0.0, 45.0),
|
||||
new Vec(40.0, 0.0, 44.0),
|
||||
new Vec(39.0, 0.0, 44.0),
|
||||
new Vec(40.0, 0.0, 43.0),
|
||||
new Vec(39.0, 0.0, 43.0),
|
||||
new Vec(39.0, 0.0, 42.0),
|
||||
new Vec(39.0, 0.0, 41.0),
|
||||
new Vec(38.0, 0.0, 41.0),
|
||||
new Vec(39.0, 0.0, 40.0),
|
||||
new Vec(38.0, 0.0, 40.0),
|
||||
new Vec(38.0, 0.0, 39.0),
|
||||
new Vec(38.0, 0.0, 38.0),
|
||||
new Vec(37.0, 0.0, 38.0),
|
||||
new Vec(38.0, 0.0, 37.0),
|
||||
new Vec(37.0, 0.0, 37.0),
|
||||
new Vec(37.0, 0.0, 36.0),
|
||||
new Vec(37.0, 0.0, 35.0),
|
||||
new Vec(36.0, 0.0, 35.0),
|
||||
new Vec(37.0, 0.0, 34.0),
|
||||
new Vec(36.0, 0.0, 34.0),
|
||||
new Vec(36.0, 0.0, 33.0),
|
||||
new Vec(36.0, 0.0, 32.0),
|
||||
new Vec(35.0, 0.0, 32.0),
|
||||
new Vec(36.0, 0.0, 31.0),
|
||||
new Vec(35.0, 0.0, 31.0),
|
||||
new Vec(35.0, 0.0, 30.0),
|
||||
new Vec(35.0, 0.0, 29.0),
|
||||
new Vec(34.0, 0.0, 29.0),
|
||||
new Vec(35.0, 0.0, 28.0),
|
||||
new Vec(34.0, 0.0, 28.0),
|
||||
new Vec(34.0, 0.0, 27.0),
|
||||
new Vec(34.0, 0.0, 26.0),
|
||||
new Vec(33.0, 0.0, 26.0),
|
||||
new Vec(34.0, 0.0, 25.0),
|
||||
new Vec(33.0, 0.0, 25.0),
|
||||
new Vec(33.0, 0.0, 24.0),
|
||||
new Vec(33.0, 0.0, 23.0),
|
||||
new Vec(32.0, 0.0, 23.0),
|
||||
new Vec(33.0, 0.0, 22.0),
|
||||
new Vec(32.0, 0.0, 22.0),
|
||||
new Vec(32.0, 0.0, 21.0),
|
||||
new Vec(32.0, 0.0, 20.0),
|
||||
new Vec(31.0, 0.0, 20.0),
|
||||
new Vec(32.0, 0.0, 19.0),
|
||||
new Vec(31.0, 0.0, 19.0),
|
||||
new Vec(31.0, 0.0, 18.0),
|
||||
new Vec(31.0, 0.0, 17.0),
|
||||
new Vec(30.0, 0.0, 17.0),
|
||||
new Vec(31.0, 0.0, 16.0),
|
||||
new Vec(30.0, 0.0, 16.0)
|
||||
Point[] validPoints = new Point[]{
|
||||
new Vec(42.0, 0.0, 51.0),
|
||||
new Vec(42.0, 0.0, 50.0),
|
||||
new Vec(41.0, 0.0, 50.0),
|
||||
new Vec(42.0, 0.0, 49.0),
|
||||
new Vec(41.0, 0.0, 49.0),
|
||||
new Vec(41.0, 0.0, 48.0),
|
||||
new Vec(41.0, 0.0, 47.0),
|
||||
new Vec(40.0, 0.0, 47.0),
|
||||
new Vec(41.0, 0.0, 46.0),
|
||||
new Vec(40.0, 0.0, 46.0),
|
||||
new Vec(40.0, 0.0, 45.0),
|
||||
new Vec(40.0, 0.0, 44.0),
|
||||
new Vec(39.0, 0.0, 44.0),
|
||||
new Vec(40.0, 0.0, 43.0),
|
||||
new Vec(39.0, 0.0, 43.0),
|
||||
new Vec(39.0, 0.0, 42.0),
|
||||
new Vec(39.0, 0.0, 41.0),
|
||||
new Vec(38.0, 0.0, 41.0),
|
||||
new Vec(39.0, 0.0, 40.0),
|
||||
new Vec(38.0, 0.0, 40.0),
|
||||
new Vec(38.0, 0.0, 39.0),
|
||||
new Vec(38.0, 0.0, 38.0),
|
||||
new Vec(37.0, 0.0, 38.0),
|
||||
new Vec(38.0, 0.0, 37.0),
|
||||
new Vec(37.0, 0.0, 37.0),
|
||||
new Vec(37.0, 0.0, 36.0),
|
||||
new Vec(37.0, 0.0, 35.0),
|
||||
new Vec(36.0, 0.0, 35.0),
|
||||
new Vec(37.0, 0.0, 34.0),
|
||||
new Vec(36.0, 0.0, 34.0),
|
||||
new Vec(36.0, 0.0, 33.0),
|
||||
new Vec(36.0, 0.0, 32.0),
|
||||
new Vec(35.0, 0.0, 32.0),
|
||||
new Vec(36.0, 0.0, 31.0),
|
||||
new Vec(35.0, 0.0, 31.0),
|
||||
new Vec(35.0, 0.0, 30.0),
|
||||
new Vec(35.0, 0.0, 29.0),
|
||||
new Vec(34.0, 0.0, 29.0),
|
||||
new Vec(35.0, 0.0, 28.0),
|
||||
new Vec(34.0, 0.0, 28.0),
|
||||
new Vec(34.0, 0.0, 27.0),
|
||||
new Vec(34.0, 0.0, 26.0),
|
||||
new Vec(33.0, 0.0, 26.0),
|
||||
new Vec(34.0, 0.0, 25.0),
|
||||
new Vec(33.0, 0.0, 25.0),
|
||||
new Vec(33.0, 0.0, 24.0),
|
||||
new Vec(33.0, 0.0, 23.0),
|
||||
new Vec(32.0, 0.0, 23.0),
|
||||
new Vec(33.0, 0.0, 22.0),
|
||||
new Vec(32.0, 0.0, 22.0),
|
||||
new Vec(32.0, 0.0, 21.0),
|
||||
new Vec(32.0, 0.0, 20.0),
|
||||
new Vec(31.0, 0.0, 20.0),
|
||||
new Vec(32.0, 0.0, 19.0),
|
||||
new Vec(31.0, 0.0, 19.0),
|
||||
new Vec(31.0, 0.0, 18.0),
|
||||
new Vec(31.0, 0.0, 17.0),
|
||||
new Vec(30.0, 0.0, 17.0),
|
||||
new Vec(31.0, 0.0, 16.0),
|
||||
new Vec(30.0, 0.0, 16.0)
|
||||
};
|
||||
|
||||
for (Point p : validPoints) {
|
||||
@ -173,59 +173,59 @@ public class BlockIteratorTest {
|
||||
points.add(iterator.next());
|
||||
}
|
||||
|
||||
Point[] validPoints = new Point[] {
|
||||
new Vec(0.0, 40.0, 0.0),
|
||||
new Vec(1.0, 40.0, 0.0),
|
||||
new Vec(1.0, 40.0, 1.0),
|
||||
new Vec(2.0, 40.0, 1.0),
|
||||
new Vec(2.0, 40.0, 2.0),
|
||||
new Vec(3.0, 40.0, 2.0),
|
||||
new Vec(3.0, 40.0, 3.0),
|
||||
new Vec(4.0, 40.0, 3.0),
|
||||
new Vec(5.0, 40.0, 3.0),
|
||||
new Vec(4.0, 40.0, 4.0),
|
||||
new Vec(5.0, 40.0, 4.0),
|
||||
new Vec(6.0, 40.0, 4.0),
|
||||
new Vec(6.0, 40.0, 5.0),
|
||||
new Vec(7.0, 40.0, 5.0),
|
||||
new Vec(7.0, 40.0, 6.0),
|
||||
new Vec(8.0, 40.0, 6.0),
|
||||
new Vec(8.0, 40.0, 7.0),
|
||||
new Vec(9.0, 40.0, 7.0),
|
||||
new Vec(10.0, 40.0, 7.0),
|
||||
new Vec(10.0, 40.0, 8.0),
|
||||
new Vec(11.0, 40.0, 8.0),
|
||||
new Vec(11.0, 40.0, 9.0),
|
||||
new Vec(12.0, 40.0, 9.0),
|
||||
new Vec(12.0, 40.0, 10.0),
|
||||
new Vec(13.0, 40.0, 10.0),
|
||||
new Vec(14.0, 40.0, 10.0),
|
||||
new Vec(13.0, 40.0, 11.0),
|
||||
new Vec(14.0, 40.0, 11.0),
|
||||
new Vec(15.0, 40.0, 11.0),
|
||||
new Vec(15.0, 40.0, 12.0),
|
||||
new Vec(16.0, 40.0, 12.0),
|
||||
new Vec(16.0, 40.0, 13.0),
|
||||
new Vec(17.0, 40.0, 13.0),
|
||||
new Vec(17.0, 40.0, 14.0),
|
||||
new Vec(18.0, 40.0, 14.0),
|
||||
new Vec(19.0, 40.0, 14.0),
|
||||
new Vec(19.0, 40.0, 15.0),
|
||||
new Vec(20.0, 40.0, 15.0),
|
||||
new Vec(20.0, 40.0, 16.0),
|
||||
new Vec(21.0, 40.0, 16.0),
|
||||
new Vec(21.0, 40.0, 17.0),
|
||||
new Vec(22.0, 40.0, 17.0),
|
||||
new Vec(23.0, 40.0, 17.0),
|
||||
new Vec(22.0, 40.0, 18.0),
|
||||
new Vec(23.0, 40.0, 18.0),
|
||||
new Vec(24.0, 40.0, 18.0),
|
||||
new Vec(24.0, 40.0, 19.0),
|
||||
new Vec(25.0, 40.0, 19.0),
|
||||
new Vec(25.0, 40.0, 20.0),
|
||||
new Vec(26.0, 40.0, 20.0),
|
||||
new Vec(26.0, 40.0, 21.0),
|
||||
new Vec(27.0, 40.0, 21.0)
|
||||
Point[] validPoints = new Point[]{
|
||||
new Vec(0.0, 40.0, 0.0),
|
||||
new Vec(1.0, 40.0, 0.0),
|
||||
new Vec(1.0, 40.0, 1.0),
|
||||
new Vec(2.0, 40.0, 1.0),
|
||||
new Vec(2.0, 40.0, 2.0),
|
||||
new Vec(3.0, 40.0, 2.0),
|
||||
new Vec(3.0, 40.0, 3.0),
|
||||
new Vec(4.0, 40.0, 3.0),
|
||||
new Vec(5.0, 40.0, 3.0),
|
||||
new Vec(4.0, 40.0, 4.0),
|
||||
new Vec(5.0, 40.0, 4.0),
|
||||
new Vec(6.0, 40.0, 4.0),
|
||||
new Vec(6.0, 40.0, 5.0),
|
||||
new Vec(7.0, 40.0, 5.0),
|
||||
new Vec(7.0, 40.0, 6.0),
|
||||
new Vec(8.0, 40.0, 6.0),
|
||||
new Vec(8.0, 40.0, 7.0),
|
||||
new Vec(9.0, 40.0, 7.0),
|
||||
new Vec(10.0, 40.0, 7.0),
|
||||
new Vec(10.0, 40.0, 8.0),
|
||||
new Vec(11.0, 40.0, 8.0),
|
||||
new Vec(11.0, 40.0, 9.0),
|
||||
new Vec(12.0, 40.0, 9.0),
|
||||
new Vec(12.0, 40.0, 10.0),
|
||||
new Vec(13.0, 40.0, 10.0),
|
||||
new Vec(14.0, 40.0, 10.0),
|
||||
new Vec(13.0, 40.0, 11.0),
|
||||
new Vec(14.0, 40.0, 11.0),
|
||||
new Vec(15.0, 40.0, 11.0),
|
||||
new Vec(15.0, 40.0, 12.0),
|
||||
new Vec(16.0, 40.0, 12.0),
|
||||
new Vec(16.0, 40.0, 13.0),
|
||||
new Vec(17.0, 40.0, 13.0),
|
||||
new Vec(17.0, 40.0, 14.0),
|
||||
new Vec(18.0, 40.0, 14.0),
|
||||
new Vec(19.0, 40.0, 14.0),
|
||||
new Vec(19.0, 40.0, 15.0),
|
||||
new Vec(20.0, 40.0, 15.0),
|
||||
new Vec(20.0, 40.0, 16.0),
|
||||
new Vec(21.0, 40.0, 16.0),
|
||||
new Vec(21.0, 40.0, 17.0),
|
||||
new Vec(22.0, 40.0, 17.0),
|
||||
new Vec(23.0, 40.0, 17.0),
|
||||
new Vec(22.0, 40.0, 18.0),
|
||||
new Vec(23.0, 40.0, 18.0),
|
||||
new Vec(24.0, 40.0, 18.0),
|
||||
new Vec(24.0, 40.0, 19.0),
|
||||
new Vec(25.0, 40.0, 19.0),
|
||||
new Vec(25.0, 40.0, 20.0),
|
||||
new Vec(26.0, 40.0, 20.0),
|
||||
new Vec(26.0, 40.0, 21.0),
|
||||
new Vec(27.0, 40.0, 21.0)
|
||||
};
|
||||
|
||||
for (Point p : validPoints) {
|
||||
@ -236,7 +236,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void testExactEnd() {
|
||||
Vec s = new Vec(0.5, 0, 0.5);
|
||||
Vec s = new Vec(0.5, 0, 0.5);
|
||||
Vec e = new Vec(0, 1, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 1);
|
||||
assertEquals(new Vec(0, 0, 0), iterator.next());
|
||||
@ -246,7 +246,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void testSameEnd() {
|
||||
Vec s = new Vec(0.5, 0, 0.5);
|
||||
Vec s = new Vec(0.5, 0, 0.5);
|
||||
Vec e = new Vec(0, 1, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 0.5);
|
||||
assertEquals(new Vec(0, 0, 0), iterator.next());
|
||||
@ -255,7 +255,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void test3dExtraCollection() {
|
||||
Vec s = new Vec(0.1, 0.1, 0.1);
|
||||
Vec s = new Vec(0.1, 0.1, 0.1);
|
||||
Vec e = new Vec(1, 1, 1);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 4);
|
||||
|
||||
@ -264,16 +264,24 @@ public class BlockIteratorTest {
|
||||
points.add(iterator.next());
|
||||
}
|
||||
|
||||
Point[] validPoints = new Point[] {
|
||||
new Vec(0.0, 0.0, 0.0),
|
||||
new Vec(1.0, 0.0, 0.0),
|
||||
new Vec(0.0, 1.0, 0.0),
|
||||
new Vec(0.0, 0.0, 1.0),
|
||||
new Vec(1.0, 1.0, 1.0),
|
||||
new Vec(2.0, 1.0, 1.0),
|
||||
new Vec(1.0, 2.0, 1.0),
|
||||
new Vec(1.0, 1.0, 2.0),
|
||||
new Vec(2.0, 2.0, 2.0)
|
||||
Point[] validPoints = new Point[]{
|
||||
new Vec(0.0, 0.0, 0.0),
|
||||
new Vec(1.0, 0.0, 0.0),
|
||||
new Vec(0.0, 1.0, 0.0),
|
||||
new Vec(0.0, 0.0, 1.0),
|
||||
new Vec(1.0, 1.0, 1.0),
|
||||
new Vec(2.0, 1.0, 1.0),
|
||||
new Vec(1.0, 2.0, 1.0),
|
||||
new Vec(1.0, 1.0, 2.0),
|
||||
new Vec(2.0, 2.0, 2.0),
|
||||
|
||||
// todo(mattw): I need to confirm that these are correct
|
||||
new Vec(1.0, 1.0, 0.0),
|
||||
new Vec(0.0, 1.0, 1.0),
|
||||
new Vec(1.0, 0.0, 1.0),
|
||||
new Vec(2.0, 2.0, 1.0),
|
||||
new Vec(1.0, 2.0, 2.0),
|
||||
new Vec(2.0, 1.0, 2.0)
|
||||
};
|
||||
|
||||
for (Point p : validPoints) {
|
||||
@ -284,7 +292,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void test2dpp() {
|
||||
Vec s = new Vec(0, 0, 0);
|
||||
Vec s = new Vec(0, 0, 0);
|
||||
Vec e = new Vec(2, 1, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 4);
|
||||
|
||||
@ -293,13 +301,13 @@ public class BlockIteratorTest {
|
||||
points.add(iterator.next());
|
||||
}
|
||||
|
||||
Point[] validPoints = new Point[] {
|
||||
new Vec(0.0, 0.0, 0.0),
|
||||
new Vec(1.0, 0.0, 0.0),
|
||||
new Vec(2.0, 0.0, 0.0),
|
||||
new Vec(1.0, 1.0, 0.0),
|
||||
new Vec(2.0, 1.0, 0.0),
|
||||
new Vec(3.0, 1.0, 0.0),
|
||||
Point[] validPoints = new Point[]{
|
||||
new Vec(0.0, 0.0, 0.0),
|
||||
new Vec(1.0, 0.0, 0.0),
|
||||
new Vec(2.0, 0.0, 0.0),
|
||||
new Vec(1.0, 1.0, 0.0),
|
||||
new Vec(2.0, 1.0, 0.0),
|
||||
new Vec(3.0, 1.0, 0.0),
|
||||
};
|
||||
|
||||
for (Point p : validPoints) {
|
||||
@ -310,7 +318,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void test2dpn() {
|
||||
Vec s = new Vec(0, 0, 0);
|
||||
Vec s = new Vec(0, 0, 0);
|
||||
Vec e = new Vec(-2, 1, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 4);
|
||||
|
||||
@ -319,14 +327,14 @@ public class BlockIteratorTest {
|
||||
points.add(iterator.next());
|
||||
}
|
||||
|
||||
Point[] validPoints = new Point[] {
|
||||
new Vec(0.0, 0.0, 0.0),
|
||||
new Vec(-1.0, 0.0, 0.0),
|
||||
new Vec(-2.0, 0.0, 0.0),
|
||||
new Vec(-3.0, 0.0, 0.0),
|
||||
new Vec(-2.0, 1.0, 0.0),
|
||||
new Vec(-3.0, 1.0, 0.0),
|
||||
new Vec(-4.0, 1.0, 0.0)
|
||||
Point[] validPoints = new Point[]{
|
||||
new Vec(0.0, 0.0, 0.0),
|
||||
new Vec(-1.0, 0.0, 0.0),
|
||||
new Vec(-2.0, 0.0, 0.0),
|
||||
new Vec(-3.0, 0.0, 0.0),
|
||||
new Vec(-2.0, 1.0, 0.0),
|
||||
new Vec(-3.0, 1.0, 0.0),
|
||||
new Vec(-4.0, 1.0, 0.0)
|
||||
};
|
||||
|
||||
for (Point p : validPoints) {
|
||||
@ -337,7 +345,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void test2dnn() {
|
||||
Vec s = new Vec(0, 0, 0);
|
||||
Vec s = new Vec(0, 0, 0);
|
||||
Vec e = new Vec(-2, -1, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 4);
|
||||
|
||||
@ -346,7 +354,7 @@ public class BlockIteratorTest {
|
||||
points.add(iterator.next());
|
||||
}
|
||||
|
||||
Point[] validPoints = new Point[] {
|
||||
Point[] validPoints = new Point[]{
|
||||
new Vec(0.0, 0.0, 0.0),
|
||||
new Vec(-1.0, 0.0, 0.0),
|
||||
new Vec(0.0, -1.0, 0.0),
|
||||
@ -366,7 +374,7 @@ public class BlockIteratorTest {
|
||||
|
||||
@Test
|
||||
public void falling() {
|
||||
Vec s = new Vec(0, 42, 0);
|
||||
Vec s = new Vec(0, 42, 0);
|
||||
Vec e = new Vec(0, -10, 0);
|
||||
BlockIterator iterator = new BlockIterator(s, e, 0, 14.142135623730951);
|
||||
|
||||
|
@ -36,6 +36,9 @@ final class TestConnectionImpl implements TestConnection {
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<Player> connect(@NotNull Instance instance, @NotNull Pos pos) {
|
||||
// Use player provider to disable queued chunk sending
|
||||
process.connection().setPlayerProvider(TestPlayerImpl::new);
|
||||
|
||||
playerConnection.setServerState(ConnectionState.LOGIN);
|
||||
var player = process.connection().createPlayer(playerConnection, UUID.randomUUID(), "RandName");
|
||||
player.eventNode().addListener(AsyncPlayerConfigurationEvent.class, event -> {
|
||||
|
@ -0,0 +1,20 @@
|
||||
package net.minestom.testing;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TestPlayerImpl extends Player {
|
||||
public TestPlayerImpl(@NotNull UUID uuid, @NotNull String username, @NotNull PlayerConnection playerConnection) {
|
||||
super(uuid, username, playerConnection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChunk(@NotNull Chunk chunk) {
|
||||
// Send immediately
|
||||
sendPacket(chunk.getFullDataPacket());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user