From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 26 Mar 2020 19:46:44 -0500
Subject: [PATCH] Breedable Polar Bears


diff --git a/src/main/java/net/minecraft/server/EntityPolarBear.java b/src/main/java/net/minecraft/server/EntityPolarBear.java
index 914c6e48d60ac8feadc08e52e050899fe1396a8d..99f0bd8f82520778d469ec51745034e6ebd3238a 100644
--- a/src/main/java/net/minecraft/server/EntityPolarBear.java
+++ b/src/main/java/net/minecraft/server/EntityPolarBear.java
@@ -23,6 +23,30 @@ public class EntityPolarBear extends EntityAnimal implements IEntityAngerable {
         super(entitytypes, world);
     }
 
+    // Purpur start
+    @Override
+    public boolean mate(EntityAnimal entityanimal) {
+        if (entityanimal == this) {
+            return false;
+        } else if (this.isStanding()) {
+            return false;
+        } else if (this.getGoalTarget() != null) {
+            return false;
+        } else if (!(entityanimal instanceof EntityPolarBear)) {
+            return false;
+        } else {
+            EntityPolarBear polarbear = (EntityPolarBear) entityanimal;
+            if (polarbear.isStanding()) {
+                return false;
+            }
+            if (polarbear.getGoalTarget() != null) {
+                return false;
+            }
+            return this.isInLove() && polarbear.isInLove();
+        }
+    }
+    // Purpur end
+
     @Override
     public EntityAgeable createChild(WorldServer worldserver, EntityAgeable entityageable) {
         return (EntityAgeable) EntityTypes.POLAR_BEAR.a((World) worldserver);
@@ -30,7 +54,7 @@ public class EntityPolarBear extends EntityAnimal implements IEntityAngerable {
 
     @Override
     public boolean k(ItemStack itemstack) {
-        return false;
+        return world.purpurConfig.polarBearBreedableItem != null && itemstack.getItem() == world.purpurConfig.polarBearBreedableItem; // Purpur;
     }
 
     @Override
@@ -39,6 +63,12 @@ public class EntityPolarBear extends EntityAnimal implements IEntityAngerable {
         this.goalSelector.a(0, new PathfinderGoalFloat(this));
         this.goalSelector.a(1, new EntityPolarBear.c());
         this.goalSelector.a(1, new EntityPolarBear.d());
+        // Purpur start
+        if (world.purpurConfig.polarBearBreedableItem != null) {
+            this.goalSelector.a(2, new PathfinderGoalBreed(this, 1.0D));
+            this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.0D, RecipeItemStack.a(world.purpurConfig.polarBearBreedableItem), false));
+        }
+        // Purpur end
         this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 1.25D));
         this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, 1.0D));
         this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
@@ -180,10 +210,12 @@ public class EntityPolarBear extends EntityAnimal implements IEntityAngerable {
         return flag;
     }
 
+    public boolean isStanding() { return eM(); } // Purpur - OBFHELPER
     public boolean eM() {
         return (Boolean) this.datawatcher.get(EntityPolarBear.bo);
     }
 
+    public void setStanding(boolean standing) { t(standing); } // Purpur - OBFHELPER
     public void t(boolean flag) {
         this.datawatcher.set(EntityPolarBear.bo, flag);
     }
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 459ff8ffe7c0bf09fe93d89b3433bc930bb52f06..09b66b9ca3185528d0bc5f0a1d811c5a42039339 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -164,6 +164,14 @@ public class PurpurWorldConfig {
         ironGolemCanSwim = getBoolean("mobs.iron_golem.can-swim", ironGolemCanSwim);
     }
 
+    public String polarBearBreedableItemString = "";
+    public Item polarBearBreedableItem = null;
+    private void polarBearSettings() {
+        polarBearBreedableItemString = getString("mobs.polar_bear.breedable-item", polarBearBreedableItemString);
+        Item item = IRegistry.ITEM.get(new MinecraftKey(polarBearBreedableItemString));
+        if (item != Items.AIR) polarBearBreedableItem = item;
+    }
+
     public double rabbitNaturalToast = 0.0D;
     public double rabbitNaturalKiller = 0.0D;
     private void rabbitSettings() {
