Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
4af62f6d1d
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2d009e64 Update SnakeYAML javadoc link b4fd213c Switch Player#updateInventory deprecation for internal API annotation CraftBukkit Changes: f3b2b2210 SPIGOT-7376: Exception with getBlockData when hasBlockData is false 725545630 SPIGOT-7375: Fix crash breeding certain entities b9873b0d4 Update Brigadier version with fix 68b320562 SPIGOT-7266: Found typo in CraftBukkit package 98b4d2ff8 SPIGOT-7372, SPIGOT-7373: Signs can't be edited, issues with SignChangeEvent 5f7bd4d78 SPIGOT-7371: Sign does not open edit text on placement b4cf99d24 SPIGOT-7371: Fix editing signs with API a2b6c2744 PR-1200: Implement open sign by side a345bb940 SPIGOT-7368: Downgrade SpecialSource version Spigot Changes: 723951c3 Rebuild patches b655c57d Drop old collision API deprecated since 1.9.4 55b0fed4 Rebuild patches
61 Zeilen
3.0 KiB
Diff
61 Zeilen
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jakub Zacek <dawon@dawon.eu>
|
|
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 d35de35f0a72bf9080b48028010379426d50c5bc..5795836844691ce4bcfaf3df8ae6dc28b80df47a 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -893,6 +893,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
}
|
|
|
|
protected BlockPos findLightningTargetAround(BlockPos pos) {
|
|
+ // Paper start
|
|
+ return this.findLightningTargetAround(pos, false);
|
|
+ }
|
|
+ public BlockPos findLightningTargetAround(BlockPos pos, boolean returnNullWhenNoTarget) {
|
|
+ // Paper end
|
|
BlockPos blockposition1 = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
|
|
Optional<BlockPos> optional = this.findLightningRod(blockposition1);
|
|
|
|
@@ -907,6 +912,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
|
|
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 200c0125c009ce08b3381814568054b881651b96..470f4f64dc5628de463e5da5083a5fbc6f2166f0 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -688,6 +688,23 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
return (LightningStrike) lightning.getBukkitEntity();
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @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
|
|
+
|
|
@Override
|
|
public boolean generateTree(Location loc, TreeType type) {
|
|
return generateTree(loc, CraftWorld.rand, type);
|