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