0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 23:16:15 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/block/entity/TileEntityConduit.patch
2024-10-23 02:15:00 +11:00

73 lines
3.4 KiB
Diff

--- a/net/minecraft/world/level/block/entity/TileEntityConduit.java
+++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java
@@ -28,6 +28,10 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import net.minecraft.server.level.WorldServer;
+// CraftBukkit end
+
public class TileEntityConduit extends TileEntity {
private static final int BLOCK_REFRESH_RATE = 2;
@@ -187,8 +191,20 @@
}
private static void applyEffects(World world, BlockPosition blockposition, List<BlockPosition> list) {
+ // CraftBukkit start
+ applyEffects(world, blockposition, getRange(list));
+ }
+
+ public static int getRange(List<BlockPosition> list) {
+ // CraftBukkit end
int i = list.size();
int j = i / 7 * 16;
+ // CraftBukkit start
+ return j;
+ }
+
+ private static void applyEffects(World world, BlockPosition blockposition, int j) { // j = effect range in blocks
+ // CraftBukkit end
int k = blockposition.getX();
int l = blockposition.getY();
int i1 = blockposition.getZ();
@@ -202,7 +218,7 @@
EntityHuman entityhuman = (EntityHuman) iterator.next();
if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) {
- entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true));
+ entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit
}
}
@@ -210,6 +226,12 @@
}
private static void updateDestroyTarget(World world, BlockPosition blockposition, IBlockData iblockdata, List<BlockPosition> list, TileEntityConduit tileentityconduit) {
+ // CraftBukkit start - add "damageTarget" boolean
+ updateDestroyTarget(world, blockposition, iblockdata, list, tileentityconduit, true);
+ }
+
+ public static void updateDestroyTarget(World world, BlockPosition blockposition, IBlockData iblockdata, List<BlockPosition> list, TileEntityConduit tileentityconduit, boolean damageTarget) {
+ // CraftBukkit end
EntityLiving entityliving = tileentityconduit.destroyTarget;
int i = list.size();
@@ -230,9 +252,12 @@
tileentityconduit.destroyTarget = null;
}
- if (tileentityconduit.destroyTarget != null) {
- world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
- tileentityconduit.destroyTarget.hurt(world.damageSources().magic(), 4.0F);
+ // CraftBukkit start
+ if (damageTarget && tileentityconduit.destroyTarget != null) {
+ if (tileentityconduit.destroyTarget.hurtServer((WorldServer) world, world.damageSources().magic().directBlock(world, blockposition), 4.0F)) {
+ world.playSound(null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ }
+ // CraftBukkit end
}
if (entityliving != tileentityconduit.destroyTarget) {