diff --git a/src/main/java/com/minecolonies/core/colony/buildings/modules/AbstractCraftingBuildingModule.java b/src/main/java/com/minecolonies/core/colony/buildings/modules/AbstractCraftingBuildingModule.java index 88c98ad2f93..fac38964d18 100644 --- a/src/main/java/com/minecolonies/core/colony/buildings/modules/AbstractCraftingBuildingModule.java +++ b/src/main/java/com/minecolonies/core/colony/buildings/modules/AbstractCraftingBuildingModule.java @@ -106,6 +106,11 @@ public abstract class AbstractCraftingBuildingModule extends AbstractBuildingMod */ protected AbstractBuilding building; + /** + * Dirty flag for recipes + */ + private boolean recipesDirty = true; + /** * Create a new module. * @param jobEntry the entry of the job. @@ -248,7 +253,7 @@ public void deserializeNBT(CompoundTag compound) } @Override - public void serializeToView(@NotNull final FriendlyByteBuf buf) + public void serializeToView(@NotNull final FriendlyByteBuf buf, final boolean fullSync) { if (jobEntry != null) { @@ -267,39 +272,46 @@ public void serializeToView(@NotNull final FriendlyByteBuf buf) buf.writeRegistryIdUnsafe(MinecoloniesAPIProxy.getInstance().getCraftingTypeRegistry(), type); } - final List storages = new ArrayList<>(); - final List disabledStorages = new ArrayList<>(); - final Map crafterRecipes = CustomRecipeManager.getInstance().getAllRecipes().getOrDefault(getCustomRecipeKey(), Collections.emptyMap()); - for (final IToken token : new ArrayList<>(recipes)) + buf.writeBoolean(recipesDirty || fullSync); + if (recipesDirty || fullSync) { - final IRecipeStorage storage = IColonyManager.getInstance().getRecipeManager().getRecipes().get(token); - - if (storage == null || (storage.getRecipeSource() != null && !crafterRecipes.containsKey(storage.getRecipeSource())) || (!isRecipeCompatibleWithCraftingModule(token) && !isPreTaughtRecipe(storage, crafterRecipes))) - { - removeRecipe(token); - } - else + final List storages = new ArrayList<>(); + final List disabledStorages = new ArrayList<>(); + final Map crafterRecipes = CustomRecipeManager.getInstance().getAllRecipes().getOrDefault(getCustomRecipeKey(), Collections.emptyMap()); + for (final IToken token : new ArrayList<>(recipes)) { - storages.add(storage); - if (disabledRecipes.contains(token)) + final IRecipeStorage storage = IColonyManager.getInstance().getRecipeManager().getRecipes().get(token); + + if (storage == null || (storage.getRecipeSource() != null && !crafterRecipes.containsKey(storage.getRecipeSource())) || ( + !isRecipeCompatibleWithCraftingModule(token) && !isPreTaughtRecipe(storage, crafterRecipes))) { - disabledStorages.add(storage); + removeRecipe(token); + } + else + { + storages.add(storage); + if (disabledRecipes.contains(token)) + { + disabledStorages.add(storage); + } } } - } - buf.writeInt(storages.size()); - for (final IRecipeStorage storage : storages) - { - buf.writeNbt(StandardFactoryController.getInstance().serialize(storage)); - } + buf.writeInt(storages.size()); + for (final IRecipeStorage storage : storages) + { + buf.writeNbt(StandardFactoryController.getInstance().serialize(storage)); + } - buf.writeInt(disabledStorages.size()); - for (final IRecipeStorage storage : disabledStorages) - { - buf.writeNbt(StandardFactoryController.getInstance().serialize(storage)); + buf.writeInt(disabledStorages.size()); + for (final IRecipeStorage storage : disabledStorages) + { + buf.writeNbt(StandardFactoryController.getInstance().serialize(storage)); + } } + recipesDirty = false; + buf.writeInt(getMaxRecipes()); buf.writeUtf(getId()); buf.writeBoolean(isVisible()); @@ -558,6 +570,7 @@ else if((forceReplace || newRecipe.getMustExist()) && !(duplicateFound.equals(re public void clearRecipes() { recipes.clear(); + recipesDirty = true; } @Override @@ -822,6 +835,7 @@ public void replaceRecipe(final IToken oldRecipe, final IToken newRecipe) { if (recipes.contains(oldRecipe)) { + recipesDirty = true; int oldIndex = recipes.indexOf(oldRecipe); recipes.add(oldIndex, newRecipe); recipes.remove(oldRecipe); @@ -834,6 +848,7 @@ public void removeRecipe(final IToken token) { if(recipes.remove(token)) { + recipesDirty = true; disabledRecipes.remove(token); markDirty(); } @@ -849,6 +864,7 @@ public void addRecipeToList(final IToken token, boolean atTop) { if (!recipes.contains(token)) { + recipesDirty = true; if(atTop) { recipes.add(0, token); @@ -863,6 +879,7 @@ public void addRecipeToList(final IToken token, boolean atTop) @Override public void switchOrder(final int i, final int j, final boolean fullMove) { + recipesDirty = true; if (fullMove) { if (i > j) diff --git a/src/main/java/com/minecolonies/core/colony/buildings/moduleviews/CraftingModuleView.java b/src/main/java/com/minecolonies/core/colony/buildings/moduleviews/CraftingModuleView.java index 98b02ee8852..18f7b4722f3 100644 --- a/src/main/java/com/minecolonies/core/colony/buildings/moduleviews/CraftingModuleView.java +++ b/src/main/java/com/minecolonies/core/colony/buildings/moduleviews/CraftingModuleView.java @@ -89,26 +89,29 @@ public void deserialize(@NotNull FriendlyByteBuf buf) } } - recipes.clear(); - disabledRecipes.clear(); - - final int recipesSize = buf.readInt(); - for (int i = 0; i < recipesSize; i++) + if (buf.readBoolean()) { - final IRecipeStorage storage = StandardFactoryController.getInstance().deserialize(buf.readNbt()); - if (storage != null) + recipes.clear(); + disabledRecipes.clear(); + + final int recipesSize = buf.readInt(); + for (int i = 0; i < recipesSize; i++) { - recipes.add(storage); + final IRecipeStorage storage = StandardFactoryController.getInstance().deserialize(buf.readNbt()); + if (storage != null) + { + recipes.add(storage); + } } - } - final int disabledRecipeSize = buf.readInt(); - for (int i = 0; i < disabledRecipeSize; i++) - { - final IRecipeStorage storage = StandardFactoryController.getInstance().deserialize(buf.readNbt()); - if (storage != null) + final int disabledRecipeSize = buf.readInt(); + for (int i = 0; i < disabledRecipeSize; i++) { - disabledRecipes.add(storage); + final IRecipeStorage storage = StandardFactoryController.getInstance().deserialize(buf.readNbt()); + if (storage != null) + { + disabledRecipes.add(storage); + } } } diff --git a/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/MinecoloniesAdvancedPathNavigate.java b/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/MinecoloniesAdvancedPathNavigate.java index ea1f65f9a99..e34fa87818f 100644 --- a/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/MinecoloniesAdvancedPathNavigate.java +++ b/src/main/java/com/minecolonies/core/entity/pathfinding/navigation/MinecoloniesAdvancedPathNavigate.java @@ -248,6 +248,11 @@ public PathResult setPathJob( return null; } + if (PathfindingUtils.trackingMap.containsValue(ourEntity.getUUID())) + { + Log.getLogger().info(ourEntity + " started pathjob to:" + dest + " job type:" + job.getClass().getSimpleName()); + } + stop(); this.destination = dest; @@ -984,7 +989,7 @@ protected void followThePath() } } - if (isTracking) + if (isTracking && reached != null) { PathfindingUtils.syncDebugReachedPositions(reached, ourEntity); reached.clear(); @@ -1028,7 +1033,7 @@ else if (isTracking) } } - if (isTracking) + if (isTracking && reached != null) { PathfindingUtils.syncDebugReachedPositions(reached, ourEntity); reached.clear(); diff --git a/src/main/resources/assets/minecolonies/lang/manual_en_us.json b/src/main/resources/assets/minecolonies/lang/manual_en_us.json index 96441c23650..ac8c054448a 100644 --- a/src/main/resources/assets/minecolonies/lang/manual_en_us.json +++ b/src/main/resources/assets/minecolonies/lang/manual_en_us.json @@ -2668,7 +2668,7 @@ "com.minecolonies.creativetab.general": "Minecolonies General", "com.minecolonies.creativetab.food": "Minecolonies Food", - "item.minecolonies.large_empty_bottle": "Large Empty Bottle", + "item.minecolonies.large_empty_bottle": "Large Bottle", "item.minecolonies.large_water_bottle": "Large Water Bottle", "item.minecolonies.large_milk_bottle": "Large Milk Bottle", "item.minecolonies.large_soy_milk_bottle": "Large Soy Milk Bottle",