geforkt von Mirrors/Paper
cfe3ad1b0f
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: 45d9c73c SPIGOT-7043: EnderChest does not implement Lidded 86b95f34 SPIGOT-7047: Add Player#getLastDeathLocation CraftBukkit Changes: b2557f6ac SPIGOT-7041: Custom BiomeProvider not used when world set to type FLAT 732c50cab SPIGOT-7043: EnderChest does not implement Lidded 6209029ea SPIGOT-7048: addPassenger() not working when vehicle is player 3aa7836df SPIGOT-7047: Add Player#getLastDeathLocation 7d522cd26 SPIGOT-7050: Enchantment data of items will not be saved correctly when saved in YAML configuration file Spigot Changes: 1dffefb4 Rebuild patches
59 Zeilen
2.9 KiB
Diff
59 Zeilen
2.9 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
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 86f3c9be119aba7ec447d6887f40c2671203fb25..5f35cfe1ab67cc77d4b7ad4e440bf1d4dc6642c6 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -775,6 +775,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);
|
|
|
|
@@ -789,6 +794,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 acd935f7b9652ae4e778d865e9be1f0bfe906fe0..7a2a8e1aeca2002378a40be5cef32238350086a7 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -691,6 +691,23 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
return (LightningStrike) lightning.getBukkitEntity();
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public Location findLightningRod(Location location) {
|
|
+ return this.world.findLightningRod(net.minecraft.server.MCUtil.toBlockPosition(location))
|
|
+ .map(blockPos -> net.minecraft.server.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(net.minecraft.server.MCUtil.toBlockPosition(location), true);
|
|
+ return pos == null ? null : net.minecraft.server.MCUtil.toLocation(this.world, pos);
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public boolean generateTree(Location loc, TreeType type) {
|
|
return generateTree(loc, CraftWorld.rand, type);
|