mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
81 lines
3.8 KiB
Diff
81 lines
3.8 KiB
Diff
From 84f371a48a082ec8dbc2469d3e750876617509fe 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 | 20 ++++++++++++++++++-
|
|
.../java/net/pl3x/purpur/PurpurConfig.java | 7 +++++++
|
|
2 files changed, 26 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySnowman.java b/src/main/java/net/minecraft/server/EntitySnowman.java
|
|
index 8677f0818..fb36306b9 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySnowman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySnowman.java
|
|
@@ -2,12 +2,14 @@ package net.minecraft.server;
|
|
|
|
import javax.annotation.Nullable;
|
|
// CraftBukkit start
|
|
+import net.pl3x.purpur.PurpurConfig;
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
import org.bukkit.event.player.PlayerShearEntityEvent;
|
|
// CraftBukkit end
|
|
|
|
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) {
|
|
@@ -112,7 +114,7 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity {
|
|
protected boolean a(EntityHuman entityhuman, EnumHand enumhand) {
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
|
|
|
- if (itemstack.getItem() == Items.SHEARS && this.hasPumpkin() && !this.world.isClientSide) {
|
|
+ if (this.hasPumpkin()) { if (itemstack.getItem() == Items.SHEARS) { // Purpur
|
|
// CraftBukkit start
|
|
PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
|
@@ -126,6 +128,22 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity {
|
|
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
|
entityhuman1.d(enumhand);
|
|
});
|
|
+
|
|
+ // Purpur start
|
|
+ if (PurpurConfig.snowmanDropsPumpkin) {
|
|
+ EntityItem pumpkin = new EntityItem(world, locX, locY, locZ, new ItemStack(Blocks.PUMPKIN.getItem()));
|
|
+ pumpkin.pickupDelay = 10;
|
|
+ world.addEntity(pumpkin);
|
|
+ }
|
|
+ return true;
|
|
+ }} else {
|
|
+ if (PurpurConfig.snowmanPumpkinPutBack && PUMPKIN.test(itemstack)) {
|
|
+ setHasPumpkin(true);
|
|
+ if (!entityhuman.abilities.canInstantlyBuild) {
|
|
+ itemstack.subtract(1);
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
}
|
|
|
|
return super.a(entityhuman, enumhand);
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
index 88835089c..8f3367ae1 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -107,4 +107,11 @@ public class PurpurConfig {
|
|
private static void cowsSettings() {
|
|
feedMushroomsToCows = getInt("settings.mobs.cow.feed-mushrooms-for-mooshroom", feedMushroomsToCows);
|
|
}
|
|
+
|
|
+ public static boolean snowmanDropsPumpkin = true;
|
|
+ public static boolean snowmanPumpkinPutBack = true;
|
|
+ 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.20.1
|
|
|