mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 20:07:41 +01:00
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent 258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD CraftBukkit Changes: 98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent 5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class 76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor Spigot Changes: e9ec5485 Rebuild patches f1b62e0c Rebuild patches
This commit is contained in:
parent
e33fdd8189
commit
1863ac217f
@ -10,9 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+++ b/src/main/java/org/bukkit/block/Sign.java
|
||||
@@ -0,0 +0,0 @@ public interface Sign extends TileState, Colorable {
|
||||
*/
|
||||
@NotNull
|
||||
public SignSide getSide(@NotNull Side side);
|
||||
+
|
||||
@Nullable
|
||||
public Player getAllowedEditor();
|
||||
+ // Paper start - get side for player
|
||||
+ /**
|
||||
+ * Compute the side facing the specified entity.
|
||||
|
@ -1,23 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 3 Jan 2021 20:03:40 -0800
|
||||
Subject: [PATCH] Added missing vanilla tags
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/Tag.java
|
||||
+++ b/src/main/java/org/bukkit/Tag.java
|
||||
@@ -0,0 +0,0 @@ public interface Tag<T extends Keyed> extends Keyed {
|
||||
* Vanilla item tag representing all chest boat items.
|
||||
*/
|
||||
Tag<Material> ITEMS_CHEST_BOATS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chest_boats"), Material.class);
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Vanilla item tag representing all non-flammable wood items.
|
||||
+ */
|
||||
+ Tag<Material> ITEMS_NON_FLAMMABLE_WOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("non_flammable_wood"), Material.class);
|
||||
+ // Paper end
|
||||
/**
|
||||
* Vanilla item tag representing all fish items.
|
||||
*/
|
@ -1598,7 +1598,7 @@ diff --git a/src/main/java/org/bukkit/block/Sign.java b/src/main/java/org/bukkit
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/Sign.java
|
||||
+++ b/src/main/java/org/bukkit/block/Sign.java
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Represents a captured state of either a SignPost or a WallSign.
|
||||
*/
|
||||
public interface Sign extends TileState, Colorable {
|
||||
|
@ -104,3 +104,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java b/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
+import com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
||||
* This event should only be used for monitoring. The result
|
||||
* of modifying the entity during or after this event is unspecified.
|
||||
* This event is not called for a {@link org.bukkit.entity.Player}.
|
||||
+ * @deprecated use {@link EntityRemoveFromWorldEvent} instead
|
||||
*/
|
||||
-@ApiStatus.Experimental
|
||||
+@Deprecated(forRemoval = true)
|
||||
public class EntityRemoveEvent extends EntityEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
@@ -0,0 +0,0 @@ public class EntityRemoveEvent extends EntityEvent {
|
||||
* When the chunk an entity is in gets unloaded.
|
||||
*/
|
||||
UNLOAD,
|
||||
+ DISCARD
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ int i = Math.min(orb.xpToDurability(amount), itemstack.getDamageValue());
|
||||
+ org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i);
|
||||
+ i = event.getRepairAmount();
|
||||
+ orb.discard();
|
||||
+ orb.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ amount -= orb.durabilityToXp(i);
|
||||
+ itemstack.setDamageValue(itemstack.getDamageValue() - i);
|
||||
|
@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ public void setHealth(int health) {
|
||||
+ if (health <= 0) {
|
||||
+ this.getHandle().getItem().onDestroyed(this.getHandle());
|
||||
+ this.getHandle().discard();
|
||||
+ this.getHandle().discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PLUGIN);
|
||||
+ } else {
|
||||
+ this.getHandle().health = health;
|
||||
+ }
|
||||
|
@ -63,10 +63,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/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 {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event;
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), cause));
|
||||
}
|
||||
+
|
||||
+ // Paper start - PlayerUseUnknownEntityEvent
|
||||
+ public static void callPlayerUseUnknownEntityEvent(net.minecraft.world.entity.player.Player player, net.minecraft.network.protocol.game.ServerboundInteractPacket packet, InteractionHand hand, @Nullable net.minecraft.world.phys.Vec3 vector) {
|
||||
+ new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
|
||||
|
@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
int j = i * i;
|
||||
|
||||
if (d0 > (double) j && this.removeWhenFarAway(d0)) {
|
||||
this.discard();
|
||||
this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
- int k = this.getType().getCategory().getNoDespawnDistance();
|
||||
|
@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
if (!this.level().isClientSide()) {
|
||||
Cow entitycow = (Cow) EntityType.COW.create(this.level());
|
||||
@@ -0,0 +0,0 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder<Mushroo
|
||||
this.discard(); // CraftBukkit - from above
|
||||
this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - from above and add Bukkit remove cause
|
||||
// CraftBukkit end
|
||||
|
||||
- for (int i = 0; i < 5; ++i) {
|
||||
|
@ -89,7 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
|
||||
MinecraftServer.LOGGER.error(msg, throwable);
|
||||
+ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable))); // Paper - ServerExceptionEvent
|
||||
entity.discard();
|
||||
entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
||||
// Paper end - Prevent block entity and entity crashes
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
|
@ -3154,10 +3154,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
} else if (!this.isWhiteListed(gameprofile)) {
|
||||
ichatmutablecomponent = Component.translatable("multiplayer.disconnect.not_whitelisted");
|
||||
- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot
|
||||
- } else if (this.ipBans.isBanned(socketaddress)) {
|
||||
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure
|
||||
} else if (this.getIpBans().isBanned(socketaddress) && !this.getIpBans().get(socketaddress).hasExpired()) {
|
||||
+ } else if (this.getIpBans().isBanned(socketaddress) && !this.getIpBans().get(socketaddress).hasExpired()) {
|
||||
IpBanListEntry ipbanentry = this.ipBans.get(socketaddress);
|
||||
|
||||
ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
|
||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
++this.life;
|
||||
- if (this.life >= ((this instanceof ThrownTrident) ? this.level().spigotConfig.tridentDespawnRate : this.level().spigotConfig.arrowDespawnRate)) { // Spigot
|
||||
+ if (this.life >= (pickup == Pickup.CREATIVE_ONLY ? this.level().paperConfig().entities.spawning.creativeArrowDespawnRate.value() : (pickup == Pickup.DISALLOWED ? this.level().paperConfig().entities.spawning.nonPlayerArrowDespawnRate.value() : ((this instanceof ThrownTrident) ? this.level().spigotConfig.tridentDespawnRate : this.level().spigotConfig.arrowDespawnRate)))) { // Spigot // Paper - Configurable non-player arrow despawn rate; TODO: Extract this to init?
|
||||
this.discard();
|
||||
this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ this.spawnAtLocation(block);
|
||||
+ }
|
||||
+
|
||||
+ this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Configurable falling blocks height nerf
|
||||
@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
+ // Paper start - Configurable TNT height nerf
|
||||
+ if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
|
||||
+ this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Configurable TNT height nerf
|
||||
@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
if (this.fuse > 0) {
|
||||
+ // Paper start - Configurable TNT height nerf
|
||||
+ if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
|
||||
+ this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Configurable TNT height nerf
|
||||
|
@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
entity.discard();
|
||||
entity.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
needsRemoval = true;
|
||||
}
|
||||
+ checkDupeUUID(world, entity); // Paper - duplicate uuid resolving
|
||||
@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ && Objects.equals(other.getEncodeId(), entity.getEncodeId())
|
||||
+ && entity.getBukkitEntity().getLocation().distance(other.getBukkitEntity().getLocation()) < level.paperConfig().entities.spawning.duplicateUuid.safeRegenDeleteRange
|
||||
+ ) {
|
||||
+ entity.discard();
|
||||
+ entity.discard(null);
|
||||
+ return true;
|
||||
+ }
|
||||
+ if (!other.isRemoved()) {
|
||||
@ -77,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ break;
|
||||
+ }
|
||||
+ case DELETE: {
|
||||
+ entity.discard();
|
||||
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
||||
+ return true;
|
||||
+ }
|
||||
+ default:
|
||||
|
@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
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 - EnderDragon Events
|
||||
this.dragon.level().addFreshEntity(dragonFireball);
|
||||
+ else dragonFireball.discard(); // Paper - EnderDragon Events
|
||||
+ else dragonFireball.discard(null); // 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 - EnderDragon Events
|
||||
+ 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) entityareaeffectcloud.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events
|
||||
this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
|
||||
this.level().addFreshEntity(areaEffectCloud);
|
||||
+ } else areaEffectCloud.discard(); // Paper - EnderDragon Events
|
||||
this.discard();
|
||||
this.level().addFreshEntity(entityareaeffectcloud);
|
||||
+ } else entityareaeffectcloud.discard(null); // Paper - EnderDragon Events
|
||||
this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper end - EntityPickupItemEvent fixes
|
||||
piglin.take(drop, drop.getItem().getCount());
|
||||
itemstack = drop.getItem();
|
||||
drop.discard();
|
||||
drop.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
} else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, drop, drop.getItem().getCount() - 1, false).isCancelled()) {
|
||||
+ piglin.onItemPickup(drop); // Paper - EntityPickupItemEvent fixes; moved from Piglin#pickUpItem - call prior to item entity modification
|
||||
piglin.take(drop, 1);
|
||||
|
@ -16,4 +16,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved() || (!event.allowsEmptyCreation() && (noEffects && entityareaeffectcloud.effects.isEmpty() && entityareaeffectcloud.getPotion().getEffects().isEmpty())))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling
|
||||
this.level().addFreshEntity(entityareaeffectcloud);
|
||||
} else {
|
||||
entityareaeffectcloud.discard();
|
||||
entityareaeffectcloud.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
|
@ -43,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i);
|
||||
+ org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, stackEntry.getKey(), i, orb::durabilityToXp); // Paper - Expand PlayerItemMendEvent
|
||||
i = event.getRepairAmount();
|
||||
orb.discard();
|
||||
orb.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
|
||||
if (!event.isCancelled()) {
|
||||
- amount -= orb.durabilityToXp(i);
|
||||
+ amount -= event.getDurabilityToXpOperation().applyAsInt(i); // Paper - Expand PlayerItemMendEvent
|
||||
|
@ -269,7 +269,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
- ExperienceOrb.award((ServerLevel) this.level(), this.position(), i);
|
||||
+ ExperienceOrb.award((ServerLevel) this.level(), this.position(), i, org.bukkit.entity.ExperienceOrb.SpawnReason.EXP_BOTTLE, this.getOwner(), this); // Paper
|
||||
this.discard();
|
||||
this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
||||
|
@ -21,6 +21,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ // Paper end - Fire entity death event
|
||||
+
|
||||
this.remove(Entity.RemovalReason.KILLED);
|
||||
this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
if (this.dragonFight != null) {
|
||||
|
@ -180,11 +180,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
Player player = entity.getBukkitEntity();
|
||||
PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.connection.channel.remoteAddress()).getAddress());
|
||||
|
||||
- if (this.getBans().isBanned(gameprofile) && !this.getBans().get(gameprofile).hasExpired()) {
|
||||
- if (this.bans.isBanned(gameprofile)) {
|
||||
- UserBanListEntry gameprofilebanentry = (UserBanListEntry) this.bans.get(gameprofile);
|
||||
+ // Paper start - Fix MC-158900
|
||||
+ UserBanListEntry gameprofilebanentry;
|
||||
+ if (getBans().isBanned(gameprofile) && (gameprofilebanentry = getBans().get(gameprofile)) != null) {
|
||||
+ if (this.bans.isBanned(gameprofile) && (gameprofilebanentry = this.bans.get(gameprofile)) != null) {
|
||||
+ // Paper end - Fix MC-158900
|
||||
|
||||
ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
|
||||
|
@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
this.level().levelEvent(i, this.blockPosition(), PotionUtils.getColor(itemstack));
|
||||
+ } // Paper - Fix potions splash events
|
||||
this.discard();
|
||||
this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved() || (noEffects && entityareaeffectcloud.effects.isEmpty() && entityareaeffectcloud.getPotion().getEffects().isEmpty()))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling
|
||||
this.level().addFreshEntity(entityareaeffectcloud);
|
||||
} else {
|
||||
entityareaeffectcloud.discard();
|
||||
entityareaeffectcloud.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ return !event.isCancelled(); // Paper - Fix potions splash events
|
||||
|
@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ // Paper end - fix sand duping
|
||||
if (this.blockState.isAir()) {
|
||||
this.discard();
|
||||
this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
} else {
|
||||
@@ -0,0 +0,0 @@ public class FallingBlockEntity extends Entity {
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - Fix villager boat exploit
|
||||
entity1.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
entity1.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause
|
||||
});
|
||||
}
|
||||
|
@ -26,12 +26,12 @@ 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 - EnderDragon Events
|
||||
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) entityareaeffectcloud.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 - EnderDragon Events
|
||||
this.discard();
|
||||
- this.level().addFreshEntity(entityareaeffectcloud);
|
||||
+ this.level().addFreshEntity(entityareaeffectcloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // Paper - use correct spawn reason
|
||||
} else entityareaeffectcloud.discard(null); // Paper - EnderDragon Events
|
||||
this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
|
@ -1214,19 +1214,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public CommandSender getBukkitSender(CommandSourceStack wrapper) {
|
||||
return this.getBukkitEntity();
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
|
||||
@Override
|
||||
public final void setRemoved(Entity.RemovalReason reason) {
|
||||
public final void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
|
||||
CraftEventFactory.callEntityRemoveEvent(this, cause);
|
||||
// CraftBukkit end
|
||||
+ final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
|
||||
if (this.removalReason == null) {
|
||||
this.removalReason = reason;
|
||||
this.removalReason = entity_removalreason;
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
|
||||
this.getPassengers().forEach(Entity::stopRiding);
|
||||
this.levelCallback.onRemove(reason);
|
||||
this.levelCallback.onRemove(entity_removalreason);
|
||||
+ // Paper start - Folia schedulers
|
||||
+ if (!(this instanceof ServerPlayer) && reason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
|
||||
+ if (!(this instanceof ServerPlayer) && entity_removalreason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
|
||||
+ // Players need to be special cased, because they are regularly removed from the world
|
||||
+ this.retireScheduler();
|
||||
+ }
|
||||
|
@ -367,7 +367,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- this.brokenByPlayer(source);
|
||||
+ org.bukkit.event.entity.EntityDeathEvent event = this.brokenByPlayer(source); // Paper
|
||||
this.showBreakingParticles();
|
||||
- this.discard(); // 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(false); // Paper - we still need to kill to follow vanilla logic (emit the game event etc...)
|
||||
}
|
||||
|
||||
@ -431,7 +431,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, this.drops); // CraftBukkit - call event // Paper - make cancellable
|
||||
+ if (event.isCancelled()) return; // Paper - make cancellable
|
||||
+ } // Paper
|
||||
this.remove(Entity.RemovalReason.KILLED);
|
||||
this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
|
@ -122,6 +122,51 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
||||
@@ -0,0 +0,0 @@ public class TranslatableContents implements ComponentContents {
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> visitor) {
|
||||
+ // Paper start
|
||||
+ try {
|
||||
+ return this.visit(new TranslatableContentConsumer<>(visitor));
|
||||
+ } catch (IllegalArgumentException var5) {
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ }
|
||||
+ private <T> Optional<T> visit(TranslatableContentConsumer<T> visitor) {
|
||||
+ // Paper end
|
||||
this.decompose();
|
||||
|
||||
for(FormattedText formattedText : this.decomposedParts) {
|
||||
@@ -0,0 +0,0 @@ public class TranslatableContents implements ComponentContents {
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
+ // Paper start
|
||||
+ private static final class TranslatableContentConsumer<T> implements FormattedText.ContentConsumer<T> {
|
||||
+ private final FormattedText.ContentConsumer<T> visitor;
|
||||
+ private int visited;
|
||||
+
|
||||
+ private TranslatableContentConsumer(FormattedText.ContentConsumer<T> visitor) {
|
||||
+ this.visitor = visitor;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Optional<T> accept(final String asString) {
|
||||
+ if (visited++ > 32) {
|
||||
+ throw new IllegalArgumentException("Too long");
|
||||
+ }
|
||||
+ return this.visitor.accept(asString);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
public MutableComponent resolve(@Nullable CommandSourceStack source, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java
|
||||
|
@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ xp.value = maxValue;
|
||||
+ } else {
|
||||
xp.value += loopItem.value;
|
||||
loopItem.discard();
|
||||
loopItem.discard(null); // Add Bukkit remove cause
|
||||
+ } // Paper end - Maximum exp value when merging
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
|
||||
this.discard();
|
||||
this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
|
||||
- Player entityhuman = this.level().getNearestPlayer(this, -1.0D);
|
||||
+ Player entityhuman = this.level().findNearbyPlayer(this, -1.0D, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper - Affects Spawning API
|
||||
|
@ -8,8 +8,8 @@ diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
// CraftBukkit end
|
||||
+import org.bukkit.event.player.PlayerAttemptPickupItemEvent; // Paper
|
||||
|
@ -38,4 +38,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ if (flyAtPlayer) // Paper - PlayerPickupItemEvent
|
||||
player.take(this, i);
|
||||
if (itemstack.isEmpty()) {
|
||||
this.discard();
|
||||
this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
|
@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper start - Prevent block entity and entity crashes
|
||||
+ final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
|
||||
+ MinecraftServer.LOGGER.error(msg, throwable);
|
||||
+ entity.discard();
|
||||
+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
||||
+ // Paper end - Prevent block entity and entity crashes
|
||||
}
|
||||
}
|
||||
|
@ -14926,6 +14926,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import java.util.Iterator;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Predicate;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+
|
||||
+public final class ChunkEntitySlices {
|
||||
+
|
||||
@ -15021,12 +15022,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (entity.shouldBeSaved()) {
|
||||
+ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK);
|
||||
+ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveEvent.Cause.UNLOAD);
|
||||
+ if (entity.isVehicle()) {
|
||||
+ // we cannot assume that these entities are contained within this chunk, because entities can
|
||||
+ // desync - so we need to remove them all
|
||||
+ for (final Entity passenger : entity.getIndirectPassengers()) {
|
||||
+ passenger.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK);
|
||||
+ passenger.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveEvent.Cause.UNLOAD);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@ -19480,7 +19481,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
|
||||
@Override
|
||||
public final void setRemoved(Entity.RemovalReason reason) {
|
||||
public final void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
|
||||
+ // Paper start - rewrite chunk system
|
||||
+ io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot remove entity off-main");
|
||||
+ if (!((ServerLevel)this.level).getEntityLookup().canRemoveEntity(this)) {
|
||||
@ -19488,18 +19489,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - rewrite chunk system
|
||||
CraftEventFactory.callEntityRemoveEvent(this, cause);
|
||||
// CraftBukkit end
|
||||
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
|
||||
if (this.removalReason == null) {
|
||||
this.removalReason = reason;
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
this.stopRiding();
|
||||
}
|
||||
|
||||
- this.getPassengers().forEach(Entity::stopRiding);
|
||||
+ if (reason != RemovalReason.UNLOADED_TO_CHUNK) this.getPassengers().forEach(Entity::stopRiding); // Paper - chunk system - don't adjust passenger state when unloading, it's just not safe (and messes with our logic in entity chunk unload)
|
||||
this.levelCallback.onRemove(reason);
|
||||
+ if (entity_removalreason != RemovalReason.UNLOADED_TO_CHUNK) this.getPassengers().forEach(Entity::stopRiding); // Paper - chunk system - don't adjust passenger state when unloading, it's just not safe (and messes with our logic in entity chunk unload)
|
||||
this.levelCallback.onRemove(entity_removalreason);
|
||||
// Paper start - Folia schedulers
|
||||
if (!(this instanceof ServerPlayer) && reason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
|
||||
if (!(this instanceof ServerPlayer) && entity_removalreason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
|
||||
@Override
|
||||
|
@ -58,6 +58,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
|
||||
+ testImplementation("org.hamcrest:hamcrest:2.2")
|
||||
+ testImplementation("org.mockito:mockito-core:5.5.0")
|
||||
+ testImplementation("org.ow2.asm:asm-tree:9.5")
|
||||
+}
|
||||
+
|
||||
+val craftbukkitPackageVersion = "1_20_R3" // Paper
|
||||
@ -474,6 +475,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- <version>5.5.0</version>
|
||||
- <scope>test</scope>
|
||||
- </dependency>
|
||||
- <dependency>
|
||||
- <groupId>org.ow2.asm</groupId>
|
||||
- <artifactId>asm-tree</artifactId>
|
||||
- <version>9.5</version>
|
||||
- <scope>test</scope>
|
||||
- </dependency>
|
||||
- </dependencies>
|
||||
-
|
||||
- <!-- This builds a completely 'ready to start' jar with all dependencies inside -->
|
||||
|
@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -0,0 +0,0 @@ dependencies {
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
|
||||
testImplementation("org.hamcrest:hamcrest:2.2")
|
||||
testImplementation("org.mockito:mockito-core:5.5.0")
|
||||
testImplementation("org.ow2.asm:asm-tree:9.5")
|
||||
+ testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest
|
||||
}
|
||||
|
||||
|
@ -15,5 +15,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- if (!flag) {
|
||||
+ if (!flag && this.level.paperConfig().entities.behavior.shouldRemoveDragon) { // Paper - Toggle for removing existing dragon
|
||||
EndDragonFight.LOGGER.info("But we didn't have a portal, let's remove it.");
|
||||
entityenderdragon.discard();
|
||||
entityenderdragon.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
this.dragonUUID = null;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 58ce1b0f157c419bab3c256659a7e632f91aeb25
|
||||
Subproject commit 9a80d38c002509a4849c5e5f735dca9f9b5731e4
|
@ -1 +1 @@
|
||||
Subproject commit 38fd4bd5034e9adcc0a3122e43eb8d0273d1bc51
|
||||
Subproject commit 98b6c1ac7d4698ded83d96217861b071e519b300
|
@ -1 +1 @@
|
||||
Subproject commit c198da22a814a0ba9c3128c3a9946286e0839b5a
|
||||
Subproject commit e9ec54852f825ba470576cd1b5a33b0d76091fbe
|
Loading…
Reference in New Issue
Block a user