Cows eat mushrooms

This commit is contained in:
William Blake Galbreath
2025-01-05 14:32:10 -08:00
committed by granny
parent e7fcac7035
commit 5b5266b61b
3 changed files with 23 additions and 49 deletions

View File

@@ -793,7 +793,7 @@ index 708bcc39e7242292d5d5bfcaf599e3738628df9b..6a19086e272363701260801f3c6db9b5
public ItemStack getBucketItemStack() {
return new ItemStack(Items.COD_BUCKET);
diff --git a/net/minecraft/world/entity/animal/Cow.java b/net/minecraft/world/entity/animal/Cow.java
index befb99f0a96cb23f139061f92497737e9203a8fd..b2bf4276952fa1c984bf0571b041be4141fbdf3a 100644
index 8c1f74c6be53cbf48bd6b5641511359578801c08..656babc0c8810a85eb9f78ced1f3ad9551fdc286 100644
--- a/net/minecraft/world/entity/animal/Cow.java
+++ b/net/minecraft/world/entity/animal/Cow.java
@@ -38,9 +38,27 @@ public class Cow extends Animal {
@@ -823,7 +823,7 @@ index befb99f0a96cb23f139061f92497737e9203a8fd..b2bf4276952fa1c984bf0571b041be41
+ this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
this.goalSelector.addGoal(1, new PanicGoal(this, 2.0));
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
this.goalSelector.addGoal(3, new TemptGoal(this, 1.25, itemStack -> itemStack.is(ItemTags.COW_FOOD), false));
this.goalSelector.addGoal(3, new TemptGoal(this, 1.25, itemStack -> level().purpurConfig.cowFeedMushrooms > 0 && (itemStack.is(net.minecraft.world.level.block.Blocks.RED_MUSHROOM.asItem()) || itemStack.is(net.minecraft.world.level.block.Blocks.BROWN_MUSHROOM.asItem())) || itemStack.is(ItemTags.COW_FOOD), false)); // Purpur - Cows eat mushrooms
@@ -86,13 +104,14 @@ public class Cow extends Animal {
@Override

View File

@@ -1,39 +1,31 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 4 May 2019 01:10:30 -0500
Subject: [PATCH] Cows eat mushrooms
diff --git a/net/minecraft/world/entity/animal/Cow.java b/net/minecraft/world/entity/animal/Cow.java
index 064188a7032170ed16cf3b538efc444e54325036..88dd147317e200a11eb6a7e496bfffee9079fd6f 100644
--- a/net/minecraft/world/entity/animal/Cow.java
+++ b/net/minecraft/world/entity/animal/Cow.java
@@ -75,7 +75,7 @@ public class Cow extends Animal {
this.goalSelector.addGoal(1, new PanicGoal(this, 2.0D));
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
this.goalSelector.addGoal(3, new TemptGoal(this, 1.25D, (itemstack) -> {
- return itemstack.is(ItemTags.COW_FOOD);
+ return level().purpurConfig.cowFeedMushrooms > 0 && (itemstack.is(net.minecraft.world.level.block.Blocks.RED_MUSHROOM.asItem()) || itemstack.is(net.minecraft.world.level.block.Blocks.BROWN_MUSHROOM.asItem())) || itemstack.is(ItemTags.COW_FOOD); // Purpur - Cows eat mushrooms
}, false));
this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25D));
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0D));
@@ -137,6 +137,10 @@ public class Cow extends Animal {
player.setItemInHand(hand, itemstack1);
@@ -43,7 +_,7 @@
this.goalSelector.addGoal(0, new FloatGoal(this));
this.goalSelector.addGoal(1, new PanicGoal(this, 2.0));
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
- this.goalSelector.addGoal(3, new TemptGoal(this, 1.25, itemStack -> itemStack.is(ItemTags.COW_FOOD), false));
+ this.goalSelector.addGoal(3, new TemptGoal(this, 1.25, itemStack -> level().purpurConfig.cowFeedMushrooms > 0 && (itemStack.is(net.minecraft.world.level.block.Blocks.RED_MUSHROOM.asItem()) || itemStack.is(net.minecraft.world.level.block.Blocks.BROWN_MUSHROOM.asItem())) || itemStack.is(ItemTags.COW_FOOD), false)); // Purpur - Cows eat mushrooms
this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25));
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
@@ -99,6 +_,10 @@
ItemStack itemStack = ItemUtils.createFilledResult(itemInHand, player, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
player.setItemInHand(hand, itemStack);
return InteractionResult.SUCCESS;
+ // Purpur start - feed mushroom to change to mooshroom - Cows eat mushrooms
+ } else if (level().purpurConfig.cowFeedMushrooms > 0 && this.getType() != EntityType.MOOSHROOM && isMushroom(itemstack)) {
+ return this.feedMushroom(player, itemstack);
+ // Purpur start - Cows eat mushrooms - feed mushroom to change to mooshroom
+ } else if (level().purpurConfig.cowFeedMushrooms > 0 && this.getType() != EntityType.MOOSHROOM && isMushroom(itemInHand)) {
+ return this.feedMushroom(player, itemInHand);
+ // Purpur end - Cows eat mushrooms
} else {
return super.mobInteract(player, hand);
}
@@ -152,4 +156,67 @@ public class Cow extends Animal {
@@ -114,4 +_,67 @@
public EntityDimensions getDefaultDimensions(Pose pose) {
return this.isBaby() ? Cow.BABY_DIMENSIONS : super.getDefaultDimensions(pose);
return this.isBaby() ? BABY_DIMENSIONS : super.getDefaultDimensions(pose);
}
+
+ // Purpur start - feed mushroom to change to mooshroom - Cows eat mushrooms
+ // Purpur start - Cows eat mushrooms - feed mushroom to change to mooshroom
+ private int redMushroomsFed = 0;
+ private int brownMushroomsFed = 0;
+
@@ -78,7 +70,7 @@ index 064188a7032170ed16cf3b538efc444e54325036..88dd147317e200a11eb6a7e496bfffee
+ if (this.hasCustomName()) {
+ mooshroom.setCustomName(this.getCustomName());
+ }
+ if (CraftEventFactory.callEntityTransformEvent(this, mooshroom, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, mooshroom, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
+ return InteractionResult.PASS;
+ }
+ this.level().addFreshEntity(mooshroom);
@@ -96,23 +88,3 @@ index 064188a7032170ed16cf3b538efc444e54325036..88dd147317e200a11eb6a7e496bfffee
+ }
+ // Purpur end - Cows eat mushrooms
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index b3284dfbcdc240919776f47a780a824c406c2781..6eb25a9b4bb634e57f6de015c9a9f2fc78d0b86f 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -390,6 +390,7 @@ public class PurpurWorldConfig {
public boolean cowControllable = true;
public double cowMaxHealth = 10.0D;
public double cowScale = 1.0D;
+ public int cowFeedMushrooms = 0;
private void cowSettings() {
cowRidable = getBoolean("mobs.cow.ridable", cowRidable);
cowRidableInWater = getBoolean("mobs.cow.ridable-in-water", cowRidableInWater);
@@ -401,6 +402,7 @@ public class PurpurWorldConfig {
}
cowMaxHealth = getDouble("mobs.cow.attributes.max_health", cowMaxHealth);
cowScale = Mth.clamp(getDouble("mobs.cow.attributes.scale", cowScale), 0.0625D, 16.0D);
+ cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms);
}
public boolean creakingRidable = false;

View File

@@ -376,6 +376,7 @@ public class PurpurWorldConfig {
public boolean cowControllable = true;
public double cowMaxHealth = 10.0D;
public double cowScale = 1.0D;
public int cowFeedMushrooms = 0;
private void cowSettings() {
cowRidable = getBoolean("mobs.cow.ridable", cowRidable);
cowRidableInWater = getBoolean("mobs.cow.ridable-in-water", cowRidableInWater);
@@ -387,6 +388,7 @@ public class PurpurWorldConfig {
}
cowMaxHealth = getDouble("mobs.cow.attributes.max_health", cowMaxHealth);
cowScale = Mth.clamp(getDouble("mobs.cow.attributes.scale", cowScale), 0.0625D, 16.0D);
cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms);
}
public boolean creakingRidable = false;