mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Improved performance for idling Enhanced Furnaces on Paper
This commit is contained in:
parent
9719058bbc
commit
06f64725d9
@ -34,6 +34,8 @@
|
||||
* Performance improvement for Programmable Android rotations
|
||||
* Removed Gravel -> Flint recipe from the Grind stone
|
||||
* Performance improvements for miner talismans
|
||||
* Performance improvements for idling Enhanced Furnaces when using Paper
|
||||
* Performance improvements for Rainbow Blocks
|
||||
|
||||
#### Fixes
|
||||
* Fixed Programmable Androids rotating in the wrong direction
|
||||
|
@ -4,10 +4,13 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -64,12 +67,18 @@ public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> {
|
||||
BlockStorage.clearBlockInfo(b);
|
||||
}
|
||||
else {
|
||||
Furnace furnace = (Furnace) b.getState();
|
||||
BlockStateSnapshotResult result = PaperLib.getBlockState(b, false);
|
||||
BlockState state = result.getState();
|
||||
|
||||
if (furnace.getCookTime() > 0) {
|
||||
int cookTime = furnace.getCookTime() + getSpeed() * 10;
|
||||
furnace.setCookTime((short) Math.min(cookTime, furnace.getCookTimeTotal() - 1));
|
||||
furnace.update(true, false);
|
||||
// Check if the BlockState is a Furnace and cooking something
|
||||
if (state instanceof Furnace && ((Furnace) state).getCookTime() > 0) {
|
||||
// Only get a snapshot if necessary
|
||||
if (result.isSnapshot()) {
|
||||
updateFurnace((Furnace) state);
|
||||
}
|
||||
else {
|
||||
updateFurnace((Furnace) b.getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,4 +89,11 @@ public class EnhancedFurnace extends SimpleSlimefunItem<BlockTicker> {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void updateFurnace(Furnace furnace) {
|
||||
// Update the cooktime
|
||||
int cookTime = furnace.getCookTime() + getSpeed() * 10;
|
||||
furnace.setCookTime((short) Math.min(cookTime, furnace.getCookTimeTotal() - 1));
|
||||
furnace.update(true, false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user