Applied-Energistics-2-tiler.../server/ServerHelper.java

112 lines
2.4 KiB
Java
Raw Normal View History

package appeng.server;
import java.util.ArrayList;
import java.util.List;
2014-01-30 03:47:55 +01:00
import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
import appeng.client.EffectType;
import appeng.core.CommonHelper;
2014-02-09 02:34:52 +01:00
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.NetworkHandler;
import appeng.util.Platform;
import cpw.mods.fml.common.FMLCommonHandler;
public class ServerHelper extends CommonHelper
{
@Override
public void doRenderItem(ItemStack sis, TileEntity tile)
{
}
@Override
public List<EntityPlayer> getPlayers()
{
if ( !Platform.isClient() )
{
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if ( server != null )
return server.getConfigurationManager().playerEntityList;
}
return new ArrayList();
}
@Override
2014-02-09 02:34:52 +01:00
public void sendToAllNearExcept(EntityPlayer p, double x, double y, double z, double dist, World w, AppEngPacket packet)
{
if ( Platform.isClient() )
return;
for (EntityPlayer o : getPlayers())
{
EntityPlayerMP entityplayermp = (EntityPlayerMP) o;
if ( entityplayermp != p && entityplayermp.worldObj == w )
{
double dX = x - entityplayermp.posX;
double dY = y - entityplayermp.posY;
double dZ = z - entityplayermp.posZ;
if ( dX * dX + dY * dY + dZ * dZ < dist * dist )
{
2014-02-09 02:34:52 +01:00
NetworkHandler.instance.sendTo( packet, entityplayermp );
}
}
}
}
@Override
public void init()
{
}
@Override
public void postinit()
{
}
@Override
public World getWorld()
{
throw new RuntimeException( "This is a server..." );
}
@Override
public void bindTileEntitySpecialRenderer(Class tile, AEBaseBlock blk)
{
throw new RuntimeException( "This is a server..." );
}
@Override
public void spawnEffect(EffectType type, World worldObj, double posX, double posY, double posZ)
2014-01-28 20:27:22 +01:00
{
// :P
}
2014-01-30 03:47:55 +01:00
@Override
public boolean shouldAddParticles(Random r)
{
return false;
}
@Override
public MovingObjectPosition getMOP()
{
return null;
}
}