Exemplo n.º 1
0
        private bool IsBlocked(BlockCoordinates coord)
        {
            var block = _level.GetBlock(coord);

            if (block == null || block.IsSolid)
            {
                return(true);
            }
            return(false);
        }
 public static bool Prefix(ref bool __result, Block __instance, IBlockAccess _world, Vector3i _blockPos, BlockValue _blockValue)
 {
     if (__instance.isMultiBlock && _blockValue.ischild)
     {
         Vector3i   parentPos = __instance.multiBlockPos.GetParentPos(_blockPos, _blockValue);
         BlockValue block     = _world.GetBlock(parentPos);
         if (block.ischild)
         {
             __result = true;
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 3
0
        private bool IsBlocked(BlockCoordinates coord)
        {
            var block = _level.GetBlock(coord);

            if (block == null || block.IsSolid)
            {
                if (block is DoorBase door)
                {
                    //Log.Warn($"Found door at {coord} and it OpenBit set to {door.OpenBit}");
                    return(!door.OpenBit);
                }

                return(true);
            }
            return(false);
        }
Exemplo n.º 4
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.GetBlock(pos);

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

            return(me.ShouldRenderFace(face, theBlock));
        }
Exemplo n.º 5
0
 public static string GetBlockName(this IBlockAccess world, int x, int y, int z)
 {
     return(world.GetBlock(x, y, z).Name);
 }
Exemplo n.º 6
0
 public static Dictionary <string, string> GetBlockProperties(this IBlockAccess world, int x, int y, int z)
 {
     return((Dictionary <string, string>)world.GetBlock(x, y, z).Properties);
 }
Exemplo n.º 7
0
 private static bool IsTerrain(IBlockAccess world, Vector3i pos)
 {
     return(world.GetBlock(pos.x, pos.y, pos.z).Block.shape.IsTerrain());
 }
Exemplo n.º 8
0
        protected void GetLight(IBlockAccess world, Vector3 facePosition, out byte blockLight, out byte skyLight, bool smooth = false)
        {
            var faceBlock = world.GetBlock(facePosition);

            skyLight   = world.GetSkyLight(facePosition);
            blockLight = world.GetBlockLight(facePosition);

            //if (skyLight == 15 || blockLight == 15)
            //	return;

            if (!smooth && !faceBlock.Transparent && !(skyLight > 0 || blockLight > 0))
            {
                return;                // (byte)Math.Min(blockLight + skyLight, 15);
            }


            Vector3 lightOffset = Vector3.Zero;

            byte highestBlocklight = blockLight;
            byte highestSkylight   = skyLight;
            bool lightFound        = false;

            for (int i = 0; i < 6; i++)
            {
                switch (i)
                {
                case 0:
                    lightOffset = Vector3.Up;
                    break;

                case 1:
                    lightOffset = Vector3.Down;
                    break;

                case 2:
                    lightOffset = Vector3.Forward;
                    break;

                case 3:
                    lightOffset = Vector3.Backward;
                    break;

                case 4:
                    lightOffset = Vector3.Left;
                    break;

                case 5:
                    lightOffset = Vector3.Right;
                    break;
                }

                skyLight   = world.GetSkyLight(facePosition + lightOffset);
                blockLight = world.GetBlockLight(facePosition + lightOffset);

                if (skyLight > 0 || blockLight > 0)
                {
                    if (skyLight > 0)
                    {
                        lightFound = true;
                        break;
                    }
                    else if (blockLight > highestBlocklight)
                    {
                        highestBlocklight = blockLight;
                        highestSkylight   = skyLight;
                    }
                }
            }

            if (!lightFound)
            {
                skyLight = highestSkylight;
                if (highestBlocklight > 0)
                {
                    blockLight = (byte)(highestBlocklight - 1);
                }
                else
                {
                    blockLight = 0;
                }
            }

            //(byte)Math.Min(Math.Max(0, blockLight + skyLight), 15);
        }