mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Add option for using milk to cure wolves
Also make wolves scared of rabid wolves
This commit is contained in:
42
patches/api/0035-Rabid-Wolf-API.patch
Normal file
42
patches/api/0035-Rabid-Wolf-API.patch
Normal file
@@ -0,0 +1,42 @@
|
||||
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] Rabid Wolf API
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||
index da638f974..39f770411 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
||||
@@ -213,5 +213,6 @@ public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
||||
GoalKey<AbstractHorse> HORSE_HAS_RIDER = GoalKey.of(AbstractHorse.class, NamespacedKey.minecraft("horse_has_rider"));
|
||||
GoalKey<Drowned> DROWNED_ATTACK_VILLAGER = GoalKey.of(Drowned.class, NamespacedKey.minecraft("drowned_attack_villager"));
|
||||
GoalKey<Zombie> ZOMBIE_ATTACK_VILLAGER = GoalKey.of(Zombie.class, NamespacedKey.minecraft("zombie_attack_villager"));
|
||||
+ GoalKey<Wolf> AVOID_RABID_WOLVES = GoalKey.of(Wolf.class, NamespacedKey.minecraft("avoid_rabid_wolves"));
|
||||
// Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Wolf.java b/src/main/java/org/bukkit/entity/Wolf.java
|
||||
index 0e5decadf..c1fd30fe4 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Wolf.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Wolf.java
|
||||
@@ -39,4 +39,20 @@ public interface Wolf extends Tameable, Sittable {
|
||||
* @param color the color to apply
|
||||
*/
|
||||
public void setCollarColor(@NotNull DyeColor color);
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Checks if this wolf is rabid
|
||||
+ *
|
||||
+ * @return whether the wolf is rabid
|
||||
+ */
|
||||
+ public boolean isRabid();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets this wolf to be rabid or not
|
||||
+ *
|
||||
+ * @param rabid whether the wolf should be rabid
|
||||
+ */
|
||||
+ public void setRabid(boolean rabid);
|
||||
+ // Purpur end
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
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] Wolf naturally spawn rabid
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Wolf.java b/src/main/java/org/bukkit/entity/Wolf.java
|
||||
index 0e5decadf..26e3d6516 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Wolf.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Wolf.java
|
||||
@@ -39,4 +39,21 @@ public interface Wolf extends Tameable, Sittable {
|
||||
* @param color the color to apply
|
||||
*/
|
||||
public void setCollarColor(@NotNull DyeColor color);
|
||||
+
|
||||
+ // Purpur start
|
||||
+
|
||||
+ /**
|
||||
+ * Check if this wolf is rabid
|
||||
+ *
|
||||
+ * @return True if rabid
|
||||
+ */
|
||||
+ public boolean isRabid();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if this wolf is rabid
|
||||
+ *
|
||||
+ * @param isRabid True if rabid
|
||||
+ */
|
||||
+ public void setRabid(boolean isRabid);
|
||||
+ // Purpur end
|
||||
}
|
||||
@@ -1,16 +1,28 @@
|
||||
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] Wolf naturally 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 ce29695c69..a5a7b426eb 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 {
|
||||
}
|
||||
}
|
||||
|
||||
+ public final void setItemInHand(EnumHand enumHand, ItemStack itemStack) { this.a(enumHand, itemStack); } // Purpur - OBFHELPER
|
||||
public void a(EnumHand enumhand, ItemStack itemstack) {
|
||||
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 6c25f667ee..adbc3ec480 100644
|
||||
index 6c25f667ee..668c877ece 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityWolf.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityWolf.java
|
||||
@@ -14,11 +14,17 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
@@ -14,11 +14,42 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
private static final DataWatcherObject<Boolean> br = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i);
|
||||
private static final DataWatcherObject<Integer> bs = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.b);
|
||||
private static final DataWatcherObject<Integer> bt = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.b);
|
||||
@@ -22,14 +34,39 @@ index 6c25f667ee..adbc3ec480 100644
|
||||
};
|
||||
+ // Purpur start - rabid wolf spawn chance
|
||||
+ private boolean isRabid = false;
|
||||
+ private static final Predicate<EntityLiving> RABID_PREDICATE = e -> e instanceof EntityPlayer || (e instanceof EntityInsentient && e.getEntityType() != EntityTypes.WOLF);
|
||||
+ private static final Predicate<EntityLiving> RABID_PREDICATE = e -> e instanceof EntityPlayer || e instanceof EntityInsentient;
|
||||
+ private final PathfinderGoal PATHFINDER_VANILLA = new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, vanillaPredicate());
|
||||
+ private final PathfinderGoal PATHFINDER_RABID = new PathfinderGoalRandomTargetNonTamed<>(this, EntityLiving.class, false, RABID_PREDICATE);
|
||||
+ private static final class PathfinderGoalAvoidRabidWolves extends PathfinderGoalAvoidTarget<EntityWolf> {
|
||||
+ private final EntityWolf wolf;
|
||||
+
|
||||
+ public PathfinderGoalAvoidRabidWolves(EntityWolf wolf, float distance, double minSpeed, double maxSpeed) {
|
||||
+ super(wolf, EntityWolf.class, distance, minSpeed, maxSpeed);
|
||||
+ this.wolf = wolf;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean a() { // shouldExecute
|
||||
+ return super.a() && !this.wolf.isRabid() && this.getTarget() != null && this.getTarget().isRabid(); // wolves which are not rabid run away from rabid wolves
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void c() { // startExecuting
|
||||
+ this.wolf.setGoalTarget(null);
|
||||
+ super.c();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void e() { // tick
|
||||
+ this.wolf.setGoalTarget(null);
|
||||
+ super.e();
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
private float bu;
|
||||
private float bv;
|
||||
private boolean bw;
|
||||
@@ -53,6 +59,33 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
@@ -53,6 +84,36 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
int getPurpurBreedTime() {
|
||||
return this.world.purpurConfig.wolfBreedingTicks;
|
||||
}
|
||||
@@ -50,8 +87,11 @@ index 6c25f667ee..adbc3ec480 100644
|
||||
+ setTamed(false);
|
||||
+ setOwnerUUID(null);
|
||||
+ this.targetSelector.addGoal(5, PATHFINDER_RABID);
|
||||
+ this.addEffect(new MobEffect(MobEffects.CONFUSION, 1200));
|
||||
+ } else {
|
||||
+ this.targetSelector.addGoal(5, PATHFINDER_VANILLA);
|
||||
+ this.removeEffect(MobEffects.CONFUSION);
|
||||
+ this.pacify();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -63,7 +103,15 @@ index 6c25f667ee..adbc3ec480 100644
|
||||
// Purpur end
|
||||
|
||||
@Override
|
||||
@@ -74,7 +107,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
@@ -61,6 +122,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));
|
||||
+ this.goalSelector.addGoal(3, new PathfinderGoalAvoidRabidWolves(this, 24.0F, 1.5D, 1.5D)); // Purpur
|
||||
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
|
||||
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_));
|
||||
@@ -72,7 +120,7 @@ index 6c25f667ee..adbc3ec480 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 +152,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
@@ -119,6 +181,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
public void saveData(NBTTagCompound nbttagcompound) {
|
||||
super.saveData(nbttagcompound);
|
||||
nbttagcompound.setByte("CollarColor", (byte) this.getCollarColor().getColorIndex());
|
||||
@@ -80,7 +128,7 @@ index 6c25f667ee..adbc3ec480 100644
|
||||
this.c(nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -128,6 +162,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
@@ -128,6 +191,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
if (nbttagcompound.hasKeyOfType("CollarColor", 99)) {
|
||||
this.setCollarColor(EnumColor.fromColorIndex(nbttagcompound.getInt("CollarColor")));
|
||||
}
|
||||
@@ -88,19 +136,81 @@ index 6c25f667ee..adbc3ec480 100644
|
||||
|
||||
this.a((WorldServer) this.world, nbttagcompound);
|
||||
}
|
||||
@@ -172,6 +236,11 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.isAlive()) {
|
||||
+ // Purpur start
|
||||
+ if (this.ticksLived % 300 == 0 && this.isRabid()) {
|
||||
+ this.addEffect(new MobEffect(MobEffects.CONFUSION, 400));
|
||||
+ }
|
||||
+ // Purpur end
|
||||
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
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
}
|
||||
+ // Purpur start
|
||||
+ else if (this.world.purpurConfig.wolfMilkCuresRabies && itemstack.getItem() == Items.MILK_BUCKET && this.isRabid()) {
|
||||
+ if (!entityhuman.isCreative()) {
|
||||
+ entityhuman.setItemInHand(enumhand, new ItemStack(Items.BUCKET));
|
||||
+ }
|
||||
+ this.setRabid(false);
|
||||
+ for (int i = 0; i < 10; ++i) {
|
||||
+ ((WorldServer) world).sendParticles(((WorldServer) world).players, null, Particles.HAPPY_VILLAGER,
|
||||
+ locX() + random.nextFloat(), locY() + (random.nextFloat() * 1.5), locZ() + random.nextFloat(), 1,
|
||||
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0, true);
|
||||
+ }
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
|
||||
return super.b(entityhuman, enumhand);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalAvoidTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalAvoidTarget.java
|
||||
index 9a4819815c..da29898574 100644
|
||||
--- a/src/main/java/net/minecraft/server/PathfinderGoalAvoidTarget.java
|
||||
+++ b/src/main/java/net/minecraft/server/PathfinderGoalAvoidTarget.java
|
||||
@@ -8,7 +8,7 @@ public class PathfinderGoalAvoidTarget<T extends EntityLiving> extends Pathfinde
|
||||
protected final EntityCreature a;
|
||||
private final double i;
|
||||
private final double j;
|
||||
- protected T b;
|
||||
+ protected T b; protected T getTarget() { return this.b; } // Purpur - OBFHELPER
|
||||
protected final float c;
|
||||
protected PathEntity d;
|
||||
protected final NavigationAbstract e;
|
||||
@@ -18,12 +18,7 @@ public class PathfinderGoalAvoidTarget<T extends EntityLiving> extends Pathfinde
|
||||
private final PathfinderTargetCondition k;
|
||||
|
||||
public PathfinderGoalAvoidTarget(EntityCreature entitycreature, Class<T> oclass, float f, double d0, double d1) {
|
||||
- Predicate predicate = (entityliving) -> {
|
||||
- return true;
|
||||
- };
|
||||
- Predicate predicate1 = IEntitySelector.e;
|
||||
-
|
||||
- this(entitycreature, oclass, predicate, f, d0, d1, predicate1::test);
|
||||
+ this(entitycreature, oclass, entityliving -> true, f, d0, d1, IEntitySelector.e::test); // Purpur - decompile fix
|
||||
}
|
||||
|
||||
public PathfinderGoalAvoidTarget(EntityCreature entitycreature, Class<T> oclass, Predicate<EntityLiving> predicate, float f, double d0, double d1, Predicate<EntityLiving> predicate1) {
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index cc92689b4c..0a471a4542 100644
|
||||
index cc92689b4c..e76ae515d9 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -1128,10 +1128,12 @@ public class PurpurWorldConfig {
|
||||
@@ -1128,10 +1128,14 @@ public class PurpurWorldConfig {
|
||||
|
||||
public boolean wolfRidable = false;
|
||||
public boolean wolfRidableInWater = false;
|
||||
+ public boolean wolfMilkCuresRabies = true;
|
||||
+ public double wolfNaturalRabid = 0.0D;
|
||||
public int wolfBreedingTicks = 6000;
|
||||
private void wolfSettings() {
|
||||
wolfRidable = getBoolean("mobs.wolf.ridable", wolfRidable);
|
||||
wolfRidableInWater = getBoolean("mobs.wolf.ridable-in-water", wolfRidableInWater);
|
||||
+ wolfMilkCuresRabies = getBoolean("mobs.wolf.milk-cures-rabid-wolves", wolfMilkCuresRabies);
|
||||
+ wolfNaturalRabid = getDouble("mobs.wolf.spawn-rabid-chance", wolfNaturalRabid);
|
||||
wolfBreedingTicks = getInt("mobs.wolf.breeding-delay-ticks", wolfBreedingTicks);
|
||||
}
|
||||
Reference in New Issue
Block a user