13
0
geforkt von Mirrors/Paper
Paper/nms-patches/PortalTravelAgent.patch
2020-08-12 07:00:00 +10:00

94 Zeilen
5.2 KiB
Diff

--- a/net/minecraft/server/PortalTravelAgent.java
+++ b/net/minecraft/server/PortalTravelAgent.java
@@ -13,13 +13,19 @@
}
public Optional<BlockUtil.Rectangle> findPortal(BlockPosition blockposition, boolean flag) {
+ // CraftBukkit start
+ return findPortal(blockposition, flag ? 16 : 128); // Search Radius
+ }
+
+ 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
villageplace.a(this.world, blockposition, i);
Optional<VillagePlaceRecord> optional = villageplace.b((villageplacetype) -> {
return villageplacetype == VillagePlaceType.v;
- }, blockposition, i, VillagePlace.Occupancy.ANY).sorted(Comparator.comparingDouble((villageplacerecord) -> {
+ }, blockposition, i, VillagePlace.Occupancy.ANY).sorted(Comparator.comparingDouble((VillagePlaceRecord villageplacerecord) -> { // CraftBukkit - decompile error
return villageplacerecord.f().j(blockposition);
}).thenComparingInt((villageplacerecord) -> {
return villageplacerecord.f().getY();
@@ -40,6 +46,12 @@
}
public Optional<BlockUtil.Rectangle> createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
+ // CraftBukkit start
+ return this.createPortal(blockposition, enumdirection_enumaxis, null, 16);
+ }
+
+ public Optional<BlockUtil.Rectangle> createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis, Entity entity, int createRadius) {
+ // CraftBukkit end
EnumDirection enumdirection = EnumDirection.a(EnumDirection.EnumAxisDirection.POSITIVE, enumdirection_enumaxis);
double d0 = -1.0D;
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
int j;
@@ -102,6 +114,7 @@
int j1;
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.world); // CraftBukkit - Use BlockStateListPopulator
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();
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
}
}
}
@@ -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
}
}
}
@@ -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();
+ 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
return Optional.of(new BlockUtil.Rectangle(blockposition1.immutableCopy(), 2, 3));
}