Fix RecipeCrafter spamming sound every tick. Thanks to aria1th
* Fix RecipeCrafter spamming sound every tick Recycler was able to spam sound due to this. Now its limited to twice per second * Revert Indent changes & test code Its Identical whitespaces but different? Speed Multiplier was changed to verify packet speed, should be reverted
This commit is contained in:
parent
80ee73ddab
commit
4fc9352c76
1 changed files with 8 additions and 1 deletions
|
@ -92,6 +92,8 @@ public class RecipeCrafter implements IUpgradeHandler {
|
|||
*/
|
||||
public int[] outputSlots;
|
||||
public RebornRecipe currentRecipe;
|
||||
public long lastSoundTime = 0;
|
||||
private long cachedWorldTime = 0;
|
||||
public int currentTickTime = 0;
|
||||
public int currentNeededTicks = 1;// Set to 1 to stop rare crashes
|
||||
|
||||
|
@ -129,6 +131,10 @@ public class RecipeCrafter implements IUpgradeHandler {
|
|||
return;
|
||||
}
|
||||
ticksSinceLastChange++;
|
||||
if (cachedWorldTime == 0){
|
||||
cachedWorldTime = blockEntity.getWorld().getTime();
|
||||
}
|
||||
cachedWorldTime++;
|
||||
// Force a has chanced every second
|
||||
if (ticksSinceLastChange == 20) {
|
||||
setInvDirty(true);
|
||||
|
@ -181,7 +187,8 @@ public class RecipeCrafter implements IUpgradeHandler {
|
|||
long useRequirement = getEuPerTick(currentRecipe.getPower());
|
||||
if (energy.tryUseExact(useRequirement)) {
|
||||
currentTickTime++;
|
||||
if ((currentTickTime == 1 || currentTickTime % 20 == 0) && soundHandler != null) {
|
||||
if ((currentTickTime == 1 || currentTickTime % 20 == 0 && cachedWorldTime > lastSoundTime+ 10) && soundHandler != null) {
|
||||
lastSoundTime = cachedWorldTime;
|
||||
soundHandler.playSound(false, blockEntity);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue