-
-
Notifications
You must be signed in to change notification settings - Fork 479
Expand file tree
/
Copy path0033-Tulips-change-fox-type.patch
More file actions
96 lines (88 loc) · 4.45 KB
/
Copy path0033-Tulips-change-fox-type.patch
File metadata and controls
96 lines (88 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 13 Jul 2019 15:56:22 -0500
Subject: [PATCH] Tulips change fox type
diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java
index 1f714f980bad7dcdeb361366a2d65c5a9f831a2c..64a564bf1a5133971050882835749807154c3a72 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
@@ -35,6 +35,7 @@ import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.InteractionHand;
+import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.Entity;
@@ -87,6 +88,7 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.CaveVines;
import net.minecraft.world.level.block.SweetBerryBushBlock;
import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.phys.Vec3;
@@ -382,6 +384,11 @@ public class Fox extends Animal {
}
private void setTargetGoals() {
+ // Purpur start - do not add duplicate goals
+ this.targetSelector.removeGoal(this.landTargetGoal);
+ this.targetSelector.removeGoal(this.turtleEggTargetGoal);
+ this.targetSelector.removeGoal(this.fishTargetGoal);
+ // Purpur end
if (this.getFoxType() == Fox.Type.RED) {
this.targetSelector.addGoal(4, this.landTargetGoal);
this.targetSelector.addGoal(4, this.turtleEggTargetGoal);
@@ -414,6 +421,7 @@ public class Fox extends Animal {
public void setFoxType(Fox.Type type) {
this.entityData.set(Fox.DATA_TYPE_ID, type.getId());
+ this.setTargetGoals(); // Purpur - fix API bug not updating pathfinders on type change
}
List<UUID> getTrustedUUIDs() {
@@ -750,6 +758,29 @@ public class Fox extends Animal {
return this.getTrustedUUIDs().contains(uuid);
}
+ // Purpur start
+ @Override
+ public InteractionResult mobInteract(Player player, InteractionHand hand) {
+ if (level.purpurConfig.foxTypeChangesWithTulips) {
+ ItemStack itemstack = player.getItemInHand(hand);
+ if (getFoxType() == Type.RED && itemstack.getItem() == Items.WHITE_TULIP) {
+ setFoxType(Type.SNOW);
+ if (!player.getAbilities().instabuild) {
+ itemstack.shrink(1);
+ }
+ return InteractionResult.SUCCESS;
+ } else if (getFoxType() == Type.SNOW && itemstack.getItem() == Items.ORANGE_TULIP) {
+ setFoxType(Type.RED);
+ if (!player.getAbilities().instabuild) {
+ itemstack.shrink(1);
+ }
+ return InteractionResult.SUCCESS;
+ }
+ }
+ return super.mobInteract(player, hand);
+ }
+ // Purpur end
+
@Override
// Paper start - Cancellable death event
protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) {
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index c092ef4a028d7dc335077b6b741bd1991cb3e7ba..e655b23d45ad4daca07202ae1e03d3dbdeff1813 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -490,6 +490,7 @@ public class PurpurWorldConfig {
public boolean foxRidableInWater = false;
public boolean foxControllable = true;
public double foxMaxHealth = 10.0D;
+ public boolean foxTypeChangesWithTulips = false;
private void foxSettings() {
foxRidable = getBoolean("mobs.fox.ridable", foxRidable);
foxRidableInWater = getBoolean("mobs.fox.ridable-in-water", foxRidableInWater);
@@ -500,6 +501,7 @@ public class PurpurWorldConfig {
set("mobs.fox.attributes.max_health", oldValue);
}
foxMaxHealth = getDouble("mobs.fox.attributes.max_health", foxMaxHealth);
+ foxTypeChangesWithTulips = getBoolean("mobs.fox.tulips-change-type", foxTypeChangesWithTulips);
}
public boolean frogRidable = false;