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


Java Chunk.removeEntity方法代码示例

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


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

示例1: 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.removeEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。