2019-05-04 14:51:54 +02:00
|
|
|
--- a/net/minecraft/server/PortalTravelAgent.java
|
|
|
|
+++ b/net/minecraft/server/PortalTravelAgent.java
|
2020-01-21 22:00:00 +01:00
|
|
|
@@ -18,12 +18,19 @@
|
2020-01-12 01:02:13 +01:00
|
|
|
}
|
|
|
|
|
2020-01-21 22:00:00 +01:00
|
|
|
public boolean findAndTeleport(Entity entity, float f) {
|
2020-01-12 01:02:13 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ return findAndTeleport(entity, new BlockPosition(entity), f, 128, false) != null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public ShapeDetector.Shape findAndTeleport(Entity entity, BlockPosition findPosition, float f, int searchRadius, boolean searchOnly) {
|
|
|
|
+ // CraftBukkit end
|
|
|
|
Vec3D vec3d = entity.getPortalOffset();
|
|
|
|
EnumDirection enumdirection = entity.getPortalDirection();
|
|
|
|
- ShapeDetector.Shape shapedetector_shape = this.a(new BlockPosition(entity), entity.getMot(), enumdirection, vec3d.x, vec3d.y, entity instanceof EntityHuman);
|
|
|
|
+ ShapeDetector.Shape shapedetector_shape = this.findPortal(findPosition, entity.getMot(), enumdirection, vec3d.x, vec3d.y, entity instanceof EntityHuman, searchRadius); // CraftBukkit - add location and searchRadius
|
|
|
|
+ if (searchOnly) return shapedetector_shape; // CraftBukkit - optional teleporting
|
|
|
|
|
|
|
|
if (shapedetector_shape == null) {
|
|
|
|
- return false;
|
|
|
|
+ return null; // CraftBukkit - return shape
|
|
|
|
} else {
|
|
|
|
Vec3D vec3d1 = shapedetector_shape.position;
|
|
|
|
Vec3D vec3d2 = shapedetector_shape.velocity;
|
|
|
|
@@ -31,19 +38,26 @@
|
|
|
|
entity.setMot(vec3d2);
|
|
|
|
entity.yaw = f + (float) shapedetector_shape.yaw;
|
2020-01-21 22:00:00 +01:00
|
|
|
entity.teleportAndSync(vec3d1.x, vec3d1.y, vec3d1.z);
|
2020-01-12 01:02:13 +01:00
|
|
|
- return true;
|
|
|
|
+ return shapedetector_shape; // CraftBukkit - return shape
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
- public ShapeDetector.Shape a(BlockPosition blockposition, Vec3D vec3d, EnumDirection enumdirection, double d0, double d1, boolean flag) {
|
|
|
|
+ public ShapeDetector.Shape a(BlockPosition blockposition, Vec3D vec3d, EnumDirection enumdirection, double d0, double d1, boolean flag) { // PAIL: rename to findPortal, d0 = portal offset x, d1 = portal offset z, flag = instanceof EntityHuman
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ return findPortal(blockposition, vec3d, enumdirection, d0, d1, flag, 128);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nullable
|
|
|
|
+ public ShapeDetector.Shape findPortal(BlockPosition blockposition, Vec3D vec3d, EnumDirection enumdirection, double d0, double d1, boolean flag, int searchRadius) {
|
|
|
|
+ // CraftBukkit end
|
|
|
|
VillagePlace villageplace = this.world.B();
|
|
|
|
|
|
|
|
villageplace.a(this.world, blockposition, 128);
|
2019-12-10 23:00:00 +01:00
|
|
|
List<VillagePlaceRecord> list = (List) villageplace.b((villageplacetype) -> {
|
|
|
|
return villageplacetype == VillagePlaceType.u;
|
2020-01-12 01:02:13 +01:00
|
|
|
- }, blockposition, 128, VillagePlace.Occupancy.ANY).collect(Collectors.toList());
|
2019-12-10 23:00:00 +01:00
|
|
|
- Optional<VillagePlaceRecord> optional = list.stream().min(Comparator.comparingDouble((villageplacerecord) -> {
|
2020-01-12 01:02:13 +01:00
|
|
|
+ }, blockposition, searchRadius, VillagePlace.Occupancy.ANY).collect(Collectors.toList()); // CraftBukkit - searchRadius
|
2019-12-10 23:00:00 +01:00
|
|
|
+ Optional<VillagePlaceRecord> optional = list.stream().min(Comparator.<VillagePlaceRecord>comparingDouble((villageplacerecord) -> { // CraftBukkit - decompile error
|
|
|
|
return villageplacerecord.f().m(blockposition);
|
|
|
|
}).thenComparingInt((villageplacerecord) -> {
|
|
|
|
return villageplacerecord.f().getY();
|
2020-01-12 01:02:13 +01:00
|
|
|
@@ -56,15 +70,23 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = BlockPortal.c((GeneratorAccess) this.world, blockposition1);
|
|
|
|
|
|
|
|
return shapedetector_shapedetectorcollection.a(enumdirection, blockposition1, d1, vec3d, d0);
|
|
|
|
- }).orElse((Object) null);
|
|
|
|
+ }).orElse(null); // CraftBukkit - decompile error
|
|
|
|
}
|
|
|
|
|
2020-01-21 22:00:00 +01:00
|
|
|
public boolean createPortal(Entity entity) {
|
|
|
|
+ // CraftBukkit start - providable position and creation radius
|
|
|
|
+ return createPortal(entity, new BlockPosition(entity), 16);
|
|
|
|
+ }
|
|
|
|
+
|
2020-01-12 01:02:13 +01:00
|
|
|
+ public boolean createPortal(Entity entity, BlockPosition createPosition, int createRadius) {
|
|
|
|
+ // CraftBukkit end
|
|
|
|
boolean flag = true;
|
|
|
|
double d0 = -1.0D;
|
|
|
|
- int i = MathHelper.floor(entity.locX());
|
|
|
|
- int j = MathHelper.floor(entity.locY());
|
|
|
|
- int k = MathHelper.floor(entity.locZ());
|
|
|
|
+ // CraftBukkit start - providable position
|
|
|
|
+ int i = createPosition.getX();
|
|
|
|
+ int j = createPosition.getY();
|
|
|
|
+ int k = createPosition.getZ();
|
|
|
|
+ // CraftBukkit end
|
|
|
|
int l = i;
|
|
|
|
int i1 = j;
|
|
|
|
int j1 = k;
|
|
|
|
@@ -88,11 +110,11 @@
|
|
|
|
double d3;
|
|
|
|
double d4;
|
|
|
|
|
|
|
|
- for (i2 = i - 16; i2 <= i + 16; ++i2) {
|
|
|
|
- d1 = (double) i2 + 0.5D - entity.locX();
|
|
|
|
+ for (i2 = i - createRadius; i2 <= i + createRadius; ++i2) { // CraftBukkit - createRadius
|
|
|
|
+ d1 = (double) i2 + 0.5D - createPosition.getX(); // CraftBukkit - providable position
|
|
|
|
|
|
|
|
- for (j2 = k - 16; j2 <= k + 16; ++j2) {
|
|
|
|
- d2 = (double) j2 + 0.5D - entity.locZ();
|
|
|
|
+ for (j2 = k - createRadius; j2 <= k + createRadius; ++j2) { // CraftBukkit - createRadius
|
|
|
|
+ d2 = (double) j2 + 0.5D - createPosition.getZ(); // CraftBukkit - providable position
|
|
|
|
|
|
|
|
label257:
|
|
|
|
for (k2 = this.world.getHeight() - 1; k2 >= 0; --k2) {
|
|
|
|
@@ -140,11 +162,11 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d0 < 0.0D) {
|
|
|
|
- for (i2 = i - 16; i2 <= i + 16; ++i2) {
|
|
|
|
- d1 = (double) i2 + 0.5D - entity.locX();
|
|
|
|
+ for (i2 = i - createRadius; i2 <= i + createRadius; ++i2) { // CraftBukkit - createRadius
|
|
|
|
+ d1 = (double) i2 + 0.5D - createPosition.getX(); // CraftBukkit - providable position
|
|
|
|
|
|
|
|
- for (j2 = k - 16; j2 <= k + 16; ++j2) {
|
|
|
|
- d2 = (double) j2 + 0.5D - entity.locZ();
|
|
|
|
+ for (j2 = k - createRadius; j2 <= k + createRadius; ++j2) { // CraftBukkit - createRadius
|
|
|
|
+ d2 = (double) j2 + 0.5D - createPosition.getZ(); // CraftBukkit - providable position
|
|
|
|
|
|
|
|
label205:
|
|
|
|
for (k2 = this.world.getHeight() - 1; k2 >= 0; --k2) {
|
|
|
|
@@ -197,6 +219,7 @@
|
2019-05-04 14:51:54 +02:00
|
|
|
l5 = -l5;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.world); // CraftBukkit - Use BlockStateListPopulator
|
|
|
|
if (d0 < 0.0D) {
|
|
|
|
i1 = MathHelper.clamp(i1, 70, this.world.getHeight() - 10);
|
|
|
|
j5 = i1;
|
2020-01-12 01:02:13 +01:00
|
|
|
@@ -210,7 +233,7 @@
|
2019-05-04 14:51:54 +02:00
|
|
|
boolean flag1 = l2 < 0;
|
|
|
|
|
|
|
|
blockposition_mutableblockposition.d(j3, l3, i4);
|
|
|
|
- this.world.setTypeUpdate(blockposition_mutableblockposition, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData());
|
|
|
|
+ blockList.setTypeAndData(blockposition_mutableblockposition, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData(), 3); // CraftBukkit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-12 01:02:13 +01:00
|
|
|
@@ -220,7 +243,7 @@
|
2019-05-04 14:51:54 +02:00
|
|
|
for (i3 = -1; i3 < 4; ++i3) {
|
|
|
|
if (k2 == -1 || k2 == 2 || i3 == -1 || i3 == 3) {
|
|
|
|
blockposition_mutableblockposition.d(i5 + k2 * k5, j5 + i3, j2 + k2 * l5);
|
|
|
|
- this.world.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3);
|
|
|
|
+ blockList.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3); // CraftBukkit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-12 01:02:13 +01:00
|
|
|
@@ -230,10 +253,19 @@
|
2019-05-04 14:51:54 +02:00
|
|
|
for (i3 = 0; i3 < 2; ++i3) {
|
|
|
|
for (l2 = 0; l2 < 3; ++l2) {
|
|
|
|
blockposition_mutableblockposition.d(i5 + i3 * k5, j5 + l2, j2 + i3 * l5);
|
|
|
|
- this.world.setTypeAndData(blockposition_mutableblockposition, iblockdata, 18);
|
|
|
|
+ blockList.setTypeAndData(blockposition_mutableblockposition, iblockdata, 18); // CraftBukkit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.World bworld = this.world.getWorld();
|
2019-05-21 04:08:19 +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.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR);
|
2019-05-04 14:51:54 +02:00
|
|
|
+
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ blockList.updateList();
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
return true;
|
|
|
|
}
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|