mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Updated Upstream (Paper & Pufferfish)
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@e4f5e1c Bump netty Pufferfish Changes: pufferfish-gg/Pufferfish@a8543a4 #33 Fix anti-xray related crash bug pufferfish-gg/Pufferfish@aefcb1a Updated Upstream (Paper)
This commit is contained in:
@@ -1,135 +0,0 @@
|
||||
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/animal/Cow.java b/src/main/java/net/minecraft/world/entity/animal/Cow.java
|
||||
index dd4d5e2e7cbfed18cf3b4664dbe08eaf9d95f61e..732c560383da3b8a270139758f29734d73b775be 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Cow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Cow.java
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.minecraft.world.entity.animal;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
@@ -28,6 +29,7 @@ import net.minecraft.world.item.ItemUtils;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
@@ -68,6 +70,7 @@ public class Cow extends Animal {
|
||||
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
||||
this.goalSelector.addGoal(1, new PanicGoal(this, 2.0D));
|
||||
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
|
||||
+ if (level.purpurConfig.cowFeedMushrooms > 0) this.goalSelector.addGoal(3, new TemptGoal(this, 1.25D, Ingredient.of(Items.WHEAT, Blocks.RED_MUSHROOM.asItem(), Blocks.BROWN_MUSHROOM.asItem()), false)); else // Purpur
|
||||
this.goalSelector.addGoal(3, new TemptGoal(this, 1.25D, Ingredient.of(Items.WHEAT), false));
|
||||
this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25D));
|
||||
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0D));
|
||||
@@ -123,11 +126,80 @@ public class Cow extends Animal {
|
||||
|
||||
player.setItemInHand(hand, itemstack1);
|
||||
return InteractionResult.sidedSuccess(this.level.isClientSide);
|
||||
+ // Purpur start - feed mushroom to change to mooshroom
|
||||
+ } else if (level.purpurConfig.cowFeedMushrooms > 0 && this.getType() != EntityType.MOOSHROOM && isMushroom(itemstack)) {
|
||||
+ return this.feedMushroom(player, itemstack);
|
||||
+ // Purpur end
|
||||
} else {
|
||||
return super.mobInteract(player, hand);
|
||||
}
|
||||
}
|
||||
|
||||
+ // Purpur start - feed mushroom to change to mooshroom
|
||||
+ private int redMushroomsFed = 0;
|
||||
+ private int brownMushroomsFed = 0;
|
||||
+
|
||||
+ private boolean isMushroom(ItemStack stack) {
|
||||
+ return stack.getItem() == Blocks.RED_MUSHROOM.asItem() || stack.getItem() == Blocks.BROWN_MUSHROOM.asItem();
|
||||
+ }
|
||||
+
|
||||
+ private int incrementFeedCount(ItemStack stack) {
|
||||
+ if (stack.getItem() == Blocks.RED_MUSHROOM.asItem()) {
|
||||
+ return ++redMushroomsFed;
|
||||
+ } else {
|
||||
+ return ++brownMushroomsFed;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private InteractionResult feedMushroom(Player player, ItemStack stack) {
|
||||
+ level.broadcastEntityEvent(this, (byte) 18); // hearts
|
||||
+ playSound(SoundEvents.COW_MILK, 1.0F, 1.0F);
|
||||
+ if (incrementFeedCount(stack) < level.purpurConfig.cowFeedMushrooms) {
|
||||
+ if (!player.getAbilities().instabuild) {
|
||||
+ stack.shrink(1);
|
||||
+ }
|
||||
+ return InteractionResult.CONSUME; // require 5 mushrooms to transform (prevents mushroom duping)
|
||||
+ }
|
||||
+ MushroomCow mooshroom = EntityType.MOOSHROOM.create(level);
|
||||
+ if (mooshroom == null) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ if (stack.getItem() == Blocks.BROWN_MUSHROOM.asItem()) {
|
||||
+ mooshroom.setMushroomType(MushroomCow.MushroomType.BROWN);
|
||||
+ } else {
|
||||
+ mooshroom.setMushroomType(MushroomCow.MushroomType.RED);
|
||||
+ }
|
||||
+ mooshroom.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
||||
+ mooshroom.setHealth(this.getHealth());
|
||||
+ mooshroom.setAge(getAge());
|
||||
+ mooshroom.copyPosition(this);
|
||||
+ mooshroom.setYBodyRot(this.yBodyRot);
|
||||
+ mooshroom.setYHeadRot(this.getYHeadRot());
|
||||
+ mooshroom.yRotO = this.yRotO;
|
||||
+ mooshroom.xRotO = this.xRotO;
|
||||
+ if (this.hasCustomName()) {
|
||||
+ mooshroom.setCustomName(this.getCustomName());
|
||||
+ }
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, mooshroom, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), mooshroom.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.INFECTED).callEvent()) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ this.level.addFreshEntity(mooshroom);
|
||||
+ this.remove(RemovalReason.DISCARDED);
|
||||
+ if (!player.getAbilities().instabuild) {
|
||||
+ stack.shrink(1);
|
||||
+ }
|
||||
+ for (int i = 0; i < 15; ++i) {
|
||||
+ ((ServerLevel) level).sendParticles(((ServerLevel) level).players, null, ParticleTypes.HAPPY_VILLAGER,
|
||||
+ getX() + random.nextFloat(), getY() + (random.nextFloat() * 2), getZ() + random.nextFloat(), 1,
|
||||
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0, true);
|
||||
+ }
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
@Override
|
||||
public Cow getBreedOffspring(ServerLevel world, AgeableMob entity) {
|
||||
return (Cow) EntityType.COW.create(world);
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index b06c801bee4dade7d655ec3f29dd38713db201e4..fcdfad2d539a65365e05ce9d49fd90e6febabecd 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -319,6 +319,7 @@ public class PurpurWorldConfig {
|
||||
public boolean cowRidableInWater = false;
|
||||
public boolean cowControllable = true;
|
||||
public double cowMaxHealth = 10.0D;
|
||||
+ public int cowFeedMushrooms = 0;
|
||||
private void cowSettings() {
|
||||
cowRidable = getBoolean("mobs.cow.ridable", cowRidable);
|
||||
cowRidableInWater = getBoolean("mobs.cow.ridable-in-water", cowRidableInWater);
|
||||
@@ -329,6 +330,7 @@ public class PurpurWorldConfig {
|
||||
set("mobs.cow.attributes.max_health", oldValue);
|
||||
}
|
||||
cowMaxHealth = getDouble("mobs.cow.attributes.max_health", cowMaxHealth);
|
||||
+ cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms);
|
||||
}
|
||||
|
||||
public boolean creeperRidable = false;
|
||||
Reference in New Issue
Block a user