mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-01 05:58:00 +01:00
Fix crash with empty recipe and made Instance constructors public
This commit is contained in:
parent
a63693b82b
commit
2daccd9d9b
@ -9,14 +9,8 @@ import fr.themode.demo.commands.HealthCommand;
|
||||
import fr.themode.demo.commands.SimpleCommand;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.command.CommandManager;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.instance.block.BlockManager;
|
||||
import net.minestom.server.instance.block.rule.vanilla.RedstonePlacementRule;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket;
|
||||
import net.minestom.server.recipe.RecipeManager;
|
||||
import net.minestom.server.recipe.ShapelessRecipe;
|
||||
import net.minestom.server.storage.StorageManager;
|
||||
import net.minestom.server.storage.systems.FileStorageSystem;
|
||||
import net.minestom.server.timer.TaskRunnable;
|
||||
@ -42,7 +36,7 @@ public class Main {
|
||||
commandManager.register(new GamemodeCommand());
|
||||
commandManager.register(new DimensionCommand());
|
||||
|
||||
RecipeManager recipeManager = MinecraftServer.getRecipeManager();
|
||||
/*RecipeManager recipeManager = MinecraftServer.getRecipeManager();
|
||||
ShapelessRecipe shapelessRecipe = new ShapelessRecipe("test", "groupname") {
|
||||
@Override
|
||||
public boolean shouldShow(Player player) {
|
||||
@ -53,7 +47,7 @@ public class Main {
|
||||
DeclareRecipesPacket.Ingredient ingredient = new DeclareRecipesPacket.Ingredient();
|
||||
ingredient.items = new ItemStack[]{new ItemStack(Material.STONE, (byte) 3)};
|
||||
shapelessRecipe.addIngredient(ingredient);
|
||||
recipeManager.addRecipe(shapelessRecipe);
|
||||
recipeManager.addRecipe(shapelessRecipe);*/
|
||||
|
||||
StorageManager storageManager = MinecraftServer.getStorageManager();
|
||||
storageManager.defineDefaultStorageSystem(FileStorageSystem::new);
|
||||
|
@ -52,7 +52,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
private Data data;
|
||||
private ExplosionSupplier explosionSupplier;
|
||||
|
||||
protected Instance(UUID uniqueId, Dimension dimension) {
|
||||
public Instance(UUID uniqueId, Dimension dimension) {
|
||||
this.uniqueId = uniqueId;
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class InstanceContainer extends Instance {
|
||||
|
||||
private boolean autoChunkLoad;
|
||||
|
||||
protected InstanceContainer(UUID uniqueId, Dimension dimension, StorageFolder storageFolder) {
|
||||
public InstanceContainer(UUID uniqueId, Dimension dimension, StorageFolder storageFolder) {
|
||||
super(uniqueId, dimension);
|
||||
this.storageFolder = storageFolder;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class SharedInstance extends Instance {
|
||||
|
||||
private InstanceContainer instanceContainer;
|
||||
|
||||
protected SharedInstance(UUID uniqueId, InstanceContainer instanceContainer) {
|
||||
public SharedInstance(UUID uniqueId, InstanceContainer instanceContainer) {
|
||||
super(uniqueId, instanceContainer.getDimension());
|
||||
this.instanceContainer = instanceContainer;
|
||||
}
|
||||
|
@ -108,8 +108,9 @@ public class LoginStartPacket implements ClientPreplayPacket {
|
||||
{
|
||||
RecipeManager recipeManager = MinecraftServer.getRecipeManager();
|
||||
DeclareRecipesPacket declareRecipesPacket = recipeManager.getDeclareRecipesPacket();
|
||||
|
||||
connection.sendPacket(declareRecipesPacket);
|
||||
if (declareRecipesPacket.recipes != null) {
|
||||
connection.sendPacket(declareRecipesPacket);
|
||||
}
|
||||
|
||||
List<String> recipesIdentifier = new ArrayList<>();
|
||||
for (Recipe recipe : recipeManager.getRecipes()) {
|
||||
@ -118,12 +119,14 @@ public class LoginStartPacket implements ClientPreplayPacket {
|
||||
|
||||
recipesIdentifier.add(recipe.getRecipeId());
|
||||
}
|
||||
String[] identifiers = recipesIdentifier.toArray(new String[recipesIdentifier.size()]);
|
||||
UnlockRecipesPacket unlockRecipesPacket = new UnlockRecipesPacket();
|
||||
unlockRecipesPacket.mode = 0;
|
||||
unlockRecipesPacket.recipesId = identifiers;
|
||||
unlockRecipesPacket.initRecipesId = identifiers;
|
||||
connection.sendPacket(unlockRecipesPacket);
|
||||
if (!recipesIdentifier.isEmpty()) {
|
||||
String[] identifiers = recipesIdentifier.toArray(new String[recipesIdentifier.size()]);
|
||||
UnlockRecipesPacket unlockRecipesPacket = new UnlockRecipesPacket();
|
||||
unlockRecipesPacket.mode = 0;
|
||||
unlockRecipesPacket.recipesId = identifiers;
|
||||
unlockRecipesPacket.initRecipesId = identifiers;
|
||||
connection.sendPacket(unlockRecipesPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user