2013-12-27 23:59:59 +01:00
|
|
|
package appeng.client;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2014-01-30 03:47:55 +01:00
|
|
|
import java.util.Random;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
2014-01-28 18:29:17 +01:00
|
|
|
import net.minecraft.client.particle.EntityFX;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.client.renderer.entity.RenderManager;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.init.Items;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
import appeng.block.AEBaseBlock;
|
|
|
|
import appeng.client.render.BaseBlockRender;
|
|
|
|
import appeng.client.render.TESRWrapper;
|
|
|
|
import appeng.client.render.WorldRender;
|
2014-01-28 20:27:22 +01:00
|
|
|
import appeng.client.render.effects.EnergyFx;
|
2014-01-28 18:29:17 +01:00
|
|
|
import appeng.client.render.effects.LightningEffect;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.client.render.entity.RenderTinyTNTPrimed;
|
|
|
|
import appeng.client.texture.CableBusTextures;
|
|
|
|
import appeng.client.texture.ExtraTextures;
|
|
|
|
import appeng.entity.EntityTinyTNTPrimed;
|
|
|
|
import appeng.server.ServerHelper;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
|
|
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
2014-02-09 02:34:52 +01:00
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class ClientHelper extends ServerHelper
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init()
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.register( this );
|
|
|
|
|
|
|
|
RenderingRegistry.registerBlockHandler( WorldRender.instance );
|
|
|
|
RenderManager.instance.entityRenderMap.put( EntityTinyTNTPrimed.class, new RenderTinyTNTPrimed() );
|
|
|
|
}
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
@SubscribeEvent
|
2013-12-27 23:59:59 +01:00
|
|
|
public void updateTextureSheet(TextureStitchEvent.Pre ev)
|
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( ev.map.getTextureType() == 0 )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
for (ExtraTextures et : ExtraTextures.values())
|
|
|
|
et.registerIcon( ev.map );
|
|
|
|
|
|
|
|
for (CableBusTextures cb : CableBusTextures.values())
|
|
|
|
cb.registerIcon( ev.map );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public World getWorld()
|
|
|
|
{
|
|
|
|
if ( Platform.isClient() )
|
|
|
|
return Minecraft.getMinecraft().theWorld;
|
|
|
|
else
|
|
|
|
return super.getWorld();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void bindTileEntitySpecialRenderer(Class tile, AEBaseBlock blk)
|
|
|
|
{
|
|
|
|
BaseBlockRender bbr = blk.getRendererInstance().rendererInstance;
|
2014-01-20 17:41:37 +01:00
|
|
|
if ( bbr.hasTESR && tile != null )
|
2013-12-27 23:59:59 +01:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer( tile, new TESRWrapper( bbr ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<EntityPlayer> getPlayers()
|
|
|
|
{
|
|
|
|
if ( Platform.isClient() )
|
|
|
|
{
|
|
|
|
List<EntityPlayer> o = new ArrayList();
|
|
|
|
o.add( Minecraft.getMinecraft().thePlayer );
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return super.getPlayers();
|
|
|
|
}
|
|
|
|
|
2014-01-28 18:29:17 +01:00
|
|
|
@Override
|
|
|
|
public void spawnLightning(World worldObj, double posX, double posY, double posZ)
|
|
|
|
{
|
|
|
|
LightningEffect fx = new LightningEffect( worldObj, posX, posY + 0.3f, posZ, 0.0f, 0.0f, 0.0f );
|
|
|
|
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
|
|
|
}
|
|
|
|
|
2014-01-28 20:27:22 +01:00
|
|
|
@Override
|
|
|
|
public void spawnEnergy(World w, double posX, double posY, double posZ)
|
|
|
|
{
|
|
|
|
float x = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
|
|
|
|
float y = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
|
|
|
|
float z = (float) (((Platform.getRandomInt() % 100) * 0.01) - 0.5) * 0.7f;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
EnergyFx fx = new EnergyFx( w, posX + x, posY + y, posZ + z, Items.diamond );
|
2014-01-28 20:27:22 +01:00
|
|
|
|
|
|
|
fx.motionX = -x * 0.1;
|
|
|
|
fx.motionY = -y * 0.1;
|
|
|
|
fx.motionZ = -z * 0.1;
|
|
|
|
|
|
|
|
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
|
|
|
}
|
2014-01-30 03:47:55 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldAddParticles(Random r)
|
|
|
|
{
|
2014-02-14 06:31:02 +01:00
|
|
|
int setting = Minecraft.getMinecraft().gameSettings.particleSetting;
|
|
|
|
if ( setting == 0 )
|
2014-01-30 03:47:55 +01:00
|
|
|
return true;
|
2014-02-14 06:31:02 +01:00
|
|
|
return r.nextInt( 2 * (setting + 1) ) == 0;
|
2014-01-30 03:47:55 +01:00
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|