From b4c75aa92c69e022b9c757f36c09e244875649c3 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 3 Dec 2024 22:06:05 +0100 Subject: [PATCH] Compilation fixes --- patches/api/DataComponent-API.patch | 4 ++-- patches/server/Add-FeatureFlag-API.patch | 3 +-- .../server/Add-Listing-API-for-Player.patch | 2 +- ...Add-api-for-spawn-egg-texture-colors.patch | 5 +++- ...event-players-from-moving-into-unloa.patch | 2 +- patches/server/DataComponent-API.patch | 23 +++++++++++-------- .../server/Fix-a-bunch-of-vanilla-bugs.patch | 13 +++++++++++ ...item-duplication-and-teleport-issues.patch | 6 ++--- patches/server/Implement-Mob-Goal-API.patch | 1 - patches/server/More-Projectile-API.patch | 2 +- patches/server/More-Teleport-API.patch | 4 ---- ...ptimize-Collision-to-not-load-chunks.patch | 12 ---------- ...he-changed-item-from-dispense-events.patch | 2 +- 13 files changed, 40 insertions(+), 39 deletions(-) diff --git a/patches/api/DataComponent-API.patch b/patches/api/DataComponent-API.patch index 948ca41188..4dbbadf86b 100644 --- a/patches/api/DataComponent-API.patch +++ b/patches/api/DataComponent-API.patch @@ -1153,7 +1153,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the model key or null + */ + @Contract(pure = true) -+ @Nullable Key model(); ++ @Nullable Key assetId(); + + /** + * Gets the camera overlay key if present. @@ -1219,7 +1219,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the builder for chaining + */ + @Contract(value = "_ -> this", mutates = "this") -+ Builder model(@Nullable Key model); ++ Builder assetId(@Nullable Key model); + + /** + * Sets the camera overlay key for this item. diff --git a/patches/server/Add-FeatureFlag-API.patch b/patches/server/Add-FeatureFlag-API.patch index 112b0a097c..ab5b93369f 100644 --- a/patches/server/Add-FeatureFlag-API.patch +++ b/patches/server/Add-FeatureFlag-API.patch @@ -57,8 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + FeatureFlag.VANILLA, FeatureFlags.VANILLA, + FeatureFlag.TRADE_REBALANCE, FeatureFlags.TRADE_REBALANCE, + FeatureFlag.MINECART_IMPROVEMENTS, FeatureFlags.MINECART_IMPROVEMENTS, -+ FeatureFlag.REDSTONE_EXPERIMENTS, FeatureFlags.REDSTONE_EXPERIMENTS, -+ FeatureFlag.WINTER_DROP, FeatureFlags.WINTER_DROP ++ FeatureFlag.REDSTONE_EXPERIMENTS, FeatureFlags.REDSTONE_EXPERIMENTS + ); + + @Override diff --git a/patches/server/Add-Listing-API-for-Player.patch b/patches/server/Add-Listing-API-for-Player.patch index 8f4b1b7085..c18fe40a0a 100644 --- a/patches/server/Add-Listing-API-for-Player.patch +++ b/patches/server/Add-Listing-API-for-Player.patch @@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start - Add Listing API for Player + Entry(UUID profileId, boolean listed) { -+ this(profileId, null, listed, 0, GameType.DEFAULT_MODE, null, 0, null); ++ this(profileId, null, listed, 0, GameType.DEFAULT_MODE, null, true, 0, null); + } + // Paper end - Add Listing API for Player } diff --git a/patches/server/Add-api-for-spawn-egg-texture-colors.patch b/patches/server/Add-api-for-spawn-egg-texture-colors.patch index 529c61964b..6de073f0b3 100644 --- a/patches/server/Add-api-for-spawn-egg-texture-colors.patch +++ b/patches/server/Add-api-for-spawn-egg-texture-colors.patch @@ -17,7 +17,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public org.bukkit.Color getSpawnEggLayerColor(final EntityType entityType, final int layer) { + final net.minecraft.world.entity.EntityType nmsType = org.bukkit.craftbukkit.entity.CraftEntityType.bukkitToMinecraft(entityType); + final net.minecraft.world.item.SpawnEggItem eggItem = net.minecraft.world.item.SpawnEggItem.byId(nmsType); -+ return eggItem == null ? null : org.bukkit.Color.fromRGB(eggItem.getColor(layer)); ++ if (eggItem != null) { ++ throw new UnsupportedOperationException("Not yet implemented"); ++ } ++ return eggItem == null ? null : org.bukkit.Color.fromRGB(1); // TODO + } + // Paper end - spawn egg color visibility + diff --git a/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch b/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch index 797f0ba1ae..5cfb24a54e 100644 --- a/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch +++ b/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position()))) || + !worldserver.areChunksLoadedForMove(entity.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(entity.position()))) + )) { -+ this.connection.send(new ClientboundMoveVehiclePacket(entity)); ++ this.connection.send(ClientboundMoveVehiclePacket.fromEntity(entity)); + return; + } + // Paper end - Prevent moving into unloaded chunks diff --git a/patches/server/DataComponent-API.patch b/patches/server/DataComponent-API.patch index 4bb18e9de4..8f6292d002 100644 --- a/patches/server/DataComponent-API.patch +++ b/patches/server/DataComponent-API.patch @@ -578,7 +578,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public CustomModelData customModelData(final int id) { -+ return new PaperCustomModelData(new net.minecraft.world.item.component.CustomModelData(id)); ++ throw new UnsupportedOperationException("Not implemented yet"); ++ //return new PaperCustomModelData(new net.minecraft.world.item.component.CustomModelData(id)); + } + + @Override @@ -1213,10 +1214,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public @Nullable Key model() { -+ return this.impl.model() -+ .map(PaperAdventure::asAdventure) -+ .orElse(null); ++ public @Nullable Key assetId() { ++ // TODO ++ throw new UnsupportedOperationException("Not yet implemented"); ++ //return this.impl.assetId() ++ // .map(PaperAdventure::asAdventure) ++ // .orElse(null); + } + + @Override @@ -1252,7 +1255,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public Builder toBuilder() { + return new BuilderImpl(this.slot()) + .equipSound(this.equipSound()) -+ .model(this.model()) ++ .assetId(this.assetId()) + .cameraOverlay(this.cameraOverlay()) + .allowedEntities(this.allowedEntities()) + .dispensable(this.dispensable()) @@ -1265,7 +1268,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private final net.minecraft.world.entity.EquipmentSlot equipmentSlot; + private Holder equipSound = SoundEvents.ARMOR_EQUIP_GENERIC; -+ private Optional model = Optional.empty(); ++ private Optional assetId = Optional.empty(); + private Optional cameraOverlay = Optional.empty(); + private Optional>> allowedEntities = Optional.empty(); + private boolean dispensable = true; @@ -1283,8 +1286,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public Builder model(final @Nullable Key model) { -+ this.model = Optional.ofNullable(model) ++ public Builder assetId(final @Nullable Key model) { ++ this.assetId = Optional.ofNullable(model) + .map(PaperAdventure::asVanilla); + + return this; @@ -1329,7 +1332,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + new net.minecraft.world.item.equipment.Equippable( + this.equipmentSlot, + this.equipSound, -+ this.model, ++ null, // TODO + this.cameraOverlay, + this.allowedEntities, + this.dispensable, diff --git a/patches/server/Fix-a-bunch-of-vanilla-bugs.patch b/patches/server/Fix-a-bunch-of-vanilla-bugs.patch index e0ca5f1f08..e349881f61 100644 --- a/patches/server/Fix-a-bunch-of-vanilla-bugs.patch +++ b/patches/server/Fix-a-bunch-of-vanilla-bugs.patch @@ -319,6 +319,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 super.setRemoved(); } +diff --git a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java b/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java +@@ -0,0 +0,0 @@ public final class TrialSpawner { + } + + public void overrideEntityToSpawn(EntityType entityType, Level world) { +- this.data.reset(); ++ this.data.reset(this); // Paper + this.normalConfig = Holder.direct(((TrialSpawnerConfig) this.normalConfig.value()).withSpawning(entityType)); + this.ominousConfig = Holder.direct(((TrialSpawnerConfig) this.ominousConfig.value()).withSpawning(entityType)); + this.setState(world, TrialSpawnerState.INACTIVE); diff --git a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java b/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java diff --git a/patches/server/Fix-item-duplication-and-teleport-issues.patch b/patches/server/Fix-item-duplication-and-teleport-issues.patch index 1cec5ad228..7ff081c4ef 100644 --- a/patches/server/Fix-item-duplication-and-teleport-issues.patch +++ b/patches/server/Fix-item-duplication-and-teleport-issues.patch @@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else { + // Paper start - Fix item duplication and teleport issues + if (this instanceof Leashable leashable) { -+ leashable.dropLeash(true, true); // Paper drop lead ++ leashable.dropLeash(); // Paper drop lead + } + // Paper end - Fix item duplication and teleport issues entity.restoreFrom(this); @@ -93,8 +93,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // CraftBukkit start - Call death event // Paper start - call advancement triggers with correct entity equipment + org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, damageSource, this.drops, () -> { + final LivingEntity entityliving = this.getKillCredit(); -+ if (this.deathScore >= 0 && entityliving != null) { -+ entityliving.awardKillScore(this, this.deathScore, damageSource); ++ if (entityliving != null) { ++ entityliving.awardKillScore(this, damageSource); + } + }); // Paper end this.postDeathDropItems(deathEvent); // Paper diff --git a/patches/server/Implement-Mob-Goal-API.patch b/patches/server/Implement-Mob-Goal-API.patch index df0e690e96..7c68ba2fc8 100644 --- a/patches/server/Implement-Mob-Goal-API.patch +++ b/patches/server/Implement-Mob-Goal-API.patch @@ -272,7 +272,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, org.bukkit.entity.Armadillo.class); + bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, org.bukkit.entity.Bogged.class); + bukkitMap.put(net.minecraft.world.entity.monster.creaking.Creaking.class, org.bukkit.entity.Creaking.class); -+ bukkitMap.put(net.minecraft.world.entity.monster.creaking.CreakingTransient.class, org.bukkit.entity.CreakingTransient.class); + bukkitMap.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, org.bukkit.entity.Squid.class); // close enough + } + diff --git a/patches/server/More-Projectile-API.patch b/patches/server/More-Projectile-API.patch index 91bc85e3a1..519f92f731 100644 --- a/patches/server/More-Projectile-API.patch +++ b/patches/server/More-Projectile-API.patch @@ -546,7 +546,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 launch = new net.minecraft.world.entity.projectile.Arrow(world, this.getHandle(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.ARROW), null); } - ((net.minecraft.world.entity.projectile.AbstractArrow) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, 3.0F, 1.0F); // ItemBow -+ ((net.minecraft.world.entity.projectile.AbstractArrow) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, Trident.class.isAssignableFrom(projectile) ? net.minecraft.world.item.TridentItem.SHOOT_POWER : 3.0F, 1.0F); // ItemBow // Paper - see TridentItem ++ ((net.minecraft.world.entity.projectile.AbstractArrow) launch).shootFromRotation(this.getHandle(), this.getHandle().getXRot(), this.getHandle().getYRot(), 0.0F, Trident.class.isAssignableFrom(projectile) ? net.minecraft.world.item.TridentItem.PROJECTILE_SHOOT_POWER : 3.0F, 1.0F); // ItemBow // Paper - see TridentItem } else if (ThrownPotion.class.isAssignableFrom(projectile)) { if (LingeringPotion.class.isAssignableFrom(projectile)) { launch = new net.minecraft.world.entity.projectile.ThrownPotion(world, this.getHandle(), new net.minecraft.world.item.ItemStack(Items.LINGERING_POTION)); diff --git a/patches/server/More-Teleport-API.patch b/patches/server/More-Teleport-API.patch index 929a892714..6b82607fe4 100644 --- a/patches/server/More-Teleport-API.patch +++ b/patches/server/More-Teleport-API.patch @@ -88,10 +88,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + world.loadChunksForMoveAsync(getHandle().getBoundingBoxAt(locationClone.getX(), locationClone.getY(), locationClone.getZ()), + this instanceof CraftPlayer ? ca.spottedleaf.concurrentutil.util.Priority.HIGHER : ca.spottedleaf.concurrentutil.util.Priority.NORMAL, (list) -> { -+ net.minecraft.server.level.ServerChunkCache chunkProviderServer = world.getChunkSource(); -+ for (net.minecraft.world.level.chunk.ChunkAccess chunk : list) { -+ chunkProviderServer.addTicketAtLevel(net.minecraft.server.level.TicketType.POST_TELEPORT, chunk.getPos(), 33, CraftEntity.this.getEntityId()); -+ } + net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { + try { + ret.complete(CraftEntity.this.teleport(locationClone, cause, teleportFlags) ? Boolean.TRUE : Boolean.FALSE); diff --git a/patches/server/Optimize-Collision-to-not-load-chunks.patch b/patches/server/Optimize-Collision-to-not-load-chunks.patch index 9a8f33a286..2ef0ecd042 100644 --- a/patches/server/Optimize-Collision-to-not-load-chunks.patch +++ b/patches/server/Optimize-Collision-to-not-load-chunks.patch @@ -15,18 +15,6 @@ massive amounts of surrounding chunks due to large AABB lookups. Feature patch -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- 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 { - Vec3 vec3d = teleporttransition.position(); - - entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot()); -+ worldserver.getChunkSource().addRegionTicket(net.minecraft.server.level.TicketType.POST_TELEPORT, new net.minecraft.world.level.ChunkPos(net.minecraft.util.Mth.floor(vec3d.x()) >> 4, net.minecraft.util.Mth.floor(vec3d.z()) >> 4), 1, entityplayer.getId()); // Paper - // CraftBukkit end - if (teleporttransition.missingRespawnBlock()) { - entityplayer1.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/patches/server/Properly-track-the-changed-item-from-dispense-events.patch b/patches/server/Properly-track-the-changed-item-from-dispense-events.patch index fbe3b65e44..c0610a5c09 100644 --- a/patches/server/Properly-track-the-changed-item-from-dispense-events.patch +++ b/patches/server/Properly-track-the-changed-item-from-dispense-events.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start - track changed items in the dispense event + itemstack1 = CraftItemStack.unwrap(event.getItem()); // unwrap is safe because the stack won't be modified -+ entitytypes = ((SpawnEggItem) itemstack1.getItem()).getType(itemstack1); ++ entitytypes = ((SpawnEggItem) itemstack1.getItem()).getType(worldserver.registryAccess(), itemstack1); + // Paper end - track changed item from dispense event }