mirror of https://github.com/PaperMC/Paper.git
Merge f600839d4e
into 8f7ac62905
This commit is contained in:
commit
26103f9cac
|
@ -0,0 +1,55 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tamion <70228790+notTamion@users.noreply.github.com>
|
||||
Date: Wed, 28 Feb 2024 19:04:08 +0100
|
||||
Subject: [PATCH] Add BlockPlayerSearchEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/block/BlockPlayerSearchEvent.java b/src/main/java/io/papermc/paper/event/block/BlockPlayerSearchEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..63ceb092cb7830641418a8de2e84308e29a31cac
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/block/BlockPlayerSearchEvent.java
|
||||
@@ -0,0 +1,43 @@
|
||||
+package io.papermc.paper.event.block;
|
||||
+
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.block.BlockEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import java.util.List;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a Block such as a Conduit or Beacon searches for players to apply effects to.
|
||||
+ */
|
||||
+public class BlockPlayerSearchEvent extends BlockEvent {
|
||||
+
|
||||
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
+ private final List<Player> players;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public BlockPlayerSearchEvent(@NotNull Block block, List<Player> players) {
|
||||
+ super(block);
|
||||
+ this.players = players;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the players which will have the effects applied to them.
|
||||
+ *
|
||||
+ * @return the players affected
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public List<Player> getPlayers() {
|
||||
+ return players;
|
||||
+ }
|
||||
+
|
||||
+ public static @NotNull HandlerList getHandlerList() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+}
|
|
@ -0,0 +1,47 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tamion <70228790+notTamion@users.noreply.github.com>
|
||||
Date: Wed, 28 Feb 2024 18:49:24 +0100
|
||||
Subject: [PATCH] Add BlockPlayerSearchEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
index dd1fe8357ccf084880a7f3d4d9e499bde672c787..e59c3c3c09270c5bf6f41823ca4c8fd4e4b9d098 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
@@ -397,6 +397,11 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
|
||||
int j = BeaconBlockEntity.getLevel(beaconLevel);
|
||||
List list = BeaconBlockEntity.getHumansInRange(world, pos, beaconLevel, blockEntity); // Paper - Custom beacon ranges
|
||||
+ // Paper start - Add BlockPlayerSearchEvent
|
||||
+ io.papermc.paper.event.block.BlockPlayerSearchEvent event = new io.papermc.paper.event.block.BlockPlayerSearchEvent(io.papermc.paper.util.MCUtil.toLocation(world, pos).getBlock(), ((List<Player>) list).stream().map(player -> (org.bukkit.entity.Player) player.getBukkitEntity()).collect(Collectors.toList()));
|
||||
+ event.callEvent();
|
||||
+ list = event.getPlayers().stream().map(player -> (Player) ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle()).toList();
|
||||
+ // Paper end - Add BlockPlayerSearchEvent
|
||||
|
||||
BeaconBlockEntity.applyEffect(list, primaryEffect, j, b0, true, pos); // Paper - BeaconEffectEvent
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
index 73e532dc998e5701c1a73da846da3d3a79871b81..fcbcbb6963d168f142cab98b2a549c78b77bad16 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java
|
||||
@@ -206,6 +206,11 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
int i1 = blockposition.getZ();
|
||||
AABB axisalignedbb = (new AABB((double) k, (double) l, (double) i1, (double) (k + 1), (double) (l + 1), (double) (i1 + 1))).inflate((double) j).expandTowards(0.0D, (double) world.getHeight(), 0.0D);
|
||||
List<Player> list1 = world.getEntitiesOfClass(Player.class, axisalignedbb);
|
||||
+ // Paper start - Add BlockPlayerSearchEvent
|
||||
+ io.papermc.paper.event.block.BlockPlayerSearchEvent event = new io.papermc.paper.event.block.BlockPlayerSearchEvent(io.papermc.paper.util.MCUtil.toLocation(world, blockposition).getBlock(), list1.stream().filter(entity -> blockposition.closerThan(entity.blockPosition(), j) && entity.isInWaterOrRain()).map(player -> (org.bukkit.entity.Player) player.getBukkitEntity()).collect(java.util.stream.Collectors.toList()));
|
||||
+ event.callEvent();
|
||||
+ list1 = event.getPlayers().stream().map(player -> (Player) ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle()).toList();
|
||||
+ // Paper end - Add BlockPlayerSearchEvent
|
||||
|
||||
if (!list1.isEmpty()) {
|
||||
Iterator iterator = list1.iterator();
|
||||
@@ -213,7 +218,7 @@ public class ConduitBlockEntity extends BlockEntity {
|
||||
while (iterator.hasNext()) {
|
||||
Player entityhuman = (Player) iterator.next();
|
||||
|
||||
- if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) {
|
||||
+ if (true || blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) { // Paper - Add BlockPlayerSearchEvent
|
||||
entityhuman.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue