2013-05-14 17:34:26 +02:00
|
|
|
package mekanism.client;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
import mekanism.api.Coord4D;
|
2013-05-14 17:34:26 +02:00
|
|
|
import mekanism.common.Mekanism;
|
2014-01-08 02:55:50 +01:00
|
|
|
import mekanism.common.tile.TileEntityDynamicTank;
|
2013-05-14 17:34:26 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
2013-10-15 05:36:07 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-05-14 17:34:26 +02:00
|
|
|
|
2013-05-29 17:35:30 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-05-14 17:34:26 +02:00
|
|
|
public class ThreadTankSparkle extends Thread
|
|
|
|
{
|
|
|
|
public TileEntityDynamicTank pointer;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
public Random random = new Random();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
public Set<TileEntity> iteratedNodes = new HashSet<TileEntity>();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
public ThreadTankSparkle(TileEntityDynamicTank tileEntity)
|
|
|
|
{
|
|
|
|
pointer = tileEntity;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
2013-05-20 00:43:01 +02:00
|
|
|
try {
|
|
|
|
if(Mekanism.dynamicTankEasterEgg)
|
|
|
|
{
|
2014-02-21 23:30:40 +01:00
|
|
|
MekanismClient.audioHandler.quickPlay("cj/CJ_" + (random.nextInt(8)+1) + ".ogg", pointer.worldObj, Coord4D.get(pointer));
|
2013-05-20 00:43:01 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-20 00:43:01 +02:00
|
|
|
loop(pointer);
|
|
|
|
} catch(Exception e) {}
|
2013-05-14 17:34:26 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
public void loop(TileEntityDynamicTank tileEntity)
|
|
|
|
{
|
|
|
|
World world = pointer.worldObj;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
for(int i = 0; i < 6; i++)
|
|
|
|
{
|
2013-12-20 22:09:09 +01:00
|
|
|
if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.DOWN, world))
|
2013-05-14 17:34:26 +02:00
|
|
|
{
|
|
|
|
world.spawnParticle("reddust", tileEntity.xCoord + random.nextDouble(), tileEntity.yCoord + -.01, tileEntity.zCoord + random.nextDouble(), 0, 0, 0);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.UP, world))
|
2013-05-14 17:34:26 +02:00
|
|
|
{
|
|
|
|
world.spawnParticle("reddust", tileEntity.xCoord + random.nextDouble(), tileEntity.yCoord + 1.01, tileEntity.zCoord + random.nextDouble(), 0, 0, 0);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.NORTH, world))
|
2013-05-14 17:34:26 +02:00
|
|
|
{
|
|
|
|
world.spawnParticle("reddust", tileEntity.xCoord + random.nextDouble(), tileEntity.yCoord + random.nextDouble(), tileEntity.zCoord + -.01, 0, 0, 0);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.SOUTH, world))
|
2013-05-14 17:34:26 +02:00
|
|
|
{
|
|
|
|
world.spawnParticle("reddust", tileEntity.xCoord + random.nextDouble(), tileEntity.yCoord + random.nextDouble(), tileEntity.zCoord + 1.01, 0, 0, 0);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.WEST, world))
|
2013-05-14 17:34:26 +02:00
|
|
|
{
|
|
|
|
world.spawnParticle("reddust", tileEntity.xCoord + -.01, tileEntity.yCoord + random.nextDouble(), tileEntity.zCoord + random.nextDouble(), 0, 0, 0);
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.EAST, world))
|
2013-05-14 17:34:26 +02:00
|
|
|
{
|
|
|
|
world.spawnParticle("reddust", tileEntity.xCoord + 1.01, tileEntity.yCoord + random.nextDouble(), tileEntity.zCoord + random.nextDouble(), 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
iteratedNodes.add(tileEntity);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
|
|
|
{
|
2013-12-20 22:09:09 +01:00
|
|
|
TileEntity tile = Coord4D.get(tileEntity).getFromSide(side).getTileEntity(pointer.worldObj);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
if(tile instanceof TileEntityDynamicTank && !iteratedNodes.contains(tile))
|
|
|
|
{
|
|
|
|
loop((TileEntityDynamicTank)tile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|