SPIGOT-4319: Conduit damage should be a block event

This commit is contained in:
md_5 2018-08-28 21:00:24 +10:00
parent 4228a56c0d
commit 9636bb8d77
2 changed files with 32 additions and 3 deletions

View File

@ -1,6 +1,17 @@
--- a/net/minecraft/server/TileEntityConduit.java --- a/net/minecraft/server/TileEntityConduit.java
+++ b/net/minecraft/server/TileEntityConduit.java +++ b/net/minecraft/server/TileEntityConduit.java
@@ -152,7 +152,7 @@ @@ -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(); EntityHuman entityhuman = (EntityHuman) iterator.next();
if (this.position.m(new BlockPosition(entityhuman)) <= (double) j && entityhuman.ao()) { if (this.position.m(new BlockPosition(entityhuman)) <= (double) j && entityhuman.ao()) {
@ -9,7 +20,7 @@
} }
} }
@@ -169,8 +169,8 @@ @@ -169,8 +173,8 @@
this.j = this.l(); this.j = this.l();
this.k = null; this.k = null;
} else if (this.j == null) { } else if (this.j == null) {
@ -20,7 +31,23 @@
}); });
if (!list.isEmpty()) { if (!list.isEmpty()) {
@@ -215,7 +215,7 @@ @@ -181,8 +185,13 @@
}
if (this.j != null) {
- this.world.a((EntityHuman) null, this.j.locX, this.j.locY, this.j.locZ, SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.j.damageEntity(DamageSource.MAGIC, 4.0F);
+ // CraftBukkit start
+ CraftEventFactory.blockDamage = CraftBlock.at(this.world, this.position);
+ if (this.j.damageEntity(DamageSource.MAGIC, 4.0F)) {
+ this.world.a((EntityHuman) null, this.j.locX, this.j.locY, this.j.locZ, SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ }
+ CraftEventFactory.blockDamage = null;
+ // CraftBukkit end
}
if (entityliving != this.j) {
@@ -215,7 +224,7 @@
@Nullable @Nullable
private EntityLiving l() { private EntityLiving l() {

View File

@ -507,6 +507,8 @@ public class CraftEventFactory {
cause = DamageCause.CONTACT; cause = DamageCause.CONTACT;
} else if (source == DamageSource.HOT_FLOOR) { } else if (source == DamageSource.HOT_FLOOR) {
cause = DamageCause.HOT_FLOOR; cause = DamageCause.HOT_FLOOR;
} else if (source == DamageSource.MAGIC) {
cause = DamageCause.MAGIC;
} else { } else {
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.translationIndex)); throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.translationIndex));
} }