Cows to mooshroms when fed muchrooms

This commit is contained in:
William Blake Galbreath
2019-04-30 22:03:46 -05:00
parent 8bcfb52714
commit 9ee7772e17
3 changed files with 125 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
From 975b3da44f75bddc4b25e99fc92fadd3041693ff Mon Sep 17 00:00:00 2001 From ffa35dba22251b8317f83f702357707dca9fde81 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com> From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Tue, 30 Apr 2019 13:50:41 -0600 Date: Tue, 30 Apr 2019 13:50:41 -0600
Subject: [PATCH] Rebrand Purpur Subject: [PATCH] Rebrand Purpur

View File

@@ -0,0 +1,29 @@
From c52f2d6be3d4fa135ab7f0841acb6cc3f235673f Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Fri, 3 May 2019 23:21:23 -0500
Subject: [PATCH] cows to mooshroom when fed mushrooms
---
.../paper/event/entity/EntityTransformedEvent.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
index d9e5cab9..6c163bd4 100644
--- a/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
@@ -76,6 +76,12 @@ public class EntityTransformedEvent extends EntityEvent implements Cancellable {
* When a mooshroom turns to a cow
*/
SHEARED,
+ // Purpur start
+ /**
+ * When a cow turns to a mooshroom
+ */
+ SHROOMED,
+ // Purpur end
/**
* When a pig turns to a zombiepigman
*/
--
2.20.1

View File

@@ -0,0 +1,95 @@
From fe885adc99d941fd02f45582e5144e9dc0631214 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Fri, 3 May 2019 23:27:47 -0500
Subject: [PATCH] cows to mooshroom when fed mushrooms
---
.../java/net/minecraft/server/Entity.java | 1 +
.../java/net/minecraft/server/EntityCow.java | 45 ++++++++++++++++++-
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 32b90f30..fcf1560e 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1064,6 +1064,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return false;
}
+ public void playSound(SoundEffect soundeffect, float volume, float pitch) { a(soundeffect, volume, pitch); } // Paper - OBFHELPER
public void a(SoundEffect soundeffect, float f, float f1) {
if (!this.isSilent()) {
this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, soundeffect, this.bV(), f, f1);
diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java
index 9c7bf12b..b4b22eed 100644
--- a/src/main/java/net/minecraft/server/EntityCow.java
+++ b/src/main/java/net/minecraft/server/EntityCow.java
@@ -21,7 +21,7 @@ public class EntityCow extends EntityAnimal {
this.goalSelector.a(0, new PathfinderGoalFloat(this));
this.goalSelector.a(1, new PathfinderGoalPanic(this, 2.0D));
this.goalSelector.a(2, new PathfinderGoalBreed(this, 1.0D));
- this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.25D, RecipeItemStack.a(new IMaterial[] { Items.WHEAT}), false));
+ this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.25D, RecipeItemStack.a(new IMaterial[] { Items.WHEAT, Blocks.RED_MUSHROOM.getItem()}), false)); // Purpur
this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 1.25D));
this.goalSelector.a(5, new PathfinderGoalRandomStrollLand(this, 1.0D));
this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
@@ -59,6 +59,8 @@ public class EntityCow extends EntityAnimal {
return LootTables.S;
}
+ private int mushroomsFed = 0; // Purpur
+
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
@@ -82,6 +84,47 @@ public class EntityCow extends EntityAnimal {
// CraftBukkit end
return true;
+ // Purpur start - feed mushroom to change to mooshroom
+ } else if (getEntityType() != EntityTypes.MOOSHROOM && itemstack.getItem() == Blocks.RED_MUSHROOM.getItem()) {
+ world.broadcastEntityEffect(this, (byte) 18); // hearts
+ playSound(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F);
+ if (++mushroomsFed < 5) {
+ if (!entityhuman.abilities.canInstantlyBuild) {
+ itemstack.subtract(1);
+ }
+ return true; // require 5 mushrooms to transform (prevents mushroom duping)
+ }
+ EntityMushroomCow mooshroom = EntityTypes.MOOSHROOM.create(world);
+ if (mooshroom == null) {
+ return false;
+ }
+ mooshroom.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
+ mooshroom.setHealth(this.getHealth());
+ mooshroom.setAge(getAge());
+ mooshroom.u(this);
+ mooshroom.aQ = this.aQ;
+ mooshroom.aS = this.aS;
+ mooshroom.lastYaw = this.lastYaw;
+ mooshroom.lastPitch = this.lastPitch;
+ if (this.hasCustomName()) {
+ mooshroom.setCustomName(this.getCustomName());
+ }
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), mooshroom.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.SHROOMED).callEvent()) {
+ mooshroom.die();
+ return false;
+ }
+ this.world.addEntity(mooshroom);
+ this.die();
+ if (!entityhuman.abilities.canInstantlyBuild) {
+ itemstack.subtract(1);
+ }
+ for (int i = 0; i < 15; ++i) {
+ ((WorldServer) world).sendParticles(world.players, null, Particles.z,
+ locX + random.nextFloat(), locY + (random.nextFloat() * 2), locZ + random.nextFloat(), 1,
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0, true);
+ }
+ return true;
+ // Purpur end
} else {
return super.a(entityhuman, enumhand);
}
--
2.20.1