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


Java Chunk.addTileEntity方法代码示例

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


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

示例1: setTileEntity

import net.minecraft.world.chunk.Chunk; //导入方法依赖的package包/类
public void setTileEntity(BlockPos pos, @Nullable TileEntity tileEntityIn)
{
    pos = pos.toImmutable(); // Forge - prevent mutable BlockPos leaks
    if (!this.isOutsideBuildHeight(pos))
    {
        if (tileEntityIn != null && !tileEntityIn.isInvalid())
        {
            if (this.processingLoadedTiles)
            {
                tileEntityIn.setPos(pos);
                if (tileEntityIn.getWorld() != this)
                    tileEntityIn.setWorldObj(this); // Forge - set the world early as vanilla doesn't set it until next tick
                Iterator<TileEntity> iterator = this.addedTileEntityList.iterator();

                while (iterator.hasNext())
                {
                    TileEntity tileentity = (TileEntity)iterator.next();

                    if (tileentity.getPos().equals(pos))
                    {
                        tileentity.invalidate();
                        iterator.remove();
                    }
                }

                this.addedTileEntityList.add(tileEntityIn);
            }
            else
            {
                this.addTileEntity(tileEntityIn);
                Chunk chunk = this.getChunkFromBlockCoords(pos); //Forge add NPE protection
                if (chunk != null) chunk.addTileEntity(pos, tileEntityIn);
            }
            this.updateComparatorOutputLevel(pos, getBlockState(pos).getBlock()); //Notify neighbors of changes
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:38,代码来源:World.java

示例2: loadEntities

import net.minecraft.world.chunk.Chunk; //导入方法依赖的package包/类
public void loadEntities(World worldIn, NBTTagCompound compound, Chunk chunk)
{
    NBTTagList nbttaglist1 = compound.getTagList("Entities", 10);

    if (nbttaglist1 != null)
    {
        for (int j1 = 0; j1 < nbttaglist1.tagCount(); ++j1)
        {
            NBTTagCompound nbttagcompound1 = nbttaglist1.getCompoundTagAt(j1);
            readChunkEntity(nbttagcompound1, worldIn, chunk);
            chunk.setHasEntities(true);
        }
    }

    NBTTagList nbttaglist2 = compound.getTagList("TileEntities", 10);

    if (nbttaglist2 != null)
    {
        for (int k1 = 0; k1 < nbttaglist2.tagCount(); ++k1)
        {
            NBTTagCompound nbttagcompound2 = nbttaglist2.getCompoundTagAt(k1);
            TileEntity tileentity = TileEntity.create(worldIn, nbttagcompound2);

            if (tileentity != null)
            {
                chunk.addTileEntity(tileentity);
            }
        }
    }

    if (compound.hasKey("TileTicks", 9))
    {
        NBTTagList nbttaglist3 = compound.getTagList("TileTicks", 10);

        if (nbttaglist3 != null)
        {
            for (int l1 = 0; l1 < nbttaglist3.tagCount(); ++l1)
            {
                NBTTagCompound nbttagcompound3 = nbttaglist3.getCompoundTagAt(l1);
                Block block;

                if (nbttagcompound3.hasKey("i", 8))
                {
                    block = Block.getBlockFromName(nbttagcompound3.getString("i"));
                }
                else
                {
                    block = Block.getBlockById(nbttagcompound3.getInteger("i"));
                }

                worldIn.scheduleBlockUpdate(new BlockPos(nbttagcompound3.getInteger("x"), nbttagcompound3.getInteger("y"), nbttagcompound3.getInteger("z")), block, nbttagcompound3.getInteger("t"), nbttagcompound3.getInteger("p"));
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:56,代码来源:AnvilChunkLoader.java


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