diff --git a/patches/unapplied/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch b/patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch similarity index 100% rename from patches/unapplied/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch rename to patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch diff --git a/patches/unapplied/server/Add-Entity-Body-Yaw-API.patch b/patches/server/Add-Entity-Body-Yaw-API.patch similarity index 100% rename from patches/unapplied/server/Add-Entity-Body-Yaw-API.patch rename to patches/server/Add-Entity-Body-Yaw-API.patch diff --git a/patches/unapplied/server/Add-EntityFertilizeEggEvent.patch b/patches/server/Add-EntityFertilizeEggEvent.patch similarity index 94% rename from patches/unapplied/server/Add-EntityFertilizeEggEvent.patch rename to patches/server/Add-EntityFertilizeEggEvent.patch index 4a981b15dd..77f9effc79 100644 --- a/patches/unapplied/server/Add-EntityFertilizeEggEvent.patch +++ b/patches/server/Add-EntityFertilizeEggEvent.patch @@ -22,9 +22,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class Turtle extends Animal { RandomSource randomsource = this.animal.getRandom(); - if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (getServerLevel((Level) this.level).getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), randomsource.nextInt(7) + 1, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper; -+ if (event.getExperience() > 0) this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), event.getExperience(), org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper - Add EntityFertilizeEggEvent event ++ if (event.getExperience() > 0) this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), randomsource.nextInt(7) + 1, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper - Add EntityFertilizeEggEvent event } } @@ -72,7 +72,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- 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 { +@@ -0,0 +0,0 @@ populateFields(victim, event); // Paper - make cancellable return event.callEvent(); } // Paper end diff --git a/patches/unapplied/server/Add-Mob-Experience-reward-API.patch b/patches/server/Add-Mob-Experience-reward-API.patch similarity index 69% rename from patches/unapplied/server/Add-Mob-Experience-reward-API.patch rename to patches/server/Add-Mob-Experience-reward-API.patch index 180d7621f1..57a564ceb9 100644 --- a/patches/unapplied/server/Add-Mob-Experience-reward-API.patch +++ b/patches/server/Add-Mob-Experience-reward-API.patch @@ -8,14 +8,6 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/mai index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -@@ -0,0 +0,0 @@ - package org.bukkit.craftbukkit.entity; - - import com.google.common.base.Preconditions; -+import net.minecraft.server.level.ServerLevel; - import net.minecraft.sounds.SoundEvent; - import org.bukkit.Sound; - import org.bukkit.craftbukkit.CraftLootTable; @@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { this.getHandle().setAggressive(aggressive); } @@ -24,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override + public int getPossibleExperienceReward() { -+ return getHandle().getExperienceReward((ServerLevel) this.getHandle().level(), null); ++ return getHandle().getExperienceReward((net.minecraft.server.level.ServerLevel) this.getHandle().level(), null); + } + // Paper end } diff --git a/patches/unapplied/server/Add-Shearable-API.patch b/patches/server/Add-Shearable-API.patch similarity index 100% rename from patches/unapplied/server/Add-Shearable-API.patch rename to patches/server/Add-Shearable-API.patch diff --git a/patches/unapplied/server/Avoid-Lazy-Initialization-for-Enum-Fields.patch b/patches/server/Avoid-Lazy-Initialization-for-Enum-Fields.patch similarity index 100% rename from patches/unapplied/server/Avoid-Lazy-Initialization-for-Enum-Fields.patch rename to patches/server/Avoid-Lazy-Initialization-for-Enum-Fields.patch diff --git a/patches/unapplied/server/Break-redstone-on-top-of-trap-doors-early.patch b/patches/server/Break-redstone-on-top-of-trap-doors-early.patch similarity index 100% rename from patches/unapplied/server/Break-redstone-on-top-of-trap-doors-early.patch rename to patches/server/Break-redstone-on-top-of-trap-doors-early.patch diff --git a/patches/unapplied/server/Correctly-handle-ArmorStand-invisibility.patch b/patches/server/Correctly-handle-ArmorStand-invisibility.patch similarity index 100% rename from patches/unapplied/server/Correctly-handle-ArmorStand-invisibility.patch rename to patches/server/Correctly-handle-ArmorStand-invisibility.patch diff --git a/patches/unapplied/server/Expand-PlayerItemMendEvent.patch b/patches/server/Expand-PlayerItemMendEvent.patch similarity index 98% rename from patches/unapplied/server/Expand-PlayerItemMendEvent.patch rename to patches/server/Expand-PlayerItemMendEvent.patch index ceb80423e7..e3c1368d25 100644 --- a/patches/unapplied/server/Expand-PlayerItemMendEvent.patch +++ b/patches/server/Expand-PlayerItemMendEvent.patch @@ -52,7 +52,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- 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 { +@@ -0,0 +0,0 @@ populateFields(victim, event); // Paper - make cancellable return event; } diff --git a/patches/unapplied/server/Fix-HumanEntity-drop-not-updating-the-client-inv.patch b/patches/server/Fix-HumanEntity-drop-not-updating-the-client-inv.patch similarity index 100% rename from patches/unapplied/server/Fix-HumanEntity-drop-not-updating-the-client-inv.patch rename to patches/server/Fix-HumanEntity-drop-not-updating-the-client-inv.patch diff --git a/patches/unapplied/server/Fix-MC-157464-Prevent-sleeping-villagers-moving-towa.patch b/patches/server/Fix-MC-157464-Prevent-sleeping-villagers-moving-towa.patch similarity index 100% rename from patches/unapplied/server/Fix-MC-157464-Prevent-sleeping-villagers-moving-towa.patch rename to patches/server/Fix-MC-157464-Prevent-sleeping-villagers-moving-towa.patch diff --git a/patches/unapplied/server/Fix-SpawnEggMeta-get-setSpawnedType.patch b/patches/server/Fix-SpawnEggMeta-get-setSpawnedType.patch similarity index 100% rename from patches/unapplied/server/Fix-SpawnEggMeta-get-setSpawnedType.patch rename to patches/server/Fix-SpawnEggMeta-get-setSpawnedType.patch diff --git a/patches/unapplied/server/Fix-a-couple-of-upstream-bed-issues.patch b/patches/server/Fix-a-couple-of-upstream-bed-issues.patch similarity index 97% rename from patches/unapplied/server/Fix-a-couple-of-upstream-bed-issues.patch rename to patches/server/Fix-a-couple-of-upstream-bed-issues.patch index 956fe9eb51..6d8ae651e8 100644 --- a/patches/unapplied/server/Fix-a-couple-of-upstream-bed-issues.patch +++ b/patches/server/Fix-a-couple-of-upstream-bed-issues.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java @@ -0,0 +0,0 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); - return InteractionResult.SUCCESS; + return InteractionResult.SUCCESS_SERVER; } else if ((Boolean) state.getValue(BedBlock.OCCUPIED)) { + if (!BedBlock.canSetSpawn(world)) return this.explodeBed(state, world, pos); // Paper - check explode first if (!this.kickVillagerOutOfBed(world, pos)) { diff --git a/patches/unapplied/server/Fix-advancement-triggers-for-entity-damage.patch b/patches/server/Fix-advancement-triggers-for-entity-damage.patch similarity index 100% rename from patches/unapplied/server/Fix-advancement-triggers-for-entity-damage.patch rename to patches/server/Fix-advancement-triggers-for-entity-damage.patch diff --git a/patches/unapplied/server/Fix-crash-relating-to-bad-recipes-in-furnace-like-ti.patch b/patches/server/Fix-crash-relating-to-bad-recipes-in-furnace-like-ti.patch similarity index 78% rename from patches/unapplied/server/Fix-crash-relating-to-bad-recipes-in-furnace-like-ti.patch rename to patches/server/Fix-crash-relating-to-bad-recipes-in-furnace-like-ti.patch index b9174b49ba..034b1ddebf 100644 --- a/patches/unapplied/server/Fix-crash-relating-to-bad-recipes-in-furnace-like-ti.patch +++ b/patches/server/Fix-crash-relating-to-bad-recipes-in-furnace-like-ti.patch @@ -10,10 +10,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit - Entry<ResourceLocation> entry = (Entry) objectiterator.next(); + Entry<ResourceKey<Recipe<?>>> entry = (Entry) objectiterator.next(); - worldserver.getRecipeManager().byKey((ResourceLocation) entry.getKey()).ifPresent((recipeholder) -> { + worldserver.recipeAccess().byKey(entry.getKey()).ifPresent((recipeholder) -> { // CraftBukkit - decompile error + if (!(recipeholder.value() instanceof AbstractCookingRecipe)) return; // Paper - don't process non-cooking recipes list.add(recipeholder); - AbstractFurnaceBlockEntity.createExperience(worldserver, vec3d, entry.getIntValue(), ((AbstractCookingRecipe) recipeholder.value()).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit + AbstractFurnaceBlockEntity.createExperience(worldserver, vec3d, entry.getIntValue(), ((AbstractCookingRecipe) recipeholder.value()).experience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit }); diff --git a/patches/unapplied/server/Fix-demo-flag-not-enabling-demo-mode.patch b/patches/server/Fix-demo-flag-not-enabling-demo-mode.patch similarity index 100% rename from patches/unapplied/server/Fix-demo-flag-not-enabling-demo-mode.patch rename to patches/server/Fix-demo-flag-not-enabling-demo-mode.patch diff --git a/patches/unapplied/server/Fix-force-opening-enchantment-tables.patch b/patches/server/Fix-force-opening-enchantment-tables.patch similarity index 100% rename from patches/unapplied/server/Fix-force-opening-enchantment-tables.patch rename to patches/server/Fix-force-opening-enchantment-tables.patch diff --git a/patches/unapplied/server/Fix-inventories-returning-null-Locations.patch b/patches/server/Fix-inventories-returning-null-Locations.patch similarity index 100% rename from patches/unapplied/server/Fix-inventories-returning-null-Locations.patch rename to patches/server/Fix-inventories-returning-null-Locations.patch diff --git a/patches/unapplied/server/Fix-text-display-error-on-spawn.patch b/patches/server/Fix-text-display-error-on-spawn.patch similarity index 100% rename from patches/unapplied/server/Fix-text-display-error-on-spawn.patch rename to patches/server/Fix-text-display-error-on-spawn.patch diff --git a/patches/unapplied/server/More-accurate-isInOpenWater-impl.patch b/patches/server/More-accurate-isInOpenWater-impl.patch similarity index 100% rename from patches/unapplied/server/More-accurate-isInOpenWater-impl.patch rename to patches/server/More-accurate-isInOpenWater-impl.patch diff --git a/patches/unapplied/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch b/patches/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch similarity index 97% rename from patches/unapplied/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch rename to patches/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch index 57db0faac4..8845dd26bb 100644 --- a/patches/unapplied/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch +++ b/patches/server/Prevent-GameEvents-being-fired-from-unloaded-chunks.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public void gameEvent(Holder<GameEvent> event, Vec3 emitterPos, GameEvent.Context emitter) { diff --git a/patches/unapplied/server/Prevent-causing-expired-keys-from-impacting-new-join.patch b/patches/server/Prevent-causing-expired-keys-from-impacting-new-join.patch similarity index 98% rename from patches/unapplied/server/Prevent-causing-expired-keys-from-impacting-new-join.patch rename to patches/server/Prevent-causing-expired-keys-from-impacting-new-join.patch index 96a56c514e..aa16e84d39 100644 --- a/patches/unapplied/server/Prevent-causing-expired-keys-from-impacting-new-join.patch +++ b/patches/server/Prevent-causing-expired-keys-from-impacting-new-join.patch @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - private int knownMovePacketCount; + private boolean receivedMovementThisTick; @Nullable private RemoteChatSession chatSession; + private boolean hasLoggedExpiry = false; // Paper - Prevent causing expired keys from impacting new joins diff --git a/patches/unapplied/server/Treat-sequence-violations-like-they-should-be.patch b/patches/server/Treat-sequence-violations-like-they-should-be.patch similarity index 100% rename from patches/unapplied/server/Treat-sequence-violations-like-they-should-be.patch rename to patches/server/Treat-sequence-violations-like-they-should-be.patch diff --git a/patches/unapplied/server/Use-array-for-gamerule-storage.patch b/patches/server/Use-array-for-gamerule-storage.patch similarity index 67% rename from patches/unapplied/server/Use-array-for-gamerule-storage.patch rename to patches/server/Use-array-for-gamerule-storage.patch index d69377731d..d505ab26f4 100644 --- a/patches/unapplied/server/Use-array-for-gamerule-storage.patch +++ b/patches/server/Use-array-for-gamerule-storage.patch @@ -9,31 +9,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/GameRules.java +++ b/src/main/java/net/minecraft/world/level/GameRules.java @@ -0,0 +0,0 @@ public class GameRules { - worldserver.setDefaultSpawnPos(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle()); })); private final Map<GameRules.Key<?>, GameRules.Value<?>> rules; + private final FeatureFlagSet enabledFeatures; + private final GameRules.Value<?>[] gameruleArray; // Paper - Perf: Use array for gamerule storage private static <T extends GameRules.Value<T>> GameRules.Key<T> register(String name, GameRules.Category category, GameRules.Type<T> type) { GameRules.Key<T> gamerules_gamerulekey = new GameRules.Key<>(name, category); @@ -0,0 +0,0 @@ public class GameRules { - } - - public GameRules() { -- this.rules = (Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> { -+ // Paper start - Perf: Use array for gamerule storage -+ this((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> { - return ((GameRules.Type) entry.getValue()).createRule(); -- })); -+ }))); -+ // Paper end - Perf: Use array for gamerule storage - } - - private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules) { + private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules, FeatureFlagSet enabledFeatures) { this.rules = rules; + this.enabledFeatures = enabledFeatures; + + // Paper start - Perf: Use array for gamerule storage -+ int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1; ++ int arraySize = GameRules.Key.lastGameRuleIndex + 1; + GameRules.Value<?>[] values = new GameRules.Value[arraySize]; + + for (Entry<GameRules.Key<?>, GameRules.Value<?>> entry : rules.entrySet()) { @@ -45,17 +34,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public <T extends GameRules.Value<T>> T getRule(GameRules.Key<T> key) { -- return (T) this.rules.get(key); // CraftBukkit - decompile error -+ return key == null ? null : (T) this.gameruleArray[key.gameRuleIndex]; // Paper - Perf: Use array for gamerule storage - } +- T t0 = (T) this.rules.get(key); // CraftBukkit - decompile error ++ T t0 = key == null ? null : (T) this.gameruleArray[key.gameRuleIndex]; // Paper - Perf: Use array for gamerule storage - public CompoundTag createTag() { + if (t0 == null) { + throw new IllegalArgumentException("Tried to access invalid game rule"); @@ -0,0 +0,0 @@ public class GameRules { } public static final class Key<T extends GameRules.Value<T>> { + // Paper start - Perf: Use array for gamerule storage -+ private static int lastGameRuleIndex = 0; ++ public static int lastGameRuleIndex = 0; + public final int gameRuleIndex = lastGameRuleIndex++; + // Paper end - Perf: Use array for gamerule storage