Пример #1
0
        public void SetBlockState(BlockPos pos, BlockState state)
        {
            Chunk chunk = GetChunk(ChunkPos.FromWorldSpace(pos));

            if (chunk == null || !chunk.HasData)
            {
                return;
            }

            _worldLut.Put(state.Block.UnlocalizedName);

            chunk.SetBlockState(ChunkPos.ToChunkLocal(pos), state);
        }
Пример #2
0
        public virtual BlockState GetBlockState(BlockPos pos)
        {
            if (pos.Y < 0 || pos.Y >= Chunk.ChunkHeight)
            {
                return(BlockRegistry.GetBlock <BlockAir>().GetState());
            }

            Chunk chunk = GetChunk(ChunkPos.FromWorldSpace(pos));

            if (chunk == null || !chunk.HasData)
            {
                return(BlockRegistry.GetBlock <BlockAir>().GetState());
            }

            return(chunk.GetBlockState(ChunkPos.ToChunkLocal(pos)));
        }
Пример #3
0
        public virtual void SetBlockState(BlockPos pos, BlockState state)
        {
            Chunk chunk = GetChunk(ChunkPos.FromWorldSpace(pos));

            if (chunk == null || !chunk.HasData)
            {
                return;
            }

            _worldLut.Put(state.Block.UnlocalizedName);

            var localPos = ChunkPos.ToChunkLocal(pos);

            chunk.SetBlockState(localPos, state);

            if (state.Block.CreateTileEntity(this, pos) is TileEntity te)
            {
                chunk.AddTileEntity(localPos, te);
            }

            chunk.Save();
        }
Пример #4
0
 public override void RemoveTileEntity(BlockPos pos)
 {
     GetChunk(pos.ChunkPos())?.RemoveTileEntity(ChunkPos.ToChunkLocal(pos));
 }
Пример #5
0
 public void SaveTileEntity(BlockPos pos)
 {
     GetChunk(pos.ChunkPos())?.SaveTileEntity(ChunkPos.ToChunkLocal(pos));
 }
Пример #6
0
 public TileEntity GetTileEntity(BlockPos pos)
 {
     return(GetChunk(pos.ChunkPos())?.GetTileEntity(ChunkPos.ToChunkLocal(pos)));
 }