From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 26 Mar 2020 21:39:32 -0500
Subject: [PATCH] Configurable jockey options


diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityDrowned.java b/src/main/java/net/minecraft/world/entity/monster/EntityDrowned.java
index e4794760fc918cccbdc3f8d10ab21dd9b6f29e8e..ea776755767f29e49de2792afa30f79420d0fa4c 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EntityDrowned.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityDrowned.java
@@ -72,6 +72,23 @@ public class EntityDrowned extends EntityZombie implements IRangedEntity {
         this.navigationLand = new Navigation(this, world);
     }
 
+    // Purpur start
+    @Override
+    public boolean jockeyOnlyBaby() {
+        return world.purpurConfig.drownedJockeyOnlyBaby;
+    }
+
+    @Override
+    public double jockeyChance() {
+        return world.purpurConfig.drownedJockeyChance;
+    }
+
+    @Override
+    public boolean jockeyTryExistingChickens() {
+        return world.purpurConfig.drownedJockeyTryExistingChickens;
+    }
+    // Purpur end
+
     @Override
     protected void m() {
         this.goalSelector.a(1, new EntityDrowned.c(this, 1.0D));
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityPigZombie.java b/src/main/java/net/minecraft/world/entity/monster/EntityPigZombie.java
index cc1bff409cad2eb6264d4b691599576960080ccd..af00a4245ca39f208810d1ec758e512cbf5648f3 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EntityPigZombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityPigZombie.java
@@ -55,6 +55,23 @@ public class EntityPigZombie extends EntityZombie implements IEntityAngerable {
         this.a(PathType.LAVA, 8.0F);
     }
 
+    // Purpur start
+    @Override
+    public boolean jockeyOnlyBaby() {
+        return world.purpurConfig.zombifiedPiglinJockeyOnlyBaby;
+    }
+
+    @Override
+    public double jockeyChance() {
+        return world.purpurConfig.zombifiedPiglinJockeyChance;
+    }
+
+    @Override
+    public boolean jockeyTryExistingChickens() {
+        return world.purpurConfig.zombifiedPiglinJockeyTryExistingChickens;
+    }
+    // Purpur end
+
     @Override
     public void setAngerTarget(@Nullable UUID uuid) {
         this.br = uuid;
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java b/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
index 634416c354184bc6a2348c27c55e9868009ccd28..5ac950614fc90d02a568bb38f71faee124584c16 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
@@ -3,6 +3,7 @@ package net.minecraft.world.entity.monster;
 import com.mojang.serialization.DynamicOps;
 import java.time.LocalDate;
 import java.time.temporal.ChronoField;
+import java.util.Collections;
 import java.util.List;
 import java.util.Random;
 import java.util.UUID;
@@ -106,6 +107,20 @@ public class EntityZombie extends EntityMonster {
         this(EntityTypes.ZOMBIE, world);
     }
 
+    // Purpur start
+    public boolean jockeyOnlyBaby() {
+        return world.purpurConfig.zombieJockeyOnlyBaby;
+    }
+
+    public double jockeyChance() {
+        return world.purpurConfig.zombieJockeyChance;
+    }
+
+    public boolean jockeyTryExistingChickens() {
+        return world.purpurConfig.zombieJockeyTryExistingChickens;
+    }
+    // Purpur end
+
     @Override
     protected void initPathfinder() {
         if (world.paperConfig.zombiesTargetTurtleEggs) this.goalSelector.a(4, new EntityZombie.a(this, 1.0D, 3)); // Paper
@@ -506,19 +521,19 @@ public class EntityZombie extends EntityMonster {
         if (object instanceof EntityZombie.GroupDataZombie) {
             EntityZombie.GroupDataZombie entityzombie_groupdatazombie = (EntityZombie.GroupDataZombie) object;
 
-            if (entityzombie_groupdatazombie.a) {
-                this.setBaby(true);
+            // Purpur start
+            if (!jockeyOnlyBaby() || entityzombie_groupdatazombie.isBaby()) {
+                this.setBaby(entityzombie_groupdatazombie.isBaby());
                 if (entityzombie_groupdatazombie.b) {
-                    if ((double) worldaccess.getRandom().nextFloat() < 0.05D) {
-                        List<EntityChicken> list = worldaccess.a(EntityChicken.class, this.getBoundingBox().grow(5.0D, 3.0D, 5.0D), IEntitySelector.c);
+                    if ((double) worldaccess.getRandom().nextFloat() < jockeyChance()) {
+                        List<EntityChicken> list = jockeyTryExistingChickens() ? worldaccess.a(EntityChicken.class, this.getBoundingBox().grow(5.0D, 3.0D, 5.0D), IEntitySelector.c) : Collections.emptyList();
 
                         if (!list.isEmpty()) {
                             EntityChicken entitychicken = (EntityChicken) list.get(0);
 
                             entitychicken.setChickenJockey(true);
                             this.startRiding(entitychicken);
-                        }
-                    } else if ((double) worldaccess.getRandom().nextFloat() < 0.05D) {
+                        } else { // Purpur
                         EntityChicken entitychicken1 = (EntityChicken) EntityTypes.CHICKEN.a(this.world);
 
                         entitychicken1.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, 0.0F);
@@ -526,6 +541,7 @@ public class EntityZombie extends EntityMonster {
                         entitychicken1.setChickenJockey(true);
                         this.startRiding(entitychicken1);
                         worldaccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
+                        } // Purpur
                     }
                 }
             }
@@ -628,7 +644,7 @@ public class EntityZombie extends EntityMonster {
 
     public static class GroupDataZombie implements GroupDataEntity {
 
-        public final boolean a;
+        public final boolean a; public boolean isBaby() { return a; } // Purpur - OBFHELPER
         public final boolean b;
 
         public GroupDataZombie(boolean flag, boolean flag1) {
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityZombieHusk.java b/src/main/java/net/minecraft/world/entity/monster/EntityZombieHusk.java
index ce08413134de6101420ccb957da925ea1e3b0884..5d3e5873f19aaf8389eb5525693b9378ea9f94ee 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EntityZombieHusk.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityZombieHusk.java
@@ -22,6 +22,23 @@ public class EntityZombieHusk extends EntityZombie {
         super(entitytypes, world);
     }
 
+    // Purpur start
+    @Override
+    public boolean jockeyOnlyBaby() {
+        return world.purpurConfig.huskJockeyOnlyBaby;
+    }
+
+    @Override
+    public double jockeyChance() {
+        return world.purpurConfig.huskJockeyChance;
+    }
+
+    @Override
+    public boolean jockeyTryExistingChickens() {
+        return world.purpurConfig.huskJockeyTryExistingChickens;
+    }
+    // Purpur end
+
     public static boolean a(EntityTypes<EntityZombieHusk> entitytypes, WorldAccess worldaccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, Random random) {
         return b(entitytypes, worldaccess, enummobspawn, blockposition, random) && (enummobspawn == EnumMobSpawn.SPAWNER || worldaccess.e(blockposition));
     }
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/EntityZombieVillager.java
index f341759f6110b51c856de09248d2f523c58aa712..99d0932e5352589cfbcc48a5e789651d0d77edde 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EntityZombieVillager.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityZombieVillager.java
@@ -70,6 +70,23 @@ public class EntityZombieVillager extends EntityZombie implements VillagerDataHo
         this.setVillagerData(this.getVillagerData().withProfession((VillagerProfession) IRegistry.VILLAGER_PROFESSION.a(this.random)));
     }
 
+    // Purpur start
+    @Override
+    public boolean jockeyOnlyBaby() {
+        return world.purpurConfig.zombieVillagerJockeyOnlyBaby;
+    }
+
+    @Override
+    public double jockeyChance() {
+        return world.purpurConfig.zombieVillagerJockeyChance;
+    }
+
+    @Override
+    public boolean jockeyTryExistingChickens() {
+        return world.purpurConfig.zombieVillagerJockeyTryExistingChickens;
+    }
+    // Purpur end
+
     @Override
     protected void initDatawatcher() {
         super.initDatawatcher();
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 54ec01c01026f14f1f91aad2639109af853e10e4..1ebc8d04020aec7e36dfed5196dde9e9fe6ada0f 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -275,6 +275,15 @@ public class PurpurWorldConfig {
         creeperChargedChance = getDouble("mobs.creeper.naturally-charged-chance", creeperChargedChance);
     }
 
+    public boolean drownedJockeyOnlyBaby = true;
+    public double drownedJockeyChance = 0.05D;
+    public boolean drownedJockeyTryExistingChickens = true;
+    private void drownedSettings() {
+        drownedJockeyOnlyBaby = getBoolean("mobs.drowned.jockey.only-babies", drownedJockeyOnlyBaby);
+        drownedJockeyChance = getDouble("mobs.drowned.jockey.chance", drownedJockeyChance);
+        drownedJockeyTryExistingChickens = getBoolean("mobs.drowned.jockey.try-existing-chickens", drownedJockeyTryExistingChickens);
+    }
+
     public boolean enderDragonAlwaysDropsFullExp = false;
     private void enderDragonSettings() {
         enderDragonAlwaysDropsFullExp = getBoolean("mobs.ender_dragon.always-drop-full-exp", enderDragonAlwaysDropsFullExp);
@@ -312,6 +321,15 @@ public class PurpurWorldConfig {
         giantMaxHealth = getDouble("mobs.giant.attributes.max-health", giantMaxHealth);
     }
 
+    public boolean huskJockeyOnlyBaby = true;
+    public double huskJockeyChance = 0.05D;
+    public boolean huskJockeyTryExistingChickens = true;
+    private void huskSettings() {
+        huskJockeyOnlyBaby = getBoolean("mobs.husk.jockey.only-babies", huskJockeyOnlyBaby);
+        huskJockeyChance = getDouble("mobs.husk.jockey.chance", huskJockeyChance);
+        huskJockeyTryExistingChickens = getBoolean("mobs.husk.jockey.try-existing-chickens", huskJockeyTryExistingChickens);
+    }
+
     public double illusionerMovementSpeed = 0.5D;
     public double illusionerFollowRange = 18.0D;
     public double illusionerMaxHealth = 32.0D;
@@ -387,8 +405,35 @@ public class PurpurWorldConfig {
         witherSkeletonTakesWitherDamage = getBoolean("mobs.wither_skeleton.takes-wither-damage", witherSkeletonTakesWitherDamage);
     }
 
+    public boolean zombieJockeyOnlyBaby = true;
+    public double zombieJockeyChance = 0.05D;
+    public boolean zombieJockeyTryExistingChickens = true;
+    private void zombieSettings() {
+        zombieJockeyOnlyBaby = getBoolean("mobs.zombie.jockey.only-babies", zombieJockeyOnlyBaby);
+        zombieJockeyChance = getDouble("mobs.zombie.jockey.chance", zombieJockeyChance);
+        zombieJockeyTryExistingChickens = getBoolean("mobs.zombie.jockey.try-existing-chickens", zombieJockeyTryExistingChickens);
+    }
+
     public double zombieHorseSpawnChance = 0.0D;
     private void zombieHorseSettings() {
         zombieHorseSpawnChance = getDouble("mobs.zombie_horse.spawn-chance", zombieHorseSpawnChance);
     }
+
+    public boolean zombifiedPiglinJockeyOnlyBaby = true;
+    public double zombifiedPiglinJockeyChance = 0.05D;
+    public boolean zombifiedPiglinJockeyTryExistingChickens = true;
+    private void zombifiedPiglinSettings() {
+        zombifiedPiglinJockeyOnlyBaby = getBoolean("mobs.zombified_piglin.jockey.only-babies", zombifiedPiglinJockeyOnlyBaby);
+        zombifiedPiglinJockeyChance = getDouble("mobs.zombified_piglin.jockey.chance", zombifiedPiglinJockeyChance);
+        zombifiedPiglinJockeyTryExistingChickens = getBoolean("mobs.zombified_piglin.jockey.try-existing-chickens", zombifiedPiglinJockeyTryExistingChickens);
+    }
+
+    public boolean zombieVillagerJockeyOnlyBaby = true;
+    public double zombieVillagerJockeyChance = 0.05D;
+    public boolean zombieVillagerJockeyTryExistingChickens = true;
+    private void zombieVillagerSettings() {
+        zombieVillagerJockeyOnlyBaby = getBoolean("mobs.zombie_villager.jockey.only-babies", zombieVillagerJockeyOnlyBaby);
+        zombieVillagerJockeyChance = getDouble("mobs.zombie_villager.jockey.chance", zombieVillagerJockeyChance);
+        zombieVillagerJockeyTryExistingChickens = getBoolean("mobs.zombie_villager.jockey.try-existing-chickens", zombieVillagerJockeyTryExistingChickens);
+    }
 }
