From 3121dbe3fe1f7adda621fa3773e16ee4faec7485 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 7 Jun 2023 15:28:06 -0700 Subject: [PATCH] fix a bunch of compile errors --- patches/server/Add-PhantomPreSpawnEvent.patch | 12 ++---------- ...option-to-allow-iron-golems-to-spawn-in-air.patch | 2 +- ...n-to-prevent-players-from-moving-into-unloa.patch | 2 +- patches/server/Adventure.patch | 4 ++-- .../Bees-get-gravity-in-void.-Fixes-MC-167279.patch | 2 +- .../Configurable-baby-zombie-movement-speed.patch | 2 +- ...gurable-chance-of-villager-zombie-infection.patch | 6 +++--- ...ing-block-and-tnt-entities-at-the-specified.patch | 4 ++-- patches/server/EntityPathfindEvent.patch | 2 +- ...ad-tile-entity-nbt-data-from-falling-blocks.patch | 2 +- patches/server/Fix-SpongeAbsortEvent-handling.patch | 2 +- patches/server/Improve-death-events.patch | 2 +- .../server/Optional-TNT-doesn-t-move-in-water.patch | 4 ++-- .../Prevent-Pathfinding-out-of-World-Border.patch | 2 +- patches/server/Starlight.patch | 2 +- patches/server/offset-item-frame-ticking.patch | 2 +- 16 files changed, 22 insertions(+), 30 deletions(-) diff --git a/patches/server/Add-PhantomPreSpawnEvent.patch b/patches/server/Add-PhantomPreSpawnEvent.patch index 92be4e2e02..f6b1bf60c9 100644 --- a/patches/server/Add-PhantomPreSpawnEvent.patch +++ b/patches/server/Add-PhantomPreSpawnEvent.patch @@ -51,20 +51,12 @@ diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java +++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -@@ -0,0 +0,0 @@ package net.minecraft.world.level.levelgen; - import java.util.Iterator; - import net.minecraft.core.BlockPos; - import net.minecraft.nbt.CompoundTag; -+import io.papermc.paper.util.MCUtil; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.stats.ServerStatsCounter; @@ -0,0 +0,0 @@ public class PhantomSpawner implements CustomSpawner { int k = 1 + randomsource.nextInt(difficultydamagescaler.getDifficulty().getId() + 1); for (int l = 0; l < k; ++l) { + // Paper start -+ com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(MCUtil.toLocation(world, blockposition1), ((ServerPlayer) entityhuman).getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); ++ com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(io.papermc.paper.util.MCUtil.toLocation(world, blockposition1), entityplayer.getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); + if (!event.callEvent()) { + if (event.shouldAbortSpawn()) { + break; @@ -75,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Phantom entityphantom = (Phantom) EntityType.PHANTOM.create(world); if (entityphantom != null) { -+ entityphantom.setSpawningEntity(entityhuman.getUUID()); // Paper ++ entityphantom.setSpawningEntity(entityphantom.getUUID()); // Paper entityphantom.moveTo(blockposition1, 0.0F, 0.0F); groupdataentity = entityphantom.finalizeSpawn(world, difficultydamagescaler, MobSpawnType.NATURAL, groupdataentity, (CompoundTag) null); world.addFreshEntityWithPassengers(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit diff --git a/patches/server/Add-option-to-allow-iron-golems-to-spawn-in-air.patch b/patches/server/Add-option-to-allow-iron-golems-to-spawn-in-air.patch index 75092de1b1..c479ddc589 100644 --- a/patches/server/Add-option-to-allow-iron-golems-to-spawn-in-air.patch +++ b/patches/server/Add-option-to-allow-iron-golems-to-spawn-in-air.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 BlockState iblockdata = world.getBlockState(blockposition1); - if (!iblockdata.entityCanStandOn(world, blockposition1, this)) { -+ if (!iblockdata.entityCanStandOn(world, blockposition1, this) && !level.paperConfig().entities.spawning.ironGolemsCanSpawnInAir) { // Paper ++ if (!iblockdata.entityCanStandOn(world, blockposition1, this) && !this.level().paperConfig().entities.spawning.ironGolemsCanSpawnInAir) { // Paper return false; } else { for (int i = 1; i < 3; ++i) { 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 d19cc1bb76..2845b78083 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 @@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 speed = this.player.getAbilities().walkingSpeed * 10f; } + // Paper start - Prevent moving into unloaded chunks -+ if (player.level.paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) { ++ if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) { + this.internalTeleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot(), Collections.emptySet()); + return; + } diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 329bda9d94..a064873c7f 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -2676,7 +2676,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 boolean flag1 = false; boolean flag2; -+ Packet disguised = sender != null && unsignedFunction == null ? new net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket(outgoingchatmessage.content(), params.toNetwork(sender.level.registryAccess())) : null; // Paper - don't send player chat packets from vanished players ++ Packet disguised = sender != null && unsignedFunction == null ? new net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket(outgoingchatmessage.content(), params.toNetwork(sender.level().registryAccess())) : null; // Paper - don't send player chat packets from vanished players for (Iterator iterator = this.players.iterator(); iterator.hasNext(); flag1 |= flag2 && message.isFullyFiltered()) { ServerPlayer entityplayer1 = (ServerPlayer) iterator.next(); @@ -2686,7 +2686,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - don't send player chat packets from vanished players + if (sender != null && !entityplayer1.getBukkitEntity().canSee(sender.getBukkitEntity())) { + entityplayer1.connection.send(unsignedFunction != null -+ ? new net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket(unsignedFunction.apply(entityplayer1.getBukkitEntity()), params.toNetwork(sender.level.registryAccess())) ++ ? new net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket(unsignedFunction.apply(entityplayer1.getBukkitEntity()), params.toNetwork(sender.level().registryAccess())) + : disguised); + continue; + } diff --git a/patches/server/Bees-get-gravity-in-void.-Fixes-MC-167279.patch b/patches/server/Bees-get-gravity-in-void.-Fixes-MC-167279.patch index 0518240e02..daa911a823 100644 --- a/patches/server/Bees-get-gravity-in-void.-Fixes-MC-167279.patch +++ b/patches/server/Bees-get-gravity-in-void.-Fixes-MC-167279.patch @@ -21,7 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public void tick() { -+ if (this.mob.getY() <= Bee.this.level.getMinBuildHeight()) { ++ if (this.mob.getY() <= Bee.this.level().getMinBuildHeight()) { + this.mob.setNoGravity(false); + } + super.tick(); diff --git a/patches/server/Configurable-baby-zombie-movement-speed.patch b/patches/server/Configurable-baby-zombie-movement-speed.patch index 5133328179..86a1b6b108 100644 --- a/patches/server/Configurable-baby-zombie-movement-speed.patch +++ b/patches/server/Configurable-baby-zombie-movement-speed.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private static final UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); private static final AttributeModifier SPEED_MODIFIER_BABY = new AttributeModifier(Zombie.SPEED_MODIFIER_BABY_UUID, "Baby speed boost", 0.5D, AttributeModifier.Operation.MULTIPLY_BASE); -+ private final AttributeModifier babyModifier = new net.minecraft.world.entity.ai.attributes.AttributeModifier(SPEED_MODIFIER_BABY.getId(), SPEED_MODIFIER_BABY.getName(), this.level.paperConfig().entities.behavior.babyZombieMovementModifier, SPEED_MODIFIER_BABY.getOperation()); // Paper - Make baby speed configurable ++ private final AttributeModifier babyModifier = new net.minecraft.world.entity.ai.attributes.AttributeModifier(SPEED_MODIFIER_BABY.getId(), SPEED_MODIFIER_BABY.getName(), this.level().paperConfig().entities.behavior.babyZombieMovementModifier, SPEED_MODIFIER_BABY.getOperation()); // Paper - Make baby speed configurable private static final EntityDataAccessor DATA_BABY_ID = SynchedEntityData.defineId(Zombie.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor DATA_SPECIAL_TYPE_ID = SynchedEntityData.defineId(Zombie.class, EntityDataSerializers.INT); public static final EntityDataAccessor DATA_DROWNED_CONVERSION_ID = SynchedEntityData.defineId(Zombie.class, EntityDataSerializers.BOOLEAN); diff --git a/patches/server/Configurable-chance-of-villager-zombie-infection.patch b/patches/server/Configurable-chance-of-villager-zombie-infection.patch index 25d1d1b03b..f034688013 100644 --- a/patches/server/Configurable-chance-of-villager-zombie-infection.patch +++ b/patches/server/Configurable-chance-of-villager-zombie-infection.patch @@ -20,11 +20,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - if (world.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { + // Paper start -+ if (level.paperConfig().entities.behavior.zombieVillagerInfectionChance != 0.0 && (level.paperConfig().entities.behavior.zombieVillagerInfectionChance != -1.0 || world.getDifficulty() == Difficulty.NORMAL || world.getDifficulty() == Difficulty.HARD) && other instanceof Villager) { -+ if (level.paperConfig().entities.behavior.zombieVillagerInfectionChance == -1.0 && world.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { ++ if (this.level().paperConfig().entities.behavior.zombieVillagerInfectionChance != 0.0 && (this.level().paperConfig().entities.behavior.zombieVillagerInfectionChance != -1.0 || world.getDifficulty() == Difficulty.NORMAL || world.getDifficulty() == Difficulty.HARD) && other instanceof Villager) { ++ if (this.level().paperConfig().entities.behavior.zombieVillagerInfectionChance == -1.0 && world.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { return flag; } -+ if (level.paperConfig().entities.behavior.zombieVillagerInfectionChance != -1.0 && (this.random.nextDouble() * 100.0) > level.paperConfig().entities.behavior.zombieVillagerInfectionChance) { ++ if (this.level().paperConfig().entities.behavior.zombieVillagerInfectionChance != -1.0 && (this.random.nextDouble() * 100.0) > this.level().paperConfig().entities.behavior.zombieVillagerInfectionChance) { + return flag; + } // Paper end + diff --git a/patches/server/Drop-falling-block-and-tnt-entities-at-the-specified.patch b/patches/server/Drop-falling-block-and-tnt-entities-at-the-specified.patch index a000688fe9..fca27e85c1 100644 --- a/patches/server/Drop-falling-block-and-tnt-entities-at-the-specified.patch +++ b/patches/server/Drop-falling-block-and-tnt-entities-at-the-specified.patch @@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.move(MoverType.SELF, this.getDeltaMovement()); + // Paper start - Configurable EntityFallingBlock height nerf -+ if (this.level.paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { -+ if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { ++ if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { ++ if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + this.spawnAtLocation(block); + } + diff --git a/patches/server/EntityPathfindEvent.patch b/patches/server/EntityPathfindEvent.patch index 9f236330f5..5f1c28f97d 100644 --- a/patches/server/EntityPathfindEvent.patch +++ b/patches/server/EntityPathfindEvent.patch @@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + boolean copiedSet = false; + for (BlockPos possibleTarget : positions) { + if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), -+ io.papermc.paper.util.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) { ++ io.papermc.paper.util.MCUtil.toLocation(this.mob.level(), possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) { + if (!copiedSet) { + copiedSet = true; + positions = new java.util.HashSet<>(positions); diff --git a/patches/server/Filter-bad-tile-entity-nbt-data-from-falling-blocks.patch b/patches/server/Filter-bad-tile-entity-nbt-data-from-falling-blocks.patch index 29dec354d2..81db71d856 100644 --- a/patches/server/Filter-bad-tile-entity-nbt-data-from-falling-blocks.patch +++ b/patches/server/Filter-bad-tile-entity-nbt-data-from-falling-blocks.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - if (nbt.contains("TileEntityData", 10)) { -+ if (nbt.contains("TileEntityData", 10) && !(this.level.paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock)) { ++ if (nbt.contains("TileEntityData", 10) && !(this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock)) { this.blockData = nbt.getCompound("TileEntityData"); } diff --git a/patches/server/Fix-SpongeAbsortEvent-handling.patch b/patches/server/Fix-SpongeAbsortEvent-handling.patch index 883c3a2351..0f1c175c8e 100644 --- a/patches/server/Fix-SpongeAbsortEvent-handling.patch +++ b/patches/server/Fix-SpongeAbsortEvent-handling.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 BlockEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null; + // Paper start -+ if (block.getHandle().getMaterial() == Material.AIR) { ++ if (block.getHandle().isAir()) { dropResources(iblockdata, world, blockposition1, tileentity); + } + // Paper end diff --git a/patches/server/Improve-death-events.patch b/patches/server/Improve-death-events.patch index 2159680d6f..1745307dd3 100644 --- a/patches/server/Improve-death-events.patch +++ b/patches/server/Improve-death-events.patch @@ -435,7 +435,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + double z = event.getEntity().getLocation().getZ(); + net.minecraft.sounds.SoundEvent soundEffect = org.bukkit.craftbukkit.CraftSound.getSoundEffect(event.getDeathSound()); + net.minecraft.sounds.SoundSource soundCategory = net.minecraft.sounds.SoundSource.valueOf(event.getDeathSoundCategory().name()); -+ victim.level.playSound(source, x, y, z, soundEffect, soundCategory, event.getDeathSoundVolume(), event.getDeathSoundPitch()); ++ victim.level().playSound(source, x, y, z, soundEffect, soundCategory, event.getDeathSoundVolume(), event.getDeathSoundPitch()); + } + } + // Paper end diff --git a/patches/server/Optional-TNT-doesn-t-move-in-water.patch b/patches/server/Optional-TNT-doesn-t-move-in-water.patch index e4c8c3cb6c..0c195e740e 100644 --- a/patches/server/Optional-TNT-doesn-t-move-in-water.patch +++ b/patches/server/Optional-TNT-doesn-t-move-in-water.patch @@ -26,13 +26,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start - Optional prevent TNT from moving in water -+ if (!this.isRemoved() && this.wasTouchingWater && this.level.paperConfig().fixes.preventTntFromMovingInWater) { ++ if (!this.isRemoved() && this.wasTouchingWater && this.level().paperConfig().fixes.preventTntFromMovingInWater) { + /* + * Author: Jedediah Smith + */ + // Send position and velocity updates to nearby players on every tick while the TNT is in water. + // This does pretty well at keeping their clients in sync with the server. -+ net.minecraft.server.level.ChunkMap.TrackedEntity ete = ((net.minecraft.server.level.ServerLevel)this.level).getChunkSource().chunkMap.entityMap.get(this.getId()); ++ net.minecraft.server.level.ChunkMap.TrackedEntity ete = ((net.minecraft.server.level.ServerLevel)this.level()).getChunkSource().chunkMap.entityMap.get(this.getId()); + if (ete != null) { + net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket velocityPacket = new net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket(this); + net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket positionPacket = new net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket(this); diff --git a/patches/server/Prevent-Pathfinding-out-of-World-Border.patch b/patches/server/Prevent-Pathfinding-out-of-World-Border.patch index 44136693cd..c5d557a0bb 100644 --- a/patches/server/Prevent-Pathfinding-out-of-World-Border.patch +++ b/patches/server/Prevent-Pathfinding-out-of-World-Border.patch @@ -22,6 +22,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 for (BlockPos possibleTarget : positions) { - if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), + if (!this.mob.getCommandSenderWorld().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border - io.papermc.paper.util.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) { + io.papermc.paper.util.MCUtil.toLocation(this.mob.level(), possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) { if (!copiedSet) { copiedSet = true; diff --git a/patches/server/Starlight.patch b/patches/server/Starlight.patch index 2161dbe8bd..b98be7a605 100644 --- a/patches/server/Starlight.patch +++ b/patches/server/Starlight.patch @@ -4586,7 +4586,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.theLightEngine.relightChunks(chunks, (ChunkPos chunkPos) -> { + chunkLightCallback.accept(chunkPos); + ((java.util.concurrent.Executor)((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().mainThreadProcessor).execute(() -> { -+ ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().chunkMap.getUpdatingChunkIfPresent(chunkPos.toLong()).broadcast(new net.minecraft.network.protocol.game.ClientboundLightUpdatePacket(chunkPos, ThreadedLevelLightEngine.this, null, null, true), false); ++ ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().chunkMap.getUpdatingChunkIfPresent(chunkPos.toLong()).broadcast(new net.minecraft.network.protocol.game.ClientboundLightUpdatePacket(chunkPos, ThreadedLevelLightEngine.this, null, null), false); + ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().removeTicketAtLevel(TicketType.CHUNK_RELIGHT, chunkPos, io.papermc.paper.util.MCUtil.getTicketLevelFor(ChunkStatus.LIGHT), ticketIds.get(chunkPos)); + }); + }, onComplete); diff --git a/patches/server/offset-item-frame-ticking.patch b/patches/server/offset-item-frame-ticking.patch index f119bb63bb..dc9e476c7a 100644 --- a/patches/server/offset-item-frame-ticking.patch +++ b/patches/server/offset-item-frame-ticking.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return entity instanceof HangingEntity; }; - private int checkInterval; -+ private int checkInterval; { this.checkInterval = this.getId() % this.level.spigotConfig.hangingTickFrequency; } // Paper ++ private int checkInterval; { this.checkInterval = this.getId() % this.level().spigotConfig.hangingTickFrequency; } // Paper public BlockPos pos; protected Direction direction;