mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
Allow Disabling Zombie Villager Aggression
Ability to configure if Zombies will be aggressive towards Villagers. By: Dylan Xaldin <Puremin0rez515@gmail.com>
This commit is contained in:
parent
3d4c222263
commit
0abc9c4cd1
@ -55,6 +55,15 @@
|
|||||||
|
|
||||||
public Zombie(EntityType<? extends Zombie> type, Level world) {
|
public Zombie(EntityType<? extends Zombie> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
|
@@ -115,7 +123,7 @@
|
||||||
|
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D));
|
||||||
|
this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers(ZombifiedPiglin.class));
|
||||||
|
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
|
||||||
|
- this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false));
|
||||||
|
+ if ( this.level().spigotConfig.zombieAggressiveTowardsVillager ) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Spigot
|
||||||
|
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
|
||||||
|
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR));
|
||||||
|
}
|
||||||
@@ -203,7 +211,10 @@
|
@@ -203,7 +211,10 @@
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) {
|
if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) {
|
||||||
@ -109,10 +118,12 @@
|
|||||||
- entityzombievillager1.setVillagerXp(villager.getVillagerXp());
|
- entityzombievillager1.setVillagerXp(villager.getVillagerXp());
|
||||||
- if (!this.isSilent()) {
|
- if (!this.isSilent()) {
|
||||||
- world.levelEvent((Player) null, 1026, this.blockPosition(), 0);
|
- world.levelEvent((Player) null, 1026, this.blockPosition(), 0);
|
||||||
|
- }
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ return Zombie.convertVillagerToZombieVillager(world, villager, this.blockPosition(), this.isSilent(), EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION) != null;
|
+ return Zombie.convertVillagerToZombieVillager(world, villager, this.blockPosition(), this.isSilent(), EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION) != null;
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
|
- });
|
||||||
+ public static ZombieVillager convertVillagerToZombieVillager(ServerLevel worldserver, Villager entityvillager, net.minecraft.core.BlockPos blockPosition, boolean silent, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
+ public static ZombieVillager convertVillagerToZombieVillager(ServerLevel worldserver, Villager entityvillager, net.minecraft.core.BlockPos blockPosition, boolean silent, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+ ZombieVillager entityzombievillager = (ZombieVillager) entityvillager.convertTo(EntityType.ZOMBIE_VILLAGER, ConversionParams.single(entityvillager, true, true), (entityzombievillager1) -> {
|
+ ZombieVillager entityzombievillager = (ZombieVillager) entityvillager.convertTo(EntityType.ZOMBIE_VILLAGER, ConversionParams.single(entityvillager, true, true), (entityzombievillager1) -> {
|
||||||
@ -124,12 +135,11 @@
|
|||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (!silent) {
|
+ if (!silent) {
|
||||||
+ worldserver.levelEvent((Player) null, 1026, blockPosition, 0);
|
+ worldserver.levelEvent((Player) null, 1026, blockPosition, 0);
|
||||||
}
|
+ }
|
||||||
|
|
||||||
- });
|
|
||||||
+ }, transformReason, spawnReason);
|
|
||||||
|
|
||||||
- return entityzombievillager != null;
|
- return entityzombievillager != null;
|
||||||
|
+ }, transformReason, spawnReason);
|
||||||
|
+
|
||||||
+ return entityzombievillager;
|
+ return entityzombievillager;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
|
@ -255,4 +255,11 @@ public class SpigotWorldConfig
|
|||||||
this.tridentDespawnRate = this.getInt( "trident-despawn-rate", this.arrowDespawnRate );
|
this.tridentDespawnRate = this.getInt( "trident-despawn-rate", this.arrowDespawnRate );
|
||||||
this.log( "Arrow Despawn Rate: " + this.arrowDespawnRate + " Trident Respawn Rate:" + this.tridentDespawnRate );
|
this.log( "Arrow Despawn Rate: " + this.arrowDespawnRate + " Trident Respawn Rate:" + this.tridentDespawnRate );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean zombieAggressiveTowardsVillager;
|
||||||
|
private void zombieAggressiveTowardsVillager()
|
||||||
|
{
|
||||||
|
this.zombieAggressiveTowardsVillager = this.getBoolean( "zombie-aggressive-towards-villager", true );
|
||||||
|
this.log( "Zombie Aggressive Towards Villager: " + this.zombieAggressiveTowardsVillager );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user