3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/unapplied/server/0613-Add-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patch

132 Zeilen
5.6 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MeFisto94 <MeFisto94@users.noreply.github.com>
Date: Tue, 11 May 2021 00:48:33 +0200
Subject: [PATCH] Add a "should burn in sunlight" API for Phantoms and
Skeletons
diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
2023-03-14 21:25:13 +01:00
index 98a3f6388712fab9012210241b84def3aca712e2..f2094c52196b45adfd51d8aebcc4c46b779b0925 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
2023-03-14 21:25:13 +01:00
@@ -98,9 +98,15 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
2021-06-11 14:02:28 +02:00
return MobType.UNDEAD;
}
+ // Paper start
+ private boolean shouldBurnInDay = true;
+ public boolean shouldBurnInDay() { return shouldBurnInDay; }
+ public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; }
+ // Paper end
+
@Override
public void aiStep() {
- boolean flag = this.isSunBurnTick();
+ boolean flag = shouldBurnInDay && this.isSunBurnTick(); // Paper - Configurable Burning
if (flag) {
ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
2023-03-23 22:57:03 +01:00
@@ -228,7 +234,20 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
2021-06-15 04:59:31 +02:00
public void readAdditionalSaveData(CompoundTag nbt) {
super.readAdditionalSaveData(nbt);
2021-06-11 14:02:28 +02:00
this.reassessWeaponGoal();
+ // Paper start
+ if (nbt.contains("Paper.ShouldBurnInDay")) {
+ this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay");
+ }
+ // Paper end
2023-03-23 22:57:03 +01:00
+ }
+
2021-06-11 14:02:28 +02:00
+ // Paper start
+ @Override
2021-06-15 04:59:31 +02:00
+ public void addAdditionalSaveData(CompoundTag nbt) {
+ super.addAdditionalSaveData(nbt);
+ nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
2023-03-23 22:57:03 +01:00
}
2021-06-11 14:02:28 +02:00
+ // Paper end
2023-03-23 22:57:03 +01:00
2021-06-11 14:02:28 +02:00
@Override
public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
2023-03-14 21:25:13 +01:00
index 0ada1ba6774e3d0514afb946fd0f104004cc020d..97fb1d2110a51498f6419841081b500b3f190370 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
2021-11-24 22:30:53 +01:00
@@ -144,7 +144,7 @@ public class Phantom extends FlyingMob implements Enemy {
2021-06-11 14:02:28 +02:00
@Override
public void aiStep() {
- if (this.isAlive() && this.isSunBurnTick()) {
+ if (this.isAlive() && shouldBurnInDay && this.isSunBurnTick()) { // Paper - Configurable Burning
this.setSecondsOnFire(8);
}
2021-11-24 22:30:53 +01:00
@@ -175,6 +175,9 @@ public class Phantom extends FlyingMob implements Enemy {
2021-06-15 04:59:31 +02:00
if (nbt.hasUUID("Paper.SpawningEntity")) {
this.spawningEntity = nbt.getUUID("Paper.SpawningEntity");
2021-06-11 14:02:28 +02:00
}
+ if (nbt.contains("Paper.ShouldBurnInDay")) {
+ this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay");
+ }
2021-06-11 14:02:28 +02:00
// Paper end
}
2021-11-24 22:30:53 +01:00
@@ -189,6 +192,7 @@ public class Phantom extends FlyingMob implements Enemy {
2021-06-11 14:02:28 +02:00
if (this.spawningEntity != null) {
2021-06-17 23:39:36 +02:00
nbt.putUUID("Paper.SpawningEntity", this.spawningEntity);
2021-06-11 14:02:28 +02:00
}
2021-06-15 04:59:31 +02:00
+ nbt.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay);
2021-06-11 14:02:28 +02:00
// Paper end
}
2023-03-14 21:25:13 +01:00
@@ -253,6 +257,10 @@ public class Phantom extends FlyingMob implements Enemy {
2021-06-11 14:02:28 +02:00
return spawningEntity;
}
public void setSpawningEntity(java.util.UUID entity) { this.spawningEntity = entity; }
+
+ private boolean shouldBurnInDay = true;
+ public boolean shouldBurnInDay() { return shouldBurnInDay; }
+ public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; }
// Paper end
2021-06-15 04:59:31 +02:00
private static enum AttackPhase {
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java
index 5ff566186431440c25a26900aba14e4adb642031..5beaa2bb0d58fe477ce8d2de8b77600d3b416d8c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java
@@ -20,4 +20,15 @@ public abstract class CraftAbstractSkeleton extends CraftMonster implements Abst
return (net.minecraft.world.entity.monster.AbstractSkeleton) super.getHandle();
2021-06-11 14:02:28 +02:00
}
// Paper end
+ // Paper start
2021-06-11 14:02:28 +02:00
+ @Override
+ public boolean shouldBurnInDay() {
+ return getHandle().shouldBurnInDay();
+ }
+
+ @Override
+ public void setShouldBurnInDay(boolean shouldBurnInDay) {
+ getHandle().setShouldBurnInDay(shouldBurnInDay);
+ }
+ // Paper end
2021-06-11 14:02:28 +02:00
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
index 1ebb83fe98f573d0a982397096d4dba7249aef4b..6b71f8b373ef524f5df16023b773e92249bb2532 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
@@ -40,5 +40,15 @@ public class CraftPhantom extends CraftFlying implements Phantom, CraftEnemy {
public java.util.UUID getSpawningEntity() {
return getHandle().getSpawningEntity();
2021-06-11 14:02:28 +02:00
}
+
+ @Override
+ public boolean shouldBurnInDay() {
+ return getHandle().shouldBurnInDay();
+ }
+
+ @Override
+ public void setShouldBurnInDay(boolean shouldBurnInDay) {
+ getHandle().setShouldBurnInDay(shouldBurnInDay);
+ }
// Paper end
2021-06-11 14:02:28 +02:00
}