diff options
author | Tamion <[email protected]> | 2024-02-09 23:03:27 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-02-09 23:03:27 +0100 |
commit | cbe62d91fb6f696c628e46007a0a82c485449ca6 (patch) | |
tree | b095d366ce9e1bb3b3a2aaf0c4c4d0f76ef19138 | |
parent | 69b52b4d8edc242cffd61c68dadf7208b508ce4e (diff) | |
download | Paper-cbe62d91fb6f696c628e46007a0a82c485449ca6.tar.gz Paper-cbe62d91fb6f696c628e46007a0a82c485449ca6.zip |
Add Conduit API (#10195)
-rw-r--r-- | patches/api/0460-Conduit-API.patch | 46 | ||||
-rw-r--r-- | patches/server/1047-Conduit-API.patch | 50 |
2 files changed, 96 insertions, 0 deletions
diff --git a/patches/api/0460-Conduit-API.patch b/patches/api/0460-Conduit-API.patch new file mode 100644 index 0000000000..57f43f96a3 --- /dev/null +++ b/patches/api/0460-Conduit-API.patch @@ -0,0 +1,46 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tamion <[email protected]> +Date: Sat, 27 Jan 2024 20:46:29 +0100 +Subject: [PATCH] Conduit API + + +diff --git a/src/main/java/org/bukkit/block/Conduit.java b/src/main/java/org/bukkit/block/Conduit.java +index 5543165536e84503c2d1476ee2001468cbb724f9..b3eec2eab586072598a40375a1c3e722ee3fa352 100644 +--- a/src/main/java/org/bukkit/block/Conduit.java ++++ b/src/main/java/org/bukkit/block/Conduit.java +@@ -3,4 +3,34 @@ package org.bukkit.block; + /** + * Represents a captured state of a conduit. + */ +-public interface Conduit extends TileState { } ++public interface Conduit extends TileState { ++ ++ // Paper start - Conduit API ++ ++ /** ++ * Gets if the conduit is currently active. ++ * <p> ++ * Requires the conduit to be placed in the world. ++ * ++ * @return if the conduit is active ++ */ ++ boolean isActive(); ++ ++ /** ++ * Gets the range in which the Conduit Power effect gets added to players. ++ * <p> ++ * Requires the conduit to be placed in the world. ++ * ++ * @return the range ++ */ ++ int getRange(); ++ ++ /** ++ * Gets the current target of the conduit. ++ * ++ * @return the current target ++ */ ++ @org.jetbrains.annotations.Nullable ++ org.bukkit.entity.LivingEntity getTarget(); ++ // Paper end - Conduit API ++} diff --git a/patches/server/1047-Conduit-API.patch b/patches/server/1047-Conduit-API.patch new file mode 100644 index 0000000000..820c5e29f3 --- /dev/null +++ b/patches/server/1047-Conduit-API.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tamion <[email protected]> +Date: Sat, 27 Jan 2024 20:46:40 +0100 +Subject: [PATCH] Conduit API + +== AT == +public net.minecraft.world.level.block.entity.ConduitBlockEntity effectBlocks +public net.minecraft.world.level.block.entity.ConduitBlockEntity destroyTarget + +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 1f493708b01ede8d54f9eb8243695fe70e7af3a1..58f2619fab37a1e2d2093ca89f66f3a8bb47d192 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 +@@ -191,7 +191,7 @@ public class ConduitBlockEntity extends BlockEntity { + + private static void applyEffects(Level world, BlockPos pos, List<BlockPos> activatingBlocks) { + int i = activatingBlocks.size(); +- int j = i / 7 * 16; ++ int j = i / 7 * 16; // Paper - Conduit API; diff on change + int k = pos.getX(); + int l = pos.getY(); + int i1 = pos.getZ(); +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java b/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java +index 29bcac10a7edf53015941e4c28c4f2d9a5a3db56..f0b0348e105fb27c829ec29e638433c57bfd5f64 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java +@@ -18,4 +18,23 @@ public class CraftConduit extends CraftBlockEntityState<ConduitBlockEntity> impl + public CraftConduit copy() { + return new CraftConduit(this); + } ++ ++ // Paper start - Conduit API ++ @Override ++ public boolean isActive() { ++ requirePlaced(); ++ return this.getTileEntity().isActive(); ++ } ++ ++ @Override ++ public int getRange() { ++ requirePlaced(); ++ return this.getTileEntity().effectBlocks.size() / 7 * 16; ++ } ++ ++ @Override ++ public org.bukkit.entity.LivingEntity getTarget() { ++ return this.getTileEntity().destroyTarget == null ? null : this.getTileEntity().destroyTarget.getBukkitLivingEntity(); ++ } ++ // Paper end - Conduit API + } |