Ejemplo 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();
            }
        }
Ejemplo n.º 2
0
        public static int GetSunlight(this IBlockAccessor blockAcessor, int posX, int posY, int posZ)
        {
            IWorldAccessor world    = (blockAcessor as BlockAccessorBase).GetField <BlockAccessorBase, IWorldAccessor>("worldAccessor");
            WorldMap       worldMap = (blockAcessor as BlockAccessorBase).GetField <BlockAccessorBase, WorldMap>("worldmap");

            IWorldChunk chunkAtBlockPos = blockAcessor.GetChunkAtBlockPos(posX, posY, posZ);

            if (chunkAtBlockPos == null || !worldMap.IsValidPos(posX, posY, posZ))
            {
                return(world.SunBrightness);
            }
            chunkAtBlockPos.Unpack();
            int chunkSize = blockAcessor.ChunkSize;
            int index     = (posY % chunkSize * chunkSize + posZ % chunkSize) * chunkSize + posX % chunkSize;
            int num       = (int)chunkAtBlockPos.Light[index];
            int val2      = num >> 5 & 31;
            int val1      = num & 31;

            return((int)Math.Round((double)val1 * (double)world.Calendar.GetDayLightStrength(posX, posZ)));
        }
Ejemplo n.º 3
0
 public override int GetLightAbsorption(IBlockAccessor blockAccessor, BlockPos pos)
 {
     return(GetLightAbsorption(blockAccessor.GetChunkAtBlockPos(pos), pos));
 }