mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
87 lines
4.0 KiB
Diff
87 lines
4.0 KiB
Diff
From e8d0089b90abb1eb2cfda12880241af711203cfb Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Fri, 3 May 2019 23:58:44 -0500
|
|
Subject: [PATCH] Snowman set pumpkin on/off by player interaction
|
|
|
|
---
|
|
.../net/minecraft/server/EntitySnowman.java | 37 ++++++++++---------
|
|
.../java/net/pl3x/purpur/PurpurConfig.java | 7 ++++
|
|
2 files changed, 27 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySnowman.java b/src/main/java/net/minecraft/server/EntitySnowman.java
|
|
index 291f4a72c6..53c5057d20 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySnowman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySnowman.java
|
|
@@ -8,6 +8,7 @@ import org.bukkit.event.player.PlayerShearEntityEvent;
|
|
|
|
public class EntitySnowman extends EntityGolem implements IRangedEntity {
|
|
|
|
+ private static final RecipeItemStack PUMPKIN = RecipeItemStack.a(Blocks.PUMPKIN.getItem(), Blocks.CARVED_PUMPKIN.getItem(), Blocks.JACK_O_LANTERN.getItem()); // Purpur
|
|
private static final DataWatcherObject<Byte> b = DataWatcher.a(EntitySnowman.class, DataWatcherRegistry.a);
|
|
|
|
public EntitySnowman(EntityTypes<? extends EntitySnowman> entitytypes, World world) {
|
|
@@ -113,25 +114,27 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity {
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
|
|
|
if (itemstack.getItem() == Items.SHEARS && this.hasPumpkin()) {
|
|
- if (!this.world.isClientSide) {
|
|
- // CraftBukkit start
|
|
- PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
|
|
- this.world.getServer().getPluginManager().callEvent(event);
|
|
-
|
|
- if (event.isCancelled()) {
|
|
- return false;
|
|
- }
|
|
- // CraftBukkit end
|
|
- this.setHasPumpkin(false);
|
|
- itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
|
- entityhuman1.d(enumhand);
|
|
- });
|
|
+ // Purpur start
|
|
+ if (!new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()).callEvent()) return false; // CraftBukkit
|
|
+
|
|
+ setHasPumpkin(false);
|
|
+ itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
|
+ entityhuman1.d(enumhand);
|
|
+ });
|
|
+
|
|
+ if (net.pl3x.purpur.PurpurConfig.snowmanDropsPumpkin) {
|
|
+ EntityItem pumpkin = new EntityItem(world, locX(), locY(), locZ(), new ItemStack(Blocks.CARVED_PUMPKIN.getItem()));
|
|
+ pumpkin.pickupDelay = 10;
|
|
+ world.addEntity(pumpkin);
|
|
+ }
|
|
+ } else if (net.pl3x.purpur.PurpurConfig.snowmanPumpkinPutBack && !hasPumpkin() && PUMPKIN.test(itemstack)) {
|
|
+ setHasPumpkin(true);
|
|
+ if (!entityhuman.abilities.canInstantlyBuild) {
|
|
+ itemstack.subtract(1);
|
|
}
|
|
-
|
|
- return true;
|
|
- } else {
|
|
- return false;
|
|
}
|
|
+ return true;
|
|
+ // Purpur end
|
|
}
|
|
|
|
public boolean hasPumpkin() {
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
index 26e95035b2..0c408a10cf 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -135,4 +135,11 @@ public class PurpurConfig {
|
|
private static void cowsSettings() {
|
|
feedMushroomsToCows = getInt("settings.mobs.cow.feed-mushrooms-for-mooshroom", feedMushroomsToCows);
|
|
}
|
|
+
|
|
+ public static boolean snowmanDropsPumpkin = false;
|
|
+ public static boolean snowmanPumpkinPutBack = false;
|
|
+ private static void snowmansSettings() {
|
|
+ snowmanDropsPumpkin = getBoolean("settings.mobs.snow_golem.drops-pumpkin-when-sheared", snowmanDropsPumpkin);
|
|
+ snowmanPumpkinPutBack = getBoolean("settings.mobs.snow_golem.pumpkin-can-be-added-back", snowmanPumpkinPutBack);
|
|
+ }
|
|
}
|
|
--
|
|
2.24.0.rc1
|
|
|