Files
Purpur/patches/server/0275-Skeletons-eat-wither-roses.patch
BillyGalbreath 47dc2e92f5 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@55a16d8 Fix Varint21FrameDecoder cached length buf usage
PaperMC/Paper@e6e37ba Add api to resolve components (#7648)
PaperMC/Paper@7168438 [ci skip] Rework workflows to support optional paperclip build (#8583)
PaperMC/Paper@da230d5 More vanilla friendly methods to update trades (#8478)
PaperMC/Paper@8aff07a Add /paper dumplisteners command (#8507)
PaperMC/Paper@b8919a7 pr command action fixes (#8591)
PaperMC/Paper@185fa48 Fix chest relooting mechanics (#8580)
PaperMC/Paper@b4beac0 Fixes potential issues arising from optimizing getPlayerByUUID (#8585)
PaperMC/Paper@f637b1a Fix async entity add due to fungus trees (#7626)
PaperMC/Paper@414ea80 ItemStack damage API (#7801)
PaperMC/Paper@d98c370 Add displayName methods for advancements (#8584)
PaperMC/Paper@44bb599 Add Tick TemporalUnit (#5445)
PaperMC/Paper@9f7eef8 Friction API (#6611)
PaperMC/Paper@4048d3e Allow using degrees for ArmorStand rotations (#7847)
PaperMC/Paper@f59c802 Schoolable Fish API (#7089)
PaperMC/Paper@21b964a Added ability to control player's insomnia and phantoms spawning (#6500)
PaperMC/Paper@f1583fc Add `/paper dumplisteners tofile` and increase detail of command output (#8592)
2022-11-26 18:48:36 -06:00

116 lines
5.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ben Kerllenevich <ben@omega24.dev>
Date: Sat, 25 Jun 2022 00:18:33 -0400
Subject: [PATCH] Skeletons eat wither roses
diff --git a/src/main/java/net/minecraft/world/entity/monster/Skeleton.java b/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
index 51c548cd84bd83624fbff3f853a8050dc1e71ecd..2c85d71cfb486d30cb58b3378ebcdf55e18423fd 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
@@ -14,6 +14,16 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.Level;
+// Purpur start
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.level.block.Blocks;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import net.minecraft.world.InteractionHand;
+import net.minecraft.world.InteractionResult;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.core.particles.ParticleTypes;
+// Purpur end
+
public class Skeleton extends AbstractSkeleton {
public static final EntityDataAccessor<Boolean> DATA_STRAY_CONVERSION_ID = SynchedEntityData.defineId(Skeleton.class, EntityDataSerializers.BOOLEAN);
@@ -170,4 +180,67 @@ public class Skeleton extends AbstractSkeleton {
}
}
+
+ // Purpur start
+ private int witherRosesFed = 0;
+
+ @Override
+ public InteractionResult mobInteract(Player player, InteractionHand hand) {
+ ItemStack stack = player.getItemInHand(hand);
+
+ if (level.purpurConfig.skeletonFeedWitherRoses > 0 && this.getType() != EntityType.WITHER_SKELETON && stack.getItem() == Blocks.WITHER_ROSE.asItem()) {
+ return this.feedWitherRose(player, stack);
+ }
+
+ return super.mobInteract(player, hand);
+ }
+
+ private InteractionResult feedWitherRose(Player player, ItemStack stack) {
+ if (++witherRosesFed < level.purpurConfig.skeletonFeedWitherRoses) {
+ if (!player.getAbilities().instabuild) {
+ stack.shrink(1);
+ }
+ return InteractionResult.CONSUME;
+ }
+
+ WitherSkeleton skeleton = EntityType.WITHER_SKELETON.create(level);
+ if (skeleton == null) {
+ return InteractionResult.PASS;
+ }
+
+ skeleton.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+ skeleton.setHealth(this.getHealth());
+ skeleton.setAggressive(this.isAggressive());
+ skeleton.copyPosition(this);
+ skeleton.setYBodyRot(this.yBodyRot);
+ skeleton.setYHeadRot(this.getYHeadRot());
+ skeleton.yRotO = this.yRotO;
+ skeleton.xRotO = this.xRotO;
+
+ if (this.hasCustomName()) {
+ skeleton.setCustomName(this.getCustomName());
+ }
+
+ if (CraftEventFactory.callEntityTransformEvent(this, skeleton, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
+ return InteractionResult.PASS;
+ }
+
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), skeleton.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.INFECTED).callEvent()) {
+ return InteractionResult.PASS;
+ }
+
+ this.level.addFreshEntity(skeleton);
+ 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
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index e937e689a46ffedfc54400fade9750aa737f0ce9..f90f561b112e35579be997b387492890b1cdf80e 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -2365,6 +2365,7 @@ public class PurpurWorldConfig {
public boolean skeletonTakeDamageFromWater = false;
public boolean skeletonAlwaysDropExp = false;
public double skeletonHeadVisibilityPercent = 0.5D;
+ public int skeletonFeedWitherRoses = 0;
private void skeletonSettings() {
skeletonRidable = getBoolean("mobs.skeleton.ridable", skeletonRidable);
skeletonRidableInWater = getBoolean("mobs.skeleton.ridable-in-water", skeletonRidableInWater);
@@ -2378,6 +2379,7 @@ public class PurpurWorldConfig {
skeletonTakeDamageFromWater = getBoolean("mobs.skeleton.takes-damage-from-water", skeletonTakeDamageFromWater);
skeletonAlwaysDropExp = getBoolean("mobs.skeleton.always-drop-exp", skeletonAlwaysDropExp);
skeletonHeadVisibilityPercent = getDouble("mobs.skeleton.head-visibility-percent", skeletonHeadVisibilityPercent);
+ skeletonFeedWitherRoses = getInt("mobs.skeleton.feed-wither-roses", skeletonFeedWitherRoses);
}
public boolean skeletonHorseRidableInWater = true;