3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

#682: Add hasDiscoveredRecipe() and getDiscoveredRecipes()

Dieser Commit ist enthalten in:
Parker Hawke 2020-07-02 09:27:18 +10:00 committet von md_5
Ursprung d9bd43b060
Commit 8297676c20
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: E8E901AC7C617C11
3 geänderte Dateien mit 37 neuen und 0 gelöschten Zeilen

11
nms-patches/RecipeBook.patch Normale Datei
Datei anzeigen

@ -0,0 +1,11 @@
--- a/net/minecraft/server/RecipeBook.java
+++ b/net/minecraft/server/RecipeBook.java
@@ -6,7 +6,7 @@
public class RecipeBook {
- protected final Set<MinecraftKey> a = Sets.newHashSet();
+ public final Set<MinecraftKey> a = Sets.newHashSet(); // PAIL
protected final Set<MinecraftKey> b = Sets.newHashSet();
protected boolean c;
protected boolean d;

Datei anzeigen

@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -506,6 +507,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
return getHandle().undiscoverRecipes(bukkitKeysToMinecraftRecipes(recipes));
}
@Override
public boolean hasDiscoveredRecipe(NamespacedKey recipe) {
return false;
}
@Override
public Set<NamespacedKey> getDiscoveredRecipes() {
return ImmutableSet.of();
}
private Collection<IRecipe<?>> bukkitKeysToMinecraftRecipes(Collection<NamespacedKey> recipeKeys) {
Collection<IRecipe<?>> recipes = new ArrayList<>();
CraftingManager manager = getHandle().world.getMinecraftServer().getCraftingManager();

Datei anzeigen

@ -77,6 +77,7 @@ import org.bukkit.GameMode;
import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Note;
import org.bukkit.OfflinePlayer;
import org.bukkit.Particle;
@ -106,6 +107,7 @@ import org.bukkit.craftbukkit.map.RenderData;
import org.bukkit.craftbukkit.scoreboard.CraftScoreboard;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerRegisterChannelEvent;
@ -757,6 +759,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return new Location(getWorld(), bed.getX(), bed.getY(), bed.getZ());
}
@Override
public boolean hasDiscoveredRecipe(NamespacedKey recipe) {
Preconditions.checkArgument(recipe != null, "recipe cannot be null");
return getHandle().B().b(CraftNamespacedKey.toMinecraft(recipe));
}
@Override
public Set<NamespacedKey> getDiscoveredRecipes() {
ImmutableSet.Builder<NamespacedKey> bukkitRecipeKeys = ImmutableSet.builder();
getHandle().B().a.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key)));
return bukkitRecipeKeys.build();
}
@Override
public void incrementStatistic(Statistic statistic) {
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic);