3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00
Paper/nms-patches/PortalTravelAgent.patch

94 Zeilen
5.2 KiB
Diff

--- a/net/minecraft/server/PortalTravelAgent.java
+++ b/net/minecraft/server/PortalTravelAgent.java
2020-08-11 23:00:00 +02:00
@@ -13,13 +13,19 @@
}
2020-08-11 23:00:00 +02:00
public Optional<BlockUtil.Rectangle> findPortal(BlockPosition blockposition, boolean flag) {
+ // CraftBukkit start
2020-08-11 23:00:00 +02:00
+ return findPortal(blockposition, flag ? 16 : 128); // Search Radius
+ }
+
2020-08-11 23:00:00 +02:00
+ public Optional<BlockUtil.Rectangle> findPortal(BlockPosition blockposition, int i) {
VillagePlace villageplace = this.world.y();
- int i = flag ? 16 : 128;
+ // int i = flag ? 16 : 128;
+ // CraftBukkit end
2020-08-11 23:00:00 +02:00
villageplace.a(this.world, blockposition, i);
Optional<VillagePlaceRecord> optional = villageplace.b((villageplacetype) -> {
2020-06-25 02:00:00 +02:00
return villageplacetype == VillagePlaceType.v;
2020-08-11 23:00:00 +02:00
- }, blockposition, i, VillagePlace.Occupancy.ANY).sorted(Comparator.comparingDouble((villageplacerecord) -> {
+ }, blockposition, i, VillagePlace.Occupancy.ANY).sorted(Comparator.comparingDouble((VillagePlaceRecord villageplacerecord) -> { // CraftBukkit - decompile error
2020-06-25 02:00:00 +02:00
return villageplacerecord.f().j(blockposition);
2019-12-10 23:00:00 +01:00
}).thenComparingInt((villageplacerecord) -> {
return villageplacerecord.f().getY();
2020-08-11 23:00:00 +02:00
@@ -40,6 +46,12 @@
2019-12-10 23:00:00 +01:00
}
2020-08-11 23:00:00 +02:00
public Optional<BlockUtil.Rectangle> createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
+ // CraftBukkit start
+ return this.createPortal(blockposition, enumdirection_enumaxis, null, 16);
2020-01-21 22:00:00 +01:00
+ }
+
2020-08-11 23:00:00 +02:00
+ public Optional<BlockUtil.Rectangle> createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis, Entity entity, int createRadius) {
+ // CraftBukkit end
2020-08-11 23:00:00 +02:00
EnumDirection enumdirection = EnumDirection.a(EnumDirection.EnumAxisDirection.POSITIVE, enumdirection_enumaxis);
double d0 = -1.0D;
2020-08-11 23:00:00 +02:00
BlockPosition blockposition1 = null;
@@ -48,7 +60,7 @@
WorldBorder worldborder = this.world.getWorldBorder();
int i = this.world.getHeight() - 1;
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.i();
- Iterator iterator = BlockPosition.a(blockposition, 16, EnumDirection.EAST, EnumDirection.SOUTH).iterator();
+ Iterator iterator = BlockPosition.a(blockposition, createRadius, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); // CraftBukkit
2020-08-11 23:00:00 +02:00
int j;
2020-08-11 23:00:00 +02:00
@@ -102,6 +114,7 @@
2020-08-11 23:00:00 +02:00
int j1;
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.world); // CraftBukkit - Use BlockStateListPopulator
2020-08-11 23:00:00 +02:00
if (d0 == -1.0D) {
blockposition1 = (new BlockPosition(blockposition.getX(), MathHelper.clamp(blockposition.getY(), 70, this.world.getHeight() - 10), blockposition.getZ())).immutableCopy();
EnumDirection enumdirection1 = enumdirection.g();
@@ -116,7 +129,7 @@
IBlockData iblockdata = k1 < 0 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData();
2020-08-11 23:00:00 +02:00
blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, j * enumdirection.getAdjacentX() + j1 * enumdirection1.getAdjacentX(), k1, j * enumdirection.getAdjacentZ() + j1 * enumdirection1.getAdjacentZ());
- this.world.setTypeUpdate(blockposition_mutableblockposition, iblockdata);
+ blockList.setTypeAndData(blockposition_mutableblockposition, iblockdata, 3); // CraftBukkit
}
}
}
2020-08-11 23:00:00 +02:00
@@ -126,7 +139,7 @@
for (j1 = -1; j1 < 4; ++j1) {
if (l1 == -1 || l1 == 2 || j1 == -1 || j1 == 3) {
blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, l1 * enumdirection.getAdjacentX(), j1, l1 * enumdirection.getAdjacentZ());
- this.world.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3);
+ blockList.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3); // CraftBukkit
}
}
}
2020-08-11 23:00:00 +02:00
@@ -136,10 +149,19 @@
for (j1 = 0; j1 < 2; ++j1) {
for (j = 0; j < 3; ++j) {
blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, j1 * enumdirection.getAdjacentX(), j, j1 * enumdirection.getAdjacentZ());
- this.world.setTypeAndData(blockposition_mutableblockposition, iblockdata1, 18);
+ blockList.setTypeAndData(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit
}
}
+ // CraftBukkit start
+ org.bukkit.World bworld = this.world.getWorld();
2020-08-11 23:00:00 +02:00
+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR);
+
+ this.world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ blockList.updateList();
+ }
+ // CraftBukkit end
2020-08-11 23:00:00 +02:00
return Optional.of(new BlockUtil.Rectangle(blockposition1.immutableCopy(), 2, 3));
}
2020-08-11 23:00:00 +02:00