mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-22 10:57:43 +01:00
Updated Upstream (Paper & Tuinity)
Upstream has released updates that appear to apply and compile correctly Paper Changes:b33b63908eSupport complex components in written book builder (#6337)bfb3d42b44Optimize entity tracker passenger checks (#6361)399710ff79Add reobf mappings patch for MinecraftServer#getLootTables (#6368)25cd8aba9fConfig option for Piglins guarding chests (#4829)80650e8936Added EntityItemDamageEvent (#4928) Tuinity Changes:8e7cc4dc96Do not submit profile lookups to worldgen threads
This commit is contained in:
135
patches/server/0196-Iron-golem-poppy-calms-anger.patch
Normal file
135
patches/server/0196-Iron-golem-poppy-calms-anger.patch
Normal file
@@ -0,0 +1,135 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Thu, 13 May 2021 21:22:51 -0500
|
||||
Subject: [PATCH] Iron golem poppy calms anger
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
|
||||
index f4e983da7206923ee0b0f984e65a6c2b3a6a8aeb..cea3725009af1bc746a593c4db63ed630889cd21 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
|
||||
@@ -91,6 +91,7 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
|
||||
protected void registerGoals() {
|
||||
if (level.purpurConfig.ironGolemCanSwim) this.goalSelector.addGoal(0, new net.minecraft.world.entity.ai.goal.FloatGoal(this)); // Purpur
|
||||
this.goalSelector.addGoal(0, new net.pl3x.purpur.entity.ai.HasRider(this)); // Purpur
|
||||
+ if (this.level.purpurConfig.ironGolemPoppyCalm) this.goalSelector.addGoal(0, new net.pl3x.purpur.entity.ai.ReceiveFlower(this)); // Purpur
|
||||
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0D, true));
|
||||
this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9D, 32.0F));
|
||||
this.goalSelector.addGoal(2, new MoveBackToVillageGoal(this, 0.6D, false));
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index 1c2d7b985a9ad7512ce584b69fac518da9ef2f54..e0e493653c95d6fdf7843efd3f3a7bec4d7729fc 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -1263,6 +1263,7 @@ public class PurpurWorldConfig {
|
||||
public boolean ironGolemRidableInWater = false;
|
||||
public boolean ironGolemCanSwim = false;
|
||||
public double ironGolemMaxHealth = 100.0D;
|
||||
+ public boolean ironGolemPoppyCalm = false;
|
||||
private void ironGolemSettings() {
|
||||
ironGolemRidable = getBoolean("mobs.iron_golem.ridable", ironGolemRidable);
|
||||
ironGolemRidableInWater = getBoolean("mobs.iron_golem.ridable-in-water", ironGolemRidableInWater);
|
||||
@@ -1273,6 +1274,7 @@ public class PurpurWorldConfig {
|
||||
set("mobs.iron_golem.attributes.max_health", oldValue);
|
||||
}
|
||||
ironGolemMaxHealth = getDouble("mobs.iron_golem.attributes.max_health", ironGolemMaxHealth);
|
||||
+ ironGolemPoppyCalm = getBoolean("mobs.iron_golem.poppy-calms-anger", ironGolemPoppyCalm);
|
||||
}
|
||||
|
||||
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
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..efbf2775558e61310dff900a0321964c63f4551d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/pl3x/purpur/entity/ai/ReceiveFlower.java
|
||||
@@ -0,0 +1,91 @@
|
||||
+package net.pl3x.purpur.entity.ai;
|
||||
+
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.world.InteractionHand;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.entity.ai.goal.Goal;
|
||||
+import net.minecraft.world.entity.animal.IronGolem;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import net.minecraft.world.level.block.Blocks;
|
||||
+
|
||||
+import java.util.EnumSet;
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+public class ReceiveFlower extends Goal {
|
||||
+ private final IronGolem irongolem;
|
||||
+ private ServerPlayer target;
|
||||
+ private int cooldown;
|
||||
+
|
||||
+ public ReceiveFlower(IronGolem entity) {
|
||||
+ this.irongolem = entity;
|
||||
+ setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canUse() {
|
||||
+ if (this.irongolem.getOfferFlowerTick() > 0) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (!this.irongolem.isAngry()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ UUID uuid = this.irongolem.getPersistentAngerTarget();
|
||||
+ if (uuid == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ Entity target = ((ServerLevel) this.irongolem.level).getEntity(uuid);
|
||||
+ if (!(target instanceof ServerPlayer player)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ InteractionHand hand = getPoppyHand(player);
|
||||
+ if (hand == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ removeFlower(player, hand);
|
||||
+ this.target = player;
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canContinueToUse() {
|
||||
+ return this.cooldown > 0;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void start() {
|
||||
+ this.cooldown = 100;
|
||||
+ this.irongolem.stopBeingAngry();
|
||||
+ this.irongolem.offerFlower(true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void stop() {
|
||||
+ this.irongolem.offerFlower(false);
|
||||
+ this.target = null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void tick() {
|
||||
+ this.irongolem.getLookControl().setLookAt(this.target, 30.0F, 30.0F);
|
||||
+ --this.cooldown;
|
||||
+ }
|
||||
+
|
||||
+ private InteractionHand getPoppyHand(ServerPlayer player) {
|
||||
+ 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) {
|
||||
+ return item.getItem() == Blocks.POPPY.asItem();
|
||||
+ }
|
||||
+}
|
||||
Reference in New Issue
Block a user