Exemplo n.º 1
0
        public virtual void PlaceDecors(IBlockAccessor blockAccessor, BlockPos startPos, bool synchronize)
        {
            BlockPos curPos = new BlockPos();

            for (int i = 0; i < DecorIndices.Count; i++)
            {
                uint index         = DecorIndices[i];
                int  storedBlockid = DecorIds[i];
                byte faceIndex     = (byte)(storedBlockid >> 24);
                if (faceIndex > 5)
                {
                    continue;
                }
                BlockFacing face = BlockFacing.ALLFACES[faceIndex];
                storedBlockid &= 0xFFFFFF;

                int dx = (int)(index & 0x1ff);
                int dy = (int)((index >> 20) & 0x1ff);
                int dz = (int)((index >> 10) & 0x1ff);

                AssetLocation blockCode = BlockCodes[storedBlockid];

                Block newBlock = blockAccessor.GetBlock(blockCode);

                if (newBlock == null)
                {
                    continue;
                }

                curPos.Set(dx + startPos.X, dy + startPos.Y, dz + startPos.Z);

                IWorldChunk chunk = blockAccessor.GetChunkAtBlockPos(curPos);
                if (chunk == null)
                {
                    continue;
                }
                if (synchronize)
                {
                    blockAccessor.MarkChunkDecorsModified(curPos);
                }
                chunk.SetDecor(blockAccessor, newBlock, curPos, face);
                chunk.MarkModified();
            }
        }