configurable damage for aggressive cows (#643)

Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com>
This commit is contained in:
Oharass
2021-09-04 21:09:29 -05:00
committed by GitHub
parent 4e400de498
commit b6d1b6af37
2 changed files with 17 additions and 9 deletions

View File

@@ -123,7 +123,7 @@ index 6f4e6105aa1d6546daa2424f57972fd29db25fa3..4c55bb04ff41fabb47c6477ba33e0e0a
this.ticksPerAnimalSpawns = this.getCraftServer().getTicksPerAnimalSpawns(); // CraftBukkit
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..963ef9cf4dc134f5311420edd8c851eab34af3e2
index 0000000000000000000000000000000000000000..f589e4376f88c7774a7fe999cad4d11a59379cd9
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -0,0 +1,159 @@
@@ -190,8 +190,8 @@ index 0000000000000000000000000000000000000000..963ef9cf4dc134f5311420edd8c851ea
+ commands = new HashMap<>();
+ commands.put("purpur", new PurpurCommand("purpur"));
+
+ version = getInt("config-version", 21);
+ set("config-version", 21);
+ version = getInt("config-version", 22);
+ set("config-version", 22);
+
+ readConfig(PurpurConfig.class, null);
+ }

View File

@@ -5,7 +5,7 @@ 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 c718697a9511ccf761467644967397b777446db9..6855c409f1c793ec436f447838008853b9b249d2 100644
index c718697a9511ccf761467644967397b777446db9..66ecd29cc52483e0a79ec6c9c5dbf071501825d5 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;
@@ -20,7 +20,7 @@ index c718697a9511ccf761467644967397b777446db9..6855c409f1c793ec436f447838008853
@Override
public void initAttributes() {
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level.purpurConfig.cowMaxHealth);
+ this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(2.0D); // Purpur
+ this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(this.level.purpurConfig.cowNaturallyAggressiveToPlayersDamage); // Purpur
}
@Override
@@ -58,22 +58,30 @@ index c718697a9511ccf761467644967397b777446db9..6855c409f1c793ec436f447838008853
@Override
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index ed03ed6a594c2b06f1f5db7cc0c2b537e7aece76..99304124b8055a6d15375922b2b47c2bfd45383c 100644
index ed03ed6a594c2b06f1f5db7cc0c2b537e7aece76..467cc1e7166875c929b4d39f7ed3d7c2f12991e6 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1151,6 +1151,7 @@ public class PurpurWorldConfig {
@@ -1151,7 +1151,14 @@ public class PurpurWorldConfig {
public double cowMaxHealth = 10.0D;
public int cowFeedMushrooms = 0;
public int cowBreedingTicks = 6000;
+ 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);
@@ -1162,6 +1163,7 @@ public class PurpurWorldConfig {
if (PurpurConfig.version < 10) {
@@ -1162,6 +1169,8 @@ public class PurpurWorldConfig {
cowMaxHealth = getDouble("mobs.cow.attributes.max_health", cowMaxHealth);
cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms);
cowBreedingTicks = getInt("mobs.cow.breeding-delay-ticks", cowBreedingTicks);
+ cowNaturallyAggressiveToPlayersChance = getDouble("mobs.cow.naturally-aggressive-to-players-chance", cowNaturallyAggressiveToPlayersChance);
+ cowNaturallyAggressiveToPlayersChance = getDouble("mobs.cow.naturally-aggressive-to-players.chance", cowNaturallyAggressiveToPlayersChance);
+ cowNaturallyAggressiveToPlayersDamage = getDouble("mobs.cow.naturally-aggressive-to-players.damage", cowNaturallyAggressiveToPlayersDamage);
}
public boolean creeperRidable = false;