Fix deployer anti agro not working, and switch away from deprecated event (#6072)

* Fix agro, switch to non deprecated event as well

* spaces -> tabs
This commit is contained in:
IThundxr 2024-03-16 14:18:07 -04:00 committed by GitHub
parent 866b619767
commit 8ffc4ef96a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,6 +6,8 @@ import java.util.UUID;
import javax.annotation.Nullable;
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
import org.apache.commons.lang3.tuple.Pair;
import com.mojang.authlib.GameProfile;
@ -110,7 +112,7 @@ public class DeployerFakePlayer extends FakePlayer {
public UUID getUUID() {
return owner == null ? super.getUUID() : owner;
}
@SubscribeEvent
public static void deployerHasEyesOnHisFeet(EntityEvent.Size event) {
if (event.getEntity() instanceof DeployerFakePlayer)
@ -149,23 +151,22 @@ public class DeployerFakePlayer extends FakePlayer {
}
@SubscribeEvent
public static void entitiesDontRetaliate(LivingSetAttackTargetEvent event) {
if (!(event.getTarget() instanceof DeployerFakePlayer))
public static void entitiesDontRetaliate(LivingChangeTargetEvent event) {
if (!(event.getOriginalTarget() instanceof DeployerFakePlayer))
return;
LivingEntity entityLiving = event.getEntityLiving();
if (!(entityLiving instanceof Mob))
if (!(entityLiving instanceof Mob mob))
return;
Mob mob = (Mob) entityLiving;
CKinetics.DeployerAggroSetting setting = AllConfigs.server().kinetics.ignoreDeployerAttacks.get();
switch (setting) {
case ALL:
mob.setTarget(null);
event.setCanceled(true);
break;
case CREEPERS:
if (mob instanceof Creeper)
mob.setTarget(null);
event.setCanceled(true);
break;
case NONE:
default: