mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 08:57:35 +01:00
#682: Add hasDiscoveredRecipe() and getDiscoveredRecipes()
This commit is contained in:
parent
d9bd43b060
commit
8297676c20
11
nms-patches/RecipeBook.patch
Normal file
11
nms-patches/RecipeBook.patch
Normal file
@ -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;
|
@ -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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user