mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: ab347c4c9 Updated Upstream (Bukkit/CraftBukkit/Spigot) e2e09326d [Auto] Updated Upstream (Bukkit/CraftBukkit) 778d63b19 Add Gradle usage information to README (#3700) 25c14f76f Fix compile 78c855237 Updated Upstream (CraftBukkit) 8a4af269b fix EntityDismountEvent being fired on gen threads 55fb7da78 Merge branch 'ver/1.16' of https://github.com/PaperMC/Paper into ver/1.16 d70195264 Merge branch 'ver/1.16' of https://github.com/PaperMC/Paper into ver/1.16 443fb80bf Merge branch 'ver/1.16' of https://github.com/PaperMC/Paper into ver/1.16 d75c939e5 Merge branch 'ver/1.16' of https://github.com/PaperMC/Paper into ver/1.16 1431b1d6c Merge branch 'ver/1.16' of https://github.com/PaperMC/Paper into ver/1.16 e4f2ec002 Merge branch 'ver/1.16' of https://github.com/PaperMC/Paper into ver/1.16 122475aee Merge branch 'ver/1.16' of https://github.com/PaperMC/Paper into ver/1.16 b98da027d Merge branch 'ver/1.16' of https://github.com/PaperMC/Paper into ver/1.16 a8ffecc74 Fix NPE and uuid lookup for player skulls
150 lines
7.4 KiB
Diff
150 lines
7.4 KiB
Diff
From 8fc20523d0a02bb4dfdf896059856706dc924463 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
|
|
|
|
---
|
|
.../java/net/minecraft/server/Entity.java | 1 +
|
|
.../java/net/minecraft/server/EntityCow.java | 70 +++++++++++++++++++
|
|
.../net/minecraft/server/EntityLiving.java | 2 +-
|
|
.../net/pl3x/purpur/PurpurWorldConfig.java | 5 ++
|
|
4 files changed, 77 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 846ebe876d..78b4d82620 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -2561,6 +2561,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 30ee6df6b4..d6baddb9d3 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 (world.purpurConfig.cowFeedMushrooms > 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));
|
|
@@ -70,11 +71,80 @@ public class EntityCow extends EntityAnimal {
|
|
|
|
entityhuman.a(enumhand, itemstack1);
|
|
return EnumInteractionResult.a(this.world.isClientSide);
|
|
+ // Purpur start - feed mushroom to change to mooshroom
|
|
+ } else if (world.purpurConfig.cowFeedMushrooms > 0 && getEntityType() != EntityTypes.MOOSHROOM && isMushroom(itemstack)) {
|
|
+ return feedMushroom(entityhuman, itemstack);
|
|
+ // Purpur end
|
|
} else {
|
|
return super.b(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 EnumInteractionResult feedMushroom(EntityHuman entityhuman, ItemStack itemstack) {
|
|
+ world.broadcastEntityEffect(this, (byte) 18); // hearts
|
|
+ playSound(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F);
|
|
+ if (incrementFeedCount(itemstack) < world.purpurConfig.cowFeedMushrooms) {
|
|
+ if (!entityhuman.abilities.canInstantlyBuild) {
|
|
+ itemstack.subtract(1);
|
|
+ }
|
|
+ return EnumInteractionResult.CONSUME; // require 5 mushrooms to transform (prevents mushroom duping)
|
|
+ }
|
|
+ EntityMushroomCow mooshroom = EntityTypes.MOOSHROOM.create(world);
|
|
+ if (mooshroom == null) {
|
|
+ return EnumInteractionResult.PASS;
|
|
+ }
|
|
+ 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.INFECTION).isCancelled()) {
|
|
+ return EnumInteractionResult.PASS;
|
|
+ }
|
|
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), mooshroom.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.INFECTED).callEvent()) {
|
|
+ return EnumInteractionResult.PASS;
|
|
+ }
|
|
+ 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 EnumInteractionResult.SUCCESS;
|
|
+ }
|
|
+ // 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 03477c6e91..63cff85af9 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -80,7 +80,7 @@ public abstract class EntityLiving extends Entity {
|
|
public int maxNoDamageTicks;
|
|
public final float aF;
|
|
public final float aG;
|
|
- public float aH;
|
|
+ public float aH; public float getRenderYawOffset() { return this.aH; } public void setRenderYawOffset(float f) { this.aH = f; } // Purpur - OBFHELPER
|
|
public float aI;
|
|
public float aJ;
|
|
public float aK;
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index ec490745b0..faddf7c4bc 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -115,6 +115,11 @@ public class PurpurWorldConfig {
|
|
chickenRetaliate = getBoolean("mobs.chicken.retaliate", chickenRetaliate);
|
|
}
|
|
|
|
+ public int cowFeedMushrooms = 0;
|
|
+ private void cowSettings() {
|
|
+ cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms);
|
|
+ }
|
|
+
|
|
public double creeperChargedChance = 0.0D;
|
|
private void creeperSettings() {
|
|
creeperChargedChance = getDouble("mobs.creeper.naturally-charged-chance", creeperChargedChance);
|
|
--
|
|
2.26.2
|
|
|