Add methods to find targets for lightning strikes

== AT ==
public net.minecraft.server.level.ServerLevel findLightningRod(Lnet/minecraft/core/BlockPos;)Ljava/util/Optional;
This commit is contained in:
Jakub Zacek
2021-10-04 10:16:44 +02:00
parent 424403988d
commit 067c4e04bd
2 changed files with 70 additions and 33 deletions

View File

@@ -676,6 +676,23 @@ public class CraftWorld extends CraftRegionAccessor implements World {
return (LightningStrike) lightning.getBukkitEntity();
}
// Paper start - Add methods to find targets for lightning strikes
@Override
public Location findLightningRod(Location location) {
return this.world.findLightningRod(io.papermc.paper.util.MCUtil.toBlockPosition(location))
.map(blockPos -> io.papermc.paper.util.MCUtil.toLocation(this.world, blockPos)
// get the actual rod pos
.subtract(0, 1, 0))
.orElse(null);
}
@Override
public Location findLightningTarget(Location location) {
final BlockPos pos = this.world.findLightningTargetAround(io.papermc.paper.util.MCUtil.toBlockPosition(location), true);
return pos == null ? null : io.papermc.paper.util.MCUtil.toLocation(this.world, pos);
}
// Paper end - Add methods to find targets for lightning strikes
@Override
public boolean generateTree(Location loc, TreeType type) {
return this.generateTree(loc, CraftWorld.rand, type);