Christmas fun :)

This commit is contained in:
Aidan Brady 2013-12-24 13:25:31 -05:00
parent 8323ea6415
commit 84f4eaee76
12 changed files with 91 additions and 13 deletions

View file

@ -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();
}

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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<String> 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);
}
}
}

View file

@ -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;
}

View file

@ -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);
}