diff --git a/common/mekanism/client/ClientProxy.java b/common/mekanism/client/ClientProxy.java index e54fd7f38..8a093ce27 100644 --- a/common/mekanism/client/ClientProxy.java +++ b/common/mekanism/client/ClientProxy.java @@ -63,7 +63,6 @@ import mekanism.client.sound.SoundHandler; import mekanism.common.CommonProxy; import mekanism.common.EntityObsidianTNT; import mekanism.common.EntityRobit; -import mekanism.common.HolidayManager; import mekanism.common.IElectricChest; import mekanism.common.IInvConfiguration; import mekanism.common.Mekanism; @@ -139,6 +138,7 @@ public class ClientProxy extends CommonProxy Mekanism.configuration.load(); MekanismClient.enableSounds = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableSounds", true).getBoolean(true); MekanismClient.fancyUniversalCableRender = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "FancyUniversalCableRender", true).getBoolean(true); + MekanismClient.holidays = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Holidays", true).getBoolean(true); MekanismClient.baseSoundVolume = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SoundVolume", 1).getDouble(1); Mekanism.configuration.save(); } diff --git a/common/mekanism/client/ClientTickHandler.java b/common/mekanism/client/ClientTickHandler.java index 91996f81a..6bec8788e 100644 --- a/common/mekanism/client/ClientTickHandler.java +++ b/common/mekanism/client/ClientTickHandler.java @@ -12,7 +12,6 @@ import mekanism.api.EnumColor; import mekanism.api.IClientTicker; import mekanism.client.sound.GasMaskSound; import mekanism.client.sound.JetpackSound; -import mekanism.common.HolidayManager; import mekanism.common.Mekanism; import mekanism.common.ObfuscatedNames; import mekanism.common.PacketHandler; diff --git a/common/mekanism/common/HolidayManager.java b/common/mekanism/client/HolidayManager.java similarity index 79% rename from common/mekanism/common/HolidayManager.java rename to common/mekanism/client/HolidayManager.java index 86459a2d1..1f4c168cd 100644 --- a/common/mekanism/common/HolidayManager.java +++ b/common/mekanism/client/HolidayManager.java @@ -1,4 +1,4 @@ -package mekanism.common; +package mekanism.client; import java.util.ArrayList; import java.util.Calendar; @@ -19,8 +19,11 @@ public final class HolidayManager public static void init() { - holidays.add(new Christmas()); - holidays.add(new NewYear()); + if(MekanismClient.holidays) + { + holidays.add(new Christmas()); + holidays.add(new NewYear()); + } System.out.println("[Mekanism] Initialized HolidayManager."); } @@ -44,6 +47,28 @@ public final class HolidayManager } catch(Exception e) {} } + public static String filterSound(String sound) + { + if(!MekanismClient.holidays) + { + return sound; + } + + try { + YearlyDate date = getDate(); + + for(Holiday holiday : holidays) + { + if(holiday.getDate().equals(date)) + { + return holiday.filterSound(sound); + } + } + } catch(Exception e) {} + + return sound; + } + private static YearlyDate getDate() { return new YearlyDate(calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)); @@ -54,10 +79,17 @@ public final class HolidayManager public abstract YearlyDate getDate(); public abstract void onEvent(EntityPlayer player); + + public String filterSound(String sound) + { + return sound; + } } private static class Christmas extends Holiday { + private String[] nutcracker = new String[] {"holiday/Nutcracker1.ogg", "holiday/Nutcracker2.ogg", "holiday/Nutcracker3.ogg", "holiday/Nutcracker4.ogg", "holiday/Nutcracker5.ogg"}; + @Override public YearlyDate getDate() { @@ -76,6 +108,33 @@ public final class HolidayManager player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_GREY + "-aidancbrady")); player.sendChatToPlayer(ChatMessageComponent.createFromText(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); } + + @Override + public String filterSound(String sound) + { + if(sound.equals("Chamber.ogg")) + { + return nutcracker[0]; + } + else if(sound.equals("MetallurgicInfuser.ogg")) + { + return nutcracker[1]; + } + else if(sound.equals("PurificationChamber.ogg")) + { + return nutcracker[2]; + } + else if(sound.equals("Smelter.ogg")) + { + return nutcracker[3]; + } + else if(sound.equals("HeatGenerator.ogg")) + { + return nutcracker[4]; + } + + return sound; + } } private static class NewYear extends Holiday diff --git a/common/mekanism/client/MekanismClient.java b/common/mekanism/client/MekanismClient.java index 2cf3a4e44..3aaaad10e 100644 --- a/common/mekanism/client/MekanismClient.java +++ b/common/mekanism/client/MekanismClient.java @@ -24,6 +24,7 @@ public class MekanismClient extends Mekanism //General Configuration public static boolean enableSounds = true; public static boolean fancyUniversalCableRender = true; + public static boolean holidays = true; public static double baseSoundVolume = 1; public static long ticksPassed = 0; diff --git a/common/mekanism/client/sound/SoundHandler.java b/common/mekanism/client/sound/SoundHandler.java index 8f23a2016..84a143d11 100644 --- a/common/mekanism/client/sound/SoundHandler.java +++ b/common/mekanism/client/sound/SoundHandler.java @@ -14,9 +14,10 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import mekanism.api.Object3D; +import mekanism.client.HolidayManager; +import mekanism.client.MekanismClient; import mekanism.common.Mekanism; import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -62,7 +63,7 @@ public class SoundHandler for(String s : listings) { - if(s.contains("etc")) + if(s.contains("etc") || s.contains("holiday")) { continue; } @@ -90,6 +91,26 @@ public class SoundHandler } System.out.println("[Mekanism] Initialized " + listings.size() + " sound effects."); + + if(MekanismClient.holidays) + { + listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sound/holiday"); + + for(String s : listings) + { + if(s.contains("/mekanism/sound/")) + { + s = s.split("/mekanism/sound/")[1]; + } + + if(!s.contains("holiday")) + { + s = "holiday/" + s; + } + + preloadSound(s); + } + } } private List listFiles(String path, String s) @@ -246,7 +267,7 @@ public class SoundHandler { if(obj instanceof TileEntity) { - new TileSound(getIdentifier(), ((IHasSound)obj).getSoundPath(), (TileEntity)obj); + new TileSound(getIdentifier(), HolidayManager.filterSound(((IHasSound)obj).getSoundPath()), (TileEntity)obj); } } } diff --git a/common/mekanism/client/sound/TileSound.java b/common/mekanism/client/sound/TileSound.java index fcef02707..58011f4b2 100644 --- a/common/mekanism/client/sound/TileSound.java +++ b/common/mekanism/client/sound/TileSound.java @@ -1,10 +1,7 @@ package mekanism.client.sound; -import java.net.URL; - -import mekanism.client.MekanismClient; +import mekanism.client.HolidayManager; import mekanism.common.IActiveState; -import net.minecraft.client.Minecraft; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import universalelectricity.core.vector.Vector3; @@ -61,7 +58,7 @@ public class TileSound extends Sound { return false; } - else if(!((IHasSound)tileEntity).getSoundPath().equals(soundPath)) + else if(!HolidayManager.filterSound(((IHasSound)tileEntity).getSoundPath()).equals(soundPath)) { return false; } diff --git a/common/mekanism/common/block/BlockMachine.java b/common/mekanism/common/block/BlockMachine.java index 33ba6f840..f9c21a918 100644 --- a/common/mekanism/common/block/BlockMachine.java +++ b/common/mekanism/common/block/BlockMachine.java @@ -775,6 +775,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds if(((IUpgradeManagement)itemStack.getItem()).supportsUpgrades(itemStack)) { IUpgradeManagement upgrade = (IUpgradeManagement)itemStack.getItem(); + upgrade.setEnergyMultiplier(((IUpgradeManagement)tileEntity).getEnergyMultiplier(), itemStack); upgrade.setSpeedMultiplier(((IUpgradeManagement)tileEntity).getSpeedMultiplier(), itemStack); } diff --git a/resources/assets/mekanism/sound/holiday/Nutcracker1.ogg b/resources/assets/mekanism/sound/holiday/Nutcracker1.ogg new file mode 100644 index 000000000..3a66b2712 Binary files /dev/null and b/resources/assets/mekanism/sound/holiday/Nutcracker1.ogg differ diff --git a/resources/assets/mekanism/sound/holiday/Nutcracker2.ogg b/resources/assets/mekanism/sound/holiday/Nutcracker2.ogg new file mode 100644 index 000000000..53ee10ced Binary files /dev/null and b/resources/assets/mekanism/sound/holiday/Nutcracker2.ogg differ diff --git a/resources/assets/mekanism/sound/holiday/Nutcracker3.ogg b/resources/assets/mekanism/sound/holiday/Nutcracker3.ogg new file mode 100644 index 000000000..e0572afe3 Binary files /dev/null and b/resources/assets/mekanism/sound/holiday/Nutcracker3.ogg differ diff --git a/resources/assets/mekanism/sound/holiday/Nutcracker4.ogg b/resources/assets/mekanism/sound/holiday/Nutcracker4.ogg new file mode 100644 index 000000000..7b7dfbc17 Binary files /dev/null and b/resources/assets/mekanism/sound/holiday/Nutcracker4.ogg differ diff --git a/resources/assets/mekanism/sound/holiday/Nutcracker5.ogg b/resources/assets/mekanism/sound/holiday/Nutcracker5.ogg new file mode 100644 index 000000000..78116bd45 Binary files /dev/null and b/resources/assets/mekanism/sound/holiday/Nutcracker5.ogg differ