Summoner API

This commit is contained in:
William Blake Galbreath
2025-01-12 11:30:20 -08:00
committed by granny
parent 305d99234b
commit f80ccb5b1e
18 changed files with 335 additions and 381 deletions

View File

@@ -1069,12 +1069,12 @@ index ddc252c76cedec0a0e9e268d8a874015a5ad52fe..8b0a813f9dd001c6dd108ba7aac04d13
}
}
diff --git a/net/minecraft/world/entity/animal/IronGolem.java b/net/minecraft/world/entity/animal/IronGolem.java
index ab3a3a2488628e18f71e30eab1639e9a08f63986..37b84f98e269bd28a67636929b200ee709804734 100644
index 46921562c9c5caf7e04ee180325a638273d6bad2..223c4796f659a24062a719045e484a22d31ab2f0 100644
--- a/net/minecraft/world/entity/animal/IronGolem.java
+++ b/net/minecraft/world/entity/animal/IronGolem.java
@@ -61,9 +61,28 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
super(entityType, level);
@@ -73,9 +73,28 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
}
// Purpur end - Summoner API
+ // Purpur start - Ridables
+ @Override
@@ -1101,7 +1101,7 @@ index ab3a3a2488628e18f71e30eab1639e9a08f63986..37b84f98e269bd28a67636929b200ee7
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0, true));
this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9, 32.0F));
this.goalSelector.addGoal(2, new MoveBackToVillageGoal(this, 0.6, false));
@@ -71,6 +90,7 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
@@ -83,6 +102,7 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
this.goalSelector.addGoal(5, new OfferFlowerGoal(this));
this.goalSelector.addGoal(7, new LookAtPlayerGoal(this, Player.class, 6.0F));
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
@@ -1109,7 +1109,7 @@ index ab3a3a2488628e18f71e30eab1639e9a08f63986..37b84f98e269bd28a67636929b200ee7
this.targetSelector.addGoal(1, new DefendVillageTargetGoal(this));
this.targetSelector.addGoal(2, new HurtByTargetGoal(this));
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
@@ -257,12 +277,12 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
@@ -271,12 +291,12 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
protected InteractionResult mobInteract(Player player, InteractionHand hand) {
ItemStack itemInHand = player.getItemInHand(hand);
if (!itemInHand.is(Items.IRON_INGOT)) {
@@ -1701,12 +1701,12 @@ index e686c500e4b5f3e7b0e808af8b2e43ddbd163bef..c27bb9e8a4a5e8fdc8ae28dae8203859
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
this.goalSelector.addGoal(3, new TemptGoal(this, 1.1, stack -> stack.is(ItemTags.SHEEP_FOOD), false));
diff --git a/net/minecraft/world/entity/animal/SnowGolem.java b/net/minecraft/world/entity/animal/SnowGolem.java
index 9130b51db39abc7781fecac8c881877e048e1c5f..17b41cfd9080cbb4def219cd91276e5a6d2a02a6 100644
index 29427515b648b84248f486c156c5cd7a0995ba14..52de92b118b613217b8f92ff672c01ddf798a1fc 100644
--- a/net/minecraft/world/entity/animal/SnowGolem.java
+++ b/net/minecraft/world/entity/animal/SnowGolem.java
@@ -49,12 +49,31 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
super(entityType, level);
@@ -61,12 +61,31 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
}
// Purpur end - Summoner API
+ // Purpur start - Ridables
+ @Override
@@ -1736,7 +1736,7 @@ index 9130b51db39abc7781fecac8c881877e048e1c5f..17b41cfd9080cbb4def219cd91276e5a
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Mob.class, 10, true, false, (entity, level) -> entity instanceof Enemy));
}
@@ -99,6 +118,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
@@ -113,6 +132,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
return;
}
@@ -1744,7 +1744,7 @@ index 9130b51db39abc7781fecac8c881877e048e1c5f..17b41cfd9080cbb4def219cd91276e5a
BlockState blockState = Blocks.SNOW.defaultBlockState();
for (int i = 0; i < 4; i++) {
@@ -141,7 +161,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
@@ -155,7 +175,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemInHand, hand, drops);
if (event != null) {
if (event.isCancelled()) {
@@ -1753,7 +1753,7 @@ index 9130b51db39abc7781fecac8c881877e048e1c5f..17b41cfd9080cbb4def219cd91276e5a
}
drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops());
// Paper end - custom shear drops
@@ -162,7 +182,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
@@ -176,7 +196,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
return InteractionResult.SUCCESS;
// Purpur end - Snowman drop and put back pumpkin
} else {
@@ -2797,7 +2797,7 @@ index f7e6866404af629ae0b20425202f592d76df4f3d..bc9564ee22ff9d7f6d819da9601c2d81
this.dragonFight.updateDragon(this);
}
diff --git a/net/minecraft/world/entity/boss/wither/WitherBoss.java b/net/minecraft/world/entity/boss/wither/WitherBoss.java
index 0ccbcd8b576b082260b17b85291a81e905e6f46f..591dbbbd1da84b0190f010b22d5163bb41cdd3c7 100644
index 79b1f6ed312b2c4c1ec708271c38bc59f0ae0e0e..c78132da8cb476e81beac68f7c0ac4ccd27a5db0 100644
--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -69,6 +69,7 @@ public class WitherBoss extends Monster implements RangedAttackMob {
@@ -2808,10 +2808,10 @@ index 0ccbcd8b576b082260b17b85291a81e905e6f46f..591dbbbd1da84b0190f010b22d5163bb
private boolean canPortal = false; // Paper
public final ServerBossEvent bossEvent = (ServerBossEvent)new ServerBossEvent(
this.getDisplayName(), BossEvent.BossBarColor.PURPLE, BossEvent.BossBarOverlay.PROGRESS
@@ -77,9 +78,23 @@ public class WitherBoss extends Monster implements RangedAttackMob {
private static final TargetingConditions.Selector LIVING_ENTITY_SELECTOR = (entity, level) -> !entity.getType().is(EntityTypeTags.WITHER_FRIENDS)
@@ -78,9 +79,23 @@ public class WitherBoss extends Monster implements RangedAttackMob {
&& entity.attackable();
private static final TargetingConditions TARGETING_CONDITIONS = TargetingConditions.forCombat().range(20.0).selector(LIVING_ENTITY_SELECTOR);
@Nullable private java.util.UUID summoner; // Purpur - Summoner API
+ private org.purpurmc.purpur.controller.FlyingWithSpacebarMoveControllerWASD purpurController; // Purpur - Ridables
public WitherBoss(EntityType<? extends WitherBoss> entityType, Level level) {
@@ -2832,9 +2832,9 @@ index 0ccbcd8b576b082260b17b85291a81e905e6f46f..591dbbbd1da84b0190f010b22d5163bb
this.moveControl = new FlyingMoveControl(this, 10, false);
this.setHealth(this.getMaxHealth());
this.xpReward = 50;
@@ -93,13 +108,114 @@ public class WitherBoss extends Monster implements RangedAttackMob {
return flyingPathNavigation;
@@ -97,6 +112,105 @@ public class WitherBoss extends Monster implements RangedAttackMob {
}
// Purpur end - Summoner API
+ // Purpur start - Ridables
+ @Override
@@ -2935,6 +2935,11 @@ index 0ccbcd8b576b082260b17b85291a81e905e6f46f..591dbbbd1da84b0190f010b22d5163bb
+ }
+ // Purpur end - Ridables
+
@Override
protected PathNavigation createNavigation(Level level) {
FlyingPathNavigation flyingPathNavigation = new FlyingPathNavigation(this, level);
@@ -107,11 +221,13 @@ public class WitherBoss extends Monster implements RangedAttackMob {
@Override
protected void registerGoals() {
+ this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur - Ridables
@@ -2947,7 +2952,7 @@ index 0ccbcd8b576b082260b17b85291a81e905e6f46f..591dbbbd1da84b0190f010b22d5163bb
this.targetSelector.addGoal(1, new HurtByTargetGoal(this));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, LivingEntity.class, 0, false, false, LIVING_ENTITY_SELECTOR));
}
@@ -257,6 +373,15 @@ public class WitherBoss extends Monster implements RangedAttackMob {
@@ -271,6 +387,15 @@ public class WitherBoss extends Monster implements RangedAttackMob {
@Override
protected void customServerAiStep(ServerLevel level) {
@@ -2963,7 +2968,7 @@ index 0ccbcd8b576b082260b17b85291a81e905e6f46f..591dbbbd1da84b0190f010b22d5163bb
if (this.getInvulnerableTicks() > 0) {
int i = this.getInvulnerableTicks() - 1;
this.bossEvent.setProgress(1.0F - i / 220.0F);
@@ -563,11 +688,11 @@ public class WitherBoss extends Monster implements RangedAttackMob {
@@ -577,11 +702,11 @@ public class WitherBoss extends Monster implements RangedAttackMob {
}
public int getAlternativeTarget(int head) {

View File

@@ -202,10 +202,10 @@ index 8b0a813f9dd001c6dd108ba7aac04d134a20fbc1..8bf893837586ae2a9b4ef7564d242e16
protected void defineSynchedData(SynchedEntityData.Builder builder) {
super.defineSynchedData(builder);
diff --git a/net/minecraft/world/entity/animal/IronGolem.java b/net/minecraft/world/entity/animal/IronGolem.java
index 37b84f98e269bd28a67636929b200ee709804734..42780e8245b1746783084558cc2deab361b09d3b 100644
index 223c4796f659a24062a719045e484a22d31ab2f0..37a353cbb0e9b16e0fc92bd1bc8194cb4cd3c13a 100644
--- a/net/minecraft/world/entity/animal/IronGolem.java
+++ b/net/minecraft/world/entity/animal/IronGolem.java
@@ -78,6 +78,14 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
@@ -90,6 +90,14 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
}
// Purpur end - Ridables
@@ -422,10 +422,10 @@ index c27bb9e8a4a5e8fdc8ae28dae820385966b8b44c..b66440f5cfbd714c6d2f5b7f66b4e755
protected void registerGoals() {
this.eatBlockGoal = new EatBlockGoal(this);
diff --git a/net/minecraft/world/entity/animal/SnowGolem.java b/net/minecraft/world/entity/animal/SnowGolem.java
index 17b41cfd9080cbb4def219cd91276e5a6d2a02a6..4f0d2ede28adbe412d208609a96eacc1309b8115 100644
index 52de92b118b613217b8f92ff672c01ddf798a1fc..d97a297db3bec0c86c6a82ef1c353015df2115f7 100644
--- a/net/minecraft/world/entity/animal/SnowGolem.java
+++ b/net/minecraft/world/entity/animal/SnowGolem.java
@@ -66,6 +66,14 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
@@ -78,6 +78,14 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
}
// Purpur end - Ridables
@@ -903,13 +903,13 @@ index bc9564ee22ff9d7f6d819da9601c2d8162d304e1..ca900bb646e16c7b4342f23c3ffae786
// CraftBukkit start - SPIGOT-2420: Special case, the ender dragon drops 12000 xp for the first kill and 500 xp for every other kill and this over time.
diff --git a/net/minecraft/world/entity/boss/wither/WitherBoss.java b/net/minecraft/world/entity/boss/wither/WitherBoss.java
index 591dbbbd1da84b0190f010b22d5163bb41cdd3c7..f6221829d213f103ffed9acbf9c6bc954ab6d539 100644
index c78132da8cb476e81beac68f7c0ac4ccd27a5db0..409b54fd8b0b9f34f2524d63d49abce6845ec80a 100644
--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -99,6 +99,13 @@ public class WitherBoss extends Monster implements RangedAttackMob {
this.setHealth(this.getMaxHealth());
this.xpReward = 50;
@@ -211,6 +211,14 @@ public class WitherBoss extends Monster implements RangedAttackMob {
}
// Purpur end - Ridables
+ // Purpur start - Configurable entity base attributes
+ @Override
+ public void initAttributes() {
@@ -917,10 +917,11 @@ index 591dbbbd1da84b0190f010b22d5163bb41cdd3c7..f6221829d213f103ffed9acbf9c6bc95
+ this.getAttribute(Attributes.SCALE).setBaseValue(this.level().purpurConfig.witherScale);
+ }
+ // Purpur end - Configurable entity base attributes
+
@Override
protected PathNavigation createNavigation(Level level) {
@@ -419,7 +426,7 @@ public class WitherBoss extends Monster implements RangedAttackMob {
FlyingPathNavigation flyingPathNavigation = new FlyingPathNavigation(this, level);
@@ -433,7 +441,7 @@ public class WitherBoss extends Monster implements RangedAttackMob {
this.setInvulnerableTicks(i);
if (this.tickCount % 10 == 0) {

View File

@@ -53,10 +53,10 @@ index 75a9bd205f32b77c5d242cb9fac0f571ce36045a..b03f182c62c699cc222e67c1ae6eadf9
itemInHand.shrink(1); // Moved up from below
} else {
diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java
index 34b7ead0f14a3f8ba8a9d94996c759896004299f..75f71b90bac3a6da888366325139485e44e472e6 100644
index ef66c7b03696c2601d1fd0379fa038336ee0bb87..735ede5c5aa4b74639660fb4966101dcf63a2d75 100644
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
@@ -731,6 +731,14 @@ public final class ItemStack implements DataComponentHolder {
@@ -733,6 +733,14 @@ public final class ItemStack implements DataComponentHolder {
org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(serverPlayer, this); // Paper - Add EntityDamageItemEvent
}
// CraftBukkit end

View File

@@ -118,10 +118,10 @@ index bbdd06002b07699fffebdf6ed8148abdb69c24cc..7379def14f3f700fb8a746dc89d89e24
}
diff --git a/net/minecraft/world/entity/animal/SnowGolem.java b/net/minecraft/world/entity/animal/SnowGolem.java
index 4f0d2ede28adbe412d208609a96eacc1309b8115..fdcc1534e59cf13ad354d56b1295cd60d1af0bc8 100644
index d97a297db3bec0c86c6a82ef1c353015df2115f7..6ee73b798ab306f7c828c9f06ca5b1a96bd96139 100644
--- a/net/minecraft/world/entity/animal/SnowGolem.java
+++ b/net/minecraft/world/entity/animal/SnowGolem.java
@@ -122,7 +122,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
@@ -136,7 +136,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
this.hurtServer(serverLevel, this.damageSources().melting(), 1.0F); // CraftBukkit - DamageSources.ON_FIRE -> CraftEventFactory.MELTING
}
@@ -144,10 +144,10 @@ index ca900bb646e16c7b4342f23c3ffae786eab28145..724d259d4b793f2043e63dda9022bdfd
//flag1 = level.removeBlock(blockPos, false) || flag1;
flag1 = true;
diff --git a/net/minecraft/world/entity/boss/wither/WitherBoss.java b/net/minecraft/world/entity/boss/wither/WitherBoss.java
index f6221829d213f103ffed9acbf9c6bc954ab6d539..a9303429be73841480f81a8a6687787e5c169ddc 100644
index 409b54fd8b0b9f34f2524d63d49abce6845ec80a..837a4bdeed3fc3878667293444340d19f7aa0df4 100644
--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -478,7 +478,7 @@ public class WitherBoss extends Monster implements RangedAttackMob {
@@ -493,7 +493,7 @@ public class WitherBoss extends Monster implements RangedAttackMob {
if (this.destroyBlocksTick > 0) {
this.destroyBlocksTick--;

View File

@@ -174,10 +174,10 @@ index 3d94d5c9ecab0fe7332daf4cdac879385159eaa1..22a70c6af965114e272bb56cb217f975
protected void defineSynchedData(SynchedEntityData.Builder builder) {
super.defineSynchedData(builder);
diff --git a/net/minecraft/world/entity/animal/IronGolem.java b/net/minecraft/world/entity/animal/IronGolem.java
index 42780e8245b1746783084558cc2deab361b09d3b..469ebee33cc8bf8f4dcad2595c80ffad19edac18 100644
index 37a353cbb0e9b16e0fc92bd1bc8194cb4cd3c13a..23108729ce65ef8b7b215b82f29347513cfd4ebf 100644
--- a/net/minecraft/world/entity/animal/IronGolem.java
+++ b/net/minecraft/world/entity/animal/IronGolem.java
@@ -86,6 +86,13 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
@@ -98,6 +98,13 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
}
// Purpur end - Configurable entity base attributes
@@ -372,10 +372,10 @@ index 882c799cb66a2acada33ff24f3adb7eb611f89c1..05d955ed33f1c3e0960657c584f4aa1b
protected void registerGoals() {
this.eatBlockGoal = new EatBlockGoal(this);
diff --git a/net/minecraft/world/entity/animal/SnowGolem.java b/net/minecraft/world/entity/animal/SnowGolem.java
index fdcc1534e59cf13ad354d56b1295cd60d1af0bc8..44729bc083a5f89fd2557a7ad42fc6f8e4cd6b92 100644
index 6ee73b798ab306f7c828c9f06ca5b1a96bd96139..dbf3e4db27477afada86e02063a486f7cec573b5 100644
--- a/net/minecraft/world/entity/animal/SnowGolem.java
+++ b/net/minecraft/world/entity/animal/SnowGolem.java
@@ -111,7 +111,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
@@ -125,7 +125,7 @@ public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackM
@Override
public boolean isSensitiveToWater() {
@@ -637,10 +637,10 @@ index 724d259d4b793f2043e63dda9022bdfddc4dca38..b2a0ba6faa117ad781aaa3e6932482d4
return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 200.0);
}
diff --git a/net/minecraft/world/entity/boss/wither/WitherBoss.java b/net/minecraft/world/entity/boss/wither/WitherBoss.java
index a9303429be73841480f81a8a6687787e5c169ddc..0bfb624fa2656ba416e02b645e92ec5814ea7156 100644
index 837a4bdeed3fc3878667293444340d19f7aa0df4..ce6d4163c34dfdefacc917beccdee0542376d55b 100644
--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -107,6 +107,13 @@ public class WitherBoss extends Monster implements RangedAttackMob {
@@ -219,6 +219,13 @@ public class WitherBoss extends Monster implements RangedAttackMob {
}
// Purpur end - Configurable entity base attributes

View File

@@ -1,13 +1,48 @@
--- a/net/minecraft/world/entity/animal/IronGolem.java
+++ b/net/minecraft/world/entity/animal/IronGolem.java
@@ -63,6 +_,7 @@
@@ -56,13 +_,26 @@
private int remainingPersistentAngerTime;
@Nullable
private UUID persistentAngerTarget;
+ @Nullable private UUID summoner; // Purpur - Summoner API
public IronGolem(EntityType<? extends IronGolem> entityType, Level level) {
super(entityType, level);
}
+ // Purpur start - Summoner API
+ @Nullable
+ public UUID getSummoner() {
+ return summoner;
+ }
+
+ public void setSummoner(@Nullable UUID summoner) {
+ this.summoner = summoner;
+ }
+ // Purpur end - Summoner API
+
@Override
protected void registerGoals() {
+ if (this.level().purpurConfig.ironGolemPoppyCalm) this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.ReceiveFlower(this)); // Purpur - Iron golem calm anger options
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0, true));
this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9, 32.0F));
this.goalSelector.addGoal(2, new MoveBackToVillageGoal(this, 0.6, false));
@@ -140,6 +_,7 @@
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putBoolean("PlayerCreated", this.isPlayerCreated());
+ if (getSummoner() != null) compound.putUUID("Purpur.Summoner", getSummoner()); // Purpur - Summoner API
this.addPersistentAngerSaveData(compound);
}
@@ -147,6 +_,7 @@
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
this.setPlayerCreated(compound.getBoolean("PlayerCreated"));
+ if (compound.contains("Purpur.Summoner")) setSummoner(compound.getUUID("Purpur.Summoner")); // Purpur - Summoner API
this.readPersistentAngerSaveData(this.level(), compound);
}
@@ -266,6 +_,7 @@
float f = 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F;
this.playSound(SoundEvents.IRON_GOLEM_REPAIR, 1.0F, f);

View File

@@ -1,7 +1,26 @@
--- a/net/minecraft/world/entity/animal/SnowGolem.java
+++ b/net/minecraft/world/entity/animal/SnowGolem.java
@@ -51,8 +_,8 @@
@@ -44,15 +_,27 @@
public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob {
private static final EntityDataAccessor<Byte> DATA_PUMPKIN_ID = SynchedEntityData.defineId(SnowGolem.class, EntityDataSerializers.BYTE);
private static final byte PUMPKIN_FLAG = 16;
+ @Nullable private java.util.UUID summoner; // Purpur - Summoner API
public SnowGolem(EntityType<? extends SnowGolem> entityType, Level level) {
super(entityType, level);
}
+ // Purpur start - Summoner API
+ @Nullable
+ public java.util.UUID getSummoner() {
+ return summoner;
+ }
+
+ public void setSummoner(@Nullable java.util.UUID summoner) {
+ this.summoner = summoner;
+ }
+ // Purpur end - Summoner API
+
@Override
protected void registerGoals() {
- this.goalSelector.addGoal(1, new RangedAttackGoal(this, 1.25, 20, 10.0F));
@@ -11,6 +30,22 @@
this.goalSelector.addGoal(3, new LookAtPlayerGoal(this, Player.class, 6.0F));
this.goalSelector.addGoal(4, new RandomLookAroundGoal(this));
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Mob.class, 10, true, false, (entity, level) -> entity instanceof Enemy));
@@ -72,6 +_,7 @@
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putBoolean("Pumpkin", this.hasPumpkin());
+ if (getSummoner() != null) compound.putUUID("Purpur.Summoner", getSummoner()); // Purpur - Summoner API
}
@Override
@@ -80,6 +_,7 @@
if (compound.contains("Pumpkin")) {
this.setPumpkin(compound.getBoolean("Pumpkin"));
}
+ if (compound.contains("Purpur.Summoner")) setSummoner(compound.getUUID("Purpur.Summoner")); // Purpur - Summoner API
}
@Override
@@ -153,6 +_,14 @@
}

View File

@@ -1,5 +1,47 @@
--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -77,6 +_,7 @@
private static final TargetingConditions.Selector LIVING_ENTITY_SELECTOR = (entity, level) -> !entity.getType().is(EntityTypeTags.WITHER_FRIENDS)
&& entity.attackable();
private static final TargetingConditions TARGETING_CONDITIONS = TargetingConditions.forCombat().range(20.0).selector(LIVING_ENTITY_SELECTOR);
+ @Nullable private java.util.UUID summoner; // Purpur - Summoner API
public WitherBoss(EntityType<? extends WitherBoss> entityType, Level level) {
super(entityType, level);
@@ -85,6 +_,17 @@
this.xpReward = 50;
}
+ // Purpur start - Summoner API
+ @Nullable
+ public java.util.UUID getSummoner() {
+ return summoner;
+ }
+
+ public void setSummoner(@Nullable java.util.UUID summoner) {
+ this.summoner = summoner;
+ }
+ // Purpur end - Summoner API
+
@Override
protected PathNavigation createNavigation(Level level) {
FlyingPathNavigation flyingPathNavigation = new FlyingPathNavigation(this, level);
@@ -117,6 +_,7 @@
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("Invul", this.getInvulnerableTicks());
+ if (getSummoner() != null) compound.putUUID("Purpur.Summoner", getSummoner()); // Purpur - Summoner API
}
@Override
@@ -126,6 +_,7 @@
if (this.hasCustomName()) {
this.bossEvent.setName(this.getDisplayName());
}
+ if (compound.contains("Purpur.Summoner")) setSummoner(compound.getUUID("Purpur.Summoner")); // Purpur - Summoner API
}
@Override
@@ -376,8 +_,10 @@
}
}

View File

@@ -0,0 +1,36 @@
--- a/net/minecraft/world/level/block/CarvedPumpkinBlock.java
+++ b/net/minecraft/world/level/block/CarvedPumpkinBlock.java
@@ -64,7 +_,7 @@
if (blockPatternMatch != null) {
SnowGolem snowGolem = EntityType.SNOW_GOLEM.create(level, EntitySpawnReason.TRIGGERED);
if (snowGolem != null) {
- spawnGolemInWorld(level, blockPatternMatch, snowGolem, blockPatternMatch.getBlock(0, 2, 0).getPos());
+ spawnGolemInWorld(level, blockPatternMatch, snowGolem, blockPatternMatch.getBlock(0, 2, 0).getPos(), this.placer); // Purpur - Summoner API
}
} else {
BlockPattern.BlockPatternMatch blockPatternMatch1 = this.getOrCreateIronGolemFull().find(level, pos);
@@ -72,13 +_,23 @@
IronGolem ironGolem = EntityType.IRON_GOLEM.create(level, EntitySpawnReason.TRIGGERED);
if (ironGolem != null) {
ironGolem.setPlayerCreated(true);
- spawnGolemInWorld(level, blockPatternMatch1, ironGolem, blockPatternMatch1.getBlock(1, 2, 0).getPos());
+ spawnGolemInWorld(level, blockPatternMatch1, ironGolem, blockPatternMatch1.getBlock(1, 2, 0).getPos(), this.placer); // Purpur - Summoner API
}
}
}
}
private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos) {
+ // Purpur start - Summoner API
+ spawnGolemInWorld(level, patternMatch, golem, pos, null);
+ }
+ private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos, net.minecraft.world.entity.LivingEntity placer) {
+ if (golem instanceof SnowGolem snowGolem) {
+ snowGolem.setSummoner(placer == null ? null : placer.getUUID());
+ } else if (golem instanceof IronGolem ironGolem) {
+ ironGolem.setSummoner(placer == null ? null : placer.getUUID());
+ }
+ // Purpur end - Summoner API
// clearPatternBlocks(level, patternMatch); // CraftBukkit - moved down
golem.moveTo(pos.getX() + 0.5, pos.getY() + 0.05, pos.getZ() + 0.5, 0.0F, 0.0F);
if (!level.addFreshEntity(golem, (golem.getType() == EntityType.SNOW_GOLEM) ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_SNOWMAN : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_IRONGOLEM)) {

View File

@@ -0,0 +1,10 @@
--- a/net/minecraft/world/level/block/WitherSkullBlock.java
+++ b/net/minecraft/world/level/block/WitherSkullBlock.java
@@ -71,6 +_,7 @@
);
witherBoss.yBodyRot = blockPatternMatch.getForwards().getAxis() == Direction.Axis.X ? 0.0F : 90.0F;
witherBoss.makeInvulnerable();
+ witherBoss.setSummoner(blockState.getBlock().placer == null ? null : blockState.getBlock().placer.getUUID()); // Purpur - Summoner API
// CraftBukkit start
if (!level.addFreshEntity(witherBoss, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_WITHER)) {
return;

View File

@@ -0,0 +1,20 @@
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java
@@ -27,4 +_,17 @@
public void setPlayerCreated(boolean playerCreated) {
this.getHandle().setPlayerCreated(playerCreated);
}
+
+ // Purpur start - Summoner API
+ @Override
+ @org.jetbrains.annotations.Nullable
+ public java.util.UUID getSummoner() {
+ return getHandle().getSummoner();
+ }
+
+ @Override
+ public void setSummoner(@org.jetbrains.annotations.Nullable java.util.UUID summoner) {
+ getHandle().setSummoner(summoner);
+ }
+ // Purpur end - Summoner API
}

View File

@@ -0,0 +1,20 @@
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
@@ -28,4 +_,17 @@
public String toString() {
return "CraftSnowman";
}
+
+ // Purpur start - Summoner API
+ @Override
+ @org.jetbrains.annotations.Nullable
+ public java.util.UUID getSummoner() {
+ return getHandle().getSummoner();
+ }
+
+ @Override
+ public void setSummoner(@org.jetbrains.annotations.Nullable java.util.UUID summoner) {
+ getHandle().setSummoner(summoner);
+ }
+ // Purpur end - Summoner API
}

View File

@@ -0,0 +1,20 @@
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
@@ -99,4 +_,17 @@
this.getHandle().makeInvulnerable();
}
// Paper end
+
+ // Purpur start - Summoner API
+ @Override
+ @org.jetbrains.annotations.Nullable
+ public java.util.UUID getSummoner() {
+ return getHandle().getSummoner();
+ }
+
+ @Override
+ public void setSummoner(@org.jetbrains.annotations.Nullable java.util.UUID summoner) {
+ getHandle().setSummoner(summoner);
+ }
+ // Purpur end - Summoner API
}