From 70ef43b8ddbb7c56c487f97223619068c71d08d9 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 21 Dec 2024 15:53:00 +0100 Subject: [PATCH] More cleanup of var names --- .../world/item/FishingRodItem.java.patch | 6 ++-- .../item/ProjectileWeaponItem.java.patch | 12 ++++--- .../item/StandingAndWallBlockItem.java.patch | 2 +- .../item/crafting/RecipeManager.java.patch | 4 +-- .../world/item/crafting/RecipeMap.java.patch | 35 +++++-------------- .../AbstractFurnaceBlockEntity.java.patch | 8 ++--- .../block/entity/BannerBlockEntity.java.patch | 8 ++--- .../entity/BeehiveBlockEntity.java.patch | 4 +-- 8 files changed, 30 insertions(+), 49 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch index e9d2feeb53..d3a5d6505d 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch @@ -29,8 +29,8 @@ int fishingLuckBonus = EnchantmentHelper.getFishingLuckBonus(serverLevel, itemInHand, player); - Projectile.spawnProjectile(new FishingHook(player, level, fishingLuckBonus, i1), serverLevel, itemInHand); + // CraftBukkit start -+ FishingHook entityfishinghook = new FishingHook(player, level, fishingLuckBonus, i1); -+ org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) player.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), org.bukkit.event.player.PlayerFishEvent.State.FISHING); ++ FishingHook fishingHook = new FishingHook(player, level, fishingLuckBonus, i1); ++ org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) player.getBukkitEntity(), null, (org.bukkit.entity.FishHook) fishingHook.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), org.bukkit.event.player.PlayerFishEvent.State.FISHING); + level.getCraftServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { @@ -47,7 +47,7 @@ + 0.5F, + 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) + ); -+ Projectile.spawnProjectile(entityfishinghook, serverLevel, itemInHand); ++ Projectile.spawnProjectile(fishingHook, serverLevel, itemInHand); + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch index 4e04b8e5b1..bfc05c761e 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ProjectileWeaponItem.java +++ b/net/minecraft/world/item/ProjectileWeaponItem.java -@@ -62,12 +_,25 @@ +@@ -62,12 +_,29 @@ float f4 = f2 + f3 * ((i + 1) / 2) * f1; f3 = -f3; int i1 = i; @@ -21,9 +21,13 @@ + } + + if (event.getProjectile() == projectile.getBukkitEntity()) { -+ if (Projectile.spawnProjectile(projectile, level, itemStack).isRemoved()) { -+ if (shooter instanceof net.minecraft.server.level.ServerPlayer) { -+ ((net.minecraft.server.level.ServerPlayer) shooter).getBukkitEntity().updateInventory(); ++ if (Projectile.spawnProjectile( ++ projectile, ++ level, ++ itemStack ++ ).isRemoved()) { ++ if (shooter instanceof net.minecraft.server.level.ServerPlayer serverPlayer) { ++ serverPlayer.getBukkitEntity().updateInventory(); + } + return; + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch index 65b7227e59..e99c04062a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/StandingAndWallBlockItem.java.patch @@ -9,7 +9,7 @@ + // CraftBukkit start + if (blockState != null) { + boolean defaultReturn = level.isUnobstructed(blockState, clickedPos, CollisionContext.empty()); -+ org.bukkit.entity.Player player = (context.getPlayer() instanceof net.minecraft.server.level.ServerPlayer) ? (org.bukkit.entity.Player) context.getPlayer().getBukkitEntity() : null; ++ org.bukkit.entity.Player player = (context.getPlayer() instanceof net.minecraft.server.level.ServerPlayer serverPlayer) ? serverPlayer.getBukkitEntity() : null; + + org.bukkit.event.block.BlockCanBuildEvent event = new org.bukkit.event.block.BlockCanBuildEvent(org.bukkit.craftbukkit.block.CraftBlock.at(context.getLevel(), clickedPos), player, org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(blockState), defaultReturn, org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand())); // Paper - Expose hand in BlockCanBuildEvent + context.getLevel().getCraftServer().getPluginManager().callEvent(event); diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch index 03dc6953c4..dcc5613328 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -5,9 +5,9 @@ } + // CraftBukkit start -+ public void addRecipe(RecipeHolder irecipe) { ++ public void addRecipe(RecipeHolder holder) { + org.spigotmc.AsyncCatcher.catchOp("Recipe Add"); // Spigot -+ this.recipes.addRecipe(irecipe); ++ this.recipes.addRecipe(holder); + this.finalizeRecipeLoading(); + } + diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeMap.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeMap.java.patch index ae4eba51bc..77d44ed126 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/RecipeMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RecipeMap.java +++ b/net/minecraft/world/item/crafting/RecipeMap.java -@@ -30,8 +_,53 @@ +@@ -30,8 +_,34 @@ builder1.put(recipeHolder.id(), recipeHolder); } @@ -10,34 +10,18 @@ + return new RecipeMap(com.google.common.collect.LinkedHashMultimap.create(builder.build()), com.google.common.collect.Maps.newHashMap(builder1.build())); + } + -+ public void addRecipe(RecipeHolder irecipe) { -+ Collection> map = this.byType.get(irecipe.value().getType()); ++ public void addRecipe(RecipeHolder holder) { ++ Collection> recipes = this.byType.get(holder.value().getType()); + -+ if (this.byKey.containsKey(irecipe.id())) { -+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id()); ++ if (this.byKey.containsKey(holder.id())) { ++ throw new IllegalStateException("Duplicate recipe ignored with ID " + holder.id()); + } else { -+ map.add(irecipe); -+ this.byKey.put(irecipe.id(), irecipe); ++ recipes.add(holder); ++ this.byKey.put(holder.id(), holder); + } + } -+ -+ // public boolean removeRecipe(ResourceKey> mcKey) { -+ // boolean removed = false; -+ // Iterator> iter = this.byType.values().iterator(); -+ // while (iter.hasNext()) { -+ // RecipeHolder recipe = iter.next(); -+ // if (recipe.id().equals(mcKey)) { -+ // iter.remove(); -+ // removed = true; -+ // } -+ // } -+ // removed |= this.byKey.remove(mcKey) != null; -+ // -+ // return removed; -+ // } + // CraftBukkit end + -+ + // Paper start - replace removeRecipe implementation + public boolean removeRecipe(ResourceKey> mcKey) { + //noinspection unchecked @@ -46,10 +30,7 @@ + return false; + } + final Collection>> recipes = this.byType(remove.value().getType()); -+ if (recipes.remove(remove)) { -+ return true; -+ } -+ return false; ++ return recipes.remove(remove); + // Paper end - why are you using a loop??? + } + // Paper end - replace removeRecipe implementation diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index f57bc6379f..5907877ed7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -214,12 +214,8 @@ this.cookingTimer = 0; this.setChanged(); } -@@ -339,11 +_,11 @@ - } - - @Override -- public void awardUsedRecipes(Player player, List items) { -+ public void awardUsedRecipes(net.minecraft.world.entity.player.Player player, List items) { +@@ -342,8 +_,8 @@ + public void awardUsedRecipes(Player player, List items) { } - public void awardUsedRecipesAndPopExperience(ServerPlayer player) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch index 152410ce51..a398e2a015 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch @@ -61,11 +61,11 @@ } + + // CraftBukkit start -+ public void setPatterns(BannerPatternLayers bannerpatternlayers) { -+ if (bannerpatternlayers.layers().size() > 20) { -+ bannerpatternlayers = new BannerPatternLayers(java.util.List.copyOf(bannerpatternlayers.layers().subList(0, 20))); ++ public void setPatterns(BannerPatternLayers bannerPatternLayers) { ++ if (bannerPatternLayers.layers().size() > 20) { ++ bannerPatternLayers = new BannerPatternLayers(java.util.List.copyOf(bannerPatternLayers.layers().subList(0, 20))); + } -+ this.patterns = bannerpatternlayers; ++ this.patterns = bannerPatternLayers; + } + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch index 4826839013..7950dedc62 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch @@ -4,7 +4,7 @@ private List stored = Lists.newArrayList(); @Nullable public BlockPos savedFlowerPos; -+ public int maxBees = 3; // CraftBukkit - allow setting max amount of bees a hive can hold ++ public int maxBees = MAX_OCCUPANTS; // CraftBukkit - allow setting max amount of bees a hive can hold public BeehiveBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.BEEHIVE, pos, blockState); @@ -64,7 +64,7 @@ + if (this.level != null) { + org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(bee.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.getBlockPos())); + if (!event.callEvent()) { -+ bee.setStayOutOfHiveCountdown(400); ++ bee.setStayOutOfHiveCountdown(MIN_TICKS_BEFORE_REENTERING_HIVE); + return; + } + }