mirror of https://github.com/YatopiaMC/Yatopia.git
157 lines
8.1 KiB
Diff
157 lines
8.1 KiB
Diff
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/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index b7c72eaf5715a30bb8f82891f9830f9f62ec03c9..c8071e2909c03bd8eafb92fbf8fd8701642df1f9 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -2886,6 +2886,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
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/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
index f5bc04059c24f57530653c8845cfe4daa5fed843..5cdefe2a1b4085e3aae7dbbb751cfd368593ebd7 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
@@ -176,7 +176,7 @@ public abstract class EntityLiving extends Entity {
|
|
public int maxNoDamageTicks;
|
|
public final float ay;
|
|
public final float az;
|
|
- public float aA;
|
|
+ public float aA; public float getRenderYawOffset() { return this.aA; } public void setRenderYawOffset(float f) { this.aA = f; } // Purpur - OBFHELPER
|
|
public float aB;
|
|
public float aC;
|
|
public float aD;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/EntityCow.java b/src/main/java/net/minecraft/world/entity/animal/EntityCow.java
|
|
index 1b43688ad232620410aa924cef02b54630ab1313..962dde5fcc617bc39b7d06a1e295370b9d60696c 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/EntityCow.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/EntityCow.java
|
|
@@ -1,6 +1,7 @@
|
|
package net.minecraft.world.entity.animal;
|
|
|
|
import net.minecraft.core.BlockPosition;
|
|
+import net.minecraft.core.particles.Particles;
|
|
import net.minecraft.server.level.WorldServer;
|
|
import net.minecraft.sounds.SoundEffect;
|
|
import net.minecraft.sounds.SoundEffects;
|
|
@@ -28,6 +29,7 @@ import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.item.Items;
|
|
import net.minecraft.world.item.crafting.RecipeItemStack;
|
|
import net.minecraft.world.level.World;
|
|
+import net.minecraft.world.level.block.Blocks;
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
|
|
// CraftBukkit start
|
|
@@ -46,6 +48,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));
|
|
@@ -100,11 +103,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(WorldServer worldserver, EntityAgeable entityageable) {
|
|
return (EntityCow) EntityTypes.COW.a((World) worldserver);
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 9e935668147d1cd822f33c9e8d41e9541022aa8a..277cc8361e8faf54b95be1e9f1467a97de14ecc4 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -132,6 +132,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);
|