mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Skeletons eat wither roses
This commit is contained in:
@@ -1,112 +0,0 @@
|
|||||||
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/net/minecraft/world/entity/monster/Skeleton.java b/net/minecraft/world/entity/monster/Skeleton.java
|
|
||||||
index 93b570c0d18f2fc76180c5c6ea292e191cb81be2..f1a9546aaa8499b198228f6a684850f7b20e67c9 100644
|
|
||||||
--- a/net/minecraft/world/entity/monster/Skeleton.java
|
|
||||||
+++ b/net/minecraft/world/entity/monster/Skeleton.java
|
|
||||||
@@ -17,6 +17,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 {
|
|
||||||
|
|
||||||
private static final int TOTAL_CONVERSION_TIME = 300;
|
|
||||||
@@ -182,4 +192,64 @@ 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(), net.minecraft.world.entity.EntitySpawnReason.CONVERSION);
|
|
||||||
+ 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;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ this.level().addFreshEntity(skeleton);
|
|
||||||
+ this.remove(RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
|
||||||
+ if (!player.getAbilities().instabuild) {
|
|
||||||
+ stack.shrink(1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ for (int i = 0; i < 15; ++i) {
|
|
||||||
+ ((ServerLevel) level()).sendParticlesSource(((ServerLevel) level()).players(), null, ParticleTypes.HAPPY_VILLAGER,
|
|
||||||
+ false, true,
|
|
||||||
+ getX() + random.nextFloat(), getY() + (random.nextFloat() * 2), getZ() + random.nextFloat(), 1,
|
|
||||||
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0);
|
|
||||||
+ }
|
|
||||||
+ 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 cbf26d5f0a3d615883b17c65709d078c72c46bbf..c122af4829a2edd3977af0310b27bb984d8eaad5 100644
|
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
@@ -2589,6 +2589,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);
|
|
||||||
@@ -2603,6 +2604,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 skeletonHorseRidable = false;
|
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
--- a/net/minecraft/world/entity/monster/Skeleton.java
|
||||||
|
+++ b/net/minecraft/world/entity/monster/Skeleton.java
|
||||||
|
@@ -135,4 +_,64 @@
|
||||||
|
this.spawnAtLocation(level, Items.SKELETON_SKULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Purpur start - Skeletons eat wither roses
|
||||||
|
+ private int witherRosesFed = 0;
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public net.minecraft.world.InteractionResult mobInteract(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand) {
|
||||||
|
+ net.minecraft.world.item.ItemStack stack = player.getItemInHand(hand);
|
||||||
|
+
|
||||||
|
+ if (level().purpurConfig.skeletonFeedWitherRoses > 0 && this.getType() != EntityType.WITHER_SKELETON && stack.getItem() == net.minecraft.world.level.block.Blocks.WITHER_ROSE.asItem()) {
|
||||||
|
+ return this.feedWitherRose(player, stack);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return super.mobInteract(player, hand);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private net.minecraft.world.InteractionResult feedWitherRose(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack) {
|
||||||
|
+ if (++witherRosesFed < level().purpurConfig.skeletonFeedWitherRoses) {
|
||||||
|
+ if (!player.getAbilities().instabuild) {
|
||||||
|
+ stack.shrink(1);
|
||||||
|
+ }
|
||||||
|
+ return net.minecraft.world.InteractionResult.CONSUME;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ WitherSkeleton skeleton = EntityType.WITHER_SKELETON.create(level(), net.minecraft.world.entity.EntitySpawnReason.CONVERSION);
|
||||||
|
+ if (skeleton == null) {
|
||||||
|
+ return net.minecraft.world.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 (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, skeleton, org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
|
||||||
|
+ return net.minecraft.world.InteractionResult.PASS;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ this.level().addFreshEntity(skeleton);
|
||||||
|
+ this.remove(RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
||||||
|
+ if (!player.getAbilities().instabuild) {
|
||||||
|
+ stack.shrink(1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < 15; ++i) {
|
||||||
|
+ ((ServerLevel) level()).sendParticlesSource(((ServerLevel) level()).players(), null, net.minecraft.core.particles.ParticleTypes.HAPPY_VILLAGER,
|
||||||
|
+ false, true,
|
||||||
|
+ getX() + random.nextFloat(), getY() + (random.nextFloat() * 2), getZ() + random.nextFloat(), 1,
|
||||||
|
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0);
|
||||||
|
+ }
|
||||||
|
+ return net.minecraft.world.InteractionResult.SUCCESS;
|
||||||
|
+ }
|
||||||
|
+ // Purpur end - Skeletons eat wither roses
|
||||||
|
}
|
||||||
@@ -2588,6 +2588,7 @@ public class PurpurWorldConfig {
|
|||||||
public boolean skeletonTakeDamageFromWater = false;
|
public boolean skeletonTakeDamageFromWater = false;
|
||||||
public boolean skeletonAlwaysDropExp = false;
|
public boolean skeletonAlwaysDropExp = false;
|
||||||
public double skeletonHeadVisibilityPercent = 0.5D;
|
public double skeletonHeadVisibilityPercent = 0.5D;
|
||||||
|
public int skeletonFeedWitherRoses = 0;
|
||||||
private void skeletonSettings() {
|
private void skeletonSettings() {
|
||||||
skeletonRidable = getBoolean("mobs.skeleton.ridable", skeletonRidable);
|
skeletonRidable = getBoolean("mobs.skeleton.ridable", skeletonRidable);
|
||||||
skeletonRidableInWater = getBoolean("mobs.skeleton.ridable-in-water", skeletonRidableInWater);
|
skeletonRidableInWater = getBoolean("mobs.skeleton.ridable-in-water", skeletonRidableInWater);
|
||||||
@@ -2602,6 +2603,7 @@ public class PurpurWorldConfig {
|
|||||||
skeletonTakeDamageFromWater = getBoolean("mobs.skeleton.takes-damage-from-water", skeletonTakeDamageFromWater);
|
skeletonTakeDamageFromWater = getBoolean("mobs.skeleton.takes-damage-from-water", skeletonTakeDamageFromWater);
|
||||||
skeletonAlwaysDropExp = getBoolean("mobs.skeleton.always-drop-exp", skeletonAlwaysDropExp);
|
skeletonAlwaysDropExp = getBoolean("mobs.skeleton.always-drop-exp", skeletonAlwaysDropExp);
|
||||||
skeletonHeadVisibilityPercent = getDouble("mobs.skeleton.head-visibility-percent", skeletonHeadVisibilityPercent);
|
skeletonHeadVisibilityPercent = getDouble("mobs.skeleton.head-visibility-percent", skeletonHeadVisibilityPercent);
|
||||||
|
skeletonFeedWitherRoses = getInt("mobs.skeleton.feed-wither-roses", skeletonFeedWitherRoses);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean skeletonHorseRidable = false;
|
public boolean skeletonHorseRidable = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user