2013-12-27 23:59:59 +01:00
|
|
|
package appeng.server;
|
|
|
|
|
|
|
|
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.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2014-08-03 06:53:34 +02:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-02-20 05:20:38 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-08-03 06:53:34 +02:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
2014-02-16 22:28:50 +01:00
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.world.World;
|
2014-08-03 06:53:34 +02:00
|
|
|
import appeng.api.parts.CableRenderMode;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.block.AEBaseBlock;
|
2014-02-23 23:50:53 +01:00
|
|
|
import appeng.client.EffectType;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.core.CommonHelper;
|
2014-02-09 02:34:52 +01:00
|
|
|
import appeng.core.sync.AppEngPacket;
|
|
|
|
import appeng.core.sync.network.NetworkHandler;
|
2014-08-03 06:53:34 +02:00
|
|
|
import appeng.items.tools.ToolNetworkTool;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.util.Platform;
|
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
|
|
|
|
|
|
public class ServerHelper extends CommonHelper
|
|
|
|
{
|
|
|
|
|
2014-02-20 05:20:38 +01:00
|
|
|
@Override
|
2014-07-07 04:04:58 +02:00
|
|
|
public void doRenderItem(ItemStack sis, World tile)
|
2014-02-20 05:20:38 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@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)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
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 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-04-20 03:41:43 +02:00
|
|
|
@Override
|
|
|
|
public void postinit()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@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..." );
|
|
|
|
}
|
|
|
|
|
2014-01-28 18:29:17 +01:00
|
|
|
@Override
|
2014-07-09 10:17:11 +02:00
|
|
|
public void spawnEffect(EffectType type, World worldObj, double posX, double posY, double posZ, Object o)
|
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;
|
|
|
|
}
|
|
|
|
|
2014-02-16 22:28:50 +01:00
|
|
|
@Override
|
|
|
|
public MovingObjectPosition getMOP()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-08-03 06:53:34 +02:00
|
|
|
@Override
|
|
|
|
public CableRenderMode getRenderMode()
|
|
|
|
{
|
|
|
|
if ( renderModeBased == null )
|
|
|
|
return CableRenderMode.Standard;
|
|
|
|
|
|
|
|
return renderModeForPlayer( renderModeBased );
|
|
|
|
}
|
|
|
|
|
|
|
|
private EntityPlayer renderModeBased;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateRenderMode(EntityPlayer player)
|
|
|
|
{
|
|
|
|
renderModeBased = player;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected CableRenderMode renderModeForPlayer(EntityPlayer player)
|
|
|
|
{
|
|
|
|
if ( player != null )
|
|
|
|
{
|
|
|
|
for (int x = 0; x < InventoryPlayer.getHotbarSize(); x++)
|
|
|
|
{
|
|
|
|
ItemStack is = player.inventory.getStackInSlot( x );
|
|
|
|
|
|
|
|
if ( is != null && is.getItem() instanceof ToolNetworkTool )
|
|
|
|
{
|
|
|
|
NBTTagCompound c = is.getTagCompound();
|
|
|
|
if ( c != null && c.getBoolean( "hideFacades" ) )
|
|
|
|
return CableRenderMode.CableView;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CableRenderMode.Standard;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void triggerUpdates()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-08-03 19:00:53 +02:00
|
|
|
@Override
|
|
|
|
public void missingCoreMod()
|
|
|
|
{
|
2014-09-21 01:40:57 +02:00
|
|
|
throw new RuntimeException( "Unable to Load Core Mod, please verify that AE2 is properly install in the mods folder, with a .jar extension." );
|
2014-08-03 19:00:53 +02:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|