13
0
geforkt von Mirrors/Paper

More cleanup of var names

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-12-21 15:53:00 +01:00
Ursprung fd4c10947f
Commit 70ef43b8dd
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
8 geänderte Dateien mit 30 neuen und 49 gelöschten Zeilen

Datei anzeigen

@ -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
}

Datei anzeigen

@ -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;
+ }

Datei anzeigen

@ -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);

Datei anzeigen

@ -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();
+ }
+

Datei anzeigen

@ -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<RecipeHolder<?>> map = this.byType.get(irecipe.value().getType());
+ public void addRecipe(RecipeHolder<?> holder) {
+ Collection<RecipeHolder<?>> 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<Recipe<?>> mcKey) {
+ // boolean removed = false;
+ // Iterator<RecipeHolder<?>> 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 <T extends RecipeInput> boolean removeRecipe(ResourceKey<Recipe<T>> mcKey) {
+ //noinspection unchecked
@ -46,10 +30,7 @@
+ return false;
+ }
+ final Collection<? extends RecipeHolder<? extends Recipe<T>>> 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

Datei anzeigen

@ -214,12 +214,8 @@
this.cookingTimer = 0;
this.setChanged();
}
@@ -339,11 +_,11 @@
}
@Override
- public void awardUsedRecipes(Player player, List<ItemStack> items) {
+ public void awardUsedRecipes(net.minecraft.world.entity.player.Player player, List<ItemStack> items) {
@@ -342,8 +_,8 @@
public void awardUsedRecipes(Player player, List<ItemStack> items) {
}
- public void awardUsedRecipesAndPopExperience(ServerPlayer player) {

Datei anzeigen

@ -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
}

Datei anzeigen

@ -4,7 +4,7 @@
private List<BeehiveBlockEntity.BeeData> 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;
+ }
+ }