This commit is contained in:
Bjarne Koll
2024-10-23 12:32:08 +02:00
parent 5a3a8af328
commit de0ed829eb
29 changed files with 101 additions and 97 deletions

View File

@@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// CraftBukkit start // CraftBukkit start
private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot

View File

@@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java --- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java +++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
@@ -0,0 +0,0 @@ public class Creeper extends Monster implements PowerableMob { @@ -0,0 +0,0 @@ public class Creeper extends Monster {
} }
if (nbt.getBoolean("ignited")) { if (nbt.getBoolean("ignited")) {
@@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
@@ -0,0 +0,0 @@ public class Creeper extends Monster implements PowerableMob { @@ -0,0 +0,0 @@ public class Creeper extends Monster {
} }
public void ignite() { public void ignite() {

View File

@@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
@@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy {
return entitysize.scale(1.0F + 0.15F * (float) i); return predicate.test(world, this, target);
} }
+ // Paper start + // Paper start
@@ -67,12 +67,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ continue; + continue;
+ } + }
+ // Paper end - PhantomPreSpawnEvent + // Paper end - PhantomPreSpawnEvent
Phantom entityphantom = (Phantom) EntityType.PHANTOM.create(world); Phantom entityphantom = (Phantom) EntityType.PHANTOM.create(world, EntitySpawnReason.NATURAL);
if (entityphantom != null) { if (entityphantom != null) {
+ entityphantom.setSpawningEntity(entityplayer.getUUID()); // Paper - PhantomPreSpawnEvent + entityphantom.setSpawningEntity(entityplayer.getUUID()); // Paper - PhantomPreSpawnEvent
entityphantom.moveTo(blockposition1, 0.0F, 0.0F); entityphantom.moveTo(blockposition1, 0.0F, 0.0F);
groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, MobSpawnType.NATURAL, groupdataentity); groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, EntitySpawnReason.NATURAL, groupdataentity);
world.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit world.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View File

@@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getIndirectSourceEntity().getBukkitEntity()).callEvent()) + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, explosionSource.getIndirectSourceEntity().getBukkitEntity()).callEvent())
+ continue; + continue;
+ // Paper end - TNTPrimeEvent + // Paper end - TNTPrimeEvent
nmsBlock.wasExploded(this.level(), blockposition, this.explosionSource); nmsBlock.wasExploded((ServerLevel) this.level(), blockposition, this.explosionSource);
this.level().removeBlock(blockposition, false); this.level().removeBlock(blockposition, false);
diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java
@@ -64,8 +64,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
@@ -0,0 +0,0 @@ public class TntBlock extends Block { @@ -0,0 +0,0 @@ public class TntBlock extends Block {
@Override @Override
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, @Nullable Orientation wireOrientation, boolean notify) {
if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, sourcePos)) { // CraftBukkit - TNTPrimeEvent if (world.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(world, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent
+ // Paper start - TNTPrimeEvent + // Paper start - TNTPrimeEvent
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) { + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) {
@@ -76,27 +76,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
world.removeBlock(pos, false); world.removeBlock(pos, false);
} }
@@ -0,0 +0,0 @@ public class TntBlock extends Block { @@ -0,0 +0,0 @@ public class TntBlock extends Block {
@Override @Override
public void wasExploded(Level world, BlockPos pos, Explosion explosion) { public void wasExploded(ServerLevel world, BlockPos pos, Explosion explosion) {
if (!world.isClientSide) { + // Paper start - TNTPrimeEvent
+ // Paper start - TNTPrimeEvent + org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + org.bukkit.entity.Entity source = explosion.getDirectSourceEntity() != null ? explosion.getDirectSourceEntity().getBukkitEntity() : null;
+ org.bukkit.entity.Entity source = explosion.source != null ? explosion.source.getBukkitEntity() : null; + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, source).callEvent()) {
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, source).callEvent()) { + return;
+ return; + }
+ } + // Paper end - TNTPrimeEvent
+ // Paper end - TNTPrimeEvent PrimedTnt entitytntprimed = new PrimedTnt(world, (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, explosion.getIndirectSourceEntity());
PrimedTnt entitytntprimed = new PrimedTnt(world, (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, explosion.getIndirectSourceEntity()); int i = entitytntprimed.getFuse();
int i = entitytntprimed.getFuse();
@@ -0,0 +0,0 @@ public class TntBlock extends Block { @@ -0,0 +0,0 @@ public class TntBlock extends Block {
return ItemInteractionResult.CONSUME; return InteractionResult.CONSUME;
} }
// CraftBukkit end // CraftBukkit end
+ // Paper start - TNTPrimeEvent + // Paper start - TNTPrimeEvent
+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); + org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos);
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.ITEM, player.getBukkitEntity()).callEvent()) { + if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.ITEM, player.getBukkitEntity()).callEvent()) {
+ return ItemInteractionResult.FAIL; + return InteractionResult.FAIL;
+ } + }
+ // Paper end - TNTPrimeEvent + // Paper end - TNTPrimeEvent
TntBlock.explode(world, pos, player); TntBlock.explode(world, pos, player);

View File

@@ -25,28 +25,36 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.logging.LogUtils;
+import io.papermc.paper.configuration.GlobalConfiguration;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
private int tickCount;
private int ackBlockChangesUpTo = -1; private int ackBlockChangesUpTo = -1;
// CraftBukkit start - multithreaded fields private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200);
private final AtomicInteger chatSpamTickCount = new AtomicInteger(); + private final TickThrottler tabSpamThrottler = new TickThrottler(GlobalConfiguration.get().spamLimiter.tabSpamIncrement, GlobalConfiguration.get().spamLimiter.tabSpamLimit); // Paper - configurable tab spam limits
+ private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits private final TickThrottler dropSpamThrottler = new TickThrottler(20, 1480);
// CraftBukkit end
private int dropSpamTickCount;
private double firstGoodX; private double firstGoodX;
private double firstGoodY;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.keepConnectionAlive(); this.keepConnectionAlive();
// CraftBukkit start this.chatSpamThrottler.tick();
for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !this.chatSpamTickCount.compareAndSet(spam, spam - 1); ) ; + this.tabSpamThrottler.tick(); // Paper - configurable tab spam limits
+ if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - configurable tab spam limits this.dropSpamThrottler.tick();
/* Use thread-safe field access instead if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) {
if (this.chatSpamTickCount > 0) { this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
--this.chatSpamTickCount;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) { public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) {
// PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // Paper - AsyncTabCompleteEvent; run this async // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // Paper - AsyncTabCompleteEvent; run this async
// CraftBukkit start // CraftBukkit start
- if (this.chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { - if (!this.chatSpamThrottler.isIncrementAndUnderThreshold(1, 500) && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
+ if (this.chatSpamTickCount.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper - configurable tab spam limits + if (!this.tabSpamThrottler.isIncrementAndUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) { // Paper - configurable tab spam limits
this.disconnect(Component.translatable("disconnect.spam")); this.disconnect(Component.translatable("disconnect.spam"));
return; return;
} }

View File

@@ -39,11 +39,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - Configurable speed for water flowing over lava + // Paper end - Configurable speed for water flowing over lava
+ +
@Override @Override
protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { protected BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) {
if (state.getFluidState().isSource() || neighborState.getFluidState().isSource()) { if (state.getFluidState().isSource() || neighborState.getFluidState().isSource()) {
@@ -0,0 +0,0 @@ public class LiquidBlock extends Block implements BucketPickup { @@ -0,0 +0,0 @@ public class LiquidBlock extends Block implements BucketPickup {
@Override @Override
protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, @Nullable Orientation wireOrientation, boolean notify) {
if (this.shouldSpreadLiquid(world, pos, state)) { if (this.shouldSpreadLiquid(world, pos, state)) {
- world.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(world)); - world.scheduleTick(pos, state.getFluidState().getType(), this.fluid.getTickDelay(world));
+ world.scheduleTick(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper - Configurable speed for water flowing over lava + world.scheduleTick(pos, state.getFluidState().getType(), this.getFlowSpeed(world, pos)); // Paper - Configurable speed for water flowing over lava

View File

@@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void die(DamageSource damageSource) { public void die(DamageSource damageSource) {
- this.gameEvent(GameEvent.ENTITY_DIE); - this.gameEvent(GameEvent.ENTITY_DIE);
+ // this.gameEvent(GameEvent.ENTITY_DIE); // Paper - move below event cancellation check + // this.gameEvent(GameEvent.ENTITY_DIE); // Paper - move below event cancellation check
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
// CraftBukkit start - fire PlayerDeathEvent // CraftBukkit start - fire PlayerDeathEvent
if (this.isRemoved()) { if (this.isRemoved()) {
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { @@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
@@ -60,15 +60,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// SPIGOT-943 - only call if they have an inventory open // SPIGOT-943 - only call if they have an inventory open
if (this.containerMenu != this.inventoryMenu) { if (this.containerMenu != this.inventoryMenu) {
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { @@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
}
} }
} }
-
- return super.hurt(source, amount); - return super.hurtServer(world, source, amount);
+ // Paper start - cancellable death events + // Paper start - cancellable death events
+ //return super.hurt(source, amount); + //return super.hurt(source, amount);
+ this.queueHealthUpdatePacket = true; + this.queueHealthUpdatePacket = true;
+ boolean damaged = super.hurt(source, amount); + boolean damaged = super.hurtServer(world, source, amount);
+ this.queueHealthUpdatePacket = false; + this.queueHealthUpdatePacket = false;
+ if (this.queuedHealthUpdatePacket != null) { + if (this.queuedHealthUpdatePacket != null) {
+ this.connection.send(this.queuedHealthUpdatePacket); + this.connection.send(this.queuedHealthUpdatePacket);
@@ -180,12 +179,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
if (!this.level().isClientSide) { if (world instanceof ServerLevel worldserver) {
boolean flag = false; boolean flag = false;
- if (adversary instanceof WitherBoss) { - if (adversary instanceof WitherBoss) {
+ if (this.dead && adversary instanceof WitherBoss) { // Paper + if (this.dead && adversary instanceof WitherBoss) { // Paper
if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { if (worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
BlockPos blockposition = this.blockPosition(); BlockPos blockposition = this.blockPosition();
BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -200,9 +199,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end + // Paper end
boolean flag = this.lastHurtByPlayerTime > 0; boolean flag = this.lastHurtByPlayerTime > 0;
this.dropEquipment(); // CraftBukkit - from below this.dropEquipment(world); // CraftBukkit - from below
if (this.shouldDropLoot() && world.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { if (this.shouldDropLoot() && world.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
this.dropFromLootTable(damageSource, flag); this.dropFromLootTable(world, damageSource, flag);
+ // Paper start + // Paper start
+ final boolean prev = this.clearEquipmentSlots; + final boolean prev = this.clearEquipmentSlots;
+ this.clearEquipmentSlots = false; + this.clearEquipmentSlots = false;
@@ -218,16 +217,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.drops = new ArrayList<>(); this.drops = new ArrayList<>();
// CraftBukkit end // CraftBukkit end
// this.dropEquipment();// CraftBukkit - moved up // this.dropEquipment(worldserver);// CraftBukkit - moved up
this.dropExperience(damageSource.getEntity()); this.dropExperience(world, damageSource.getEntity());
+ return deathEvent; // Paper + return deathEvent; // Paper
} }
protected void dropEquipment() {} protected void dropEquipment(ServerLevel world) {}
+ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {} // Paper - method for post death logic that cannot be ran before the event is potentially cancelled + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {} // Paper - method for post death logic that cannot be ran before the event is potentially cancelled
public int getExpReward(@Nullable Entity entity) { // CraftBukkit public int getExpReward(ServerLevel worldserver, @Nullable Entity entity) { // CraftBukkit
Level world = this.level(); if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
@@ -247,8 +246,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
super.dropCustomDeathLoot(world, source, causedByPlayer); super.dropCustomDeathLoot(world, source, causedByPlayer);
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
for (int j = 0; j < i; ++j) { while (iterator.hasNext()) {
EquipmentSlot enumitemslot = aenumitemslot[j]; EquipmentSlot enumitemslot = (EquipmentSlot) iterator.next();
+ if (this.shouldSkipLoot(enumitemslot)) continue; // Paper + if (this.shouldSkipLoot(enumitemslot)) continue; // Paper
ItemStack itemstack = this.getItemBySlot(enumitemslot); ItemStack itemstack = this.getItemBySlot(enumitemslot);
float f = this.getEquipmentDropChance(enumitemslot); float f = this.getEquipmentDropChance(enumitemslot);
@@ -256,7 +255,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
} }
this.spawnAtLocation(itemstack); this.spawnAtLocation(world, itemstack);
+ if (this.clearEquipmentSlots) { // Paper + if (this.clearEquipmentSlots) { // Paper
this.setItemSlot(enumitemslot, ItemStack.EMPTY); this.setItemSlot(enumitemslot, ItemStack.EMPTY);
+ // Paper start + // Paper start
@@ -271,7 +270,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java --- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java +++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
@@ -0,0 +0,0 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> { @@ -0,0 +0,0 @@ public class Fox extends Animal implements VariantHolder<Fox.Variant> {
return this.getTrustedUUIDs().contains(uuid); return this.getTrustedUUIDs().contains(uuid);
} }
@@ -290,8 +289,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (!itemstack.isEmpty()) { - if (!itemstack.isEmpty()) {
+ boolean releaseMouth = false; + boolean releaseMouth = false;
+ if (!itemstack.isEmpty() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Fix MC-153010 + if (!itemstack.isEmpty() && world.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Fix MC-153010
this.spawnAtLocation(itemstack); this.spawnAtLocation(world, itemstack);
+ releaseMouth = true; + releaseMouth = true;
+ } + }
+ +
@@ -318,13 +317,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java --- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
@@ -0,0 +0,0 @@ public abstract class AbstractChestedHorse extends AbstractHorse { @@ -0,0 +0,0 @@ public abstract class AbstractChestedHorse extends AbstractHorse {
this.spawnAtLocation(Blocks.CHEST); super.dropEquipment(world);
} if (this.hasChest()) {
this.spawnAtLocation(world, Blocks.CHEST);
+ //this.setChest(false); // Paper - moved to post death logic + //this.setChest(false); // Paper - moved to post death logic
+ } + }
+ } + }
+
+ // Paper start + // Paper start
+ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {
+ if (this.hasChest() && (event == null || !event.isCancelled())) { + if (this.hasChest() && (event == null || !event.isCancelled())) {
@@ -340,36 +338,35 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
} }
// CraftBukkit end // CraftBukkit end
if (source.is(DamageTypeTags.IS_EXPLOSION)) { if (source.is(DamageTypeTags.IS_EXPLOSION)) {
- this.brokenByAnything(worldserver, source); - this.brokenByAnything(world, source);
- this.kill(source); // CraftBukkit - this.kill(world, source); // CraftBukkit
+ // Paper start - avoid duplicate event call + // Paper start - avoid duplicate event call
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(worldserver, source); + org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(world, source);
+ if (!event.isCancelled()) this.kill(source, false); // CraftBukkit + if (!event.isCancelled()) this.kill(source, false); // CraftBukkit
+ // Paper end + // Paper end
return false; return false;
} else if (source.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) { } else if (source.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) {
if (this.isOnFire()) { if (this.isOnFire()) {
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity());
this.lastHit = i; this.lastHit = i;
} else { } else {
- this.brokenByPlayer(worldserver, source); - this.brokenByPlayer(world, source);
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(worldserver, source); // Paper + org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(world, source); // Paper
this.showBreakingParticles(); this.showBreakingParticles();
- this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event - this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event
+ if (!event.isCancelled()) this.kill(source, false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...) + if (!event.isCancelled()) this.kill(source, false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...)
} }
return true; return true;
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
f1 -= amount; f1 -= amount;
if (f1 <= 0.5F) { if (f1 <= 0.5F) {
- this.brokenByAnything(world, damageSource); this.brokenByAnything(world, damageSource);
- this.kill(damageSource); // CraftBukkit - this.kill(world, damageSource); // CraftBukkit
+ // Paper start - avoid duplicate event call + // Paper start - avoid duplicate event call
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(world, damageSource); + org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(world, damageSource);
+ if (!event.isCancelled()) this.kill(damageSource, false); // CraftBukkit + if (!event.isCancelled()) this.kill(damageSource, false); // CraftBukkit
@@ -408,7 +405,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
} }
public void kill(DamageSource damageSource) { public void kill(ServerLevel worldserver, DamageSource damageSource) {
- org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, (damageSource == null ? this.damageSources().genericKill() : damageSource), this.drops); // CraftBukkit - call event - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, (damageSource == null ? this.damageSources().genericKill() : damageSource), this.drops); // CraftBukkit - call event
+ // Paper start - make cancellable + // Paper start - make cancellable
+ this.kill(damageSource, true); + this.kill(damageSource, true);
@@ -447,11 +444,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -0,0 +0,0 @@ public class CraftEventFactory { @@ -0,0 +0,0 @@ public class CraftEventFactory {
CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource);
EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity()));
+ populateFields(victim, event); // Paper - make cancellable
CraftWorld world = (CraftWorld) entity.getWorld(); CraftWorld world = (CraftWorld) entity.getWorld();
EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(world.getHandle(), damageSource.getEntity()));
+ populateFields(victim, event); // Paper - make cancellable
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
+ // Paper start - make cancellable + // Paper start - make cancellable
@@ -464,10 +460,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
@@ -0,0 +0,0 @@ public class CraftEventFactory { @@ -0,0 +0,0 @@ public class CraftEventFactory {
PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity()), 0, deathMessage); PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(victim.serverLevel(), damageSource.getEntity()), 0, deathMessage);
event.setKeepInventory(keepInventory); event.setKeepInventory(keepInventory);
event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel
+ populateFields(victim, event); // Paper - make cancellable +populateFields(victim, event); // Paper - make cancellable
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
+ // Paper start - make cancellable + // Paper start - make cancellable
+ if (event.isCancelled()) { + if (event.isCancelled()) {

View File

@@ -11,9 +11,9 @@ diff --git a/src/main/java/net/minecraft/core/MappedRegistry.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/core/MappedRegistry.java --- a/src/main/java/net/minecraft/core/MappedRegistry.java
+++ b/src/main/java/net/minecraft/core/MappedRegistry.java +++ b/src/main/java/net/minecraft/core/MappedRegistry.java
@@ -0,0 +0,0 @@ public class MappedRegistry<T> implements WritableRegistry<T> { @@ -0,0 +0,0 @@ import net.minecraft.util.RandomSource;
private static final Logger LOGGER = LogUtils.getLogger(); public class MappedRegistry<T> implements WritableRegistry<T> {
final ResourceKey<? extends Registry<T>> key; private final ResourceKey<? extends Registry<T>> key;
private final ObjectList<Holder.Reference<T>> byId = new ObjectArrayList<>(256); private final ObjectList<Holder.Reference<T>> byId = new ObjectArrayList<>(256);
- private final Reference2IntMap<T> toId = Util.make(new Reference2IntOpenHashMap<>(), map -> map.defaultReturnValue(-1)); - private final Reference2IntMap<T> toId = Util.make(new Reference2IntOpenHashMap<>(), map -> map.defaultReturnValue(-1));
- private final Map<ResourceLocation, Holder.Reference<T>> byLocation = new HashMap<>(); - private final Map<ResourceLocation, Holder.Reference<T>> byLocation = new HashMap<>();
@@ -26,5 +26,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final Map<T, Holder.Reference<T>> byValue = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map<T, Holder.Reference<T>> byValue = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions
+ private final Map<ResourceKey<T>, RegistrationInfo> registrationInfos = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions + private final Map<ResourceKey<T>, RegistrationInfo> registrationInfos = new IdentityHashMap<>(2048); // Paper - Perf: Use bigger expected size to reduce collisions
private Lifecycle registryLifecycle; private Lifecycle registryLifecycle;
private volatile Map<TagKey<T>, HolderSet.Named<T>> tags = new IdentityHashMap<>(); private final Map<TagKey<T>, HolderSet.Named<T>> frozenTags = new IdentityHashMap<>();
private boolean frozen; MappedRegistry.TagSet<T> allTags = MappedRegistry.TagSet.unbound();