Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bukkit.entity;

import net.kyori.adventure.util.TriState;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -33,14 +34,15 @@ public interface AbstractSkeleton extends Monster, com.destroystokyo.paper.entit
@Contract("_ -> fail")
public void setSkeletonType(Skeleton.SkeletonType type);

// Paper start
/**
* Check if this skeleton will burn in the sunlight. This
* does not take into account an entity's natural fire
* immunity.
*
* @return True if skeleton will burn in sunlight
* @deprecated All mobs can now be changed to burn in daylight, use {@link Mob#burnsInDaylight()} instead.
*/
@Deprecated(since = "1.21.11")
boolean shouldBurnInDay();

/**
Expand All @@ -49,7 +51,8 @@ public interface AbstractSkeleton extends Monster, com.destroystokyo.paper.entit
* immunity.
*
* @param shouldBurnInDay True to burn in sunlight
* @deprecated All mobs can now be changed to burn in daylight, use {@link Mob#setBurnInDaylightOverride(TriState)} instead.
*/
@Deprecated(since = "1.21.11")
void setShouldBurnInDay(boolean shouldBurnInDay);
// Paper end
}
20 changes: 20 additions & 0 deletions paper-api/src/main/java/org/bukkit/entity/Mob.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,24 @@ default void setLootTable(final @Nullable LootTable table, final long seed) {
* @return the amount of experience the mob will possibly drop
*/
int getPossibleExperienceReward();

/**
* {@return whether this mob will burn when exposed to daylight, accounting for environment attributes, but not for fire immunity or sun protection items}
* @see #isInDaylight()
*/
boolean burnsInDaylight();

/**
* Sets whether this mob will burn in daylight, a value of {@link TriState#NOT_SET} makes default behavior apply.
*
* @param state a {@link TriState} representing the state of the override
*/
void setBurnInDaylightOverride(TriState state);

/**
* Gets whether this mob will burn in daylight, a value of {@link TriState#NOT_SET} means default behavior apply.
*
* @return a {@link TriState} representing the state of the override
*/
TriState getBurnInDaylightOverride();
}
9 changes: 7 additions & 2 deletions paper-api/src/main/java/org/bukkit/entity/Phantom.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bukkit.entity;

import net.kyori.adventure.util.TriState;
import org.bukkit.Location;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
Expand Down Expand Up @@ -31,15 +32,19 @@ public interface Phantom extends Flying, Enemy {
* Check if this phantom will burn in the sunlight
*
* @return True if phantom will burn in sunlight
* @deprecated All mobs can now be changed to burn in daylight, use {@link Mob#burnsInDaylight()} instead.
*/
public boolean shouldBurnInDay();
@Deprecated(since = "1.21.11")
boolean shouldBurnInDay();

/**
* Set if this phantom should burn in the sunlight
*
* @param shouldBurnInDay True to burn in sunlight
* @deprecated All mobs can now be changed to burn in daylight, use {@link Mob#setBurnInDaylightOverride(TriState)} instead.
*/
public void setShouldBurnInDay(boolean shouldBurnInDay);
@Deprecated(since = "1.21.11")
void setShouldBurnInDay(boolean shouldBurnInDay);

/**
* Gets the location that this phantom circles around when not attacking a player
Expand Down
5 changes: 5 additions & 0 deletions paper-api/src/main/java/org/bukkit/entity/Zombie.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.bukkit.entity;

import net.kyori.adventure.util.TriState;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -153,14 +154,18 @@ public interface Zombie extends Monster, Ageable {
* Check if this zombie will burn in the sunlight
*
* @return True if zombie will burn in sunlight
* @deprecated All mobs can now be changed to burn in daylight, use {@link Mob#burnsInDaylight()} instead.
*/
@Deprecated(since = "1.21.11")
boolean shouldBurnInDay();

/**
* Set if this zombie should burn in the sunlight
*
* @param shouldBurnInDay True to burn in sunlight
* @deprecated All mobs can now be changed to burn in daylight, use {@link Mob#setBurnInDaylightOverride(TriState)} instead.
*/
@Deprecated(since = "1.21.11")
void setShouldBurnInDay(boolean shouldBurnInDay);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ index 5461bd9a39bb20ad29d3bc110c38860cf35a770a..75f80787966cdda6f51f55a8f6cb2218
public void tick() {
super.tick();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 57cff20212f6d5f83d4b0169bf6aa185a403e1d3..1b554121a550f0a2c7e5d6b041450b4bcba781c5 100644
index 34ef15867759ebc7296256a6d5ec286eb3a5f895..d3d97b0b6ff6312f1deb0bb8b1beef8b3578bc53 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -368,6 +368,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
Expand Down Expand Up @@ -542,10 +542,10 @@ index 5b6020de0848458f5576113e690b5a6435f35d05..6f49b5e5888a6296b929e465a5ef87dc
public void tick() {
super.tick();
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
index 43c3d5a7cb4303d4f4a0de9209ebe4e6c22e1a65..a6ed274cb0cf86a1ca93588f946ed52a58354546 100644
index 230af192db5e7b81756fd30d63c99be23715cc7a..c24dcd5537d0ca0e706c1794c66a0936912884a7 100644
--- a/net/minecraft/world/entity/Mob.java
+++ b/net/minecraft/world/entity/Mob.java
@@ -217,6 +217,19 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@@ -218,6 +218,19 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
return this.lookControl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
public GoalSelector targetSelector;
private @Nullable LivingEntity target;
private final Sensing sensing;
@@ -139,6 +_,8 @@
@@ -139,6 +_,9 @@
private Leashable.@Nullable LeashData leashData;
private BlockPos homePosition = BlockPos.ZERO;
private int homeRadius = -1;
+ public boolean aware = true; // CraftBukkit
+ public net.kyori.adventure.util.TriState despawnInPeacefulOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - allow changing despawnInPeaceful
+ public net.kyori.adventure.util.TriState burnInDaylightOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - burnInDaylight API

protected Mob(EntityType<? extends Mob> type, Level level) {
super(type, level);
Expand Down Expand Up @@ -85,7 +86,7 @@
}

@Override
@@ -371,13 +_,27 @@
@@ -371,13 +_,32 @@
if (this.isNoAi()) {
output.putBoolean("NoAI", this.isNoAi());
}
Expand All @@ -95,6 +96,11 @@
+ output.putString("Paper.DespawnInPeacefulOverride", this.despawnInPeacefulOverride.name());
+ }
+ // Paper end - allow changing despawnInPeaceful
+ // Paper start - burnInDaylight API
+ if (this.burnInDaylightOverride != net.kyori.adventure.util.TriState.NOT_SET) {
+ output.putString("Paper.BurnInDaylightOverride", this.burnInDaylightOverride.name());
+ }
+ // Paper end - burnInDaylight API
}

@Override
Expand All @@ -115,11 +121,12 @@
this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT);
this.readLeashData(input);
this.homeRadius = input.getIntOr("home_radius", -1);
@@ -389,6 +_,13 @@
@@ -389,6 +_,14 @@
this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC);
this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L);
this.setNoAi(input.getBooleanOr("NoAI", false));
+ this.aware = input.getBooleanOr("Bukkit.Aware", true); // CraftBukkit
+ this.burnInDaylightOverride = input.read("Paper.BurnInDaylightOverride", io.papermc.paper.util.PaperCodecs.TRI_STATE_CODEC).orElse(net.kyori.adventure.util.TriState.NOT_SET); // Paper - burnInDaylight API
+ // Paper start - allow changing despawnInPeaceful
+ this.despawnInPeacefulOverride = readDespawnInPeacefulOverride(input);
+ }
Expand All @@ -129,6 +136,15 @@
}

@Override
@@ -437,7 +_,7 @@
@Override
public void aiStep() {
super.aiStep();
- if (this.getType().is(EntityTypeTags.BURN_IN_DAYLIGHT)) {
+ if (this.burnInDaylightOverride.toBooleanOrElse(this.getType().is(EntityTypeTags.BURN_IN_DAYLIGHT))) { // Paper - burnInDaylight API
this.burnUndead();
}

@@ -456,6 +_,11 @@
&& !itemEntity.getItem().isEmpty()
&& !itemEntity.hasPickUpDelay()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,27 @@
--- a/net/minecraft/world/entity/monster/Phantom.java
+++ b/net/minecraft/world/entity/monster/Phantom.java
@@ -49,6 +_,10 @@
@@ -49,6 +_,7 @@
Vec3 moveTargetPoint = Vec3.ZERO;
@Nullable public BlockPos anchorPoint;
Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE;
+ // Paper start
+ public java.util.@Nullable UUID spawningEntity;
+ public boolean shouldBurnInDay = true;
+ // Paper end
+ public java.util.@Nullable UUID spawningEntity; // Paper

public Phantom(EntityType<? extends Phantom> type, Level level) {
super(type, level);
@@ -136,6 +_,13 @@
}
}

+ // Paper start
+ @Override
+ public boolean isSunBurnTick() {
+ return this.shouldBurnInDay && super.isSunBurnTick();
+ }
+ // Paper end
+
@Override
protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) {
}
@@ -164,6 +_,10 @@
@@ -164,6 +_,8 @@
super.readAdditionalSaveData(input);
this.anchorPoint = input.read("anchor_pos", BlockPos.CODEC).orElse(null);
this.setPhantomSize(input.getIntOr("size", 0));
+ // Paper start
+ this.spawningEntity = input.read("Paper.SpawningEntity", net.minecraft.core.UUIDUtil.CODEC).orElse(null);
+ this.shouldBurnInDay = input.getBooleanOr("Paper.ShouldBurnInDay", true);
+ // Paper end
+ this.spawningEntity = input.read("Paper.SpawningEntity", net.minecraft.core.UUIDUtil.CODEC).orElse(null); // Paper
+ if (!input.getBooleanOr("Paper.ShouldBurnInDay", true)) super.burnInDaylightOverride = net.kyori.adventure.util.TriState.FALSE; // Paper - burnInDaylight API - read old value
}

@Override
@@ -171,6 +_,10 @@
@@ -171,6 +_,7 @@
super.addAdditionalSaveData(output);
output.storeNullable("anchor_pos", BlockPos.CODEC, this.anchorPoint);
output.putInt("size", this.getPhantomSize());
+ // Paper start
+ output.storeNullable("Paper.SpawningEntity", net.minecraft.core.UUIDUtil.CODEC, this.spawningEntity);
+ output.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
+ // Paper end
+ output.storeNullable("Paper.SpawningEntity", net.minecraft.core.UUIDUtil.CODEC, this.spawningEntity); // Paper
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
--- a/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java
+++ b/net/minecraft/world/entity/monster/skeleton/AbstractSkeleton.java
@@ -66,6 +_,7 @@
AbstractSkeleton.this.setAggressive(true);
}
};
+ private boolean shouldBurnInDay = true; // Paper - shouldBurnInDay API

protected AbstractSkeleton(EntityType<? extends AbstractSkeleton> type, Level level) {
super(type, level);
@@ -90,6 +_,21 @@
return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.25);
}

+ // Paper start - shouldBurnInDay API
+ public boolean shouldBurnInDay() {
+ return this.shouldBurnInDay;
+ }
+
+ public void setShouldBurnInDay(boolean shouldBurnInDay) {
+ this.shouldBurnInDay = shouldBurnInDay;
+ }
+
+ @Override
+ public boolean isSunBurnTick() {
+ return this.shouldBurnInDay && super.isSunBurnTick();
+ }
+ // Paper end - shouldBurnInDay API
+
@Override
protected void playStepSound(BlockPos pos, BlockState block) {
this.playSound(this.getStepSound(), 0.15F, 1.0F);
@@ -120,7 +_,7 @@
this.populateDefaultEquipmentSlots(random, difficulty);
this.populateDefaultEquipmentEnchantments(level, random, difficulty);
Expand Down Expand Up @@ -72,28 +42,17 @@
}

this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
@@ -192,11 +_,22 @@
@@ -192,11 +_,14 @@
protected void readAdditionalSaveData(ValueInput input) {
super.readAdditionalSaveData(input);
this.reassessWeaponGoal();
- }
-
- @Override
+ if (!input.getBooleanOr("Paper.ShouldBurnInDay", true)) super.burnInDaylightOverride = net.kyori.adventure.util.TriState.FALSE; // Paper - burnInDaylight API - read old value
}

@Override
- public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) {
- super.onEquipItem(slot, oldItem, newItem);
+ this.shouldBurnInDay = input.getBooleanOr("Paper.ShouldBurnInDay", true); // Paper - shouldBurnInDay API
+ }
+
+ // Paper start - shouldBurnInDay API
+ @Override
+ protected void addAdditionalSaveData(final net.minecraft.world.level.storage.ValueOutput output) {
+ super.addAdditionalSaveData(output);
+ output.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
+ }
+ // Paper end - shouldBurnInDay API
+
+ // Paper start - silent equipping
+ @Override
+ public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem, boolean silent) {
+ super.onEquipItem(slot, oldItem, newItem, silent);
+ // Paper end - silent equipping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
private static final Identifier REINFORCEMENT_CALLER_CHARGE_ID = Identifier.withDefaultNamespace("reinforcement_caller_charge");
private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier(
Identifier.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE
@@ -90,13 +_,15 @@
@@ -90,13 +_,14 @@
private static final boolean DEFAULT_BABY = false;
private static final boolean DEFAULT_CAN_BREAK_DOORS = false;
private static final int DEFAULT_IN_WATER_TIME = 0;
Expand All @@ -20,7 +20,6 @@
private boolean canBreakDoors = false;
private int inWaterTime = 0;
public int conversionTime;
+ private boolean shouldBurnInDay = true; // Paper - Add more Zombie API

public Zombie(EntityType<? extends Zombie> type, Level level) {
super(type, level);
Expand Down Expand Up @@ -90,7 +89,7 @@
public void startUnderWaterConversion(int conversionTime) {
this.conversionTime = conversionTime;
this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true);
@@ -240,31 +_,50 @@
@@ -240,26 +_,39 @@
}

protected void convertToZombieType(ServerLevel level, EntityType<? extends Zombie> entityType) {
Expand Down Expand Up @@ -137,19 +136,6 @@
}

public boolean isSunSensitive() {
- return true;
- }
+ return this.shouldBurnInDay; // Paper - Add more Zombie API
+ }
+
+ // Paper start - Add more Zombie API
+ public void setShouldBurnInDay(boolean shouldBurnInDay) {
+ this.shouldBurnInDay = shouldBurnInDay;
+ }
+ // Paper end - Add more Zombie API

@Override
public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) {
@@ -297,13 +_,13 @@
if (SpawnPlacements.isSpawnPositionOk(type, level, blockPos)
&& SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, blockPos, level.random)) {
Expand Down Expand Up @@ -181,19 +167,11 @@
}
}

@@ -390,6 +_,7 @@
output.putBoolean("CanBreakDoors", this.canBreakDoors());
output.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1);
output.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1);
+ output.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); // Paper - Add more Zombie API
}

@Override
@@ -404,13 +_,15 @@
} else {
this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false);
}
+ this.shouldBurnInDay = input.getBooleanOr("Paper.ShouldBurnInDay", true); // Paper - Add more Zombie API
+ if (!input.getBooleanOr("Paper.ShouldBurnInDay", true)) super.burnInDaylightOverride = net.kyori.adventure.util.TriState.FALSE; // Paper - burnInDaylight API - read old value
}

@Override
Expand Down
Loading
Loading