1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2021-03-22 15:43:20 +01:00
parent f6d4d20090
commit e277732608
2 changed files with 12 additions and 1 deletions

View File

@ -38,6 +38,7 @@
* Fixed items getting deleted when breaking enhanced furnaces
* Fixed #2895
* Fixed #2896
* Fixed #2899
## Release Candidate 21 (14 Mar 2021)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#21

View File

@ -37,6 +37,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.AutoCrafterLi
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.papermc.lib.PaperLib;
import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
@ -218,7 +219,9 @@ public abstract class AbstractAutoCrafter extends SlimefunItem implements Energy
*/
protected void setSelectedRecipe(@Nonnull Block b, @Nullable AbstractRecipe recipe) {
Validate.notNull(b, "The Block cannot be null!");
BlockState state = PaperLib.getBlockState(b, false).getState();
BlockStateSnapshotResult result = PaperLib.getBlockState(b, false);
BlockState state = result.getState();
if (state instanceof Skull) {
if (recipe == null) {
@ -228,6 +231,11 @@ public abstract class AbstractAutoCrafter extends SlimefunItem implements Energy
// Store the value to persistent data storage
PersistentDataAPI.setString((Skull) state, recipeStorageKey, recipe.toString());
}
// Fixes #2899 - Update the BlockState if necessary
if (result.isSnapshot()) {
state.update(true, false);
}
}
}
@ -263,12 +271,14 @@ public abstract class AbstractAutoCrafter extends SlimefunItem implements Energy
return false;
});
// This makes the slots cycle through different ingredients
AsyncRecipeChoiceTask task = new AsyncRecipeChoiceTask();
recipe.show(menu, task);
menu.open(p);
p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
// Only schedule the task if necessary
if (!task.isEmpty()) {
task.start(menu.toInventory());
}