mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 09:57:43 +01:00
add summoner api to copper golem
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
--- a/src/main/java/org/bukkit/entity/CopperGolem.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/CopperGolem.java
|
||||||
|
@@ -3,4 +_,19 @@
|
||||||
|
import io.papermc.paper.entity.Shearable;
|
||||||
|
|
||||||
|
public interface CopperGolem extends Golem, Shearable {
|
||||||
|
+ // Purpur start
|
||||||
|
+ /**
|
||||||
|
+ * Get the player that summoned this iron golem
|
||||||
|
+ *
|
||||||
|
+ * @return UUID of summoner
|
||||||
|
+ */
|
||||||
|
+ @org.jetbrains.annotations.Nullable java.util.UUID getSummoner();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Set the player that summoned this iron golem
|
||||||
|
+ *
|
||||||
|
+ * @param summoner UUID of summoner
|
||||||
|
+ */
|
||||||
|
+ void setSummoner(@org.jetbrains.annotations.Nullable java.util.UUID summoner);
|
||||||
|
+ // Purpur end
|
||||||
|
}
|
||||||
@@ -2127,10 +2127,10 @@ index 9ad94aca22a100dddaded5833763f9acd2a0ce56..96c98f032b1b3aec32aba38244ee8b45
|
|||||||
protected void addAdditionalSaveData(ValueOutput output) {
|
protected void addAdditionalSaveData(ValueOutput output) {
|
||||||
super.addAdditionalSaveData(output);
|
super.addAdditionalSaveData(output);
|
||||||
diff --git a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java
|
diff --git a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java
|
||||||
index facc49cb9a6aa7dddfbbf9733391fc9cf656f0ce..292c9a82028503566c8d3b50b87d09f79619aa7d 100644
|
index f9c3a33a7c5efc30a97f1ce74b94f5e6213298fe..82c2ff4ba05921a102d21e8fe547adb82fe9a445 100644
|
||||||
--- a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java
|
--- a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java
|
||||||
+++ b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java
|
+++ b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java
|
||||||
@@ -185,6 +185,7 @@ public class CopperGolem extends AbstractGolem implements ContainerUser, Shearab
|
@@ -199,6 +199,7 @@ public class CopperGolem extends AbstractGolem implements ContainerUser, Shearab
|
||||||
protected void customServerAiStep(ServerLevel level) {
|
protected void customServerAiStep(ServerLevel level) {
|
||||||
ProfilerFiller profilerFiller = Profiler.get();
|
ProfilerFiller profilerFiller = Profiler.get();
|
||||||
profilerFiller.push("copperGolemBrain");
|
profilerFiller.push("copperGolemBrain");
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
--- a/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/coppergolem/CopperGolem.java
|
||||||
|
@@ -84,6 +_,7 @@
|
||||||
|
private final AnimationState interactionDropItemAnimationState = new AnimationState();
|
||||||
|
private final AnimationState interactionDropNoItemAnimationState = new AnimationState();
|
||||||
|
public static final EquipmentSlot EQUIPMENT_SLOT_ANTENNA = EquipmentSlot.SADDLE;
|
||||||
|
+ @Nullable private UUID summoner; // Purpur - Summoner API
|
||||||
|
|
||||||
|
public CopperGolem(EntityType<? extends AbstractGolem> entityType, Level level) {
|
||||||
|
super(entityType, level);
|
||||||
|
@@ -97,6 +_,17 @@
|
||||||
|
this.getBrain().setMemory(MemoryModuleType.TRANSPORT_ITEMS_COOLDOWN_TICKS, this.getRandom().nextInt(60, 100));
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Purpur start - Summoner API
|
||||||
|
+ @Nullable
|
||||||
|
+ public UUID getSummoner() {
|
||||||
|
+ return summoner;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void setSummoner(@Nullable UUID summoner) {
|
||||||
|
+ this.summoner = summoner;
|
||||||
|
+ }
|
||||||
|
+ // Purpur end - Summoner API
|
||||||
|
+
|
||||||
|
public static AttributeSupplier.Builder createAttributes() {
|
||||||
|
return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0.2F).add(Attributes.STEP_HEIGHT, 1.0).add(Attributes.MAX_HEALTH, 12.0);
|
||||||
|
}
|
||||||
|
@@ -172,6 +_,7 @@
|
||||||
|
super.addAdditionalSaveData(output);
|
||||||
|
output.putLong("next_weather_age", this.nextWeatheringTick);
|
||||||
|
output.store("weather_state", WeatheringCopper.WeatherState.CODEC, this.getWeatherState());
|
||||||
|
+ output.storeNullable("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC, getSummoner()); // Purpur - Summoner API
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -179,6 +_,7 @@
|
||||||
|
super.readAdditionalSaveData(input);
|
||||||
|
this.nextWeatheringTick = input.getLongOr("next_weather_age", -1L);
|
||||||
|
this.setWeatherState(input.read("weather_state", WeatheringCopper.WeatherState.CODEC).orElse(WeatheringCopper.WeatherState.UNAFFECTED));
|
||||||
|
+ this.setSummoner(input.read("Purpur.Summoner", net.minecraft.core.UUIDUtil.CODEC).orElse(null)); // Purpur - Summoner API
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@@ -18,18 +18,31 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,6 +_,16 @@
|
@@ -93,7 +_,7 @@
|
||||||
|
if (blockPatternMatch2 != null) {
|
||||||
|
CopperGolem copperGolem = EntityType.COPPER_GOLEM.create(level, EntitySpawnReason.TRIGGERED);
|
||||||
|
if (copperGolem != null) {
|
||||||
|
- spawnGolemInWorld(level, blockPatternMatch2, copperGolem, blockPatternMatch2.getBlock(0, 0, 0).getPos());
|
||||||
|
+ spawnGolemInWorld(level, blockPatternMatch2, copperGolem, blockPatternMatch2.getBlock(0, 0, 0).getPos(), this.placer); // Purpur - Summoner API
|
||||||
|
this.replaceCopperBlockWithChest(level, blockPatternMatch2);
|
||||||
|
copperGolem.spawn(this.getWeatherStateFromPattern(blockPatternMatch2));
|
||||||
|
}
|
||||||
|
@@ -111,7 +_,20 @@
|
||||||
|
.getAge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ @io.papermc.paper.annotation.DoNotUse
|
||||||
private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos) {
|
private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos) {
|
||||||
+ // Purpur start - Summoner API
|
+ // Purpur start - Summoner API
|
||||||
+ spawnGolemInWorld(level, patternMatch, golem, pos, null);
|
+ 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) {
|
+ private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos, net.minecraft.world.entity.LivingEntity placer) {
|
||||||
+ if (golem instanceof SnowGolem snowGolem) {
|
+ java.util.UUID summoner = placer == null ? null : placer.getUUID();
|
||||||
+ snowGolem.setSummoner(placer == null ? null : placer.getUUID());
|
+ switch (golem) {
|
||||||
+ } else if (golem instanceof IronGolem ironGolem) {
|
+ case SnowGolem snowGolem -> snowGolem.setSummoner(summoner);
|
||||||
+ ironGolem.setSummoner(placer == null ? null : placer.getUUID());
|
+ case IronGolem ironGolem -> ironGolem.setSummoner(summoner);
|
||||||
|
+ case CopperGolem copperGolem -> copperGolem.setSummoner(summoner);
|
||||||
|
+ default -> throw new IllegalStateException("Unexpected value: " + golem);
|
||||||
+ }
|
+ }
|
||||||
+ // Purpur end - Summoner API
|
+ // Purpur end - Summoner API
|
||||||
// clearPatternBlocks(level, patternMatch); // Paper - moved down
|
// clearPatternBlocks(level, patternMatch); // Paper - moved down
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCopperGolem.java
|
||||||
|
@@ -13,4 +_,17 @@
|
||||||
|
public net.minecraft.world.entity.animal.coppergolem.CopperGolem getHandle() {
|
||||||
|
return (net.minecraft.world.entity.animal.coppergolem.CopperGolem) this.entity;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user