From 4cc2be301d871f0153b325dab5e38ca5ae58bab6 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sun, 15 Dec 2024 14:35:59 -0800 Subject: [PATCH] it compiles? --- .../io/papermc/paper/FeatureHooks.java.patch | 7 ++- .../framework/GameTestServer.java.patch | 35 ++++++++++-- .../chat/ComponentSerialization.java.patch | 4 +- .../world/entity/monster/Spider.java.patch | 2 +- .../projectile/AbstractArrow.java.patch | 55 +++++++++++++++++-- .../minecraft/world/item/ItemStack.java.patch | 6 +- .../entity/CraftAbstractArrow.java | 2 +- 7 files changed, 95 insertions(+), 16 deletions(-) diff --git a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch index af8d9a6358..69bf0f769f 100644 --- a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch +++ b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch @@ -1,6 +1,6 @@ --- /dev/null +++ b/io/papermc/paper/FeatureHooks.java -@@ -1,0 +_,72 @@ +@@ -1,0 +_,77 @@ +package io.papermc.paper; + +import io.papermc.paper.command.PaperSubcommand; @@ -16,6 +16,7 @@ +import net.minecraft.core.Registry; +import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.server.level.ServerPlayer; ++import net.minecraft.world.entity.monster.Spider; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; @@ -72,4 +73,8 @@ + public static boolean isChunkSent(final ServerPlayer player, final long chunkKey) { + return player.getChunkTrackingView().contains(new ChunkPos(chunkKey)); + } ++ ++ public static boolean isSpiderCollidingWithWorldBorder(final Spider spider) { ++ return true; // ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isCollidingWithBorder(spider.level().getWorldBorder(), spider.getBoundingBox().inflate(ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_EPSILON)) ++ } +} diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch index b03cf4110d..5bfe64d450 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,16 +1,43 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -304,6 +_,13 @@ +@@ -139,6 +_,8 @@ + BlockPos spawnPos + ) { + super( ++ null, // Paper ++ null, // Paper + serverThread, + storageSource, + packRepository, +@@ -154,8 +_,15 @@ + + @Override + public boolean initServer() { +- this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, 1) {}); +- this.loadLevel(); ++ // Paper start ++ this.setPlayerList(new PlayerList(this, this.registries(), this.playerDataStorage, 1) { ++ @Override ++ public void loadAndSaveFiles() { ++ throw new UnsupportedOperationException("Should not be called in a GameTestServer"); ++ } ++ }); ++ this.loadLevel("blah"); ++ // Paper end + ServerLevel serverLevel = this.overworld(); + this.testBatches = Lists.newArrayList(GameTestBatchFactory.fromTestFunction(this.testFunctions, serverLevel)); + serverLevel.setDefaultSpawnPos(this.spawnPos, 0.0F); +@@ -303,6 +_,13 @@ + public boolean shouldInformAdmins() { return false; } - ++ + // Paper start + @Override + public org.bukkit.command.CommandSender getBukkitSender(final net.minecraft.commands.CommandSourceStack wrapper) { + throw new UnsupportedOperationException("Not supported."); + } + // Paper end -+ + @Override public boolean isSingleplayerOwner(GameProfile profile) { - return false; diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch index 1ae5d92462..daf7751fe7 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch @@ -65,8 +65,8 @@ .apply(instance, MutableComponent::new) ); + // Paper start - adventure; create separate codec for each locale -+ final Codec origCodec = codec; -+ codec = new Codec<>() { ++ final Codec origCodec = codec1; ++ codec1 = new Codec<>() { + @Override + public DataResult> decode(final DynamicOps ops, final T input) { + return origCodec.decode(ops, input); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch index cbaaaef4ef..16a88af185 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch @@ -5,7 +5,7 @@ super.tick(); if (!this.level().isClientSide) { - this.setClimbing(this.horizontalCollision); -+ this.setClimbing(this.horizontalCollision && (this.level().paperConfig().entities.behavior.allowSpiderWorldBorderClimbing || !(ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isCollidingWithBorder(this.level().getWorldBorder(), this.getBoundingBox().inflate(ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_EPSILON)) && this.level().getWorldBorder().isInsideCloseToBorder(this, this.getBoundingBox())))); // Paper - Add config option for spider worldborder climbing (Inflate by +EPSILON as collision will just barely place us outside border) ++ this.setClimbing(this.horizontalCollision && (this.level().paperConfig().entities.behavior.allowSpiderWorldBorderClimbing || !(io.papermc.paper.FeatureHooks.isSpiderCollidingWithWorldBorder(this) && this.level().getWorldBorder().isInsideCloseToBorder(this, this.getBoundingBox())))); // Paper - Add config option for spider worldborder climbing (Inflate by +EPSILON as collision will just barely place us outside border) } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index d215e5ce83..23dc1ce9bf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -8,10 +8,25 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -@@ -74,6 +_,16 @@ +@@ -63,16 +_,26 @@ + protected int inGroundTime; + public AbstractArrow.Pickup pickup = AbstractArrow.Pickup.DISALLOWED; + public int shakeTime; +- private int life; ++ public int life; // Paper - private -> public + private double baseDamage = 2.0; +- private SoundEvent soundEvent = this.getDefaultHitGroundSoundEvent(); ++ public SoundEvent soundEvent = this.getDefaultHitGroundSoundEvent(); // Paper - private -> public @Nullable - private ItemStack firedFromWeapon = null; - + private IntOpenHashSet piercingIgnoreEntityIds; + @Nullable + private List piercedAndKilledEntities; +- private ItemStack pickupItemStack = this.getDefaultPickupItem(); ++ public ItemStack pickupItemStack = this.getDefaultPickupItem(); // Paper - private -> public + @Nullable +- private ItemStack firedFromWeapon = null; ++ public ItemStack firedFromWeapon = null; // Paper - private -> public ++ + // Spigot Start + @Override + public void inactiveTick() { @@ -21,10 +36,9 @@ + super.inactiveTick(); + } + // Spigot End -+ + protected AbstractArrow(EntityType entityType, Level level) { super(entityType, level); - } @@ -87,7 +_,13 @@ ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon @@ -231,3 +245,34 @@ } } } +@@ -643,7 +_,7 @@ + }; + } + +- protected ItemStack getPickupItem() { ++ public ItemStack getPickupItem() { // Paper - protected -> public + return this.pickupItemStack.copy(); + } + +@@ -675,7 +_,7 @@ + this.setFlag(1, critArrow); + } + +- private void setPierceLevel(byte pierceLevel) { ++ public void setPierceLevel(byte pierceLevel) { // Paper - private -> public + this.entityData.set(PIERCE_LEVEL, pierceLevel); + } + +@@ -687,6 +_,12 @@ + this.entityData.set(ID_FLAGS, (byte)(b & ~id)); + } + } ++ ++ // Paper start ++ public void setPickupItemStackPublic(final ItemStack pickupItemStack) { ++ this.setPickupItemStack(pickupItemStack); ++ } ++ // Paper end + + protected void setPickupItemStack(ItemStack pickupItemStack) { + if (!pickupItemStack.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index 4675b2f09b..9eba8654c6 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -219,11 +219,13 @@ return interactionResult; } -@@ -470,30 +_,69 @@ +@@ -469,31 +_,70 @@ + return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; } - public void hurtAndBreak(int damage, ServerLevel level, @Nullable ServerPlayer player, Consumer onBreak) { +- public void hurtAndBreak(int damage, ServerLevel level, @Nullable ServerPlayer player, Consumer onBreak) { - int i = this.processDurabilityChange(damage, level, player); ++ public void hurtAndBreak(int damage, ServerLevel level, @Nullable LivingEntity player, Consumer onBreak) { // Paper - Add EntityDamageItemEvent + // Paper start - add force boolean overload + this.hurtAndBreak(damage, level, player, onBreak, false); + } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java index d0c30fd12a..af2c1ad8cd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java @@ -150,7 +150,7 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr @Override public void setItemStack(final ItemStack stack) { Preconditions.checkArgument(stack != null, "ItemStack cannot be null"); - this.getHandle().setPickupItemStack(CraftItemStack.asNMSCopy(stack)); + this.getHandle().setPickupItemStackPublic(CraftItemStack.asNMSCopy(stack)); } @Override