Files
Purpur/patches/server/0234-Cows-naturally-aggressive-to-players-chance.patch
BillyGalbreath b7f623afe5 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
9259558b58 Fix remapping issue with RangedAttackMob and RangedEntity (#7167)
3d9385e665 Add material tags for copper blocks (#7141)
75f4cb074a Move setShouldBurnInDay to AbstractSkeleton (#7120)
9adc0b243b Fix breakNaturally for fluid-logged blocks (#7134)
76f327471d Move VehicleCollisionEvent HandlerList up (#7112)
d4c819056d Forward CraftEntity in teleport command (#7025)
9012ae8880 Improve scoreboard entries (#6871)
264b11d9f3 Entity powdered snow API (#6833)
a6a6a3db24 [ci skip] Revert change to apatch script
2cf6a57bca Fix entity type tags suggestions in selectors (#6468)
8a21c1742b Add API for item entity health (#6514)
26fbb02aae Adventure changes for Java 17 and Component support for resourcepack prompt
10bfb63f6c Configurable max block light for monster spawning (#7129)
6e5ceb34eb Fix ChunkMap distanceManager field reobf
82eaf4ee15 Fix duplicated BlockPistonRetractEvent call (#7111)
cf621c5eb3 Load effect amplifiers greater than 127 correctly (#7175)
1ce4281666 Fix ABI breakage for plainSerializer (#7178)
bf826b3fac [ci skip] Update Gradle wrapper to 7.3.3
464b1715bb Add uncaught exception handler using logger to usages of ThreadFactoryBuilder (#7179)
2021-12-23 22:44:22 -06:00

89 lines
5.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Mon, 30 Aug 2021 22:49:53 -0500
Subject: [PATCH] Cows naturally aggressive to players chance
diff --git a/src/main/java/net/minecraft/world/entity/animal/Cow.java b/src/main/java/net/minecraft/world/entity/animal/Cow.java
index 7042b95e92520c5e152af0fa71a553122ec814df..bbd210f8779138b225ce886b3917ca9ccbcbcf60 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Cow.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Cow.java
@@ -37,6 +37,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
// CraftBukkit end
public class Cow extends Animal {
+ private boolean isNaturallyAggressiveToPlayers; // Purpur
public Cow(EntityType<? extends Cow> type, Level world) {
super(type, world);
@@ -56,6 +57,7 @@ public class Cow extends Animal {
@Override
public void initAttributes() {
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level.purpurConfig.cowMaxHealth);
+ this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(this.level.purpurConfig.cowNaturallyAggressiveToPlayersDamage); // Purpur
}
@Override
@@ -67,6 +69,12 @@ public class Cow extends Animal {
public boolean isSensitiveToWater() {
return this.level.purpurConfig.cowTakeDamageFromWater;
}
+
+ @Override
+ public net.minecraft.world.entity.SpawnGroupData finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor world, net.minecraft.world.DifficultyInstance difficulty, net.minecraft.world.entity.MobSpawnType spawnReason, net.minecraft.world.entity.SpawnGroupData entityData, net.minecraft.nbt.CompoundTag entityNbt) {
+ this.isNaturallyAggressiveToPlayers = level.purpurConfig.cowNaturallyAggressiveToPlayersChance > 0.0D && random.nextDouble() <= level.purpurConfig.cowNaturallyAggressiveToPlayersChance;
+ return super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt);
+ }
// Purpur end
@Override
@@ -74,6 +82,7 @@ public class Cow extends Animal {
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
this.goalSelector.addGoal(1, new PanicGoal(this, 2.0D));
+ this.goalSelector.addGoal(1, new net.minecraft.world.entity.ai.goal.MeleeAttackGoal(this, 1.2000000476837158D, true)); // Purpur
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
if (level.purpurConfig.cowFeedMushrooms > 0) this.goalSelector.addGoal(3, new TemptGoal(this, 1.25D, Ingredient.of(Items.WHEAT, Blocks.RED_MUSHROOM.asItem(), Blocks.BROWN_MUSHROOM.asItem()), false)); else // Purpur
this.goalSelector.addGoal(3, new TemptGoal(this, 1.25D, Ingredient.of(Items.WHEAT), false));
@@ -81,10 +90,11 @@ public class Cow extends Animal {
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0D));
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
+ this.targetSelector.addGoal(0, new net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, target -> isNaturallyAggressiveToPlayers)); // Purpur
}
public static AttributeSupplier.Builder createAttributes() {
- return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 10.0D).add(Attributes.MOVEMENT_SPEED, 0.20000000298023224D);
+ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 10.0D).add(Attributes.MOVEMENT_SPEED, 0.20000000298023224D).add(Attributes.ATTACK_DAMAGE, 0.0D); // Purpur
}
@Override
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index c0538bf713edcc9166b9a8558112bab3f2cfa831..7106b9525e7c01b66bb16161641cd772a0c3bd8b 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1122,7 +1122,14 @@ public class PurpurWorldConfig {
public int cowFeedMushrooms = 0;
public int cowBreedingTicks = 6000;
public boolean cowTakeDamageFromWater = false;
+ public double cowNaturallyAggressiveToPlayersChance = 0.0D;
+ public double cowNaturallyAggressiveToPlayersDamage = 2.0D;
private void cowSettings() {
+ if (PurpurConfig.version < 22) {
+ double oldValue = getDouble("mobs.cow.naturally-aggressive-to-players-chance", cowNaturallyAggressiveToPlayersChance);
+ set("mobs.cow.naturally-aggressive-to-players-chance", null);
+ set("mobs.cow.naturally-aggressive-to-players.chance", oldValue);
+ }
cowRidable = getBoolean("mobs.cow.ridable", cowRidable);
cowRidableInWater = getBoolean("mobs.cow.ridable-in-water", cowRidableInWater);
if (PurpurConfig.version < 10) {
@@ -1134,6 +1141,8 @@ public class PurpurWorldConfig {
cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms);
cowBreedingTicks = getInt("mobs.cow.breeding-delay-ticks", cowBreedingTicks);
cowTakeDamageFromWater = getBoolean("mobs.cow.takes-damage-from-water", cowTakeDamageFromWater);
+ cowNaturallyAggressiveToPlayersChance = getDouble("mobs.cow.naturally-aggressive-to-players.chance", cowNaturallyAggressiveToPlayersChance);
+ cowNaturallyAggressiveToPlayersDamage = getDouble("mobs.cow.naturally-aggressive-to-players.damage", cowNaturallyAggressiveToPlayersDamage);
}
public boolean creeperRidable = false;