mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Add a "should burn in sunlight" API for Phantoms and Skeletons
This commit is contained in:
parent
b70d1e8bdc
commit
637bb9a05d
@ -1,6 +1,23 @@
|
||||
--- a/net/minecraft/world/entity/monster/AbstractSkeleton.java
|
||||
+++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java
|
||||
@@ -152,7 +152,7 @@
|
||||
@@ -97,9 +97,15 @@
|
||||
|
||||
abstract SoundEvent getStepSound();
|
||||
|
||||
+ // Paper start - shouldBurnInDay API
|
||||
+ private boolean shouldBurnInDay = true;
|
||||
+ public boolean shouldBurnInDay() { return shouldBurnInDay; }
|
||||
+ public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; }
|
||||
+ // Paper end - shouldBurnInDay API
|
||||
+
|
||||
@Override
|
||||
public void aiStep() {
|
||||
- boolean flag = this.isSunBurnTick();
|
||||
+ boolean flag = shouldBurnInDay && this.isSunBurnTick(); // Paper - shouldBurnInDay API
|
||||
|
||||
if (flag) {
|
||||
ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
|
||||
@@ -152,7 +158,7 @@
|
||||
this.populateDefaultEquipmentSlots(randomsource, difficulty);
|
||||
this.populateDefaultEquipmentEnchantments(world, randomsource, difficulty);
|
||||
this.reassessWeaponGoal();
|
||||
@ -9,7 +26,7 @@
|
||||
if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) {
|
||||
LocalDate localdate = LocalDate.now();
|
||||
int i = localdate.get(ChronoField.DAY_OF_MONTH);
|
||||
@@ -209,7 +209,17 @@
|
||||
@@ -209,7 +215,17 @@
|
||||
Level world = this.level();
|
||||
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
@ -28,3 +45,26 @@
|
||||
}
|
||||
|
||||
this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
@@ -233,9 +249,22 @@
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
this.reassessWeaponGoal();
|
||||
+ // Paper start - shouldBurnInDay API
|
||||
+ if (nbt.contains("Paper.ShouldBurnInDay")) {
|
||||
+ this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay");
|
||||
+ }
|
||||
+ // Paper end - shouldBurnInDay API
|
||||
}
|
||||
|
||||
+ // Paper start - shouldBurnInDay API
|
||||
@Override
|
||||
+ public void addAdditionalSaveData(CompoundTag nbt) {
|
||||
+ super.addAdditionalSaveData(nbt);
|
||||
+ nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
|
||||
+ }
|
||||
+ // Paper end - shouldBurnInDay API
|
||||
+
|
||||
+ @Override
|
||||
public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
|
||||
super.setItemSlot(slot, stack);
|
||||
if (!this.level().isClientSide) {
|
||||
|
@ -1,6 +1,15 @@
|
||||
--- a/net/minecraft/world/entity/monster/Phantom.java
|
||||
+++ b/net/minecraft/world/entity/monster/Phantom.java
|
||||
@@ -161,6 +161,11 @@
|
||||
@@ -139,7 +139,7 @@
|
||||
|
||||
@Override
|
||||
public void aiStep() {
|
||||
- if (this.isAlive() && this.isSunBurnTick()) {
|
||||
+ if (this.isAlive() && this.shouldBurnInDay && this.isSunBurnTick()) { // Paper - shouldBurnInDay API
|
||||
this.igniteForSeconds(8.0F);
|
||||
}
|
||||
|
||||
@@ -161,6 +161,14 @@
|
||||
}
|
||||
|
||||
this.setPhantomSize(nbt.getInt("Size"));
|
||||
@ -8,11 +17,14 @@
|
||||
+ if (nbt.hasUUID("Paper.SpawningEntity")) {
|
||||
+ this.spawningEntity = nbt.getUUID("Paper.SpawningEntity");
|
||||
+ }
|
||||
+ if (nbt.contains("Paper.ShouldBurnInDay")) {
|
||||
+ this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay");
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,6 +175,11 @@
|
||||
@@ -170,6 +178,12 @@
|
||||
nbt.putInt("AY", this.anchorPoint.getY());
|
||||
nbt.putInt("AZ", this.anchorPoint.getZ());
|
||||
nbt.putInt("Size", this.getPhantomSize());
|
||||
@ -20,16 +32,15 @@
|
||||
+ if (this.spawningEntity != null) {
|
||||
+ nbt.putUUID("Paper.SpawningEntity", this.spawningEntity);
|
||||
+ }
|
||||
+ nbt.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,7 +227,18 @@
|
||||
|
||||
boolean canAttack(ServerLevel world, LivingEntity target, TargetingConditions predicate) {
|
||||
@@ -219,6 +233,20 @@
|
||||
return predicate.test(world, this, target);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Nullable
|
||||
+ java.util.UUID spawningEntity;
|
||||
@ -37,13 +48,17 @@
|
||||
+ @Nullable
|
||||
+ public java.util.UUID getSpawningEntity() {
|
||||
+ return this.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
|
||||
|
||||
+
|
||||
private static enum AttackPhase {
|
||||
|
||||
@@ -522,14 +543,15 @@
|
||||
CIRCLE, SWOOP;
|
||||
@@ -522,14 +550,15 @@
|
||||
List<Player> list = worldserver.getNearbyPlayers(this.attackTargeting, Phantom.this, Phantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D));
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
|
@ -20,4 +20,15 @@ public abstract class CraftAbstractSkeleton extends CraftMonster implements Abst
|
||||
return (net.minecraft.world.entity.monster.AbstractSkeleton) super.getHandle();
|
||||
}
|
||||
// Paper end
|
||||
// Paper start
|
||||
@Override
|
||||
public boolean shouldBurnInDay() {
|
||||
return getHandle().shouldBurnInDay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShouldBurnInDay(boolean shouldBurnInDay) {
|
||||
getHandle().setShouldBurnInDay(shouldBurnInDay);
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
@ -34,5 +34,15 @@ public class CraftPhantom extends CraftFlying implements Phantom, CraftEnemy {
|
||||
public java.util.UUID getSpawningEntity() {
|
||||
return getHandle().getSpawningEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBurnInDay() {
|
||||
return getHandle().shouldBurnInDay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShouldBurnInDay(boolean shouldBurnInDay) {
|
||||
getHandle().setShouldBurnInDay(shouldBurnInDay);
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user