From cc0308bf1d7d9b681efca6c38a15ff514f77865c Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 25 Oct 2024 13:34:01 +0200 Subject: [PATCH] Some more compile issues --- ...Bees-get-gravity-in-void.-Fixes-MC-167279.patch | 2 +- .../Don-t-fire-sync-events-during-worldgen.patch | 2 +- ...g-block-and-tnt-entities-at-the-specified.patch | 4 ++-- ...tyRaider-respects-game-and-entity-rules-f.patch | 2 +- patches/server/EntityPickupItemEvent-fixes.patch | 2 +- patches/server/Fix-a-bunch-of-vanilla-bugs.patch | 4 ++-- ...new-block-data-for-EntityChangeBlockEvent.patch | 2 +- ...LootTable-API-and-replenishable-lootables.patch | 2 +- patches/server/Player-affects-spawning-API.patch | 2 +- patches/server/Remap-fixes.patch | 13 +++++++++++++ patches/server/Timings-v2.patch | 13 ++----------- .../Validate-ResourceLocation-in-NBT-reading.patch | 2 +- ...event-unintended-light-block-manipulation.patch | 14 ++------------ 13 files changed, 29 insertions(+), 35 deletions(-) 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 0d04051663..1b7d20fd69 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().getMinY()) { + this.mob.setNoGravity(false); + } + super.tick(); diff --git a/patches/server/Don-t-fire-sync-events-during-worldgen.patch b/patches/server/Don-t-fire-sync-events-during-worldgen.patch index d0661c4ec8..d52b66ac11 100644 --- a/patches/server/Don-t-fire-sync-events-during-worldgen.patch +++ b/patches/server/Don-t-fire-sync-events-during-worldgen.patch @@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static Optional create(CompoundTag nbt, Level world, EntitySpawnReason reason) { + // Paper start - Don't fire sync event during generation -+ return create(nbt, world, false); ++ return create(nbt, world, reason, false); + } + public static Optional create(CompoundTag nbt, Level world, EntitySpawnReason reason, boolean generation) { + // Paper end - Don't fire sync event during generation 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 edb02cc105..64728f79e2 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 @@ -15,8 +15,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.applyEffectsFromBlocks(); + // Paper start - Configurable falling blocks height nerf + if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { -+ if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { -+ this.spawnAtLocation(block); ++ if (this.dropItem && this.level() instanceof final ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { ++ this.spawnAtLocation(serverLevel, block); + } + + this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); diff --git a/patches/server/Ensure-EntityRaider-respects-game-and-entity-rules-f.patch b/patches/server/Ensure-EntityRaider-respects-game-and-entity-rules-f.patch index 6a47f9d2d6..634bc7e3ed 100644 --- a/patches/server/Ensure-EntityRaider-respects-game-and-entity-rules-f.patch +++ b/patches/server/Ensure-EntityRaider-respects-game-and-entity-rules-f.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } private boolean cannotPickUpBanner() { -+ if (!this.mob.level().getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING) || !this.mob.canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items ++ if (!getServerLevel(this.mob).getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING) || !this.mob.canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items if (!this.mob.hasActiveRaid()) { return true; } else if (this.mob.getCurrentRaid().isOver()) { diff --git a/patches/server/EntityPickupItemEvent-fixes.patch b/patches/server/EntityPickupItemEvent-fixes.patch index bd9b5ccbc8..2d7b46beff 100644 --- a/patches/server/EntityPickupItemEvent-fixes.patch +++ b/patches/server/EntityPickupItemEvent-fixes.patch @@ -64,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getOminousBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) { + // Paper start - EntityPickupItemEvent fixes -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, item, 0, false).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, itemstack, 0, false).isCancelled()) { + return; + } + // Paper end - EntityPickupItemEvent fixes diff --git a/patches/server/Fix-a-bunch-of-vanilla-bugs.patch b/patches/server/Fix-a-bunch-of-vanilla-bugs.patch index dc6b3feacf..fa71a3ca1c 100644 --- a/patches/server/Fix-a-bunch-of-vanilla-bugs.patch +++ b/patches/server/Fix-a-bunch-of-vanilla-bugs.patch @@ -245,8 +245,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Fix MC-123848 (spawn item frame drops above block) + @Nullable + @Override -+ public net.minecraft.world.entity.item.ItemEntity spawnAtLocation(ItemStack stack) { -+ return this.spawnAtLocation(stack, getDirection().equals(Direction.DOWN) ? -0.6F : 0.0F); ++ public net.minecraft.world.entity.item.ItemEntity spawnAtLocation(ServerLevel serverLevel, ItemStack stack) { ++ return this.spawnAtLocation(serverLevel, stack, getDirection().equals(Direction.DOWN) ? -0.6F : 0.0F); + } + // Paper end + diff --git a/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch b/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch index 7b43845643..d537d6bac4 100644 --- a/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch +++ b/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch @@ -125,7 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (block instanceof InfestedBlock) { // CraftBukkit start - if (!CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) { -+ BlockState afterState = world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? iblockdata.getFluidState().createLegacyBlock() : ((InfestedBlock) block).hostStateByInfested(world.getBlockState(blockposition1)); // Paper - fix wrong block state ++ BlockState afterState = getServerLevel(world).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? iblockdata.getFluidState().createLegacyBlock() : ((InfestedBlock) block).hostStateByInfested(world.getBlockState(blockposition1)); // Paper - fix wrong block state + if (!CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, afterState)) { // Paper - fix wrong block state continue; } diff --git a/patches/server/LootTable-API-and-replenishable-lootables.patch b/patches/server/LootTable-API-and-replenishable-lootables.patch index 30469230fe..0611c85f5c 100644 --- a/patches/server/LootTable-API-and-replenishable-lootables.patch +++ b/patches/server/LootTable-API-and-replenishable-lootables.patch @@ -678,7 +678,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (nbt.contains("LootTable", 8)) { this.setContainerLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("LootTable")))); + // Paper start - LootTable API -+ if (this.getLootTable() != null) { ++ if (this.getContainerLootTable() != null) { + this.lootableData().loadNbt(nbt); + } + // Paper end - LootTable API diff --git a/patches/server/Player-affects-spawning-API.patch b/patches/server/Player-affects-spawning-API.patch index 1be762e02d..8f98bead6c 100644 --- a/patches/server/Player-affects-spawning-API.patch +++ b/patches/server/Player-affects-spawning-API.patch @@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (SpawnPlacements.isSpawnPositionOk(entitytypes, world, blockposition) && SpawnPlacements.checkSpawnRules(entitytypes, world, EntitySpawnReason.REINFORCEMENT, blockposition, world.random)) { entityzombie.setPos((double) i1, (double) j1, (double) k1); - if (!world.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && world.isUnobstructed(entityzombie) && world.noCollision((Entity) entityzombie) && (entityzombie.canSpawnInLiquids() || !world.containsAnyLiquid(entityzombie.getBoundingBox()))) { -+ if (!world.hasNearbyAlivePlayerhasNearbyAlivePlayerThatAffectsSpawning((double) i1, (double) j1, (double) k1, 7.0D) && world.isUnobstructed(entityzombie) && world.noCollision((Entity) entityzombie) && (entityzombie.canSpawnInLiquids() || !world.containsAnyLiquid(entityzombie.getBoundingBox()))) { // Paper - affects spawning api ++ if (!world.hasNearbyAlivePlayerThatAffectsSpawning((double) i1, (double) j1, (double) k1, 7.0D) && world.isUnobstructed(entityzombie) && world.noCollision((Entity) entityzombie) && (entityzombie.canSpawnInLiquids() || !world.containsAnyLiquid(entityzombie.getBoundingBox()))) { // Paper - affects spawning api entityzombie.setTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit entityzombie.finalizeSpawn(world, world.getCurrentDifficultyAt(entityzombie.blockPosition()), EntitySpawnReason.REINFORCEMENT, (SpawnGroupData) null); world.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit diff --git a/patches/server/Remap-fixes.patch b/patches/server/Remap-fixes.patch index 2abac08787..2c49c8c758 100644 --- a/patches/server/Remap-fixes.patch +++ b/patches/server/Remap-fixes.patch @@ -58,6 +58,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 entityliving1 = entityliving2; } else { entityliving1 = null; +diff --git a/src/main/java/net/minecraft/world/entity/animal/Dolphin.java b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/animal/Dolphin.java ++++ b/src/main/java/net/minecraft/world/entity/animal/Dolphin.java +@@ -0,0 +0,0 @@ public class Dolphin extends AgeableWaterCreature { + + @Nullable + @Override +- protected SoundEvent getDeathSound() { ++ public SoundEvent getDeathSound() { // Paper - remap fixes + return SoundEvents.DOLPHIN_DEATH; + } + diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java diff --git a/patches/server/Timings-v2.patch b/patches/server/Timings-v2.patch index fbfd090076..a569fd9d3d 100644 --- a/patches/server/Timings-v2.patch +++ b/patches/server/Timings-v2.patch @@ -1352,9 +1352,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public EntityType(EntityType.EntityFactory factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet canSpawnInside, EntityDimensions dimensions, float spawnBoxScale, int maxTrackDistance, int trackTickInterval, String translationKey, Optional> lootTable, FeatureFlagSet requiredFeatures) { + // Paper start -+ this(factory, spawnGroup, saveable, summonable, fireImmune, spawnableFarFromPlayer, canSpawnInside, dimensions, spawnBoxScale, maxTrackDistance, trackTickInterval, requiredFeatures, "custom"); ++ this(factory, spawnGroup, saveable, summonable, fireImmune, spawnableFarFromPlayer, canSpawnInside, dimensions, spawnBoxScale, maxTrackDistance, trackTickInterval, translationKey, lootTable, requiredFeatures, "custom"); + } -+ public EntityType(EntityType.EntityFactory factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet canSpawnInside, EntityDimensions dimensions, float spawnBoxScale, int maxTrackDistance, int trackTickInterval, FeatureFlagSet requiredFeatures, String id) { ++ public EntityType(EntityType.EntityFactory factory, MobCategory spawnGroup, boolean saveable, boolean summonable, boolean fireImmune, boolean spawnableFarFromPlayer, ImmutableSet canSpawnInside, EntityDimensions dimensions, float spawnBoxScale, int maxTrackDistance, int trackTickInterval, String translationKey, Optional> lootTable, FeatureFlagSet requiredFeatures, String id) { + this.tickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "tick"); + this.inactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "inactiveTick"); + this.passengerTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerTick"); @@ -1378,15 +1378,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public boolean trackDeltas() { return this != EntityType.PLAYER && this != EntityType.LLAMA_SPIT && this != EntityType.WITHER && this != EntityType.BAT && this != EntityType.ITEM_FRAME && this != EntityType.GLOW_ITEM_FRAME && this != EntityType.LEASH_KNOT && this != EntityType.PAINTING && this != EntityType.END_CRYSTAL && this != EntityType.EVOKER_FANGS; } -@@ -0,0 +0,0 @@ public class EntityType implements FeatureElement, EntityTypeT - Util.fetchChoiceType(References.ENTITY_TREE, registryKey.location().toString()); - } - -- return new EntityType<>(this.factory, this.category, this.serialize, this.summon, this.fireImmune, this.canSpawnFarFromPlayer, this.immuneTo, this.dimensions.withAttachments(this.attachments), this.spawnDimensionsScale, this.clientTrackingRange, this.updateInterval, (String) this.descriptionId.get(registryKey), (Optional) this.lootTable.get(registryKey), this.requiredFeatures); -+ return new EntityType<>(this.factory, this.category, this.serialize, this.summon, this.fireImmune, this.canSpawnFarFromPlayer, this.immuneTo, this.dimensions.withAttachments(this.attachments), this.spawnDimensionsScale, this.clientTrackingRange, this.updateInterval, (String) this.descriptionId.get(registryKey), (Optional) this.lootTable.get(registryKey), this.requiredFeatures, this.id); // Paper - add id - } - } - diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/patches/server/Validate-ResourceLocation-in-NBT-reading.patch b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch index dc34efcc70..57f0170f5d 100644 --- a/patches/server/Validate-ResourceLocation-in-NBT-reading.patch +++ b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch @@ -139,7 +139,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.setContainerLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("LootTable")))); + this.setContainerLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation // Paper start - LootTable API - if (this.getLootTable() != null) { + if (this.getContainerLootTable() != null) { this.lootableData().loadNbt(nbt); diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/server/prevent-unintended-light-block-manipulation.patch b/patches/server/prevent-unintended-light-block-manipulation.patch index d3f4082f68..009ec3dc9d 100644 --- a/patches/server/prevent-unintended-light-block-manipulation.patch +++ b/patches/server/prevent-unintended-light-block-manipulation.patch @@ -8,24 +8,14 @@ diff --git a/src/main/java/net/minecraft/world/level/block/LightBlock.java b/src index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/LightBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LightBlock.java -@@ -0,0 +0,0 @@ import java.util.function.ToIntFunction; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; - import net.minecraft.core.component.DataComponents; -+import net.minecraft.server.level.ServerLevel; - import net.minecraft.util.RandomSource; -+import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.ItemStack; @@ -0,0 +0,0 @@ public class LightBlock extends Block implements SimpleWaterloggedBlock { builder.add(LEVEL, WATERLOGGED); } + // Paper start - prevent unintended light block manipulation + @Override -+ protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { -+ if (player.getItemInHand(hand).getItem() != Items.LIGHT || (world instanceof final ServerLevel serverLevel && !player.mayInteract(serverLevel, pos)) || !player.mayUseItemAt(pos, hit.getDirection(), player.getItemInHand(hand))) { return net.minecraft.world.InteractionResult.PASS; } // Paper - Prevent unintended light block manipulation ++ protected InteractionResult useItemOn(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, net.minecraft.world.InteractionHand hand, BlockHitResult hit) { ++ if (player.getItemInHand(hand).getItem() != Items.LIGHT || (world instanceof final net.minecraft.server.level.ServerLevel serverLevel && !player.mayInteract(serverLevel, pos)) || !player.mayUseItemAt(pos, hit.getDirection(), player.getItemInHand(hand))) { return net.minecraft.world.InteractionResult.PASS; } // Paper - Prevent unintended light block manipulation + return super.useItemOn(stack, state, world, pos, player, hand, hit); + } + // Paper end - prevent unintended light block manipulation