summaryrefslogtreecommitdiffstats
path: root/nms-patches/TileEntityConduit.patch
blob: c73526c8cf601bce915a834a1095dc7c7a103a09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--- a/net/minecraft/server/TileEntityConduit.java
+++ b/net/minecraft/server/TileEntityConduit.java
@@ -7,6 +7,10 @@
 import java.util.UUID;
 import java.util.function.Predicate;
 import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
 
 public class TileEntityConduit extends TileEntity implements ITickable {
 
@@ -152,7 +156,7 @@
                 EntityHuman entityhuman = (EntityHuman) iterator.next();
 
                 if (this.position.m(new BlockPosition(entityhuman)) <= (double) j && entityhuman.ao()) {
-                    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
                 }
             }
 
@@ -169,8 +173,8 @@
             this.target = this.l();
             this.k = null;
         } else if (this.target == null) {
-            List list = this.world.a(EntityLiving.class, this.k(), (entityliving) -> {
-                return entityliving instanceof IMonster && entityliving.ao();
+            List list = this.world.a(EntityLiving.class, this.k(), (Predicate<EntityLiving>) (entitylivingx) -> { // CraftBukkit - decompile error
+                return entitylivingx instanceof IMonster && entitylivingx.ao(); // CraftBukkit - decompile error
             });
 
             if (!list.isEmpty()) {
@@ -181,8 +185,13 @@
         }
 
         if (this.target != null) {
-            this.world.a((EntityHuman) null, this.target.locX, this.target.locY, this.target.locZ, SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
-            this.target.damageEntity(DamageSource.MAGIC, 4.0F);
+            // CraftBukkit start
+            CraftEventFactory.blockDamage = CraftBlock.at(this.world, this.position);
+            if (this.target.damageEntity(DamageSource.MAGIC, 4.0F)) {
+                this.world.a((EntityHuman) null, this.target.locX, this.target.locY, this.target.locZ, SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
+            }
+            CraftEventFactory.blockDamage = null;
+            // CraftBukkit end
         }
 
         if (entityliving != this.target) {
@@ -215,7 +224,7 @@
 
     @Nullable
     private EntityLiving l() {
-        List list = this.world.a(EntityLiving.class, this.k(), (entityliving) -> {
+        List list = this.world.a(EntityLiving.class, this.k(), (Predicate<EntityLiving>) (entityliving) -> { // CraftBukkit - decompile error
             return entityliving.getUniqueID().equals(this.k);
         });