mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 01:17:42 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: aa022fda Fix java cross-version compilation 8b7952a9 Implement alternative item-despawn-rate (#2128) 6ccf0bda Reimplement hopper optimization patch (#2388) e264c365 MC-156852 fix (#2396) b6c32b2a Fix recursion in EntityFox (#2418) 7c640a1a Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415)
164 lines
7.6 KiB
Diff
164 lines
7.6 KiB
Diff
From 1e49c1d0ba9fd497dc02f9104398dfe3ead1a9cd 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 to mooshroom when fed mushrooms
|
|
|
|
---
|
|
.../java/net/minecraft/server/Entity.java | 2 +
|
|
.../java/net/minecraft/server/EntityCow.java | 70 +++++++++++++++++++
|
|
.../net/minecraft/server/EntityLiving.java | 10 ++-
|
|
.../java/net/pl3x/purpur/PurpurConfig.java | 5 ++
|
|
4 files changed, 85 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index e8def7f81..40ab9daad 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1049,6 +1049,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.playSound((EntityHuman) null, this.locX, this.locY, this.locZ, soundeffect, this.getSoundCategory(), f, f1);
|
|
@@ -2546,6 +2547,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
this.invulnerable = flag;
|
|
}
|
|
|
|
+ public void copyPositionRotation(Entity entity) { this.u(entity); } // Purpur - OBFHELPER
|
|
public void u(Entity entity) {
|
|
this.setPositionRotation(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java
|
|
index d2c2e3cc3..0c00a86a8 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityCow.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityCow.java
|
|
@@ -16,6 +16,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));
|
|
+ if (net.pl3x.purpur.PurpurConfig.feedMushroomsToCows > 0) this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.25D, RecipeItemStack.a(Items.WHEAT, Blocks.RED_MUSHROOM.getItem(), Blocks.BROWN_MUSHROOM.getItem()), false)); else // Purpur
|
|
this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.25D, RecipeItemStack.a(Items.WHEAT), false));
|
|
this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 1.25D));
|
|
this.goalSelector.a(5, new PathfinderGoalRandomStrollLand(this, 1.0D));
|
|
@@ -79,11 +80,80 @@ public class EntityCow extends EntityAnimal {
|
|
// CraftBukkit end
|
|
|
|
return true;
|
|
+ // Purpur start - feed mushroom to change to mooshroom
|
|
+ } else if (net.pl3x.purpur.PurpurConfig.feedMushroomsToCows > 0 && getEntityType() != EntityTypes.MOOSHROOM && isMushroom(itemstack)) {
|
|
+ return feedMushroom(entityhuman, itemstack);
|
|
+ // Purpur end
|
|
} else {
|
|
return super.a(entityhuman, enumhand);
|
|
}
|
|
}
|
|
|
|
+ // Purpur start - feed mushroom to change to mooshroom
|
|
+ private int redMushroomsFed = 0;
|
|
+ private int brownMushroomsFed = 0;
|
|
+
|
|
+ private boolean isMushroom(ItemStack itemstack) {
|
|
+ return itemstack.getItem() == Blocks.RED_MUSHROOM.getItem() || itemstack.getItem() == Blocks.BROWN_MUSHROOM.getItem();
|
|
+ }
|
|
+
|
|
+ private int incrementFeedCount(ItemStack itemstack) {
|
|
+ if (itemstack.getItem() == Blocks.RED_MUSHROOM.getItem()) {
|
|
+ return ++redMushroomsFed;
|
|
+ } else {
|
|
+ return ++brownMushroomsFed;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private boolean feedMushroom(EntityHuman entityhuman, ItemStack itemstack) {
|
|
+ world.broadcastEntityEffect(this, (byte) 18); // hearts
|
|
+ playSound(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F);
|
|
+ if (incrementFeedCount(itemstack) < net.pl3x.purpur.PurpurConfig.feedMushroomsToCows) {
|
|
+ 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;
|
|
+ }
|
|
+ if (itemstack.getItem() == Blocks.BROWN_MUSHROOM.getItem()) {
|
|
+ mooshroom.setVariant(EntityMushroomCow.Type.BROWN);
|
|
+ } else {
|
|
+ mooshroom.setVariant(EntityMushroomCow.Type.RED);
|
|
+ }
|
|
+ mooshroom.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
|
|
+ mooshroom.setHealth(this.getHealth());
|
|
+ mooshroom.setAge(getAge());
|
|
+ mooshroom.copyPositionRotation(this);
|
|
+ mooshroom.setRenderYawOffset(this.getRenderYawOffset());
|
|
+ mooshroom.setHeadRotation(this.getHeadRotation());
|
|
+ mooshroom.lastYaw = this.lastYaw;
|
|
+ mooshroom.lastPitch = this.lastPitch;
|
|
+ if (this.hasCustomName()) {
|
|
+ mooshroom.setCustomName(this.getCustomName());
|
|
+ }
|
|
+ if (CraftEventFactory.callEntityTransformEvent(this, mooshroom, org.bukkit.event.entity.EntityTransformEvent.TransformReason.SHROOMED).isCancelled()) {
|
|
+ return false;
|
|
+ }
|
|
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), mooshroom.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.SHROOMED).callEvent()) {
|
|
+ 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(((WorldServer) world).players, null, Particles.HAPPY_VILLAGER,
|
|
+ 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
|
|
+
|
|
@Override
|
|
public EntityCow createChild(EntityAgeable entityageable) {
|
|
return (EntityCow) EntityTypes.COW.a(this.world);
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index 31d14b19b..ba9b21549 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -2746,8 +2746,14 @@ public abstract class EntityLiving extends Entity {
|
|
this.aM = f;
|
|
}
|
|
|
|
- @Override
|
|
- public void l(float f) {
|
|
+ // Purpur start
|
|
+ public float getRenderYawOffset() {
|
|
+ return this.aK;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
+ public void setRenderYawOffset(float f) { this.l(f); } // Purpur - OBFHELPER
|
|
+ @Override public void l(float f) {
|
|
this.aK = f;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
index b0f0040a4..d013f8407 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -130,4 +130,9 @@ public class PurpurConfig {
|
|
config.addDefault(path, def);
|
|
return config.getString(path, config.getString(path));
|
|
}
|
|
+
|
|
+ public static int feedMushroomsToCows = 0;
|
|
+ private static void cowsSettings() {
|
|
+ feedMushroomsToCows = getInt("settings.mobs.cow.feed-mushrooms-for-mooshroom", feedMushroomsToCows);
|
|
+ }
|
|
}
|
|
--
|
|
2.20.1
|
|
|