Commits
Owen1212055 authored and md_5 committed c1279f7751f
11 11 | |
12 12 | |
13 13 | commandspreadplayers_a = acommandspreadplayers_a[j++]; |
14 14 | } |
15 15 | |
16 16 | - entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot()); |
17 17 | + entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - handle teleport reason |
18 18 | d1 = Double.MAX_VALUE; |
19 19 | CommandSpreadPlayers.a[] acommandspreadplayers_a1 = acommandspreadplayers_a; |
20 20 | int k = acommandspreadplayers_a.length; |
21 - | |
22 - | |
23 - | for (boolean flag2 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) { |
24 - | blockposition_mutableblockposition.move(EnumDirection.DOWN); |
25 - | - flag1 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir(); |
26 - | + flag1 = getBlockState(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit |
27 - | if (!flag1 && flag2 && flag) { |
28 - | return blockposition_mutableblockposition.getY() + 1; |
29 - | } |
30 - | |
31 - | |
32 - | public boolean isSafe(IBlockAccess iblockaccess, int i) { |
33 - | BlockPosition blockposition = BlockPosition.containing(this.x, (double) (this.getSpawnY(iblockaccess, i) - 1), this.z); |
34 - | - IBlockData iblockdata = iblockaccess.getBlockState(blockposition); |
35 - | + IBlockData iblockdata = getBlockState(iblockaccess, blockposition); // CraftBukkit |
36 - | |
37 - | return blockposition.getY() < i && !iblockdata.liquid() && !iblockdata.is(TagsBlock.FIRE); |
38 - | } |
39 - | |
40 - | this.x = MathHelper.nextDouble(randomsource, d0, d2); |
41 - | this.z = MathHelper.nextDouble(randomsource, d1, d3); |
42 - | } |
43 - | + |
44 - | + // CraftBukkit start - add a version of getBlockState which force loads chunks |
45 - | + private static IBlockData getBlockState(IBlockAccess iblockaccess, BlockPosition position) { |
46 - | + ((WorldServer) iblockaccess).getChunkSource().getChunk(position.getX() >> 4, position.getZ() >> 4, true); |
47 - | + return iblockaccess.getBlockState(position); |
48 - | + } |
49 - | + // CraftBukkit end |
50 - | } |
51 - | } |