Breedable parrots

This commit is contained in:
William Blake Galbreath
2025-01-11 18:54:32 -08:00
committed by granny
parent 68b70c0446
commit 9caa34c68f
3 changed files with 43 additions and 71 deletions

View File

@@ -1,71 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 13 May 2021 22:17:50 -0500
Subject: [PATCH] Breedable parrots
diff --git a/net/minecraft/world/entity/animal/Parrot.java b/net/minecraft/world/entity/animal/Parrot.java
index 3305a49fed395c134cf099253ea0558b6bd27bd4..eb7d6c1367ad9e4b8292987a69531cd627580167 100644
--- a/net/minecraft/world/entity/animal/Parrot.java
+++ b/net/minecraft/world/entity/animal/Parrot.java
@@ -226,6 +226,7 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder<Parrot
protected void registerGoals() {
//this.goalSelector.addGoal(0, new TamableAnimal.TamableAnimalPanicGoal(1.25D)); // Purpur - move down
this.goalSelector.addGoal(0, new FloatGoal(this));
+ if (this.level().purpurConfig.parrotBreedable) this.goalSelector.addGoal(1, new net.minecraft.world.entity.ai.goal.BreedGoal(this, 1.0D)); // Purpur - Breedable parrots
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
this.goalSelector.addGoal(1, new TamableAnimal.TamableAnimalPanicGoal(1.25D)); // Purpur - Ridables
this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Player.class, 8.0F));
@@ -333,6 +334,7 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder<Parrot
}
}
+ if (this.level().purpurConfig.parrotBreedable) return super.mobInteract(player, hand); // Purpur - Breedable parrots
return InteractionResult.SUCCESS;
} else if (!itemstack.is(ItemTags.PARROT_POISONOUS_FOOD)) {
if (!this.isFlying() && this.isTame() && this.isOwnedBy(player)) {
@@ -357,7 +359,7 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder<Parrot
@Override
public boolean isFood(ItemStack stack) {
- return false;
+ return this.level().purpurConfig.parrotBreedable && stack.is(ItemTags.PARROT_FOOD); // Purpur - Breedable parrots
}
public static boolean checkParrotSpawnRules(EntityType<Parrot> type, LevelAccessor world, EntitySpawnReason spawnReason, BlockPos pos, RandomSource random) {
@@ -369,13 +371,13 @@ public class Parrot extends ShoulderRidingEntity implements VariantHolder<Parrot
@Override
public boolean canMate(Animal other) {
- return false;
+ return super.canMate(other); // Purpur - Breedable parrots
}
@Nullable
@Override
public AgeableMob getBreedOffspring(ServerLevel world, AgeableMob entity) {
- return null;
+ return world.purpurConfig.parrotBreedable ? EntityType.PARROT.create(world, EntitySpawnReason.BREEDING) : null; // Purpur - Breedable parrots
}
@Nullable
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 5caaaa88d71f84562f8ab403062bf9ac4eb4dfb9..3d226e2cd3d805a7f53f845f5b873506b6ef274a 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1620,6 +1620,7 @@ public class PurpurWorldConfig {
public double parrotMaxHealth = 6.0D;
public double parrotScale = 1.0D;
public boolean parrotTakeDamageFromWater = false;
+ public boolean parrotBreedable = false;
private void parrotSettings() {
parrotRidable = getBoolean("mobs.parrot.ridable", parrotRidable);
parrotRidableInWater = getBoolean("mobs.parrot.ridable-in-water", parrotRidableInWater);
@@ -1633,6 +1634,7 @@ public class PurpurWorldConfig {
parrotMaxHealth = getDouble("mobs.parrot.attributes.max_health", parrotMaxHealth);
parrotScale = Mth.clamp(getDouble("mobs.parrot.attributes.scale", parrotScale), 0.0625D, 16.0D);
parrotTakeDamageFromWater = getBoolean("mobs.parrot.takes-damage-from-water", parrotTakeDamageFromWater);
+ parrotBreedable = getBoolean("mobs.parrot.can-breed", parrotBreedable);
}
public boolean phantomRidable = false;

View File

@@ -1,5 +1,13 @@
--- a/net/minecraft/world/entity/animal/Parrot.java
+++ b/net/minecraft/world/entity/animal/Parrot.java
@@ -152,6 +_,7 @@
protected void registerGoals() {
this.goalSelector.addGoal(0, new TamableAnimal.TamableAnimalPanicGoal(1.25));
this.goalSelector.addGoal(0, new FloatGoal(this));
+ if (this.level().purpurConfig.parrotBreedable) this.goalSelector.addGoal(1, new net.minecraft.world.entity.ai.goal.BreedGoal(this, 1.0D)); // Purpur - Breedable parrots
this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(2, new SitWhenOrderedToGoal(this));
this.goalSelector.addGoal(2, new FollowOwnerGoal(this, 1.0, 5.0F, 1.0F));
@@ -257,7 +_,7 @@
}
@@ -9,3 +17,36 @@
this.tame(player);
this.level().broadcastEntityEvent(this, (byte)7);
} else {
@@ -265,6 +_,7 @@
}
}
+ if (this.level().purpurConfig.parrotBreedable) return super.mobInteract(player, hand); // Purpur - Breedable parrots
return InteractionResult.SUCCESS;
} else if (!itemInHand.is(ItemTags.PARROT_POISONOUS_FOOD)) {
if (!this.isFlying() && this.isTame() && this.isOwnedBy(player)) {
@@ -289,7 +_,7 @@
@Override
public boolean isFood(ItemStack stack) {
- return false;
+ return this.level().purpurConfig.parrotBreedable && stack.is(ItemTags.PARROT_FOOD); // Purpur - Breedable parrots
}
public static boolean checkParrotSpawnRules(
@@ -304,13 +_,13 @@
@Override
public boolean canMate(Animal otherAnimal) {
- return false;
+ return super.canMate(other); // Purpur - Breedable parrots
}
@Nullable
@Override
public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob otherParent) {
- return null;
+ return world.purpurConfig.parrotBreedable ? EntityType.PARROT.create(world, EntitySpawnReason.BREEDING) : null; // Purpur - Breedable parrots
}
@Nullable

View File

@@ -1612,6 +1612,7 @@ public class PurpurWorldConfig {
public double parrotMaxHealth = 6.0D;
public double parrotScale = 1.0D;
public boolean parrotTakeDamageFromWater = false;
public boolean parrotBreedable = false;
private void parrotSettings() {
parrotRidable = getBoolean("mobs.parrot.ridable", parrotRidable);
parrotRidableInWater = getBoolean("mobs.parrot.ridable-in-water", parrotRidableInWater);
@@ -1625,6 +1626,7 @@ public class PurpurWorldConfig {
parrotMaxHealth = getDouble("mobs.parrot.attributes.max_health", parrotMaxHealth);
parrotScale = Mth.clamp(getDouble("mobs.parrot.attributes.scale", parrotScale), 0.0625D, 16.0D);
parrotTakeDamageFromWater = getBoolean("mobs.parrot.takes-damage-from-water", parrotTakeDamageFromWater);
parrotBreedable = getBoolean("mobs.parrot.can-breed", parrotBreedable);
}
public boolean phantomRidable = false;