当前位置: 首页>>代码示例>>Java>>正文


Java Chunk.getEntityLists方法代码示例

本文整理汇总了Java中net.minecraft.world.chunk.Chunk.getEntityLists方法的典型用法代码示例。如果您正苦于以下问题:Java Chunk.getEntityLists方法的具体用法?Java Chunk.getEntityLists怎么用?Java Chunk.getEntityLists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.world.chunk.Chunk的用法示例。


在下文中一共展示了Chunk.getEntityLists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: affectChunk

import net.minecraft.world.chunk.Chunk; //导入方法依赖的package包/类
@Override
public void affectChunk(World world) {
	
	Chunk chunk = world.getChunkFromChunkCoords(chunkPos.x, chunkPos.z);
	
	for (int i = 0; i < chunk.getEntityLists().length; i++) {
		if (chunk.getEntityLists()[i] != null) {
			for (EntityAnimal e : chunk.getEntityLists()[i].getByClass(EntityAnimal.class)) {
				if (world.rand.nextInt(3) == 0) {
					e.addTag(TAG);
				}
			}
		}
	}

}
 
开发者ID:the-realest-stu,项目名称:Etheric,代码行数:17,代码来源:InfertilityEvent.java

示例2: fetchDormantChunk

import net.minecraft.world.chunk.Chunk; //导入方法依赖的package包/类
public static Chunk fetchDormantChunk(long coords, World world)
{
    if (dormantChunkCacheSize == 0) return null; // Don't bother with maps at all if its never gonna get a response
    Cache<Long, Chunk> cache = dormantChunkCache.get(world);
    if (cache == null)
    {
        return null;
    }
    Chunk chunk = cache.getIfPresent(coords);
    if (chunk != null)
    {
        for (ClassInheritanceMultiMap<Entity> eList : chunk.getEntityLists())
        {
            Iterator<Entity> itr = eList.iterator();
            while (itr.hasNext())
            {
                (itr.next()).resetEntityId();
            }
        }
    }
    return chunk;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:ForgeChunkManager.java

示例3: onChunkUnload

import net.minecraft.world.chunk.Chunk; //导入方法依赖的package包/类
@SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload event) {
    Chunk chunk = event.getChunk();
    for (int i = 0; i < chunk.getEntityLists().length; ++i) {
        for (Object o : chunk.getEntityLists()[i]) {
            if (o instanceof EntityWirelessTracker)
                ((EntityWirelessTracker) o).onChunkUnload();
        }
    }
}
 
开发者ID:TheCBProject,项目名称:WirelessRedstone,代码行数:11,代码来源:WREventHandler.java

示例4: onMessage

import net.minecraft.world.chunk.Chunk; //导入方法依赖的package包/类
@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data)
{
    super.onMessage(messageType, data);
    // This message will be sent to us once the server has decided the mission is over.
    if (messageType == MalmoMessageType.SERVER_STOPAGENTS)
    {
        this.quitCode = data.containsKey("QuitCode") ? data.get("QuitCode") : "";
        try
        {
            // Save the quit code for anything that needs it:
            MalmoMod.getPropertiesForCurrentThread().put("QuitCode", this.quitCode);
        }
        catch (Exception e)
        {
            System.out.println("Failed to get properties - final reward may go missing.");
        }
        // Get the final reward data:
        ClientAgentConnection cac = currentMissionInit().getClientAgentConnection();
        if (currentMissionBehaviour() != null && currentMissionBehaviour().rewardProducer != null && cac != null)
            currentMissionBehaviour().rewardProducer.getReward(currentMissionInit(), ClientStateMachine.this.finalReward);

        onMissionEnded(ClientState.MISSION_ENDED, null);
    }
    else if (messageType == MalmoMessageType.SERVER_GO)
    {
        // First, force all entities to get re-added to their chunks, clearing out any old entities in the process.
        // We need to do this because the process of teleporting all agents to their start positions, combined
        // with setting them to/from spectator mode, leaves the client chunk entity lists etc in a parlous state.
        List lel = Minecraft.getMinecraft().theWorld.loadedEntityList;
        for (int i = 0; i < lel.size(); i++)
        {
            Entity entity = (Entity)lel.get(i);
            Chunk chunk = Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(entity.chunkCoordX, entity.chunkCoordZ);
            List<Entity> entitiesToRemove = new ArrayList<Entity>();
            for (int k = 0; k < chunk.getEntityLists().length; k++)
            {
                Iterator iterator = chunk.getEntityLists()[k].iterator();
                while (iterator.hasNext())
                {
                    Entity chunkent = (Entity)iterator.next();
                    if (chunkent.getEntityId() == entity.getEntityId())
                    {
                        entitiesToRemove.add(chunkent);
                    }
                }
            }
            for (Entity removeEnt : entitiesToRemove)
            {
                chunk.removeEntity(removeEnt);
            }
            entity.addedToChunk = false;    // Will force it to get re-added to the chunk list.
        }
        this.serverHasFiredStartingPistol = true; // GO GO GO!
    }
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:57,代码来源:ClientStateMachine.java


注:本文中的net.minecraft.world.chunk.Chunk.getEntityLists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。