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


Java ForgeHooks.canInteractWith方法代码示例

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


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

示例1: updateScreen

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public void updateScreen() {
  super.updateScreen();

  if (!ForgeHooks.canInteractWith(mc.thePlayer, inventorySlots)) {
    mc.thePlayer.closeScreen();
  }

  for (GuiTextField f : textFields) {
    f.updateCursorCounter();
  }
}
 
开发者ID:SleepyTrousers,项目名称:EnderCore,代码行数:13,代码来源:GuiContainerBase.java

示例2: onUpdate

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    this.theItemInWorldManager.updateBlockRemoving();
    --this.initialInvulnerability;
    this.openContainer.detectAndSendChanges();

    if (!this.worldObj.isRemote && !ForgeHooks.canInteractWith(this, this.openContainer))
    {
        this.closeScreen();
        this.openContainer = this.inventoryContainer;
    }

    while (!this.destroyedItemsNetCache.isEmpty())
    {
        int i = Math.min(this.destroyedItemsNetCache.size(), 127);
        int[] aint = new int[i];
        Iterator iterator = this.destroyedItemsNetCache.iterator();
        int j = 0;

        while (iterator.hasNext() && j < i)
        {
            aint[j++] = ((Integer)iterator.next()).intValue();
            iterator.remove();
        }

        this.playerNetServerHandler.sendPacketToPlayer(new Packet29DestroyEntity(aint));
    }

    if (!this.loadedChunks.isEmpty())
    {
        ArrayList arraylist = new ArrayList();
        Iterator iterator1 = this.loadedChunks.iterator();
        ArrayList arraylist1 = new ArrayList();

        while (iterator1.hasNext() && arraylist.size() < 5)
        {
            ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator1.next();
            iterator1.remove();

            if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4))
            {
                arraylist.add(this.worldObj.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos));
                //BugFix: 16 makes it load an extra chunk, which isn't associated with a player, which makes it not unload unless a player walks near it.
                //ToDo: Find a way to efficiently clean abandoned chunks.
                //arraylist1.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 16, 256, chunkcoordintpair.chunkZPos * 16 + 16));
                arraylist1.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 15, 256, chunkcoordintpair.chunkZPos * 16 + 15));
            }
        }

        if (!arraylist.isEmpty())
        {
            this.playerNetServerHandler.sendPacketToPlayer(new Packet56MapChunks(arraylist));
            Iterator iterator2 = arraylist1.iterator();

            while (iterator2.hasNext())
            {
                TileEntity tileentity = (TileEntity)iterator2.next();
                this.sendTileEntityToPlayer(tileentity);
            }

            iterator2 = arraylist.iterator();

            while (iterator2.hasNext())
            {
                Chunk chunk = (Chunk)iterator2.next();
                this.getServerForPlayer().getEntityTracker().func_85172_a(this, chunk);
                MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(chunk.getChunkCoordIntPair(), this));
            }
        }
    }

    if (this.field_143005_bX > 0L && this.mcServer.func_143007_ar() > 0 && MinecraftServer.getSystemTimeMillis() - this.field_143005_bX > (long)(this.mcServer.func_143007_ar() * 1000 * 60))
    {
        this.playerNetServerHandler.kickPlayerFromServer("You have been idle for too long!");
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:80,代码来源:EntityPlayerMP.java


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