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


Java CommonUtils類代碼示例

本文整理匯總了Java中codechicken.lib.util.CommonUtils的典型用法代碼示例。如果您正苦於以下問題:Java CommonUtils類的具體用法?Java CommonUtils怎麽用?Java CommonUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: jamTile

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
private void jamTile() {
    if (world.isRemote || target == null)
        return;

    RedstoneEtherServer ether = (RedstoneEtherServer) this.ether;
    if (canhittarget) {
        TileEntity tile = RedstoneEther.getTile(world, target);
        if (tile == null || !(tile instanceof ITileWireless)) {
            ether.unjamTile(world, target.getX(), target.getY(), target.getZ());
            return;
        }
        ITileWireless wirelesstile = (ITileWireless) tile;
        int freq = wirelesstile.getFreq();
        if (freq == 0) {
            ether.unjamTile(world, target.getX(), target.getY(), target.getZ());
            return;
        }
        ether.jamNode(world, target, CommonUtils.getDimension(world), freq);
        wirelesstile.jamTile();
    } else {
        ether.unjamTile(world, target.getX(), target.getY(), target.getZ());
    }
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:24,代碼來源:WirelessBolt.java

示例2: verifyChunkTransmitters

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void verifyChunkTransmitters(World world, int chunkx, int chunkz)
{
    int dimension = CommonUtils.getDimension(world);
    DimensionalEtherHash ether = ethers.get(dimension);
    int blockxmin = chunkx * 16;
    int blockxmax = blockxmin + 15;
    int blockzmin = chunkz * 16;
    int blockzmax = blockzmin + 15;
    
    ArrayList<BlockPos> transmittingblocks = new ArrayList<>(ether.transmittingblocks.keySet());
    
    for(BlockPos node : transmittingblocks)
    {            
        if(node.getX() >= blockxmin && node.getX() <= blockxmax && node.getZ() >= blockzmin && node.getZ() <= blockzmax)
        {
            TileEntity tile = RedstoneEther.getTile(world, node);
            int freq = ether.transmittingblocks.get(node).freq;
            if(tile == null || !(tile instanceof ITileWireless) || ((ITileWireless)tile).getFreq() != freq)
            {
                remTransmitter(world, node, freq);
                System.out.println("Removed Badly Synced node at:"+node.getX()+","+node.getY()+","+node.getZ()+" on "+freq+" in dim"+dimension);
            }
        }
    }
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:26,代碼來源:RedstoneEtherServer.java

示例3: setTransmitter

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void setTransmitter(World world, BlockPos node, int freq, boolean on)
{
    if(freq == 0)
    {
        return;
    }

    int dimension = CommonUtils.getDimension(world);
    
    if(isNodeInAOEofJammer(node, dimension))
    {
        jamNodeSometime(world, node, dimension, freq);
    }
    TXNodeInfo info = ethers.get(dimension).transmittingblocks.get(node);
    if(info == null)
        ethers.get(dimension).transmittingblocks.put(node, new TXNodeInfo(freq, on));
    else
        info.on = on;
    freqarray[freq].setTransmitter(world, node, dimension, on);
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:21,代碼來源:RedstoneEtherServer.java

示例4: entityJamTest

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
private void entityJamTest(World world)
{
    if(world.getTotalWorldTime() % 10 != 0)
        return;
    
    int dimension = CommonUtils.getDimension(world);
    for(Iterator<BlockPos> iterator = ethers.get(dimension).jammerset.iterator(); iterator.hasNext();)
    {
        BlockPos jammer = iterator.next();
        List<Entity> entitiesinrange = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(jammer.getX()-9.5, jammer.getY()-9.5, jammer.getZ()-9.5, jammer.getX()+10.5, jammer.getY()+10.5, jammer.getZ()+10.5));
        for(Iterator<Entity> iterator2 = entitiesinrange.iterator(); iterator2.hasNext();)
        {
            Entity entity = iterator2.next();
            if(!(entity instanceof EntityLivingBase))
                continue;
            
            if(entity instanceof EntityPlayer)
                if(isPlayerJammed((EntityPlayer)entity))
                    continue;
            
            jamEntitySometime((EntityLivingBase) entity);
        }
    }
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:25,代碼來源:RedstoneEtherServer.java

示例5: loadDimension

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
@SuppressWarnings ("unchecked")
public void loadDimension(WorldServer world) {
    PacketCustom packet = new PacketCustom(channel, 2).compress();
    int dim = CommonUtils.getDimension(world);
    packet.writeInt(dim);

    Collection<Chunk> allchunks = world.getChunkProvider().getLoadedChunks();
    packet.writeInt(allchunks.size());
    for (Chunk chunk : allchunks) {
        packet.writeInt(chunk.x);
        packet.writeInt(chunk.z);
    }

    Map<Ticket, Collection<ChunkPos>> tickets = ForgeChunkManager.getPersistentChunksFor(world).inverse().asMap();
    packet.writeInt(tickets.size());
    for (Entry<Ticket, Collection<ChunkPos>> entry : tickets.entrySet()) {
        writeTicketToPacket(packet, entry.getKey(), entry.getValue());
    }

    packet.sendToPlayer(owner);
}
 
開發者ID:TheCBProject,項目名稱:ChickenChunks,代碼行數:22,代碼來源:PlayerChunkViewerTracker.java

示例6: remChunkLoader

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void remChunkLoader(IChickenChunkLoader loader) {
    int dim = CommonUtils.getDimension(loader.getLoaderWorld());
    if (dormant) {
        Set<BlockPos> coords = dormantLoaders.get(dim);
        if (coords != null) {
            coords.remove(loader.getPosition());
        }
    } else {
        Set<ChunkPos> chunks = forcedChunksByLoader.remove(loader);
        if (chunks == null) {
            return;
        }
        unforceChunks(loader, dim, chunks, true);
    }
    setDirty();
}
 
開發者ID:TheCBProject,項目名稱:ChickenChunks,代碼行數:17,代碼來源:ChunkLoaderManager.java

示例7: updateChunkLoader

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void updateChunkLoader(IChickenChunkLoader loader) {
    Set<ChunkPos> loaderChunks = forcedChunksByLoader.get(loader);
    if (loaderChunks == null) {
        addChunkLoader(loader);
        return;
    }
    HashSet<ChunkPos> oldChunks = new HashSet<>(loaderChunks);
    HashSet<ChunkPos> newChunks = new HashSet<>();
    for (ChunkPos chunk : loader.getChunks()) {
        if (!oldChunks.remove(chunk)) {
            newChunks.add(chunk);
        }
    }

    int dim = CommonUtils.getDimension(loader.getLoaderWorld());
    if (!oldChunks.isEmpty()) {
        unforceChunks(loader, dim, oldChunks, false);
    }
    if (!newChunks.isEmpty()) {
        forceChunks(loader, dim, newChunks);
    }
}
 
開發者ID:TheCBProject,項目名稱:ChickenChunks,代碼行數:23,代碼來源:ChunkLoaderManager.java

示例8: revive

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void revive(World world) {
    Set<BlockPos> coords = dormantLoaders.get(CommonUtils.getDimension(world));
    if (coords == null) {
        return;
    }

    //addChunkLoader will add to the coord set if we are dormant
    ArrayList<BlockPos> verifyCoords = new ArrayList<>(coords);
    coords.clear();

    for (BlockPos coord : verifyCoords) {
        reviving = true;
        TileEntity tile = world.getTileEntity(coord);
        reviving = false;
        if (tile instanceof IChickenChunkLoader) {
            ChunkLoaderManager.addChunkLoader((IChickenChunkLoader) tile);
        }
    }
}
 
開發者ID:TheCBProject,項目名稱:ChickenChunks,代碼行數:20,代碼來源:ChunkLoaderManager.java

示例9: dumpFile

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void dumpFile() {
    try {
        File file = new File(CommonUtils.getMinecraftDir(), "dumps/" + getFileName(name.replaceFirst(".+\\.", "")));
        if (!file.getParentFile().exists()) {
            file.getParentFile().mkdirs();
        }
        if (!file.exists()) {
            file.createNewFile();
        }

        dumpTo(file);

        NEIClientUtils.printChatMessage(dumpMessage(file));
    } catch (Exception e) {
        LogHelper.errorError("Error dumping " + renderName() + " mode: " + getMode(), e);
    }
}
 
開發者ID:TheCBProject,項目名稱:NotEnoughItems,代碼行數:18,代碼來源:DataDumper.java

示例10: loadServerWorld

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public static void loadServerWorld(World world) {
    int dimension = CommonUtils.getDimension(world);
    if (serverEther == null)
        new RedstoneEtherServer().init(world);

    serverEther.addEther(world, dimension);
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:8,代碼來源:RedstoneEther.java

示例11: saveEther

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void saveEther(World world)
{
    int dimension = CommonUtils.getDimension(world);
    if(!ethers.containsKey(dimension))
        return;
    
    for(RedstoneEtherFrequency freq : ethers.get(dimension).freqsToSave)
        freq.saveFreq(dimension);
    
    ethers.get(dimension).freqsToSave.clear();
    SaveManager.getInstance(dimension).removeTrailingSectors();
    SaveManager.saveDimensionHash();
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:14,代碼來源:RedstoneEtherServer.java

示例12: remTransmitter

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void remTransmitter(World world, BlockPos node, int freq)
{
    if(freq == 0)
    {
        return;
    }

    int dimension = CommonUtils.getDimension(world);
    
    ethers.get(dimension).jammednodes.remove(node);
    ethers.get(dimension).transmittingblocks.remove(node);
    freqarray[freq].remTransmitter(world, node, dimension);
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:14,代碼來源:RedstoneEtherServer.java

示例13: addReceiver

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void addReceiver(World world, BlockPos node, int freq)
{
    if(freq == 0)
        return;

    int dimension = CommonUtils.getDimension(world);
    
    if(isNodeInAOEofJammer(node, dimension))
    {
        jamNodeSometime(world, node, dimension, freq);
    }
    ethers.get(dimension).recievingblocks.put(node, freq);
    freqarray[freq].addReceiver(world, node, dimension);
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:15,代碼來源:RedstoneEtherServer.java

示例14: remReceiver

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void remReceiver(World world, BlockPos node, int freq)
{
    if(freq == 0)
        return;

    int dimension = CommonUtils.getDimension(world);

    ethers.get(dimension).jammednodes.remove(node);    
    ethers.get(dimension).recievingblocks.remove(node);
    freqarray[freq].remReceiver(world, node, dimension);
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:12,代碼來源:RedstoneEtherServer.java

示例15: addJammer

import codechicken.lib.util.CommonUtils; //導入依賴的package包/類
public void addJammer(World world, BlockPos jammer)
{
    int dimension = CommonUtils.getDimension(world);
    
    ethers.get(dimension).jammerset.add(jammer);
    jamNodesInAOEOfJammer(world, jammer, dimension);        
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:8,代碼來源:RedstoneEtherServer.java


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