mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: c8028d1c Fix data version check for ItemStack serialization (#3394) 9254a80a Fix race condition reintroduced in Prioritize class loader patch 6f196fe7 Add Raw Byte ItemStack Serialization df43f828 Allow server startup for those poor people running <1G Xmx 3c9b65ef Fix cases where no-tick < tick view distance 72f89a07 Workaround for Client Lag Spikes (MC-162253) 3f941c0c Add option for console having all permissions d2ae4658 Add permission for command blocks 9f8ae5cb Prioritise own classes where possible 74466412 Check portal restrictions when entering end gateways fc9cf84d Fix NPE when temp ip bans expire (#3373) 16bd420d Add missing mob goals for API (#3367) b5c4e2f6 Ensure no-tick view is not smaller than ticking VD 52564b1f Expand Pathfinding API with more options dde65481 Fix usage of vanilla goals 7797aebe Drop Leads from nether portals - Fixes #3226 511b6bc2 Reduce MutableInt and Vec3d allocations, use ArrayDeque 84673141 Optimize NibbleArray to use pooled buffers 897dd2c8 Foundational work for Future Memory usage improvements bb4002d8 Handle CraftPlayer#setSpectatorTarget better 4ae08959 Fix collision checks on spawning hanging entities and null on async chunk loads c2f8d1ef Protect Bedrock and End Portal/Frames from being destroyed 827cc632 Updated Upstream (Bukkit/CraftBukkit/Spigot) 92f680ed Fix Pathfinding and obscure glitchy buggy 0 tick farms 7a7c4292 Optimize Pathfinder - Remove Streams / Optimized collections fc917d16 Optimize Hoppers - Major performance improvement 14ad77c6 Fix PotionEffect API Ignoring Icon bug eb3ce8a2 Fix EntityRaider picking up items when they shouldn't be able 1ea9ada0 Add a TELEPORT ticket when changing dimensions 8e9459ea Fix missing flag pass for isUrgent 7befec44 Potential bed api (#3339) 27945a6b Optimize WorldBorder collision checks and air 55e17a85 Wait for Async Tasks during shutdown b5905256 Ensure Entity AABB's are never invalid a054aa6f Properly remove Entities from current chunk c894ddfd Fix teleporting onto a chunk line 57d6cc01 Send LOGIN protocol packets immediately - Fix disconnect during async prelogin cd93e54d Don't use our modified chunk checks for collision in world gen b4003ef1 Allow loading entities current chunk if needed to fix collision checks e5f64896 Add Urgent API for Async Chunks API and use it for Async Teleport ad8e59dc Ensure chunks loaded on respawn for suffocation check
162 lines
7.9 KiB
Diff
162 lines
7.9 KiB
Diff
From 424361653f547e2ef080fcccba4bca7e6752a6ba 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 | 2 +
|
|
.../java/net/minecraft/server/EntityCow.java | 70 +++++++++++++++++++
|
|
.../net/minecraft/server/EntityLiving.java | 5 +-
|
|
.../net/pl3x/purpur/PurpurWorldConfig.java | 2 +
|
|
4 files changed, 77 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 1ef13ee78..0652f6312 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1098,6 +1098,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);
|
|
@@ -2646,6 +2647,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 723a9fa1e..f56fd7c01 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityCow.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityCow.java
|
|
@@ -34,6 +34,7 @@ public class EntityCow extends EntityAnimal {
|
|
this.goalSelector.a(0, new net.pl3x.purpur.pathfinder.PathfinderGoalHasRider(this)); // Purpur
|
|
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));
|
|
@@ -96,11 +97,80 @@ public class EntityCow extends EntityAnimal {
|
|
// CraftBukkit end
|
|
|
|
return true;
|
|
+ // 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.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) < world.purpurConfig.cowFeedMushrooms) {
|
|
+ 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.INFECTION).isCancelled()) {
|
|
+ return false;
|
|
+ }
|
|
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), mooshroom.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.INFECTED).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 58aa2a9a3..ea245de18 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -2831,8 +2831,9 @@ public abstract class EntityLiving extends Entity {
|
|
this.aK = f;
|
|
}
|
|
|
|
- @Override
|
|
- public void l(float f) {
|
|
+ public float getRenderYawOffset() { return this.aI; } // Purpur - OBFHELPER
|
|
+ public void setRenderYawOffset(float f) { this.l(f); } // Purpur - OBFHELPER
|
|
+ @Override public void l(float f) {
|
|
this.aI = f;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 12fbdf65c..091f30727 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -145,10 +145,12 @@ public class PurpurWorldConfig {
|
|
public boolean cowRidable = false;
|
|
public boolean cowRidableInWater = false;
|
|
public boolean cowRequireShiftToMount = true;
|
|
+ public int cowFeedMushrooms = 0;
|
|
private void cowSettings() {
|
|
cowRidable = getBoolean("mobs.cow.ridable", cowRidable);
|
|
cowRidableInWater = getBoolean("mobs.cow.ridable-in-water", cowRidableInWater);
|
|
cowRequireShiftToMount = getBoolean("mobs.cow.require-shift-to-mount", cowRequireShiftToMount);
|
|
+ cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms);
|
|
}
|
|
|
|
public boolean creeperRidable = false;
|
|
--
|
|
2.24.0
|
|
|