From 16f03e76e82cfbde8f3c355fa1224a3b88472f06 Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Wed, 26 Oct 2016 20:34:04 +0200 Subject: [PATCH] Allow max 1 crafting sound every 10 ticks to prevent rare crashes. --- src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java | 5 ++++- src/main/java/gregtech/common/GT_Proxy.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index 0fae6d11..b368a47b 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import crazypants.enderio.api.tool.ITool; import forestry.api.arboriculture.IToolGrafter; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enchants.Enchantment_Radioactivity; import gregtech.api.enums.Materials; @@ -16,6 +17,7 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Proxy; import mods.railcraft.api.core.items.IToolCrowbar; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; @@ -476,7 +478,8 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements if (tStats == null) return null; doDamage(aStack, tStats.getToolDamagePerContainerCraft()); aStack = aStack.stackSize > 0 ? aStack : null; - if (playSound) { + if (playSound && GT_Mod.gregtechproxy.mTicksUntilNextCraftSound <= 0) { + GT_Mod.gregtechproxy.mTicksUntilNextCraftSound = 10; String sound = (aStack == null) ? tStats.getBreakingSound() : tStats.getCraftingSound(); GT_Utility.doSoundAtClient(sound, 1, 1.0F); } diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 00bc5ab0..00ee739e 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -173,6 +173,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public int mPollutionPoisonLimit = 750000; public int mPollutionVegetationLimit = 1000000; public int mPollutionSourRainLimit = 2000000; + public int mTicksUntilNextCraftSound = 0; public double mMagneticraftBonusOutputPercent = 100.0d; private World mUniverse = null; private final String aTextThermalExpansion = "ThermalExpansion"; @@ -1186,10 +1187,12 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { @SubscribeEvent public void onWorldTickEvent(TickEvent.WorldTickEvent aEvent) { + if(aEvent.world.provider.dimensionId == 0) + mTicksUntilNextCraftSound--; if (aEvent.side.isServer()) { if (this.mUniverse == null) { this.mUniverse = aEvent.world; - } + } if (this.isFirstServerWorldTick) { File tSaveDiretory = getSaveDirectory(); if (tSaveDiretory != null) {