mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 09:27:43 +01:00
Fix #476 - Calming iron golom with rose doesnt consume item
This commit is contained in:
@@ -38,14 +38,15 @@ index 2c790011043065158a1ab092aa417fd8df45f246..1ca8fe623c69d5149d22902087be6a08
|
|||||||
public boolean llamaRidable = false;
|
public boolean llamaRidable = false;
|
||||||
diff --git a/src/main/java/net/pl3x/purpur/entity/ai/ReceiveFlower.java b/src/main/java/net/pl3x/purpur/entity/ai/ReceiveFlower.java
|
diff --git a/src/main/java/net/pl3x/purpur/entity/ai/ReceiveFlower.java b/src/main/java/net/pl3x/purpur/entity/ai/ReceiveFlower.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..f2f04547509b48c4c13b21e35d77c0ed36086f6b
|
index 0000000000000000000000000000000000000000..efbf2775558e61310dff900a0321964c63f4551d
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/net/pl3x/purpur/entity/ai/ReceiveFlower.java
|
+++ b/src/main/java/net/pl3x/purpur/entity/ai/ReceiveFlower.java
|
||||||
@@ -0,0 +1,78 @@
|
@@ -0,0 +1,91 @@
|
||||||
+package net.pl3x.purpur.entity.ai;
|
+package net.pl3x.purpur.entity.ai;
|
||||||
+
|
+
|
||||||
+import net.minecraft.server.level.ServerLevel;
|
+import net.minecraft.server.level.ServerLevel;
|
||||||
+import net.minecraft.server.level.ServerPlayer;
|
+import net.minecraft.server.level.ServerPlayer;
|
||||||
|
+import net.minecraft.world.InteractionHand;
|
||||||
+import net.minecraft.world.entity.Entity;
|
+import net.minecraft.world.entity.Entity;
|
||||||
+import net.minecraft.world.entity.ai.goal.Goal;
|
+import net.minecraft.world.entity.ai.goal.Goal;
|
||||||
+import net.minecraft.world.entity.animal.IronGolem;
|
+import net.minecraft.world.entity.animal.IronGolem;
|
||||||
@@ -81,9 +82,11 @@ index 0000000000000000000000000000000000000000..f2f04547509b48c4c13b21e35d77c0ed
|
|||||||
+ if (!(target instanceof ServerPlayer player)) {
|
+ if (!(target instanceof ServerPlayer player)) {
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+ if (!isOfferingFlower(player)) {
|
+ InteractionHand hand = getPoppyHand(player);
|
||||||
|
+ if (hand == null) {
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
|
+ removeFlower(player, hand);
|
||||||
+ this.target = player;
|
+ this.target = player;
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
@@ -112,8 +115,18 @@ index 0000000000000000000000000000000000000000..f2f04547509b48c4c13b21e35d77c0ed
|
|||||||
+ --this.cooldown;
|
+ --this.cooldown;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private boolean isOfferingFlower(ServerPlayer player) {
|
+ private InteractionHand getPoppyHand(ServerPlayer player) {
|
||||||
+ return isPoppy(player.getMainHandItem()) || isPoppy(player.getOffhandItem());
|
+ if (isPoppy(player.getMainHandItem())) {
|
||||||
|
+ return InteractionHand.MAIN_HAND;
|
||||||
|
+ }
|
||||||
|
+ if (isPoppy(player.getOffhandItem())) {
|
||||||
|
+ return InteractionHand.OFF_HAND;
|
||||||
|
+ }
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void removeFlower(ServerPlayer player, InteractionHand hand) {
|
||||||
|
+ player.setItemInHand(hand, ItemStack.EMPTY);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ private boolean isPoppy(ItemStack item) {
|
+ private boolean isPoppy(ItemStack item) {
|
||||||
|
|||||||
Reference in New Issue
Block a user