diff options
author | Jake Potrebic <[email protected]> | 2024-05-29 13:58:57 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2024-05-29 22:58:57 +0200 |
commit | a31dc90741ed9c121a13a3c124c9ebf5bafd0da7 (patch) | |
tree | 81963bd94fe7772ee08bd21710230de21b6b25da /patches/server/0597-Add-methods-to-find-targets-for-lightning-strikes.patch | |
parent | ed85aac53cfd93d29fa24e6071dbdddd0e49624b (diff) | |
download | Paper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.tar.gz Paper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.zip |
Several fixes and new api for experience merging/stacking (#9242)
Diffstat (limited to 'patches/server/0597-Add-methods-to-find-targets-for-lightning-strikes.patch')
-rw-r--r-- | patches/server/0597-Add-methods-to-find-targets-for-lightning-strikes.patch | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/patches/server/0597-Add-methods-to-find-targets-for-lightning-strikes.patch b/patches/server/0597-Add-methods-to-find-targets-for-lightning-strikes.patch new file mode 100644 index 0000000000..fdc84ceea1 --- /dev/null +++ b/patches/server/0597-Add-methods-to-find-targets-for-lightning-strikes.patch @@ -0,0 +1,60 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jakub Zacek <[email protected]> +Date: Mon, 4 Oct 2021 10:16:44 +0200 +Subject: [PATCH] Add methods to find targets for lightning strikes + +== AT == +public net.minecraft.server.level.ServerLevel findLightningRod(Lnet/minecraft/core/BlockPos;)Ljava/util/Optional; + +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index eecc5704582ce7c9a45adee8057d8297eae03a86..5cb0281ea110a1ce3444f4392bccbb19ca3bbf09 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -763,6 +763,11 @@ public class ServerLevel extends Level implements WorldGenLevel { + } + + protected BlockPos findLightningTargetAround(BlockPos pos) { ++ // Paper start - Add methods to find targets for lightning strikes ++ return this.findLightningTargetAround(pos, false); ++ } ++ public BlockPos findLightningTargetAround(BlockPos pos, boolean returnNullWhenNoTarget) { ++ // Paper end - Add methods to find targets for lightning strikes + BlockPos blockposition1 = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); + Optional<BlockPos> optional = this.findLightningRod(blockposition1); + +@@ -777,6 +782,7 @@ public class ServerLevel extends Level implements WorldGenLevel { + if (!list.isEmpty()) { + return ((LivingEntity) list.get(this.random.nextInt(list.size()))).blockPosition(); + } else { ++ if (returnNullWhenNoTarget) return null; // Paper - Add methods to find targets for lightning strikes + if (blockposition1.getY() == this.getMinBuildHeight() - 1) { + blockposition1 = blockposition1.above(2); + } +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +index 3e448a40aaf4c2ae61de685d060495d4cedea031..5f6cec79745aa8e5ae3aa8139c93bbdd1c36c6d5 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +@@ -687,6 +687,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); |