當前位置: 首頁>>代碼示例>>Java>>正文


Java Effect.getType方法代碼示例

本文整理匯總了Java中org.bukkit.Effect.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java Effect.getType方法的具體用法?Java Effect.getType怎麽用?Java Effect.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Effect的用法示例。


在下文中一共展示了Effect.getType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: playEffect

import org.bukkit.Effect; //導入方法依賴的package包/類
@Override
public void playEffect( Location location, Effect effect, int id, int data, float offsetX, float offsetY, float offsetZ, float speed, int particleCount, int radius )
{
    Validate.notNull( location, "Location cannot be null" );
    Validate.notNull( effect, "Effect cannot be null" );
    Validate.notNull( location.getWorld(), "World cannot be null" );
    net.minecraft.network.Packet packet;
    if ( effect.getType() != Effect.Type.PARTICLE )
    {
        int packetData = effect.getId();
        packet = new net.minecraft.network.play.server.S28PacketEffect( packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), id, false );
    } else
    {
        StringBuilder particleFullName = new StringBuilder();
        particleFullName.append( effect.getName() );
        if ( effect.getData() != null && ( effect.getData().equals( net.minecraft.block.material.Material.class ) || effect.getData().equals( org.bukkit.material.MaterialData.class ) ) )
        {
            particleFullName.append( '_' ).append( id );
        }
        if ( effect.getData() != null && effect.getData().equals( org.bukkit.material.MaterialData.class ) )
        {
            particleFullName.append( '_' ).append( data );
        }
        packet = new net.minecraft.network.play.server.S2APacketParticles( particleFullName.toString(), (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, particleCount );
    }
    int distance;
    radius *= radius;
    for ( Player player : getPlayers() )
    {
        if ( ( (CraftPlayer) player ).getHandle().playerNetServerHandler == null )
        {
            continue;
        }
        if ( !location.getWorld().equals( player.getWorld() ) )
        {
            continue;
        }
        distance = (int) player.getLocation().distanceSquared( location );
        if ( distance <= radius )
        {
            ( (CraftPlayer) player ).getHandle().playerNetServerHandler.sendPacket( packet );
        }
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:45,代碼來源:CraftWorld.java


注:本文中的org.bukkit.Effect.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。