Yatopia/patches/server/0031-EMC-ConduitNewTargetEvent-and-remove-target-for-canc.patch
2020-02-26 20:12:29 +01:00

43 lines
2.3 KiB
Diff

From 0e2d2f494498668839dce1edbe436ae08ec6b85d Mon Sep 17 00:00:00 2001
From: chickeneer <emcchickeneer@gmail.com>
Date: Sun, 14 Jul 2019 13:50:53 -0500
Subject: [PATCH] EMC ConduitNewTargetEvent and remove target for cancelled
damage events
---
.../java/net/minecraft/server/TileEntityConduit.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/main/java/net/minecraft/server/TileEntityConduit.java b/src/main/java/net/minecraft/server/TileEntityConduit.java
index 07f265b2..b6ad68fc 100644
--- a/src/main/java/net/minecraft/server/TileEntityConduit.java
+++ b/src/main/java/net/minecraft/server/TileEntityConduit.java
@@ -182,7 +182,14 @@ public class TileEntityConduit extends TileEntity implements ITickable {
List<EntityLiving> list = this.world.a(EntityLiving.class, this.m(), (java.util.function.Predicate<EntityLiving>) (entityliving1) -> { // CraftBukkit - decompile error
return entityliving1 instanceof IMonster && entityliving1.isInWaterOrRain();
});
-
+ // EMC start
+ List<org.bukkit.entity.LivingEntity> bukkitEntities = Lists.newArrayListWithCapacity(list.size());
+ for (EntityLiving entity : list) {
+ bukkitEntities.add(entity.getBukkitLivingEntity());
+ }
+ new com.empireminecraft.customevents.ConduitNewTargetEvent(bukkitEntities, CraftBlock.at(this.world, this.position)).callEvent();
+ list.removeIf(entityLiving -> !bukkitEntities.contains(entityLiving.getBukkitLivingEntity()));
+ // EMC end
if (!list.isEmpty()) {
this.target = (EntityLiving) list.get(this.world.random.nextInt(list.size()));
}
@@ -195,7 +202,7 @@ public class TileEntityConduit extends TileEntity implements ITickable {
CraftEventFactory.blockDamage = CraftBlock.at(this.world, this.position);
if (this.target.damageEntity(DamageSource.MAGIC, 4.0F)) {
this.world.playSound((EntityHuman) null, this.target.locX(), this.target.locY(), this.target.locZ(), SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
- }
+ } else { this.target = null; } // EMC
CraftEventFactory.blockDamage = null;
// CraftBukkit end
}
--
2.25.1.windows.1