Esempio n. 1
0
        private bool Check(IBlockAccess world, BlockCoordinates position, BlockFace face, out int yOffset)
        {
            yOffset = 0;
            if (world.GetBlockState(position + face.GetBlockCoordinates()).Block is Rail)
            {
                return(true);
            }

            if (world.GetBlockState(position + BlockCoordinates.Up + face.GetBlockCoordinates()).Block is Rail)
            {
                yOffset = 1;
                return(true);
            }

            if (world.GetBlockState(position + BlockCoordinates.Down + face.GetBlockCoordinates()).Block is Rail)
            {
                yOffset = -1;
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        protected virtual bool ShouldRenderFace(IBlockAccess world, BlockFace face, BlockCoordinates position, Block me)
        {
            if (world == null)
            {
                return(true);
            }

            if (position.Y >= 256)
            {
                return(true);
            }

            if (face == BlockFace.None)
            {
                return(true);
            }

            var pos = position + face.GetBlockCoordinates();

            var cX = (int)pos.X & 0xf;
            var cZ = (int)pos.Z & 0xf;

            if (cX < 0 || cX > 16)
            {
                return(false);
            }

            if (cZ < 0 || cZ > 16)
            {
                return(false);
            }

            //if (!world.HasBlock(pos.X, pos.Y, pos.Z))
            //	return false;

            var theBlock = world.GetBlockState(pos).Block;

            if (!theBlock.Renderable)
            {
                return(true);
            }

            return(me.ShouldRenderFace(face, theBlock));
        }
Esempio n. 3
0
        internal virtual bool ShouldRenderFace(IWorld world, BlockFace face, BlockCoordinates position, IBlock me)
        {
            if (position.Y >= 256)
            {
                return(true);
            }

            var pos = position + face.GetBlockCoordinates();

            var cX = (int)pos.X & 0xf;
            var cZ = (int)pos.Z & 0xf;

            if (cX < 0 || cX > 16)
            {
                return(false);
            }

            if (cZ < 0 || cZ > 16)
            {
                return(false);
            }

            world.GetBlockData(pos.X, pos.Y, pos.Z, out bool blockTransparent, out bool blockSolid);

            if (me.Solid && me.Transparent)
            {
                //	if (IsFullCube && Name.Equals(block.Name)) return false;
                if (blockSolid && !blockTransparent)
                {
                    return(false);
                }
            }
            else if (me.Transparent)
            {
                if (blockSolid && !blockTransparent)
                {
                    return(false);
                }
                //if (blockTransparent) return true;
            }


            if (me.Solid && blockTransparent)
            {
                return(true);
            }
            //   if (me.Transparent && block.Transparent && !block.Solid) return false;
            if (me.Transparent)
            {
                return(true);
            }
            if (!me.Transparent && blockTransparent)
            {
                return(true);
            }
            if (blockSolid && !blockTransparent)
            {
                return(false);
            }
            if (me.Solid && blockSolid)
            {
                return(false);
            }

            return(true);
        }