readd beacon effect cause

This commit is contained in:
Lulu13022002
2024-12-18 19:09:46 +01:00
parent dedc6b3394
commit 6126012369
102 changed files with 443 additions and 488 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -136,6 +_,114 @@
@@ -136,6 +_,108 @@
import org.slf4j.Logger;
public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder {
@@ -105,12 +105,6 @@
+ return this.bukkitEntity;
+ }
+ // Paper end
+
+ // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ public int getDefaultMaxAirSupply() {
+ return Entity.TOTAL_AIR_SUPPLY;
+ }
+ // CraftBukkit end
+
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id";
@@ -205,6 +199,19 @@
}
public boolean isColliding(BlockPos pos, BlockState state) {
@@ -284,6 +_,12 @@
return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215;
}
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ public int getDefaultMaxAirSupply() {
+ return Entity.TOTAL_AIR_SUPPLY;
+ }
+ // CraftBukkit end
+
public boolean isSpectator() {
return false;
}
@@ -324,7 +_,7 @@
}

View File

@@ -44,7 +44,7 @@
if (!(this.level() instanceof ServerLevel)) {
this.level().setSkyFlashTime(2);
- } else if (!this.visualOnly) {
+ } else if (!this.visualOnly && !this.isEffect) { // Paper - Properly handle lightning effects api
+ } else if (!this.visualOnly && !this.isEffect) { // Paper - Properly handle lightning effects api
List<Entity> entities = this.level()
.getEntities(
this,

View File

@@ -66,7 +66,7 @@
- this.setHealth(this.getMaxHealth());
+ this.craftAttributes = new CraftAttributeMap(this.attributes); // CraftBukkit
+ // CraftBukkit - this.setHealth(this.getMaxHealth()) inlined and simplified to skip the instanceof check for Player, as getBukkitEntity() is not initialized in constructor
+ this.entityData.set(LivingEntity.DATA_HEALTH_ID, (float) this.getAttribute(Attributes.MAX_HEALTH).getValue());
+ this.entityData.set(LivingEntity.DATA_HEALTH_ID, this.getMaxHealth());
this.blocksBuilding = true;
this.rotA = (float)((Math.random() + 1.0) * 0.01F);
this.reapplyPosition();

View File

@@ -4,7 +4,7 @@
public FloatGoal(Mob mob) {
this.mob = mob;
+ if (mob.getCommandSenderWorld().paperConfig().entities.behavior.spawnerNerfedMobsShouldJump) mob.goalFloat = this; // Paper - Allow nerfed mobs to jump and float
+ if (mob.level().paperConfig().entities.behavior.spawnerNerfedMobsShouldJump) mob.goalFloat = this; // Paper - Allow nerfed mobs to jump and float
this.setFlags(EnumSet.of(Goal.Flag.JUMP));
mob.getNavigation().setCanFloat(true);
}

View File

@@ -50,7 +50,7 @@
+ // Paper start - EntityPathfindEvent
+ boolean copiedSet = false;
+ for (BlockPos possibleTarget : targets) {
+ if (!this.mob.getCommandSenderWorld().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border
+ if (!this.mob.level().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border
+ io.papermc.paper.util.MCUtil.toLocation(this.mob.level(), possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
+ if (!copiedSet) {
+ copiedSet = true;

View File

@@ -4,7 +4,7 @@
}
public void stopFollowing() {
+ if (this.leader == null) return; // Avoid NPE, plugins can now set the leader and certain fish goals might cause this method to be called
+ if (this.leader == null) return; // Paper - Avoid NPE, plugins can now set the leader and certain fish goals might cause this method to be called
this.leader.removeFollower();
this.leader = null;
}

View File

@@ -14,8 +14,8 @@
@Override
- protected void actuallyHurt(ServerLevel level, DamageSource damageSource, float amount) {
+ // CraftBukkit start - void -> boolean
+ public boolean actuallyHurt(ServerLevel worldserver, DamageSource damagesource, float f, org.bukkit.event.entity.EntityDamageEvent event) {
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
+ public boolean actuallyHurt(ServerLevel level, DamageSource damageSource, float amount, org.bukkit.event.entity.EntityDamageEvent event) {
+ boolean damageResult = super.actuallyHurt(level, damageSource, amount, event);
+ if (!damageResult) return false;
this.resetLove();
- super.actuallyHurt(level, damageSource, amount);

View File

@@ -1,6 +1,10 @@
--- a/net/minecraft/world/entity/animal/Bee.java
+++ b/net/minecraft/world/entity/animal/Bee.java
@@ -144,7 +_,22 @@
@@ -141,10 +_,26 @@
Bee.BeeGoToHiveGoal goToHiveGoal;
private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal;
private int underWaterTicks;
+ public net.kyori.adventure.util.TriState rollingOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Rolling override
public Bee(EntityType<? extends Bee> entityType, Level level) {
super(entityType, level);
@@ -65,24 +69,18 @@
- return this.isTooFarAway(this.hivePos) ? null : this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
+ // Paper start - move over logic to accommodate isTooFarAway with chunk load check
+ if (this.hivePos != null && !this.isTooFarAway(this.hivePos) && this.level().getChunkIfLoadedImmediately(this.hivePos.getX() >> 4, this.hivePos.getZ() >> 4) != null) {
+ return (BeehiveBlockEntity) this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
+ return this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null);
}
+ return null;
+ // Paper end
}
boolean isHiveValid() {
@@ -520,11 +_,13 @@
this.setFlag(4, hasStung);
}
+ public net.kyori.adventure.util.TriState rollingOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Rolling override
public boolean isRolling() {
return this.getFlag(2);
@@ -525,6 +_,7 @@
}
public void setRolling(boolean isRolling) {
+ isRolling = rollingOverride.toBooleanOrElse(isRolling); // Paper - Rolling override
+ isRolling = this.rollingOverride.toBooleanOrElse(isRolling); // Paper - Rolling override
this.setFlag(2, isRolling);
}

View File

@@ -1,18 +1,19 @@
--- a/net/minecraft/world/entity/animal/Dolphin.java
+++ b/net/minecraft/world/entity/animal/Dolphin.java
@@ -63,6 +_,12 @@
import net.minecraft.world.phys.Vec3;
@@ -96,6 +_,13 @@
return EntityType.DOLPHIN.create(level, EntitySpawnReason.BREEDING);
}
public class Dolphin extends AgeableWaterCreature {
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ @Override
+ public int getDefaultMaxAirSupply() {
+ return TOTAL_AIR_SUPPLY;
+ }
+ // CraftBukkit end
private static final EntityDataAccessor<BlockPos> TREASURE_POS = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BLOCK_POS);
private static final EntityDataAccessor<Boolean> GOT_FISH = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BOOLEAN);
private static final EntityDataAccessor<Integer> MOISTNESS_LEVEL = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.INT);
+
@Override
public float getAgeScale() {
return this.isBaby() ? 0.65F : 1.0F;
@@ -196,7 +_,7 @@
@Override

View File

@@ -22,9 +22,9 @@
}
@Override
@@ -620,4 +_,11 @@
return Util.getRandom(variants, random);
}
@@ -521,6 +_,13 @@
) {
return level.getBlockState(pos.below()).is(BlockTags.AXOLOTLS_SPAWNABLE_ON);
}
+
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
@@ -33,4 +33,6 @@
+ return Axolotl.AXOLOTL_TOTAL_AIR_SUPPLY;
+ }
+ // CraftBukkit end
}
public static enum AnimationState {
PLAYING_DEAD,

View File

@@ -34,10 +34,11 @@
}
}
@@ -381,4 +_,14 @@
@@ -381,4 +_,15 @@
) {
return level.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos);
}
+
+ // Paper start - Goat ram API
+ public void ram(net.minecraft.world.entity.LivingEntity entity) {
+ Brain<Goat> brain = this.getBrain();

View File

@@ -1,12 +1,13 @@
--- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
+++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
@@ -69,9 +_,16 @@
@@ -69,9 +_,17 @@
super.dropEquipment(level);
if (this.hasChest()) {
this.spawnAtLocation(level, Blocks.CHEST);
+ //this.setChest(false); // Paper - moved to post death logic
+ }
+ }
+
+ // Paper start
+ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {
+ if (this.hasChest() && (event == null || !event.isCancelled())) {

View File

@@ -24,7 +24,7 @@
}
+
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ public final List<HumanEntity> transaction = new java.util.ArrayList<>();
+ private int maxStack = MAX_STACK;
+
+ @Override
@@ -132,7 +132,7 @@
}
if (this.canEatGrass()) {
@@ -690,6 +_,15 @@
@@ -690,6 +_,16 @@
}
}
@@ -140,6 +140,7 @@
+ public void setMouthOpen(boolean open) {
+ this.setFlag(FLAG_OPEN_MOUTH, open);
+ }
+
+ public boolean isMouthOpen() {
+ return this.getFlag(FLAG_OPEN_MOUTH);
+ }
@@ -148,7 +149,7 @@
@Override
public InteractionResult mobInteract(Player player, InteractionHand hand) {
if (this.isVehicle() || this.isBaby()) {
@@ -727,6 +_,11 @@
@@ -727,6 +_,12 @@
this.setFlag(16, eating);
}
@@ -157,6 +158,7 @@
+ this.setFlag(FLAG_STANDING, standing);
+ }
+ // Paper end - Horse API
+
public void setStanding(boolean standing) {
if (standing) {
this.setEating(false);

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
@@ -266,6 +_,13 @@
BlockPos headBlock = this.getHeadBlock();
@@ -267,6 +_,13 @@
this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.SNIFFER_DIGGING, (serverLevel1, itemStack) -> {
ItemEntity itemEntity = new ItemEntity(this.level(), headBlock.getX(), headBlock.getY(), headBlock.getZ(), itemStack);
itemEntity.setDefaultPickUpDelay();
+ // CraftBukkit start - handle EntityDropItemEvent
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity());
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
@@ -11,9 +11,9 @@
+ return;
+ }
+ // CraftBukkit end
itemEntity.setDefaultPickUpDelay();
serverLevel1.addFreshEntity(itemEntity);
});
this.playSound(SoundEvents.SNIFFER_DROP_SEED, 1.0F, 1.0F);
@@ -325,12 +_,17 @@
@Override

View File

@@ -48,16 +48,14 @@
double d = flyTargetLocation.x - this.getX();
double d1 = flyTargetLocation.y - this.getY();
double d2 = flyTargetLocation.z - this.getZ();
@@ -369,7 +_,14 @@
@@ -369,7 +_,12 @@
if (this.nearestCrystal.isRemoved()) {
this.nearestCrystal = null;
} else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
- this.setHealth(this.getHealth() + 1.0F);
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityRegainHealthEvent event = new org.bukkit.event.entity.EntityRegainHealthEvent(this.getBukkitEntity(), 1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ if (event.callEvent()) {
+ this.setHealth((float) (this.getHealth() + event.getAmount()));
+ }
+ // CraftBukkit end
@@ -94,7 +92,7 @@
} else {
flag = true;
}
@@ -450,6 +_,54 @@
@@ -450,6 +_,58 @@
}
}
@@ -116,32 +114,36 @@
+ }
+ } else {
+ for (org.bukkit.block.Block block : event.blockList()) {
+ org.bukkit.Material blockId = block.getType();
+ if (blockId.isAir()) {
+ org.bukkit.Material blockType = block.getType();
+ if (blockType.isAir()) {
+ continue;
+ }
+
+ org.bukkit.craftbukkit.block.CraftBlock craftBlock = ((org.bukkit.craftbukkit.block.CraftBlock) block);
+ BlockPos blockposition = craftBlock.getPosition();
+ BlockPos pos = craftBlock.getPosition();
+
+ net.minecraft.world.level.block.Block nmsBlock = craftBlock.getNMS().getBlock();
+ if (nmsBlock.dropFromExplosion(this.explosionSource)) {
+ net.minecraft.world.level.block.entity.BlockEntity tileentity = craftBlock.getNMS().hasBlockEntity() ? this.level().getBlockEntity(blockposition) : null;
+ net.minecraft.world.level.storage.loot.LootParams.Builder loottableinfo_builder = (new net.minecraft.world.level.storage.loot.LootParams.Builder((ServerLevel) this.level())).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.ORIGIN, Vec3.atCenterOf(blockposition)).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.TOOL, net.minecraft.world.item.ItemStack.EMPTY).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.EXPLOSION_RADIUS, 1.0F / event.getYield()).withOptionalParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.BLOCK_ENTITY, tileentity);
+ net.minecraft.world.level.block.entity.BlockEntity blockEntity = craftBlock.getNMS().hasBlockEntity() ? this.level().getBlockEntity(pos) : null;
+ net.minecraft.world.level.storage.loot.LootParams.Builder builder = new net.minecraft.world.level.storage.loot.LootParams.Builder((ServerLevel) this.level())
+ .withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.ORIGIN, Vec3.atCenterOf(pos))
+ .withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.TOOL, net.minecraft.world.item.ItemStack.EMPTY)
+ .withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.EXPLOSION_RADIUS, 1.0F / event.getYield())
+ .withOptionalParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.BLOCK_ENTITY, blockEntity);
+
+ craftBlock.getNMS().getDrops(loottableinfo_builder).forEach((itemstack) -> {
+ net.minecraft.world.level.block.Block.popResource(this.level(), blockposition, itemstack);
+ craftBlock.getNMS().getDrops(builder).forEach((stack) -> {
+ net.minecraft.world.level.block.Block.popResource(this.level(), pos, stack);
+ });
+ craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level(), blockposition, net.minecraft.world.item.ItemStack.EMPTY, false);
+ craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level(), pos, net.minecraft.world.item.ItemStack.EMPTY, false);
+ }
+ // Paper start - TNTPrimeEvent
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level(), blockposition);
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level(), pos);
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getIndirectSourceEntity().getBukkitEntity()).callEvent())
+ continue;
+ // Paper end - TNTPrimeEvent
+ nmsBlock.wasExploded((ServerLevel) this.level(), blockposition, this.explosionSource);
+ nmsBlock.wasExploded((ServerLevel) this.level(), pos, this.explosionSource);
+
+ this.level().removeBlock(blockposition, false);
+ this.level().removeBlock(pos, false);
+ }
+ }
+ // CraftBukkit end

View File

@@ -6,7 +6,7 @@
DragonFireball dragonFireball = new DragonFireball(level, this.dragon, vec32.normalize());
+ dragonFireball.preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported
dragonFireball.moveTo(d2, d3, d4, 0.0F, 0.0F);
+ if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper - EnderDragon Events
+ if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper - EnderDragon Events
level.addFreshEntity(dragonFireball);
+ else dragonFireball.discard(null); // Paper - EnderDragon Events
this.fireballCharge = 0;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java
+++ b/net/minecraft/world/entity/boss/enderdragon/phases/EnderDragonPhaseManager.java
@@ -23,6 +_,19 @@
@@ -23,6 +_,18 @@
this.currentPhase.end();
}
@@ -10,8 +10,7 @@
+ (this.currentPhase == null) ? null : org.bukkit.craftbukkit.entity.CraftEnderDragon.getBukkitPhase(this.currentPhase.getPhase()),
+ org.bukkit.craftbukkit.entity.CraftEnderDragon.getBukkitPhase(phase)
+ );
+ this.dragon.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ if (!event.callEvent()) {
+ return;
+ }
+ phase = org.bukkit.craftbukkit.entity.CraftEnderDragon.getMinecraftPhase(event.getNewPhase());

View File

@@ -1,18 +1,13 @@
--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java
+++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java
@@ -77,6 +_,12 @@
&& entity.attackable();
private static final TargetingConditions TARGETING_CONDITIONS = TargetingConditions.forCombat().range(20.0).selector(LIVING_ENTITY_SELECTOR);
+ // Paper start
+ private boolean canPortal = false;
+
+ public void setCanTravelThroughPortals(boolean canPortal) { this.canPortal = canPortal; }
+ // Paper end
+
public WitherBoss(EntityType<? extends WitherBoss> entityType, Level level) {
super(entityType, level);
this.moveControl = new FlyingMoveControl(this, 10, false);
@@ -69,6 +_,7 @@
private final int[] nextHeadUpdate = new int[2];
private final int[] idleHeadUpdates = new int[2];
private int destroyBlocksTick;
+ private boolean canPortal = false; // Paper
public final ServerBossEvent bossEvent = (ServerBossEvent)new ServerBossEvent(
this.getDisplayName(), BossEvent.BossBarColor.PURPLE, BossEvent.BossBarOverlay.PROGRESS
)
@@ -260,15 +_,40 @@
int i = this.getInvulnerableTicks() - 1;
this.bossEvent.setProgress(1.0F - i / 220.0F);
@@ -106,13 +101,20 @@
} else {
this.noActionTime = 0;
}
@@ -547,12 +_,12 @@
@@ -547,12 +_,18 @@
@Override
public boolean canUsePortal(boolean allowPassengers) {
- return false;
- }
+ return this.canPortal; // Paper
}
+ }
+
+ // Paper start
+ public void setCanTravelThroughPortals(boolean canPortal) {
+ this.canPortal = canPortal;
+ }
+ // Paper end
@Override
public boolean canBeAffected(MobEffectInstance potioneffect) {

View File

@@ -155,7 +155,7 @@
+ // CraftBukkit end
+ // Paper start - avoid duplicate event call
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(level, damageSource);
+ if (!event.isCancelled()) this.kill(damageSource, false); // CraftBukkit
+ if (!event.isCancelled()) this.kill(level, damageSource, false); // CraftBukkit
+ // Paper end
return false;
} else if (damageSource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) {
@@ -204,7 +204,7 @@
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(level, damageSource); // Paper
this.showBreakingParticles();
- this.kill(level);
+ if (!event.isCancelled()) this.kill(damageSource, false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...)
+ if (!event.isCancelled()) this.kill(level, damageSource, false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...)
}
return true;
@@ -215,7 +215,7 @@
- this.kill(level);
+ // Paper start - avoid duplicate event call
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(level, damageSource);
+ if (!event.isCancelled()) this.kill(damageSource, false); // CraftBukkit
+ if (!event.isCancelled()) this.kill(level, damageSource, false); // CraftBukkit
+ // Paper end
} else {
this.setHealth(health);
@@ -289,7 +289,7 @@
Rotations rotations = this.entityData.get(DATA_HEAD_POSE);
if (!this.headPose.equals(rotations)) {
this.setHeadPose(rotations);
@@ -587,9 +_,31 @@
@@ -587,9 +_,32 @@
return this.isSmall();
}
@@ -309,9 +309,10 @@
+
+ public void kill(ServerLevel level, @Nullable DamageSource damageSource) {
+ // Paper start - make cancellable
+ this.kill(damageSource, true);
+ this.kill(level, damageSource, true);
+ }
+ public void kill(@Nullable DamageSource damageSource, boolean callEvent) {
+
+ public void kill(ServerLevel level, @Nullable DamageSource damageSource, boolean callEvent) {
+ if (callEvent) {
+ org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, (damageSource == null ? this.damageSources().genericKill() : damageSource), this.drops); // CraftBukkit - call event
+ if (event.isCancelled()) return;

View File

@@ -4,7 +4,7 @@
import net.minecraft.world.phys.Vec3;
import org.slf4j.Logger;
+// CraftBukkit start;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
@@ -20,28 +20,14 @@
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) {
super(entityType, level);
@@ -80,6 +_,10 @@
}
public static FallingBlockEntity fall(Level level, BlockPos pos, BlockState blockState) {
+ // CraftBukkit start
+ return FallingBlockEntity.fall(level, pos, blockState, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+ public static FallingBlockEntity fall(Level level, BlockPos pos, BlockState blockState, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) {
FallingBlockEntity fallingBlockEntity = new FallingBlockEntity(
level,
pos.getX() + 0.5,
@@ -89,8 +_,9 @@
@@ -89,6 +_,7 @@
? blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false))
: blockState
);
+ if (!CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit
level.setBlock(pos, blockState.getFluidState().createLegacyBlock(), 3);
- level.addFreshEntity(fallingBlockEntity);
+ level.addFreshEntity(fallingBlockEntity, creatureSpawnReason); // CraftBukkit
level.addFreshEntity(fallingBlockEntity);
return fallingBlockEntity;
}
@@ -139,13 +_,22 @@
@Override
public void tick() {
@@ -147,9 +133,9 @@
}
+
+ // Paper start - Expand FallingBlock API
+ if (compound.contains("Paper.AutoExpire")) {
+ if (compound.contains("Paper.AutoExpire")) {
+ this.autoExpire = compound.getBoolean("Paper.AutoExpire");
+ }
+ }
+ // Paper end - Expand FallingBlock API
}

View File

@@ -142,18 +142,18 @@
}
return true;
@@ -308,6 +_,11 @@
@Override
public void addAdditionalSaveData(CompoundTag compound) {
@@ -322,6 +_,11 @@
if (!this.getItem().isEmpty()) {
compound.put("Item", this.getItem().save(this.registryAccess()));
}
+ // Paper start - Friction API
+ if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) {
+ compound.putString("Paper.FrictionState", this.frictionState.toString());
+ }
+ // Paper end - Friction API
compound.putShort("Health", (short)this.health);
compound.putShort("Age", (short)this.age);
compound.putShort("PickupDelay", (short)this.pickupDelay);
}
@Override
@@ -347,9 +_,19 @@
} else {
this.setItem(ItemStack.EMPTY);
@@ -164,7 +164,7 @@
+ try {
+ frictionState = net.kyori.adventure.util.TriState.valueOf(fs);
+ } catch (Exception ignored) {
+ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state " + fs + " for " + this);
+ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state {} for {}", fs, this);
+ }
+ }
+ // Paper end - Friction API

View File

@@ -4,7 +4,7 @@
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.portal.TeleportTransition;
+// CraftBukkit start;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
@@ -95,7 +95,7 @@
+ if (event.isCancelled()) {
+ return;
+ }
+ // Craftbukkit end
+ // CraftBukkit end
this.level()
.explode(
this,
@@ -118,7 +118,7 @@
+ // Paper start - Option to prevent TNT from moving in water
+ @Override
+ public boolean isPushedByFluid() {
+ return !level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
+ return !this.level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
+ }
+ // Paper end - Option to prevent TNT from moving in water
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/Bogged.java
+++ b/net/minecraft/world/entity/monster/Bogged.java
@@ -72,7 +_,20 @@
@@ -72,7 +_,19 @@
ItemStack itemInHand = player.getItemInHand(hand);
if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) {
if (this.level() instanceof ServerLevel serverLevel) {
@@ -11,18 +11,17 @@
+ org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemInHand, hand, drops);
+ if (event != null) {
+ if (event.isCancelled()) {
+ // this.getEntityData().markDirty(Bogged.DATA_SHEARED); // CraftBukkit - mark dirty to restore sheared state to clients // Paper - no longer needed
+ return InteractionResult.PASS;
+ }
+ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops());
+ // Paper end - custom shear drops
+ // Paper end - custom shear drops
+ }
+ // CraftBukkit end
+ this.shear(serverLevel, SoundSource.PLAYERS, itemInHand, drops); // Paper - custom shear drops
this.gameEvent(GameEvent.SHEAR, player);
itemInHand.hurtAndBreak(1, player, getSlotForHand(hand));
}
@@ -125,15 +_,34 @@
@@ -125,15 +_,33 @@
@Override
public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) {
@@ -53,10 +52,9 @@
- level, BuiltInLootTables.BOGGED_SHEAR, stack, (serverLevel, itemStack) -> this.spawnAtLocation(serverLevel, itemStack, this.getBbHeight())
- );
+ // Paper start - custom shear drops
+ private void spawnShearedMushrooms(ServerLevel world, ItemStack shears, java.util.List<ItemStack> drops) {
+ final ServerLevel worldserver1 = world; // Named for lambda consumption
+ private void spawnShearedMushrooms(ServerLevel level, ItemStack stack, java.util.List<ItemStack> drops) {
+ this.forceDrops = true; // Paper - Add missing forceDrop toggles
+ drops.forEach(itemstack1 -> this.spawnAtLocation(world, shears, this.getBbHeight()));
+ drops.forEach(itemstack1 -> this.spawnAtLocation(level, stack, this.getBbHeight()));
+ this.forceDrops = false; // Paper - Add missing forceDrop toggles
+ // Paper end - custom shear drops
}

View File

@@ -13,7 +13,7 @@
if (compound.getBoolean("ignited")) {
- this.ignite();
+ this.entityData.set(Creeper.DATA_IS_IGNITED, true); // Paper - set directly to avoid firing event
+ this.entityData.set(DATA_IS_IGNITED, true); // Paper - set directly to avoid firing event
}
}
@@ -66,7 +66,7 @@
+ // CraftBukkit start
+ } else {
+ this.swell = 0;
+ this.entityData.set(DATA_IS_IGNITED, Boolean.valueOf(false)); // Paper
+ this.entityData.set(DATA_IS_IGNITED, false); // Paper
+ }
+ // CraftBukkit end
}
@@ -81,7 +81,7 @@
areaEffectCloud.setRadius(2.5F);
areaEffectCloud.setRadiusOnUse(-0.5F);
areaEffectCloud.setWaitTime(10);
@@ -254,16 +_,26 @@
@@ -254,16 +_,27 @@
areaEffectCloud.addEffect(new MobEffectInstance(mobEffectInstance));
}
@@ -91,12 +91,13 @@
+ this.level().addFreshEntity(areaEffectCloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
+ }
+ }
+
+ // Paper start - CreeperIgniteEvent
+ public void setIgnited(boolean ignited) {
+ if (isIgnited() != ignited) {
+ com.destroystokyo.paper.event.entity.CreeperIgniteEvent event = new com.destroystokyo.paper.event.entity.CreeperIgniteEvent((org.bukkit.entity.Creeper) getBukkitEntity(), ignited);
+ if (event.callEvent()) {
+ this.entityData.set(Creeper.DATA_IS_IGNITED, event.isIgnited());
+ this.entityData.set(DATA_IS_IGNITED, event.isIgnited());
+ }
+ }
+ }

View File

@@ -71,22 +71,23 @@
return flag1;
}
@@ -400,6 +_,15 @@
public void setBeingStaredAt() {
@@ -401,6 +_,16 @@
this.entityData.set(DATA_STARED_AT, true);
}
+ // Paper start
+ public void setCreepy(boolean creepy) {
+ this.entityData.set(EnderMan.DATA_CREEPY, creepy);
+ this.entityData.set(DATA_CREEPY, creepy);
+ }
+
+ public void setHasBeenStaredAt(boolean hasBeenStaredAt) {
+ this.entityData.set(EnderMan.DATA_STARED_AT, hasBeenStaredAt);
+ this.entityData.set(DATA_STARED_AT, hasBeenStaredAt);
+ }
+ // Paper end
+
@Override
public boolean requiresCustomPersistence() {
return super.requiresCustomPersistence() || this.getCarriedBlock() != null;
@@ -460,16 +_,19 @@
int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0);
int floor2 = Mth.floor(this.enderman.getZ() - 1.0 + random.nextDouble() * 2.0);

View File

@@ -17,7 +17,7 @@
}
LargeFireball largeFireball = new LargeFireball(level, this.ghast, vec3.normalize(), this.ghast.getExplosionPower());
+ largeFireball.bukkitYield = largeFireball.explosionPower = this.ghast.getExplosionPower(); // CraftBukkit - set bukkitYield when setting explosionpower
+ largeFireball.bukkitYield = largeFireball.explosionPower = this.ghast.getExplosionPower(); // CraftBukkit - set bukkitYield when setting explosionPower
largeFireball.setPos(this.ghast.getX() + viewVector.x * 4.0, this.ghast.getY(0.5) + 0.5, largeFireball.getZ() + viewVector.z * 4.0);
level.addFreshEntity(largeFireball);
this.chargeTime = -40;

View File

@@ -1,5 +1,17 @@
--- a/net/minecraft/world/entity/monster/Phantom.java
+++ b/net/minecraft/world/entity/monster/Phantom.java
@@ -47,6 +_,11 @@
Vec3 moveTargetPoint = Vec3.ZERO;
public BlockPos anchorPoint = BlockPos.ZERO;
Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE;
+ // Paper start
+ @Nullable
+ public java.util.UUID spawningEntity;
+ public boolean shouldBurnInDay = true;
+ // Paper end
public Phantom(EntityType<? extends Phantom> entityType, Level level) {
super(entityType, level);
@@ -141,7 +_,7 @@
@Override
@@ -9,10 +21,11 @@
this.igniteForSeconds(8.0F);
}
@@ -165,6 +_,14 @@
@@ -165,6 +_,15 @@
}
this.setPhantomSize(compound.getInt("Size"));
+
+ // Paper start
+ if (compound.hasUUID("Paper.SpawningEntity")) {
+ this.spawningEntity = compound.getUUID("Paper.SpawningEntity");
@@ -32,31 +45,11 @@
+ if (this.spawningEntity != null) {
+ compound.putUUID("Paper.SpawningEntity", this.spawningEntity);
+ }
+ compound.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay);
+ compound.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay);
+ // Paper end
}
@Override
@@ -222,6 +_,19 @@
return targetingConditions.test(level, this, entity);
}
+ // Paper start
+ @Nullable
+ java.util.UUID spawningEntity;
+
+ @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
static enum AttackPhase {
CIRCLE,
SWOOP;
@@ -247,7 +_,8 @@
for (Player player : nearbyPlayers) {

View File

@@ -175,10 +175,11 @@
}
@Override
@@ -398,6 +_,12 @@
@@ -398,6 +_,13 @@
slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage());
}
}
+
+ // Paper start - Slime pathfinder events; clear timer and target when goal resets
+ public void stop() {
+ this.growTiredTimer = 0;

View File

@@ -30,7 +30,7 @@
PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY),
SoundEvents.WANDERING_TRADER_DISAPPEARED,
- wanderingTrader -> this.level().isNight() && !wanderingTrader.isInvisible()
+ wanderingTrader -> this.canDrinkPotion && this.level().isNight() && !wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API
+ wanderingTrader -> this.canDrinkPotion && this.level().isNight() && !wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API
)
);
this.goalSelector