Don't apply potion effect to wolves during worldgen

This commit is contained in:
jmp
2020-12-12 03:27:18 -08:00
parent 06c4f83ef5
commit bbe5a58267
3 changed files with 21 additions and 20 deletions

View File

@@ -1,13 +1,13 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Tue, 8 Dec 2020 17:15:15 -0500
Subject: [PATCH] Configurable chance for Wolves to spawn rabid
Subject: [PATCH] Configurable chance for wolves to spawn rabid
Configurable chance to spawn a wolf that is rabid.
Rabid wolves attack all players, mobs, and animals.
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index ce29695c6..a5a7b426e 100644
index f730fa484..e3ac6ebfd 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2085,6 +2085,7 @@ public abstract class EntityLiving extends Entity {
@@ -19,7 +19,7 @@ index ce29695c6..a5a7b426e 100644
if (enumhand == EnumHand.MAIN_HAND) {
this.setSlot(EnumItemSlot.MAINHAND, itemstack);
diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java
index 6c25f667e..fa7f47fef 100644
index 6c25f667e..b28f1a374 100644
--- a/src/main/java/net/minecraft/server/EntityWolf.java
+++ b/src/main/java/net/minecraft/server/EntityWolf.java
@@ -14,11 +14,42 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
@@ -66,7 +66,7 @@ index 6c25f667e..fa7f47fef 100644
private float bu;
private float bv;
private boolean bw;
@@ -53,6 +84,36 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
@@ -53,6 +84,37 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
int getPurpurBreedTime() {
return this.world.purpurConfig.wolfBreedingTicks;
}
@@ -77,33 +77,34 @@ index 6c25f667e..fa7f47fef 100644
+
+ public void setRabid(boolean isRabid) {
+ this.isRabid = isRabid;
+ updatePathfinders();
+ updatePathfinders(true);
+ }
+
+ public void updatePathfinders() {
+ public void updatePathfinders(boolean modifyEffects) {
+ this.targetSelector.removeGoal(PATHFINDER_VANILLA);
+ this.targetSelector.removeGoal(PATHFINDER_RABID);
+ if (this.isRabid) {
+ setTamed(false);
+ setOwnerUUID(null);
+ this.targetSelector.addGoal(5, PATHFINDER_RABID);
+ this.addEffect(new MobEffect(MobEffects.CONFUSION, 1200));
+ if (modifyEffects) this.addEffect(new MobEffect(MobEffects.CONFUSION, 1200));
+ } else {
+ this.targetSelector.addGoal(5, PATHFINDER_VANILLA);
+ this.removeEffect(MobEffects.CONFUSION);
+ this.pacify();
+ if (modifyEffects) this.removeEffect(MobEffects.CONFUSION);
+ }
+ }
+
+ @Override
+ public GroupDataEntity prepare(WorldAccess worldaccess, DifficultyDamageScaler difficultydamagescaler, EnumMobSpawn enummobspawn, @Nullable GroupDataEntity groupdataentity, @Nullable NBTTagCompound nbttagcompound) {
+ setRabid(world.purpurConfig.wolfNaturalRabid > 0.0D && random.nextDouble() <= world.purpurConfig.wolfNaturalRabid);
+ this.isRabid = world.purpurConfig.wolfNaturalRabid > 0.0D && random.nextDouble() <= world.purpurConfig.wolfNaturalRabid;
+ this.updatePathfinders(false);
+ return super.prepare(worldaccess, difficultydamagescaler, enummobspawn, groupdataentity, nbttagcompound);
+ }
// Purpur end
@Override
@@ -61,6 +122,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
@@ -61,6 +123,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
this.goalSelector.a(1, new PathfinderGoalHasRider(this)); // Purpur
this.goalSelector.a(2, new PathfinderGoalSit(this));
this.goalSelector.a(3, new EntityWolf.a<>(this, EntityLlama.class, 24.0F, 1.5D, 1.5D));
@@ -111,7 +112,7 @@ index 6c25f667e..fa7f47fef 100644
this.goalSelector.a(4, new PathfinderGoalLeapAtTarget(this, 0.4F));
this.goalSelector.a(5, new PathfinderGoalMeleeAttack(this, 1.0D, true));
this.goalSelector.a(6, new PathfinderGoalFollowOwner(this, 1.0D, 10.0F, 2.0F, false));
@@ -74,7 +136,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
@@ -74,7 +137,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this));
this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_));
@@ -120,7 +121,7 @@ index 6c25f667e..fa7f47fef 100644
this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bo));
this.targetSelector.a(7, new PathfinderGoalNearestAttackableTarget<>(this, EntitySkeletonAbstract.class, false));
this.targetSelector.a(8, new PathfinderGoalUniversalAngerReset<>(this, true));
@@ -119,6 +181,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
@@ -119,6 +182,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
public void saveData(NBTTagCompound nbttagcompound) {
super.saveData(nbttagcompound);
nbttagcompound.setByte("CollarColor", (byte) this.getCollarColor().getColorIndex());
@@ -128,7 +129,7 @@ index 6c25f667e..fa7f47fef 100644
this.c(nbttagcompound);
}
@@ -128,6 +191,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
@@ -128,6 +192,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
if (nbttagcompound.hasKeyOfType("CollarColor", 99)) {
this.setCollarColor(EnumColor.fromColorIndex(nbttagcompound.getInt("CollarColor")));
}
@@ -136,7 +137,7 @@ index 6c25f667e..fa7f47fef 100644
this.a((WorldServer) this.world, nbttagcompound);
}
@@ -172,6 +236,11 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
@@ -172,6 +237,11 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
public void tick() {
super.tick();
if (this.isAlive()) {
@@ -148,7 +149,7 @@ index 6c25f667e..fa7f47fef 100644
this.bv = this.bu;
if (this.eY()) {
this.bu += (1.0F - this.bu) * 0.4F;
@@ -343,6 +412,20 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
@@ -343,6 +413,20 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
return EnumInteractionResult.SUCCESS;
}

View File

@@ -7,11 +7,11 @@ This allows for the server to set a default collar color when a wolf is tamed.
Resets to RED when the value is invalid.
diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java
index fa7f47fef..ca38c2224 100644
index b28f1a374..0d179f3d3 100644
--- a/src/main/java/net/minecraft/server/EntityWolf.java
+++ b/src/main/java/net/minecraft/server/EntityWolf.java
@@ -114,6 +114,12 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
setRabid(world.purpurConfig.wolfNaturalRabid > 0.0D && random.nextDouble() <= world.purpurConfig.wolfNaturalRabid);
@@ -115,6 +115,12 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
this.updatePathfinders(false);
return super.prepare(worldaccess, difficultydamagescaler, enummobspawn, groupdataentity, nbttagcompound);
}
+

View File

@@ -1259,10 +1259,10 @@ index 323d79a99..1809f2ba3 100644
@Override
diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java
index ca38c2224..f60dc96fc 100644
index 0d179f3d3..fa68a0feb 100644
--- a/src/main/java/net/minecraft/server/EntityWolf.java
+++ b/src/main/java/net/minecraft/server/EntityWolf.java
@@ -120,6 +120,14 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
@@ -121,6 +121,14 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
setCollarColor(world.purpurConfig.wolfDefaultCollarColor);
super.tame(entityhuman);
}