2012-11-05 20:29:04 +01:00
|
|
|
package mekanism.client;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
|
|
|
import java.util.EnumSet;
|
2013-07-20 18:10:14 +02:00
|
|
|
import java.util.HashMap;
|
2013-06-21 17:47:01 +02:00
|
|
|
import java.util.List;
|
2013-07-20 18:10:14 +02:00
|
|
|
import java.util.Map;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
2012-11-05 20:29:04 +01:00
|
|
|
import mekanism.common.Mekanism;
|
2013-10-14 20:59:48 +02:00
|
|
|
import mekanism.common.ObfuscatedNames;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
2013-06-21 17:47:01 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2013-07-20 18:10:14 +02:00
|
|
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
2013-06-21 17:47:01 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.util.StringUtils;
|
2013-02-14 19:26:13 +01:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
2012-08-15 22:41:41 +02:00
|
|
|
import cpw.mods.fml.common.ITickHandler;
|
|
|
|
import cpw.mods.fml.common.TickType;
|
2013-04-13 16:33:37 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
2012-09-08 18:48:24 +02:00
|
|
|
/**
|
2012-11-05 20:29:04 +01:00
|
|
|
* Client-side tick handler for Mekanism. Used mainly for the update check upon startup.
|
2012-09-08 18:48:24 +02:00
|
|
|
* @author AidanBrady
|
|
|
|
*
|
|
|
|
*/
|
2013-04-13 16:33:37 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2012-08-15 22:41:41 +02:00
|
|
|
public class ClientTickHandler implements ITickHandler
|
|
|
|
{
|
2012-12-21 14:30:40 +01:00
|
|
|
public boolean hasNotified = false;
|
2012-11-27 01:18:50 +01:00
|
|
|
|
2013-06-21 17:47:01 +02:00
|
|
|
public Minecraft mc = FMLClientHandler.instance().getClient();
|
|
|
|
|
2013-07-20 18:10:14 +02:00
|
|
|
public static final String MIKE_CAPE = "https://dl.dropboxusercontent.com/s/ji06yflixnszcby/cape.png";
|
|
|
|
public static final String DONATE_CAPE = "https://dl.dropboxusercontent.com/u/90411166/donate.png";
|
|
|
|
public static final String AIDAN_CAPE = "https://dl.dropboxusercontent.com/u/90411166/aidan.png";
|
|
|
|
|
2013-10-14 21:54:10 +02:00
|
|
|
private Map<String, CapeBufferDownload> mikeDownload = new HashMap<String, CapeBufferDownload>();
|
|
|
|
private Map<String, CapeBufferDownload> donateDownload = new HashMap<String, CapeBufferDownload>();
|
|
|
|
private Map<String, CapeBufferDownload> aidanDownload = new HashMap<String, CapeBufferDownload>();
|
2013-06-21 17:47:01 +02:00
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
|
|
|
{
|
2013-06-21 17:47:01 +02:00
|
|
|
if(!hasNotified && mc.theWorld != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
|
2012-08-15 22:41:41 +02:00
|
|
|
{
|
2013-06-21 17:47:01 +02:00
|
|
|
MekanismUtils.checkForUpdates(mc.thePlayer);
|
2012-12-21 14:30:40 +01:00
|
|
|
hasNotified = true;
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
2013-06-21 17:47:01 +02:00
|
|
|
|
|
|
|
if(mc.theWorld != null)
|
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
for(EntityPlayer entityPlayer : (List<EntityPlayer>)mc.theWorld.playerEntities)
|
2013-06-21 17:47:01 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
if(entityPlayer instanceof AbstractClientPlayer)
|
2013-06-24 18:24:04 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
AbstractClientPlayer player = (AbstractClientPlayer)entityPlayer;
|
|
|
|
|
|
|
|
if(player != null)
|
|
|
|
{
|
2013-06-24 18:24:04 +02:00
|
|
|
if(StringUtils.stripControlCodes(player.username).equals("mikeacttck"))
|
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
CapeBufferDownload download = mikeDownload.get(player.username);
|
|
|
|
|
|
|
|
if(download == null)
|
2013-07-20 18:10:14 +02:00
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
download = new CapeBufferDownload(player.username, MIKE_CAPE);
|
|
|
|
mikeDownload.put(player.username, download);
|
|
|
|
|
|
|
|
download.start();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(!download.downloaded)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
2013-07-20 18:10:14 +02:00
|
|
|
}
|
2013-06-24 18:24:04 +02:00
|
|
|
}
|
|
|
|
else if(StringUtils.stripControlCodes(player.username).equals("aidancbrady"))
|
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
CapeBufferDownload download = aidanDownload.get(player.username);
|
|
|
|
|
|
|
|
if(download == null)
|
2013-07-20 18:10:14 +02:00
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
download = new CapeBufferDownload(player.username, AIDAN_CAPE);
|
|
|
|
aidanDownload.put(player.username, download);
|
|
|
|
|
|
|
|
download.start();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(!download.downloaded)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
2013-07-20 18:10:14 +02:00
|
|
|
}
|
2013-06-24 18:24:04 +02:00
|
|
|
}
|
2013-07-20 18:10:14 +02:00
|
|
|
else if(Mekanism.donators.contains(StringUtils.stripControlCodes(player.username)) || player.username.contains("Player"))
|
2013-06-24 18:24:04 +02:00
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
CapeBufferDownload download = donateDownload.get(player.username);
|
|
|
|
|
|
|
|
if(download == null)
|
2013-07-20 18:10:14 +02:00
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
download = new CapeBufferDownload(player.username, DONATE_CAPE);
|
|
|
|
donateDownload.put(player.username, download);
|
|
|
|
|
|
|
|
download.start();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(!download.downloaded)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
2013-07-20 18:10:14 +02:00
|
|
|
}
|
2013-06-24 18:24:04 +02:00
|
|
|
}
|
2013-07-20 18:10:14 +02:00
|
|
|
}
|
2013-06-24 18:24:04 +02:00
|
|
|
}
|
2013-06-21 17:47:01 +02:00
|
|
|
}
|
|
|
|
}
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
|
|
|
{
|
2013-10-15 05:36:07 +02:00
|
|
|
if(MekanismClient.audioHandler != null)
|
2012-12-30 22:34:45 +01:00
|
|
|
{
|
2013-10-15 05:36:07 +02:00
|
|
|
synchronized(MekanismClient.audioHandler.sounds)
|
2013-02-14 19:26:13 +01:00
|
|
|
{
|
2013-10-15 05:36:07 +02:00
|
|
|
MekanismClient.audioHandler.onTick();
|
2013-02-14 19:26:13 +01:00
|
|
|
}
|
2012-12-30 22:34:45 +01:00
|
|
|
}
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
2013-02-14 19:26:13 +01:00
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public EnumSet<TickType> ticks()
|
|
|
|
{
|
2012-08-24 02:04:52 +02:00
|
|
|
return EnumSet.of(TickType.CLIENT);
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public String getLabel()
|
|
|
|
{
|
2013-01-21 02:15:59 +01:00
|
|
|
return "MekanismClient";
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
}
|