1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-01-31 20:13:33 +01:00

[ci skip] Add more patch identifying comments

This commit is contained in:
Nassim Jahnke 2024-01-21 19:37:09 +01:00
parent bc99c40604
commit b088c37fc1
39 changed files with 146 additions and 180 deletions
patches
api
server
Add-API-for-quit-reason.patchAdd-EntityKnockbackByEntityEvent-and-EntityPushedByE.patchAdd-EntityTeleportEndGatewayEvent.patchAdd-PrepareResultEvent.patchAdd-additional-open-container-api-to-HumanEntity.patchAdd-config-to-disable-ender-dragon-legacy-check.patchAdd-critical-damage-API.patchAdd-ray-tracing-methods-to-LivingEntity.patchAdd-titleOverride-to-InventoryOpenEvent.patchCollision-optimisations.patchConfigurable-LootPool-luck-formula.patchDo-not-run-close-logic-for-inventories-on-chunk-unlo.patchDon-t-enforce-icanhasbukkit-default-if-alias-block-e.patchEnderDragon-Events.patchEndermanAttackPlayerEvent.patchExpand-World.spawnParticle-API-and-add-Builder.patchFix-merchant-inventory-not-closing-on-entity-removal.patchFixes-and-additions-to-the-SpawnReason-API.patchImprove-BlockPosition-inlining.patchImprove-EntityShootBowEvent.patchInventoryCloseEvent-Reason-API.patchMake-shield-blocking-delay-configurable.patchMissing-Entity-API.patchMore-Teleport-API.patchOptimize-NetworkManager-Exception-Handling.patchOption-to-prevent-armor-stands-from-doing-entity-loo.patchPlayerElytraBoostEvent.patchPlayerLaunchProjectileEvent.patchPlayerReadyArrowEvent.patchPrevent-Frosted-Ice-from-loading-holding-chunks.patchPrevent-opening-inventories-when-frozen.patchPrint-Error-details-when-failing-to-save-player-data.patchRefresh-player-inventory-when-cancelling-PlayerInter.patchRemote-Connections-shouldn-t-hold-up-shutdown.patchWitchConsumePotionEvent.patchWitchThrowPotionEvent.patchadd-more-information-to-Entity.toString.patch

View file

@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public static ChunkGenerator.ChunkData createVanillaChunkData(@NotNull World world, int x, int z) {
+ return server.createVanillaChunkData(world, x, z);
+ }
+ // Paper stop
+ // Paper end
+
/**
* Creates a boss bar instance to display to players. The progress

View file

@ -1451,7 +1451,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * org.bukkit.{@link org.bukkit.Sound#ENTITY_ZOMBIE_VILLAGER_CURE} from playing.
+ */
+ void setConversionTime(int time, boolean broadcastEntityEvent);
+ // Paper stop - missing entity behaviour api - converting without entity event
+ // Paper end - missing entity behaviour api - converting without entity event
}
diff --git a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java b/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View file

@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -0,0 +0,0 @@ public abstract class PlayerList {
entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper
entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason
}
- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName()))); // Paper - Adventure

View file

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Brokkonaut <hannos17@gmx.de>
Date: Mon, 18 Jun 2018 15:46:23 +0200
Subject: [PATCH] Implement EntityKnockbackByEntityEvent and
Subject: [PATCH] Add EntityKnockbackByEntityEvent and
EntityPushedByEntityAttackEvent
Co-authored-by: aerulion <aerulion@gmail.com>
@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void push(double deltaX, double deltaY, double deltaZ) {
- this.setDeltaMovement(this.getDeltaMovement().add(deltaX, deltaY, deltaZ));
- this.hasImpulse = true;
+ // Paper start - call EntityPushedByEntityEvent
+ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
+ this.push(deltaX, deltaY, deltaZ, null);
+ }
+
@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ()));
+ this.hasImpulse = true;
+ }
+ // Paper end - call EntityPushedByEntityEvent
+ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
}
protected void markHurt() {
@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
- this.knockback(0.4000000059604645D, d0, d1);
+ this.knockback(0.4000000059604645D, d0, d1, entity1); // Paper
+ this.knockback(0.4000000059604645D, d0, d1, entity1); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
if (!flag) {
this.indicateDamage(d0, d1);
}
@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected void blockedByShield(LivingEntity target) {
- target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ());
+ target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Paper
+ target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
}
private boolean checkTotemDeathProtection(DamageSource source) {
@ -58,11 +58,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
public void knockback(double strength, double x, double z) {
+ // Paper start - add knockbacking entity parameter
+ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
+ this.knockback(strength, x, z, null);
+ }
+ public void knockback(double strength, double x, double z, Entity knockingBackEntity) {
+ // Paper end - add knockbacking entity parameter
+ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
if (strength > 0.0D) {
this.hasImpulse = true;
@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Vec3 vec3d1 = (new Vec3(x, 0.0D, z)).normalize().scale(strength);
this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + strength) : vec3d.y, vec3d.z / 2.0D - vec3d1.z);
+ // Paper start - call EntityKnockbackByEntityEvent
+ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEventt
+ Vec3 currentMovement = this.getDeltaMovement();
+ org.bukkit.util.Vector delta = new org.bukkit.util.Vector(currentMovement.x - vec3d.x, currentMovement.y - vec3d.y, currentMovement.z - vec3d.z);
+ // Restore old velocity to be able to access it in the event
@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (knockingBackEntity == null || new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent((org.bukkit.entity.LivingEntity) getBukkitEntity(), knockingBackEntity.getBukkitEntity(), (float) strength, delta).callEvent()) {
+ this.setDeltaMovement(vec3d.x + delta.getX(), vec3d.y + delta.getY(), vec3d.z + delta.getZ());
+ }
+ // Paper end
+ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
}
}
@ -91,7 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (flag) {
if (f1 > 0.0F && target instanceof LivingEntity) {
- ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
+ ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper
+ ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
}
@ -104,7 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
float g = Mth.clamp(entity.getSpeed() * 1.65F, 0.2F, 3.0F) + f;
float h = livingEntity.isDamageSourceBlocked(world.damageSources().mobAttack(entity)) ? 0.5F : 1.0F;
- livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z());
+ livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), entity); // Paper
+ livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), entity); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
this.finishRam(world, entity);
world.playSound((Player)null, entity, this.getImpactSound.apply(entity), SoundSource.NEUTRAL, 1.0F, 1.0F);
} else if (this.hasRammedHornBreakingBlock(world, entity)) {
@ -117,7 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
double d = 0.5D * (1.0D - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE));
double e = 2.5D * (1.0D - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE));
- target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e);
+ target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e, entity); // Paper
+ target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e, entity); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
});
}
}
@ -130,7 +130,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
double d4 = Math.max(d2 * d2 + d3 * d3, 0.1D);
- entity.push(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D);
+ entity.push(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D, this); // Paper
+ entity.push(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D, this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
if (!this.phaseManager.getCurrentPhase().isSitting() && ((LivingEntity) entity).getLastHurtByMobTimestamp() < entity.tickCount - 2) {
entity.hurt(this.damageSources().mobAttack(this), 5.0F);
this.doEnchantDamageEffects(this, entity);
@ -143,7 +143,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
double d2 = Math.max(d0 * d0 + d1 * d1, 0.001D);
- entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D);
+ entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D, this); // Paper
+ entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D, this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
}
@Override
@ -156,7 +156,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Vec3 vec3 = (new Vec3(g, 0.0D, h)).normalize().scale(j).yRot(i);
double k = f * (double)attacker.level().random.nextFloat() * 0.5D;
- target.push(vec3.x, k, vec3.z);
+ target.push(vec3.x, k, vec3.z, attacker); // Paper
+ target.push(vec3.x, k, vec3.z, attacker); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
target.hurtMarked = true;
}
}
@ -169,10 +169,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (i > 0) {
if (target instanceof LivingEntity) {
- ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
+ ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper
+ ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
} else {
- target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F));
+ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F), this); // Paper
+ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
}
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
@ -181,7 +181,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start - Only apply knockback if the damage hits
if (entityliving.hurt(this.damageSources().playerAttack(this).sweep(), f4)) {
- entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
+ entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Pa
+ entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
}
// CraftBukkit end
}

View file

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 9 Jun 2018 14:08:39 +0200
Subject: [PATCH] Implement EntityTeleportEndGatewayEvent
Subject: [PATCH] Add EntityTeleportEndGatewayEvent
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java

View file

@ -140,7 +140,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end - Add PrepareResultEvent
+
+ // Paper start - support specific overrides for prepare result
+ // Paper start - Add PrepareResultEvent
+ public static void callPrepareResultEvent(AbstractContainerMenu container, int resultSlot) {
+ com.destroystokyo.paper.event.inventory.PrepareResultEvent event;
+ InventoryView view = container.getBukkitView();

View file

@ -78,4 +78,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
@Override
public void closeInventory() {
// Paper start
// Paper start - Inventory close reason

View file

@ -12,10 +12,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.ticksSinceLastPlayerScan = 21;
this.skipArenaLoadedCheck = false;
this.needsStateScanning = true;
+ // Paper start
+ // Paper start - Add config to disable ender dragon legacy check
+ this.needsStateScanning = world.paperConfig().entities.spawning.scanForLegacyEnderDragon;
+ if (!this.needsStateScanning) this.dragonKilled = true;
+ // Paper end
+ // Paper end - Add config to disable ender dragon legacy check
this.level = world;
this.origin = origin;
this.validPlayer = EntitySelector.ENTITY_STILL_ALIVE.and(EntitySelector.withinDistance((double) origin.getX(), (double) (128 + origin.getY()), (double) origin.getZ(), 192.0D));

View file

@ -55,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start - Only apply knockback if the damage hits
- if (entityliving.hurt(this.damageSources().playerAttack(this).sweep(), f4)) {
+ if (entityliving.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API
entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Pa
entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java

View file

@ -11,8 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
// Paper start
+
// Paper start - Make shield blocking delay configurable
+ public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) {
+ if (maxDistance < 1 || maxDistance > 120) {
+ throw new IllegalArgumentException("maxDistance must be between 1-120");

View file

@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
//String title = inventory.getTitle(); // Paper - comment
net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper
if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper
+ if (result.getFirst() != null) adventure$title = result.getFirst(); // Paper - Add titleOverride to InventoryOpenEvent //player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment
+ if (result.getFirst() != null) adventure$title = result.getFirst(); // Paper - Add titleOverride to InventoryOpenEvent
//player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment
if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper - Prevent opening inventories when frozen
player.containerMenu = container;
@ -103,7 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public static com.mojang.datafixers.util.Pair<net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component, @org.jetbrains.annotations.Nullable AbstractContainerMenu> callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) {
+ // Paper end - Add titleOverride to InventoryOpenEvent
if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open
player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper
player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason
}
@@ -0,0 +0,0 @@ public class CraftEventFactory {

View file

@ -2446,7 +2446,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
@Override
protected void pushEntities() {
if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper
if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups
- List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox(), ArmorStand.RIDABLE_MINECARTS);
+ List<AbstractMinecart> list = this.level().getEntitiesOfClass(AbstractMinecart.class, this.getBoundingBox(), ArmorStand.RIDABLE_MINECARTS); // Paper - optimise collisions
Iterator iterator = list.iterator();
@ -3002,7 +3002,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return !io.papermc.paper.util.CollisionUtil.getEntityHardCollisions(this, entity, box, null, flags, null);
+ // Paper end - optimise collisions
}
// Paper end
// Paper end - Option to prevent armor stands from doing entity lookups
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View file

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 15 Jun 2018 00:30:32 -0400
Subject: [PATCH] Configurable Alternative LootPool Luck Formula
Subject: [PATCH] Configurable LootPool luck formula
Rewrites the Vanilla luck application formula so that luck can be
applied to items that do not have any quality defined.
@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public int getWeight(float luck) {
- return Math.max(Mth.floor((float)LootPoolSingletonContainer.this.weight + (float)LootPoolSingletonContainer.this.quality * luck), 0);
+ // Paper start - Offer an alternative loot formula to refactor how luck bonus applies
+ // Paper start - Configurable LootPool luck formula
+ // SEE: https://luckformula.emc.gs for details and data
+ if (LootPoolSingletonContainer.this.lastLuck != null && LootPoolSingletonContainer.this.lastLuck == luck) {
+ return lastWeight;
@ -72,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
+ private Float lastLuck = null;
+ private int lastWeight = 0;
+ // Paper end
+ // Paper end - Configurable LootPool luck formula
@FunctionalInterface
protected interface EntryConstructor {

View file

@ -20,8 +20,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // chests for example can apply physics to the world
+ // so instead we just change the active container and call the event
for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) {
- h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper
+ ((org.bukkit.craftbukkit.entity.CraftHumanEntity)h).getHandle().closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper
- h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
+ ((org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
}
+ // Paper end - this area looks like it can load chunks, change the behavior
}
@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
this.containerMenu = this.inventoryMenu;
}
// Paper end
// Paper end - Inventory close reason
+ // Paper start - special close for unloaded inventory
+ public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
+ this.containerMenu = this.inventoryMenu;

View file

@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final YamlConfiguration commandsDefaults = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8));
+ if (this.commandsConfiguration.contains("aliases")) commandsDefaults.set("aliases", null);
+ this.commandsConfiguration.setDefaults(commandsDefaults);
+ // Paper stop - don't enforce icanhasbukkit default if alias block exists
+ // Paper end - don't enforce icanhasbukkit default if alias block exists
this.saveCommandsConfig();
// Migrate aliases from old file and add previously implicit $1- to pass all arguments

View file

@ -12,13 +12,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.flame.setDuration(200);
this.flame.setParticle(ParticleTypes.DRAGON_BREATH);
this.flame.addEffect(new MobEffectInstance(MobEffects.HARM));
+ if (new com.destroystokyo.paper.event.entity.EnderDragonFlameEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.AreaEffectCloud) this.flame.getBukkitEntity()).callEvent()) { // Paper
+ if (new com.destroystokyo.paper.event.entity.EnderDragonFlameEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.AreaEffectCloud) this.flame.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events
this.dragon.level().addFreshEntity(this.flame);
+ // Paper start
+ // Paper start - EnderDragon Events
+ } else {
+ this.end();
+ }
+ // Paper end
+ // Paper end - EnderDragon Events
}
}
@ -30,9 +30,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
DragonFireball dragonFireball = new DragonFireball(this.dragon.level(), this.dragon, r, s, t);
dragonFireball.moveTo(o, p, q, 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
+ if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper - EnderDragon Events
this.dragon.level().addFreshEntity(dragonFireball);
+ else dragonFireball.discard(); // Paper
+ else dragonFireball.discard(); // Paper - EnderDragon Events
this.fireballCharge = 0;
if (this.currentPath != null) {
while(!this.currentPath.isDone()) {
@ -44,10 +44,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
}
+ if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper
+ if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events
this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
this.level().addFreshEntity(areaEffectCloud);
+ } else areaEffectCloud.discard(); // Paper
+ } else areaEffectCloud.discard(); // Paper - EnderDragon Events
this.discard();
}

View file

@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return event.callEvent();
+ }
+ private boolean isLookingAtMe_check(Player player) {
+ // Paper end
+ // Paper end - EndermanAttackPlayerEvent
ItemStack itemstack = (ItemStack) player.getInventory().armor.get(3);
if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem())) {

View file

@ -17,19 +17,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
public <T extends ParticleOptions> int sendParticles(ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) {
+ // Paper start - Particle API Expansion
+ // Paper start - Particle API
+ return sendParticles(players, sender, t0, d0, d1, d2, i, d3, d4, d5, d6, force);
+ }
+ public <T extends ParticleOptions> int sendParticles(List<ServerPlayer> receivers, @Nullable ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) {
+ // Paper end
+ // Paper end - Particle API
ClientboundLevelParticlesPacket packetplayoutworldparticles = new ClientboundLevelParticlesPacket(t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
// CraftBukkit end
int j = 0;
- for (int k = 0; k < this.players.size(); ++k) {
- ServerPlayer entityplayer = (ServerPlayer) this.players.get(k);
+ for (Player entityhuman : receivers) { // Paper - Particle API Expansion
+ ServerPlayer entityplayer = (ServerPlayer) entityhuman; // Paper - Particle API Expansion
+ for (Player entityhuman : receivers) { // Paper - Particle API
+ ServerPlayer entityplayer = (ServerPlayer) entityhuman; // Paper - Particle API
if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit
if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit
@ -41,12 +41,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
+ // Paper start - Particle API Expansion
+ // Paper start - Particle API
+ spawnParticle(particle, null, null, x, y, z, count, offsetX, offsetY, offsetZ, extra, data, force);
+ }
+ @Override
+ public <T> void spawnParticle(Particle particle, List<Player> receivers, Player sender, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
+ // Paper end
+ // Paper end - Particle API
particle = CraftParticle.convertLegacy(particle);
data = CraftParticle.convertLegacy(data);
if (data != null) {
@ -54,8 +54,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
this.getHandle().sendParticles(
- null, // Sender
+ receivers == null ? getHandle().players() : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API Expansion
+ sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API Expansion
+ receivers == null ? getHandle().players() : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API
+ sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API
CraftParticle.createParticleParam(particle, data), // Particle
x, y, z, // Position
count, // Count

View file

@ -18,5 +18,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end - Fix merchant inventory not closing on entity removal
for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) {
h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper
h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
}

View file

@ -26,11 +26,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
@@ -0,0 +0,0 @@ public class DragonFireball extends AbstractHurtingProjectile {
if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper
if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events
this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
- this.level().addFreshEntity(areaEffectCloud);
+ this.level().addFreshEntity(areaEffectCloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // Paper - use correct spawn reason
} else areaEffectCloud.discard(); // Paper
} else areaEffectCloud.discard(); // Paper - EnderDragon Events
this.discard();
}
diff --git a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java

View file

@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
- public boolean equals(Object object) {
+ public final boolean equals(Object object) { // Paper
+ public final boolean equals(Object object) { // Paper - Perf: Final for inline
if (this == object) {
return true;
} else if (!(object instanceof Vec3i)) {
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
- public int hashCode() {
+ public final int hashCode() { // Paper
+ public final int hashCode() { // Paper - Perf: Final for inline
return (this.getY() + this.getZ() * 31) * 31 + this.getX();
}
@ -47,17 +47,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
- public int getX() {
+ public final int getX() { // Paper
+ public final int getX() { // Paper - Perf: Final for inline
return this.x;
}
- public int getY() {
+ public final int getY() { // Paper
+ public final int getY() { // Paper - Perf: Final for inline
return this.y;
}
- public int getZ() {
+ public final int getZ() { // Paper
+ public final int getZ() { // Paper - Perf: Final for inline
return this.z;
}

View file

@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
double d3 = Math.sqrt(d0 * d0 + d2 * d2);
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level().getDifficulty().getId() * 4));
+ // Paper start
+ // Paper start - EntityShootBowEvent
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), entityarrow.getPickupItem(), entityarrow, target.getUsedItemHand(), 0.8F, true);
+ if (event.isCancelled()) {
+ event.getProjectile().remove();
@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+ this.level().addFreshEntity(entityarrow);
+ }
+ // Paper end
+ // Paper end - EntityShootBowEvent
this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
- this.level().addFreshEntity(entityarrow);
}

View file

@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (tileentity instanceof net.minecraft.world.Container) {
for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) {
- h.closeInventory();
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
}
}
}
@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message
for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) {
- h.closeInventory();
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason
}
}
// Spigot End
@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper end
if (!this.level().isClientSide && !this.containerMenu.stillValid(this)) {
- this.closeContainer();
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper - Inventory close reason
this.containerMenu = this.inventoryMenu;
}
@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// SPIGOT-943 - only call if they have an inventory open
if (this.containerMenu != this.inventoryMenu) {
- this.closeContainer();
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DEATH); // Paper
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DEATH); // Paper - Inventory close reason
}
net.kyori.adventure.text.Component deathMessage = event.deathMessage() != null ? event.deathMessage() : net.kyori.adventure.text.Component.empty(); // Paper - Adventure
@ -55,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end
if (this.containerMenu != this.inventoryMenu) {
- this.closeContainer();
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason
}
// this.nextContainerCounter(); // CraftBukkit - moved up
@ -64,13 +64,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public void closeContainer() {
- CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
+ // Paper start
+ // Paper start - Inventory close reason
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNKNOWN);
+ }
+ @Override
+ public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
+ CraftEventFactory.handleInventoryCloseEvent(this, reason); // CraftBukkit
+ // Paper end
+ // Paper end - Inventory close reason
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
this.doCloseContainer();
}
@ -90,11 +90,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public void handleContainerClose(ServerboundContainerClosePacket packet) {
+ // Paper start
+ // Paper start - Inventory close reason
+ this.handleContainerClose(packet, InventoryCloseEvent.Reason.PLAYER);
+ }
+ public void handleContainerClose(ServerboundContainerClosePacket packet, InventoryCloseEvent.Reason reason) {
+ // Paper end
+ // Paper end - Inventory close reason
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (this.player.isImmobile()) return; // CraftBukkit
@ -112,7 +112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// See SPIGOT-5799, SPIGOT-6145
if (entityplayer.containerMenu != entityplayer.inventoryMenu) {
- entityplayer.closeContainer();
+ entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper
+ entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason
}
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName()))); // Paper - Adventure
@ -125,7 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
super.tick();
if (!this.level().isClientSide && this.containerMenu != null && !this.containerMenu.stillValid(this)) {
- this.closeContainer();
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper - Inventory close reason
this.containerMenu = this.inventoryMenu;
}
@ -133,12 +133,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
+ // Paper start - unused code, but to keep signatures aligned
+ // Paper start - Inventory close reason; unused code, but to keep signatures aligned
+ public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
+ closeContainer();
+ this.containerMenu = this.inventoryMenu;
+ }
+ // Paper end
+ // Paper end - Inventory close reason
+
public void closeContainer() {
this.containerMenu = this.inventoryMenu;
@ -152,7 +152,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) {
// fire INVENTORY_CLOSE if one already open
- ((ServerPlayer) this.getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(this.getHandle().containerMenu.containerId));
+ ((ServerPlayer) this.getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(this.getHandle().containerMenu.containerId), org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper
+ ((ServerPlayer) this.getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(this.getHandle().containerMenu.containerId), org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason
}
ServerPlayer player = (ServerPlayer) this.getHandle();
AbstractContainerMenu container;
@ -161,14 +161,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public void closeInventory() {
- this.getHandle().closeContainer();
+ // Paper start
+ // Paper start - Inventory close reason
+ this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.PLUGIN);
}
+ @Override
+ public void closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
+ getHandle().closeContainer(reason);
+ }
+ // Paper end
+ // Paper end - Inventory close reason
@Override
public boolean isBlocking() {
@ -181,7 +181,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Close any foreign inventory
if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) {
- this.getHandle().closeContainer();
+ this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper
+ this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper - Inventory close reason
}
// Check if the fromWorld and toWorld are the same.
@ -194,7 +194,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public static AbstractContainerMenu callInventoryOpenEvent(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) {
if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open
- player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId));
+ player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper
+ player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason
}
CraftServer server = player.level().getCraftServer();

View file

@ -13,13 +13,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Item item = this.useItem.getItem();
- return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem) - this.useItemRemaining >= 5;
+ return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem) - this.useItemRemaining >= getShieldBlockingDelay(); // Paper - shieldBlockingDelay
+ return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem) - this.useItemRemaining >= getShieldBlockingDelay(); // Paper - Make shield blocking delay configurable
} else {
return false;
}
}
+ // Paper start
+ // Paper start - Make shield blocking delay configurable
+ public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay;
+
+ public int getShieldBlockingDelay() {
@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public void setShieldBlockingDelay(int shieldBlockingDelay) {
+ this.shieldBlockingDelay = shieldBlockingDelay;
+ }
+ // Paper end
+ // Paper end - Make shield blocking delay configurable
+
public boolean isSuppressingSlidingDownLadder() {
return this.isShiftKeyDown();

View file

@ -1250,7 +1250,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ @Override
+ public void setConversionTime(int time, boolean broadcastEntityEvent) {
+ // Paper stop - missing entity behaviour api - converting without entity event
+ // Paper end - missing entity behaviour api - converting without entity event
if (time < 0) {
this.getHandle().villagerConversionTime = -1;
this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.ZombieVillager.DATA_CONVERTING_ID, false);

View file

@ -211,7 +211,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Close any foreign inventory
- if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) {
+ if (this.getHandle().containerMenu != this.getHandle().inventoryMenu && !allFlags.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_OPEN_INVENTORY)) { // Paper
this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper
this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper - Inventory close reason
}
// Check if the fromWorld and toWorld are the same.

View file

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Nullable
public Packet<?> createPacket(int id, FriendlyByteBuf buf) {
+ if (id < 0 || id >= this.idToDeserializer.size()) return null; // Paper - Perf: Optmize exception handling
+ if (id < 0 || id >= this.idToDeserializer.size()) return null; // Paper - Perf: Optimize exception handling
Function<FriendlyByteBuf, ? extends Packet<? super T>> function = this.idToDeserializer.get(id);
return function != null ? function.apply(buf) : null;
}
@ -24,12 +24,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) {
+ // Paper start - Perf: Optmize exception handling; if channel is not active just discard the packet
+ // Paper start - Perf: Optimize exception handling; if channel is not active just discard the packet
+ if (!channelHandlerContext.channel().isActive()) {
+ byteBuf.skipBytes(byteBuf.readableBytes());
+ return;
+ }
+ // Paper end - Perf: Optmize exception handling
+ // Paper end - Perf: Optimize exception handling
byteBuf.markReaderIndex();
this.helperBuf.clear();
if (!copyVarint(byteBuf, this.helperBuf)) {

View file

@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
protected void pushEntities() {
+ if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper
+ if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox(), ArmorStand.RIDABLE_MINECARTS);
Iterator iterator = list.iterator();
@ -24,13 +24,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper end
}
}
+ // Paper start - Prevent armor stands from doing entity lookups
+ // Paper start - Option to prevent armor stands from doing entity lookups
+ @Override
+ public boolean noCollision(@Nullable Entity entity, AABB box) {
+ if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false;
+ return LevelAccessor.super.noCollision(entity, box);
+ }
+ // Paper end
+ // Paper end - Option to prevent armor stands from doing entity lookups
public boolean shouldTickDeath(Entity entity) {
return true;

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
fireworkRocketEntity.spawningEntity = user.getUUID(); // Paper
- world.addFreshEntity(fireworkRocketEntity);
- if (!user.getAbilities().instabuild) {
+ // Paper start
+ // Paper start - PlayerElytraBoostEvent
+ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.getBukkitEntity());
+ if (event.callEvent() && world.addFreshEntity(fireworkRocketEntity)) {
+ user.awardStat(Stats.ITEM_USED.get(this));
@ -23,11 +23,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } else ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
+ // Paper end
+ // Paper end - PlayerElytraBoostEvent
}
- user.awardStat(Stats.ITEM_USED.get(this));
+ // user.awardStat(Stats.ITEM_USED.get(this)); // Paper - move up
+ // user.awardStat(Stats.ITEM_USED.get(this)); // Paper - PlayerElytraBoostEvent; move up
}
return InteractionResultHolder.sidedSuccess(user.getItemInHand(hand), world.isClientSide());

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entityegg.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
- // CraftBukkit start
- if (!world.addFreshEntity(entityegg)) {
+ // Paper start
+ // Paper start - PlayerLaunchProjectileEvent
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityegg.getBukkitEntity());
+ if (event.callEvent() && world.addFreshEntity(entityegg)) {
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
@ -32,16 +32,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return InteractionResultHolder.fail(itemstack);
}
- // CraftBukkit end
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
}
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ /* // Paper start - moved up
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
user.awardStat(Stats.ITEM_USED.get(this));
if (!user.getAbilities().instabuild) {
itemstack.shrink(1);
}
+ */ // Paper end
+ */ // Paper end - PlayerLaunchProjectileEvent
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
}
@ -54,8 +54,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entityenderpearl.setItem(itemstack);
entityenderpearl.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
- if (!world.addFreshEntity(entityenderpearl)) {
+ // Paper start
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityenderpearl.getBukkitEntity());
+ // Paper start - PlayerLaunchProjectileEvent
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityenderpearl.getBukkitEntity());
+ if (event.callEvent() && world.addFreshEntity(entityenderpearl)) {
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
+ itemstack.shrink(1);
@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ user.awardStat(Stats.ITEM_USED.get(this));
+ user.getCooldowns().addCooldown(this, 20);
+ } else {
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
if (user instanceof net.minecraft.server.level.ServerPlayer) {
((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
}
@ -75,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
}
+ /* // Paper start - moved up
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
user.getCooldowns().addCooldown(this, 20);
// CraftBukkit end
@ -83,7 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (!user.getAbilities().instabuild) {
itemstack.shrink(1);
}
+ */ // Paper end - moved up
+ */ // Paper end - PlayerLaunchProjectileEvent; moved up
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
}
@ -96,13 +96,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
ItemStack itemStack = user.getItemInHand(hand);
- world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ // world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // Paper - moved down
+ // world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // Paper - PlayerLaunchProjectileEvent; moved down
if (!world.isClientSide) {
ThrownExperienceBottle thrownExperienceBottle = new ThrownExperienceBottle(world, user);
thrownExperienceBottle.setItem(itemStack);
thrownExperienceBottle.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.7F, 1.0F);
- world.addFreshEntity(thrownExperienceBottle);
+ // Paper start
+ // Paper start - PlayerLaunchProjectileEvent
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) thrownExperienceBottle.getBukkitEntity());
+ if (event.callEvent() && world.addFreshEntity(thrownExperienceBottle)) {
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
@ -119,15 +119,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ return InteractionResultHolder.fail(itemStack);
+ }
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
}
+ /* // Paper start - moved up
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
user.awardStat(Stats.ITEM_USED.get(this));
if (!user.getAbilities().instabuild) {
itemStack.shrink(1);
}
+ */ // Paper end
+ */ // Paper end - PlayerLaunchProjectileEvent
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
}
@ -146,7 +146,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (!event.callEvent() || !level.addFreshEntity(fireworkRocketEntity)) return InteractionResult.PASS;
+ if (event.shouldConsume() && !context.getPlayer().getAbilities().instabuild) itemStack.shrink(1);
+ else if (context.getPlayer() instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) context.getPlayer()).getBukkitEntity().updateInventory();
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
}
return InteractionResult.sidedSuccess(level.isClientSide);
@ -158,14 +158,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
+ // Paper start
+ // Paper start - PlayerLaunchProjectileEvent
+ InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand);
+ if (wrapper.getResult() != net.minecraft.world.InteractionResult.FAIL) {
world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.LINGERING_POTION_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
- return super.use(world, user, hand);
+ }
+ return wrapper;
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
}
}
diff --git a/src/main/java/net/minecraft/world/item/SnowballItem.java b/src/main/java/net/minecraft/world/item/SnowballItem.java
@ -178,28 +178,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entitysnowball.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F);
- if (world.addFreshEntity(entitysnowball)) {
- if (!user.getAbilities().instabuild) {
+ // Paper start
+ // Paper start - PlayerLaunchProjectileEvent
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitysnowball.getBukkitEntity());
+ if (event.callEvent() && world.addFreshEntity(entitysnowball)) {
+ user.awardStat(Stats.ITEM_USED.get(this));
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
itemstack.shrink(1);
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) { // Paper
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper
+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) { // Paper - PlayerLaunchProjectileEvent
+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper - PlayerLaunchProjectileEvent
}
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.SNOWBALL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
- } else if (user instanceof net.minecraft.server.level.ServerPlayer) {
- ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
+ } else { // Paper
+ if (user instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper
+ return InteractionResultHolder.fail(itemstack); // Paper
+ } else { // Paper - PlayerLaunchProjectileEvent
+ if (user instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper - PlayerLaunchProjectileEvent
+ return InteractionResultHolder.fail(itemstack); // Paper - PlayerLaunchProjectileEvent
}
}
// CraftBukkit end
+ /* // Paper tart - moved up
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
user.awardStat(Stats.ITEM_USED.get(this));
// CraftBukkit start - moved up
/*
@ -207,7 +207,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
itemstack.shrink(1);
}
*/
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
}
@ -219,14 +219,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
+ // Paper start
+ // Paper start - PlayerLaunchProjectileEvent
+ InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand);
+ if (wrapper.getResult() != net.minecraft.world.InteractionResult.FAIL) {
world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.SPLASH_POTION_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
- return super.use(world, user, hand);
+ }
+ return wrapper;
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
}
}
diff --git a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java
@ -238,7 +238,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
thrownPotion.setItem(itemStack);
thrownPotion.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.5F, 1.0F);
- world.addFreshEntity(thrownPotion);
+ // Paper start
+ // Paper start - PlayerLaunchProjectileEvent
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) thrownPotion.getBukkitEntity());
+ if (event.callEvent() && world.addFreshEntity(thrownPotion)) {
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
@ -254,10 +254,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ return InteractionResultHolder.fail(itemStack);
+ }
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
}
+ /* // Paper start - moved up
+ /* // Paper start - PlayerLaunchProjectileEvent; moved up
user.awardStat(Stats.ITEM_USED.get(this));
if (!user.getAbilities().instabuild) {
itemStack.shrink(1);
@ -275,27 +275,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start
- if (!world.addFreshEntity(entitythrowntrident)) {
+ // Paper start
+ // Paper start - PlayerLaunchProjectileEvent
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), (org.bukkit.entity.Projectile) entitythrowntrident.getBukkitEntity());
+ if (!event.callEvent() || !world.addFreshEntity(entitythrowntrident)) {
+ // Paper end
+ // Paper end - PlayerLaunchProjectileEvent
if (entityhuman instanceof net.minecraft.server.level.ServerPlayer) {
((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().updateInventory();
}
return;
}
+ if (event.shouldConsume()) { // Paper
+ if (event.shouldConsume()) { // Paper - PlayerLaunchProjectileEvent
stack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
entityhuman1.broadcastBreakEvent(user.getUsedItemHand());
});
+ } // Paper
+ } // Paper - PlayerLaunchProjectileEvent
entitythrowntrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved
// CraftBukkit end
world.playSound((Player) null, (Entity) entitythrowntrident, SoundEvents.TRIDENT_THROW, SoundSource.PLAYERS, 1.0F, 1.0F);
- if (!entityhuman.getAbilities().instabuild) {
+ if (event.shouldConsume() && !entityhuman.getAbilities().instabuild) { // Paper
+ if (event.shouldConsume() && !entityhuman.getAbilities().instabuild) { // Paper - PlayerLaunchProjectileEvent
entityhuman.getInventory().removeItem(stack);
}
// CraftBukkit start - SPIGOT-5458 also need in this branch :(

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING);
}
+ // Paper start
+ // Paper start - PlayerReadyArrowEvent
+ protected boolean tryReadyArrow(ItemStack bow, ItemStack itemstack) {
+ return !(this instanceof ServerPlayer) ||
+ new com.destroystokyo.paper.event.player.PlayerReadyArrowEvent(
@ -22,8 +22,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(bow),
+ org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)
+ ).callEvent();
+ // Paper end
+ }
+ // Paper end - PlayerReadyArrowEvent
+
@Override
public ItemStack getProjectile(ItemStack stack) {
@ -31,14 +31,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return ItemStack.EMPTY;
} else {
- Predicate<ItemStack> predicate = ((ProjectileWeaponItem) stack.getItem()).getSupportedHeldProjectiles();
+ Predicate<ItemStack> predicate = ((ProjectileWeaponItem) stack.getItem()).getSupportedHeldProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper
+ Predicate<ItemStack> predicate = ((ProjectileWeaponItem) stack.getItem()).getSupportedHeldProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper - PlayerReadyArrowEvent
ItemStack itemstack1 = ProjectileWeaponItem.getHeldProjectile(this, predicate);
if (!itemstack1.isEmpty()) {
return itemstack1;
} else {
- predicate = ((ProjectileWeaponItem) stack.getItem()).getAllSupportedProjectiles();
+ predicate = ((ProjectileWeaponItem) stack.getItem()).getAllSupportedProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper
+ predicate = ((ProjectileWeaponItem) stack.getItem()).getAllSupportedProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper - PlayerReadyArrowEvent
for (int i = 0; i < this.inventory.getContainerSize(); ++i) {
ItemStack itemstack2 = this.inventory.getItem(i);

View file

@ -1,33 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 10 Mar 2018 16:33:15 -0500
Subject: [PATCH] Prevent Frosted Ice from loading/holding chunks
1.17: Shouldn't be needed as blocks no longer tick without at least 1 radius chunk loaded.
diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
@@ -0,0 +0,0 @@ public class FrostedIceBlock extends IceBlock {
for(Direction direction : Direction.values()) {
mutableBlockPos.setWithOffset(pos, direction);
- BlockState blockState = world.getBlockState(mutableBlockPos);
+ BlockState blockState = world.getBlockStateIfLoaded(mutableBlockPos); // Paper
+ if (blockState == null) { continue; } // Paper
if (blockState.is(this) && !this.slightlyMelt(blockState, world, mutableBlockPos)) {
world.scheduleTick(mutableBlockPos, this, Mth.nextInt(random, world.paperConfig().environment.frostedIce.delay.min, world.paperConfig().environment.frostedIce.delay.max)); // Paper - use configurable min/max delay
}
@@ -0,0 +0,0 @@ public class FrostedIceBlock extends IceBlock {
for(Direction direction : Direction.values()) {
mutableBlockPos.setWithOffset(pos, direction);
- if (world.getBlockState(mutableBlockPos).is(this)) {
+ // Paper start
+ BlockState blockState = world.getBlockStateIfLoaded(mutableBlockPos);
+ if (blockState != null && blockState.is(this)) {
+ // Paper end
++i;
if (i >= maxNeighbors) {
return false;

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// Paper end
- if (!this.level().isClientSide && !this.containerMenu.stillValid(this)) {
+ if (!this.level().isClientSide && this.containerMenu != this.inventoryMenu && (this.isImmobile() || !this.containerMenu.stillValid(this))) { // Paper - Prevent opening inventories when frozen
this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper
this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper - Inventory close reason
this.containerMenu = this.inventoryMenu;
}
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Util.safeReplaceFile(path2, path1, path3);
} catch (Exception exception) {
- PlayerDataStorage.LOGGER.warn("Failed to save player data for {}", player.getName().getString());
+ PlayerDataStorage.LOGGER.warn("Failed to save player data for {}", player.getScoreboardName(), exception); // Paper
+ PlayerDataStorage.LOGGER.warn("Failed to save player data for {}", player.getScoreboardName(), exception); // Paper - Print exception
}
}

View file

@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
if (event.isCancelled()) {
+ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - Refresh player inventory
+ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - Refresh player inventory
return;
}
// CraftBukkit end

View file

@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ client.running = false;
+ }
+ }
+ // Paper stop - don't wait for remote connections
+ // Paper end - don't wait for remote connections
private void closeSocket(ServerSocket socket) {
LOGGER.debug("closeSocket: {}", (Object)socket);

View file

@ -14,11 +14,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
if (itemstack.is(Items.POTION)) {
- List<MobEffectInstance> list = PotionUtils.getMobEffects(itemstack);
+ // Paper start
+ // Paper start - WitchConsumePotionEvent
+ com.destroystokyo.paper.event.entity.WitchConsumePotionEvent event = new com.destroystokyo.paper.event.entity.WitchConsumePotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack));
+
+ List<MobEffectInstance> list = event.callEvent() ? PotionUtils.getMobEffects(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion())) : null;
+ // Paper end
+ // Paper end - WitchConsumePotionEvent
if (list != null) {
Iterator iterator = list.iterator();

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
potionregistry = Potions.WEAKNESS;
}
+ // Paper start
+ // Paper start - WitchThrowPotionEvent
+ ItemStack potion = PotionUtils.setPotion(new ItemStack(Items.SPLASH_POTION), potionregistry);
+ com.destroystokyo.paper.event.entity.WitchThrowPotionEvent event = new com.destroystokyo.paper.event.entity.WitchThrowPotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), (org.bukkit.entity.LivingEntity) target.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(potion));
+ if (!event.callEvent()) {
@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
-
- entitypotion.setItem(PotionUtils.setPotion(new ItemStack(Items.SPLASH_POTION), potionregistry));
+ entitypotion.setItem(potion);
+ // Paper end
+ // Paper end - WitchThrowPotionEvent
entitypotion.setXRot(entitypotion.getXRot() - -20.0F);
entitypotion.shoot(d0, d1 + d3 * 0.2D, d2, 0.75F, 8.0F);
if (!this.isSilent()) {

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
String s = this.level() == null ? "~NULL~" : this.level().toString();
- return this.removalReason != null ? String.format(Locale.ROOT, "%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f, removed=%s]", this.getClass().getSimpleName(), this.getName().getString(), this.id, s, this.getX(), this.getY(), this.getZ(), this.removalReason) : String.format(Locale.ROOT, "%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f]", this.getClass().getSimpleName(), this.getName().getString(), this.id, s, this.getX(), this.getY(), this.getZ());
+ return this.removalReason != null ? String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b, removed=%s]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid, this.removalReason) : String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid);
+ return this.removalReason != null ? String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b, removed=%s]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid, this.removalReason) : String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid); // Paper - add more info
}
public boolean isInvulnerableTo(DamageSource damageSource) {